@cotal-ai/manager 0.171.3 → 0.171.4

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.
@@ -0,0 +1,64 @@
1
+ import type { AttachSession } from "@cotal-ai/core";
2
+ import type { Manager } from "./manager.js";
3
+ import type { ManagedAgent } from "./seat-types.js";
4
+ /** What {@link ReadinessWait} reads from the Manager. Every entry is read at use, so a field the Manager
5
+ * assigns after construction is always current, and a Manager method a test replaces is the one that runs. */
6
+ export interface ReadinessWaitDeps {
7
+ agents: () => Manager["agents"];
8
+ ep: () => Manager["ep"];
9
+ shutdownReadiness: () => Manager["shutdownReadiness"];
10
+ managedPrincipal: (...args: Parameters<Manager["managedPrincipal"]>) => ReturnType<Manager["managedPrincipal"]>;
11
+ onAgentExit: (...args: Parameters<Manager["onAgentExit"]>) => ReturnType<Manager["onAgentExit"]>;
12
+ }
13
+ /** The launch readiness race (join, exit or the bound), the exit watch that outlives it, and the transcript tail an exit reports. */
14
+ export declare class ReadinessWait {
15
+ private readonly deps;
16
+ constructor(deps: ReadinessWaitDeps);
17
+ private get agents();
18
+ private get ep();
19
+ private get shutdownReadiness();
20
+ private managedPrincipal;
21
+ private onAgentExit;
22
+ /** #159 B1: wait for a detached launch to reach a REAL outcome before replying — never a liveness-
23
+ * inferring timer. Races three:
24
+ * • the assigned id joins presence (live) → **started** — the honest signal (the manager owns mesh
25
+ * lifecycle, not app health, so `ok:true` means "it joined the mesh", not "fully healthy");
26
+ * • the child process exits → **failed** — surface its last output and reap the slot;
27
+ * • neither within {@link readinessTimeoutMs} → **uncertain** — a non-success diagnostic that does NOT
28
+ * deprovision (it may still be booting; the caller keeps {@link watchExit} wired so a later death is
29
+ * still reaped).
30
+ * Presence is keyed on the EXACT freshly-minted id, never the name — a fresh id has no prior record, so
31
+ * any live presence for it is from THIS launch (stale/same-name records can't false-start it). The
32
+ * `"presence"` event is only a wake; the roster is re-read as the source of truth (subscribe-then-check
33
+ * catches a join/exit that landed before we subscribed). A runtime whose `attach()` throws (an external
34
+ * surface) streams no output or exit, so its exit leg polls the runtime's exit proof ({@link pollProvedExit}),
35
+ * reads it once more when the window closes, and its failure carries no last output; one that cannot prove an
36
+ * exit either races presence-vs-backstop only.
37
+ * A launch that waits for the operator at `opts.operator`, a screen its connector names, is ready once a
38
+ * process this runtime owns has run for {@link OPERATOR_READINESS_MS} without exiting. An uncertain verdict
39
+ * says whether a process this runtime owns is still running. */
40
+ awaitReadiness(a: ManagedAgent, readinessTimeoutMs: number, opts?: {
41
+ reapOnExit?: boolean;
42
+ joinedAfter?: number;
43
+ operator?: string;
44
+ }): Promise<{
45
+ ok: true;
46
+ operator?: string;
47
+ } | {
48
+ ok: false;
49
+ uncertain?: boolean;
50
+ running?: boolean;
51
+ deliberate?: boolean;
52
+ detail: string;
53
+ }>;
54
+ /** Last non-empty line of the session's rendered backlog as a single trimmed snippet (≤160 chars)
55
+ * — a readable one-line cause for an early-exit diagnostic. The backlog repaints cells a TUI
56
+ * skipped with cursor moves, so it is rendered and the line is read off the terminal; stripping
57
+ * its escapes would glue the words those moves separate. */
58
+ tail(session: AttachSession): Promise<string>;
59
+ /** Subscribe to a managed agent's process-exit so a self-driven exit frees its slot and reaps
60
+ * its children (P4b/P4c). The watch is bound to the current handle: a restart swaps in a new one
61
+ * and watches it, so a late exit proved for the old handle must not retire the row. */
62
+ watchExit(a: ManagedAgent): void;
63
+ }
64
+ //# sourceMappingURL=readiness-wait.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readiness-wait.d.ts","sourceRoot":"","sources":["../src/readiness-wait.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAYpD;+GAC+G;AAC/G,MAAM,WAAW,iBAAiB;IAChC,MA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D,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAwBnD;;4FAEwF;IACxF,SAAS,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;CAOjC"}
@@ -0,0 +1,244 @@
1
+ import { rejectionText } from "@cotal-ai/core";
2
+ import Headless from "@xterm/headless";
3
+ import { exitProof, pollProvedExit, watchProvedExit } from "./runtime/index.js";
4
+ /** How often the readiness race asks a runtime that streams no exit whether its child has exited, and
5
+ * how long it waits past the window for the proof of its last read. An operator waits on this reply,
6
+ * so it asks more often than the exit watch that outlives readiness. */
7
+ const READINESS_EXIT_POLL_MS = 1_000;
8
+ /** How long the process of a launch that waits for the operator ({@link Connector.waitsForOperator})
9
+ * must run without exiting before it is ready: long enough that a harness refusing its arguments
10
+ * exits first and is reported as failed. */
11
+ const OPERATOR_READINESS_MS = 3_000;
12
+ /** The launch readiness race (join, exit or the bound), the exit watch that outlives it, and the transcript tail an exit reports. */
13
+ export class ReadinessWait {
14
+ deps;
15
+ constructor(deps) {
16
+ this.deps = deps;
17
+ }
18
+ // The Manager members these bodies read, under their Manager names. Each reads through its dep at
19
+ // use, so a field the Manager assigns later is current and a method a test replaces on the Manager
20
+ // is the one that runs.
21
+ get agents() { return this.deps.agents(); }
22
+ get ep() { return this.deps.ep(); }
23
+ get shutdownReadiness() { return this.deps.shutdownReadiness(); }
24
+ managedPrincipal(...args) { return this.deps.managedPrincipal(...args); }
25
+ onAgentExit(...args) { return this.deps.onAgentExit(...args); }
26
+ /** #159 B1: wait for a detached launch to reach a REAL outcome before replying — never a liveness-
27
+ * inferring timer. Races three:
28
+ * • the assigned id joins presence (live) → **started** — the honest signal (the manager owns mesh
29
+ * lifecycle, not app health, so `ok:true` means "it joined the mesh", not "fully healthy");
30
+ * • the child process exits → **failed** — surface its last output and reap the slot;
31
+ * • neither within {@link readinessTimeoutMs} → **uncertain** — a non-success diagnostic that does NOT
32
+ * deprovision (it may still be booting; the caller keeps {@link watchExit} wired so a later death is
33
+ * still reaped).
34
+ * Presence is keyed on the EXACT freshly-minted id, never the name — a fresh id has no prior record, so
35
+ * any live presence for it is from THIS launch (stale/same-name records can't false-start it). The
36
+ * `"presence"` event is only a wake; the roster is re-read as the source of truth (subscribe-then-check
37
+ * catches a join/exit that landed before we subscribed). A runtime whose `attach()` throws (an external
38
+ * surface) streams no output or exit, so its exit leg polls the runtime's exit proof ({@link pollProvedExit}),
39
+ * reads it once more when the window closes, and its failure carries no last output; one that cannot prove an
40
+ * exit either races presence-vs-backstop only.
41
+ * A launch that waits for the operator at `opts.operator`, a screen its connector names, is ready once a
42
+ * process this runtime owns has run for {@link OPERATOR_READINESS_MS} without exiting. An uncertain verdict
43
+ * says whether a process this runtime owns is still running. */
44
+ async awaitReadiness(a, readinessTimeoutMs, opts = {}) {
45
+ let session;
46
+ try {
47
+ session = a.handle.attach();
48
+ }
49
+ catch {
50
+ /* external surfaces stream no output or exit; their exit is polled below */
51
+ }
52
+ const s = session;
53
+ // Presence cards carry the wire PRINCIPAL dot-form (`<owner>.<actor>`), never a raw nkey — match
54
+ // through managedPrincipal or a static launch can never be seen joining (every static spawn would
55
+ // resolve "uncertain"; caught by the lifecycle e2e).
56
+ const wanted = this.managedPrincipal(a);
57
+ // READINESS LIFECYCLE FENCE (SPEC 13.1): match the exact principal AND the exact lifecycle uid
58
+ // the manager minted for THIS spawn (presence carries it, §6). The endpoint's own
59
+ // register-only broker proof is gated on the CLIENT-authored `card.kind`, which a managed child
60
+ // holding a valid agent credential could set to "endpoint" to skip - so it is defense-in-depth,
61
+ // NOT the authority boundary. This equality is: the manager (not the child) owns the expected
62
+ // uid, so a ghost that advertises a wrong/absent uid never reports STARTED, whatever kind it
63
+ // claims. The manager threads the uid into EVERY mode's launch (open included), so the child
64
+ // adopts it over a self-mint and publishes it in presence; the uid is absent only from a peer
65
+ // the manager never launched (a pure operator/daemon connection that never registers).
66
+ // A supervised restart keeps the same principal+uid, so a SIGKILL'd child's still-live
67
+ // presence row would otherwise satisfy this equality. `joinedAfter` is one millisecond
68
+ // past that row's last heartbeat: only a later heartbeat counts as THIS replacement joining.
69
+ const joined = () => this.ep.getRoster().some((p) => p.card.id === wanted
70
+ && p.status !== "offline"
71
+ && p.lifecycleUid === a.lifecycleUid
72
+ && (opts.joinedAfter === undefined || p.ts >= opts.joinedAfter));
73
+ return await new Promise((resolve) => {
74
+ let done = false;
75
+ let timer;
76
+ let unsubExit = () => { };
77
+ let joinedPoll;
78
+ let operatorTimer;
79
+ const finish = (r) => {
80
+ if (done)
81
+ return;
82
+ done = true;
83
+ if (!r.ok && r.uncertain) {
84
+ a.joinIssue = r.detail;
85
+ console.error(`seat join degraded: ${r.detail}`);
86
+ }
87
+ else if (r.ok) {
88
+ a.joinIssue = undefined;
89
+ }
90
+ clearTimeout(timer);
91
+ clearTimeout(operatorTimer);
92
+ if (joinedPoll !== undefined)
93
+ clearInterval(joinedPoll);
94
+ this.ep.off("presence", onPresence);
95
+ this.shutdownReadiness.signal.removeEventListener("abort", onShutdown);
96
+ unsubExit();
97
+ resolve(r);
98
+ };
99
+ const onPresence = () => {
100
+ if (joined())
101
+ finish({ ok: true });
102
+ };
103
+ // Shutdown owns the seat's stop and retirement after the lifecycle ticket drains. Do not
104
+ // keep that ticket waiting on a connector's readiness window while shutdown waits on it.
105
+ const onShutdown = () => finish({ ok: false, deliberate: true, detail: `${a.name} was stopped before it reported ready` });
106
+ if (opts.joinedAfter !== undefined) {
107
+ // Heartbeats bump roster.ts without emitting "presence" (same status/uid/activity).
108
+ // A supervised restart needs that bump, so poll joined() rather than waiting on the event.
109
+ joinedPoll = setInterval(onPresence, 50);
110
+ }
111
+ // Process exit → failed. Clear the backstop FIRST (synchronously) so it can't resolve UNCERTAIN while
112
+ // the backlog reads async — the process is known dead, that's a failure, not an unknown. Reap through
113
+ // onAgentExit so a child the launcher spawned in the window is reaped too.
114
+ const onExit = () => {
115
+ if (done)
116
+ return;
117
+ clearTimeout(timer);
118
+ clearTimeout(operatorTimer);
119
+ // `stopHandle` sets `terminalizing` synchronously before it kills, and `onAgentExit` sets it
120
+ // through `freeSlot` when it retires the seat, so only a read before the await and the reap
121
+ // tells a deliberate stop from a launch failure.
122
+ const deliberate = a.terminalizing === true;
123
+ void (async () => {
124
+ // A closed stream or a reader failure must not prevent settlement, or read as empty output.
125
+ let tail = "";
126
+ try {
127
+ if (s)
128
+ tail = await this.tail(s);
129
+ }
130
+ catch (error) {
131
+ console.error(`! ${a.name}: last output unavailable: ${rejectionText(error)}`);
132
+ }
133
+ if (opts.reapOnExit !== false)
134
+ this.onAgentExit(a);
135
+ // The despawn path owns this goal's terminal (`cancel`), and this promise still settles
136
+ // as the `deliberate` variant so the caller commits none: the readiness timer is already
137
+ // cleared, and the spawn's lifecycle ticket is released only on settle.
138
+ if (deliberate) {
139
+ finish({ ok: false, deliberate: true, detail: `${a.name} was stopped before it reported ready` });
140
+ return;
141
+ }
142
+ // The screen's last row can be a dialog footer, so the exit's diagnostic is named beside it:
143
+ // it carries the runtime's own reason when it stopped the seat. A connector that ends on its
144
+ // diagnostic already shows it as the last row, and it is not repeated.
145
+ let exitDetail = "";
146
+ try {
147
+ const diagnostic = a.handle.exitInfo?.()?.diagnostic;
148
+ if (diagnostic && diagnostic !== tail)
149
+ exitDetail = `; diagnostic: ${diagnostic}`;
150
+ }
151
+ catch (e) {
152
+ // The backstop is already cleared, so a reader that throws must still let this settle.
153
+ exitDetail = `; exit detail unreadable from runtime "${a.handle.kind}": ${rejectionText(e)}`;
154
+ }
155
+ // A runtime's text can carry a lone surrogate, which is not I-JSON, and the failed terminal
156
+ // this detail becomes is refused with it.
157
+ exitDetail = exitDetail.replace(/\p{Cs}/gu, "\uFFFD");
158
+ finish({ ok: false, detail: `${a.name} exited on launch${tail ? ` - last output: ${tail}` : ""}${exitDetail}` });
159
+ })();
160
+ };
161
+ // A process this runtime owns reports its own exit, so one still running here is running.
162
+ const uncertain = () => {
163
+ const running = s !== undefined && a.handle.status() === "running";
164
+ finish({
165
+ ok: false,
166
+ uncertain: true,
167
+ running,
168
+ detail: running
169
+ ? `${a.name} (${a.id}): launch status uncertain - its process is running but did not join the mesh within ${readinessTimeoutMs}ms; it may still be starting or waiting at a prompt. Inspect with \`cotal attach ${a.name}\` / \`cotal ps\`; do not stop it solely because this bounded wait elapsed.`
170
+ : `${a.name} (${a.id}): launch status uncertain - no process exit and no mesh presence within ${readinessTimeoutMs}ms; it may still be booting or stuck before connector startup. Inspect with \`cotal attach ${a.name}\` / \`cotal ps\`; do not stop it solely because this bounded wait elapsed.`,
171
+ });
172
+ };
173
+ if (opts.operator !== undefined && s)
174
+ operatorTimer = setTimeout(() => { if (a.handle.status() === "running")
175
+ finish({ ok: true, operator: opts.operator }); }, OPERATOR_READINESS_MS);
176
+ // The exit poll read the runtime up to a poll ago, and a window can be shorter than a poll, so
177
+ // the window closes on a fresh read: a child that exited by then is reported as exited. Nothing
178
+ // bounds how long a runtime's proof takes, so it gets one more poll before the launch is uncertain.
179
+ timer = setTimeout(() => {
180
+ const proof = s ? undefined : exitProof(a.handle);
181
+ if (!proof) {
182
+ uncertain();
183
+ return;
184
+ }
185
+ timer = setTimeout(uncertain, READINESS_EXIT_POLL_MS);
186
+ proof.then(onExit, uncertain);
187
+ }, readinessTimeoutMs);
188
+ // The poll stops once the race is done, so it needs no unsubscribe.
189
+ if (s)
190
+ unsubExit = s.onExit(onExit);
191
+ else
192
+ pollProvedExit(a.handle, onExit, () => !done, READINESS_EXIT_POLL_MS);
193
+ this.ep.on("presence", onPresence);
194
+ this.shutdownReadiness.signal.addEventListener("abort", onShutdown, { once: true });
195
+ // Subscribe-then-check (TOCTOU): a join or an exit that already landed before we subscribed.
196
+ if (this.shutdownReadiness.signal.aborted)
197
+ onShutdown();
198
+ else if (s && a.handle.status() === "exited")
199
+ onExit();
200
+ else
201
+ onPresence();
202
+ });
203
+ }
204
+ /** Last non-empty line of the session's rendered backlog as a single trimmed snippet (≤160 chars)
205
+ * — a readable one-line cause for an early-exit diagnostic. The backlog repaints cells a TUI
206
+ * skipped with cursor moves, so it is rendered and the line is read off the terminal; stripping
207
+ * its escapes would glue the words those moves separate. */
208
+ async tail(session) {
209
+ const backlog = await session.backlog();
210
+ // Sized after the snapshot: a custodial seat's snapshot carries the geometry it was taken at.
211
+ // The headless build exposes `buffer` only as proposed API.
212
+ const term = new Headless.Terminal({ cols: session.cols, rows: session.rows, allowProposedApi: true });
213
+ await new Promise((done) => term.write(backlog, done));
214
+ const screen = term.buffer.active;
215
+ let text = "";
216
+ for (let y = screen.length - 1; y >= 0; y--) {
217
+ const row = screen.getLine(y);
218
+ // A line wider than the screen continues across wrapped rows, so it is read whole.
219
+ text = row.translateToString(text === "") + text;
220
+ if (row.isWrapped)
221
+ continue;
222
+ // Blanks a program painted survive the right trim, so a line of only blanks is skipped.
223
+ if (text.trim())
224
+ break;
225
+ text = "";
226
+ }
227
+ term.dispose();
228
+ text = text.trim();
229
+ // Cut on code points: half a surrogate pair is not I-JSON, and a launch terminal carrying it is refused.
230
+ const chars = [...text];
231
+ return chars.length > 160 ? `…${chars.slice(-160).join("")}` : text;
232
+ }
233
+ /** Subscribe to a managed agent's process-exit so a self-driven exit frees its slot and reaps
234
+ * its children (P4b/P4c). The watch is bound to the current handle: a restart swaps in a new one
235
+ * and watches it, so a late exit proved for the old handle must not retire the row. */
236
+ watchExit(a) {
237
+ const handle = a.handle;
238
+ const current = () => this.agents.get(a.name) === a && a.handle === handle;
239
+ const watched = watchProvedExit(handle, () => this.onAgentExit(a), current);
240
+ if (!watched)
241
+ console.error(`! ${a.name}: runtime "${handle.kind}" cannot prove a child exit (AgentHandle.waitForExit is not implemented) - it stays managed after it exits, until it is stopped`);
242
+ }
243
+ }
244
+ //# sourceMappingURL=readiness-wait.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readiness-wait.js","sourceRoot":"","sources":["../src/readiness-wait.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,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AC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC;QACpF,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAC5E,IAAI,CAAC,OAAO;YACV,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,cAAc,MAAM,CAAC,IAAI,iIAAiI,CAAC,CAAC;IACzL,CAAC;CACF"}
@@ -0,0 +1,51 @@
1
+ import type { ControlReply, EpCaller } from "@cotal-ai/core";
2
+ import type { Manager } from "./manager.js";
3
+ import type { SpawnHooks } from "./seat-types.js";
4
+ /** What {@link StartDoors} reads from the Manager. Every entry is read at use, so a field the Manager
5
+ * assigns after construction is always current, and a Manager method a test replaces is the one that runs. */
6
+ export interface StartDoorsDeps {
7
+ eventsRequired: () => Manager["eventsRequired"];
8
+ execution: () => Manager["execution"];
9
+ remoteAuthority: () => Manager["remoteAuthority"];
10
+ space: () => Manager["space"];
11
+ userMode: () => Manager["userMode"];
12
+ workspaceRoot: () => Manager["workspaceRoot"];
13
+ executionRefusal: (...args: Parameters<Manager["executionRefusal"]>) => ReturnType<Manager["executionRefusal"]>;
14
+ startAgent: (...args: Parameters<Manager["startAgent"]>) => ReturnType<Manager["startAgent"]>;
15
+ }
16
+ /** The `start` and `launch` control doors: argument checks and the hand-off to `startAgent`. */
17
+ export declare class StartDoors {
18
+ private readonly deps;
19
+ constructor(deps: StartDoorsDeps);
20
+ private get eventsRequired();
21
+ private get execution();
22
+ private get remoteAuthority();
23
+ private get space();
24
+ private get userMode();
25
+ private get workspaceRoot();
26
+ private executionRefusal;
27
+ private startAgent;
28
+ /** Parse a served `spawn` request into {@link StartAgentOpts}. The compiled spawn input contract
29
+ * is the shape check: it already refused a non-mapping `launchOptions`, a `supervise` that is not
30
+ * the closed `{ restarts, windowMs }` pair, and a list on `subscribe`, `allowSubscribe`,
31
+ * `allowPublish`, `shareTools`, `join` or `callerAcl` that is not an array of strings. This reads
32
+ * those fields as admitted, the way it reads the string fields. The connector still validates the
33
+ * launch-option keys, and `startAgent` still refuses a supervise budget the seat record would not
34
+ * take. `once` is shape-checked by that same contract. Its omitted `deadlineMs` takes the default
35
+ * here, and a deadline past the scheduler's last instant is refused here, which the schema does
36
+ * not express. */
37
+ opStart(args: Record<string, unknown>, caller: string, admin: boolean, hooks?: SpawnHooks, route?: "one" | "all" | "inst", authenticatedCaller?: EpCaller, served?: string): Promise<ControlReply>;
38
+ /** Boot one resolved agent from a mesh-manifest launch spec, for `cotal spawn -f` onto a RUNNING
39
+ * manager. The request carries `{ runId, name }` — plus, for a deploy from another checkout or
40
+ * host, the resolved `spec` itself inline (validated as untrusted input and persisted under THIS
41
+ * manager's `.cotal/run/` first) — NEVER a path: the manager derives + validates
42
+ * `.cotal/run/<runId>.json` itself ({@link launchSpecForRun} — token-safe id, no-follow,
43
+ * `loadLaunchSpec`'s untrusted-input + `validateLaunchPolicy` contract), materializes the named
44
+ * agent's transient persona, and spawns via the same `startAgent({ resolved })` path as
45
+ * `supervise --launch`. The reply is enriched for the ownership ledger: the SPAWNED
46
+ * (collision-numbered) name + nkey id creds are filed under, plus the manifest `requested` name,
47
+ * `runId`, and resolved `hash`. USER mesh: a privileged-tier launch is owner-equality-authorized
48
+ * (spec owner === caller owner) before any side effect; the admin tier keeps operator behavior. */
49
+ opLaunch(args: Record<string, unknown>, caller: string, admin: boolean, hooks?: SpawnHooks, route?: "one" | "all" | "inst"): Promise<ControlReply>;
50
+ }
51
+ //# sourceMappingURL=start-doors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-doors.d.ts","sourceRoot":"","sources":["../src/start-doors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAiB,MAAM,gBAAgB,CAAC;AAG5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,E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GAAG,KAAK,GAAG,MAAe,EAAE,mBAAmB,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAsF1M;;;;;;;;;;wGAUoG;IAC9F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE,KAAK,GAAE,KAAK,GAAG,KAAK,GAAG,MAAe,GAAG,OAAO,CAAC,YAAY,CAAC;CAuDjK"}
@@ -0,0 +1,187 @@
1
+ import { MAX_SCHEDULE_MS, parsePrincipalKey, rejectionText } from "@cotal-ai/core";
2
+ import { authorizeLaunch } from "./authorize.js";
3
+ import { launchAgentToStartOpts, launchSpecForRun, materializePersona, parseLaunchSpec, persistLaunchSpec } from "./launch.js";
4
+ /** A `once` spawn's task deadline when the caller names none: one hour from the spawn's accept. */
5
+ const ONCE_DEFAULT_DEADLINE_MS = 60 * 60_000;
6
+ /** The `start` and `launch` control doors: argument checks and the hand-off to `startAgent`. */
7
+ export class StartDoors {
8
+ deps;
9
+ constructor(deps) {
10
+ this.deps = deps;
11
+ }
12
+ // The Manager members these bodies read, under their Manager names. Each reads through its dep at
13
+ // use, so a field the Manager assigns later is current and a method a test replaces on the Manager
14
+ // is the one that runs.
15
+ get eventsRequired() { return this.deps.eventsRequired(); }
16
+ get execution() { return this.deps.execution(); }
17
+ get remoteAuthority() { return this.deps.remoteAuthority(); }
18
+ get space() { return this.deps.space(); }
19
+ get userMode() { return this.deps.userMode(); }
20
+ get workspaceRoot() { return this.deps.workspaceRoot(); }
21
+ executionRefusal(...args) { return this.deps.executionRefusal(...args); }
22
+ startAgent(...args) { return this.deps.startAgent(...args); }
23
+ /** Parse a served `spawn` request into {@link StartAgentOpts}. The compiled spawn input contract
24
+ * is the shape check: it already refused a non-mapping `launchOptions`, a `supervise` that is not
25
+ * the closed `{ restarts, windowMs }` pair, and a list on `subscribe`, `allowSubscribe`,
26
+ * `allowPublish`, `shareTools`, `join` or `callerAcl` that is not an array of strings. This reads
27
+ * those fields as admitted, the way it reads the string fields. The connector still validates the
28
+ * launch-option keys, and `startAgent` still refuses a supervise budget the seat record would not
29
+ * take. `once` is shape-checked by that same contract. Its omitted `deadlineMs` takes the default
30
+ * here, and a deadline past the scheduler's last instant is refused here, which the schema does
31
+ * not express. */
32
+ opStart(args, caller, admin, hooks, route = "inst", authenticatedCaller, served) {
33
+ const supervise = args.supervise;
34
+ let once;
35
+ if (args.once !== undefined) {
36
+ const rec = args.once;
37
+ // The default is applied here, so every caller of the wire gets the same one.
38
+ const d = rec.deadlineMs ?? ONCE_DEFAULT_DEADLINE_MS;
39
+ if (d !== -1 && (typeof d !== "number" || !Number.isSafeInteger(d) || d < 1 || Date.now() + d > MAX_SCHEDULE_MS))
40
+ return Promise.resolve({ ok: false, error: "once.deadlineMs: expected -1 (no deadline) or a positive whole number of milliseconds that ends by the deadline scheduler's last instant (the end of year 9999)" });
41
+ once = { deadlineMs: d === -1 ? undefined : d };
42
+ }
43
+ const callerAcl = args.callerAcl;
44
+ // #373: the event-plane admission gate. `startAgent` resolves `eventsRequired || opts.events
45
+ // !== false`, so omission ARMS the plane — a gate on the explicit bit alone is bypassed by
46
+ // omitting it. The gate is on the DECISION, and it runs before connector resolution and
47
+ // before `startAgent` (which mints credentials), so a refusal provisions nothing.
48
+ if (args.eventPayloads !== undefined && typeof args.eventPayloads !== "boolean")
49
+ return Promise.resolve({ ok: false, error: "eventPayloads must be a boolean" });
50
+ const requestedEvents = typeof args.events === "boolean" ? args.events : undefined;
51
+ let eventsNotice;
52
+ let events = requestedEvents;
53
+ // Imperative spawns have no payload-selected owner. Local provisioning derives it from
54
+ // the authenticated u_-owner caller; hosted enrollment fixes it to the manager's owner.
55
+ // Match the same owner-domain boundary as authorizeNamed, without treating the spawn's
56
+ // spawner relation as authority over a different owner's session.
57
+ const callerOwner = parsePrincipalKey(caller)?.owner;
58
+ const childOwner = this.remoteAuthority?.owner ?? (callerOwner?.startsWith("u_") ? callerOwner : undefined);
59
+ const ownsChild = this.userMode && callerOwner !== undefined && callerOwner === childOwner;
60
+ if (!admin && !ownsChild) {
61
+ if (requestedEvents === true)
62
+ return Promise.resolve({
63
+ ok: false,
64
+ error: `spawn is operator reach; the caller's current ledger grant does not carry "admin" (SPEC 13.2): events: arming the event plane needs the admin tier`,
65
+ });
66
+ if (this.eventsRequired)
67
+ return Promise.resolve({
68
+ ok: false,
69
+ error: `spawn is operator reach; the caller's current ledger grant does not carry "admin" (SPEC 13.2): space "${this.space}" requires the event plane by registration policy, which cannot be met without the admin tier`,
70
+ });
71
+ // Omission arms by default in startAgent; serve it DISARMED and say so (never a silent
72
+ // downgrade). An explicit `false` is already the opt-out — served as-is, no notice.
73
+ if (requestedEvents === undefined) {
74
+ events = false;
75
+ eventsNotice = `event plane not armed: arming it on spawn needs the admin tier; the spawn was served with events: false`;
76
+ }
77
+ }
78
+ return this.startAgent({
79
+ name: String(args.name ?? "").trim(),
80
+ agent: args.agent,
81
+ defaultAgent: args.defaultAgent,
82
+ role: args.role,
83
+ config: args.config,
84
+ identity: args.identity,
85
+ // Passed as sent: spawnPersona validates the record, the one place every door reads it.
86
+ persona: args.persona,
87
+ ...(typeof args.runId === "string" ? { runId: args.runId } : {}),
88
+ model: args.model,
89
+ variant: args.variant,
90
+ launchOptions: args.launchOptions,
91
+ resume: args.resume,
92
+ resumeClaim: args.resumeClaim,
93
+ resumeAgent: args.resumeAgent,
94
+ events,
95
+ eventPayloads: args.eventPayloads,
96
+ eventsNotice,
97
+ cwd: args.cwd,
98
+ prompt: args.prompt,
99
+ subscribe: args.subscribe,
100
+ allowSubscribe: args.allowSubscribe,
101
+ allowPublish: args.allowPublish,
102
+ join: args.join,
103
+ callerAcl,
104
+ shareTools: args.shareTools,
105
+ ...(supervise !== undefined ? { supervise } : {}),
106
+ ...(once !== undefined ? { once } : {}),
107
+ ...(typeof args.runtime === "string" ? { runtime: args.runtime.trim() } : {}),
108
+ route,
109
+ ...(served !== undefined ? { served } : {}),
110
+ }, caller, hooks, authenticatedCaller);
111
+ }
112
+ /** Boot one resolved agent from a mesh-manifest launch spec, for `cotal spawn -f` onto a RUNNING
113
+ * manager. The request carries `{ runId, name }` — plus, for a deploy from another checkout or
114
+ * host, the resolved `spec` itself inline (validated as untrusted input and persisted under THIS
115
+ * manager's `.cotal/run/` first) — NEVER a path: the manager derives + validates
116
+ * `.cotal/run/<runId>.json` itself ({@link launchSpecForRun} — token-safe id, no-follow,
117
+ * `loadLaunchSpec`'s untrusted-input + `validateLaunchPolicy` contract), materializes the named
118
+ * agent's transient persona, and spawns via the same `startAgent({ resolved })` path as
119
+ * `supervise --launch`. The reply is enriched for the ownership ledger: the SPAWNED
120
+ * (collision-numbered) name + nkey id creds are filed under, plus the manifest `requested` name,
121
+ * `runId`, and resolved `hash`. USER mesh: a privileged-tier launch is owner-equality-authorized
122
+ * (spec owner === caller owner) before any side effect; the admin tier keeps operator behavior. */
123
+ async opLaunch(args, caller, admin, hooks, route = "inst") {
124
+ if (this.execution === "none")
125
+ return { ok: false, error: this.executionRefusal() };
126
+ const runId = String(args.runId ?? "").trim();
127
+ const name = String(args.name ?? "").trim();
128
+ if (!runId || !name)
129
+ return { ok: false, error: "launch requires runId + name" };
130
+ let spec;
131
+ if (args.spec !== undefined) {
132
+ // REMOTE deploy: the caller pushes the resolved spec inline over the control plane instead of
133
+ // sharing this checkout's disk. Same untrusted-input contract as the file path (strict schema,
134
+ // safe names, policy re-validation), then persisted under OUR `.cotal/run/<runId>.json` so
135
+ // stale-restart and retained resume read the same on-disk source either way. Still never a
136
+ // path: the payload is the spec itself, and where it lands is derived here.
137
+ try {
138
+ spec = parseLaunchSpec(args.spec, `inline launch spec (run ${runId})`);
139
+ if (spec.runId !== runId)
140
+ return { ok: false, error: `inline launch spec runId "${spec.runId}" does not match requested "${runId}"` };
141
+ hooks?.onEffect?.();
142
+ persistLaunchSpec(this.workspaceRoot, spec);
143
+ }
144
+ catch (e) {
145
+ return { ok: false, error: rejectionText(e) };
146
+ }
147
+ }
148
+ else {
149
+ try {
150
+ spec = launchSpecForRun(this.workspaceRoot, runId);
151
+ }
152
+ catch (e) {
153
+ return { ok: false, error: rejectionText(e) };
154
+ }
155
+ }
156
+ const la = spec.agents.find((a) => a.name === name);
157
+ if (!la)
158
+ return { ok: false, error: `no agent "${name}" in launch spec for run ${runId}` };
159
+ // USER mesh: a manifest launch runs under the spec's apply-time owner, never the ctl caller —
160
+ // fail loud on a spec without one rather than guess (core `MeshLaunchSpec.owner`).
161
+ if (this.userMode && !spec.owner)
162
+ return { ok: false, error: `user-auth space "${this.space}": launch spec for run ${runId} carries no owner - re-apply the manifest as a logged-in operator` };
163
+ if (this.userMode) {
164
+ // Privileged-tier user-mode launch: owner-equality (spec owner === caller owner), decided by
165
+ // the pure policy BEFORE materializePersona or any other side effect, so a denied
166
+ // cross-owner launch writes nothing. Admin tier passes through it unchanged.
167
+ const denied = authorizeLaunch({ specOwner: spec.owner, caller, admin, runId });
168
+ if (denied)
169
+ return { ok: false, error: denied };
170
+ }
171
+ let configPath;
172
+ try {
173
+ hooks?.onEffect?.();
174
+ configPath = materializePersona(this.workspaceRoot, runId, la);
175
+ }
176
+ catch (e) {
177
+ return { ok: false, error: rejectionText(e) };
178
+ }
179
+ const reply = await this.startAgent({ ...launchAgentToStartOpts(la, configPath, spec.owner, runId), route }, caller, hooks);
180
+ if (reply.ok)
181
+ // `data.name` stays the spawned (numbered) identity — what creds are filed under and the ledger
182
+ // keys on; `requested`/`runId`/`hash` give the CLI the manifest name + drift hash for the ledger.
183
+ reply.data = { ...reply.data, requested: la.name, runId, hash: la.hash, newlyStarted: true };
184
+ return reply;
185
+ }
186
+ }
187
+ //# sourceMappingURL=start-doors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-doors.js","sourceRoot":"","sources":["../src/start-doors.ts"],"names":[],"mappings":"AA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