@tangle-network/agent-runtime 0.233.1 → 0.235.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{activation-D0_qcEXf.js → activation-BJakmnI1.js} +2 -2
- package/dist/{activation-D0_qcEXf.js.map → activation-BJakmnI1.js.map} +1 -1
- package/dist/{activation-C8fPmjWa.d.ts → activation-BqEP6ExG.d.ts} +2 -2
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/{coordination-driver-BR52Rt39.js → coordination-driver-mujMubUb.js} +2 -2
- package/dist/{coordination-driver-BR52Rt39.js.map → coordination-driver-mujMubUb.js.map} +1 -1
- package/dist/{delegate-CA-Tnr1_.js → delegate-BqN82j4Z.js} +2 -2
- package/dist/{delegate-CA-Tnr1_.js.map → delegate-BqN82j4Z.js.map} +1 -1
- package/dist/durable.d.ts +4 -2
- package/dist/durable.js +4 -2
- package/dist/durable.js.map +1 -1
- package/dist/{graph-BtMQMQin.js → graph-B-Sbq3QW.js} +3 -3
- package/dist/{graph-BtMQMQin.js.map → graph-B-Sbq3QW.js.map} +1 -1
- package/dist/{improvement-cycle-WJJALdil.js → improvement-cycle-DpX5QVx0.js} +3 -3
- package/dist/{improvement-cycle-WJJALdil.js.map → improvement-cycle-DpX5QVx0.js.map} +1 -1
- package/dist/{index-BwWBXoyq.d.ts → index-DgFsQnzq.d.ts} +4 -17
- package/dist/index.d.ts +6 -6
- package/dist/index.js +7 -7
- package/dist/intelligence.d.ts +3 -3
- package/dist/intelligence.js +3 -3
- package/dist/kernel.d.ts +4 -4
- package/dist/kernel.js +8 -8
- package/dist/{loop-runner-bin-DaOd42mA.d.ts → loop-runner-bin-3H3Iq9iY.d.ts} +3 -3
- package/dist/{loop-runner-bin-7cS9NAmk.js → loop-runner-bin-Dyc1IS0f.js} +3 -3
- package/dist/{loop-runner-bin-7cS9NAmk.js.map → loop-runner-bin-Dyc1IS0f.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +5 -5
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-BdFqNlha.d.ts → openai-tools-CoAfqfko.d.ts} +2 -2
- package/dist/profiles.d.ts +2 -2
- package/dist/{provision-supervisor-BME3OgTk.js → provision-supervisor-Wh8JAo-o.js} +3 -3
- package/dist/{provision-supervisor-BME3OgTk.js.map → provision-supervisor-Wh8JAo-o.js.map} +1 -1
- package/dist/{runtime-CcfA_ElB.js → runtime-Dffe3FZC.js} +8 -8
- package/dist/{runtime-CcfA_ElB.js.map → runtime-Dffe3FZC.js.map} +1 -1
- package/dist/{server-DU3nDuDb.js → server-BdKJxqUd.js} +3 -3
- package/dist/{server-DU3nDuDb.js.map → server-BdKJxqUd.js.map} +1 -1
- package/dist/{stream-agent-turn-aXpd9b_N.d.ts → stream-agent-turn-r1mtjn0i.d.ts} +2 -2
- package/dist/{structural-rollout-YlkrevWE.js → structural-rollout-BLTQRy-B.js} +2 -2
- package/dist/{structural-rollout-YlkrevWE.js.map → structural-rollout-BLTQRy-B.js.map} +1 -1
- package/dist/{substrate-B2Os0b0f.d.ts → substrate-BfNaAM8h.d.ts} +2 -2
- package/dist/{supervise-CAJWyXQ-.js → supervise-DMiJQB2_.js} +3 -3
- package/dist/{supervise-CAJWyXQ-.js.map → supervise-DMiJQB2_.js.map} +1 -1
- package/dist/{supervisor-C2xWmESG.js → supervisor-CBtuIoqP.js} +354 -96
- package/dist/supervisor-CBtuIoqP.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +12 -12
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{types-F5MG_7Qq.d.ts → types-BxjpKpb-.d.ts} +112 -13
- package/package.json +1 -1
- package/dist/supervisor-C2xWmESG.js.map +0 -1
|
@@ -6239,6 +6239,23 @@ function assertRequestedInteractionCapabilities(providerName, requested, capabil
|
|
|
6239
6239
|
}
|
|
6240
6240
|
//#endregion
|
|
6241
6241
|
//#region src/runtime/retained-run-events.ts
|
|
6242
|
+
/** The runtime's own contract checks inside the stream loop, so the catch can tell a broken
|
|
6243
|
+
* answer (a verdict) from a read the provider's iterator failed (a wrapper). */
|
|
6244
|
+
const runtimeChecks = /* @__PURE__ */ new WeakSet();
|
|
6245
|
+
function contractCheckFailed(message) {
|
|
6246
|
+
const error = new Error(message);
|
|
6247
|
+
runtimeChecks.add(error);
|
|
6248
|
+
throw error;
|
|
6249
|
+
}
|
|
6250
|
+
/** Run one of the runtime's own checks; whatever it throws is a verdict, not a failed read. */
|
|
6251
|
+
function verdict(check) {
|
|
6252
|
+
try {
|
|
6253
|
+
return check();
|
|
6254
|
+
} catch (error) {
|
|
6255
|
+
if (error instanceof Error) runtimeChecks.add(error);
|
|
6256
|
+
throw error;
|
|
6257
|
+
}
|
|
6258
|
+
}
|
|
6242
6259
|
async function* retainedRunEvents(session, controlRef, options, now) {
|
|
6243
6260
|
const after = options?.after;
|
|
6244
6261
|
if (after) {
|
|
@@ -6261,24 +6278,24 @@ async function* retainedRunEvents(session, controlRef, options, now) {
|
|
|
6261
6278
|
const source = next.value;
|
|
6262
6279
|
const identity = extractTransportEventIdentity(source);
|
|
6263
6280
|
const sourceCursor = identity.cursor ?? identity.eventId;
|
|
6264
|
-
assertEventBinding(source, controlRef);
|
|
6281
|
+
verdict(() => assertEventBinding(source, controlRef));
|
|
6265
6282
|
if (sourceCursor === after?.cursor) continue;
|
|
6266
6283
|
const event = canonicalEvent(source);
|
|
6267
6284
|
if (!event) continue;
|
|
6268
|
-
assertCanonicalEventBinding(controlRef, event);
|
|
6285
|
+
verdict(() => assertCanonicalEventBinding(controlRef, event));
|
|
6269
6286
|
if (firstAfterEvent && after !== void 0) {
|
|
6270
|
-
if (identity.sequence !== void 0 && identity.sequence <= after.sequence)
|
|
6287
|
+
if (identity.sequence !== void 0 && identity.sequence <= after.sequence) contractCheckFailed("provider replay did not prove that the first event follows the requested cursor");
|
|
6271
6288
|
firstAfterEvent = false;
|
|
6272
6289
|
}
|
|
6273
6290
|
const eventId = identity.eventId ?? identity.cursor;
|
|
6274
|
-
if (!eventId)
|
|
6291
|
+
if (!eventId) contractCheckFailed("replayable canonical event has no stable provider event id or cursor");
|
|
6275
6292
|
assertStableText(eventId, "provider event id");
|
|
6276
|
-
if (seen.has(eventId))
|
|
6293
|
+
if (seen.has(eventId)) contractCheckFailed(`provider replay repeated event id "${eventId}"`);
|
|
6277
6294
|
seen.add(eventId);
|
|
6278
6295
|
const sequence = identity.sequence ?? nextSequence;
|
|
6279
|
-
if (sequence <= lastSequence)
|
|
6296
|
+
if (sequence <= lastSequence) contractCheckFailed(`provider event sequence is not monotonic: ${sequence} follows ${lastSequence}`);
|
|
6280
6297
|
const occurredAt = identity.occurredAt;
|
|
6281
|
-
yield RuntimeEventEnvelopeSchema.parse({
|
|
6298
|
+
yield verdict(() => RuntimeEventEnvelopeSchema.parse({
|
|
6282
6299
|
runId: controlRef.runId,
|
|
6283
6300
|
eventId,
|
|
6284
6301
|
sequence,
|
|
@@ -6286,7 +6303,7 @@ async function* retainedRunEvents(session, controlRef, options, now) {
|
|
|
6286
6303
|
...occurredAt === void 0 ? {} : { occurredAt },
|
|
6287
6304
|
receivedAt: new Date(now()).toISOString(),
|
|
6288
6305
|
event
|
|
6289
|
-
});
|
|
6306
|
+
}));
|
|
6290
6307
|
lastSequence = sequence;
|
|
6291
6308
|
nextSequence = sequence + 1;
|
|
6292
6309
|
}
|
|
@@ -6298,8 +6315,9 @@ async function* retainedRunEvents(session, controlRef, options, now) {
|
|
|
6298
6315
|
throw abortError$2(options.signal.reason);
|
|
6299
6316
|
}
|
|
6300
6317
|
if (error instanceof RetainedRunProviderContractError) throw error;
|
|
6318
|
+
const fromProvider = error instanceof Error && !runtimeChecks.has(error);
|
|
6301
6319
|
throw new RetainedRunProviderContractError(error instanceof Error ? error.message : "provider retained event stream failed", {
|
|
6302
|
-
code: "RETAINED_EVENT_STREAM_INVALID",
|
|
6320
|
+
code: fromProvider ? "RETAINED_EVENT_STREAM_READ_FAILED" : "RETAINED_EVENT_STREAM_INVALID",
|
|
6303
6321
|
cause: error
|
|
6304
6322
|
});
|
|
6305
6323
|
} finally {
|
|
@@ -7208,11 +7226,102 @@ const retainedExecutorSeamKey = "runtime.retainedExecutor";
|
|
|
7208
7226
|
function retainedExecutorContext(ctx) {
|
|
7209
7227
|
return ctx.seams[retainedExecutorSeamKey];
|
|
7210
7228
|
}
|
|
7211
|
-
|
|
7229
|
+
const causeMessages = {
|
|
7230
|
+
unobservable: "retained provider execution requires reconciliation before replacement",
|
|
7231
|
+
"provider-contract": "retained provider execution ended on a provider contract violation; nothing to reconcile",
|
|
7232
|
+
"request-rejected": "retained provider execution was refused before it ran; nothing to reconcile",
|
|
7233
|
+
transport: "retained provider execution lost its transport; status in doubt",
|
|
7234
|
+
"nested-recovery": "retained nested execution requires recovery before replacement"
|
|
7235
|
+
};
|
|
7236
|
+
/** The contract-error codes that wrap a failed READ rather than name a broken answer. */
|
|
7237
|
+
const readFailureCodes = /* @__PURE__ */ new Set(["RETAINED_RESULT_READ_FAILED", "RETAINED_CONTROL_REF_READ_FAILED"]);
|
|
7238
|
+
/** Socket-level failures, by the codes Node and undici assign, plus the Sandbox SDK's own. */
|
|
7239
|
+
const transportCodes = /* @__PURE__ */ new Set([
|
|
7240
|
+
"ECONNRESET",
|
|
7241
|
+
"ECONNREFUSED",
|
|
7242
|
+
"ETIMEDOUT",
|
|
7243
|
+
"ENOTFOUND",
|
|
7244
|
+
"EAI_AGAIN",
|
|
7245
|
+
"EPIPE",
|
|
7246
|
+
"UND_ERR_SOCKET",
|
|
7247
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
7248
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
7249
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
7250
|
+
"NETWORK_ERROR"
|
|
7251
|
+
]);
|
|
7252
|
+
function readNumber(value, key) {
|
|
7253
|
+
const read = Reflect.get(value, key);
|
|
7254
|
+
return typeof read === "number" && Number.isFinite(read) ? read : void 0;
|
|
7255
|
+
}
|
|
7256
|
+
function readString(value, key) {
|
|
7257
|
+
const read = Reflect.get(value, key);
|
|
7258
|
+
return typeof read === "string" ? read : void 0;
|
|
7259
|
+
}
|
|
7260
|
+
/**
|
|
7261
|
+
* Walk the cause chain (bounded, cycle-safe) and name the first cause whose structure decides.
|
|
7262
|
+
*
|
|
7263
|
+
* `phase` says whether a 4xx or a client deadline can mean "refused before it ran": only at
|
|
7264
|
+
* admission. After admission the same status means the provider cannot resolve what it
|
|
7265
|
+
* admitted, and the honest name is the refusal.
|
|
7266
|
+
*/
|
|
7267
|
+
function classifyRetainedPendingCause(cause, phase = "execution") {
|
|
7268
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7269
|
+
const queue = [{
|
|
7270
|
+
value: cause,
|
|
7271
|
+
phase
|
|
7272
|
+
}];
|
|
7273
|
+
let steps = 0;
|
|
7274
|
+
while (queue.length > 0 && steps < 12) {
|
|
7275
|
+
steps += 1;
|
|
7276
|
+
const { value, phase: at } = queue.shift();
|
|
7277
|
+
if (typeof value !== "object" || value === null || seen.has(value)) continue;
|
|
7278
|
+
seen.add(value);
|
|
7279
|
+
if (value instanceof RetainedExecutionPendingError) return value.pendingCause;
|
|
7280
|
+
const name = readString(value, "name");
|
|
7281
|
+
const code = readString(value, "code");
|
|
7282
|
+
const status = readNumber(value, "status") ?? readNumber(value, "statusCode");
|
|
7283
|
+
if (name === "RetainedRunProviderContractError") {
|
|
7284
|
+
if (code === void 0 || !readFailureCodes.has(code)) return "provider-contract";
|
|
7285
|
+
queue.unshift({
|
|
7286
|
+
value: Reflect.get(value, "cause"),
|
|
7287
|
+
phase: "execution"
|
|
7288
|
+
});
|
|
7289
|
+
continue;
|
|
7290
|
+
}
|
|
7291
|
+
if (name === "ZodError" || Array.isArray(Reflect.get(value, "issues"))) return at === "admission" ? "request-rejected" : "provider-contract";
|
|
7292
|
+
if (code !== void 0 && transportCodes.has(code)) return "transport";
|
|
7293
|
+
if (name === "NetworkError" || name === "ServerError") return "transport";
|
|
7294
|
+
if (status !== void 0) {
|
|
7295
|
+
if (status >= 500) return "transport";
|
|
7296
|
+
if (at === "admission" && status !== 408) return "request-rejected";
|
|
7297
|
+
return "unobservable";
|
|
7298
|
+
}
|
|
7299
|
+
const errors = Reflect.get(value, "errors");
|
|
7300
|
+
if (Array.isArray(errors)) for (const member of errors) queue.push({
|
|
7301
|
+
value: member,
|
|
7302
|
+
phase: at
|
|
7303
|
+
});
|
|
7304
|
+
queue.push({
|
|
7305
|
+
value: Reflect.get(value, "cause"),
|
|
7306
|
+
phase: at
|
|
7307
|
+
});
|
|
7308
|
+
}
|
|
7309
|
+
return "unobservable";
|
|
7310
|
+
}
|
|
7311
|
+
/**
|
|
7312
|
+
* Local observation stopped; the retained provider execution has no accepted terminal result.
|
|
7313
|
+
*
|
|
7314
|
+
* The message names WHICH of the situations in {@link RetainedPendingCause} this is, and the
|
|
7315
|
+
* `pendingCause` field carries it as a value the settlement records, so a reader never splits
|
|
7316
|
+
* the population on the message's wording. The cause chain is kept for the `caused by` receipt.
|
|
7317
|
+
*/
|
|
7212
7318
|
var RetainedExecutionPendingError = class extends Error {
|
|
7213
|
-
|
|
7214
|
-
|
|
7319
|
+
pendingCause;
|
|
7320
|
+
constructor(cause, pendingCause = "execution") {
|
|
7321
|
+
const resolved = pendingCause === "admission" || pendingCause === "execution" ? classifyRetainedPendingCause(cause, pendingCause) : pendingCause;
|
|
7322
|
+
super(causeMessages[resolved], { cause });
|
|
7215
7323
|
this.name = "RetainedExecutionPendingError";
|
|
7324
|
+
this.pendingCause = resolved;
|
|
7216
7325
|
}
|
|
7217
7326
|
};
|
|
7218
7327
|
const retainedPreparations = /* @__PURE__ */ new WeakMap();
|
|
@@ -8193,7 +8302,14 @@ async function providerExecutionSource(args, turn, signal) {
|
|
|
8193
8302
|
break;
|
|
8194
8303
|
}
|
|
8195
8304
|
if (next.done) break;
|
|
8196
|
-
|
|
8305
|
+
try {
|
|
8306
|
+
assertEventBinding(next.value, handle.controlRef);
|
|
8307
|
+
} catch (error) {
|
|
8308
|
+
throw new RetainedRunProviderContractError(error instanceof Error ? error.message : "provider event bound to another run", {
|
|
8309
|
+
code: "RETAINED_EVENT_BINDING_INVALID",
|
|
8310
|
+
cause: error
|
|
8311
|
+
});
|
|
8312
|
+
}
|
|
8197
8313
|
if (next.value.id !== void 0) lastReplayPosition = next.value.id;
|
|
8198
8314
|
if (isTerminalEnvironmentEvent(next.value)) sawTerminal = true;
|
|
8199
8315
|
yield next.value;
|
|
@@ -8244,7 +8360,7 @@ async function providerExecutionSource(args, turn, signal) {
|
|
|
8244
8360
|
retained: true
|
|
8245
8361
|
};
|
|
8246
8362
|
} catch (error) {
|
|
8247
|
-
if (admitted) throw new RetainedExecutionPendingError(error);
|
|
8363
|
+
if (admitted) throw new RetainedExecutionPendingError(error, "admission");
|
|
8248
8364
|
throw error;
|
|
8249
8365
|
}
|
|
8250
8366
|
}
|
|
@@ -16085,6 +16201,7 @@ async function replaySpawnTree(journal, blobs, root) {
|
|
|
16085
16201
|
},
|
|
16086
16202
|
...ev.harnessTranscript === void 0 ? {} : { harnessTranscript: ev.harnessTranscript },
|
|
16087
16203
|
...ev.retainedExecution === void 0 ? {} : { retainedExecution: ev.retainedExecution },
|
|
16204
|
+
...ev.retainedPendingCause === void 0 ? {} : { retainedPendingCause: ev.retainedPendingCause },
|
|
16088
16205
|
...settlementTime(ev.at),
|
|
16089
16206
|
seq: ev.seq
|
|
16090
16207
|
});
|
|
@@ -16104,6 +16221,7 @@ async function replaySpawnTree(journal, blobs, root) {
|
|
|
16104
16221
|
trace,
|
|
16105
16222
|
...ev.harnessTranscript === void 0 ? {} : { harnessTranscript: ev.harnessTranscript },
|
|
16106
16223
|
...ev.retainedExecution === void 0 ? {} : { retainedExecution: ev.retainedExecution },
|
|
16224
|
+
...ev.retainedPendingCause === void 0 ? {} : { retainedPendingCause: ev.retainedPendingCause },
|
|
16107
16225
|
...settlementTime(ev.at),
|
|
16108
16226
|
seq: ev.seq
|
|
16109
16227
|
});
|
|
@@ -16206,6 +16324,7 @@ function materializeTreeView(events) {
|
|
|
16206
16324
|
node.trace = traceEvidenceFor(ev);
|
|
16207
16325
|
node.budgetViolation = budgetViolationOf(ev).budgetViolation;
|
|
16208
16326
|
if (ev.retainedExecution !== void 0) node.retainedExecution = ev.retainedExecution;
|
|
16327
|
+
if (ev.retainedPendingCause !== void 0) node.retainedPendingCause = ev.retainedPendingCause;
|
|
16209
16328
|
const settledAt = Date.parse(ev.at);
|
|
16210
16329
|
if (Number.isFinite(settledAt)) node.settledAt = settledAt;
|
|
16211
16330
|
} else if (ev.kind === "woken") {
|
|
@@ -16230,6 +16349,7 @@ function materializeTreeView(events) {
|
|
|
16230
16349
|
node.outRef = ev.outRef;
|
|
16231
16350
|
node.budgetViolation = budgetViolationOf(ev).budgetViolation;
|
|
16232
16351
|
if (ev.retainedExecution !== void 0) node.retainedExecution = ev.retainedExecution;
|
|
16352
|
+
if (ev.retainedPendingCause !== void 0) node.retainedPendingCause = ev.retainedPendingCause;
|
|
16233
16353
|
const settledAt = Date.parse(ev.at);
|
|
16234
16354
|
if (Number.isFinite(settledAt)) node.settledAt = settledAt;
|
|
16235
16355
|
}
|
|
@@ -16336,6 +16456,7 @@ function freezeSnapshot(node) {
|
|
|
16336
16456
|
trace: node.trace,
|
|
16337
16457
|
...node.budgetViolation === void 0 ? {} : { budgetViolation: node.budgetViolation },
|
|
16338
16458
|
...node.retainedExecution === void 0 ? {} : { retainedExecution: node.retainedExecution },
|
|
16459
|
+
...node.retainedPendingCause === void 0 ? {} : { retainedPendingCause: node.retainedPendingCause },
|
|
16339
16460
|
settledAt: node.settledAt,
|
|
16340
16461
|
spawnedAt: node.spawnedAt
|
|
16341
16462
|
};
|
|
@@ -19856,7 +19977,178 @@ function stableText(value, label) {
|
|
|
19856
19977
|
return text;
|
|
19857
19978
|
}
|
|
19858
19979
|
//#endregion
|
|
19980
|
+
//#region src/runtime/supervise/terminal-record.ts
|
|
19981
|
+
/** The settlement fields every writer copies, in the terminal record's key order. The
|
|
19982
|
+
* `reconciled` record is built from this same spread so it and the terminal record can never
|
|
19983
|
+
* disagree on a field. */
|
|
19984
|
+
function settlementFields(subject, settlement) {
|
|
19985
|
+
return {
|
|
19986
|
+
spent: subject.spent,
|
|
19987
|
+
infra: settlement.infra,
|
|
19988
|
+
reason: settlement.reason,
|
|
19989
|
+
...settlement.retainedPendingCause === void 0 ? {} : { retainedPendingCause: settlement.retainedPendingCause },
|
|
19990
|
+
...settlement.outRef ? { outRef: settlement.outRef } : {},
|
|
19991
|
+
...settlement.providerModel ? { providerModel: settlement.providerModel } : {},
|
|
19992
|
+
...subject.budgetViolation ? { budgetViolation: subject.budgetViolation } : {},
|
|
19993
|
+
trace: settlement.trace,
|
|
19994
|
+
...settlement.harnessTranscript ? { harnessTranscript: settlement.harnessTranscript } : {}
|
|
19995
|
+
};
|
|
19996
|
+
}
|
|
19997
|
+
/** `cancelled` keeps its `source` from the subject's own cancellation reason, so a released
|
|
19998
|
+
* cancelled child records the same source it settled with. */
|
|
19999
|
+
function terminalDownEvent(subject, settlement, seq, at, retainedExecution) {
|
|
20000
|
+
const cancellation = subject.cancellationReason;
|
|
20001
|
+
return {
|
|
20002
|
+
...cancellation === void 0 ? {
|
|
20003
|
+
kind: "settled",
|
|
20004
|
+
status: "down"
|
|
20005
|
+
} : {
|
|
20006
|
+
kind: "cancelled",
|
|
20007
|
+
source: cancellation.source
|
|
20008
|
+
},
|
|
20009
|
+
id: subject.id,
|
|
20010
|
+
...settlementFields(subject, settlement),
|
|
20011
|
+
...retainedExecution === void 0 ? {} : { retainedExecution },
|
|
20012
|
+
seq,
|
|
20013
|
+
at
|
|
20014
|
+
};
|
|
20015
|
+
}
|
|
20016
|
+
/**
|
|
20017
|
+
* The evidence a settled node carries beyond its status: the receipts that name what actually
|
|
20018
|
+
* ran, the own-inference spend the parent tree re-homes as a `metered` event, and the wall-clock
|
|
20019
|
+
* window. One builder feeds BOTH terminal paths, so an observer never sees a `down` node
|
|
20020
|
+
* described in different terms from a `done` one. Every field is omitted when the fact is
|
|
20021
|
+
* absent — an unreported receipt must not read as an empty one. Snapshots are detached because
|
|
20022
|
+
* an observer may serialize them after the live child has moved on.
|
|
20023
|
+
*/
|
|
20024
|
+
function settledNodeEvidence(subject, settlement, settledAt) {
|
|
20025
|
+
return {
|
|
20026
|
+
runtime: subject.runtime,
|
|
20027
|
+
startedAt: subject.startedAt,
|
|
20028
|
+
settledAt,
|
|
20029
|
+
...settlement.metered ? { metered: detachedSnapshot(settlement.metered, "metered") } : {},
|
|
20030
|
+
...subject.providerModel ? { providerModel: detachedSnapshot(subject.providerModel, "provider model evidence") } : {},
|
|
20031
|
+
...subject.materialization ? { materialization: detachedSnapshot(subject.materialization, "materialization receipt") } : {},
|
|
20032
|
+
...subject.executionBindings.length > 0 ? { executionBindings: detachedSnapshot([...subject.executionBindings], "execution binding receipts") } : {},
|
|
20033
|
+
...subject.budgetViolation ? { budgetViolation: detachedSnapshot(subject.budgetViolation, "budget violation") } : {},
|
|
20034
|
+
trace: detachedSnapshot(settlement.trace, "worker trace evidence")
|
|
20035
|
+
};
|
|
20036
|
+
}
|
|
20037
|
+
/** The `agent.child` payload of the release: the settlement restated as released, `settledAt`
|
|
20038
|
+
* kept at the settlement instant and `metered` omitted so the driver's inference is not summed
|
|
20039
|
+
* twice. The sweep and the resume heal emit it from the same builder. */
|
|
20040
|
+
function releasedChildPayload(subject, settlement, settledAt, releasedAt) {
|
|
20041
|
+
return {
|
|
20042
|
+
childId: subject.id,
|
|
20043
|
+
status: "down",
|
|
20044
|
+
retainedExecution: "released",
|
|
20045
|
+
...settlement.retainedPendingCause === void 0 ? {} : { retainedPendingCause: settlement.retainedPendingCause },
|
|
20046
|
+
releasedAt,
|
|
20047
|
+
...settlement.outRef === void 0 ? {} : { outRef: settlement.outRef },
|
|
20048
|
+
reason: settlement.reason,
|
|
20049
|
+
infra: settlement.infra,
|
|
20050
|
+
spent: subject.spent,
|
|
20051
|
+
...settledNodeEvidence(subject, {
|
|
20052
|
+
...settlement,
|
|
20053
|
+
metered: void 0
|
|
20054
|
+
}, settledAt)
|
|
20055
|
+
};
|
|
20056
|
+
}
|
|
20057
|
+
//#endregion
|
|
19859
20058
|
//#region src/runtime/supervise/recover-executors.ts
|
|
20059
|
+
/** The environment id the node's latest durable admission names — the executor's own rule
|
|
20060
|
+
* (`admittedEnvironmentId` in environment-provider.ts), read off the journal. */
|
|
20061
|
+
function journaledEnvironmentId(owned) {
|
|
20062
|
+
for (const event of [...owned].reverse()) {
|
|
20063
|
+
if (event.kind !== "execution-admitted") continue;
|
|
20064
|
+
if (event.admission.phase === "dispatched") return event.admission.controlRef.environmentId;
|
|
20065
|
+
if (event.admission.phase === "environment") return event.admission.environmentId;
|
|
20066
|
+
}
|
|
20067
|
+
}
|
|
20068
|
+
/**
|
|
20069
|
+
* Close the cursor slot of every node the release sweep destroyed but never recorded: the
|
|
20070
|
+
* settling process died between the last `environment-teardown` receipt and the terminal record
|
|
20071
|
+
* (the 0.233.0 crash window). The record is the sweep's own — the same builder, the cursor seq
|
|
20072
|
+
* `next()` stamped on the delivery and the settlement instant, all read back from the node's
|
|
20073
|
+
* latest `reconciled` record — so a healed journal replays as one the sweep completed.
|
|
20074
|
+
*
|
|
20075
|
+
* The gate is fail-closed, every clause required, because the heal cannot re-ask the executor
|
|
20076
|
+
* to confirm teardown the way the sweep does:
|
|
20077
|
+
* - the latest `reconciled` record carries `settledSeq`, `reason`, `infra` and `trace` (a record
|
|
20078
|
+
* written before those fields existed names no cursor position and is not healed);
|
|
20079
|
+
* - at least one receipt sits after that record and every such receipt reads `destroyed: true`
|
|
20080
|
+
* (an empty set must not close the slot vacuously, and a receipt from an earlier process
|
|
20081
|
+
* belongs to an earlier settlement);
|
|
20082
|
+
* - the environment the latest admission names is among those receipts, so a receipt for an
|
|
20083
|
+
* environment the journal never admitted, or a re-admitted node whose receipt names the
|
|
20084
|
+
* earlier environment, is left open where the live sweep would have closed it.
|
|
20085
|
+
* A node with an `execution-result` is left to the recorded-result branch of
|
|
20086
|
+
* {@link prepareInterruptedExecutors}, which settles it from the durable blob and takes
|
|
20087
|
+
* precedence. The walk is over the whole forest because a nested manager settled on the ordinary
|
|
20088
|
+
* path is never restored, so a per-tree heal inside the resume of its tree would never reach its
|
|
20089
|
+
* grandchild. Returns the number of records written.
|
|
20090
|
+
*/
|
|
20091
|
+
async function healReleasedSlots(opts, signal, now) {
|
|
20092
|
+
const forest = await loadSpawnForest(opts.journal, opts.runId);
|
|
20093
|
+
let healed = 0;
|
|
20094
|
+
for (const tree of forest.trees) {
|
|
20095
|
+
signal.throwIfAborted();
|
|
20096
|
+
const events = tree.events;
|
|
20097
|
+
const closed = new Set(events.filter(closesCursorSlot).map((event) => event.id));
|
|
20098
|
+
const recorded = new Set(events.flatMap((event) => event.kind === "execution-result" ? [event.id] : []));
|
|
20099
|
+
for (const spawned of events) {
|
|
20100
|
+
if (spawned.kind !== "spawned" || spawned.parent === void 0) continue;
|
|
20101
|
+
if (closed.has(spawned.id) || recorded.has(spawned.id)) continue;
|
|
20102
|
+
const owned = events.filter((event) => event.id === spawned.id);
|
|
20103
|
+
const floor = owned.reduce((latest, event) => event.kind === "reconciled" && (latest === void 0 || event.seq > latest.seq) ? event : latest, void 0);
|
|
20104
|
+
if (floor?.settledSeq === void 0 || floor.reason === void 0 || floor.infra === void 0 || floor.trace === void 0) continue;
|
|
20105
|
+
const receipts = owned.slice(owned.indexOf(floor) + 1).filter((event) => event.kind === "environment-teardown");
|
|
20106
|
+
if (receipts.length === 0 || !receipts.every((receipt) => receipt.destroyed)) continue;
|
|
20107
|
+
const held = journaledEnvironmentId(owned);
|
|
20108
|
+
if (held === void 0 || !receipts.some((receipt) => receipt.environmentId === held)) continue;
|
|
20109
|
+
const settledSeq = floor.settledSeq;
|
|
20110
|
+
if (events.some((event) => closesCursorSlot(event) && event.seq === settledSeq)) throw new RuntimeRunStateError(`retained child '${spawned.id}' cannot be released at cursor seq ${settledSeq}: tree '${tree.root}' already closes that seq`);
|
|
20111
|
+
const subject = {
|
|
20112
|
+
id: spawned.id,
|
|
20113
|
+
spent: floor.spent,
|
|
20114
|
+
...floor.budgetViolation ? { budgetViolation: floor.budgetViolation } : {},
|
|
20115
|
+
...floor.cancellation ? { cancellationReason: floor.cancellation } : {}
|
|
20116
|
+
};
|
|
20117
|
+
const settlement = {
|
|
20118
|
+
kind: "down",
|
|
20119
|
+
reason: floor.reason,
|
|
20120
|
+
infra: floor.infra,
|
|
20121
|
+
trace: floor.trace,
|
|
20122
|
+
...floor.outRef ? { outRef: floor.outRef } : {},
|
|
20123
|
+
...floor.providerModel ? { providerModel: floor.providerModel } : {},
|
|
20124
|
+
...floor.harnessTranscript ? { harnessTranscript: floor.harnessTranscript } : {},
|
|
20125
|
+
...floor.retainedPendingCause ? { retainedPendingCause: floor.retainedPendingCause } : {}
|
|
20126
|
+
};
|
|
20127
|
+
await opts.journal.appendEvent(tree.root, terminalDownEvent(subject, settlement, settledSeq, floor.at, "released"));
|
|
20128
|
+
healed += 1;
|
|
20129
|
+
const materialized = owned.find((event) => event.kind === "materialized");
|
|
20130
|
+
const lastReceipt = receipts[receipts.length - 1];
|
|
20131
|
+
notifyRuntimeHookEvent(opts.hooks, {
|
|
20132
|
+
id: `${spawned.id}:released`,
|
|
20133
|
+
runId: tree.root,
|
|
20134
|
+
target: "agent.child",
|
|
20135
|
+
phase: "after",
|
|
20136
|
+
timestamp: now(),
|
|
20137
|
+
stepIndex: settledSeq,
|
|
20138
|
+
parentId: tree.ownerNodeId ?? opts.runId,
|
|
20139
|
+
payload: releasedChildPayload({
|
|
20140
|
+
...subject,
|
|
20141
|
+
runtime: materialized?.receipt.runtime ?? spawned.runtime,
|
|
20142
|
+
startedAt: Date.parse(spawned.at),
|
|
20143
|
+
...materialized === void 0 ? {} : { materialization: materialized.receipt },
|
|
20144
|
+
executionBindings: owned.flatMap((event) => event.kind === "execution-bound" ? [event.binding] : []),
|
|
20145
|
+
...floor.providerModel ? { providerModel: floor.providerModel } : {}
|
|
20146
|
+
}, settlement, Date.parse(floor.at), Date.parse(lastReceipt.at))
|
|
20147
|
+
}, { signal });
|
|
20148
|
+
}
|
|
20149
|
+
}
|
|
20150
|
+
return healed;
|
|
20151
|
+
}
|
|
19860
20152
|
/** Validate durable inputs without waiting for work that may need its resumed manager. */
|
|
19861
20153
|
async function prepareInterruptedExecutors(opts, events, signal, now, parentId = opts.runId) {
|
|
19862
20154
|
signal.throwIfAborted();
|
|
@@ -19929,7 +20221,7 @@ async function prepareInterruptedExecutors(opts, events, signal, now, parentId =
|
|
|
19929
20221
|
factory: prepared?.factory ?? opts.recoverExecutor
|
|
19930
20222
|
});
|
|
19931
20223
|
}
|
|
19932
|
-
let seq = events
|
|
20224
|
+
let seq = reservedCursorFloor(events) + 1;
|
|
19933
20225
|
for (const { result, fault, budgetViolation } of accepted) {
|
|
19934
20226
|
signal.throwIfAborted();
|
|
19935
20227
|
const failureReason = executorFailureReason(result);
|
|
@@ -20011,6 +20303,19 @@ function maxSeqOf(events, pred) {
|
|
|
20011
20303
|
for (const ev of events) if (pred(ev) && ev.seq > max) max = ev.seq;
|
|
20012
20304
|
return max;
|
|
20013
20305
|
}
|
|
20306
|
+
/**
|
|
20307
|
+
* The highest cursor seq any record in the journal already owns, closed OR reserved.
|
|
20308
|
+
*
|
|
20309
|
+
* A closed slot owns its seq outright. An open retained node owns the `settledSeq` its
|
|
20310
|
+
* `reconciled` record carries: that is the seq the driver already branched on, and the seq the
|
|
20311
|
+
* heal (or a later release sweep) writes the terminal record under. Every writer that mints a
|
|
20312
|
+
* new cursor seq in a resumed process — the recorded-result settlements below and the resumed
|
|
20313
|
+
* scope's own cursor — must start past BOTH, or a recovered result lands on a seq an open node
|
|
20314
|
+
* has reserved and the heal can only ever collide. One function so no writer can drift.
|
|
20315
|
+
*/
|
|
20316
|
+
function reservedCursorFloor(events) {
|
|
20317
|
+
return Math.max(maxSeqOf(events, closesCursorSlot), events.reduce((max, event) => event.kind === "reconciled" && event.settledSeq !== void 0 ? Math.max(max, event.settledSeq) : max, -1));
|
|
20318
|
+
}
|
|
20014
20319
|
/** Per-channel sum over a journaled event list: `settled` = spawned-child work (reconciled), plus
|
|
20015
20320
|
* the reconciled floor of every node still open, plus the declared ceiling of every open node
|
|
20016
20321
|
* nothing reconciled; `metered` = driver inference (re-homed up the tree, so a single root-tree
|
|
@@ -20060,6 +20365,7 @@ function sumMeasuredSpendFromEvents(events) {
|
|
|
20060
20365
|
}
|
|
20061
20366
|
/** Restore the same journal projection and accounting for root and nested scopes. @internal */
|
|
20062
20367
|
async function prepareScopeResume(opts, events, signal, now, parentId = opts.runId) {
|
|
20368
|
+
if (parentId === opts.runId && await healReleasedSlots(opts, signal, now) > 0) events = await opts.journal.loadTree(opts.runId) ?? events;
|
|
20063
20369
|
const prepared = await prepareInterruptedExecutors(opts, events, signal, now, parentId);
|
|
20064
20370
|
const prior = prepared.events;
|
|
20065
20371
|
const recovering = new Set(prepared.recoveries.map((item) => item.spawned.id));
|
|
@@ -20079,7 +20385,7 @@ async function prepareScopeResume(opts, events, signal, now, parentId = opts.run
|
|
|
20079
20385
|
settled,
|
|
20080
20386
|
view: materializeTreeView(prior),
|
|
20081
20387
|
maxSpawnOrdinal: maxSeqOf(prior, (event) => event.kind === "spawned"),
|
|
20082
|
-
maxCursorSeq:
|
|
20388
|
+
maxCursorSeq: reservedCursorFloor(prior),
|
|
20083
20389
|
maxWaitOrdinal: maxSeqOf(prior, (event) => event.kind === "waiting"),
|
|
20084
20390
|
waits: pendingWaits(prior),
|
|
20085
20391
|
keys: keyedAssignments(prior, settled),
|
|
@@ -21598,20 +21904,7 @@ function createScope(args) {
|
|
|
21598
21904
|
timestamp: releasedAt,
|
|
21599
21905
|
stepIndex: child.settledSeq,
|
|
21600
21906
|
parentId: args.parentId,
|
|
21601
|
-
payload:
|
|
21602
|
-
childId: child.id,
|
|
21603
|
-
status: "down",
|
|
21604
|
-
retainedExecution: "released",
|
|
21605
|
-
releasedAt,
|
|
21606
|
-
...child.resolved.outRef === void 0 ? {} : { outRef: child.resolved.outRef },
|
|
21607
|
-
reason: child.resolved.reason,
|
|
21608
|
-
infra: child.resolved.infra,
|
|
21609
|
-
spent: child.spent,
|
|
21610
|
-
...settledNodeEvidence(child, {
|
|
21611
|
-
...child.resolved,
|
|
21612
|
-
metered: void 0
|
|
21613
|
-
}, settledAt)
|
|
21614
|
-
}
|
|
21907
|
+
payload: releasedChildPayload(child, child.resolved, settledAt, releasedAt)
|
|
21615
21908
|
}, { signal: args.signal });
|
|
21616
21909
|
}
|
|
21617
21910
|
}
|
|
@@ -21897,14 +22190,18 @@ async function appendSettlementMetering(journal, root, id, spend, at) {
|
|
|
21897
22190
|
}
|
|
21898
22191
|
/** An open node's reconciled floor has the same per-child sequence discipline as its metering:
|
|
21899
22192
|
* outside the cursor namespace, monotonic per node, so a node reconciled once per process (a
|
|
21900
|
-
* retained failure, a recovery, a second retained failure) keeps its records ordered.
|
|
21901
|
-
|
|
21902
|
-
|
|
22193
|
+
* retained failure, a recovery, a second retained failure) keeps its records ordered. It carries
|
|
22194
|
+
* the whole settlement and the cursor seq (`settledSeq`) beside the floor, through the same
|
|
22195
|
+
* field spread the terminal record uses, so a resume that finds the release sweep died before
|
|
22196
|
+
* its record can write that record byte-for-byte instead of inventing one. */
|
|
22197
|
+
async function appendReconciledFloor(journal, root, subject, settlement, settledSeq, at) {
|
|
22198
|
+
const seq = await nextPerNodeSeq(journal, root, "reconciled", subject.id);
|
|
21903
22199
|
await appendAcknowledged(journal, root, {
|
|
21904
22200
|
kind: "reconciled",
|
|
21905
|
-
id,
|
|
21906
|
-
|
|
21907
|
-
...
|
|
22201
|
+
id: subject.id,
|
|
22202
|
+
...settlementFields(subject, settlement),
|
|
22203
|
+
...subject.cancellationReason === void 0 ? {} : { cancellation: { source: subject.cancellationReason.source } },
|
|
22204
|
+
settledSeq,
|
|
21908
22205
|
seq,
|
|
21909
22206
|
at
|
|
21910
22207
|
});
|
|
@@ -21953,9 +22250,18 @@ async function finalizeSettlement(child, settlement, seq, args, now) {
|
|
|
21953
22250
|
if (!retainedPending) await args.journal.appendEvent(args.root, terminalDownEvent(child, settlement, seq, at));
|
|
21954
22251
|
else {
|
|
21955
22252
|
child.retainedExecution = "pending";
|
|
21956
|
-
|
|
21957
|
-
|
|
21958
|
-
|
|
22253
|
+
child.retainedPendingCause = settlement.retainedPendingCause;
|
|
22254
|
+
if (settlement.reconciled !== void 0) await appendReconciledFloor(args.journal, args.root, {
|
|
22255
|
+
id: child.id,
|
|
22256
|
+
spent: settlement.reconciled,
|
|
22257
|
+
...child.retainedViolation === void 0 ? {} : { budgetViolation: child.retainedViolation },
|
|
22258
|
+
...child.cancellationReason === void 0 ? {} : { cancellationReason: child.cancellationReason }
|
|
22259
|
+
}, settlement, seq, at);
|
|
22260
|
+
}
|
|
22261
|
+
const retainedExecution = retainedPending ? {
|
|
22262
|
+
retainedExecution: "pending",
|
|
22263
|
+
...settlement.retainedPendingCause === void 0 ? {} : { retainedPendingCause: settlement.retainedPendingCause }
|
|
22264
|
+
} : {};
|
|
21959
22265
|
notifyRuntimeHookEvent(args.hooks, {
|
|
21960
22266
|
id: `${child.id}:settled`,
|
|
21961
22267
|
runId: args.root,
|
|
@@ -22042,56 +22348,6 @@ async function finalizeSettlement(child, settlement, seq, args, now) {
|
|
|
22042
22348
|
seq
|
|
22043
22349
|
};
|
|
22044
22350
|
}
|
|
22045
|
-
/**
|
|
22046
|
-
* The evidence a settled node carries beyond its status: the receipts that name what actually
|
|
22047
|
-
* ran, the own-inference spend the parent tree re-homes as a `metered` event, and the wall-clock
|
|
22048
|
-
* window. One builder feeds BOTH terminal paths, so an observer never sees a `down` node
|
|
22049
|
-
* described in different terms from a `done` one. Every field is omitted when the fact is
|
|
22050
|
-
* absent — an unreported receipt must not read as an empty one. Snapshots are detached because
|
|
22051
|
-
* an observer may serialize them after the live child has moved on.
|
|
22052
|
-
*/
|
|
22053
|
-
/** The one builder of a down child's terminal record, for both its writers: the settle path at
|
|
22054
|
-
* the reconcile and the release sweep closing a retained slot later. Two hand-written literals
|
|
22055
|
-
* for one record shape is how a field lands on one path and not the other (#1244 was exactly
|
|
22056
|
-
* that for `harnessTranscript`). `cancelled` keeps its `source` from the child's own
|
|
22057
|
-
* cancellation reason, so a released cancelled child records the same source it settled with. */
|
|
22058
|
-
function terminalDownEvent(child, settlement, seq, at, retainedExecution) {
|
|
22059
|
-
const cancellation = child.cancellationReason;
|
|
22060
|
-
return {
|
|
22061
|
-
...cancellation === void 0 ? {
|
|
22062
|
-
kind: "settled",
|
|
22063
|
-
status: "down"
|
|
22064
|
-
} : {
|
|
22065
|
-
kind: "cancelled",
|
|
22066
|
-
source: cancellation.source
|
|
22067
|
-
},
|
|
22068
|
-
id: child.id,
|
|
22069
|
-
spent: child.spent,
|
|
22070
|
-
infra: settlement.infra,
|
|
22071
|
-
reason: settlement.reason,
|
|
22072
|
-
...settlement.outRef ? { outRef: settlement.outRef } : {},
|
|
22073
|
-
...settlement.providerModel ? { providerModel: settlement.providerModel } : {},
|
|
22074
|
-
...child.budgetViolation ? { budgetViolation: child.budgetViolation } : {},
|
|
22075
|
-
trace: settlement.trace,
|
|
22076
|
-
...settlement.harnessTranscript ? { harnessTranscript: settlement.harnessTranscript } : {},
|
|
22077
|
-
...retainedExecution === void 0 ? {} : { retainedExecution },
|
|
22078
|
-
seq,
|
|
22079
|
-
at
|
|
22080
|
-
};
|
|
22081
|
-
}
|
|
22082
|
-
function settledNodeEvidence(child, settlement, settledAt) {
|
|
22083
|
-
return {
|
|
22084
|
-
runtime: child.runtime,
|
|
22085
|
-
startedAt: child.startedAt,
|
|
22086
|
-
settledAt,
|
|
22087
|
-
...settlement.metered ? { metered: detachedSnapshot(settlement.metered, "metered") } : {},
|
|
22088
|
-
...child.providerModel ? { providerModel: detachedSnapshot(child.providerModel, "provider model evidence") } : {},
|
|
22089
|
-
...child.materialization ? { materialization: detachedSnapshot(child.materialization, "materialization receipt") } : {},
|
|
22090
|
-
...child.executionBindings.length > 0 ? { executionBindings: detachedSnapshot([...child.executionBindings], "execution binding receipts") } : {},
|
|
22091
|
-
...child.budgetViolation ? { budgetViolation: detachedSnapshot(child.budgetViolation, "budget violation") } : {},
|
|
22092
|
-
trace: detachedSnapshot(settlement.trace, "worker trace evidence")
|
|
22093
|
-
};
|
|
22094
|
-
}
|
|
22095
22351
|
/** Journal a wait-state's settlement as a `woken` event and project it onto the same `Settled`
|
|
22096
22352
|
* the driver branches on. `by` names WHY it woke — `fired` / `timeout` / `cancelled` — which is
|
|
22097
22353
|
* the fact a resumed reader needs and cannot recover from a payload it may never fetch. */
|
|
@@ -22370,7 +22626,8 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
|
|
|
22370
22626
|
live.budgetViolation = void 0;
|
|
22371
22627
|
return {
|
|
22372
22628
|
...downRecord(errMessage(err), true, trace, executor.metered?.(), void 0, retainedOutputRef, await persistTranscriptOnce()),
|
|
22373
|
-
reconciled: live.spent
|
|
22629
|
+
reconciled: live.spent,
|
|
22630
|
+
retainedPendingCause: err instanceof RetainedExecutionPendingError ? err.pendingCause : "unobservable"
|
|
22374
22631
|
};
|
|
22375
22632
|
}
|
|
22376
22633
|
live.executorDone = true;
|
|
@@ -22462,7 +22719,8 @@ function makeTreeView(root, children) {
|
|
|
22462
22719
|
...c.trace ? { trace: c.trace } : {},
|
|
22463
22720
|
...c.providerModel ? { providerModel: c.providerModel } : {},
|
|
22464
22721
|
...c.budgetViolation ? { budgetViolation: c.budgetViolation } : {},
|
|
22465
|
-
...c.retainedExecution ? { retainedExecution: c.retainedExecution } : {}
|
|
22722
|
+
...c.retainedExecution ? { retainedExecution: c.retainedExecution } : {},
|
|
22723
|
+
...c.retainedPendingCause ? { retainedPendingCause: c.retainedPendingCause } : {}
|
|
22466
22724
|
}));
|
|
22467
22725
|
return {
|
|
22468
22726
|
root,
|
|
@@ -22843,8 +23101,8 @@ const driverExecutorFactory = (rawSpec, ctx) => {
|
|
|
22843
23101
|
const prior = await journal.loadTree(nestedRoot) ?? [];
|
|
22844
23102
|
if (prior.length === 0) await journal.appendEvent(nestedRoot, ownedSpawn);
|
|
22845
23103
|
else if (contentAddress(prior[0]) !== contentAddress(ownedSpawn)) throw new ValidationError$1("driverExecutor: nested recovery changed its owning parent spawn");
|
|
22846
|
-
else if (prior.length !== 1 && !recovering) throw new RetainedExecutionPendingError(new ValidationError$1("driverExecutor: interrupted nested execution requires recovery"));
|
|
22847
|
-
if (recovering && (!spec.recoverExecutor || !seam.restore)) throw new RetainedExecutionPendingError(new ValidationError$1("driverExecutor: nested recovery has no original executor reconstruction"));
|
|
23104
|
+
else if (prior.length !== 1 && !recovering) throw new RetainedExecutionPendingError(new ValidationError$1("driverExecutor: interrupted nested execution requires recovery"), "nested-recovery");
|
|
23105
|
+
if (recovering && (!spec.recoverExecutor || !seam.restore)) throw new RetainedExecutionPendingError(new ValidationError$1("driverExecutor: nested recovery has no original executor reconstruction"), "nested-recovery");
|
|
22848
23106
|
signal.throwIfAborted();
|
|
22849
23107
|
const controller = new AbortController();
|
|
22850
23108
|
const onParentAbort = () => controller.abort(signal.reason);
|
|
@@ -22856,7 +23114,7 @@ const driverExecutorFactory = (rawSpec, ctx) => {
|
|
|
22856
23114
|
} catch (error) {
|
|
22857
23115
|
controller.abort(error);
|
|
22858
23116
|
signal.removeEventListener("abort", onParentAbort);
|
|
22859
|
-
throw new RetainedExecutionPendingError(error);
|
|
23117
|
+
throw new RetainedExecutionPendingError(error, "nested-recovery");
|
|
22860
23118
|
}
|
|
22861
23119
|
active = {
|
|
22862
23120
|
controller,
|
|
@@ -22895,7 +23153,7 @@ const driverExecutorFactory = (rawSpec, ctx) => {
|
|
|
22895
23153
|
accounting = partial?.accounting;
|
|
22896
23154
|
const events = await journal.loadTree(nestedRoot).catch(() => void 0);
|
|
22897
23155
|
const settledIds = new Set(events?.filter((event) => event.kind === "settled" || event.kind === "cancelled").map((event) => event.id));
|
|
22898
|
-
if (events?.some((event) => event.kind === "execution-admitted" && event.id === seam.nodeId || event.kind === "spawned" && event.parent !== void 0 && event.runtime !== "inline" && !settledIds.has(event.id))) throw new RetainedExecutionPendingError(err);
|
|
23156
|
+
if (events?.some((event) => event.kind === "execution-admitted" && event.id === seam.nodeId || event.kind === "spawned" && event.parent !== void 0 && event.runtime !== "inline" && !settledIds.has(event.id))) throw new RetainedExecutionPendingError(err, "nested-recovery");
|
|
22899
23157
|
if (cleanupError !== void 0) throw cleanupError;
|
|
22900
23158
|
throw err;
|
|
22901
23159
|
} finally {
|
|
@@ -24306,4 +24564,4 @@ function isNonEmptySpend(s) {
|
|
|
24306
24564
|
//#endregion
|
|
24307
24565
|
export { bindReusableExecutorExecutionId as $, providerMessageText as $i, buildRuntimeEventOtelSpans as $n, providerAttemptEvidence as $r, addHarnessUsage as $t, waitUntil as A, deleteBoxSafe as Ai, RunCancellationReason as An, profileMaterializationAxes$1 as Ar, spendFromUsageTotals as At, attachWorker as B, withTimeout as Bi, defaultRedactorIdentityMaterial as Bn, worktreeCliProfileMaterialization as Br, createInbox as Bt, scopeOwnerExecutorNodeContext as C, notifySandboxEventObserver as Ci, resolveAgentEnvironmentProvider as Cn, parseCodexTokenUsage as Cr, workerTraceAnalysisStore as Ct, pollFor as D, addSpend as Di, sandboxSessionTraceSource as Dn, controlProfileMaterialization as Dr, meterUsageEvent as Dt, isWaitOutcome as E, sumSandboxUsage as Ei, decodeToolPart as En, assertProfileMaterialization as Er, createBudgetPool as Et, scopeRetainedOwnerPriorSpend as F, sleep as Fi, recoverRetainedRun as Fn, renderProfileMaterializationIssues as Fr, workerTraceSeamKey as Ft, recoverRetainedInteractiveRun as G, decodeHarnessUsage as Gi, contentAddress as Gn, attestRuntimeOwnedPendingExecutor as Gr, createPeerMailbox as Gt, workerInteractiveBindingFile as H, addResourceSpend as Hi, captureHarnessTranscript as Hn, parseCommittedJsonLines as Hr, DEFAULT_PEER_MAIL_LIMITS as Ht, scopeRetainedOwnerResult as I, stringifySafe as Ii, startRetainedRun as In, renderUnsupported as Ir, taskToPrompt as It, errMessage as J, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as Ji, readTraceContextFromEnv as Jn, finalizeRuntimeOwnedPendingExecutor as Jr, peerMailVerbNames as Jt, startRetainedInteractiveRun as K, abortError$2 as Ki, createPropagatingTraceEmitter as Kn, attestRuntimeOwnedScopeOwner as Kr, isPeerMailEnvelope as Kt, interactiveAdmissionSeamKey as L, throwAbort as Li, startRetainedRunInEnvironment as Ln, sandboxActProfileMaterialization as Lr, DEFAULT_STALL_AFTER_MS as Lt, consumeScopeRetainedOwnerResult as M, isAbortError$2 as Mi, linkAbort as Mn, promptModelProfileMaterialization as Mr, readWorkerTraceContext as Mt, prepareScopeRetainedOwnerTask as N, promptCacheTokenClasses as Ni, runAbortable as Nn, promptOnlyProfileMaterialization as Nr, workerTraceEnv as Nt, timerAt as O, chargedTokens as Oi, registerRetainedExecutorPreparation as On, defineProfileMaterializationContract as Or, newUsageTotals as Ot, scopeRetainedOwnerContext as P, randomSuffix as Pi, reconnectRetainedRun as Pn, promptResourceProfileMaterialization as Pr, workerTraceHeaders as Pt, rollingDispatch as Q, promptOptionsFromAgentTurnInput as Qi, buildLoopSpanNodes as Qn, newExecutionAttemptId as Qr, bridgeModelRouteRefusal as Qt, readWorkerInteractiveAdmissions as R, throwIfAborted as Ri, retainedCreateMaterial as Rn, unsupportedProfileDimensions as Rr, createActivityLog as Rt, restoreScopeOwnerAcceptedExecution as S, mapSandboxToolEvent as Si, providerAsSandboxClient as Sn, localHarnessExecutable as Sr, parseWorkerToolTraceArtifact as St, createWaitProbes as T, sandboxProgressEvents as Ti, createPushTraceSource as Tn, AGENT_PROFILE_MATERIALIZATION_AXES as Tr, assertValidBudget as Tt, workerInteractiveBindingsDir as U, resourceTelemetry as Ui, harnessTranscriptArtifact as Un, prepareJsonlAppend as Ur, PEER_MAIL_WIRE_KEY as Ut, readWorkerInteractiveBinding as V, zeroSpend as Vi, resolveRedactor as Vn, isNoEntError as Vr, AUTHORITY_MARKERS as Vt, reconnectRetainedInteractiveRun as W, withBudgetResources as Wi, persistHarnessTranscript as Wn, writeAllBytes as Wr, claimsAuthority as Wt, freeSlots as X, teardownExecutor as Xi, INTELLIGENCE_WIRE_VERSION as Xn, knownExecutionBindingReceipt as Xr, isTerminalNodeStatus as Xt, effectiveConcurrency as Y, armDeadlineTimer as Yi, traceContextToEnv as Yn, inheritRuntimeOwnedExecutorAttestation as Yr, isLiveNodeStatus as Yt, queueOf as Z, promptFromAgentTurnInput as Zi, buildLoopOtelSpans as Zn, knownMaterializationReceipt as Zr, bridgeAdmissionRefusal as Zt, createScope as _, createSandboxToolPartState as _i, canonicalObservedModelParts as _n, createWorktree as _r, pendingWaits as _t, pickBestDelivered as a, runtimeOwnedPendingExecutorMaterialization as ai, TERMINAL_DECISIONS as an, loopEventToOtelSpan as ar, snapshotExecutorConfig as at, meterRuntimeOwnedProviderAttempt as b, isSandboxTerminalEvent as bi, createAgentEnvironmentProviderRegistry as bn, LOCAL_HARNESSES as br, captureWorkerTraceEvidence as bt, DriverAttemptsExhaustedError as c, unknownMaterializationReceipt as ci, isTerminalDecision as cn, toOtelAttributes as cr, createSteerableSandboxSession as ct, runDriverWithRetry as d, detachedFrozen as di, probeSandboxCapabilities as dn, sanitizeAgentRuntimeEvent as dr, FileSpawnJournal as dt, recordRuntimeOwnedDriveHarnessProviderEvidence as ei, createCodexRolloutStoreReader as en, createOpenInferenceFileExporter as er, captureReusableExecutorConfig as et, driverChild as f, detachedSnapshot as fi, acquireSandbox as fn, sanitizeKnowledgeReadinessReport as fr, InMemoryResultBlobStore as ft, beginScopeOwnerAttempt as g, canonicalStreamEventFromSandboxEvent as gi, runBrainLoop as gn, captureWorktreeDiff as gr, materializeTreeView as gt, withDriverExecutor as h, assertSandboxServedModel as hi, routerBrain as hn, runWorktreeHarness as hr, loadSpawnForest as ht, collectDelivered as i, runtimeOwnedExecutorProviderEvidence as ii, bridgeStopSignalKey as in, generateSpanId as ir, createExecutorRegistry as it, bindScopeRetainedOwnerProvider as j, hasCompleteCacheBreakdown as ji, abortError as jn, promptControlProfileMaterialization as jr, WORKER_TRACE_PROPAGATION as jt, validateWaitSpec as k, cloneSpend as ki, retainedExecutorSeamKey as kn, fullProfileMaterialization as kr, spendFromUsageEvents as kt, classifyDriverFailure as l, executableAgentProfileSnapshot as li, runAgentRounds as ln, createRuntimeEventCollector as lr, createInPlaceCliExecutor as lt, isDriverSpec as m, readSandboxOutcome as mi, readPromptOptions as mn, runSettledCommand as mr, insideCursorNamespace as mt, createSupervisor as n, runtimeOwnedExecutorExecutionBinding as ni, readCodexRolloutSession as nn, exportEvalRuns as nr, cliWorktreeExecutor as nt, runFinalizer as o, runtimeOwnedScopeOwnerRuntime as oi, createSandboxForSpec as on, padSpanId as or, createWorktreeCliExecutor as ot, driverExecutorFactory as p, projectSandboxOutcome as pi, assertBoxlessPromptOptions as pn, sanitizeRuntimeStreamEvent as pr, InMemorySpawnJournal as pt, destroyInteractiveEnvironment as q, awaitAbortable$1 as qi, mergeTraceEnv as qn, authoredProfileDigest as qr, peerMailTools as qt, bestDelivered as r, runtimeOwnedExecutorMaterialization as ri, bridgeRuntimeAttachmentsKey as rn, flatOtelSpan as rr, createExecutor as rt, runTree as s, unknownExecutionBindingReceipt as si, defaultSelectWinner as sn, padTraceId as sr, DEFAULT_SANDBOX_STEERING_MAX_TURNS as st, createRootHandle as t, runtimeOwnedDriveHarnessProviderEvidence as ti, harnessUsageIsEmpty as tn, createOtelExporter as tr, cliInPlaceExecutor as tt, defaultUnmetContractSteer as u, executableAgentSpecSnapshot as ui, createSandboxLineage as un, createRuntimeStreamEventCollector as ur, FileResultBlobStore as ut, deriveNodeExecutionIdentity as v, createSandboxUsageLedger as vi, observedModelMatchesDeclared as vn, removeWorktree as vr, replaySpawnTree as vt, settledToIteration as w, sandboxEventServedBackend as wi, sandboxClientAsProvider as wn, CodexExecutionDiagnosticError as wr, BudgetReconcileFault as wt, recordScopeOwnerMaterialization as x, mapSandboxEvent as xi, providerAsExecutor as xn, harnessSupportsReasoningEffort as xr, isTraceAnalysisStore as xt, meterRuntimeOwnedAccounting as y, extractLlmCallEvent as yi, DEFAULT_SANDBOX_IDLE_TIMEOUT_SECONDS as yn, DEFAULT_LOCAL_HARNESS as yr, WORKER_TOOL_TRACE_SCHEMA_VERSION as yt, workerInteractiveAdmissionFile as z, unmeteredSpend as zi, defaultRedactor as zn, validateProfileMaterialization as zr, readWorkerProgress as zt };
|
|
24308
24566
|
|
|
24309
|
-
//# sourceMappingURL=supervisor-
|
|
24567
|
+
//# sourceMappingURL=supervisor-CBtuIoqP.js.map
|