@cotal-ai/manager 0.171.2 → 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.
- package/dist/broker-transport.d.ts +126 -0
- package/dist/broker-transport.d.ts.map +1 -0
- package/dist/broker-transport.js +263 -0
- package/dist/broker-transport.js.map +1 -0
- package/dist/command-dispatch.d.ts +206 -0
- package/dist/command-dispatch.d.ts.map +1 -0
- package/dist/command-dispatch.js +471 -0
- package/dist/command-dispatch.js.map +1 -0
- package/dist/connector-inventory.d.ts +37 -0
- package/dist/connector-inventory.d.ts.map +1 -0
- package/dist/connector-inventory.js +73 -0
- package/dist/connector-inventory.js.map +1 -0
- package/dist/harness-resolution.d.ts +71 -0
- package/dist/harness-resolution.d.ts.map +1 -0
- package/dist/harness-resolution.js +111 -0
- package/dist/harness-resolution.js.map +1 -0
- package/dist/manager.d.ts +91 -375
- package/dist/manager.d.ts.map +1 -1
- package/dist/manager.js +400 -2811
- package/dist/manager.js.map +1 -1
- package/dist/persona-catalog.d.ts +86 -0
- package/dist/persona-catalog.d.ts.map +1 -0
- package/dist/persona-catalog.js +325 -0
- package/dist/persona-catalog.js.map +1 -0
- package/dist/preservation.d.ts +157 -0
- package/dist/preservation.d.ts.map +1 -0
- package/dist/preservation.js +583 -0
- package/dist/preservation.js.map +1 -0
- package/dist/readiness-wait.d.ts +64 -0
- package/dist/readiness-wait.d.ts.map +1 -0
- package/dist/readiness-wait.js +244 -0
- package/dist/readiness-wait.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +22 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/service-adapter.d.ts.map +1 -1
- package/dist/service-adapter.js +6 -0
- package/dist/service-adapter.js.map +1 -1
- package/dist/spawn-goal.d.ts +77 -0
- package/dist/spawn-goal.d.ts.map +1 -0
- package/dist/spawn-goal.js +357 -0
- package/dist/spawn-goal.js.map +1 -0
- package/dist/start-doors.d.ts +51 -0
- package/dist/start-doors.d.ts.map +1 -0
- package/dist/start-doors.js +187 -0
- package/dist/start-doors.js.map +1 -0
- package/dist/status-and-models.d.ts +155 -0
- package/dist/status-and-models.d.ts.map +1 -0
- package/dist/status-and-models.js +290 -0
- package/dist/status-and-models.js.map +1 -0
- package/dist/terminal-input.d.ts +82 -0
- package/dist/terminal-input.d.ts.map +1 -0
- package/dist/terminal-input.js +266 -0
- package/dist/terminal-input.js.map +1 -0
- package/package.json +12 -12
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ControlReply, EpServeContext, GoalRef } from "@cotal-ai/core";
|
|
2
|
+
import type { Manager } from "./manager.js";
|
|
3
|
+
import type { SpawnAcceptance, SpawnHooks } from "./seat-types.js";
|
|
4
|
+
/** What {@link SpawnGoal} 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 SpawnGoalDeps {
|
|
7
|
+
agentGoals: () => Manager["agentGoals"];
|
|
8
|
+
execution: () => Manager["execution"];
|
|
9
|
+
goalAcceptanceRetentionMs: () => Manager["goalAcceptanceRetentionMs"];
|
|
10
|
+
goalAcceptances: () => Manager["goalAcceptances"];
|
|
11
|
+
goalReconcileDone: () => Manager["goalReconcileDone"];
|
|
12
|
+
goalWriter: () => Manager["goalWriter"];
|
|
13
|
+
managerInstanceId: () => Manager["managerInstanceId"];
|
|
14
|
+
onceWatched: () => Manager["onceWatched"];
|
|
15
|
+
readinessTimeoutMs: () => Manager["readinessTimeoutMs"];
|
|
16
|
+
serviceServe: () => Manager["serviceServe"];
|
|
17
|
+
userMode: () => Manager["userMode"];
|
|
18
|
+
acceptOnceTurn: (...args: Parameters<Manager["acceptOnceTurn"]>) => ReturnType<Manager["acceptOnceTurn"]>;
|
|
19
|
+
assertGoalWriterEpochCurrent: (...args: Parameters<Manager["assertGoalWriterEpochCurrent"]>) => ReturnType<Manager["assertGoalWriterEpochCurrent"]>;
|
|
20
|
+
commitOnceCancel: (...args: Parameters<Manager["commitOnceCancel"]>) => ReturnType<Manager["commitOnceCancel"]>;
|
|
21
|
+
emitGoalProgress: (...args: Parameters<Manager["emitGoalProgress"]>) => ReturnType<Manager["emitGoalProgress"]>;
|
|
22
|
+
executionRefusal: (...args: Parameters<Manager["executionRefusal"]>) => ReturnType<Manager["executionRefusal"]>;
|
|
23
|
+
settleOnceTurn: (...args: Parameters<Manager["settleOnceTurn"]>) => ReturnType<Manager["settleOnceTurn"]>;
|
|
24
|
+
}
|
|
25
|
+
/** Serving `spawn` and `launch` as goals: acceptance, the cached acceptance a retry reads, and its expiry. */
|
|
26
|
+
export declare class SpawnGoal {
|
|
27
|
+
private readonly deps;
|
|
28
|
+
constructor(deps: SpawnGoalDeps);
|
|
29
|
+
private get agentGoals();
|
|
30
|
+
private get execution();
|
|
31
|
+
private get goalAcceptanceRetentionMs();
|
|
32
|
+
private get goalAcceptances();
|
|
33
|
+
private get goalReconcileDone();
|
|
34
|
+
private get goalWriter();
|
|
35
|
+
private get managerInstanceId();
|
|
36
|
+
private get onceWatched();
|
|
37
|
+
private get readinessTimeoutMs();
|
|
38
|
+
private get serviceServe();
|
|
39
|
+
private get userMode();
|
|
40
|
+
private acceptOnceTurn;
|
|
41
|
+
private assertGoalWriterEpochCurrent;
|
|
42
|
+
private commitOnceCancel;
|
|
43
|
+
private emitGoalProgress;
|
|
44
|
+
private executionRefusal;
|
|
45
|
+
private settleOnceTurn;
|
|
46
|
+
/** A spawn's refusal reaches only its caller's terminal, so the manager also writes one line for it
|
|
47
|
+
* to its own log, naming the request ID the caller printed, the persona and the reason. */
|
|
48
|
+
loggedSpawnRefusal<T>(ctx: EpServeContext, serve: () => Promise<T>): Promise<T>;
|
|
49
|
+
/** Serve `spawn`/`launch` as an ACTION. Authz already ran in {@link serveGated}. The
|
|
50
|
+
* accept path runs INLINE on the handler ({@link startAgent} with hooks): the goal binds + the
|
|
51
|
+
* acceptance replies the moment the identity is minted, BEFORE any provision, or on the
|
|
52
|
+
* hosted enrollment arm once the host has enrolled the agent; progress and the terminal are driven
|
|
53
|
+
* OFF-handler, so the ~30s readiness wait no longer blocks the reply.
|
|
54
|
+
* Returns the acceptance floor payload {name, owner, actor, uid, goalId, fingerprint, executor}
|
|
55
|
+
* (the ALLOCATED identity). goalId = the request id (env.id). */
|
|
56
|
+
serveSpawnGoal(ctx: EpServeContext, run: (hooks: SpawnHooks) => Promise<ControlReply>): Promise<SpawnAcceptance>;
|
|
57
|
+
/** H2: an acceptance served from a WINNER'S durable acceptance floor (the goal-index entry it
|
|
58
|
+
* wrote before its own ack). Refuses `unavailable` rather than inventing one — see
|
|
59
|
+
* {@link cachedSpawnAcceptance} for why an empty identity is never an acceptable answer. */
|
|
60
|
+
private acceptanceFromIndex;
|
|
61
|
+
/** Reconstruct a cached acceptance for a same-goalId retry NOT in the live map (a prior incarnation
|
|
62
|
+
* accepted it, or a concurrent winner whose map write this reader has not yet observed).
|
|
63
|
+
*
|
|
64
|
+
* H2 — WHY THIS PREFERS THE INDEX OVER THE TERMINAL. It used to read only the committed terminal
|
|
65
|
+
* and fall back to `{name:"", actor:"", uid:""}` when there was none. That is the common case,
|
|
66
|
+
* not a corner: a client retry over ANYCAST reaches a sibling while the winner is still
|
|
67
|
+
* provisioning, so no terminal exists yet, and the caller was handed an ACCEPTED reply naming an
|
|
68
|
+
* empty agent it can never address. The acceptance floor in the goal index exists from the moment
|
|
69
|
+
* of acceptance, so it answers precisely the window the terminal cannot. Where neither is
|
|
70
|
+
* readable the honest answer is a REFUSAL: an accepted goal whose identity nobody can name is
|
|
71
|
+
* `unavailable` while it runs and its cached outcome once it has ended, never a hollow success. */
|
|
72
|
+
private cachedSpawnAcceptance;
|
|
73
|
+
/** Drop a goal's acceptance {@link goalAcceptanceRetentionMs} after its terminal committed. A
|
|
74
|
+
* retry after that reads the terminal, so only a goal that has one may be passed here. */
|
|
75
|
+
expireGoalAcceptance(ref: GoalRef): void;
|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gBAAgB;IACxB,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,cAAc;IAEtB;gGAC4F;IACtF,kBAAkB,CAAC,CAAC,EAAE,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IASrF;;;;;;sEAMkE;IAC5D,cAAc,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAyOtH;;iGAE6F;YAC/E,mBAAmB;IASjC;;;;;;;;;;wGAUoG;YACtF,qBAAqB;IAoBnC;+FAC2F;IAC3F,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI;CAIzC"}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { bindGoal, canonicalJson, clearGoalIndex, commitGoalResult, createGoal, DEV_OWNER, EpEnvelopeError, goalAlreadyTerminal, goalRefOf, oneLine, parsePrincipalKey, readGoalIndex, readGoalResult, readGoalSpec, recordGoalIndex, rejectionText, settleGoalUncertain, submissionFingerprint } from "@cotal-ai/core";
|
|
2
|
+
import { caughtEnvelope, goalKey } from "./turn-relay.js";
|
|
3
|
+
/** The failed terminal a post-accept fallback commits for `error` and `source`'s optional details.
|
|
4
|
+
* `commitGoalResult` refuses a payload that is not interchangeable JSON, and this terminal must commit
|
|
5
|
+
* whatever failed, so a lone surrogate in the text becomes U+FFFD and details it cannot read or carry
|
|
6
|
+
* (a Proxy's throwing getter, an accessor, a cycle) are dropped. A Proxy can answer the check and the
|
|
7
|
+
* serializer differently, so the detached copy is checked again before it commits. */
|
|
8
|
+
function failedTerminal(error, source) {
|
|
9
|
+
const text = error.replace(/\p{Cs}/gu, "\uFFFD");
|
|
10
|
+
try {
|
|
11
|
+
const details = source?.details;
|
|
12
|
+
if (details) {
|
|
13
|
+
const copy = JSON.parse(canonicalJson(details));
|
|
14
|
+
canonicalJson(copy);
|
|
15
|
+
return { error: text, details: copy };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch { /* unreadable or not interchangeable */ }
|
|
19
|
+
return { error: text };
|
|
20
|
+
}
|
|
21
|
+
/** Serving `spawn` and `launch` as goals: acceptance, the cached acceptance a retry reads, and its expiry. */
|
|
22
|
+
export class SpawnGoal {
|
|
23
|
+
deps;
|
|
24
|
+
constructor(deps) {
|
|
25
|
+
this.deps = deps;
|
|
26
|
+
}
|
|
27
|
+
// The Manager members these bodies read, under their Manager names. Each reads through its dep at
|
|
28
|
+
// use, so a field the Manager assigns later is current and a method a test replaces on the Manager
|
|
29
|
+
// is the one that runs.
|
|
30
|
+
get agentGoals() { return this.deps.agentGoals(); }
|
|
31
|
+
get execution() { return this.deps.execution(); }
|
|
32
|
+
get goalAcceptanceRetentionMs() { return this.deps.goalAcceptanceRetentionMs(); }
|
|
33
|
+
get goalAcceptances() { return this.deps.goalAcceptances(); }
|
|
34
|
+
get goalReconcileDone() { return this.deps.goalReconcileDone(); }
|
|
35
|
+
get goalWriter() { return this.deps.goalWriter(); }
|
|
36
|
+
get managerInstanceId() { return this.deps.managerInstanceId(); }
|
|
37
|
+
get onceWatched() { return this.deps.onceWatched(); }
|
|
38
|
+
get readinessTimeoutMs() { return this.deps.readinessTimeoutMs(); }
|
|
39
|
+
get serviceServe() { return this.deps.serviceServe(); }
|
|
40
|
+
get userMode() { return this.deps.userMode(); }
|
|
41
|
+
acceptOnceTurn(...args) { return this.deps.acceptOnceTurn(...args); }
|
|
42
|
+
assertGoalWriterEpochCurrent(...args) { return this.deps.assertGoalWriterEpochCurrent(...args); }
|
|
43
|
+
commitOnceCancel(...args) { return this.deps.commitOnceCancel(...args); }
|
|
44
|
+
emitGoalProgress(...args) { return this.deps.emitGoalProgress(...args); }
|
|
45
|
+
executionRefusal(...args) { return this.deps.executionRefusal(...args); }
|
|
46
|
+
settleOnceTurn(...args) { return this.deps.settleOnceTurn(...args); }
|
|
47
|
+
/** A spawn's refusal reaches only its caller's terminal, so the manager also writes one line for it
|
|
48
|
+
* to its own log, naming the request ID the caller printed, the persona and the reason. */
|
|
49
|
+
async loggedSpawnRefusal(ctx, serve) {
|
|
50
|
+
try {
|
|
51
|
+
return await serve();
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
const persona = ctx.request.args?.name;
|
|
55
|
+
console.error(oneLine(`! spawn request ${ctx.request.id} for persona "${String(persona ?? "")}" refused (${e instanceof EpEnvelopeError ? e.code : "error"}): ${rejectionText(e)}`));
|
|
56
|
+
throw e;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** Serve `spawn`/`launch` as an ACTION. Authz already ran in {@link serveGated}. The
|
|
60
|
+
* accept path runs INLINE on the handler ({@link startAgent} with hooks): the goal binds + the
|
|
61
|
+
* acceptance replies the moment the identity is minted, BEFORE any provision, or on the
|
|
62
|
+
* hosted enrollment arm once the host has enrolled the agent; progress and the terminal are driven
|
|
63
|
+
* OFF-handler, so the ~30s readiness wait no longer blocks the reply.
|
|
64
|
+
* Returns the acceptance floor payload {name, owner, actor, uid, goalId, fingerprint, executor}
|
|
65
|
+
* (the ALLOCATED identity). goalId = the request id (env.id). */
|
|
66
|
+
async serveSpawnGoal(ctx, run) {
|
|
67
|
+
// These four refuse before anything is accepted or allocated, so they state it (SPEC 13.3).
|
|
68
|
+
if (this.execution === "none")
|
|
69
|
+
throw new EpEnvelopeError("unimplemented", this.executionRefusal(), undefined, "not-executed");
|
|
70
|
+
const gw = this.goalWriter;
|
|
71
|
+
if (!gw)
|
|
72
|
+
throw new EpEnvelopeError("unavailable", "the manager goal-writer connection is not standing; spawn-as-action cannot accept (SPEC 13.6)", undefined, "not-executed");
|
|
73
|
+
// Refuse to accept until the boot reconcile of inherited goals completes, so a fresh
|
|
74
|
+
// acceptance never races the sweep (settling a live goal mid-flight would steal its real terminal).
|
|
75
|
+
if (!this.goalReconcileDone)
|
|
76
|
+
throw new EpEnvelopeError("unavailable", "the manager is still reconciling accepted goals at boot; retry shortly (SPEC 13.6)", undefined, "not-executed");
|
|
77
|
+
const goalId = ctx.request.id;
|
|
78
|
+
const { fingerprint } = submissionFingerprint(ctx.request, ctx.subject);
|
|
79
|
+
const ref = goalRefOf(ctx.subject, goalId);
|
|
80
|
+
const key = goalKey(ref);
|
|
81
|
+
const executor = { lifecycleUid: this.managerInstanceId, epoch: this.serviceServe?.grant.epoch ?? 0 };
|
|
82
|
+
const epoch = executor.epoch;
|
|
83
|
+
const acceptedAt = Date.now();
|
|
84
|
+
// Idempotent same-goalId retry (a client re-send): serve the IDENTICAL acceptance without
|
|
85
|
+
// re-running the accept path — so a HARD-PINNED retry does not trip the same-name refuse and no
|
|
86
|
+
// name is re-allocated. Same-incarnation rides the live map; the create-only bindGoal in onAccepted
|
|
87
|
+
// still fences a CONCURRENT same-goalId race (the loser aborts and serves the winner's acceptance).
|
|
88
|
+
const prior = this.goalAcceptances.get(key);
|
|
89
|
+
// A goal that already ENDED is answered from its committed terminal and never accepted again.
|
|
90
|
+
// Running the accept for it allocates a fresh name and identity, then refuses at the index
|
|
91
|
+
// CAS, because the entry its terminal cleared cannot be created twice, and that refusal tells
|
|
92
|
+
// the caller to reconcile the store. A retry that outlived its entry above must not reach it.
|
|
93
|
+
const ended = prior === undefined ? await readGoalResult(gw.ctx, ref) : undefined;
|
|
94
|
+
const accepted = prior ?? ended;
|
|
95
|
+
if (accepted !== undefined) {
|
|
96
|
+
if (accepted.fingerprint !== fingerprint)
|
|
97
|
+
throw new EpEnvelopeError("failed-precondition", `goal "${goalId}" was accepted under a different submission; one goalId never carries two specs (SPEC 13.6)`, undefined, "not-executed");
|
|
98
|
+
return prior ?? this.cachedSpawnAcceptance(ref, goalId, fingerprint, executor);
|
|
99
|
+
}
|
|
100
|
+
let resolveAccept;
|
|
101
|
+
let rejectAccept;
|
|
102
|
+
const acceptP = new Promise((res, rej) => { resolveAccept = res; rejectAccept = rej; });
|
|
103
|
+
let acceptance;
|
|
104
|
+
let readinessTimeoutMs = this.readinessTimeoutMs;
|
|
105
|
+
// H1: set the instant the terminal path is ENTERED, not when it succeeds — the post-accept
|
|
106
|
+
// fallback below must fire only when `onOutcome` never ran at all, never as a second attempt
|
|
107
|
+
// behind a commit that threw.
|
|
108
|
+
let terminalEntered = false;
|
|
109
|
+
// TWO DIFFERENT QUESTIONS, DELIBERATELY NOT ONE FLAG.
|
|
110
|
+
//
|
|
111
|
+
// `terminalEntered` HAS this goal already been settled (or claimed) by someone?
|
|
112
|
+
// `ownsGoal` MAY THIS ATTEMPT settle it at all?
|
|
113
|
+
//
|
|
114
|
+
// The second is the authority, and it is default-CLOSED: an attempt earns it by WINNING the
|
|
115
|
+
// create-only `bindGoal` CAS below, and nothing else grants it. That matters because the
|
|
116
|
+
// post-accept fallback exists to settle a goal nobody answered, so every new way of leaving
|
|
117
|
+
// this function is opted INTO committing a terminal unless something stops it. Deriving the
|
|
118
|
+
// right from the claim instead of from a running record means a losing attempt CANNOT commit
|
|
119
|
+
// down any unwind path, including ones added later that never thought about this. Collapsing
|
|
120
|
+
// the two into one boolean is what let a duplicate-goal loser steal the winner's terminal
|
|
121
|
+
// (#357): it had entered no terminal, so the fallback wrote one for it, using its own abort
|
|
122
|
+
// message as the caller-visible outcome.
|
|
123
|
+
let ownsGoal = false;
|
|
124
|
+
// Set by onEffect. A refusal that arrives with it still false changed nothing.
|
|
125
|
+
let effectStarted = false;
|
|
126
|
+
// Set by onUndone: the host's code for a later refusal that left nothing behind.
|
|
127
|
+
let undone;
|
|
128
|
+
// The task of a once spawn, once accepted.
|
|
129
|
+
let onceRef;
|
|
130
|
+
// The terminal commits OFF-handler on the goal-writer connection (manager-only authority; a
|
|
131
|
+
// caller cannot publish it). TWO COMPOSED FENCES (defense in depth): (a) reads THIS
|
|
132
|
+
// incarnation's OWN gate epoch and REFUSES a superseded commit (the currency belt), and (b)
|
|
133
|
+
// barrier-revoke evicts this connection on takeover. The terminal lands on the ONE subject
|
|
134
|
+
// SPEC §13.2 (reserved subjects) reserves; first-terminal-fact-wins is global, so a committed outcome is visible
|
|
135
|
+
// to every reader in every incarnation. On success the reconcile-index entry is cleared.
|
|
136
|
+
//
|
|
137
|
+
// Named rather than inlined into the hooks below so the H1 post-accept fallback drives THIS
|
|
138
|
+
// path — one commit site, so the progress event, the index clear and the `agentGoals` cleanup
|
|
139
|
+
// cannot drift between a normal outcome and a recovered one.
|
|
140
|
+
const onOutcome = async (o) => {
|
|
141
|
+
// THE AUTHORITY CHECK, and the only one. An attempt that never won the bind provisioned
|
|
142
|
+
// nothing and has no outcome to report: the goal belongs to whoever won it, in this
|
|
143
|
+
// incarnation or a sibling. Refusing here rather than at each unwind site is the point --
|
|
144
|
+
// there is exactly one commit path, so this fences every route into it, present and future.
|
|
145
|
+
if (!ownsGoal)
|
|
146
|
+
return false;
|
|
147
|
+
terminalEntered = true; // entered, not succeeded — see the catch below
|
|
148
|
+
// A once spawn that did not succeed never served its task (delivery opens only with a
|
|
149
|
+
// succeeded verdict), so the task is cancelled now rather than at the seat's exit. A launched
|
|
150
|
+
// seat's debt is still settled by its exit, which proves the seat gone first; a spawn that
|
|
151
|
+
// never launched one owes nothing more.
|
|
152
|
+
if (o.kind !== "succeeded" && onceRef !== undefined) {
|
|
153
|
+
const reason = o.kind === "uncertain" ? "readiness-timeout" : "launch-failed";
|
|
154
|
+
if (this.onceWatched.has(goalKey(onceRef)))
|
|
155
|
+
void this.commitOnceCancel(onceRef, reason).catch((e) => console.error(`! once task ${onceRef.goalId} (${reason}): ${rejectionText(e)}; its seat's exit cancels it`));
|
|
156
|
+
else
|
|
157
|
+
void this.settleOnceTurn(onceRef, reason);
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
await this.assertGoalWriterEpochCurrent(epoch); // a superseded corpse never commits
|
|
161
|
+
let fact;
|
|
162
|
+
if (o.kind === "succeeded") {
|
|
163
|
+
this.emitGoalProgress(ref, epoch, { phase: "presence" });
|
|
164
|
+
({ fact } = await commitGoalResult(gw.ctx, { ref, now: Date.now(), cause: "complete", state: "succeeded", data: o.data, committer: { instanceId: this.managerInstanceId, epoch } }));
|
|
165
|
+
}
|
|
166
|
+
else if (o.kind === "failed") {
|
|
167
|
+
({ fact } = await commitGoalResult(gw.ctx, { ref, now: Date.now(), cause: "complete", state: "failed", data: o.data, committer: { instanceId: this.managerInstanceId, epoch } }));
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
// Forward the readiness detail as the terminal's reason: this manager owns the deadline,
|
|
171
|
+
// so it owns what elapsing it MEANS. Absent, core commits its own generic line (#605).
|
|
172
|
+
const { reason: why, running } = (o.data ?? {});
|
|
173
|
+
({ fact } = await settleGoalUncertain(gw.ctx, { ref, now: Date.now(), committer: { instanceId: this.managerInstanceId, epoch }, ...(typeof why === "string" && why.length > 0 ? { reason: why } : {}), ...(running === true ? { running: true } : {}) }));
|
|
174
|
+
}
|
|
175
|
+
this.expireGoalAcceptance(ref);
|
|
176
|
+
this.emitGoalProgress(ref, epoch, { phase: "terminal", state: fact.state, ...(fact.data !== undefined ? { data: fact.data } : {}) });
|
|
177
|
+
await clearGoalIndex(gw.ctx, ref); // terminal reached - the successor never reconciles it
|
|
178
|
+
if (acceptance)
|
|
179
|
+
this.agentGoals.delete(acceptance.name); // goal terminal - no cancel path left
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
catch (e) {
|
|
183
|
+
// THE NARROWER LEG, LEFT OPEN DELIBERATELY. If the COMMIT ITSELF throws (the currency belt
|
|
184
|
+
// refused a superseded commit, or the broker failed) there is genuinely no terminal, and the
|
|
185
|
+
// H1 fallback must NOT retry it: a retry either loses the same way or overwrites a real
|
|
186
|
+
// supersession refusal with a manufactured outcome. That is why `terminalEntered` is set on
|
|
187
|
+
// ENTRY. This leg is infrastructure-class and converges through the reconcile index at the
|
|
188
|
+
// next boot, which is why the index is NOT cleared above on this path. Do not "close" it
|
|
189
|
+
// here with a retry loop.
|
|
190
|
+
console.error(`! goal terminal commit for ${goalId} failed: ${rejectionText(e)}`);
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
const bg = run({
|
|
195
|
+
onAccepted: async ({ name, agentTriple }) => {
|
|
196
|
+
// Record the goal in the reconcile index BEFORE the bind (index-CAS-before-bind),
|
|
197
|
+
// so a successor incarnation finds + settles this goal if we crash before its terminal. A
|
|
198
|
+
// crash between this write and the bind leaves an index entry whose goal status is absent —
|
|
199
|
+
// the sweep clears it as a no-goal; a crash before it leaves no entry (never durable). A
|
|
200
|
+
// Carry THIS incarnation's instanceId (the executor coord) so a multi-instance sweep can skip a live sibling's goal.
|
|
201
|
+
//
|
|
202
|
+
// H2, THE ACCEPTANCE FLOOR: the allocated identity is written HERE, before the bind and so
|
|
203
|
+
// before the acceptance is acked, because this entry is the only durable record of it that
|
|
204
|
+
// exists that early — the goal spec does not carry it and the terminal does not exist yet.
|
|
205
|
+
// A same-goalId attempt that loses the bind while the winner is still in flight can then
|
|
206
|
+
// serve what the winner actually allocated instead of inventing an empty identity.
|
|
207
|
+
const idx = await recordGoalIndex(gw.ctx, ref, executor.lifecycleUid, { name, owner: agentTriple.owner, actor: agentTriple.actor, uid: agentTriple.uid, readinessDeadlineMs: readinessTimeoutMs });
|
|
208
|
+
// A create loss is an idempotent retry ONLY for the same incarnation. A FOREIGN iid means a
|
|
209
|
+
// sibling instance accepted this goalId (the live vector is a client retry over ANYCAST, not
|
|
210
|
+
// a journal consumer): this attempt provisions nothing and answers with the winner's floor,
|
|
211
|
+
// or refuses if that instance never persisted one.
|
|
212
|
+
if (!idx.recorded && idx.existing.iid !== executor.lifecycleUid) {
|
|
213
|
+
acceptance = await this.acceptanceFromIndex(idx.existing, ref, goalId, fingerprint, executor);
|
|
214
|
+
resolveAccept(acceptance);
|
|
215
|
+
// No claim needed here: `ownsGoal` is still false, so the commit path refuses this attempt.
|
|
216
|
+
throw new EpEnvelopeError("failed-precondition", `goal "${goalId}" was accepted by instance "${idx.existing.iid}"; that instance's acceptance is served and this attempt provisions nothing (SPEC 13.6)`);
|
|
217
|
+
}
|
|
218
|
+
// Bind AFTER the accept-path checks (name/capacity/persona) + identity mint, BEFORE any provision:
|
|
219
|
+
// a create-only CAS per goalId (a refused accept above left zero bind, zero reserve).
|
|
220
|
+
const b = await bindGoal(gw.ctx, ref, fingerprint);
|
|
221
|
+
if (!b.bound) {
|
|
222
|
+
if (b.existing.fingerprint !== fingerprint)
|
|
223
|
+
throw new EpEnvelopeError("failed-precondition", `goal "${goalId}" is already bound to a different submission; one goalId never carries two specs (SPEC 13.6)`);
|
|
224
|
+
// Lost a concurrent same-goalId race: serve the winner's acceptance and abort THIS provision
|
|
225
|
+
// (no second spawn). The throw unwinds to the finally, which releases this attempt's reserve.
|
|
226
|
+
acceptance = this.goalAcceptances.get(key) ?? await this.cachedSpawnAcceptance(ref, goalId, fingerprint, executor);
|
|
227
|
+
resolveAccept(acceptance);
|
|
228
|
+
// No claim needed here either. This attempt lost the CAS, so `ownsGoal` is still false and
|
|
229
|
+
// the single check in `onOutcome` refuses it. Before that check existed this site had to
|
|
230
|
+
// remember to claim the terminal by hand, and the one place that forgot is how a loser
|
|
231
|
+
// came to commit `failed` on the winner's goal, using its own abort text as the outcome.
|
|
232
|
+
// Unwind the provision (the acceptance is already served); the code is discarded by the
|
|
233
|
+
// caller (acceptance !== undefined), so it just aborts this attempt's side-effects.
|
|
234
|
+
throw new EpEnvelopeError("failed-precondition", `goal "${goalId}" is already accepted; the cached acceptance is served`);
|
|
235
|
+
}
|
|
236
|
+
// WON the claim: this attempt, and only this attempt, may settle this goal.
|
|
237
|
+
ownsGoal = true;
|
|
238
|
+
await createGoal(gw.ctx, ref, {
|
|
239
|
+
fingerprint,
|
|
240
|
+
command: ctx.subject.command,
|
|
241
|
+
caller: { id: `${ctx.subject.caller.owner}.${ctx.subject.caller.actor}`, lifecycleUid: ctx.subject.caller.uid },
|
|
242
|
+
// The ACCEPTING incarnation's epoch: half of the terminal's attribution pair (§13.6).
|
|
243
|
+
acceptedEpoch: epoch,
|
|
244
|
+
requestId: goalId,
|
|
245
|
+
sourceSeq: 0,
|
|
246
|
+
acceptedAt,
|
|
247
|
+
readinessDeadlineMs: readinessTimeoutMs,
|
|
248
|
+
});
|
|
249
|
+
acceptance = { name, owner: agentTriple.owner, actor: agentTriple.actor, uid: agentTriple.uid, goalId, fingerprint, readinessDeadlineMs: readinessTimeoutMs, executor };
|
|
250
|
+
this.goalAcceptances.set(key, acceptance);
|
|
251
|
+
this.agentGoals.set(name, ref); // A despawn of this name mid-goal drives the cancel path
|
|
252
|
+
resolveAccept(acceptance);
|
|
253
|
+
this.emitGoalProgress(ref, epoch, { phase: "handoff" });
|
|
254
|
+
},
|
|
255
|
+
onLaunched: () => this.emitGoalProgress(ref, epoch, { phase: "launched" }),
|
|
256
|
+
onReadinessWindow: (value) => { readinessTimeoutMs = value; },
|
|
257
|
+
onOutcome,
|
|
258
|
+
// Claim the terminal WITHOUT committing one: the despawn/stop that ended this launch owns
|
|
259
|
+
// it and commits `cancel`. This only stops the non-ok reply below from manufacturing a
|
|
260
|
+
// `failed` that would race that `cancel` (first-terminal-fact-wins).
|
|
261
|
+
onTerminalDeferred: () => { terminalEntered = true; },
|
|
262
|
+
onEffect: () => { effectStarted = true; },
|
|
263
|
+
onUndone: (code) => { undone = code; },
|
|
264
|
+
onOnce: async (task) => {
|
|
265
|
+
try {
|
|
266
|
+
const accepted = await this.acceptOnceTurn({ spawnRef: ref, fingerprint, command: ctx.subject.command, executor, acceptedAt, ...task });
|
|
267
|
+
onceRef = accepted.ref;
|
|
268
|
+
return accepted;
|
|
269
|
+
}
|
|
270
|
+
catch (e) {
|
|
271
|
+
// The spawn goal is already bound, so its refusal is a terminal: nothing has launched.
|
|
272
|
+
await onOutcome({ kind: "failed", data: { error: `the once task was not accepted: ${rejectionText(e)}` } });
|
|
273
|
+
throw e;
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
bg.then((reply) => {
|
|
278
|
+
// Refused BEFORE onAccepted (hard-pin collision, capacity, persona-not-found) — no goal bound.
|
|
279
|
+
// Only a refusal before the first effect, or one whose effects were all removed, states
|
|
280
|
+
// `not-executed`; a later one, such as the alias gate that re-drives a teardown, leaves the
|
|
281
|
+
// outcome unknown.
|
|
282
|
+
if (acceptance === undefined) {
|
|
283
|
+
const details = reply.details;
|
|
284
|
+
const code = undone ?? reply.code ?? "failed-precondition";
|
|
285
|
+
rejectAccept(new EpEnvelopeError(code, reply.error ?? "spawn refused at accept", details, effectStarted && undone === undefined ? undefined : "not-executed"));
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
// H1: `run` CATCHES its own body (a throw in buildLaunch/runtime.spawn) and RESOLVES `{ok:false}`
|
|
289
|
+
// rather than rejecting, so a post-accept failure arrives here, not in the catch below, and
|
|
290
|
+
// reaches none of the onOutcome sites. Without this the goal stays accepted-but-unanswered:
|
|
291
|
+
// the caller follows epe to a terminal that never comes, and the reconcile index that would
|
|
292
|
+
// settle it is only swept at BOOT, so a manager that stays up never converges it.
|
|
293
|
+
if (reply.ok === false && !terminalEntered)
|
|
294
|
+
return onOutcome({ kind: "failed", data: failedTerminal(reply.error ?? "spawn failed after accept", reply) });
|
|
295
|
+
}).catch((e) => {
|
|
296
|
+
if (acceptance === undefined) {
|
|
297
|
+
rejectAccept(e);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
// Same obligation for a genuine rejection (one that escaped `run`'s own catch).
|
|
301
|
+
if (!terminalEntered)
|
|
302
|
+
return onOutcome({ kind: "failed", data: failedTerminal(rejectionText(e), caughtEnvelope(e)) });
|
|
303
|
+
console.error(`! spawn-as-action async body for ${goalId}: ${rejectionText(e)}`);
|
|
304
|
+
}).catch((e) => console.error(`! goal terminal fallback for ${goalId}: ${rejectionText(e)}`));
|
|
305
|
+
return acceptP;
|
|
306
|
+
}
|
|
307
|
+
/** H2: an acceptance served from a WINNER'S durable acceptance floor (the goal-index entry it
|
|
308
|
+
* wrote before its own ack). Refuses `unavailable` rather than inventing one — see
|
|
309
|
+
* {@link cachedSpawnAcceptance} for why an empty identity is never an acceptable answer. */
|
|
310
|
+
async acceptanceFromIndex(entry, ref, goalId, fingerprint, executor) {
|
|
311
|
+
if (entry.allocated?.owner === undefined)
|
|
312
|
+
throw new EpEnvelopeError("unavailable", `goal "${goalId}" was accepted by instance "${entry.iid}", which persisted no acceptance floor naming its owner; its allocated identity is not readable from here (SPEC 13.6)`);
|
|
313
|
+
const readinessDeadlineMs = entry.allocated.readinessDeadlineMs ?? (await readGoalSpec(this.goalWriter.ctx, ref))?.value.readinessDeadlineMs;
|
|
314
|
+
if (readinessDeadlineMs === undefined)
|
|
315
|
+
throw new EpEnvelopeError("unavailable", `goal "${goalId}" is accepted but its readiness deadline is not readable; a synchronous follower cannot bound its wait honestly (SPEC 13.6)`);
|
|
316
|
+
return { name: entry.allocated.name, owner: entry.allocated.owner, actor: entry.allocated.actor, uid: entry.allocated.uid, goalId, fingerprint, readinessDeadlineMs, executor };
|
|
317
|
+
}
|
|
318
|
+
/** Reconstruct a cached acceptance for a same-goalId retry NOT in the live map (a prior incarnation
|
|
319
|
+
* accepted it, or a concurrent winner whose map write this reader has not yet observed).
|
|
320
|
+
*
|
|
321
|
+
* H2 — WHY THIS PREFERS THE INDEX OVER THE TERMINAL. It used to read only the committed terminal
|
|
322
|
+
* and fall back to `{name:"", actor:"", uid:""}` when there was none. That is the common case,
|
|
323
|
+
* not a corner: a client retry over ANYCAST reaches a sibling while the winner is still
|
|
324
|
+
* provisioning, so no terminal exists yet, and the caller was handed an ACCEPTED reply naming an
|
|
325
|
+
* empty agent it can never address. The acceptance floor in the goal index exists from the moment
|
|
326
|
+
* of acceptance, so it answers precisely the window the terminal cannot. Where neither is
|
|
327
|
+
* readable the honest answer is a REFUSAL: an accepted goal whose identity nobody can name is
|
|
328
|
+
* `unavailable` while it runs and its cached outcome once it has ended, never a hollow success. */
|
|
329
|
+
async cachedSpawnAcceptance(ref, goalId, fingerprint, executor) {
|
|
330
|
+
const entry = await readGoalIndex(this.goalWriter.ctx, ref);
|
|
331
|
+
if (entry?.allocated !== undefined)
|
|
332
|
+
return this.acceptanceFromIndex(entry, ref, goalId, fingerprint, executor);
|
|
333
|
+
// The index is CLEARED at terminal, so a settled goal legitimately has no entry: fall back to
|
|
334
|
+
// the terminal's data, which carries the same identity for exactly that case.
|
|
335
|
+
const result = await readGoalResult(this.goalWriter.ctx, ref);
|
|
336
|
+
const d = (result?.data ?? {});
|
|
337
|
+
const spec = await readGoalSpec(this.goalWriter.ctx, ref);
|
|
338
|
+
const readinessDeadlineMs = spec?.value.readinessDeadlineMs;
|
|
339
|
+
// The terminal names the agent by its slot id: the `owner.actor` principal in user mode, the
|
|
340
|
+
// bare nkey under DEV_OWNER on a static mesh.
|
|
341
|
+
const principal = typeof d.id !== "string" || d.id.length === 0 ? null : this.userMode ? parsePrincipalKey(d.id) : { owner: DEV_OWNER, actor: d.id };
|
|
342
|
+
if (typeof d.name === "string" && d.name.length > 0 && principal !== null && typeof d.lifecycleUid === "string" && d.lifecycleUid.length > 0 && readinessDeadlineMs !== undefined)
|
|
343
|
+
return { name: d.name, owner: principal.owner, actor: principal.actor, uid: d.lifecycleUid, goalId, fingerprint, readinessDeadlineMs, executor };
|
|
344
|
+
// Only a `succeeded` terminal names the agent. Any other ended goal has its outcome as its
|
|
345
|
+
// whole durable answer, and no retry will make an identity readable (SPEC 13.6 item 5).
|
|
346
|
+
if (result !== undefined)
|
|
347
|
+
throw goalAlreadyTerminal(goalId, result);
|
|
348
|
+
throw new EpEnvelopeError("unavailable", `goal "${goalId}" is already accepted but its allocated identity is not readable (no acceptance floor, and no terminal carrying one); retry (SPEC 13.6)`);
|
|
349
|
+
}
|
|
350
|
+
/** Drop a goal's acceptance {@link goalAcceptanceRetentionMs} after its terminal committed. A
|
|
351
|
+
* retry after that reads the terminal, so only a goal that has one may be passed here. */
|
|
352
|
+
expireGoalAcceptance(ref) {
|
|
353
|
+
const key = goalKey(ref);
|
|
354
|
+
setTimeout(() => this.goalAcceptances.delete(key), this.goalAcceptanceRetentionMs).unref?.();
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
//# sourceMappingURL=spawn-goal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn-goal.js","sourceRoot":"","sources":["../src/spawn-goal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,mBAAmB,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAIxT,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1D;;;;uFAIuF;AACvF,SAAS,cAAc,CAAC,KAAa,EAAE,MAAyC;IAC9E,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACjD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,EAAE,OAAO,CAAC;QAChC,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;YAChD,aAAa,CAAC,IAAI,CAAC,CAAC;YACpB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACxC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC,CAAC,uCAAuC,CAAC,CAAC;IACnD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACzB,CAAC;AAwBD,8GAA8G;AAC9G,MAAM,OAAO,SAAS;IACS;IAA7B,YAA6B,IAAmB;QAAnB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EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC;QACnJ,2FAA2F;QAC3F,wFAAwF;QACxF,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACpE,MAAM,IAAI,eAAe,CAAC,aAAa,EAAE,SAAS,MAAM,yIAAyI,CAAC,CAAC;IACrM,CAAC;IAED;+FAC2F;IAC3F,oBAAoB,CAAC,GAAY;QAC/B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QACzB,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;IAC/F,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,EAAE,UAAU,EAAkB,MAAM,iBAAiB,CAAC;AAKlE;+GAC+G;AAC/G,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChD,SAAS,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IACtC,eAAe,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClD,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,aAAa,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9C,gBAAgB,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,KAAK,UAAU,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC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