@oh-hai/cli 0.1.0-beta.0 → 0.2.1
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 +51 -8
- package/dist/auth/resolve-token.d.ts +2 -4
- package/dist/auth/resolve-token.js +4 -11
- package/dist/auth/resolve-token.js.map +1 -1
- package/dist/bindings.d.ts +65 -0
- package/dist/bindings.js +242 -0
- package/dist/bindings.js.map +1 -0
- package/dist/cli.js +211 -12
- package/dist/cli.js.map +1 -1
- package/dist/commands/ask.js +21 -17
- package/dist/commands/ask.js.map +1 -1
- package/dist/commands/binary-update.d.ts +61 -0
- package/dist/commands/binary-update.js +160 -0
- package/dist/commands/binary-update.js.map +1 -0
- package/dist/commands/context.d.ts +135 -0
- package/dist/commands/doctor.js +30 -3
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/flags.d.ts +14 -2
- package/dist/commands/flags.js +34 -6
- package/dist/commands/flags.js.map +1 -1
- package/dist/commands/handlers.js +8 -0
- package/dist/commands/handlers.js.map +1 -1
- package/dist/commands/inbox.js +129 -33
- package/dist/commands/inbox.js.map +1 -1
- package/dist/commands/login.d.ts +13 -0
- package/dist/commands/login.js +35 -27
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/messaging/identity.d.ts +9 -0
- package/dist/commands/messaging/identity.js +21 -0
- package/dist/commands/messaging/identity.js.map +1 -1
- package/dist/commands/messaging/validate.d.ts +6 -5
- package/dist/commands/messaging/validate.js +7 -16
- package/dist/commands/messaging/validate.js.map +1 -1
- package/dist/commands/registry.js +88 -8
- package/dist/commands/registry.js.map +1 -1
- package/dist/commands/setup.d.ts +26 -0
- package/dist/commands/setup.js +221 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/task.js +21 -24
- package/dist/commands/task.js.map +1 -1
- package/dist/commands/teach.d.ts +13 -0
- package/dist/commands/teach.js +317 -0
- package/dist/commands/teach.js.map +1 -0
- package/dist/commands/update-check.d.ts +49 -0
- package/dist/commands/update-check.js +203 -0
- package/dist/commands/update-check.js.map +1 -0
- package/dist/commands/upgrade.d.ts +2 -0
- package/dist/commands/upgrade.js +178 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/use.d.ts +2 -0
- package/dist/commands/use.js +99 -0
- package/dist/commands/use.js.map +1 -0
- package/dist/commands/whoami.js +113 -27
- package/dist/commands/whoami.js.map +1 -1
- package/dist/config-file.js +4 -20
- package/dist/config-file.js.map +1 -1
- package/dist/config.d.ts +15 -1
- package/dist/config.js +43 -4
- package/dist/config.js.map +1 -1
- package/dist/exit-codes.d.ts +6 -0
- package/dist/exit-codes.js +6 -0
- package/dist/exit-codes.js.map +1 -1
- package/dist/help.js +5 -1
- package/dist/help.js.map +1 -1
- package/dist/onboarding/open-url.d.ts +26 -0
- package/dist/onboarding/open-url.js +69 -0
- package/dist/onboarding/open-url.js.map +1 -0
- package/dist/onboarding/status.d.ts +24 -0
- package/dist/onboarding/status.js +53 -0
- package/dist/onboarding/status.js.map +1 -0
- package/dist/os.d.ts +16 -0
- package/dist/os.js +32 -0
- package/dist/os.js.map +1 -0
- package/dist/url.d.ts +8 -0
- package/dist/url.js +29 -0
- package/dist/url.js.map +1 -0
- package/dist/version.d.ts +11 -3
- package/dist/version.js +20 -3
- package/dist/version.js.map +1 -1
- package/dist/watch-lock.d.ts +85 -0
- package/dist/watch-lock.js +358 -0
- package/dist/watch-lock.js.map +1 -0
- package/package.json +2 -2
package/dist/commands/inbox.js
CHANGED
|
@@ -12,20 +12,27 @@
|
|
|
12
12
|
// loop's. The signed delivery `{ directive, signature }` is forwarded VERBATIM so a runtime that
|
|
13
13
|
// wants defense-in-depth can verify it against the Hub key. In-session `id` dedup (§13.4) IS handled
|
|
14
14
|
// here (see the loop). Sibling subcommands (`inbox list` / `inbox ack`) and long-poll are out of scope.
|
|
15
|
-
import {
|
|
15
|
+
import { originOf } from "../auth/resolve-token.js";
|
|
16
|
+
import { CliError, buildOk, serializeEnvelope } from "../envelope.js";
|
|
17
|
+
import { acquireWatchLock } from "../watch-lock.js";
|
|
16
18
|
import { parseSubcommandArgs } from "./flags.js";
|
|
17
19
|
import { ackInbox, drainInbox, redactToken } from "./messaging/http.js";
|
|
18
|
-
import {
|
|
20
|
+
import { requireWatchIdentity } from "./messaging/identity.js";
|
|
19
21
|
import { positiveInt, sanitizeForTerminal, strictBoolFlag, stringFlag } from "./messaging/shared.js";
|
|
20
22
|
const SUBCOMMANDS = ["watch"];
|
|
21
23
|
const INBOX_WATCH_OPTIONS = {
|
|
22
24
|
interval: { type: "string" },
|
|
23
25
|
max: { type: "string" },
|
|
24
26
|
once: { type: "boolean" },
|
|
27
|
+
force: { type: "boolean" },
|
|
25
28
|
};
|
|
26
29
|
/** Default poll cadence (ms). Well under the Hub's 90s presence-freshness window so the agent stays
|
|
27
30
|
* `online` between polls, and responsive to arriving directives without hammering the Hub. */
|
|
28
31
|
const DEFAULT_INTERVAL_MS = 5000;
|
|
32
|
+
/** Consecutive failed heartbeats before the guard warns (#323). Past a few misses the lock's heartbeat
|
|
33
|
+
* is frozen and a peer may reclaim it while this watcher keeps draining — a silent double-drain we
|
|
34
|
+
* surface once. Above 1 so a single transient write blip doesn't cry wolf. */
|
|
35
|
+
const HEARTBEAT_FAILURE_WARN_THRESHOLD = 3;
|
|
29
36
|
/** A sane upper bound for `--max` (a drain batch size, not a timer): generous enough to never reject a
|
|
30
37
|
* realistic mailbox drain, small enough to reject an absurd `?max=` — the Hub clamps to its own cap
|
|
31
38
|
* regardless. Distinct from the timer ceiling `--interval` uses. */
|
|
@@ -42,9 +49,17 @@ async function inboxWatch(ctx, flags) {
|
|
|
42
49
|
// Strict boolean: a mistyped `--once=treu` is a usage error, not a silent fall-through to the
|
|
43
50
|
// infinite watch loop (it would keep draining + acking every interval instead of a one-shot).
|
|
44
51
|
const once = strictBoolFlag(flags.once, "--once");
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
// `--force` takes over a lock held by another watcher for this identity (see the guard below).
|
|
53
|
+
const force = strictBoolFlag(flags.force, "--force");
|
|
54
|
+
// The mailbox is selected by the bearer (the Hub derives the agent from the token), so the drain
|
|
55
|
+
// needs only a token — like `await`. But the concurrent-drain guard keys on the AGENT ID (the mailbox
|
|
56
|
+
// is per-agent, not per-token: one agent can hold several bearers), so resolve both here.
|
|
57
|
+
const { token, agentId } = await requireWatchIdentity(ctx);
|
|
58
|
+
// Concurrent-drain guard (#323): `inbox watch` is a DESTRUCTIVE drain+ack, so two watchers sharing
|
|
59
|
+
// one identity race to consume the same directive. Acquire an agent-scoped lock before the loop,
|
|
60
|
+
// refuse a live second watcher (unless --force), and release on exit. Skipped when no lock seam is
|
|
61
|
+
// wired (hermetic callers) — production always wires one, so the guard is active in the shipped CLI.
|
|
62
|
+
const lock = acquireWatchGuard(ctx, agentId, intervalMs, force);
|
|
48
63
|
// Cross-poll dedup (§13.4): once a directive id has been emitted AND its batch acked, a later
|
|
49
64
|
// redelivery of that same id (fresh t/jti, after a crash or the server's visibility timeout) is
|
|
50
65
|
// suppressed from re-emission — but still acked so the Hub consumes it. `seen` commits only AFTER a
|
|
@@ -54,36 +69,117 @@ async function inboxWatch(ctx, flags) {
|
|
|
54
69
|
// set (dp-007), the runtime's concern, not this loop's. A long-lived watch grows `seen` with
|
|
55
70
|
// directive volume; acceptable for v1.
|
|
56
71
|
const seen = new Set();
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
for (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
// Track sustained heartbeat failure so a frozen-heartbeat watcher warns instead of silently letting a
|
|
73
|
+
// peer reclaim its identity mid-drain (#323). Reset on any successful heartbeat.
|
|
74
|
+
let heartbeatFailures = 0;
|
|
75
|
+
let heartbeatWarned = false;
|
|
76
|
+
try {
|
|
77
|
+
for (;;) {
|
|
78
|
+
// Refresh the heartbeat each poll so a live watcher isn't seen as stale, while a crashed one
|
|
79
|
+
// ages out and becomes reclaimable. Best-effort (a failed write never crashes the loop) — but a
|
|
80
|
+
// SUSTAINED failure means our heartbeat is frozen; warn once so the operator knows the guard may
|
|
81
|
+
// have silently degraded and a second watcher could now be draining too.
|
|
82
|
+
if (lock !== undefined && !lock.heartbeat()) {
|
|
83
|
+
heartbeatFailures += 1;
|
|
84
|
+
if (!heartbeatWarned && heartbeatFailures >= HEARTBEAT_FAILURE_WARN_THRESHOLD) {
|
|
85
|
+
heartbeatWarned = true;
|
|
86
|
+
ctx.io.err(`⚠️ oh-hai: the watch-lock heartbeat has failed ${heartbeatFailures}× in a row (state dir ` +
|
|
87
|
+
`unwritable?) — another watcher may reclaim this identity while this one keeps draining.`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
heartbeatFailures = 0;
|
|
92
|
+
heartbeatWarned = false;
|
|
93
|
+
}
|
|
94
|
+
const { directives } = await drainInbox(ctx, token, max);
|
|
95
|
+
// The unique ids in THIS drain — both the ack list and the within-batch emit guard (a Hub could
|
|
96
|
+
// repeat an id inside one batch; emit it once and ack it once, not twice).
|
|
97
|
+
const batchIds = new Set();
|
|
98
|
+
for (const delivery of directives) {
|
|
99
|
+
const id = delivery.directive.id;
|
|
100
|
+
if (!seen.has(id) && !batchIds.has(id))
|
|
101
|
+
emitDirective(ctx, delivery, token);
|
|
102
|
+
batchIds.add(id);
|
|
103
|
+
}
|
|
104
|
+
if (batchIds.size > 0) {
|
|
105
|
+
// Flush stdout BEFORE acking so the emit-then-ack handoff is genuinely at-least-once: `io.log`
|
|
106
|
+
// only queues to stdout, so when `watch` is piped to a runtime under backpressure the bytes may
|
|
107
|
+
// still be buffered in this process. Acking first would let the Hub consume a directive that a
|
|
108
|
+
// crash/EPIPE could still lose before it reaches the consumer. `flushOutput` waits for the
|
|
109
|
+
// queued writes to complete (a write-callback barrier, not just the drain flag); THEN ack.
|
|
110
|
+
await ctx.runtime.flushOutput?.();
|
|
111
|
+
// The single batched consume-ack (§14) — one call per drained batch, deduped ids.
|
|
112
|
+
await ackInbox(ctx, token, [...batchIds]);
|
|
113
|
+
// Commit to the cross-poll dedup set only now that the batch is durably consumed.
|
|
114
|
+
for (const id of batchIds)
|
|
115
|
+
seen.add(id);
|
|
116
|
+
}
|
|
117
|
+
// --once: a single drain→emit→ack pass (cron / scripting / deterministic tests). Otherwise loop;
|
|
118
|
+
// the poll itself IS the presence heartbeat, so keep polling on the interval even on an empty drain.
|
|
119
|
+
if (once)
|
|
120
|
+
return;
|
|
121
|
+
await ctx.runtime.sleep(intervalMs);
|
|
67
122
|
}
|
|
68
|
-
if (batchIds.size > 0) {
|
|
69
|
-
// Flush stdout BEFORE acking so the emit-then-ack handoff is genuinely at-least-once: `io.log`
|
|
70
|
-
// only queues to stdout, so when `watch` is piped to a runtime under backpressure the bytes may
|
|
71
|
-
// still be buffered in this process. Acking first would let the Hub consume a directive that a
|
|
72
|
-
// crash/EPIPE could still lose before it reaches the consumer. `flushOutput` waits for the
|
|
73
|
-
// queued writes to complete (a write-callback barrier, not just the drain flag); THEN ack.
|
|
74
|
-
await ctx.runtime.flushOutput?.();
|
|
75
|
-
// The single batched consume-ack (§14) — one call per drained batch, deduped ids.
|
|
76
|
-
await ackInbox(ctx, token, [...batchIds]);
|
|
77
|
-
// Commit to the cross-poll dedup set only now that the batch is durably consumed.
|
|
78
|
-
for (const id of batchIds)
|
|
79
|
-
seen.add(id);
|
|
80
|
-
}
|
|
81
|
-
// --once: a single drain→emit→ack pass (cron / scripting / deterministic tests). Otherwise loop;
|
|
82
|
-
// the poll itself IS the presence heartbeat, so keep polling on the interval even on an empty drain.
|
|
83
|
-
if (once)
|
|
84
|
-
return;
|
|
85
|
-
await ctx.runtime.sleep(intervalMs);
|
|
86
123
|
}
|
|
124
|
+
finally {
|
|
125
|
+
// Release on every exit path (--once return, a thrown drain/ack error, the loop's stop). Deletes
|
|
126
|
+
// the lockfile only if it is still ours, so a reclaimer's lock is never removed. An abrupt SIGKILL
|
|
127
|
+
// skips this, but the dead pid then makes the lock reclaimable — the stale mechanism is the net.
|
|
128
|
+
lock?.release();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Acquire the per-agent watch lock (#323) and translate the outcome into user-facing behavior:
|
|
133
|
+
* refuse a live second watcher (`already_running`, exit 10), a `--force` steal warning, a
|
|
134
|
+
* stale-reclaim note, or an "unavailable" warning when no lock dir resolves — or when the agent id
|
|
135
|
+
* can't be resolved (the guard keys on the agent id, never the bearer). Returns the live handle to
|
|
136
|
+
* heartbeat/release, or undefined when there is no handle to manage (guard unavailable, or no lock
|
|
137
|
+
* seam wired — the hermetic-test path). All human notes go to stderr so the `--json` NDJSON stdout
|
|
138
|
+
* stream stays clean.
|
|
139
|
+
*/
|
|
140
|
+
function acquireWatchGuard(ctx, agentId, intervalMs, force) {
|
|
141
|
+
const io = ctx.runtime.watchLockIo;
|
|
142
|
+
if (io === undefined)
|
|
143
|
+
return undefined; // no seam wired → guard skipped (existing behavior)
|
|
144
|
+
if (agentId === undefined) {
|
|
145
|
+
// The mailbox is per-agent, so without a resolved agent id there's no correct key (the bearer is
|
|
146
|
+
// wrong — one agent can hold several). Degrade honestly rather than key on the token.
|
|
147
|
+
ctx.io.err("⚠️ oh-hai: concurrent-watch protection is unavailable (no resolvable agent id — set --account / " +
|
|
148
|
+
"MA2H_AGENT_ID, or log in). Proceeding without a lock — do not start a second watcher for this identity.");
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
const origin = originOf(ctx.config.baseUrl);
|
|
152
|
+
const outcome = acquireWatchLock(io, { origin, agentId, intervalMs, force });
|
|
153
|
+
if (outcome.kind === "held") {
|
|
154
|
+
const h = outcome.holder;
|
|
155
|
+
// `already_running` (exit 10), NOT `conflict`/exit 8: this is a LOCAL precondition conflict with no
|
|
156
|
+
// Hub call, distinct from a Hub 409, so a caller branching on the exit code never treats "stop the
|
|
157
|
+
// other watcher" (non-retryable) as a retryable idempotency conflict. See docs/specs/cli.md §7/§8.
|
|
158
|
+
// `holder` is undefined when a peer just won the create race and its record isn't readable yet.
|
|
159
|
+
const who = h !== undefined ? `(pid ${h.pid} on ${h.hostname}, watching ${h.origin} since ${new Date(h.startedAt).toISOString()})` : "(it just started; its lock is being written)";
|
|
160
|
+
throw new CliError("already_running", `another 'oh-hai inbox watch' is already draining this identity ${who}. Two watchers on one ` +
|
|
161
|
+
`identity race to drain the same mailbox — a directive delivered once is consumed by whichever ` +
|
|
162
|
+
`drains first, so the other agent can silently lose it. Stop the other watcher, or re-run with ` +
|
|
163
|
+
`--force to take over.`);
|
|
164
|
+
}
|
|
165
|
+
if (outcome.kind === "unavailable") {
|
|
166
|
+
ctx.io.err(`⚠️ oh-hai: concurrent-watch protection is unavailable (${outcome.reason}). Proceeding without a ` +
|
|
167
|
+
`lock — do not start a second 'oh-hai inbox watch' for this identity.`);
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
if (outcome.reclaimed?.wasLive) {
|
|
171
|
+
// Only reachable under --force: we stole a lock that still looked live.
|
|
172
|
+
const h = outcome.reclaimed.holder;
|
|
173
|
+
ctx.io.err(`⚠️ oh-hai: --force took over the watch lock held by pid ${h.pid} on ${h.hostname} (held since ` +
|
|
174
|
+
`${new Date(h.startedAt).toISOString()}). If that watcher is still running you now BOTH drain ` +
|
|
175
|
+
`this mailbox and will race for directives.`);
|
|
176
|
+
}
|
|
177
|
+
else if (outcome.reclaimed) {
|
|
178
|
+
const h = outcome.reclaimed.holder;
|
|
179
|
+
ctx.io.err(`oh-hai: reclaimed a stale watch lock from pid ${h.pid} on ${h.hostname} (last active ` +
|
|
180
|
+
`${new Date(h.heartbeatAt).toISOString()}).`);
|
|
181
|
+
}
|
|
182
|
+
return outcome.lock;
|
|
87
183
|
}
|
|
88
184
|
/** Hand one directive to the agent runtime. stdout is the directive STREAM.
|
|
89
185
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbox.js","sourceRoot":"","sources":["../../src/commands/inbox.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,+FAA+F;AAC/F,qGAAqG;AACrG,qGAAqG;AACrG,qGAAqG;AACrG,8GAA8G;AAC9G,EAAE;AACF,kGAAkG;AAClG,qGAAqG;AACrG,oGAAoG;AACpG,mGAAmG;AACnG,iGAAiG;AACjG,qGAAqG;AACrG,wGAAwG;AAExG,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"inbox.js","sourceRoot":"","sources":["../../src/commands/inbox.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,+FAA+F;AAC/F,qGAAqG;AACrG,qGAAqG;AACrG,qGAAqG;AACrG,8GAA8G;AAC9G,EAAE;AACF,kGAAkG;AAClG,qGAAqG;AACrG,oGAAoG;AACpG,mGAAmG;AACnG,iGAAiG;AACjG,qGAAqG;AACrG,wGAAwG;AAExG,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAkB,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGrG,MAAM,WAAW,GAAG,CAAC,OAAO,CAAU,CAAC;AAEvC,MAAM,mBAAmB,GAAG;IAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC5B,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACv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AAQ,EAAE,CAAC;IAChI,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC;AACrD,CAAC"}
|
package/dist/commands/login.d.ts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
1
|
import type { CommandContext } from "./context.js";
|
|
2
2
|
export declare function loginCommand(ctx: CommandContext): Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* The device-code acquisition (§4.3/§1, RFC 8628), shared by `oh-hai login`, `oh-hai setup`, and the
|
|
5
|
+
* bare-`oh-hai` first-run onboarding (#271). Requests a device code, opens the human's browser to the
|
|
6
|
+
* approval URL (falling back to PRINTING it), prompts on STDERR (stdout stays reserved for the single
|
|
7
|
+
* `--json` envelope, §8), then polls until the human approves — storing the returned bearer under
|
|
8
|
+
* `<origin>|<agent id>`. The agent id comes FROM the token response (the human chose which agent to
|
|
9
|
+
* bind at approval time, in the browser), so this path needs no `--account`, unlike `--token-stdin`.
|
|
10
|
+
* `command` is the §8 envelope label the success reports under — "login" for `oh-hai login`, "setup"
|
|
11
|
+
* for the onboarding entrypoints — so `--json` automation dispatching on `command` stays consistent.
|
|
12
|
+
* Returns the AGENT ID the approved bearer was stored under (the one the human bound in the browser),
|
|
13
|
+
* so the onboarding caller can reconcile it against the resolver's precedence and give honest next steps.
|
|
14
|
+
*/
|
|
15
|
+
export declare function runDeviceCodeFlow(ctx: CommandContext, command?: string): Promise<string>;
|
package/dist/commands/login.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { CliError, buildOk, serializeEnvelope } from "../envelope.js";
|
|
10
10
|
import { originOf } from "../auth/resolve-token.js";
|
|
11
11
|
import { sanitizeForTerminal } from "../terminal.js";
|
|
12
|
+
import { isHttpUrl } from "../url.js";
|
|
12
13
|
import { flagOn, parseCommandArgs } from "./flags.js";
|
|
13
14
|
import { throwTransportError } from "./http.js";
|
|
14
15
|
/** Per-request bound for each device-grant POST when no `--timeout`/`MA2H_TIMEOUT_MS` is set. It
|
|
@@ -36,7 +37,7 @@ export async function loginCommand(ctx) {
|
|
|
36
37
|
await tokenStdinLogin(ctx);
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
39
|
-
await
|
|
40
|
+
await runDeviceCodeFlow(ctx);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
/** `--token-stdin` (§4.3): read a bearer from stdin (local bootstrap / paste) and store it the same
|
|
@@ -54,19 +55,35 @@ async function tokenStdinLogin(ctx) {
|
|
|
54
55
|
await storeAndReport(ctx, account, token);
|
|
55
56
|
}
|
|
56
57
|
/**
|
|
57
|
-
* The
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
58
|
+
* The device-code acquisition (§4.3/§1, RFC 8628), shared by `oh-hai login`, `oh-hai setup`, and the
|
|
59
|
+
* bare-`oh-hai` first-run onboarding (#271). Requests a device code, opens the human's browser to the
|
|
60
|
+
* approval URL (falling back to PRINTING it), prompts on STDERR (stdout stays reserved for the single
|
|
61
|
+
* `--json` envelope, §8), then polls until the human approves — storing the returned bearer under
|
|
62
|
+
* `<origin>|<agent id>`. The agent id comes FROM the token response (the human chose which agent to
|
|
63
|
+
* bind at approval time, in the browser), so this path needs no `--account`, unlike `--token-stdin`.
|
|
64
|
+
* `command` is the §8 envelope label the success reports under — "login" for `oh-hai login`, "setup"
|
|
65
|
+
* for the onboarding entrypoints — so `--json` automation dispatching on `command` stays consistent.
|
|
66
|
+
* Returns the AGENT ID the approved bearer was stored under (the one the human bound in the browser),
|
|
67
|
+
* so the onboarding caller can reconcile it against the resolver's precedence and give honest next steps.
|
|
62
68
|
*/
|
|
63
|
-
async function
|
|
69
|
+
export async function runDeviceCodeFlow(ctx, command = "login") {
|
|
64
70
|
const code = await requestDeviceCode(ctx);
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
// Try to open the browser for the human first (#271 "platinum" onboarding — no copy-paste). The
|
|
72
|
+
// capability is optional and best-effort: `openBrowser` resolves false when it can't launch one
|
|
73
|
+
// (headless box, no opener), and every hermetic test omits it → the printed fallback below. `openUrl`
|
|
74
|
+
// prefers the one-click `verification_uri_complete` (embeds the code). All server-supplied strings are
|
|
75
|
+
// sanitized of control characters first — they're echoed straight to the terminal.
|
|
76
|
+
const opened = ctx.runtime.openBrowser !== undefined ? await ctx.runtime.openBrowser(code.openUrl) : false;
|
|
77
|
+
if (opened) {
|
|
78
|
+
ctx.io.err(`oh-hai: opened your browser to ${sanitizeForTerminal(code.openUrl)} — approve there.`);
|
|
79
|
+
// Still show the short code so the human can approve from ANOTHER device if the opened tab isn't
|
|
80
|
+
// where they're signed in.
|
|
81
|
+
ctx.io.err(`oh-hai: if it didn't open, enter this code there: ${sanitizeForTerminal(code.userCode)}`);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
ctx.io.err(`oh-hai: to authorize this device, open ${sanitizeForTerminal(code.openUrl)}`);
|
|
85
|
+
ctx.io.err(`oh-hai: and enter the code: ${sanitizeForTerminal(code.userCode)}`);
|
|
86
|
+
}
|
|
70
87
|
ctx.io.err("oh-hai: waiting for approval…");
|
|
71
88
|
// Poll budget: the server expires the code and returns `expired_token` at the real deadline; this
|
|
72
89
|
// cap is a pure anti-infinite-loop guard against a server that never returns a terminal state.
|
|
@@ -83,8 +100,8 @@ async function deviceCodeLogin(ctx) {
|
|
|
83
100
|
const res = await hubPost(ctx, "/auth/device/token", { device_code: code.deviceCode });
|
|
84
101
|
if (res.status === 200) {
|
|
85
102
|
const token = await readAccessToken(res);
|
|
86
|
-
await storeAndReport(ctx, token.agentId, token.accessToken);
|
|
87
|
-
return;
|
|
103
|
+
await storeAndReport(ctx, token.agentId, token.accessToken, command);
|
|
104
|
+
return token.agentId;
|
|
88
105
|
}
|
|
89
106
|
// The Hub's per-IP limiter throttles the shared device surface with HTTP 429 `rate_limited`
|
|
90
107
|
// (+ Retry-After); a legit poller (e.g. behind a corporate NAT) can trip it mid-approval, so
|
|
@@ -122,14 +139,15 @@ async function deviceCodeLogin(ctx) {
|
|
|
122
139
|
throw new CliError("timeout", "device authorization did not complete before the code expired; run `oh-hai login` again.");
|
|
123
140
|
}
|
|
124
141
|
/** Store the bearer Hub-scoped (§5.1) and report success. The token is NEVER in the output (§5.4);
|
|
125
|
-
* an existing token for this identity is overwritten silently (§4.3). Shared by both login paths
|
|
126
|
-
|
|
142
|
+
* an existing token for this identity is overwritten silently (§4.3). Shared by both login paths and
|
|
143
|
+
* the onboarding entrypoints — `command` labels the §8 success envelope ("login" / "setup"). */
|
|
144
|
+
async function storeAndReport(ctx, agentId, token, command = "login") {
|
|
127
145
|
const store = await ctx.runtime.openStore();
|
|
128
146
|
await store.set(originOf(ctx.config.baseUrl), agentId, token);
|
|
129
147
|
if (ctx.json) {
|
|
130
148
|
// No token field, ever (§5.4). `storage` reports which backend actually holds it. The agent id
|
|
131
149
|
// is emitted raw — JSON.stringify escapes any control character, so it can't reach the terminal.
|
|
132
|
-
ctx.io.log(serializeEnvelope(buildOk(
|
|
150
|
+
ctx.io.log(serializeEnvelope(buildOk(command, { agent_id: agentId, base_url: ctx.config.baseUrl, storage: store.backendName })));
|
|
133
151
|
}
|
|
134
152
|
else {
|
|
135
153
|
// Sanitize the DISPLAYED agent id — on the device-code path it's server-supplied, so a hostile
|
|
@@ -251,16 +269,6 @@ function str(value) {
|
|
|
251
269
|
const trimmed = value.trim();
|
|
252
270
|
return trimmed === "" ? undefined : trimmed;
|
|
253
271
|
}
|
|
254
|
-
/** True when `value` parses as an http(s) URL — the only schemes we invite the user to open (§4.3). */
|
|
255
|
-
function isHttpUrl(value) {
|
|
256
|
-
try {
|
|
257
|
-
const { protocol } = new URL(value);
|
|
258
|
-
return protocol === "http:" || protocol === "https:";
|
|
259
|
-
}
|
|
260
|
-
catch {
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
272
|
/** An integer from an unknown response field, clamped to `[min, max]`; `fallback` (already in range)
|
|
265
273
|
* is used when the value is missing or non-finite. Clamping means a missing, zero, fractional
|
|
266
274
|
* (floors to 0), negative, or absurdly large server-supplied `interval` / `expires_in` can never
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,4FAA4F;AAC5F,4FAA4F;AAC5F,0FAA0F;AAC1F,8FAA8F;AAC9F,gGAAgG;AAChG,kGAAkG;AAClG,8EAA8E;AAE9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,4FAA4F;AAC5F,4FAA4F;AAC5F,0FAA0F;AAC1F,8FAA8F;AAC9F,gGAAgG;AAChG,kGAAkG;AAClG,8EAA8E;AAE9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD;;qGAEqG;AACrG,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAE1C,mGAAmG;AACnG,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAErC,oGAAoG;AACpG,MAAM,uBAAuB,GA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,CAAC;IAC7B,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;AAC9C,CAAC;AAED;;;sGAGsG;AACtG,SAAS,UAAU,CAAC,KAAc,EAAE,QAAgB,EAAE,GAAW,EAAE,GAAW;IAC5E,MAAM,CAAC,GAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC7F,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -22,6 +22,15 @@ export declare function resolveSubmitIdentity(ctx: CommandContext): Promise<{
|
|
|
22
22
|
* + the submitter-bound bearer). Uses `resolveIdentity` so a zero-config single stored identity is
|
|
23
23
|
* discovered for the token lookup. A missing token is an auth error (exit 3). */
|
|
24
24
|
export declare function requireToken(ctx: CommandContext): Promise<string>;
|
|
25
|
+
/** The bearer PLUS the resolved agent id, for `inbox watch`: the token drains the mailbox, while the
|
|
26
|
+
* agent id keys the concurrent-drain lock (the mailbox is scoped to the AGENT, not the bearer — one
|
|
27
|
+
* agent can hold several tokens, #323). `account` may be undefined (an env token with no
|
|
28
|
+
* `MA2H_AGENT_ID`, or an ambiguous store) — the caller degrades the guard to "unavailable" then,
|
|
29
|
+
* never keying on the token. A missing token is still an auth error (exit 3). */
|
|
30
|
+
export declare function requireWatchIdentity(ctx: CommandContext): Promise<{
|
|
31
|
+
token: string;
|
|
32
|
+
agentId: string | undefined;
|
|
33
|
+
}>;
|
|
25
34
|
/** The bearer for an `--envelope` replay. The captured envelope already carries the submitting
|
|
26
35
|
* `agent.id`, so fall back to it for the store lookup when no explicit `--account` was given —
|
|
27
36
|
* otherwise a user with a stored login but no `default_account` following the replay example
|
|
@@ -49,6 +49,27 @@ export async function requireToken(ctx) {
|
|
|
49
49
|
}
|
|
50
50
|
return token;
|
|
51
51
|
}
|
|
52
|
+
/** The bearer PLUS the resolved agent id, for `inbox watch`: the token drains the mailbox, while the
|
|
53
|
+
* agent id keys the concurrent-drain lock (the mailbox is scoped to the AGENT, not the bearer — one
|
|
54
|
+
* agent can hold several tokens, #323). `account` may be undefined (an env token with no
|
|
55
|
+
* `MA2H_AGENT_ID`, or an ambiguous store) — the caller degrades the guard to "unavailable" then,
|
|
56
|
+
* never keying on the token. A missing token is still an auth error (exit 3). */
|
|
57
|
+
export async function requireWatchIdentity(ctx) {
|
|
58
|
+
const store = ctx.config.tokenSource === "env" ? undefined : await ctx.runtime.openStore();
|
|
59
|
+
const { token, account } = await resolveIdentity(ctx.config, store);
|
|
60
|
+
if (token === undefined) {
|
|
61
|
+
throw new CliError("auth", NOT_AUTHENTICATED);
|
|
62
|
+
}
|
|
63
|
+
// The lock key must be the agent that OWNS this bearer. In the store-backed path the token was looked
|
|
64
|
+
// up BY the agent id (or discovered as the sole stored identity), so the two are bound. But an ENV
|
|
65
|
+
// token is not bound to config: an account from a machine default (`default_account` or a directory
|
|
66
|
+
// binding) may name a DIFFERENT agent than the env bearer — locking on it would guard the wrong agent
|
|
67
|
+
// while draining another's mailbox. So alongside an env token, only trust an EXPLICITLY-supplied agent
|
|
68
|
+
// id (`--account` / `MA2H_AGENT_ID`); otherwise leave it undefined so the guard degrades to a warning.
|
|
69
|
+
const explicit = ctx.config.accountSource === "flag" || ctx.config.accountSource === "env";
|
|
70
|
+
const agentId = ctx.config.tokenSource === "env" && !explicit ? undefined : account;
|
|
71
|
+
return { token, agentId };
|
|
72
|
+
}
|
|
52
73
|
/** The bearer for an `--envelope` replay. The captured envelope already carries the submitting
|
|
53
74
|
* `agent.id`, so fall back to it for the store lookup when no explicit `--account` was given —
|
|
54
75
|
* otherwise a user with a stored login but no `default_account` following the replay example
|
|
@@ -1 +1 @@
|
|
|
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GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,KAAK,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;IACpF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC;AAED;;;kFAGkF;AAClF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,GAAmB,EAAE,eAAuB;IACnF,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IACxD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -16,14 +16,15 @@ export declare function isActor(value: string): value is Actor;
|
|
|
16
16
|
export declare function normalizePushUrl(raw: string): string;
|
|
17
17
|
/** Parse `value:label` (label may itself contain ':'). Throws a usage CliError on a bad shape. */
|
|
18
18
|
export declare function parseOption(raw: string): ResponseOption;
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
/** True when allowed_resolvers names ≥1 `human:<id>`. The Hub always lets the account OWNER resolve
|
|
20
|
+
* (issue #366) — an omitted/empty list is owner-only, and a non-owner human may resolve only if
|
|
21
|
+
* explicitly listed (fail-closed, spec §5.4). Callers use this to nudge when the ONLY resolvers
|
|
22
|
+
* given are non-human: the resolve route is human-only, so such a list narrows to the owner alone. */
|
|
22
23
|
export declare function hasHumanResolver(resolvers: readonly unknown[] | undefined): boolean;
|
|
23
24
|
/** Stricter than `hasHumanResolver`: requires ≥1 `human:<id>` with a CONCRETE (non-wildcard,
|
|
24
25
|
* non-empty) id. The Hub matches allowed_resolvers literally (`allowed.includes(actor)`), so a
|
|
25
|
-
* captured `human:*` can never match any real actor — the replay
|
|
26
|
-
* the
|
|
26
|
+
* captured `human:*` can never match any real actor — the replay callers use this to note (and
|
|
27
|
+
* proceed) that only the account owner will be able to resolve the replayed ask/task. */
|
|
27
28
|
export declare function hasConcreteHumanResolver(resolvers: readonly unknown[] | undefined): boolean;
|
|
28
29
|
/** Read the `--envelope` source: inline JSON, `@<path>` (local file), or `@-` (stdin, via the
|
|
29
30
|
* injected reader so tests never touch fd 0). */
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// so tests stay hermetic.
|
|
7
7
|
import { readFileSync } from "node:fs";
|
|
8
8
|
import { CliError } from "../../envelope.js";
|
|
9
|
+
import { isHttpUrl } from "../../url.js";
|
|
9
10
|
export const PRIORITIES = ["low", "normal", "high", "urgent"];
|
|
10
11
|
export const REQUEST_MODES = ["select", "input", "confirm"];
|
|
11
12
|
export const CALLBACK_MODES = ["pull", "push"];
|
|
@@ -23,17 +24,6 @@ export function isCallbackMode(value) {
|
|
|
23
24
|
export function isActor(value) {
|
|
24
25
|
return /^(human|agent|system):[^\s]+$/.test(value);
|
|
25
26
|
}
|
|
26
|
-
/** True when `raw` parses as an http(s) URL — the only schemes the Hub's SSRF delivery guard
|
|
27
|
-
* accepts for a push callback, so a mailto:/file: url would silently lose the push. */
|
|
28
|
-
function isHttpUrl(raw) {
|
|
29
|
-
try {
|
|
30
|
-
const u = new URL(raw);
|
|
31
|
-
return u.protocol === "http:" || u.protocol === "https:";
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
27
|
/** Normalize a push `--callback-url` to the canonical WHATWG href the Hub signs and `fetch` POSTs
|
|
38
28
|
* to (so the signed callback_url can't desync from the delivery URL), and enforce http(s) — the
|
|
39
29
|
* Hub's SSRF delivery guard rejects every other scheme, so a mailto:/file: url would pass
|
|
@@ -63,16 +53,17 @@ export function parseOption(raw) {
|
|
|
63
53
|
}
|
|
64
54
|
return { value, label };
|
|
65
55
|
}
|
|
66
|
-
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
56
|
+
/** True when allowed_resolvers names ≥1 `human:<id>`. The Hub always lets the account OWNER resolve
|
|
57
|
+
* (issue #366) — an omitted/empty list is owner-only, and a non-owner human may resolve only if
|
|
58
|
+
* explicitly listed (fail-closed, spec §5.4). Callers use this to nudge when the ONLY resolvers
|
|
59
|
+
* given are non-human: the resolve route is human-only, so such a list narrows to the owner alone. */
|
|
69
60
|
export function hasHumanResolver(resolvers) {
|
|
70
61
|
return (resolvers ?? []).some((r) => typeof r === "string" && r.startsWith("human:"));
|
|
71
62
|
}
|
|
72
63
|
/** Stricter than `hasHumanResolver`: requires ≥1 `human:<id>` with a CONCRETE (non-wildcard,
|
|
73
64
|
* non-empty) id. The Hub matches allowed_resolvers literally (`allowed.includes(actor)`), so a
|
|
74
|
-
* captured `human:*` can never match any real actor — the replay
|
|
75
|
-
* the
|
|
65
|
+
* captured `human:*` can never match any real actor — the replay callers use this to note (and
|
|
66
|
+
* proceed) that only the account owner will be able to resolve the replayed ask/task. */
|
|
76
67
|
export function hasConcreteHumanResolver(resolvers) {
|
|
77
68
|
return (resolvers ?? []).some((r) => {
|
|
78
69
|
if (typeof r !== "string" || !r.startsWith("human:"))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/commands/messaging/validate.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,wFAAwF;AACxF,4FAA4F;AAC5F,yFAAyF;AACzF,gGAAgG;AAChG,0BAA0B;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/commands/messaging/validate.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,wFAAwF;AACxF,4FAA4F;AAC5F,yFAAyF;AACzF,gGAAgG;AAChG,0BAA0B;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,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