git clone https://garage44.eu/jeroen/midas.gitcartopolis-agent · 2026-11-21T20:36:59Z
chore: no address or path of one workspace as a default For readers of the public repository: the node daemon, the push hook and the page's dev proxy fell back to 10.44.0.1:4791, the network diagram printed that address as a label, the session hook and the ssh config knew /home/agent, and a tool description named cartopolis.org. The node falls back to what any client uses (MIDAS_HUB, hub.conf, loopback); the push hook does nothing until MIDAS_HUB is set; the dev proxy defaults to loopback; the diagram shows the address the hub reports in /v1/state (and "hub" from an older one); paths come from $HOME; the example is example.org.
hooks/git-post-receive | 4 +++-
hooks/session-start | 2 +-
src/hub.rs | 7 ++++++-
src/mcp.rs | 2 +-
src/node.rs | 4 +++-
src/sshcfg.rs | 9 ++++++---
web/build.ts | 2 +-
web/src/components/network.tsx | 4 +++-
web/src/lib/types.ts | 2 ++
9 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/hooks/git-post-receive b/hooks/git-post-receive
index 6dd24cd..33e3365 100755
--- a/hooks/git-post-receive
+++ b/hooks/git-post-receive
@@ -13,7 +13,9 @@
# It fails open: a short timeout and always exit 0. The push it reports has
# already happened, and a hub that is down must never read as a push error.
-hub="${MIDAS_HUB:-http://10.44.0.1:4791}"
+# The hub's address, as docs/hub.md says to set it where this hook is installed.
+hub="${MIDAS_HUB:-}"
+[ -n "$hub" ] || exit 0
# The repository as owner/name, from where git runs the hook: its directory.
dir=$(pwd -P)
diff --git a/hooks/session-start b/hooks/session-start
index 5bd6521..4ecefc5 100755
--- a/hooks/session-start
+++ b/hooks/session-start
@@ -9,7 +9,7 @@
# midas and cargo are one binary. If it lives somewhere a container
# recreate does not empty (MIDAS_BIN, where deploy.sh puts it), link the names.
-BIN=${MIDAS_BIN:-/home/agent/cargo-target/midas/bin/midas}
+BIN=${MIDAS_BIN:-$HOME/cargo-target/midas/bin/midas}
if [ -x "$BIN" ]; then
mkdir -p "$HOME/.local/bin" 2>/dev/null
for name in midas cargo; do
diff --git a/src/hub.rs b/src/hub.rs
index 0414c1f..5ad3abc 100644
--- a/src/hub.rs
+++ b/src/hub.rs
@@ -509,7 +509,12 @@ fn api(method: &str, path: &str, query: &str, body: &Value, who: &Who, peer: &st
Some(p) => json!({"caller": p.caller, "account": p.account, "role": p.role}),
None => json!({"caller": null, "account": null, "role": null}),
})),
- ("GET", "state") => return Ok((200, registry::snapshot()?)),
+ ("GET", "state") => {
+ // With the hub's own address and build, for the page's network diagram.
+ let mut st = registry::snapshot()?;
+ st["hub"] = json!({"listen": crate::conf::hub().listen, "version": crate::VERSION});
+ return Ok((200, st));
+ }
// Paired devices (device.rs), with the tools each announced: no tokens.
("GET", "devices") => return Ok((200, json!({"devices": crate::device::list()}))),
// Remote MCP servers (remote.rs), with the tools each announced: no tokens.
diff --git a/src/mcp.rs b/src/mcp.rs
index 2328ce5..9c8386e 100644
--- a/src/mcp.rs
+++ b/src/mcp.rs
@@ -193,7 +193,7 @@ fn tools() -> Vec<Value> {
json!({"in": s("how long from now: 90m, 4h, 1d, 1d12h"), "at": s("or when: a date, a clock time and its offset from UTC, 2026-10-30T09:00+01:00"),
"text": s("what to do then, in words this session will read"), "cancel": json!({"type": "boolean", "description": "drop the time set instead"})}), &[]),
tool("session_await", "Wait on the person for something only they can do before this session can go on: paste a token, add a DNS record, register an OAuth app. The Midas hub page lists the session under Needs you, with what it waits for, the steps and, for a secret, a field whose value goes straight to where it is used (never to you), until they give it, put it off or decline; midas then tells this session. Call it instead of ending a turn on a request in prose, and before landing without finishing for such a step. One per session; setting it again replaces it. With done, it waits on nothing any more (the person gave it in a reply). Only in a session started from the page.",
- json!({"text": s("what you wait for, in a line: Paste a cartopolis.org token"), "steps": s("the steps to it, as short Markdown (a numbered list, with links)"),
+ json!({"text": s("what you wait for, in a line: Paste an API token for example.org"), "steps": s("the steps to it, as short Markdown (a numbered list, with links)"),
"secret": s("when it is a secret, where it goes: remote:<name> (a remote MCP server's token) or bot:<node or group>:<NAME>"),
"url": s("for remote:<name> the hub does not have yet: its MCP endpoint, https://…/mcp"),
"done": json!({"type": "boolean", "description": "it waits on nothing any more"})}), &[]),
diff --git a/src/node.rs b/src/node.rs
index 06f76a0..e511402 100644
--- a/src/node.rs
+++ b/src/node.rs
@@ -59,7 +59,9 @@ pub(crate) fn config() -> Config {
let num = |k: &str, d: f64| m.get(k).and_then(|v| v.parse().ok()).unwrap_or(d);
Config {
node: m.get("MIDAS_NODE").cloned().unwrap_or_else(|| "unknown".into()),
- hub: m.get("MIDAS_HUB").cloned().unwrap_or_else(|| "http://10.44.0.1:4791".into()),
+ // The installer writes MIDAS_HUB; without it, what any client would use
+ // (MIDAS_HUB in the environment, else hub.conf, else loopback).
+ hub: m.get("MIDAS_HUB").cloned().unwrap_or_else(crate::client::hub_url),
warn_pct: num("MIDAS_GUARD_WARN", 80.0),
stop_pct: num("MIDAS_GUARD_STOP", 92.0),
recipe: m.get("MIDAS_RECIPE").filter(|r| !r.is_empty()).cloned(),
diff --git a/src/sshcfg.rs b/src/sshcfg.rs
index 7a56431..1c533b6 100644
--- a/src/sshcfg.rs
+++ b/src/sshcfg.rs
@@ -57,9 +57,12 @@ pub fn known_hosts(nodes: &[serde_json::Value]) -> String {
pub fn block_for(nodes: &[serde_json::Value], o: &Opts) -> String {
let mut b = vec![BEGIN.to_string()];
let me = crate::util::exe().map(|p| p.to_string_lossy().to_string()).unwrap_or_else(|_| "midas".into());
- // ~/.local/bin/midas rather than the volume path the exe resolves to, when
- // that is how this machine reaches it (a recreate keeps the symlink's name).
- let me = if Path::new("/home/agent/.local/bin/midas").exists() { "/home/agent/.local/bin/midas".to_string() } else { me };
+ // ~/.local/bin/midas rather than the path the exe resolves to, when that
+ // link is how this machine reaches it: a container recreate keeps the
+ // link's name while the volume path behind it may change.
+ let link = std::env::var("HOME").map(|h| format!("{h}/.local/bin/midas")).unwrap_or_default();
+ let same = |a: &str, b: &str| fs::canonicalize(a).ok().is_some_and(|x| fs::canonicalize(b).ok() == Some(x));
+ let me = if !link.is_empty() && same(&link, &me) { link } else { me };
let aliases: Vec<&str> = nodes.iter().filter_map(|n| n["id"].as_str()).collect();
if o.flush {
// First, so its settings win (ssh keeps the first value it reads): a
diff --git a/web/build.ts b/web/build.ts
index dd4ef9d..23ba1a0 100644
--- a/web/build.ts
+++ b/web/build.ts
@@ -13,7 +13,7 @@ import path from 'node:path'
const root = import.meta.dir
const dist = path.join(root, 'dist')
const serve = process.argv.includes('--serve')
-const HUB = process.env.MIDAS_HUB || 'http://10.44.0.1:4791'
+const HUB = process.env.MIDAS_HUB || 'http://127.0.0.1:4791'
const PORT = Number(process.env.PORT || 3200)
async function build() {
diff --git a/web/src/components/network.tsx b/web/src/components/network.tsx
index 7e66ce1..d962516 100644
--- a/web/src/components/network.tsx
+++ b/web/src/components/network.tsx
@@ -148,9 +148,11 @@ export class Network extends Measured<{workspace: WorkspaceState}> {
const hubBottom = hub.y + TOP_H
// A box of less than 180 px says the short form of each line.
const narrow = (phone ? half : third) < 180
+ // Where the hub listens, as the state says; a hub from before it said so shows as "hub".
+ const hubAt = $s.workspace?.hub?.listen ?? ''
const top = [
{title: 'agents', lines: [`${holding} holding`, `${waiting} waiting`]},
- {title: 'hub', lines: [narrow && !phone ? '10.44.0.1' : '10.44.0.1:4791', narrow && !phone ? $s.hubVersion : `midas ${$s.hubVersion}`]},
+ {title: 'hub', lines: [narrow && !phone ? (hubAt.split(':')[0] || 'hub') : (hubAt || 'hub'), narrow && !phone ? $s.hubVersion : `midas ${$s.hubVersion}`]},
{title: 'deploys', lines: deployLines($s.deploys, narrow)},
]
diff --git a/web/src/lib/types.ts b/web/src/lib/types.ts
index 9389ca4..7b34c40 100644
--- a/web/src/lib/types.ts
+++ b/web/src/lib/types.ts
@@ -66,6 +66,8 @@ export interface LandingTurn {
}
export interface WorkspaceState {
+ /** The hub itself: where it listens on the tunnel, and its build. */
+ hub?: {listen: string; version: string}
nodes: Node[]
leases: Record<string, Lease>
waiters: Record<string, Waiter>