@tangle-network/agent-runtime 0.319.7 → 0.319.10
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-CcfUmnAe.js → activation-BKglRwjB.js} +2 -2
- package/dist/{activation-CcfUmnAe.js.map → activation-BKglRwjB.js.map} +1 -1
- package/dist/agent.js +2 -2
- package/dist/{coordination-driver-Dim6ig4M.js → coordination-driver-CE01_us_.js} +2 -2
- package/dist/{coordination-driver-Dim6ig4M.js.map → coordination-driver-CE01_us_.js.map} +1 -1
- package/dist/{delegate-STDZnzjY.js → delegate-BptW384t.js} +2 -2
- package/dist/{delegate-STDZnzjY.js.map → delegate-BptW384t.js.map} +1 -1
- package/dist/durable.js +2 -2
- package/dist/{graph-Df65qgYK.js → graph-Bkcora6P.js} +4 -4
- package/dist/{graph-Df65qgYK.js.map → graph-Bkcora6P.js.map} +1 -1
- package/dist/{improvement-cycle-Bb5kkUi6.js → improvement-cycle-0cnwWPFY.js} +3 -3
- package/dist/{improvement-cycle-Bb5kkUi6.js.map → improvement-cycle-0cnwWPFY.js.map} +1 -1
- package/dist/index.js +7 -7
- package/dist/intelligence.js +3 -3
- package/dist/kernel.js +8 -8
- package/dist/{loop-runner-bin-BaGWLMYN.js → loop-runner-bin-DRw76sWb.js} +3 -3
- package/dist/{loop-runner-bin-BaGWLMYN.js.map → loop-runner-bin-DRw76sWb.js.map} +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.js +4 -4
- package/dist/{provision-supervisor-CS_Negf6.js → provision-supervisor-Bs698TqJ.js} +3 -3
- package/dist/{provision-supervisor-CS_Negf6.js.map → provision-supervisor-Bs698TqJ.js.map} +1 -1
- package/dist/{runtime-HY1z-MOb.js → runtime-SioKh3r_.js} +8 -8
- package/dist/{runtime-HY1z-MOb.js.map → runtime-SioKh3r_.js.map} +1 -1
- package/dist/{search-executor-OIy7kg74.js → search-executor-DjKdQluM.js} +2 -2
- package/dist/{search-executor-OIy7kg74.js.map → search-executor-DjKdQluM.js.map} +1 -1
- package/dist/{server-BMG_Uted.js → server-BfEwCD55.js} +3 -3
- package/dist/{server-BMG_Uted.js.map → server-BfEwCD55.js.map} +1 -1
- package/dist/{supervise-CDn-1ThW.js → supervise-Bj8U345y.js} +4 -4
- package/dist/{supervise-CDn-1ThW.js.map → supervise-Bj8U345y.js.map} +1 -1
- package/dist/{supervisor-B_mWdKva.js → supervisor-CCtmmmOz.js} +179 -68
- package/dist/supervisor-CCtmmmOz.js.map +1 -0
- package/dist/testing.js +12 -12
- package/dist/tui/index.js +1 -1
- package/package.json +1 -1
- package/dist/supervisor-B_mWdKva.js.map +0 -1
|
@@ -7428,6 +7428,42 @@ async function captureProviderLiveWorkspace(port, context, parent) {
|
|
|
7428
7428
|
clearDeadline();
|
|
7429
7429
|
}
|
|
7430
7430
|
}
|
|
7431
|
+
/** @internal Construct the same exact receipt for a live capture and evidence-only recovery. */
|
|
7432
|
+
function workspaceCaptureReceipt(context, captured) {
|
|
7433
|
+
const { snapshot, provenance, coverageComplete = false, incompleteReason } = captured;
|
|
7434
|
+
return {
|
|
7435
|
+
executionId: context.executionId,
|
|
7436
|
+
...context.controlRef === void 0 ? {} : { controlRef: context.controlRef },
|
|
7437
|
+
...context.node === void 0 ? {} : { node: context.node },
|
|
7438
|
+
environmentId: context.environment.id,
|
|
7439
|
+
profileDigest: canonicalAgentProfileDigest(context.profile),
|
|
7440
|
+
...capturedSessionIdentity(provenance, coverageComplete, context.executionId, context.providerSessionId ?? null),
|
|
7441
|
+
snapshot,
|
|
7442
|
+
provenance,
|
|
7443
|
+
coverageComplete,
|
|
7444
|
+
...incompleteReason === void 0 ? {} : { incompleteReason }
|
|
7445
|
+
};
|
|
7446
|
+
}
|
|
7447
|
+
/** Only a verified, single-session capture may supply a scalar session identity. */
|
|
7448
|
+
function capturedSessionIdentity(provenance, coverageComplete, executionId, providerSessionId) {
|
|
7449
|
+
const unknown = {
|
|
7450
|
+
providerSessionId,
|
|
7451
|
+
nativeSessionId: null
|
|
7452
|
+
};
|
|
7453
|
+
if (!coverageComplete || provenance?.status !== "reported" || provenance.executionId !== executionId || provenance.sessions?.length !== 1) return unknown;
|
|
7454
|
+
const session = provenance.sessions[0];
|
|
7455
|
+
if (session.executionId !== executionId || providerSessionId !== null && session.id !== providerSessionId) return unknown;
|
|
7456
|
+
const ids = new Set((provenance.attempts ?? []).filter((attempt) => session.executionIds?.includes(attempt.executionId)).flatMap((attempt) => attempt.nativeSessionIds));
|
|
7457
|
+
const nativeSessionId = ids.size === 1 ? [...ids][0] : null;
|
|
7458
|
+
if (session.nativeSessionId != null && nativeSessionId !== session.nativeSessionId) return {
|
|
7459
|
+
providerSessionId,
|
|
7460
|
+
nativeSessionId: null
|
|
7461
|
+
};
|
|
7462
|
+
return {
|
|
7463
|
+
providerSessionId,
|
|
7464
|
+
nativeSessionId
|
|
7465
|
+
};
|
|
7466
|
+
}
|
|
7431
7467
|
/** Validate the executable retention port at the create boundary. */
|
|
7432
7468
|
function assertProviderWorkspaceRetentionPort(port, context) {
|
|
7433
7469
|
if (!Number.isSafeInteger(port.timeoutMs) || port.timeoutMs <= 0) throw new ValidationError$1(`${context}: workspaceRetention.timeoutMs must be a positive safe integer`);
|
|
@@ -11272,6 +11308,13 @@ function classifyRetainedPendingCause(cause, phase = "execution") {
|
|
|
11272
11308
|
}
|
|
11273
11309
|
return "unobservable";
|
|
11274
11310
|
}
|
|
11311
|
+
/** @internal Evidence recovery failed; the accepted turn stands and a root pursuit stays open. */
|
|
11312
|
+
var RetainedWorkspaceCapturePendingError = class extends Error {
|
|
11313
|
+
constructor(executionId, cause) {
|
|
11314
|
+
super(`retained workspace capture pending for ${executionId}; source environment preserved: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
11315
|
+
this.name = "RetainedWorkspaceCapturePendingError";
|
|
11316
|
+
}
|
|
11317
|
+
};
|
|
11275
11318
|
/**
|
|
11276
11319
|
* Local observation stopped; the retained provider execution has no accepted terminal result.
|
|
11277
11320
|
*
|
|
@@ -11670,26 +11713,6 @@ function providerAsSandboxClient(provider, options = {}) {
|
|
|
11670
11713
|
});
|
|
11671
11714
|
} };
|
|
11672
11715
|
}
|
|
11673
|
-
/** Only a verified, single-session capture may supply a scalar session identity. */
|
|
11674
|
-
function capturedSessionIdentity(provenance, coverageComplete, executionId, providerSessionId) {
|
|
11675
|
-
const unknown = {
|
|
11676
|
-
providerSessionId,
|
|
11677
|
-
nativeSessionId: null
|
|
11678
|
-
};
|
|
11679
|
-
if (!coverageComplete || provenance?.status !== "reported" || provenance.executionId !== executionId || provenance.sessions?.length !== 1) return unknown;
|
|
11680
|
-
const session = provenance.sessions[0];
|
|
11681
|
-
if (session.executionId !== executionId || providerSessionId !== null && session.id !== providerSessionId) return unknown;
|
|
11682
|
-
const ids = new Set((provenance.attempts ?? []).filter((attempt) => session.executionIds?.includes(attempt.executionId)).flatMap((attempt) => attempt.nativeSessionIds));
|
|
11683
|
-
const nativeSessionId = ids.size === 1 ? [...ids][0] : null;
|
|
11684
|
-
if (session.nativeSessionId != null && nativeSessionId !== session.nativeSessionId) return {
|
|
11685
|
-
providerSessionId,
|
|
11686
|
-
nativeSessionId: null
|
|
11687
|
-
};
|
|
11688
|
-
return {
|
|
11689
|
-
providerSessionId,
|
|
11690
|
-
nativeSessionId
|
|
11691
|
-
};
|
|
11692
|
-
}
|
|
11693
11716
|
/**
|
|
11694
11717
|
* Lower the seam's prompt options onto turn fields, through the one mapper this module already
|
|
11695
11718
|
* uses to raise a sandbox prompt into a provider turn. Reusing it is what keeps the two directions
|
|
@@ -12497,24 +12520,24 @@ function admittedEnvironmentId(retention) {
|
|
|
12497
12520
|
}
|
|
12498
12521
|
}
|
|
12499
12522
|
function providerWorkspaceCaptureReceipt(args, environment, snapshot, fallbackSessionId) {
|
|
12500
|
-
const provenance = args.workspaceProvenance();
|
|
12501
12523
|
const coverage = args.workspaceCoverage();
|
|
12502
12524
|
const controlRef = args.workspaceControlRef();
|
|
12503
|
-
return {
|
|
12525
|
+
return workspaceCaptureReceipt({
|
|
12504
12526
|
executionId: args.executionId,
|
|
12505
12527
|
...controlRef === void 0 ? {} : { controlRef },
|
|
12506
12528
|
...args.node === void 0 ? {} : { node: args.node },
|
|
12507
|
-
|
|
12508
|
-
|
|
12509
|
-
|
|
12529
|
+
environment,
|
|
12530
|
+
profile: args.profile,
|
|
12531
|
+
providerSessionId: controlRef?.sessionId ?? fallbackSessionId
|
|
12532
|
+
}, {
|
|
12510
12533
|
snapshot,
|
|
12511
|
-
provenance:
|
|
12534
|
+
provenance: args.workspaceProvenance() ?? {
|
|
12512
12535
|
status: "unavailable",
|
|
12513
12536
|
missing: ["Capture coverage metadata was not retained"]
|
|
12514
12537
|
},
|
|
12515
12538
|
coverageComplete: coverage.complete,
|
|
12516
12539
|
...coverage.incompleteReason === void 0 ? {} : { incompleteReason: coverage.incompleteReason }
|
|
12517
|
-
};
|
|
12540
|
+
});
|
|
12518
12541
|
}
|
|
12519
12542
|
async function* streamProviderExecutor(args) {
|
|
12520
12543
|
const started = Date.now();
|
|
@@ -12561,8 +12584,12 @@ async function* streamProviderExecutor(args) {
|
|
|
12561
12584
|
let unavailable;
|
|
12562
12585
|
let finalCopyTaken = false;
|
|
12563
12586
|
const ownerTakesCapture = () => args.options.workspaceRetention?.captureNative !== void 0 && args.createProfile.harness !== void 0 && source.retained && args.retention?.preserveEnvironment === true && args.retention.onEndOfTurnWork !== void 0;
|
|
12564
|
-
const handCaptureToOwner = (reported, captureOutcome, publish) => {
|
|
12565
|
-
args.retention?.onEndOfTurnWork?.(
|
|
12587
|
+
const handCaptureToOwner = (reported, captureOutcome, publish, beforeCapture) => {
|
|
12588
|
+
args.retention?.onEndOfTurnWork?.((async () => {
|
|
12589
|
+
try {
|
|
12590
|
+
await beforeCapture?.();
|
|
12591
|
+
} catch {}
|
|
12592
|
+
const snapshot = await args.captureWorkspace(environment, captureOutcome);
|
|
12566
12593
|
if (publish) args.onPublishedSnapshot(snapshot);
|
|
12567
12594
|
if (snapshot === void 0) return;
|
|
12568
12595
|
await args.retention?.onEvidence?.({
|
|
@@ -12570,7 +12597,7 @@ async function* streamProviderExecutor(args) {
|
|
|
12570
12597
|
workspaceSnapshot: snapshot,
|
|
12571
12598
|
workspaceCapture: providerWorkspaceCaptureReceipt(args, environment, snapshot, turn.sessionId ?? null)
|
|
12572
12599
|
});
|
|
12573
|
-
}
|
|
12600
|
+
})().catch(() => void 0));
|
|
12574
12601
|
};
|
|
12575
12602
|
let harnessStop;
|
|
12576
12603
|
const stopEndedHarness = () => {
|
|
@@ -12698,9 +12725,8 @@ async function* streamProviderExecutor(args) {
|
|
|
12698
12725
|
args.onPending(false);
|
|
12699
12726
|
args.onArtifact(settled);
|
|
12700
12727
|
if (deferCapture) {
|
|
12701
|
-
await args.finishNativeMirror(environment, "settled");
|
|
12702
12728
|
finalCopyTaken = true;
|
|
12703
|
-
handCaptureToOwner(settledResult, outcome, true);
|
|
12729
|
+
handCaptureToOwner(settledResult, outcome, true, () => args.finishNativeMirror(environment, "settled"));
|
|
12704
12730
|
}
|
|
12705
12731
|
} catch (error) {
|
|
12706
12732
|
yield* creditUsage(usageLedger.settleTurn(args.profile.name ?? "agent"));
|
|
@@ -13329,18 +13355,14 @@ function environmentAsSandboxInstance(environment, options) {
|
|
|
13329
13355
|
providerSessionId,
|
|
13330
13356
|
nativeSessionId: null,
|
|
13331
13357
|
profile: identity.profile
|
|
13332
|
-
}).then((
|
|
13358
|
+
}).then((captured) => workspaceCaptureReceipt({
|
|
13359
|
+
environment,
|
|
13333
13360
|
executionId: identity.executionId,
|
|
13334
13361
|
...controlRef === void 0 ? {} : { controlRef },
|
|
13335
13362
|
...identity.node === void 0 ? {} : { node: identity.node },
|
|
13336
|
-
|
|
13337
|
-
|
|
13338
|
-
|
|
13339
|
-
snapshot,
|
|
13340
|
-
provenance,
|
|
13341
|
-
coverageComplete: coverageComplete ?? false,
|
|
13342
|
-
...incompleteReason === void 0 ? {} : { incompleteReason }
|
|
13343
|
-
}));
|
|
13363
|
+
profile: identity.profile,
|
|
13364
|
+
providerSessionId
|
|
13365
|
+
}, captured));
|
|
13344
13366
|
const receipt = await capture;
|
|
13345
13367
|
publication ??= Promise.resolve().then(async () => {
|
|
13346
13368
|
await options.onWorkspaceCaptured?.(receipt);
|
|
@@ -24887,6 +24909,7 @@ async function prepareScopeRetainedOwnerSeatSwitch(scope, mode) {
|
|
|
24887
24909
|
if (!state?.acceptedRef || !state.acceptedConsumed) throw new ValidationError$1("seat switch requires a committed owner turn");
|
|
24888
24910
|
const accepted = state.acceptedRef;
|
|
24889
24911
|
await scopeRetainedOwnerTurnEnded(scope);
|
|
24912
|
+
await reconcileOwnerWorkspaceBeforeReuse(state, scope.signal);
|
|
24890
24913
|
await state.checkpointing;
|
|
24891
24914
|
await checkpointOwnerWorkspace(scope, state);
|
|
24892
24915
|
const owned = (await state.args.journal.loadTree(state.args.rootId) ?? []).filter((event) => event.id === state.args.nodeId);
|
|
@@ -25487,7 +25510,7 @@ async function releaseOwnerEnvironment(state, provider, capturesMs) {
|
|
|
25487
25510
|
const pendingSources = new Set(requestFailures.map(({ event }) => event.environmentId));
|
|
25488
25511
|
const released = new Set(events.flatMap((event) => event.kind === "environment-teardown" && event.id === args.nodeId && event.provider === provider.name && event.destroyed ? [event.environmentId] : []));
|
|
25489
25512
|
const environments = new Set(events.flatMap((event) => event.id === args.nodeId && event.kind === "execution-admitted" && event.admission.phase === "environment" ? [event.admission.environmentId] : []));
|
|
25490
|
-
const retentionFailures = state.workspaceRetention || events.some((event) => event.kind === "execution-input" && event.id === args.nodeId && event.workspaceRetention === true) ? await ownerWorkspaceRetentionFailures(events, args
|
|
25513
|
+
const retentionFailures = state.workspaceRetention || events.some((event) => event.kind === "execution-input" && event.id === args.nodeId && event.workspaceRetention === true) ? await ownerWorkspaceRetentionFailures(events, args) : /* @__PURE__ */ new Set();
|
|
25491
25514
|
const unconfirmed = [];
|
|
25492
25515
|
const preserved = [];
|
|
25493
25516
|
let lastDetail;
|
|
@@ -25638,23 +25661,17 @@ function unsettledOwnerRuns(events, nodeId, environmentId) {
|
|
|
25638
25661
|
close();
|
|
25639
25662
|
return [...runs.values()];
|
|
25640
25663
|
}
|
|
25641
|
-
/**
|
|
25642
|
-
|
|
25643
|
-
*
|
|
25644
|
-
* The receipt is the attempt's committed result, or an evidence record of the same attempt: a
|
|
25645
|
-
* turn its manager stopped commits its result first and journals its capture as evidence after
|
|
25646
|
-
* it, and a turn that failed journals the capture it took of the stopped session. This runs only
|
|
25647
|
-
* at a release no process will resume, so a complete, verified capture of the exact execution is
|
|
25648
|
-
* the whole of what keeping the source would preserve.
|
|
25649
|
-
*/
|
|
25650
|
-
async function ownerWorkspaceRetentionFailures(events, nodeId, blobs) {
|
|
25664
|
+
/** One grouping for release and the evidence gate before another owner invocation. */
|
|
25665
|
+
function ownerWorkspaceAttempts(events, nodeId) {
|
|
25651
25666
|
const attempts = [];
|
|
25652
25667
|
let current;
|
|
25653
25668
|
const flush = () => {
|
|
25654
25669
|
if (current !== void 0) attempts.push(current);
|
|
25655
25670
|
current = void 0;
|
|
25656
25671
|
};
|
|
25657
|
-
const fresh = (executionId) => ({
|
|
25672
|
+
const fresh = (executionId, workspaceRetention) => ({
|
|
25673
|
+
workspaceRetention,
|
|
25674
|
+
admissions: [],
|
|
25658
25675
|
...executionId === void 0 ? {} : { executionId },
|
|
25659
25676
|
environmentIds: /* @__PURE__ */ new Set(),
|
|
25660
25677
|
controlByEnvironment: /* @__PURE__ */ new Map(),
|
|
@@ -25664,18 +25681,37 @@ async function ownerWorkspaceRetentionFailures(events, nodeId, blobs) {
|
|
|
25664
25681
|
if (!("id" in event) || event.id !== nodeId) continue;
|
|
25665
25682
|
if (event.kind === "execution-input") {
|
|
25666
25683
|
flush();
|
|
25667
|
-
current = fresh(`${nodeId}:input:${event.seq}
|
|
25684
|
+
current = fresh(`${nodeId}:input:${event.seq}`, event.workspaceRetention);
|
|
25668
25685
|
} else if (event.kind === "execution-admitted" && event.admission.phase === "environment") {
|
|
25669
25686
|
if (current?.result !== void 0) flush();
|
|
25670
25687
|
current ??= fresh();
|
|
25671
25688
|
current.environmentIds.add(event.admission.environmentId);
|
|
25672
|
-
|
|
25673
|
-
else if (event.kind === "execution-
|
|
25689
|
+
current.admissions.push(event.admission);
|
|
25690
|
+
} else if (event.kind === "execution-admitted" && event.admission.phase === "dispatched") {
|
|
25691
|
+
current?.admissions.push(event.admission);
|
|
25692
|
+
current?.controlByEnvironment.set(event.admission.controlRef.environmentId, event.admission.controlRef);
|
|
25693
|
+
} else if (event.kind === "execution-admitted") current?.admissions.push(event.admission);
|
|
25694
|
+
else if (event.kind === "execution-bound") {
|
|
25695
|
+
if (current !== void 0 && current.result === void 0) current.binding = event.binding;
|
|
25696
|
+
} else if (event.kind === "execution-result") {
|
|
25674
25697
|
current ??= fresh();
|
|
25675
25698
|
current.result = event;
|
|
25676
25699
|
} else if (event.kind === "execution-evidence") current?.evidence.push(event);
|
|
25677
25700
|
}
|
|
25678
25701
|
flush();
|
|
25702
|
+
return attempts;
|
|
25703
|
+
}
|
|
25704
|
+
/**
|
|
25705
|
+
* Group owner admissions by input and require a verified workspace receipt before deletion.
|
|
25706
|
+
*
|
|
25707
|
+
* The receipt is the attempt's committed result, or an evidence record of the same attempt: a
|
|
25708
|
+
* turn its manager stopped commits its result first and journals its capture as evidence after
|
|
25709
|
+
* it, and a turn that failed journals the capture it took of the stopped session. A root capture
|
|
25710
|
+
* failure can enter this cleanup barrier and still be resumed, so any receipt refused before
|
|
25711
|
+
* reuse must also preserve its source here.
|
|
25712
|
+
*/
|
|
25713
|
+
async function ownerWorkspaceRetentionFailures(events, owner) {
|
|
25714
|
+
const attempts = ownerWorkspaceAttempts(events, owner.nodeId);
|
|
25679
25715
|
const failures = /* @__PURE__ */ new Set();
|
|
25680
25716
|
for (const attempt of attempts) {
|
|
25681
25717
|
if (attempt.environmentIds.size === 0) continue;
|
|
@@ -25684,19 +25720,87 @@ async function ownerWorkspaceRetentionFailures(events, nodeId, blobs) {
|
|
|
25684
25720
|
continue;
|
|
25685
25721
|
}
|
|
25686
25722
|
const environmentId = [...attempt.environmentIds][0];
|
|
25687
|
-
|
|
25688
|
-
|
|
25689
|
-
|
|
25690
|
-
|
|
25691
|
-
|
|
25692
|
-
|
|
25693
|
-
|
|
25694
|
-
|
|
25723
|
+
if (!await ownerAttemptHasCapture(attempt, environmentId, owner.blobs, attempt.workspaceRetention === true ? owner : void 0)) failures.add(environmentId);
|
|
25724
|
+
}
|
|
25725
|
+
return failures;
|
|
25726
|
+
}
|
|
25727
|
+
async function ownerAttemptHasCapture(attempt, environmentId, blobs, owner) {
|
|
25728
|
+
const controlRef = attempt.controlByEnvironment.get(environmentId);
|
|
25729
|
+
const receipts = [...attempt.result === void 0 ? [] : [attempt.result.outRef], ...attempt.evidence.map((event) => event.outRef)];
|
|
25730
|
+
let verified = false;
|
|
25731
|
+
for (const outRef of receipts) {
|
|
25732
|
+
const output = await storedOutput(blobs, outRef);
|
|
25733
|
+
if (hasDurableWorkspaceCapture(output, output !== null && typeof output === "object" ? output.workspaceSnapshot : void 0, environmentId, attempt.executionId, controlRef, owner === void 0 ? void 0 : ownerCaptureIdentity(attempt, owner))) {
|
|
25734
|
+
verified = true;
|
|
25735
|
+
break;
|
|
25736
|
+
}
|
|
25737
|
+
}
|
|
25738
|
+
return verified;
|
|
25739
|
+
}
|
|
25740
|
+
function ownerCaptureIdentity(attempt, owner) {
|
|
25741
|
+
const intent = attempt.admissions.find((admission) => admission.phase === "intent");
|
|
25742
|
+
const node = attempt.binding === void 0 ? void 0 : {
|
|
25743
|
+
rootId: owner.executionRootId ?? owner.rootId,
|
|
25744
|
+
parentId: owner.nodeId,
|
|
25745
|
+
nodeId: owner.nodeId,
|
|
25746
|
+
...owner.depth === void 0 ? {} : { depth: owner.depth },
|
|
25747
|
+
attemptId: attempt.binding.attemptId
|
|
25748
|
+
};
|
|
25749
|
+
return {
|
|
25750
|
+
profileDigest: intent?.requestedProfileDigest,
|
|
25751
|
+
node
|
|
25752
|
+
};
|
|
25753
|
+
}
|
|
25754
|
+
/** Recover evidence only, before a later turn or checkpoint can change the accepted workspace. */
|
|
25755
|
+
async function reconcileOwnerWorkspaceBeforeReuse(state, signal) {
|
|
25756
|
+
const { args } = state;
|
|
25757
|
+
const events = await args.journal.loadTree(args.rootId) ?? [];
|
|
25758
|
+
const attempts = ownerWorkspaceAttempts(events, args.nodeId);
|
|
25759
|
+
const latest = attempts.at(-1);
|
|
25760
|
+
const unusable = unusableEnvironmentIds(events.filter((event) => event.id === args.nodeId));
|
|
25761
|
+
if (latest === void 0) return;
|
|
25762
|
+
const reusing = new Set(latest.environmentIds);
|
|
25763
|
+
if (latest.result === void 0 && state.priorSession !== void 0) reusing.add(state.priorSession.environmentId);
|
|
25764
|
+
for (const [index, attempt] of attempts.entries()) {
|
|
25765
|
+
if (attempt.workspaceRetention !== true || attempt.result === void 0) continue;
|
|
25766
|
+
for (const environmentId of attempt.environmentIds) {
|
|
25767
|
+
if (!reusing.has(environmentId) || unusable.has(environmentId)) continue;
|
|
25768
|
+
if (await ownerAttemptHasCapture(attempt, environmentId, args.blobs, args)) continue;
|
|
25769
|
+
try {
|
|
25770
|
+
if (attempt.environmentIds.size !== 1 || attempt.executionId === void 0) throw new Error("accepted workspace has ambiguous admission identity");
|
|
25771
|
+
if (index < attempts.length - 1) throw new Error("a later invocation already admitted this environment; historical workspace cannot be recaptured");
|
|
25772
|
+
const capture = state.checkpointCapture;
|
|
25773
|
+
const provider = state.provider;
|
|
25774
|
+
const intent = attempt.admissions.find((admission) => admission.phase === "intent");
|
|
25775
|
+
const admission = attempt.admissions.find((admission) => admission.phase === "environment");
|
|
25776
|
+
const dispatched = attempt.admissions.find((admission) => admission.phase === "dispatched");
|
|
25777
|
+
if (capture === void 0 || provider?.get === void 0 || intent?.phase !== "intent" || admission?.phase !== "environment" || dispatched?.phase !== "dispatched") throw new Error("accepted workspace recovery requires its retention port and exact admissions");
|
|
25778
|
+
const controlRef = dispatched.controlRef;
|
|
25779
|
+
if (provider.name !== intent.provider || admission.provider !== intent.provider || controlRef.provider !== intent.provider || admission.environmentId !== controlRef.environmentId || admission.sessionId !== controlRef.sessionId || admission.executionId !== controlRef.executionId || admission.idempotencyKey !== intent.idempotencyKey || dispatched.idempotencyKey !== intent.idempotencyKey || admission.sessionId !== intent.sessionId || admission.executionId !== intent.executionId || admission.turnId !== intent.turnId || dispatched.turnId !== intent.turnId || canonicalAgentProfileDigest(capture.profile) !== intent.requestedProfileDigest) throw new Error("accepted workspace recovery does not match its original profile or admission");
|
|
25780
|
+
const environment = await runAbortable(() => provider.get(environmentId), AbortSignal.any([signal, AbortSignal.timeout(Math.min(3e4, capture.port.timeoutMs))]), "accepted workspace source lookup timed out");
|
|
25781
|
+
if (environment === null || environment.id !== environmentId || environment.provider !== provider.name) throw new Error("accepted workspace source is unavailable");
|
|
25782
|
+
const identity = ownerCaptureIdentity(attempt, args);
|
|
25783
|
+
const context = {
|
|
25784
|
+
environment,
|
|
25785
|
+
executionId: attempt.executionId,
|
|
25786
|
+
controlRef,
|
|
25787
|
+
providerSessionId: controlRef.sessionId,
|
|
25788
|
+
nativeSessionId: null,
|
|
25789
|
+
profile: capture.profile,
|
|
25790
|
+
...identity.node === void 0 ? {} : { node: identity.node }
|
|
25791
|
+
};
|
|
25792
|
+
const captured = await runAbortable(() => captureProviderWorkspaceSnapshot(capture.port, context), signal, "accepted workspace capture aborted");
|
|
25793
|
+
const output = {
|
|
25794
|
+
workspaceSnapshot: captured.snapshot,
|
|
25795
|
+
workspaceCapture: workspaceCaptureReceipt(context, captured)
|
|
25796
|
+
};
|
|
25797
|
+
if (!hasDurableWorkspaceCapture(output, captured.snapshot, environmentId, attempt.executionId, controlRef, identity)) throw new Error(captured.incompleteReason ?? "accepted workspace capture is incomplete");
|
|
25798
|
+
await state.context.onEvidence(output);
|
|
25799
|
+
} catch (cause) {
|
|
25800
|
+
throw new RetainedWorkspaceCapturePendingError(attempt.executionId ?? args.nodeId, cause);
|
|
25695
25801
|
}
|
|
25696
25802
|
}
|
|
25697
|
-
if (!verified) failures.add(environmentId);
|
|
25698
25803
|
}
|
|
25699
|
-
return failures;
|
|
25700
25804
|
}
|
|
25701
25805
|
/** A stored output whose bytes match its content reference, or undefined. */
|
|
25702
25806
|
async function storedOutput(blobs, outRef) {
|
|
@@ -25708,13 +25812,14 @@ async function storedOutput(blobs, outRef) {
|
|
|
25708
25812
|
}
|
|
25709
25813
|
}
|
|
25710
25814
|
/** A stored result authorizes cleanup only for the exact source and complete capture. */
|
|
25711
|
-
function hasDurableWorkspaceCapture(output, snapshot, environmentId, executionId, controlRef) {
|
|
25815
|
+
function hasDurableWorkspaceCapture(output, snapshot, environmentId, executionId, controlRef, identity) {
|
|
25712
25816
|
const parsed = agentCandidateWorkspaceSnapshotEvidenceSchema.safeParse(snapshot);
|
|
25713
25817
|
if (!parsed.success || !("locator" in parsed.data.manifest) || !("locator" in parsed.data.archive)) return false;
|
|
25714
25818
|
if (output === null || typeof output !== "object") return false;
|
|
25715
25819
|
const capture = output.workspaceCapture;
|
|
25716
25820
|
if (capture === null || typeof capture !== "object") return false;
|
|
25717
25821
|
const receipt = capture;
|
|
25822
|
+
if (identity !== void 0 && (identity.profileDigest === void 0 || receipt.profileDigest !== identity.profileDigest || (identity.node === void 0 ? receipt.node !== void 0 : receipt.node === void 0 || contentAddress(receipt.node) !== contentAddress(identity.node)))) return false;
|
|
25718
25823
|
const capturedControl = AgentExactRunControlRefSchema.safeParse(receipt.controlRef);
|
|
25719
25824
|
if (executionId === void 0 || controlRef === void 0 || !capturedControl.success || !sameControlCoordinates(capturedControl.data, controlRef) || receipt.environmentId !== environmentId || receipt.executionId !== executionId || receipt.coverageComplete !== true) return false;
|
|
25720
25825
|
const linked = agentCandidateWorkspaceSnapshotEvidenceSchema.safeParse(receipt.snapshot);
|
|
@@ -25835,6 +25940,7 @@ async function prepareScopeRetainedOwnerTask(scope, task) {
|
|
|
25835
25940
|
const accepted = [...attempt].reverse().find((event) => event.kind === "execution-result");
|
|
25836
25941
|
if (accepted?.kind === "execution-result") state.acceptedRef = accepted;
|
|
25837
25942
|
}
|
|
25943
|
+
if (state.taskRef !== void 0 && state.acceptedRef === void 0) await reconcileOwnerWorkspaceBeforeReuse(state, scope.signal);
|
|
25838
25944
|
const unusable = unusableEnvironmentIds(owned);
|
|
25839
25945
|
const inFlight = continuedEnvironment(owned);
|
|
25840
25946
|
if (inFlight?.inFlight && unusable.has(inFlight.admission.environmentId)) {
|
|
@@ -25849,6 +25955,7 @@ async function prepareScopeRetainedOwnerTask(scope, task) {
|
|
|
25849
25955
|
state.admissions.length = 0;
|
|
25850
25956
|
}
|
|
25851
25957
|
if (state.prepared && state.acceptedRef && state.acceptedConsumed) {
|
|
25958
|
+
await reconcileOwnerWorkspaceBeforeReuse(state, scope.signal);
|
|
25852
25959
|
const currentEnvironment = [...state.admissions].reverse().find((admission) => admission.phase === "environment");
|
|
25853
25960
|
if (currentEnvironment?.phase === "environment") state.priorSession = currentEnvironment;
|
|
25854
25961
|
delete state.inputSequence;
|
|
@@ -27536,7 +27643,9 @@ function createScope(args) {
|
|
|
27536
27643
|
});
|
|
27537
27644
|
registerScopeRetainedOwner(scope, {
|
|
27538
27645
|
rootId: args.root,
|
|
27646
|
+
executionRootId: args.ownerMaterialization?.journalRoot ?? args.root,
|
|
27539
27647
|
nodeId: args.parentId,
|
|
27648
|
+
depth: args.depth,
|
|
27540
27649
|
journal: args.journal,
|
|
27541
27650
|
blobs: args.blobs,
|
|
27542
27651
|
priorEvents: args.resumeFrom?.events ?? [],
|
|
@@ -29554,6 +29663,7 @@ async function runDriverWithRetry(run) {
|
|
|
29554
29663
|
try {
|
|
29555
29664
|
await run.drive(attempt, reentry);
|
|
29556
29665
|
} catch (error) {
|
|
29666
|
+
if (error instanceof RetainedWorkspaceCapturePendingError) throw error;
|
|
29557
29667
|
const durationMs = now() - startedAt;
|
|
29558
29668
|
const classification = classifyDriverFailure(error, run.signal);
|
|
29559
29669
|
const after = run.progress();
|
|
@@ -30411,6 +30521,7 @@ function createSupervisor() {
|
|
|
30411
30521
|
const tree = runTree(scope);
|
|
30412
30522
|
const leakedReservations = pool.openReservations();
|
|
30413
30523
|
if (controller.signal.reason instanceof RunCancellationReason) return noWinner();
|
|
30524
|
+
if (!actOutcome.ok && actOutcome.error instanceof RetainedWorkspaceCapturePendingError) throw actOutcome.error;
|
|
30414
30525
|
if (actOutcome.ok) {
|
|
30415
30526
|
if (executionAborted) return noWinner();
|
|
30416
30527
|
const out = actOutcome.out;
|
|
@@ -30900,4 +31011,4 @@ function isNonEmptySpend(s) {
|
|
|
30900
31011
|
//#endregion
|
|
30901
31012
|
export { environmentReader as $, runtimeOwnedScopeOwnerRuntime as $i, parseWorkerToolTraceArtifact as $n, loopEventToOtelSpan as $r, PEER_MAIL_WIRE_KEY as $t, scopeOwnerExecutorNodeContext as A, promptOnlyProfileMaterialization as Ai, resolveAgentEnvironmentProvider as An, resolveHarnessTranscriptCapture as Ar, captureReusableExecutorConfig as At, consumeScopeRetainedOwnerResult as B, authoredProfileDigest as Bi, InMemoryResultBlobStore as Bn, mergeTraceEnv as Br, createInPlaceCliExecutor as Bt, deriveNodeExecutionIdentity as C, promptFromAgentTurnInput as Ca, assertProfileMaterializes as Ci, readPromptOptions as Cn, abortError as Cr, createContinuationKeeper as Ct, recordScopeOwnerMaterialization as D, profileMaterializationAxes$1 as Di, createAgentEnvironmentProviderRegistry as Dn, harnessTranscriptArtifact as Dr, passedItems as Dt, recordScopeOwnerDriverAttempt as E, fullProfileMaterialization as Ei, LEAF_CONTINUATION_TASK as En, captureHarnessTranscript as Er, failedItems as Et, seatExecutionProfile as F, unsupportedProfileDimensions as Fi, retainedExecutorSeamKey as Fn, runCodeMode as Fr, snapshotExecutorConfig as Ft, scopeRetainedOwnerContext as G, newExecutionAttemptId as Gi, replaySpawnTree as Gn, resolveRedactor as Gr, workerTraceSeamKey as Gt, prepareScopeRetainedOwnerSeatSwitch as H, inheritRuntimeOwnedExecutorAttestation as Hi, insideCursorNamespace as Hn, traceContextToEnv as Hr, readWorkerTraceContext as Ht, abandonScopeRetainedOwnerInvocation as I, validateProfileMaterialization as Ii, unavailablePauseMs as In, priceTokens as Ir, createWorktreeCliExecutor as It, scopeRetainedOwnerResourceReader as J, runtimeOwnedDriveHarnessProviderEvidence as Ji, readCommittedJsonLines as Jn, buildRuntimeEventOtelSpans as Jr, createActivityLog as Jt, scopeRetainedOwnerJournalRoot as K, providerAttemptEvidence as Ki, isNoEntError as Kn, buildLoopOtelSpans as Kr, taskToPrompt as Kt, beginScopeRetainedOwnerDrive as L, worktreeCliProfileMaterialization as Li, unavailableSignalOfFailure as Ln, routerTokenPrice as Lr, DEFAULT_SANDBOX_STEERING_MAX_TURNS as Lt, SeatChain as M, renderProfileMaterializationIssues as Mi, decodeToolPart as Mn, contentAddress as Mr, cliWorktreeExecutor as Mt, SeatChainExhaustedError as N, renderUnsupported as Ni, sandboxSessionTraceSource as Nn, createCodeModeTools as Nr, createExecutor as Nt, recordScopeOwnerPause as O, promptControlProfileMaterialization as Oi, providerAsExecutor as On, persistHarnessTranscript as Or, verdictFromJudgeScore as Ot, authoredSeatStages as P, sandboxActProfileMaterialization as Pi, registerRetainedExecutorPreparation as Pn, describeCodeModeTools as Pr, createExecutorRegistry as Pt, SPAWN_RESOURCE_PATH_MAX_BYTES as Q, runtimeOwnedPendingExecutorMaterialization as Qi, isTraceAnalysisStore as Qn, generateSpanId as Qr, DEFAULT_PEER_MAIL_LIMITS as Qt, bindScopeRetainedOwnerEnvironmentId as R, attestRuntimeOwnedPendingExecutor as Ri, FileResultBlobStore as Rn, ROUTER_PRICE_SOURCE as Rr, createSteerableSandboxSession as Rt, createScope as S, awaitAbortable$1 as Sa, assertProfileMaterialization as Si, assertBoxlessPromptOptions as Sn, RunCancellationReason as Sr, checkVerdictOf as St, meterRuntimeOwnedProviderAttempt as T, providerMessageText as Ta, defineProfileMaterializationContract as Ti, runBrainLoop as Tn, runAbortable as Tr, expandQuestions as Tt, prepareScopeRetainedOwnerTask as U, knownExecutionBindingReceipt as Ui, loadSpawnForest as Un, defaultRedactor as Ur, workerTraceEnv as Ut, noteScopeRetainedOwnerCoordination as V, finalizeRuntimeOwnedPendingExecutor as Vi, InMemorySpawnJournal as Vn, readTraceContextFromEnv as Vr, WORKER_TRACE_PROPAGATION as Vt, reconcileScopeRetainedOwnerEnvironment as W, knownMaterializationReceipt as Wi, materializeTreeView as Wn, defaultRedactorIdentityMaterial as Wr, workerTraceHeaders as Wt, scopeRetainedOwnerResult as X, runtimeOwnedExecutorMaterialization as Xi, WORKER_TOOL_TRACE_SCHEMA_VERSION as Xn, createOtelExporter as Xr, createInbox as Xt, scopeRetainedOwnerRestorePoint as Y, runtimeOwnedExecutorExecutionBinding as Yi, writeAllBytes as Yn, createOpenInferenceFileExporter as Yr, readWorkerProgress as Yt, scopeRetainedOwnerTurnEnded as Z, runtimeOwnedExecutorProviderEvidence as Zi, captureWorkerTraceEvidence as Zn, flatOtelSpan as Zr, AUTHORITY_MARKERS as Zt, isDriverSpec as _, sandboxEventServedBackend as _a, localHarnessExecutable as _i, runAgentRounds as _n, retainedCreateMaterial as _r, CONTINUATION_FACTS as _t, collectDelivered as a, detachedSnapshot as aa, sanitizeAgentRuntimeEvent as ai, isLiveNodeStatus as an, createBudgetPool as ar, interactiveAdmissionSeamKey as at, assertRecursiveReservationPolicy as b, decodeHarnessUsage as ba, terminateProcessTreeAndConfirm as bi, SandboxEvidenceRetentionError as bn, createWorkerSlots as br, admitFinding as bt, runTree as c, assertSandboxServedModel as ca, runSettledCommand as ci, bridgeModelRouteRefusal as cn, spendFromUsageEvents as cr, reconnectRetainedInteractiveRun as ct, classifyDriverFailure as d, createSandboxUsageLedger as da, createWorktree as di, harnessUsageIsEmpty as dn, bridgeStopSignalKey as dr, freeSlots as dt, unknownExecutionBindingReceipt as ea, padSpanId as ei, claimsAuthority as en, workerTraceAnalysisStore as er, hostDirectoryReader as et, runDriverWithRetry as f, extractLlmCallEvent as fa, removeWorktree as fi, readCodexRolloutSession as fn, errMessage as fr, queueOf as ft, driverExecutorFactory as g, notifySandboxEventObserver as ga, harnessSupportsReasoningEffort as gi, isTerminalDecision as gn, startRetainedRunInEnvironment as gr, CONTINUATIONS_DIR as gt, driverChild as h, mapSandboxToolEvent as ha, harnessInvocation as hi, defaultSelectWinner as hn, startRetainedRun as hr, mapExecutorResult as ht, bestDelivered as i, detachedFrozen as ia, createRuntimeStreamEventCollector as ii, peerMailVerbNames as in, assertValidBudget as ir, providerVisibleProfile as it, settledToIteration as j, promptResourceProfileMaterialization as ji, createPushTraceSource as jn, retainHarnessTranscript as jr, cliInPlaceExecutor as jt, restoreScopeOwnerAcceptedExecution as k, promptModelProfileMaterialization as ki, providerAsSandboxClient as kn, readHarnessTranscript as kr, bindReusableExecutorExecutionId as kt, DriverAttemptsExhaustedError as l, canonicalStreamEventFromSandboxEvent as la, runWorktreeHarness as li, addHarnessUsage as ln, spendFromUsageTotals as lr, recoverRetainedInteractiveRun as lt, upstreamUnavailableSignal as m, mapSandboxEvent as ma, LOCAL_HARNESSES as mi, createSandboxForSpec as mn, recoverRetainedRun as mr, gateOnDeliverable as mt, createRootHandle as n, executableAgentProfileSnapshot as na, toOtelAttributes as ni, isPeerMailEnvelope as nn, BudgetReconcileFault as nr, coordinationMcpAlias as nt, pickBestDelivered as o, projectSandboxOutcome as oa, sanitizeKnowledgeReadinessReport as oi, isTerminalNodeStatus as on, meterUsageEvent as or, attachWorker as ot, summarizeDriverAttempts as p, isSandboxTerminalEvent as pa, DEFAULT_LOCAL_HARNESS as pi, TERMINAL_DECISIONS as pn, reconnectRetainedRun as pr, rollingDispatch as pt, scopeRetainedOwnerPriorSpend as q, recordRuntimeOwnedDriveHarnessProviderEvidence as qi, prepareJsonlAppend as qn, buildLoopSpanNodes as qr, DEFAULT_STALL_AFTER_MS as qt, createSupervisor as r, executableAgentSpecSnapshot as ra, createRuntimeEventCollector as ri, peerMailTools as rn, ReservationWaitRefused as rr, coordinationProfileToolPrefix as rt, runFinalizer as s, readSandboxOutcome as sa, sanitizeRuntimeStreamEvent as si, bridgeAdmissionRefusal as sn, newUsageTotals as sr, readWorkerInteractiveBinding as st, DEFAULT_MAX_DEPTH as t, unknownMaterializationReceipt as ta, padTraceId as ti, createPeerMailbox as tn, executorFailure as tr, resolveSpawnResourcePaths as tt, HarnessTurnFailedError as u, createSandboxToolPartState as ua, captureWorktreeDiff as ui, createCodexRolloutStoreReader as un, bridgeRuntimeAttachmentsKey as ur, startRetainedInteractiveRun as ut, withDriverExecutor as v, sandboxProgressEvents as va, parseCodexTokenUsage as vi, createSandboxLineage as vn, destroyInteractiveEnvironment as vr, CheckUnavailableError as vt, meterRuntimeOwnedAccounting as w, promptOptionsFromAgentTurnInput as wa, controlProfileMaterialization as wi, routerBrain as wn, linkAbort as wr, distillFindings as wt, beginScopeOwnerAttempt as x, abortError$1 as xa, AGENT_PROFILE_MATERIALIZATION_AXES as xi, captureBeforeDestroy as xn, openSlotGroup as xr, bestComposite as xt, SUBTREE_RESULT_LIMIT as y, sumSandboxUsage as ya, CodexExecutionDiagnosticError as yi, acquireSandbox as yn, environmentGone as yr, admitContinuationPolicy as yt, bindScopeRetainedOwnerProvider as z, attestRuntimeOwnedScopeOwner as zi, FileSpawnJournal as zn, createPropagatingTraceEmitter as zr, createRouterTranscript as zt };
|
|
30902
31013
|
|
|
30903
|
-
//# sourceMappingURL=supervisor-
|
|
31014
|
+
//# sourceMappingURL=supervisor-CCtmmmOz.js.map
|