@staix/agent-hub 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +2 -2
- package/docs/operations.md +64 -19
- package/docs/quickstart.md +1 -1
- package/docs/security.md +3 -2
- package/docs/smoke.md +54 -0
- package/docs/specs/2026-09-19-agent-hub-design.md +42 -5
- package/package.json +1 -1
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/server.js +1 -1
- package/src/adapters/local-worker.ts +4 -3
- package/src/cli/main.ts +1 -0
- package/src/hub/ask.ts +7 -2
- package/src/hub/board.ts +3 -1
- package/src/hub/config-trust.ts +1 -1
- package/src/hub/crash.ts +10 -5
- package/src/hub/daemon.ts +78 -20
- package/src/hub/tasks.ts +48 -15
- package/src/local/deny.ts +2 -2
- package/src/local/proxy.ts +169 -0
- package/src/local/sandbox.ts +66 -39
- package/src/local/tools.ts +4 -2
- package/templates/config.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
Issue and pull request numbers in the entries for 0.7.7 and earlier refer to the previous repository, archived on 2026-09-30 when this repository's history was rewritten; the one exception is the open smoke-check issue, formerly #12, which moved here as #1. Numbers in newer entries refer to this repository.
|
|
4
4
|
|
|
5
|
+
## 0.12.0
|
|
6
|
+
|
|
7
|
+
- The egress proxy logs every refusal: an oversized request header and an unreachable listed host now leave a `network: refused` line too, the latter with its error code, never the error text; a failure after the tunnel opened closes the connection instead of writing an HTTP answer into it (#81).
|
|
8
|
+
- Behind NAT64 with the well-known prefix `64:ff9b::/96`, the egress proxy judges an answer by the IPv4 address it carries, so a listed name that resolves to an internal IPv4 host through DNS64 is refused; the local-use prefix `64:ff9b:1::/48` is refused outright, and a scoped IPv6 address (`fe80::1%en0`) counts as internal. A network-specific NAT64 prefix is not recognised (#82).
|
|
9
|
+
- `local.sandbox: "allow-default"` is removed: the local worker's and Pi's commands always run under the deny-default sandbox, and a project that still sets it starts normally with a note in `hub.log` and `ahub doctor` (paths a toolchain needs go in `local.read_allow`). `local.bash_network: "direct"` still works until 0.13.0, with the same note naming that release (#83).
|
|
10
|
+
|
|
11
|
+
## 0.11.0
|
|
12
|
+
|
|
13
|
+
- Task operations settle model-written arguments before anything reaches the board: an `owner` or `peer` that is not a peer id, or a task id that is not a whole number, is refused with a clear message instead of leaving an ownerless task behind after a database error; `null` and an empty owner mean no owner (#70).
|
|
14
|
+
- Review outcomes are credited to the work they judged in more cases: task paths are stored in one spelling (`./src/a.ts` and `src/a.ts` are one file for blame, and `.` blames nobody), and handing a task to the owner it already has keeps an earlier catch; ownership events now record the owner in the task history (#67).
|
|
15
|
+
- After a crash, `pi.auto_start` brings Pi back on its recorded headless session, with or without `recovery.auto_resume_after_crash`, and on a fresh session (on the recorded backend and model) if that resume fails; before, a fresh Pi started and the recorded session could not be resumed while it ran (#66).
|
|
16
|
+
- Tests cover a refused `hub_send` from the local worker and from Pi, a Pi resumed after `kill -9` on the session file the dead run recorded, and the crash report for Codex and Claude (#68).
|
|
17
|
+
- Model-written text on an ordinary task is screened before it leaves the hub: a done summary, a review note, an unmet item or a budget handoff that matches a PII pattern is not saved to claude-mem, and every peer (the local worker included) gets a stub naming `ahub task show <id>`; the board keeps the text, and `ahub ask` shows such a note only on campus (#69).
|
|
18
|
+
- With `local.bash_network` on, the local worker's commands can read Python's own CA bundle (`certifi/cacert.pem`, also vendored by pip), so `pip install` and `requests` work over HTTPS; every other `.pem` stays denied (#64).
|
|
19
|
+
- Each command the local worker runs gets a temp dir of its own (`TMPDIR`), removed when it ends, a timeout or kill included; under deny-default the shared temp dirs (the user's and `/private/tmp`) are closed, so a command can no longer read what other tools left there (#63).
|
|
20
|
+
- Under deny-default, Apple's `/usr/bin` shims (python3 among them) work with a full Xcode selected: the sandbox opens the app's whole `Contents`, since its tools load `SharedFrameworks`; 0.10.0 opened only `Contents/Developer`, so they worked with the Command Line Tools only.
|
|
21
|
+
- With `local.bash_network: true` the local worker's and Pi's commands reach the network only through the hub's egress proxy: HTTPS to the hosts in `local.network_allow` (machine-local; by default the npm, PyPI, crates.io and Go module registries and GitHub), with names that resolve to internal addresses refused and each policy refusal logged by method and host; direct egress and loopback to claude-mem or the Codex app-server are denied. `"direct"` keeps the open network for one release (#65).
|
|
22
|
+
|
|
5
23
|
## 0.10.0
|
|
6
24
|
|
|
7
25
|
- Review checklists and review outcomes: review requests ask the reviewer to map signatures and call sites to the plan, read the check result and list unmet items (`hub_review {unmet}`); the hub records approved, caught, contradicted and escalated reviews per implementer, reviewer and class, shown by `ahub task show` and `ahub route explain`, and `review.adaptive` (off by default) orders reviewers by that record, after idle before busy and ahead of quota. A record counts tasks, a catch belongs to the owner whose work was caught, and only a failure on the same file or symbol contradicts an approval (#35).
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Native multi-agent hub for one developer's machine: Claude Code, Codex, Kimi Cod
|
|
|
4
4
|
hub-owned local-LLM worker collaborate as peers in independent project directories, with
|
|
5
5
|
task-aware model routing (Switchyard) in front of a self-hosted gateway (OmniRoute).
|
|
6
6
|
|
|
7
|
-
Status: 0.
|
|
7
|
+
Status: 0.12.0, control protocol 10. Durable delivery records distinguish queued
|
|
8
8
|
work from uncertain execution. The [smoke checklist](docs/smoke.md) records
|
|
9
9
|
verified paths and remaining prerequisites.
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ cd <your project> && ahub init && ahub up && ahub tail
|
|
|
28
28
|
Or install the same version from GitHub:
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
bun add -g github:STAIxBWLB/agent-hub#v0.
|
|
31
|
+
bun add -g github:STAIxBWLB/agent-hub#v0.12.0 && ahub setup
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
The installed commands remain `ahub` and `agent-hub`.
|
package/docs/operations.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Operations guide
|
|
2
2
|
|
|
3
|
-
This guide describes ahub 0.
|
|
3
|
+
This guide describes ahub 0.12.0 and control protocol 10. Live verification
|
|
4
4
|
results and remaining prerequisites are recorded separately in [the smoke ledger](smoke.md).
|
|
5
5
|
|
|
6
6
|
## Install and start
|
|
@@ -27,7 +27,7 @@ what the hub runs, which files it sends as credentials, where task text goes,
|
|
|
27
27
|
or how far the local worker's sandbox reaches (`kimi_cmd`, `codex_bin`,
|
|
28
28
|
`pi.cmd`, `checks`, `mlx.bin`, `mlx.runtimeDir`, `mlx.modelPath`, `omniroute.urls`,
|
|
29
29
|
`omniroute.access_hosts`, the `omniroute` key files, `memory.worker_url`,
|
|
30
|
-
`local.read_allow`, `local.bash_network`, `local.sandbox`) are machine-local:
|
|
30
|
+
`local.read_allow`, `local.bash_network`, `local.network_allow`, `local.sandbox`) are machine-local:
|
|
31
31
|
they apply only from a file git confirms nobody committed. Put them in
|
|
32
32
|
`.agenthub/config.local.json` (`ahub init` adds it to `.gitignore`), which is
|
|
33
33
|
read after `config.json`; outside a git repository they keep their defaults, and
|
|
@@ -35,12 +35,36 @@ an empty value always means the default.
|
|
|
35
35
|
|
|
36
36
|
The local worker's commands run under a sandbox that starts from deny default
|
|
37
37
|
(0.10): they may run and read the system, toolchain and project directories and
|
|
38
|
-
the selected Xcode or Command Line Tools dir (`xcode-select -p
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
the selected Xcode or Command Line Tools dir (`xcode-select -p`; for an Xcode
|
|
39
|
+
app, its whole `Contents`, whose `SharedFrameworks` its tools load), write the
|
|
40
|
+
project and a temp dir of their own (`TMPDIR`, made for each command and
|
|
41
|
+
removed when it ends; one left by a hub crash, named `ahub-cmd-*`, goes with
|
|
42
|
+
the OS temp cleanup), and nothing else; the shared temp dirs are closed.
|
|
43
|
+
|
|
44
|
+
Network is off unless `local.bash_network` says otherwise. With `true` it goes
|
|
45
|
+
only through the hub's egress proxy on a loopback port (0.11): commands get
|
|
46
|
+
`HTTPS_PROXY` and the other proxy variables, the proxy opens HTTPS (`CONNECT`,
|
|
47
|
+
port 443 unless an entry names one) to the hosts in `local.network_allow`, and
|
|
48
|
+
the profile denies every other connection, direct egress and other loopback
|
|
49
|
+
ports (claude-mem's, the Codex app-server's) included. A listed name also
|
|
50
|
+
covers its subdomains; a name that resolves to a loopback or private address is
|
|
51
|
+
refused, and so is plain HTTP. Behind NAT64 with the well-known prefix
|
|
52
|
+
`64:ff9b::/96`, the IPv4 address inside the answer is what counts; the local-use
|
|
53
|
+
prefix `64:ff9b:1::/48` is refused outright, so on a network whose DNS64 uses it
|
|
54
|
+
an IPv4-only host such as github.com is refused too; use `"direct"` there (it is
|
|
55
|
+
removed in 0.13.0). A network-specific NAT64 prefix is not recognised. Every
|
|
56
|
+
refusal is a `network: refused` line in `hub.log`, by host where one is known
|
|
57
|
+
(with the method for plain HTTP, and the error code when a listed host is
|
|
58
|
+
unreachable), never a path, query or header. The default list holds the npm, PyPI, crates.io and Go module
|
|
59
|
+
registries and GitHub's code hosts; set `local.network_allow` in
|
|
60
|
+
`config.local.json` to replace it. `"direct"` keeps the open network of 0.10 and
|
|
61
|
+
earlier until 0.13.0, which removes it; while it is set, `hub.log` and `ahub
|
|
62
|
+
doctor` say so. With network on, commands may also read the public CA
|
|
63
|
+
bundles and Python's `certifi/cacert.pem`, which the `*.pem` key deny would
|
|
64
|
+
otherwise hide.
|
|
65
|
+
The allow-default profile of 0.9 and earlier was removed in 0.12.0: a
|
|
66
|
+
`local.sandbox` setting is ignored (`"allow-default"` with a note in `hub.log`
|
|
67
|
+
and `ahub doctor`), and a toolchain the profile lacks goes in `local.read_allow`. Newly closed outside home: `/Applications`
|
|
44
68
|
(an app's bundled CLI), `/nix`, `/Volumes` and `/Users/Shared`. A toolchain
|
|
45
69
|
there, or elsewhere in your home (a CI tool cache, a version manager the profile
|
|
46
70
|
does not list), needs its directory in `local.read_allow`, for example
|
|
@@ -425,8 +449,8 @@ source and carries every recovery fix released up to it. Protocol 8 and older
|
|
|
425
449
|
project directory, without replacing the global CLI first:
|
|
426
450
|
|
|
427
451
|
```bash
|
|
428
|
-
bunx --package @staix/agent-hub@0.
|
|
429
|
-
bunx --package @staix/agent-hub@0.
|
|
452
|
+
bunx --package @staix/agent-hub@0.12.0 ahub upgrade --to 0.12.0 --dry-run
|
|
453
|
+
bunx --package @staix/agent-hub@0.12.0 ahub upgrade --to 0.12.0 --yes
|
|
430
454
|
```
|
|
431
455
|
|
|
432
456
|
| Running now | Coordinator to use |
|
|
@@ -449,26 +473,29 @@ no blocker, and `--yes` stops at staging ("target protocol requires a newer
|
|
|
449
473
|
coordinator") with an operation left to clear by `ahub recovery abort <id>`. An
|
|
450
474
|
older 0.7.x CLI may lack recovery fixes released after it. The
|
|
451
475
|
[smoke ledger](smoke.md) records dry-runs from real 0.6.4 and 0.7.5 hubs (issue
|
|
452
|
-
#75)
|
|
453
|
-
0.8.1 hub with tasks and a budget pause
|
|
476
|
+
#75) and these applied upgrades: one with the 0.7.0 coordinator; one with the
|
|
477
|
+
0.9.0 coordinator from a running 0.8.1 hub with tasks and a budget pause; one
|
|
478
|
+
with the 0.10.0 coordinator from a 0.9.0 hub (one completion check running and
|
|
479
|
+
one queued); and one with the 0.11.0 coordinator from a 0.10.0 hub with
|
|
480
|
+
`local.bash_network` on.
|
|
454
481
|
|
|
455
482
|
The coordinator verifies and retains the exact target package, preserves its
|
|
456
483
|
own source, and promotes the global CLI only after restored projects pass
|
|
457
484
|
readback.
|
|
458
485
|
|
|
459
|
-
Once the installed CLI is 0.
|
|
486
|
+
Once the installed CLI is 0.12.0, review the current project or all registered
|
|
460
487
|
projects first:
|
|
461
488
|
|
|
462
489
|
```bash
|
|
463
490
|
ahub restart --dry-run
|
|
464
|
-
ahub upgrade --to 0.
|
|
491
|
+
ahub upgrade --to 0.12.0 --dry-run
|
|
465
492
|
```
|
|
466
493
|
|
|
467
494
|
Apply only after reviewing the plan:
|
|
468
495
|
|
|
469
496
|
```bash
|
|
470
497
|
ahub restart --yes
|
|
471
|
-
ahub upgrade --to 0.
|
|
498
|
+
ahub upgrade --to 0.12.0 --yes
|
|
472
499
|
ahub recovery status <operation-id>
|
|
473
500
|
ahub recovery resume <operation-id>
|
|
474
501
|
ahub recovery abort <operation-id>
|
|
@@ -494,11 +521,25 @@ to 0 to opt out.
|
|
|
494
521
|
0.10.0 changes every project's local worker: its commands run under the
|
|
495
522
|
deny-default sandbox described above, and a toolchain outside the listed
|
|
496
523
|
directories needs `local.read_allow`; `"local": { "sandbox": "allow-default" }`
|
|
497
|
-
in `config.local.json`
|
|
524
|
+
in `config.local.json` restored the old profile until 0.12.0. Off unless set:
|
|
498
525
|
`review.adaptive`, `recovery.auto_resume_after_crash` and `capabilities`. A hub
|
|
499
526
|
before 0.10.0 keeps no session record, so a crash of one is not reported as such
|
|
500
527
|
by the next start.
|
|
501
528
|
|
|
529
|
+
0.11.0 changes what `local.bash_network: true` means: the local worker's and
|
|
530
|
+
Pi's commands reach the network only through the hub's egress proxy, to the
|
|
531
|
+
hosts in `local.network_allow` (package registries and GitHub's code hosts by
|
|
532
|
+
default). `local.network_allow` is machine-local and replaces the default list:
|
|
533
|
+
a project that needs another host sets it in `config.local.json` with the
|
|
534
|
+
defaults it still needs. `"direct"` keeps the open network of 0.10.0 until
|
|
535
|
+
0.13.0. Each command gets a temp dir of its own, and under deny-default the
|
|
536
|
+
shared temp dirs are closed.
|
|
537
|
+
|
|
538
|
+
0.12.0 removes `local.sandbox: "allow-default"`: a project that still sets it
|
|
539
|
+
runs under the deny-default sandbox, and `hub.log` and `ahub doctor` say so.
|
|
540
|
+
`local.bash_network: "direct"` still works until 0.13.0, and both name it while
|
|
541
|
+
it is set.
|
|
542
|
+
|
|
502
543
|
The 0.7.0 transition stages the verified package and runs a retained
|
|
503
544
|
coordinator from the source tree. It accepts a verified protocol-9 source and
|
|
504
545
|
moves to a protocol-10 target. The source journal, queued envelopes, tasks,
|
|
@@ -537,9 +578,13 @@ crash of one is not reported this way.
|
|
|
537
578
|
hub starts them again: Kimi loads its recorded session (ACP `session/load`), Pi
|
|
538
579
|
resumes its session file, and the local worker starts without its history, on
|
|
539
580
|
its recorded route (or pinned model). Off by default: the report then says
|
|
540
|
-
what to start.
|
|
541
|
-
|
|
542
|
-
|
|
581
|
+
what to start. With `pi.auto_start` on, Pi comes back on its recorded
|
|
582
|
+
headless session whether or not auto-resume is on (it runs on-prem, so this
|
|
583
|
+
spends no cloud quota), and on a fresh session if that fails, keeping the
|
|
584
|
+
recorded backend and model; the report says which. Malformed records in
|
|
585
|
+
`sessions.json` are skipped. A Pi that ran in a terminal (`--mode tui`) is never started on its
|
|
586
|
+
recorded session by the hub; the report gives the command, and with
|
|
587
|
+
`pi.auto_start` a fresh headless Pi starts instead.
|
|
543
588
|
- Codex's app-server died with the hub; run `ahub codex` again. Claude Code's
|
|
544
589
|
plugin reconnects by itself while that session is open.
|
|
545
590
|
|
package/docs/quickstart.md
CHANGED
package/docs/security.md
CHANGED
|
@@ -7,14 +7,15 @@ agent-hub connects agents that can each run commands. This page says what the hu
|
|
|
7
7
|
- **Other agents' text is untrusted.** Every message that crosses from one peer to another is framed as untrusted input (a channel tag with `meta.source` for Claude, a fixed header line plus a standing instruction for the others). A message body cannot forge the hub's own headers: such lines are quoted (`sanitize`). Replies inherit a hop count capped at 3, so agents cannot ping-pong forever; neither a digest nor a steer can reset it.
|
|
8
8
|
- **The control link is loopback plus a secret.** The daemon and the Codex proxy bind 127.0.0.1 only. The control WebSocket requires a per-run token (`.agenthub/state/control-token`, mode 600), and both servers refuse any request that carries an `Origin` header: any web page can open a WebSocket to localhost, and browsers always send `Origin`. External clients cannot claim the console user's id or a hub-managed peer's id.
|
|
9
9
|
- **Permission prompts stay on.** `ahub claude` and `ahub codex` add nothing that weakens the agents' own prompts. Kimi's and `local`'s permission requests are relayed to the console and cancelled after `approvals.timeout_s` (default 120 s) of silence; the macOS notification for a waiting request carries the peer and the tool name only. The one exception is the hub's own tools (`hub_send` and the task tools, matched by exact name): Kimi's requests for them are approved once without a prompt and logged by name, the same trust Codex gets through `approval_mode` in the hub's config. They touch no file and run no process, and every call passes the hub's own checks. The match relies on the agent putting the tool name in the request's `title`, as Kimi does; an ACP agent that titles calls with model-written text must not be configured as `kimi_cmd`. A payload longer than the console shows is marked as cut and never offers a session-wide grant. `--unattended` turns prompts off, says so loudly, and is never the default.
|
|
10
|
-
- **A committed config cannot choose launch commands, credential files, data endpoints or a wider sandbox.** The machine-local fields (`kimi_cmd`, `codex_bin`, `pi.cmd`, `checks`, `mlx.bin`, `mlx.runtimeDir`, `mlx.modelPath`, `omniroute.urls`, `omniroute.access_hosts`, the `omniroute` key files, `memory.worker_url`, `local.read_allow`, `local.bash_network`) apply only from a config file git confirms nobody committed: `.agenthub/config.json` or `.agenthub/config.local.json`, matched by file identity so no other spelling the file system accepts slips past, and `.agenthub` itself not a committed symlink or submodule. Without a repository, or when git fails, they keep their defaults; an empty value always means the default. "Untracked" is answered by the repository that contains the project: a checkout copied or extracted into an unrelated repository, or into an ignored directory of one, is trusted like your own files. So a cloned repository cannot choose a launch command, a completion check, a gateway to send a key file to, a memory endpoint, or a wider sandbox. A command in `checks` runs as you, outside the local worker's sandbox, like a git hook. Nothing in `routing.toml` or in task text is ever run. `routing.toml` and the other shared fields still come from the checkout, and they matter: `routing.toml` picks the models the local worker and the hub's inference use at your gateway and can turn the PII constraint off, and roles and budget shape who does what. Review them in a repository you do not trust.
|
|
10
|
+
- **A committed config cannot choose launch commands, credential files, data endpoints or a wider sandbox.** The machine-local fields (`kimi_cmd`, `codex_bin`, `pi.cmd`, `checks`, `mlx.bin`, `mlx.runtimeDir`, `mlx.modelPath`, `omniroute.urls`, `omniroute.access_hosts`, the `omniroute` key files, `memory.worker_url`, `local.read_allow`, `local.bash_network`, `local.network_allow`) apply only from a config file git confirms nobody committed: `.agenthub/config.json` or `.agenthub/config.local.json`, matched by file identity so no other spelling the file system accepts slips past, and `.agenthub` itself not a committed symlink or submodule. Without a repository, or when git fails, they keep their defaults; an empty value always means the default. "Untracked" is answered by the repository that contains the project: a checkout copied or extracted into an unrelated repository, or into an ignored directory of one, is trusted like your own files. So a cloned repository cannot choose a launch command, a completion check, a gateway to send a key file to, a memory endpoint, or a wider sandbox. A command in `checks` runs as you, outside the local worker's sandbox, like a git hook. Nothing in `routing.toml` or in task text is ever run. `routing.toml` and the other shared fields still come from the checkout, and they matter: `routing.toml` picks the models the local worker and the hub's inference use at your gateway and can turn the PII constraint off, and roles and budget shape who does what. Review them in a repository you do not trust.
|
|
11
11
|
- **Telemetry holds no bodies.** `.agenthub/state/events.jsonl` (issue #40) records envelope ids, routing and sizes, task ids and states, overlapping paths and token counts. It never records a message body, a task title or detail, and marks private (PII) envelopes and tasks as such. It stays on the machine; `ahub export` only prints it.
|
|
12
12
|
- **Snapshots stay in your repository.** Per-turn snapshots (issue #33) are git objects in the project's own object store, written through a temporary index; nothing is referenced, pushed or copied elsewhere, and `git gc` prunes them. They hold what the work tree held, including untracked files that are not ignored, so keep secrets in ignored files. They carry the repository's own permissions, and nothing caps their disk use but `git gc`. A turn of a peer holding an open PII task is not snapshotted; a PII file left in the project is snapshotted by later turns like any other file. `ahub undo` restores only files whose current content is exactly what the turn left.
|
|
13
13
|
- **The edit hook reads, never decides.** `ahub check-path --hook` (issue #32) reads hub.db and returns context for Claude and a line for you; it sets no permission decision, so your permission rules stay in charge. It names other owners' task ids, titles and states, which then reach Claude's model; PII tasks are left out.
|
|
14
14
|
- **The session record holds identities only.** `.agenthub/state/sessions.json` (issue #37, mode 600) keeps each attached peer's recovery metadata: launch options, session and thread ids, Pi's session file path. No message or task text; loss notices name deliveries by id, sender and public task title.
|
|
15
|
-
- **The local worker is boxed in.** Paths are resolved through symlinks and must stay inside the project; a secrets denylist (`.env*`, keys, credential files, the hub's own state) applies to its file tools, its git arguments and its memory capture alike; `.git` and `.agenthub` are not writable. Writes, edits, shell commands and mutating git wait for approval, and the approver sees what will be written or run, with control characters escaped. Everything it executes runs under the macOS sandbox, attended or not. Since 0.10 the profile starts from deny default (issue #39): commands run and read only the system, toolchain and project directories (and the project's git dir
|
|
15
|
+
- **The local worker is boxed in.** Paths are resolved through symlinks and must stay inside the project; a secrets denylist (`.env*`, keys, credential files, the hub's own state) applies to its file tools, its git arguments and its memory capture alike; `.git` and `.agenthub` are not writable. Writes, edits, shell commands and mutating git wait for approval, and the approver sees what will be written or run, with control characters escaped. Everything it executes runs under the macOS sandbox, attended or not. Since 0.10 the profile starts from deny default (issue #39): commands run and read only the system, toolchain and project directories (and the project's git dir and the selected developer dir; with network on, the public CA bundles); no writes outside the project, its git dir and a temp dir of its own (`TMPDIR`, made for each command and removed when it ends; issue #63); no `.git/hooks` or `.git/config` writes; no network, loopback included, unless `local.bash_network`; with it, only through the hub's egress proxy to the hosts in `local.network_allow` (issue #65), which refuses names that resolve to internal addresses (behind NAT64 with the well-known prefix, by the IPv4 address the answer carries; a network-specific prefix is not recognised), so claude-mem and the Codex app-server stay out of reach (`"direct"` opens everything, until 0.13.0). One channel stays open: `trustd`, which TLS clients need, can fetch a certificate's AIA or OCSP URL on a command's behalf, outside the proxy. The allow-default profile of 0.9 and earlier was removed in 0.12.0 (issue #83); a `local.sandbox` setting is ignored with a note. The shared temp dirs (the user's and `/private/tmp`) are closed. Without the sandbox there is no `bash` tool.
|
|
16
16
|
- **Capabilities are enforced, not suggested.** `capabilities` (issue #39) is checked by the daemon where task operations and messages arrive, so a peer cannot get round it by phrasing. A peer can never answer a permission request: the control link takes `permit` from the console role only, and a message that quotes a permit command is just text. Both bind the hub's own tool paths: a vendor agent with its own shell in the project (Codex, Claude, Kimi) can read `.agenthub/state/control-token` and connect as the console, which only the local worker's and Pi's sandbox prevents.
|
|
17
17
|
- **PII has an enforced path.** A task matching `signals.pii_patterns` goes to `local` or to nobody; its text is absent from other peers' envelopes, the console stream, the log and the board listing; the console user reviews it; `local` answers such a turn to the console only, keeps it out of its history, refuses it when the only gateway is off campus, and may not save notes or spin off tasks during it. Nothing about it is sent to claude-mem, whose observer is a cloud model.
|
|
18
|
+
- **Free text is screened too.** On an ordinary task, a done summary (with its check output: a match withholds the whole note), a review note, an unmet item or a budget handoff that matches a PII pattern (issue #69) is not saved to claude-mem, and every peer, `local` included, gets a stub naming `ahub task show <id>`; the board keeps the text, `hub.log` notes the withholding by task id only, and `ahub ask` shows such a note only when its model is reached on campus. `hub_remember` refuses a match; what a vendor agent writes to its own memory is not screened.
|
|
18
19
|
- **Secrets stay where they are read.** The gateway key and Cloudflare Access values are read inside the gateway client and go only into request headers: never into logs, errors, envelopes, tool output, memory, or the generated Switchyard config (the key travels by environment variable name). Subscription logins of Claude, Codex and Kimi are never proxied or pooled.
|
|
19
20
|
- **The hub's own model calls are fenced.** Digest condensation and task triage read agent-written text as data; their output is capped text framed as untrusted, or a value checked against a closed list. It is never used as a route, a peer id, a tool call or an instruction.
|
|
20
21
|
|
package/docs/smoke.md
CHANGED
|
@@ -937,3 +937,57 @@ configured or running, and no peer was attached at the upgrade.
|
|
|
937
937
|
- For about two minutes after the publish step logged `+ @staix/agent-hub@0.9.0`,
|
|
938
938
|
`npm view` still showed `latest: 0.8.1`; the registry caught up without any
|
|
939
939
|
action.
|
|
940
|
+
|
|
941
|
+
## 0.9.0 to 0.10.0 attended upgrade (2026-10-01)
|
|
942
|
+
|
|
943
|
+
A scratch project (a git work tree initialized by the 0.9.0 `ahub init`) ran a
|
|
944
|
+
0.9.0 hub with tasks on its board and a completion check for the review class, set in
|
|
945
|
+
`.agenthub/config.local.json` (`"review": "sleep 40"`, timeout 120 s). No peer
|
|
946
|
+
was attached. Times are UTC.
|
|
947
|
+
|
|
948
|
+
- At 05:54:46 the console marked task #1 done, which started its 40 s check.
|
|
949
|
+
`bunx --package @staix/agent-hub@0.10.0 ahub upgrade --to 0.10.0 --yes` right
|
|
950
|
+
after, about 90 s after the publish, failed with "registry metadata
|
|
951
|
+
unavailable for @staix/agent-hub@0.10.0" and scheduled nothing; the 0.9.0 hub
|
|
952
|
+
kept running. This is the registry lag from the 0.9.0 entry, met here as an
|
|
953
|
+
error instead of a stale `npm view`.
|
|
954
|
+
- At 05:55:03 the console marked task #3 done, which queued its check behind
|
|
955
|
+
#1's (checks run one at a time), and `--yes` was applied in the same second.
|
|
956
|
+
Its plan listed one project, source 0.9.0, no blockers. The source did not
|
|
957
|
+
commit while a check was running or queued: #1's passed at 05:55:26 and #3's
|
|
958
|
+
at 05:56:07, the source committed and stopped at 05:56:07.1, and the 0.10.0
|
|
959
|
+
hub was up at 05:56:07.7. The operation, global install included, completed
|
|
960
|
+
at 05:56:15.
|
|
961
|
+
- After release the hub ran 0.10.0 under a new instance id. All three tasks
|
|
962
|
+
were on the board with their full history (#1 and #3 approved by their
|
|
963
|
+
checks, #2 still proposed), and no history entry recorded an interrupted
|
|
964
|
+
check.
|
|
965
|
+
- The coordinator promoted the global CLI to 0.10.0, and `ahub setup --yes`
|
|
966
|
+
installed the 0.10.0 plugin.
|
|
967
|
+
|
|
968
|
+
## 0.10.0 to 0.11.0 attended upgrade (2026-10-01)
|
|
969
|
+
|
|
970
|
+
A scratch project (a git work tree initialized by the 0.10.0 `ahub init`) ran a
|
|
971
|
+
0.10.0 hub with `"local": { "bash_network": true }` in
|
|
972
|
+
`.agenthub/config.local.json`, two tasks (#1 with the path spelled `./a.txt`),
|
|
973
|
+
and an open budget pause: a peer had attached once and gone offline, and `ahub
|
|
974
|
+
budget set` fed it a 95% reading. No peer was attached at the upgrade. Times are
|
|
975
|
+
UTC, from `hub.log` and the operation record.
|
|
976
|
+
|
|
977
|
+
- 0.11.0 was published at 08:43:45 (the registry's `time` field); a
|
|
978
|
+
cache-busting registry read, observed at the console at 08:43:58, showed it
|
|
979
|
+
as `latest`. `bunx --package @staix/agent-hub@0.11.0 ahub
|
|
980
|
+
upgrade --to 0.11.0 --dry-run` then listed one project, source 0.10.0, protocol
|
|
981
|
+
10, no blockers.
|
|
982
|
+
- `--yes` created the operation at 08:44:19.4. The source committed at 08:44:19.5
|
|
983
|
+
and stopped; the 0.11.0 hub started its egress proxy (13 allowed hosts) at
|
|
984
|
+
08:44:19.7, found the pause still open with its reset time, and was up at
|
|
985
|
+
08:44:19.7. The operation, global install and plugin install included,
|
|
986
|
+
completed at 08:44:27.7.
|
|
987
|
+
- The tasks' refs and history and the pause row's columns, dumped with `sqlite3`
|
|
988
|
+
before and after (the latter once the 0.11.0 hub was up), were byte-identical: #1 still reads `./a.txt` (0.11.0 normalizes paths only on new
|
|
989
|
+
writes).
|
|
990
|
+
- Through the proxy, `curl` reached registry.npmjs.org (200, observed at the
|
|
991
|
+
console: the proxy logs no successes) and was refused example.com, logged as `network: refused example.com:443 (example.com:443 is
|
|
992
|
+
not in local.network_allow)`.
|
|
993
|
+
- After `ahub setup --yes`, `claude plugin list` showed the 0.11.0 plugin.
|
|
@@ -1037,6 +1037,15 @@ session modes (`default`, `plan`, `auto`, `yolo`) but nothing per server or tool
|
|
|
1037
1037
|
`min_reviews` by held, others keep their place, and the implementer is never
|
|
1038
1038
|
a candidate. The record is applied after quota, so the order is idle before
|
|
1039
1039
|
busy, then the record, then quota.
|
|
1040
|
+
- Task paths are stored in one spelling (issue #67): no leading `./`, no repeated
|
|
1041
|
+
or trailing `/`, the root as `.`; older rows are compared in that spelling.
|
|
1042
|
+
Blame needs the same path, so a directory never blames the files under it,
|
|
1043
|
+
though two tasks that both claim the same directory still blame each other: a
|
|
1044
|
+
path does not say whether it is a directory. Existing rows are never
|
|
1045
|
+
rewritten.
|
|
1046
|
+
Ownership events (`assigned`, `escalated`, `reassigned`, `unassigned`) record
|
|
1047
|
+
the owner they leave, so a reassignment to the same owner does not end the
|
|
1048
|
+
window in which a catch counts; rows written before keep the old rule.
|
|
1040
1049
|
|
|
1041
1050
|
## Amendment: recovery after an unplanned stop (issue #37)
|
|
1042
1051
|
|
|
@@ -1051,6 +1060,12 @@ session modes (`default`, `plan`, `auto`, `yolo`) but nothing per server or tool
|
|
|
1051
1060
|
journal rows stay in `needs_review`, shown by `ahub queue list`), and the first
|
|
1052
1061
|
attach rewrites the record with only the attached peers. A Pi in TUI mode is
|
|
1053
1062
|
reported with its command, not resumed: the CLI runs its terminal.
|
|
1063
|
+
- `pi.auto_start` (issue #66) counts as consent to start Pi after a crash too:
|
|
1064
|
+
crash recovery, not the plain auto-start, starts it, on the recorded headless
|
|
1065
|
+
session first and with a `fresh` start (one that does not inherit the failed
|
|
1066
|
+
launch's pending session, keeps the recorded backend and model) if that fails
|
|
1067
|
+
or nothing headless was recorded. If crash recovery itself fails, the plain
|
|
1068
|
+
auto-start runs after all.
|
|
1054
1069
|
- Resume goes through the same start path as `ahub kimi` / `ahub pi` / `ahub
|
|
1055
1070
|
local`: Kimi with `sessionId` (ACP `session/load`, refused when the agent does
|
|
1056
1071
|
not offer `loadSession`), Pi with its session file, the local worker afresh.
|
|
@@ -1070,18 +1085,23 @@ session modes (`default`, `plan`, `auto`, `yolo`) but nothing per server or tool
|
|
|
1070
1085
|
(`/usr`, `/bin`, `/sbin`, `/System`, `/Library`, `/opt`, `/private/etc`, the
|
|
1071
1086
|
dyld and timezone databases), the toolchain directories in home, `read_allow`,
|
|
1072
1087
|
the project, its external git dirs, the selected developer dir (`xcode-select
|
|
1073
|
-
-p`) and temp
|
|
1088
|
+
-p`) and a temp dir made for each command (issue #63; the shared user temp
|
|
1089
|
+
dir and `/private/tmp` are not open); writes to the project, its git dirs and
|
|
1090
|
+
that temp dir; a short list of mach services (directory
|
|
1074
1091
|
lookups, logging, notifications), plus name resolution and TLS trust when
|
|
1075
1092
|
network is on, the trust being the public CA bundles allowed by exact path
|
|
1076
|
-
after the denies (the `*.pem` key deny matches them)
|
|
1093
|
+
after the denies (the `*.pem` key deny matches them), and any path ending in
|
|
1094
|
+
`/certifi/cacert.pem` (Python's own bundle, issue #64); no brokers that act
|
|
1077
1095
|
outside the sandbox (LaunchServices, SecurityServer). The denies at the end (credential
|
|
1078
1096
|
stores, the denylist, `.agenthub`, git hooks and config) are shared by both
|
|
1079
1097
|
bases.
|
|
1080
1098
|
- The issue's allowlist proxy for `local.bash_network` is not built here: with
|
|
1081
|
-
the flag on, network is allowed as in 0.9 and earlier.
|
|
1082
|
-
|
|
1099
|
+
the flag on, network is allowed as in 0.9 and earlier. Issue #65 builds it
|
|
1100
|
+
(amendment below).
|
|
1083
1101
|
- `local.sandbox` ("deny-default" | "allow-default") is machine-local, since
|
|
1084
|
-
"allow-default" widens the sandbox.
|
|
1102
|
+
"allow-default" widens the sandbox. Removed in 0.12.0 (issue #83): the field is
|
|
1103
|
+
ignored with a note in `hub.log` and `ahub doctor`, and is no longer
|
|
1104
|
+
machine-local because nothing reads it.
|
|
1085
1105
|
- Capabilities: `propose`, `assign` (a proposal naming another peer as owner),
|
|
1086
1106
|
`remember`, `important`. A peer not listed in `capabilities` has all of them,
|
|
1087
1107
|
which keeps today's behaviour, and a listed peer whose value is not a list has
|
|
@@ -1092,3 +1112,20 @@ session modes (`default`, `plan`, `auto`, `yolo`) but nothing per server or tool
|
|
|
1092
1112
|
`important` is checked where messages are admitted, the others in the task
|
|
1093
1113
|
operations, so in-process tools (the local worker, Pi) are covered too.
|
|
1094
1114
|
|
|
1115
|
+
## Amendment: egress proxy for the local worker (issue #65)
|
|
1116
|
+
|
|
1117
|
+
- With `local.bash_network: true` the daemon runs an HTTP `CONNECT` proxy on a
|
|
1118
|
+
loopback port for the hub run (`src/local/proxy.ts`, built-ins only). The
|
|
1119
|
+
profile allows outbound network only to that port, looks up TLS trust but no
|
|
1120
|
+
DNS (the proxy resolves), and commands get the proxy variables.
|
|
1121
|
+
- The proxy opens a tunnel only to a host in `local.network_allow`
|
|
1122
|
+
(machine-local): a name also covers its subdomains, an address only itself,
|
|
1123
|
+
port 443 unless an entry names one (`host:port`). A name that resolves to a
|
|
1124
|
+
loopback, private, link-local or carrier-grade NAT address is refused; an
|
|
1125
|
+
address is reached only when listed. Plain HTTP is refused. No TLS
|
|
1126
|
+
interception. Each refusal is logged with the host only.
|
|
1127
|
+
- Decisions recorded in the issue: the default list holds the npm, Yarn, PyPI,
|
|
1128
|
+
crates.io and Go module registries and GitHub's code hosts, so a project that
|
|
1129
|
+
already had network on keeps installing packages; `"direct"` keeps the open
|
|
1130
|
+
network of 0.10 and earlier until 0.13.0 (issue #83).
|
|
1131
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-hub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Channel between Claude Code and the agent-hub daemon: peer messages from Codex, Kimi and the local worker arrive as channel events; hub_send replies.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Young Joon Lee",
|
|
@@ -15727,7 +15727,7 @@ class ControlClient {
|
|
|
15727
15727
|
// package.json
|
|
15728
15728
|
var package_default = {
|
|
15729
15729
|
name: "@staix/agent-hub",
|
|
15730
|
-
version: "0.
|
|
15730
|
+
version: "0.12.0",
|
|
15731
15731
|
description: "Native multi-agent hub: Claude Code, Codex, Kimi Code, Pi and local inference as peers in one project",
|
|
15732
15732
|
license: "MIT",
|
|
15733
15733
|
type: "module",
|
|
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { renderDigest, replyAudience, replyParent, STANDING_INSTRUCTION, USER, type Envelope, type EnvelopeOpts, type PeerId } from "../hub/envelope.ts";
|
|
3
3
|
import { TASK_TOOL_NAMES, TASK_TOOLS } from "../hub/hub-tools.ts";
|
|
4
4
|
import { BasePeer } from "../hub/peers.ts";
|
|
5
|
-
import { profile } from "../local/sandbox.ts";
|
|
5
|
+
import { profile, proxyEnv, type SandboxNetwork } from "../local/sandbox.ts";
|
|
6
6
|
import { runTool, TOOL_SCHEMAS, touchedPaths, type ToolContext } from "../local/tools.ts";
|
|
7
7
|
import type { Capture } from "../memory/capture.ts";
|
|
8
8
|
import type { ChatMessage, ChatResult, OmniRoute } from "../omniroute/client.ts";
|
|
@@ -17,7 +17,7 @@ export interface LocalOptions {
|
|
|
17
17
|
route?: string;
|
|
18
18
|
/** Model id sent straight to OmniRoute when the sidecar is absent, unhealthy or fails a call. */
|
|
19
19
|
fixedModel: string;
|
|
20
|
-
tools: { deny: string[]; permit: ToolContext["permit"]; bashNetwork?:
|
|
20
|
+
tools: { deny: string[]; permit: ToolContext["permit"]; bashNetwork?: SandboxNetwork; readAllow?: string[] };
|
|
21
21
|
capture?: Capture;
|
|
22
22
|
/** Runs a hub task tool (hub_task_*, hub_review, hub_remember) as this peer. Absent = the tools are not offered. */
|
|
23
23
|
taskTool?: (name: string, args: Record<string, unknown>, turn: { pii: boolean }) => Promise<string>;
|
|
@@ -67,7 +67,7 @@ export class LocalPeer extends BasePeer {
|
|
|
67
67
|
private readonly opts: LocalOptions,
|
|
68
68
|
) {
|
|
69
69
|
super(id, opts.watchdogMs);
|
|
70
|
-
this.sandboxProfile = profile(opts.cwd, opts.tools.bashNetwork ?? false, opts.tools.readAllow, opts.tools.deny
|
|
70
|
+
this.sandboxProfile = profile(opts.cwd, opts.tools.bashNetwork ?? false, opts.tools.readAllow, opts.tools.deny);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
recoveryMetadata(): Record<string, unknown> {
|
|
@@ -165,6 +165,7 @@ export class LocalPeer extends BasePeer {
|
|
|
165
165
|
deny: this.opts.tools.deny,
|
|
166
166
|
permit: this.opts.tools.permit,
|
|
167
167
|
sandboxProfile: this.sandboxProfile,
|
|
168
|
+
sandboxEnv: proxyEnv(this.opts.tools.bashNetwork ?? false),
|
|
168
169
|
send: (text, to) => {
|
|
169
170
|
const refused = this.onMessage?.(text, policy?.pii ? reply : { inReplyTo: replyParent(envs), to: to?.length ? to : replyAudience(envs) });
|
|
170
171
|
if (typeof refused === "string") return `not sent: ${refused}`;
|
package/src/cli/main.ts
CHANGED
|
@@ -892,6 +892,7 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
892
892
|
|
|
893
893
|
const config = loadConfig(cwd);
|
|
894
894
|
row(!config.ignored, "config", config.ignored ? `${config.ignored.join("; ")} (move them to .agenthub/config.local.json)` : "no machine-local field ignored");
|
|
895
|
+
for (const line of config.retired ?? []) row(false, "retired setting", line); // issue #83
|
|
895
896
|
const omni = new OmniRoute(config.omniroute);
|
|
896
897
|
const gateway = await omni.base();
|
|
897
898
|
row(!!gateway, "omniroute", gateway ? `${new URL(gateway).host} healthy` : config.omniroute.urls.length || process.env.AGENTHUB_OMNIROUTE_URL ? "no candidate reachable (VPN off?); ahub local cannot run" : "not configured: set omniroute.urls in .agenthub/config.local.json (any OpenAI-compatible gateway); ahub local cannot run");
|
package/src/hub/ask.ts
CHANGED
|
@@ -85,14 +85,19 @@ export async function gather(question: string, d: AskDeps): Promise<{ evidence:
|
|
|
85
85
|
|
|
86
86
|
// Matching tasks first, then the most recently touched; PII rows keep their place with a stub, so counts stay right.
|
|
87
87
|
const tasks = d.board.list().sort((a, b) => hit(b.title) - hit(a.title) || b.updated - a.updated).slice(0, MAX_TASKS);
|
|
88
|
-
|
|
88
|
+
// An ordinary task's last note is model-written (a summary, a review note): one that matches a PII pattern is shown
|
|
89
|
+
// only on campus, like a PII task (#69).
|
|
90
|
+
const notePii = (t: (typeof tasks)[number]) => !d.isPii(t) && !!t.history.at(-1)?.note && (d.isPiiText?.(t.history.at(-1)!.note!) ?? false);
|
|
91
|
+
const anyPii = tasks.some((t) => d.isPii(t) || notePii(t));
|
|
89
92
|
const showPii = anyPii ? await onCampus() : false;
|
|
90
93
|
let piiShown = false;
|
|
91
94
|
const taskRows: Evidence[] = tasks.map((t) => {
|
|
92
95
|
const secret = d.isPii(t);
|
|
93
96
|
if (secret && showPii) piiShown = true;
|
|
94
97
|
const last = t.history.at(-1);
|
|
95
|
-
|
|
98
|
+
if (notePii(t) && showPii) piiShown = true;
|
|
99
|
+
const note = last?.note && notePii(t) && !showPii ? "its note is shown only when the model is reached on campus" : last?.note;
|
|
100
|
+
const text = secret && !showPii ? "[pii] (its text is shown only when the model is reached on campus)" : `${t.title}${last ? ` | last: ${last.event} by ${last.by}${note ? ` (${note})` : ""}` : ""}`;
|
|
96
101
|
return { id: `task #${t.id}`, kind: "task", text: `[${t.class}] ${t.state}, owner ${t.owner ?? "none"}, reviewer ${t.reviewer ?? "none"}: ${text}`.slice(0, ITEM_CHARS) };
|
|
97
102
|
});
|
|
98
103
|
|
package/src/hub/board.ts
CHANGED
|
@@ -22,6 +22,8 @@ export interface HistoryEntry {
|
|
|
22
22
|
by: PeerId;
|
|
23
23
|
event: string; // proposed | assigned | accepted | declined | done | approved | changes_requested | escalated | reassigned
|
|
24
24
|
note?: string;
|
|
25
|
+
/** The owner an event that set it left the task with (#67); absent in rows written before 0.11. */
|
|
26
|
+
owner?: PeerId | null;
|
|
25
27
|
}
|
|
26
28
|
export interface Task {
|
|
27
29
|
id: number;
|
|
@@ -122,7 +124,7 @@ export class Board {
|
|
|
122
124
|
throw new Error(`task #${id} is ${task.state}: cannot move to ${patch.state}`);
|
|
123
125
|
}
|
|
124
126
|
const next = { ...task, ...patch, refs: { ...task.refs, ...patch.refs } };
|
|
125
|
-
const history = [...task.history, { at: Date.now(), by, event, ...(note ? { note } : {}) }];
|
|
127
|
+
const history = [...task.history, { at: Date.now(), by, event, ...(note ? { note } : {}), ...("owner" in patch ? { owner: next.owner } : {}) }];
|
|
126
128
|
this.db
|
|
127
129
|
.query("UPDATE tasks SET state = ?, owner = ?, reviewer = ?, refs = ?, plan = ?, rejections = ?, history = ?, updated = ? WHERE id = ?")
|
|
128
130
|
.run(next.state, next.owner, next.reviewer, JSON.stringify(next.refs), JSON.stringify(next.plan ?? {}), next.rejections, JSON.stringify(history), Date.now(), id);
|
package/src/hub/config-trust.ts
CHANGED
|
@@ -24,7 +24,7 @@ export const MACHINE_LOCAL = [
|
|
|
24
24
|
"memory.worker_url",
|
|
25
25
|
"local.read_allow",
|
|
26
26
|
"local.bash_network",
|
|
27
|
-
"local.
|
|
27
|
+
"local.network_allow", // the hosts the egress proxy opens (#65)
|
|
28
28
|
] as const;
|
|
29
29
|
|
|
30
30
|
/**
|
package/src/hub/crash.ts
CHANGED
|
@@ -31,7 +31,9 @@ export function readSessions(stateDir: string): SessionsFile | undefined {
|
|
|
31
31
|
if (!existsSync(fileOf(stateDir))) return undefined;
|
|
32
32
|
try {
|
|
33
33
|
const s = JSON.parse(readFileSync(fileOf(stateDir), "utf8")) as SessionsFile;
|
|
34
|
-
|
|
34
|
+
if (!Array.isArray(s.peers)) return undefined;
|
|
35
|
+
// A record without a peer id or metadata says nothing to resume, and reading it would stop recovery for the rest.
|
|
36
|
+
return { ...s, peers: s.peers.filter((p) => !!p && typeof p.peer === "string" && !!p.meta && typeof p.meta === "object") };
|
|
35
37
|
} catch {
|
|
36
38
|
return undefined; // cut short by the crash: nothing to resume from
|
|
37
39
|
}
|
|
@@ -51,7 +53,7 @@ const str = (v: unknown) => (typeof v === "string" && v ? v : undefined);
|
|
|
51
53
|
* What can come back after a crash. `resume` holds the start arguments for peers the hub launches itself (Kimi through
|
|
52
54
|
* ACP `session/load`, Pi through its session file, the local worker afresh); the others say what the user has to do.
|
|
53
55
|
*/
|
|
54
|
-
export function crashPlan(records: SessionRecord[]): { peer: string; resume?: Record<string, string>; how: string }[] {
|
|
56
|
+
export function crashPlan(records: SessionRecord[]): { peer: string; resume?: Record<string, string>; how: string; fresh?: Record<string, string>; tui?: true }[] {
|
|
55
57
|
return records.map(({ peer, meta }) => {
|
|
56
58
|
const launch = (meta.launch && typeof meta.launch === "object" ? meta.launch : {}) as Record<string, unknown>;
|
|
57
59
|
const model = str(launch.model);
|
|
@@ -66,13 +68,16 @@ export function crashPlan(records: SessionRecord[]): { peer: string; resume?: Re
|
|
|
66
68
|
return { peer, resume: { sessionId, ...(model ? { model } : {}) }, how: `kimi: session ${sessionId} can be loaded again (ACP session/load)` };
|
|
67
69
|
}
|
|
68
70
|
case "pi": {
|
|
71
|
+
// `fresh`: what a new headless session keeps of the recorded one (pi.auto_start's fallback, #66).
|
|
72
|
+
const fresh: Record<string, string> = {};
|
|
73
|
+
for (const k of ["backend", "model"] as const) if (str(launch[k])) fresh[k] = str(launch[k])!;
|
|
69
74
|
const sessionFile = str(meta.sessionFile) ?? str(launch.sessionFile);
|
|
70
|
-
if (!sessionFile) return { peer, how: "pi: no session file was recorded; start it again with ahub pi" };
|
|
75
|
+
if (!sessionFile) return { peer, fresh, how: "pi: no session file was recorded; start it again with ahub pi" };
|
|
71
76
|
// A terminal Pi is run by the CLI that launched it, not by the hub: nothing here could start it again.
|
|
72
|
-
if (str(launch.mode) === "tui") return { peer, how: `pi: it ran in a terminal; start it again with ahub pi --mode tui --session-file ${sessionFile}` };
|
|
77
|
+
if (str(launch.mode) === "tui") return { peer, fresh, tui: true, how: `pi: it ran in a terminal; start it again with ahub pi --mode tui --session-file ${sessionFile}` };
|
|
73
78
|
const args: Record<string, string> = { sessionFile };
|
|
74
79
|
for (const k of ["mode", "backend", "model"] as const) if (str(launch[k])) args[k] = str(launch[k])!;
|
|
75
|
-
return { peer, resume: args, how: `pi: its session file can be resumed (${sessionFile})` };
|
|
80
|
+
return { peer, fresh, resume: args, how: `pi: its session file can be resumed (${sessionFile})` };
|
|
76
81
|
}
|
|
77
82
|
case "local": {
|
|
78
83
|
// `model` is also recorded as the route's fallback, and a model given at start pins it: pass one or the other.
|