@haven_ai/connect 0.1.28-alpha.0 → 0.1.29-alpha.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/README.md CHANGED
@@ -52,6 +52,57 @@ spending authority.
52
52
  `haven_get_allowances` tools to confirm the Haven wallet and live budget.
53
53
  Do not sign, fund, or create a payment to verify setup.
54
54
 
55
+ ### `--doctor` reports every agent, not just one (#1697)
56
+
57
+ With several agents wired into one runtime (`--name`), the doctor enumerates
58
+ every credential directory on the machine and classifies each one:
59
+
60
+ | Classification | Meaning |
61
+ | --- | --- |
62
+ | `wired` | Its MCP pair is present in this runtime's config. Fully checked. |
63
+ | `superseded` | It holds credentials, but no config entry points at it. Reported, never silently skipped — its API key may still spend. |
64
+ | `retired` | Tombstoned (see below); key material removed. |
65
+ | `orphaned` | No usable identity and no tombstone. |
66
+
67
+ The exit code is non-zero if **any** wired agent fails **any** check — not
68
+ only the one the report's main section describes. In `--json`, the same
69
+ information is on `agents[]`, each entry carrying `slug`, `agentId`,
70
+ `directory`, `classification` and its own `checks[]`; the flat `checks` array
71
+ is retained and still describes one agent, so a single-agent install reads as
72
+ it always did.
73
+
74
+ One check is worth calling out: **`identity_match`** compares the agent the
75
+ stored API key actually authenticates as against the `delegate_address` in
76
+ that directory's `signer.json`. A mismatch means the runtime would quote as
77
+ one agent and sign as another, and it fails hard. This is the half of that
78
+ hazard a local tool can know — the doctor still cannot see inside an
79
+ already-running host, which is why the restart guidance below matters.
80
+
81
+ ## Retiring an old agent directory
82
+
83
+ Re-running setup creates a NEW agent and retires nothing. Long-lived MCP hosts
84
+ (gateways, TUI workers, editors, desktop apps) load their MCP wiring once, at
85
+ process start — a host started before your latest setup keeps spawning the OLD
86
+ agent's signer path forever, and when that directory is later removed the spawn
87
+ failure surfaces only as a masked "Connection closed" retried every few
88
+ minutes. Two rules follow:
89
+
90
+ 1. **Restart EVERY long-lived host after a setup or retirement, not just one.**
91
+ Each process holds the snapshot from its own start time, so after a chain of
92
+ re-setups each host can be parked on a *different* old agent.
93
+ 2. **Tombstone a directory before (or instead of) deleting it:**
94
+
95
+ ```
96
+ npx @haven_ai/connect@alpha --tombstone ~/.haven/agents/<id> --reason "superseded"
97
+ ```
98
+
99
+ This replaces the directory's signer wrapper with a diagnostic that logs the
100
+ retirement (agent id, date, reason, restart guidance) to the host's MCP
101
+ stderr log on every probe, and records it in `TOMBSTONE.json` for
102
+ `--doctor`. It touches no key material and revokes nothing — revoke the
103
+ agent on the Haven agent page yourself. Delete the tombstone only once every
104
+ long-lived host has been restarted.
105
+
55
106
  ### Structured output for automation
56
107
 
57
108
  Pass `--json` when a launcher needs a machine-readable completion record. Connect
@@ -150,6 +201,23 @@ prints one concrete repair action; the exit code is non-zero on any failure.
150
201
  Add `--json` for a machine-readable report. No secret material is ever
151
202
  printed.
152
203
 
204
+ `--doctor` also probes every OTHER agent credential directory it did not
205
+ select (#1688). A re-run of setup mints a NEW agent and retires nothing, so
206
+ a directory from a previous setup can hold an API key that still
207
+ authenticates — meaning any host that started before the re-run keeps
208
+ spending as the agent you believe you replaced. A superseded directory
209
+ whose key is still live is a FAILING check naming the agent id, with the
210
+ repair spelled out: revoke it on the Haven agent page, then remove the
211
+ directory. An already-revoked one reports as informational; an unreachable
212
+ probe is a note, never a verdict. Connect never revokes or deletes
213
+ credentials itself — it reports, you decide. The setup completion output
214
+ names superseded agents the moment they are created, for the same reason.
215
+ One honest limit: "newest" is decided by file mtime, so a restored backup or
216
+ a sync tool that rewrites timestamps can make doctor examine the wrong
217
+ directory as current — before revoking anything, confirm the agent id
218
+ against the Haven agent page, which is the authority on which agent is
219
+ which.
220
+
153
221
  `--repair` re-runs what setup already owns — reinstall the pinned signer
154
222
  runtime, rewrite the wrapper + sidecar, and re-write the runtime config from
155
223
  the STORED credentials. It never touches keys and never needs a new token.