@oh-hai/cli 0.2.3 → 0.3.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 +98 -0
- package/README.md +59 -29
- package/dist/commands/ask.js +71 -10
- package/dist/commands/ask.js.map +1 -1
- package/dist/commands/bridge.d.ts +2 -0
- package/dist/commands/bridge.js +502 -0
- package/dist/commands/bridge.js.map +1 -0
- package/dist/commands/context.d.ts +22 -0
- package/dist/commands/doctor.js +12 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/fleet.d.ts +2 -0
- package/dist/commands/fleet.js +164 -0
- package/dist/commands/fleet.js.map +1 -0
- package/dist/commands/handlers.js +8 -0
- package/dist/commands/handlers.js.map +1 -1
- package/dist/commands/messages.d.ts +2 -0
- package/dist/commands/messages.js +131 -0
- package/dist/commands/messages.js.map +1 -0
- package/dist/commands/messaging/build.d.ts +10 -1
- package/dist/commands/messaging/build.js +22 -4
- package/dist/commands/messaging/build.js.map +1 -1
- package/dist/commands/messaging/capability.d.ts +42 -0
- package/dist/commands/messaging/capability.js +164 -0
- package/dist/commands/messaging/capability.js.map +1 -0
- package/dist/commands/messaging/http.d.ts +28 -1
- package/dist/commands/messaging/http.js +234 -13
- package/dist/commands/messaging/http.js.map +1 -1
- package/dist/commands/messaging/inbox-entries.d.ts +83 -0
- package/dist/commands/messaging/inbox-entries.js +362 -0
- package/dist/commands/messaging/inbox-entries.js.map +1 -0
- package/dist/commands/messaging/inbox-stream.d.ts +37 -0
- package/dist/commands/messaging/inbox-stream.js +224 -0
- package/dist/commands/messaging/inbox-stream.js.map +1 -0
- package/dist/commands/messaging/session-drain.d.ts +50 -0
- package/dist/commands/messaging/session-drain.js +163 -0
- package/dist/commands/messaging/session-drain.js.map +1 -0
- package/dist/commands/messaging/session-scope.d.ts +93 -0
- package/dist/commands/messaging/session-scope.js +0 -0
- package/dist/commands/messaging/session-scope.js.map +1 -0
- package/dist/commands/messaging/sessions-http.d.ts +20 -0
- package/dist/commands/messaging/sessions-http.js +153 -0
- package/dist/commands/messaging/sessions-http.js.map +1 -0
- package/dist/commands/messaging/shared.d.ts +19 -1
- package/dist/commands/messaging/shared.js +69 -2
- package/dist/commands/messaging/shared.js.map +1 -1
- package/dist/commands/messaging/validate.d.ts +33 -1
- package/dist/commands/messaging/validate.js +78 -0
- package/dist/commands/messaging/validate.js.map +1 -1
- package/dist/commands/messaging/wire.d.ts +180 -3
- package/dist/commands/notify.js +47 -5
- package/dist/commands/notify.js.map +1 -1
- package/dist/commands/registry.js +128 -3
- package/dist/commands/registry.js.map +1 -1
- package/dist/commands/self-test.d.ts +17 -0
- package/dist/commands/self-test.js +472 -0
- package/dist/commands/self-test.js.map +1 -0
- package/dist/commands/session.d.ts +2 -0
- package/dist/commands/session.js +158 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/setup.js +44 -0
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/task.js +61 -11
- package/dist/commands/task.js.map +1 -1
- package/dist/commands/teach.js +84 -4
- package/dist/commands/teach.js.map +1 -1
- package/dist/commands/whoami.js +14 -1
- package/dist/commands/whoami.js.map +1 -1
- package/dist/exit-codes.d.ts +37 -1
- package/dist/exit-codes.js +42 -1
- package/dist/exit-codes.js.map +1 -1
- package/dist/help.js +5 -1
- package/dist/help.js.map +1 -1
- package/dist/watch-lock.js +7 -0
- package/dist/watch-lock.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
// `oh-hai bridge` (docs/specs/cli.md §4.15) — the SUPERVISED, LOUD-FAILURE consumer of the MA2H v0.5
|
|
2
|
+
// §8.7.1 session-scoped mailbox (issue #658). The client half of the reliability invariant: the
|
|
3
|
+
// server side made a message reach a running agent and made the delivery track honest; this is the
|
|
4
|
+
// process a supervisor can trust to either deliver that message or DIE SAYING WHY.
|
|
5
|
+
//
|
|
6
|
+
// WHY NOT `inbox watch`. Two reasons, and both are structural rather than stylistic.
|
|
7
|
+
//
|
|
8
|
+
// 1. THE WIRE SHAPES DIFFER. A session-LESS drain answers `{ directives: [...] }` (the v0.4 body);
|
|
9
|
+
// a session-PRESENTING drain answers `{ messages: [ { <kind>, signature } ] }` with the four
|
|
10
|
+
// §8.7.1 entry kinds. Presenting `?session=` from `inbox watch` would leave `body.directives`
|
|
11
|
+
// undefined and turn EVERY drain into "malformed inbox drain" for anyone with MA2H_SESSION_ID
|
|
12
|
+
// exported.
|
|
13
|
+
// 2. `inbox watch` FAILS QUIETLY BY CONSTRUCTION. It is a poll loop guarded by a userspace lockfile
|
|
14
|
+
// because concurrent runs of one principal race a single destructive drain; when the loop dies,
|
|
15
|
+
// it dies with whatever generic code the last call produced, and a supervisor cannot tell "fix
|
|
16
|
+
// the credential" from "the lease lapsed, restart me".
|
|
17
|
+
//
|
|
18
|
+
// THE WATCH-LOCK IS RETIRED HERE, and that is a consequence of the design rather than a shortcut.
|
|
19
|
+
// `cli/src/watch-lock.ts` exists because two watchers sharing one identity drain ONE principal-wide
|
|
20
|
+
// mailbox and eat each other's directives. A session-scoped drain claims only what is addressed to
|
|
21
|
+
// THIS session (plus principal-addressed entries, first-claim-wins server-side), so concurrent
|
|
22
|
+
// bridges under one credential are the intended topology, not a hazard — that is the entire point of
|
|
23
|
+
// sessions. Taking a per-identity lock here would forbid exactly the concurrency v0.5 exists to
|
|
24
|
+
// enable. `inbox watch` keeps the lock, unchanged.
|
|
25
|
+
//
|
|
26
|
+
// NEVER SILENT. Every fatal class exits with its OWN nonzero code and prints a final stderr line
|
|
27
|
+
// naming what died and what to do — in `--json` mode too, where the failure envelope goes to stdout
|
|
28
|
+
// and a supervisor tailing stderr would otherwise see nothing at all. See EXIT CODES below.
|
|
29
|
+
import { CliError, buildOk, serializeEnvelope } from "../envelope.js";
|
|
30
|
+
import { sanitizeForTerminal } from "../terminal.js";
|
|
31
|
+
import { parseCommandArgs } from "./flags.js";
|
|
32
|
+
import { assertHubSpeaksSessionDrain, fetchCapability } from "./messaging/capability.js";
|
|
33
|
+
import { redactToken } from "./messaging/http.js";
|
|
34
|
+
import { resolveSubmitIdentity } from "./messaging/identity.js";
|
|
35
|
+
import { ALLOW_ANY_IN_ACCOUNT, DEFAULT_REPLAY_WINDOW_SECONDS, ReplayGuard, ackKeyOf, entryKindOf, isBenignRedelivery, verifyEntry, } from "./messaging/inbox-entries.js";
|
|
36
|
+
import { readInboxStream, streamUrlFor } from "./messaging/inbox-stream.js";
|
|
37
|
+
import { ackInboxSession, drainInboxSession, isRetryable } from "./messaging/session-drain.js";
|
|
38
|
+
import { explicitSession, rememberSession } from "./messaging/session-scope.js";
|
|
39
|
+
import { getSession, registerSession } from "./messaging/sessions-http.js";
|
|
40
|
+
import { positiveInt, resolveRunId, stringFlag, strictBoolFlag } from "./messaging/shared.js";
|
|
41
|
+
const BRIDGE_OPTIONS = {
|
|
42
|
+
"until-event": { type: "boolean" },
|
|
43
|
+
stream: { type: "boolean" },
|
|
44
|
+
session: { type: "string" },
|
|
45
|
+
transport: { type: "string" },
|
|
46
|
+
interval: { type: "string" },
|
|
47
|
+
max: { type: "string" },
|
|
48
|
+
"max-retries": { type: "string" },
|
|
49
|
+
"allow-from": { type: "string", multiple: true },
|
|
50
|
+
label: { type: "string" },
|
|
51
|
+
};
|
|
52
|
+
/** Poll cadence when the Hub offers no stream. Well under the 90s presence-freshness window, so a
|
|
53
|
+
* polling bridge stays `online` and keeps renewing its lease between drains. */
|
|
54
|
+
const DEFAULT_POLL_INTERVAL_MS = 5_000;
|
|
55
|
+
/** First backoff step for a GENUINE transport fault. Never applied to a bounded close. */
|
|
56
|
+
const BACKOFF_BASE_MS = 1_000;
|
|
57
|
+
/** Backoff ceiling. Above this a bridge is just a slow poller, and the §16 lease would lapse long
|
|
58
|
+
* before a longer sleep bought anything. */
|
|
59
|
+
const BACKOFF_CAP_MS = 30_000;
|
|
60
|
+
/** Reconnect attempts before `retries_exhausted` (exit 13). Deliberately finite: an infinite retry
|
|
61
|
+
* loop is indistinguishable, from the outside, from a healthy bridge waiting for mail — which is
|
|
62
|
+
* exactly the silent death this command exists to prevent. */
|
|
63
|
+
const DEFAULT_MAX_RETRIES = 8;
|
|
64
|
+
/** Sanity ceiling on `--max` (a drain batch size, not a timer); the Hub clamps to its own cap. */
|
|
65
|
+
const MAX_DRAIN_BATCH = 10_000;
|
|
66
|
+
export async function bridgeCommand(ctx) {
|
|
67
|
+
const parsed = parseCommandArgs(ctx.argv, BRIDGE_OPTIONS, { maxOperands: 1 });
|
|
68
|
+
const operand = parsed.positionals[1];
|
|
69
|
+
if (operand !== undefined && operand !== "status") {
|
|
70
|
+
throw new CliError("usage", `unknown subcommand: ${operand} (expected 'status', or no subcommand to run the bridge).`);
|
|
71
|
+
}
|
|
72
|
+
const flags = parsed.values;
|
|
73
|
+
if (operand === "status")
|
|
74
|
+
return bridgeStatus(ctx, flags);
|
|
75
|
+
return runBridge(ctx, flags);
|
|
76
|
+
}
|
|
77
|
+
// ---- flag parsing ----
|
|
78
|
+
function parseOptions(flags) {
|
|
79
|
+
const untilEvent = strictBoolFlag(flags["until-event"], "--until-event");
|
|
80
|
+
const stream = strictBoolFlag(flags.stream, "--stream");
|
|
81
|
+
if (untilEvent && stream) {
|
|
82
|
+
throw new CliError("usage", "--until-event and --stream are contradictory: one exits on the first entry, the other never does.");
|
|
83
|
+
}
|
|
84
|
+
const rawTransport = stringFlag(flags.transport) ?? "auto";
|
|
85
|
+
if (rawTransport !== "auto" && rawTransport !== "sse" && rawTransport !== "poll") {
|
|
86
|
+
throw new CliError("usage", `invalid --transport '${sanitizeForTerminal(rawTransport)}': expected auto | sse | poll.`);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
// `--until-event` is the DEFAULT: it is the bounded, re-invocable primitive, so a bare
|
|
90
|
+
// `oh-hai bridge` in a harness terminates rather than becoming an unsupervised daemon by accident.
|
|
91
|
+
untilEvent: !stream,
|
|
92
|
+
transport: rawTransport,
|
|
93
|
+
intervalMs: flags.interval !== undefined ? positiveInt(stringFlag(flags.interval), "--interval") : DEFAULT_POLL_INTERVAL_MS,
|
|
94
|
+
max: flags.max !== undefined ? positiveInt(stringFlag(flags.max), "--max", "a positive integer", MAX_DRAIN_BATCH) : undefined,
|
|
95
|
+
maxRetries: flags["max-retries"] !== undefined
|
|
96
|
+
? positiveIntOrZero(flags["max-retries"])
|
|
97
|
+
: DEFAULT_MAX_RETRIES,
|
|
98
|
+
allowFrom: parseAllowFrom(flags["allow-from"]),
|
|
99
|
+
label: stringFlag(flags.label),
|
|
100
|
+
session: stringFlag(flags.session),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/** `--max-retries 0` is meaningful (fail on the first fault — the right setting under a supervisor
|
|
104
|
+
* that restarts instantly), so this accepts zero where `positiveInt` would not. */
|
|
105
|
+
function positiveIntOrZero(raw) {
|
|
106
|
+
const value = stringFlag(raw)?.trim();
|
|
107
|
+
// `Number("")` is 0, so an empty `--max-retries=` would silently become "fail on the first fault".
|
|
108
|
+
// Reject it: a flag whose value was lost to a shell expansion must not change failure policy.
|
|
109
|
+
const parsed = value !== undefined && value !== "" ? Number(value) : Number.NaN;
|
|
110
|
+
if (!Number.isInteger(parsed) || parsed < 0 || parsed > 1_000) {
|
|
111
|
+
throw new CliError("usage", "--max-retries must be an integer between 0 and 1000.");
|
|
112
|
+
}
|
|
113
|
+
return parsed;
|
|
114
|
+
}
|
|
115
|
+
/** Validate the declared §13.4 authorization policy at PARSE time, so a typo'd address fails before
|
|
116
|
+
* the bridge opens a connection rather than silently never matching a sender. */
|
|
117
|
+
function parseAllowFrom(raw) {
|
|
118
|
+
const values = raw === undefined ? [] : Array.isArray(raw) ? raw : [raw];
|
|
119
|
+
const out = [];
|
|
120
|
+
for (const value of values) {
|
|
121
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
122
|
+
throw new CliError("usage", "--allow-from needs a value: an `agent:<id>[#sess_…]` address, or `any-in-account`.");
|
|
123
|
+
}
|
|
124
|
+
const entry = value.trim();
|
|
125
|
+
if (entry === ALLOW_ANY_IN_ACCOUNT) {
|
|
126
|
+
out.push(entry);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (!/^agent:[^\s#]+(#[^\s#]+)?$/.test(entry)) {
|
|
130
|
+
throw new CliError("usage", `invalid --allow-from '${sanitizeForTerminal(entry)}': expected agent:<id>, agent:<id>#<sess_…>, or ${ALLOW_ANY_IN_ACCOUNT}.`);
|
|
131
|
+
}
|
|
132
|
+
out.push(entry);
|
|
133
|
+
}
|
|
134
|
+
return out;
|
|
135
|
+
}
|
|
136
|
+
// ---- the bridge ----
|
|
137
|
+
/**
|
|
138
|
+
* The never-silent boundary: EVERY way this command can fail passes through here, so exactly one
|
|
139
|
+
* `FATAL` line reaches stderr and nothing exits mute.
|
|
140
|
+
*
|
|
141
|
+
* It wraps the whole run rather than only the reconnect loop because the pre-flight failures are the
|
|
142
|
+
* ones an operator is most likely to hit — a dead credential, a pre-0.5 Hub, an already-terminal
|
|
143
|
+
* `MA2H_SESSION_ID` — and a supervisor tailing stderr must not have to know which phase failed to
|
|
144
|
+
* learn that anything did.
|
|
145
|
+
*/
|
|
146
|
+
async function runBridge(ctx, flags) {
|
|
147
|
+
try {
|
|
148
|
+
await bridgeLoop(ctx, flags);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
fatal(ctx, error);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async function bridgeLoop(ctx, flags) {
|
|
155
|
+
const options = parseOptions(flags);
|
|
156
|
+
const identity = await resolveSubmitIdentity(ctx);
|
|
157
|
+
// THE §8.0 GATE, before a single drain. A pre-v0.5 Hub does not refuse `?session=` — per §10 it
|
|
158
|
+
// IGNORES the unknown parameter and answers with the principal-wide v0.4 mailbox, so an ungated
|
|
159
|
+
// bridge would destructively claim every directive queued for the whole agent while believing it
|
|
160
|
+
// had drained only its own session. Fails closed on an unreadable capability document.
|
|
161
|
+
await assertHubSpeaksSessionDrain(ctx);
|
|
162
|
+
const capability = await fetchCapability(ctx);
|
|
163
|
+
const session = await resolveBridgeSession(ctx, identity, options);
|
|
164
|
+
const policy = {
|
|
165
|
+
agentId: identity.agentId,
|
|
166
|
+
sessionId: session.id,
|
|
167
|
+
allowFrom: options.allowFrom,
|
|
168
|
+
replayWindowSeconds: typeof capability?.replay_window_seconds === "number" && capability.replay_window_seconds > 0
|
|
169
|
+
? capability.replay_window_seconds
|
|
170
|
+
: DEFAULT_REPLAY_WINDOW_SECONDS,
|
|
171
|
+
};
|
|
172
|
+
const guard = new ReplayGuard();
|
|
173
|
+
const streamUrl = options.transport === "poll" ? undefined : streamUrlFor(ctx, capability);
|
|
174
|
+
if (options.transport === "sse" && streamUrl === undefined) {
|
|
175
|
+
throw new CliError("usage", "--transport sse was requested but this Hub advertises no `inbound.stream_url` (§8.0). Use --transport poll (or auto), " +
|
|
176
|
+
"which drains on an interval and renews the lease just as well — the stream is latency, never a requirement (§8.7.2).");
|
|
177
|
+
}
|
|
178
|
+
ctx.io.err(`oh-hai bridge: session ${session.id} · transport ${streamUrl !== undefined ? "sse" : `poll (${options.intervalMs}ms)`} · ` +
|
|
179
|
+
`mode ${options.untilEvent ? "--until-event" : "--stream"} · policy ${options.allowFrom.length > 0 ? options.allowFrom.join(", ") : "(none declared — addressed ask/task refused)"}`);
|
|
180
|
+
// THE RECONNECT LOOP. `attempt` counts CONSECUTIVE genuine faults; a completed hold — including
|
|
181
|
+
// one the Hub bounded — resets it to zero, because a bounded close is a success, not a failure.
|
|
182
|
+
let attempt = 0;
|
|
183
|
+
for (;;) {
|
|
184
|
+
try {
|
|
185
|
+
const emitted = streamUrl !== undefined
|
|
186
|
+
? await oneStreamHold(ctx, identity.token, session.id, streamUrl, policy, guard, options)
|
|
187
|
+
: await onePollCycle(ctx, identity.token, session.id, policy, guard, options);
|
|
188
|
+
attempt = 0;
|
|
189
|
+
if (options.untilEvent && emitted > 0)
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
// Fatal by construction: an auth refusal, a terminal session or a verification failure answers
|
|
194
|
+
// identically on the next attempt, and a retry loop around one is exactly how a bridge goes
|
|
195
|
+
// silently dead. Rethrown to the never-silent boundary above.
|
|
196
|
+
if (!isRetryable(error))
|
|
197
|
+
throw error;
|
|
198
|
+
if (attempt >= options.maxRetries) {
|
|
199
|
+
throw new CliError("retries_exhausted", `gave up after ${attempt} reconnect attempt${attempt === 1 ? "" : "s"} — last failure: ` +
|
|
200
|
+
`${error instanceof Error ? error.message : String(error)}. The Hub is unreachable or failing; the bridge is NOT ` +
|
|
201
|
+
"delivering mail. Restart it once connectivity is restored (a supervisor should treat exit 13 as restartable, " +
|
|
202
|
+
"with its own backoff, and page if it repeats).");
|
|
203
|
+
}
|
|
204
|
+
attempt += 1;
|
|
205
|
+
const delay = backoffMs(attempt);
|
|
206
|
+
ctx.io.err(`oh-hai bridge: ${error instanceof Error ? error.message : String(error)} — reconnect attempt ${attempt}/${options.maxRetries} in ${delay}ms.`);
|
|
207
|
+
await ctx.runtime.sleep(delay);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/** Exponential backoff with FULL JITTER, applied only to genuine transport faults. Full jitter (a
|
|
212
|
+
* uniform draw over `[0, window)`) rather than the bare exponential because a Hub restart wakes
|
|
213
|
+
* every bridge in a fleet at once, and a deterministic schedule turns that into a synchronized
|
|
214
|
+
* thundering herd against a service that is already struggling. */
|
|
215
|
+
function backoffMs(attempt) {
|
|
216
|
+
const window = Math.min(BACKOFF_CAP_MS, BACKOFF_BASE_MS * 2 ** (attempt - 1));
|
|
217
|
+
return Math.max(1, Math.floor(Math.random() * window));
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Print the final, loud stderr line for a fatal, then throw it.
|
|
221
|
+
*
|
|
222
|
+
* cli.ts already renders a thrown `CliError` — but under `--json` it renders it to STDOUT as the §8
|
|
223
|
+
* failure envelope, and a supervisor that captures stderr (the normal arrangement: stdout is the
|
|
224
|
+
* entry pipe) would then see a process exit with a distinct code and NOTHING explaining it. That is
|
|
225
|
+
* the silent death this command exists to prevent, so the line is emitted here unconditionally.
|
|
226
|
+
*/
|
|
227
|
+
function fatal(ctx, error) {
|
|
228
|
+
const cliError = error instanceof CliError ? error : new CliError("error", error instanceof Error ? error.message : String(error));
|
|
229
|
+
ctx.io.err(`oh-hai bridge: FATAL (exit ${cliError.exitCode}, ${cliError.code}) — ${cliError.message}`);
|
|
230
|
+
throw cliError;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Resolve the session this bridge speaks from.
|
|
234
|
+
*
|
|
235
|
+
* An ATTACHED session (`--session` / `MA2H_SESSION_ID`) is the supervised arrangement and the one
|
|
236
|
+
* the docs recommend: the address stays stable across restarts, so senders that published
|
|
237
|
+
* `agent:<id>#<sess_…>` keep reaching this agent. When nothing is attached the bridge mints one and
|
|
238
|
+
* says so on stderr with the export line — and deliberately does NOT close it on exit, because the
|
|
239
|
+
* whole point of `--until-event` is to be re-invoked, and closing the session between invocations
|
|
240
|
+
* would hand every re-invocation a different address (§16.3 terminals are immutable, so the old one
|
|
241
|
+
* could never be revived).
|
|
242
|
+
*/
|
|
243
|
+
async function resolveBridgeSession(ctx, identity, options) {
|
|
244
|
+
const attached = explicitSession(flagsWithSession(options));
|
|
245
|
+
if (attached !== undefined) {
|
|
246
|
+
const session = await getSession(ctx, identity.token, attached.id);
|
|
247
|
+
// Fail on the READ rather than on the first drain. A terminal session is still 200-with-its-state
|
|
248
|
+
// for the Hub's retention window (§16.4), so presenting one would otherwise cost a destructive
|
|
249
|
+
// drain attempt to discover what this read already knows — and the operator would see the 410's
|
|
250
|
+
// message instead of the one that names where the id came from.
|
|
251
|
+
if (session.state !== "active") {
|
|
252
|
+
const from = attached.source === "flag" ? "--session" : "MA2H_SESSION_ID";
|
|
253
|
+
// THE ATTACHED CASE IS THE ONE THAT MATTERS FOR THE KILL-SWITCH (issue #683 §5). A supervised
|
|
254
|
+
// bridge is told to attach a stable session, so on restart this pre-flight read — not the
|
|
255
|
+
// drain — is what discovers the terminal. Reporting it as an ordinary `session_terminal` here
|
|
256
|
+
// would hand the supervisor exit 11 ("restart me") for a session a human deliberately killed,
|
|
257
|
+
// which is precisely the auto-restart that undoes the operator's stop.
|
|
258
|
+
if (session.closed_by_operator === true) {
|
|
259
|
+
throw new CliError("session_closed_by_operator", `the attached session ${session.id} (from ${from}) was closed by an account human — the §16.4 operator ` +
|
|
260
|
+
"kill-switch. This is a deliberate STOP: do NOT restart and do NOT start a replacement session. Senders " +
|
|
261
|
+
"waiting on this agent were already unblocked by the §14.2 bounce. Resume only when a human says so.");
|
|
262
|
+
}
|
|
263
|
+
throw new CliError("session_terminal", `the attached session ${session.id} (from ${from}) is ` +
|
|
264
|
+
`${session.state}, not active. §16.3 terminal states are immutable, so it cannot be revived: start a new session ` +
|
|
265
|
+
"(`oh-hai session start`), export the new id, and re-publish the address to anyone who had it.");
|
|
266
|
+
}
|
|
267
|
+
return session;
|
|
268
|
+
}
|
|
269
|
+
const session = await registerSession(ctx, identity.token, {
|
|
270
|
+
run_id: resolveRunId(),
|
|
271
|
+
kind: "cli",
|
|
272
|
+
label: options.label ?? "oh-hai bridge",
|
|
273
|
+
});
|
|
274
|
+
rememberSession(ctx, identity.agentId, session);
|
|
275
|
+
ctx.io.err(`oh-hai bridge: no session was attached, so one was registered — ${session.id}. Others address this run at ` +
|
|
276
|
+
`--to agent:${session.agent_id}#${session.id}. Export it (export MA2H_SESSION_ID=${session.id}) before re-invoking, ` +
|
|
277
|
+
"or every invocation gets a NEW address and senders lose track of you.");
|
|
278
|
+
return session;
|
|
279
|
+
}
|
|
280
|
+
/** `explicitSession` reads a raw flag record; the bridge has already parsed its flags, so hand it
|
|
281
|
+
* back the one key it consumes rather than threading the whole record through. Omitting the key
|
|
282
|
+
* (rather than passing `undefined`) is what lets its `MA2H_SESSION_ID` fallback apply. */
|
|
283
|
+
function flagsWithSession(options) {
|
|
284
|
+
return options.session !== undefined ? { session: options.session } : {};
|
|
285
|
+
}
|
|
286
|
+
// ---- one hold, per transport ----
|
|
287
|
+
/**
|
|
288
|
+
* One SSE hold: connect, consume, and return when the Hub bounds the hold.
|
|
289
|
+
*
|
|
290
|
+
* THE BOUNDED CLOSE IS A NORMAL RETURN, not an exception — that single choice is what keeps the
|
|
291
|
+
* bridge's own lease alive. The Hub closes each hold with `event: reconnect {"reason":"hold_bound"}`
|
|
292
|
+
* precisely so the client reconnects, and the CONNECT is the §16.2 renewal (an open socket renews
|
|
293
|
+
* nothing: SSE is unidirectional and TCP half-open, so the Hub cannot tell a live client from a
|
|
294
|
+
* corpse). A bridge that treated this as a fault and backed off exponentially would let its OWN
|
|
295
|
+
* lease lapse and get its mail bounced — the exact failure backoff is supposed to prevent.
|
|
296
|
+
*/
|
|
297
|
+
async function oneStreamHold(ctx, token, session, streamUrl, policy, guard, options) {
|
|
298
|
+
let emitted = 0;
|
|
299
|
+
for await (const event of readInboxStream(ctx, token, session, streamUrl)) {
|
|
300
|
+
if (event.type === "entries") {
|
|
301
|
+
emitted += await handleEntries(ctx, token, session, event.entries, policy, guard);
|
|
302
|
+
// `--until-event` stops at the first delivered entry; leaving the loop closes the stream via
|
|
303
|
+
// the generator's cleanup, and the entries were acked before we got here.
|
|
304
|
+
if (options.untilEvent && emitted > 0)
|
|
305
|
+
return emitted;
|
|
306
|
+
}
|
|
307
|
+
// `open` and `reconnect` need no handling beyond the loop's own control flow: `open` states the
|
|
308
|
+
// bound (already applied inside the client's deadline) and `reconnect` ends the iteration.
|
|
309
|
+
}
|
|
310
|
+
return emitted;
|
|
311
|
+
}
|
|
312
|
+
/** One long-poll cycle: drain, hand off, ack — then wait `--interval` if the mailbox was empty.
|
|
313
|
+
* The drain itself is the §16.2 renewal AND the §15 presence heartbeat, so an empty cycle is not
|
|
314
|
+
* wasted work; it is what keeps the session `online`. */
|
|
315
|
+
async function onePollCycle(ctx, token, session, policy, guard, options) {
|
|
316
|
+
const entries = await drainInboxSession(ctx, token, session, options.max);
|
|
317
|
+
const emitted = await handleEntries(ctx, token, session, entries, policy, guard);
|
|
318
|
+
if (emitted === 0)
|
|
319
|
+
await ctx.runtime.sleep(options.intervalMs);
|
|
320
|
+
return emitted;
|
|
321
|
+
}
|
|
322
|
+
// ---- the §13.4 handoff ----
|
|
323
|
+
/**
|
|
324
|
+
* Verify → confirm addressee → policy → dedup-reserve → EMIT → FLUSH → ACK, in that order.
|
|
325
|
+
*
|
|
326
|
+
* The ordering is the safety property, not a style. Acking before the durable handoff silently drops
|
|
327
|
+
* mail on a crash; and because `io.log` only QUEUES a write, a bridge piped into a runtime under
|
|
328
|
+
* backpressure can have bytes still sitting in its own buffer when it acks. So the flush is a real
|
|
329
|
+
* write-callback barrier awaited BEFORE the ack — and when it fails (EPIPE: the runtime closed the
|
|
330
|
+
* pipe) the reservations are released and nothing is acked, so the Hub redelivers to the next run.
|
|
331
|
+
*
|
|
332
|
+
* A refusal is never acked, with one exception: a redelivery of work this run already handled
|
|
333
|
+
* durably must be acked, or the Hub keeps redelivering it forever. That mirrors the reference
|
|
334
|
+
* oracle's split between "benign redelivery" and "policy/addressee refusal".
|
|
335
|
+
*/
|
|
336
|
+
async function handleEntries(ctx, token, session, entries, policy, guard) {
|
|
337
|
+
const toAck = [];
|
|
338
|
+
const reserved = [];
|
|
339
|
+
let emitted = 0;
|
|
340
|
+
for (const entry of entries) {
|
|
341
|
+
// Throws on the §13.4 verification classes — fatal, exit 12, BEFORE anything is printed.
|
|
342
|
+
const verdict = verifyEntry(entry, policy, guard, Date.now());
|
|
343
|
+
if (verdict.kind === "refuse") {
|
|
344
|
+
ctx.io.err(`oh-hai bridge: refused a ${verdict.entryKind} entry — ${verdict.reason}`);
|
|
345
|
+
if (isBenignRedelivery(verdict))
|
|
346
|
+
toAck.push(ackKeyOf(entry));
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
emitEntry(ctx, entry, token);
|
|
350
|
+
emitted += 1;
|
|
351
|
+
reserved.push(verdict.ackKey);
|
|
352
|
+
toAck.push(verdict.ackKey);
|
|
353
|
+
}
|
|
354
|
+
if (toAck.length === 0)
|
|
355
|
+
return emitted;
|
|
356
|
+
try {
|
|
357
|
+
await ctx.runtime.flushOutput?.();
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
// The handoff did NOT complete, so nothing may be acked. Release the reservations so the Hub's
|
|
361
|
+
// redelivery is re-emitted by the next run rather than suppressed as "already handled".
|
|
362
|
+
for (const key of reserved)
|
|
363
|
+
guard.release(key);
|
|
364
|
+
throw error;
|
|
365
|
+
}
|
|
366
|
+
await ackInboxSession(ctx, token, session, toAck);
|
|
367
|
+
return emitted;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Hand one entry to the agent runtime. stdout IS the entry stream.
|
|
371
|
+
*
|
|
372
|
+
* Under `--json` the delivery is emitted BYTE-VERBATIM inside one NDJSON envelope. That is
|
|
373
|
+
* deliberate and must not be "cleaned up": the detached `signature` is computed over these exact
|
|
374
|
+
* bytes, so mutating the payload — even to strip an echoed token — would break the signature a
|
|
375
|
+
* defense-in-depth runtime verifies against the Hub key, and the bridge would then be acking an
|
|
376
|
+
* entry its consumer could not authenticate. `kind` is added ALONGSIDE (never inside) the payload so
|
|
377
|
+
* a consumer can switch without re-deriving it.
|
|
378
|
+
*
|
|
379
|
+
* The HUMAN summary carries no signature contract, so it stays hardened (§5.4): terminal-sanitized
|
|
380
|
+
* and bearer-redacted, because a person may read or log it.
|
|
381
|
+
*/
|
|
382
|
+
function emitEntry(ctx, entry, token) {
|
|
383
|
+
const kind = entryKindOf(entry);
|
|
384
|
+
if (ctx.json) {
|
|
385
|
+
ctx.io.log(serializeEnvelope(buildOk("bridge", { kind, ...entry })));
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const summary = humanSummary(entry, kind);
|
|
389
|
+
ctx.io.log(redactToken(summary, token) ?? summary);
|
|
390
|
+
}
|
|
391
|
+
function humanSummary(entry, kind) {
|
|
392
|
+
const s = sanitizeForTerminal;
|
|
393
|
+
if ("directive" in entry) {
|
|
394
|
+
const d = entry.directive;
|
|
395
|
+
return `📨 ${kind} · ${s(d.id)} · ${s(d.from)} · ${s(d.title)}`;
|
|
396
|
+
}
|
|
397
|
+
if ("message" in entry) {
|
|
398
|
+
const m = entry.message;
|
|
399
|
+
return `🤝 ${kind}/${s(m.type)} · ${s(m.id)} · ${s(m.from)} · ${s(m.title)}`;
|
|
400
|
+
}
|
|
401
|
+
if ("response" in entry) {
|
|
402
|
+
const r = entry.response;
|
|
403
|
+
return `✅ ${kind} · ${s(r.resolution_id)} · in reply to ${s(r.in_reply_to)} · ${s(r.resolution)}`;
|
|
404
|
+
}
|
|
405
|
+
const rc = entry.receipt;
|
|
406
|
+
return `⚠️ ${kind} · ${s(rc.id)} · ${s(rc.event)} · in reply to ${s(rc.in_reply_to)} (was ${s(rc.prior)})`;
|
|
407
|
+
}
|
|
408
|
+
// ---- `oh-hai bridge status` ----
|
|
409
|
+
/**
|
|
410
|
+
* The human surface of a machine primitive.
|
|
411
|
+
*
|
|
412
|
+
* A supervised bridge writes its entries to a pipe and its diagnostics to stderr, so when something
|
|
413
|
+
* looks wrong the operator has nowhere to look. `status` answers the questions they actually have —
|
|
414
|
+
* is my session still alive, which transport would be used, is a policy declared — WITHOUT side
|
|
415
|
+
* effects: it never registers a session and never drains, so running it while a bridge is live
|
|
416
|
+
* cannot consume that bridge's mail.
|
|
417
|
+
*/
|
|
418
|
+
async function bridgeStatus(ctx, flags) {
|
|
419
|
+
const options = parseOptions(flags);
|
|
420
|
+
const identity = await resolveSubmitIdentity(ctx);
|
|
421
|
+
const capability = await fetchCapability(ctx);
|
|
422
|
+
const attached = explicitSession(flagsWithSession(options));
|
|
423
|
+
// Read-only: an attached session's real Hub-side state, or nothing. A `status` that MINTED a
|
|
424
|
+
// session to have something to report would burn a §16.1 registration slot per invocation and
|
|
425
|
+
// report on a session no bridge is using.
|
|
426
|
+
const session = attached !== undefined ? await getSession(ctx, identity.token, attached.id) : undefined;
|
|
427
|
+
const transport = transportOf(ctx, capability, options);
|
|
428
|
+
if (ctx.json) {
|
|
429
|
+
ctx.io.log(serializeEnvelope(buildOk("bridge.status", {
|
|
430
|
+
agent_id: identity.agentId,
|
|
431
|
+
session: session ?? null,
|
|
432
|
+
session_source: attached?.source ?? null,
|
|
433
|
+
transport,
|
|
434
|
+
hub: {
|
|
435
|
+
ma2h_version: capability?.ma2h_version ?? null,
|
|
436
|
+
session_param: capability?.inbound?.session_param ?? null,
|
|
437
|
+
stream_url: capability?.inbound?.stream_url ?? null,
|
|
438
|
+
stream_max_hold_seconds: capability?.inbound?.stream_max_hold_seconds ?? null,
|
|
439
|
+
},
|
|
440
|
+
allow_from: options.allowFrom,
|
|
441
|
+
exit_codes: {
|
|
442
|
+
"0": "success",
|
|
443
|
+
"3": "auth — the credential is dead; a human must fix it (do NOT restart-loop)",
|
|
444
|
+
"11": "session terminal (lease lapsed) — restart; the new run registers a fresh session",
|
|
445
|
+
"12": "signature/verification failure — possible tampering; surface to a human",
|
|
446
|
+
"13": "retries exhausted — restartable, with the supervisor's own backoff",
|
|
447
|
+
"14": "closed by the §16.4 operator kill-switch — a human STOPPED this agent; do NOT restart",
|
|
448
|
+
},
|
|
449
|
+
})));
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const s = sanitizeForTerminal;
|
|
453
|
+
ctx.io.log("oh-hai bridge — status");
|
|
454
|
+
ctx.io.log(` agent: ${s(identity.agentId)}`);
|
|
455
|
+
if (session !== undefined) {
|
|
456
|
+
ctx.io.log(` session: ${s(session.id)} (${s(session.state)}, from ${attached?.source ?? "?"})`);
|
|
457
|
+
ctx.io.log(` lease: expires ${s(session.expires_at)}`);
|
|
458
|
+
ctx.io.log(` address: agent:${s(session.agent_id)}#${s(session.id)}`);
|
|
459
|
+
if (session.state !== "active") {
|
|
460
|
+
// The two terminals give OPPOSITE advice, so `status` must not print one legend for both
|
|
461
|
+
// (issue #683 §5). Telling an operator investigating a session they themselves closed to
|
|
462
|
+
// "start a new one" is an instruction to undo their own kill-switch — from the very command
|
|
463
|
+
// they ran to find out what happened.
|
|
464
|
+
ctx.io.err(session.closed_by_operator === true
|
|
465
|
+
? "oh-hai bridge: that session was CLOSED BY AN ACCOUNT HUMAN — the §16.4 kill-switch. A bridge presenting it " +
|
|
466
|
+
"exits 14, a STOP. Do not start a replacement session unless you intend to undo that decision; senders " +
|
|
467
|
+
"waiting on this agent were already unblocked by the §14.2 bounce."
|
|
468
|
+
: "oh-hai bridge: that session is TERMINAL — a bridge presenting it exits 11 immediately. Start a new one " +
|
|
469
|
+
"(`oh-hai session start`) and re-publish the address; §16.3 terminals are immutable.");
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
ctx.io.log(" session: (none attached — a bridge would register one and print its address)");
|
|
474
|
+
}
|
|
475
|
+
ctx.io.log(` hub: MA2H ${s(capability?.ma2h_version ?? "(unreadable)")}`);
|
|
476
|
+
ctx.io.log(` transport: ${transport}${capability?.inbound?.stream_max_hold_seconds !== undefined ? ` (hold ceiling ${capability.inbound.stream_max_hold_seconds}s; each hold's real bound arrives as hold_ms)` : ""}`);
|
|
477
|
+
ctx.io.log(` policy: ${options.allowFrom.length > 0 ? s(options.allowFrom.join(", ")) : "(none declared — every addressed ask/task is refused, §13.4)"}`);
|
|
478
|
+
ctx.io.log("");
|
|
479
|
+
ctx.io.log("Exit codes a supervisor must distinguish:");
|
|
480
|
+
ctx.io.log(" 3 auth failed — the credential is dead. STOP; a human fixes it. Never restart-loop.");
|
|
481
|
+
ctx.io.log(" 11 session terminal (lease lapsed) — RESTART; the new run registers a fresh session.");
|
|
482
|
+
ctx.io.log(" 12 verification failure — possible tampering. STOP and surface to a human.");
|
|
483
|
+
ctx.io.log(" 13 retries exhausted — RESTART with the supervisor's own backoff.");
|
|
484
|
+
ctx.io.log(" 14 closed by the §16.4 kill-switch — a HUMAN stopped this agent. STOP; restarting undoes their decision.");
|
|
485
|
+
}
|
|
486
|
+
function transportOf(ctx, capability, options) {
|
|
487
|
+
if (options.transport === "poll")
|
|
488
|
+
return "poll (forced)";
|
|
489
|
+
let streamUrl;
|
|
490
|
+
try {
|
|
491
|
+
streamUrl = streamUrlFor(ctx, capability);
|
|
492
|
+
}
|
|
493
|
+
catch {
|
|
494
|
+
// `status` reports; it does not refuse. An off-origin advertised stream URL is reported as
|
|
495
|
+
// unusable rather than thrown, so the operator still gets the rest of the picture.
|
|
496
|
+
return "poll (the Hub advertises an off-origin stream_url, which the bridge refuses)";
|
|
497
|
+
}
|
|
498
|
+
if (streamUrl !== undefined)
|
|
499
|
+
return "sse";
|
|
500
|
+
return options.transport === "sse" ? "sse REQUESTED but unavailable (this Hub advertises no stream_url)" : "poll (no stream advertised)";
|
|
501
|
+
}
|
|
502
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../src/commands/bridge.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,gGAAgG;AAChG,mGAAmG;AACnG,mFAAmF;AACnF,EAAE;AACF,qFAAqF;AACrF,EAAE;AACF,qGAAqG;AACrG,kGAAkG;AAClG,mGAAmG;AACnG,mGAAmG;AACnG,iBAAiB;AACjB,sGAAsG;AACtG,qGAAqG;AACrG,oGAAoG;AACpG,4DAA4D;AAC5D,EAAE;AACF,kGAAkG;AAClG,oGAAoG;AACpG,mGAAmG;AACnG,+FAA+F;AAC/F,qGAAqG;AACrG,gGAAgG;AAChG,mDAAmD;AACnD,EAAE;AACF,iGAAiG;AACjG,oGAAoG;AACpG,4FAA4F;AAE5F,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;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AO,CAAC,SAAS,KAAK,MAAM;QAAE,OAAO,eAAe,CAAC;IACzD,IAAI,SAA6B,CAAC;IAClC,IAAI,CAAC;QACH,SAAS,GAAG,YAAY,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,2FAA2F;QAC3F,mFAAmF;QACnF,OAAO,8EAA8E,CAAC;IACxF,CAAC;IACD,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC1C,OAAO,OAAO,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,mEAAmE,CAAC,CAAC,CAAC,6BAA6B,CAAC;AAC3I,CAAC"}
|
|
@@ -28,6 +28,28 @@ export interface HttpResponse {
|
|
|
28
28
|
/** The response body as text — read only by the binary self-update (#358), to download the
|
|
29
29
|
* `SHA256SUMS` checksum file. Optional for the same reason as `arrayBuffer`. */
|
|
30
30
|
text?(): Promise<string>;
|
|
31
|
+
/** The response body as an INCREMENTALLY READABLE stream — read only by `oh-hai bridge`'s SSE
|
|
32
|
+
* client (#658), which must consume events as they arrive over a held connection rather than
|
|
33
|
+
* awaiting a completed body. Optional like the readers above (a status-only / JSON fake still
|
|
34
|
+
* satisfies the type); `null` mirrors the DOM, which uses it for a bodiless response.
|
|
35
|
+
*
|
|
36
|
+
* Typed structurally rather than as `ReadableStream<Uint8Array>` for the same reason `headers`
|
|
37
|
+
* is: production `fetch` returns a real `ReadableStream`, which is structurally assignable, while
|
|
38
|
+
* a hermetic test can hand back a three-line fake reader with no web-streams dependency. */
|
|
39
|
+
body?: HttpBody | null;
|
|
40
|
+
}
|
|
41
|
+
/** The slice of a `ReadableStream<Uint8Array>` the SSE client uses (see `HttpResponse.body`). */
|
|
42
|
+
export interface HttpBody {
|
|
43
|
+
getReader(): HttpBodyReader;
|
|
44
|
+
}
|
|
45
|
+
export interface HttpBodyReader {
|
|
46
|
+
read(): Promise<{
|
|
47
|
+
done: boolean;
|
|
48
|
+
value?: Uint8Array | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
/** Abandon the rest of the body. Optional — a fake reader need not implement it, and the client
|
|
51
|
+
* also aborts the request itself, so cancellation is never load-bearing on this alone. */
|
|
52
|
+
cancel?(): Promise<void>;
|
|
31
53
|
}
|
|
32
54
|
/** The subset of `fetch` the CLI uses. `body` carries a JSON request payload (the device-code
|
|
33
55
|
* POSTs); it's optional so a bodyless GET (`whoami --check`) is unaffected. Real `fetch`'s return
|
package/dist/commands/doctor.js
CHANGED
|
@@ -23,6 +23,7 @@ import { buildNotify } from "./messaging/build.js";
|
|
|
23
23
|
import { submitEnvelope } from "./messaging/http.js";
|
|
24
24
|
import { resolveSubmitIdentity } from "./messaging/identity.js";
|
|
25
25
|
import { resolveRunId } from "./messaging/shared.js";
|
|
26
|
+
import { runSelfTest } from "./self-test.js";
|
|
26
27
|
import { checkForUpdate } from "./update-check.js";
|
|
27
28
|
/** Default per-request bound for the network probes when no --timeout/MA2H_TIMEOUT_MS is set —
|
|
28
29
|
* §9 promises offline is an explicit state, never a silent hang. Mirrors whoami's checkToken. */
|
|
@@ -134,8 +135,9 @@ function emitReport(ctx, checks) {
|
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
export async function doctorCommand(ctx) {
|
|
137
|
-
const { values } = parseCommandArgs(ctx.argv, { "test-notify": { type: "boolean" } });
|
|
138
|
+
const { values } = parseCommandArgs(ctx.argv, { "test-notify": { type: "boolean" }, "self-test": { type: "boolean" } });
|
|
138
139
|
const testNotify = flagOn(values["test-notify"]);
|
|
140
|
+
const selfTest = flagOn(values["self-test"]);
|
|
139
141
|
// Open the store once and reuse it for BOTH the keychain-availability signal and identity
|
|
140
142
|
// resolution. Unlike whoami (which skips the store for an env token), doctor opens it even for an
|
|
141
143
|
// env token — reporting keychain status is the point of a diagnostic, and openStore()'s probe is
|
|
@@ -255,6 +257,15 @@ export async function doctorCommand(ctx) {
|
|
|
255
257
|
if (testNotify) {
|
|
256
258
|
checks.push(await testNotifyCheck(ctx));
|
|
257
259
|
}
|
|
260
|
+
// 7. The END-TO-END SELF-TEST (REQUIRED when asked for, opt-in, #660). Unlike every other check
|
|
261
|
+
// here it proves the loop rather than a precondition: session → self-addressed send → drain →
|
|
262
|
+
// §13.4 → ack → reachability. Its steps are REQUIRED — "no green, no done" is the whole point,
|
|
263
|
+
// and an advisory reachability check would let a machine that cannot be reached report a clean
|
|
264
|
+
// doctor. It runs LAST so a broken token / unreachable Hub is named by the cheap local checks
|
|
265
|
+
// first, rather than surfacing as a confusing failure five network calls deep.
|
|
266
|
+
if (selfTest) {
|
|
267
|
+
checks.push(...(await runSelfTest(ctx)));
|
|
268
|
+
}
|
|
258
269
|
emitReport(ctx, checks);
|
|
259
270
|
// Exit code = the first failing REQUIRED check's code (config is checked before token, so a bad
|
|
260
271
|
// base URL wins over a missing token); undefined (→ exit 0) when every required check passed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,2FAA2F;AAC3F,6FAA6F;AAC7F,kGAAkG;AAClG,+FAA+F;AAC/F,yFAAyF;AACzF,+FAA+F;AAC/F,gGAAgG;AAChG,2DAA2D;AAC3D,EAAE;AACF,mGAAmG;AACnG,8FAA8F;AAC9F,oGAAoG;AACpG,mGAAmG;AACnG,6CAA6C;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MA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