@tangle-network/agent-runtime 0.283.0 → 0.284.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-DL1VoNrT.d.ts → activation-CxiJixSO.d.ts} +2 -2
- package/dist/{activation-B_vuAOSo.js → activation-DXFzDCmr.js} +2 -2
- package/dist/{activation-B_vuAOSo.js.map → activation-DXFzDCmr.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/candidate-execution/index.d.ts +2 -38
- package/dist/{coordination-driver-BmkANXc5.js → coordination-driver-BJzVI1oV.js} +2 -2
- package/dist/{coordination-driver-BmkANXc5.js.map → coordination-driver-BJzVI1oV.js.map} +1 -1
- package/dist/{delegate-BfHKdHzV.js → delegate-CfoEXPam.js} +2 -2
- package/dist/{delegate-BfHKdHzV.js.map → delegate-CfoEXPam.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +2 -2
- package/dist/{graph-XmlRTlaI.js → graph-RCV6ri8A.js} +4 -4
- package/dist/{graph-XmlRTlaI.js.map → graph-RCV6ri8A.js.map} +1 -1
- package/dist/{improvement-cycle-BFerq3l4.js → improvement-cycle-DxBnEP8q.js} +3 -3
- package/dist/{improvement-cycle-BFerq3l4.js.map → improvement-cycle-DxBnEP8q.js.map} +1 -1
- package/dist/{index-CkLB8mJF.d.ts → index-BmGVkjsc.d.ts} +66 -5
- package/dist/index.d.ts +13 -6
- package/dist/index.js +51 -9
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +4 -4
- package/dist/intelligence.js +4 -4
- package/dist/kernel.d.ts +3 -3
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-D8P3T5rT.js → loop-runner-bin-BPy7y5rd.js} +3 -3
- package/dist/{loop-runner-bin-D8P3T5rT.js.map → loop-runner-bin-BPy7y5rd.js.map} +1 -1
- package/dist/{loop-runner-bin-CINywrHK.d.ts → loop-runner-bin-CqwbQ0et.d.ts} +2 -2
- 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 +2 -2
- package/dist/mcp/index.js +4 -4
- package/dist/{protected-model-port-BlLP8ja6.d.ts → protected-model-port-DDnU39ul.d.ts} +2 -2
- package/dist/{provision-supervisor-BNUmrHwC.js → provision-supervisor-CqRp0Rzo.js} +3 -3
- package/dist/{provision-supervisor-BNUmrHwC.js.map → provision-supervisor-CqRp0Rzo.js.map} +1 -1
- package/dist/{runtime-CM3KCe9V.js → runtime-lin_kRwN.js} +102 -10
- package/dist/runtime-lin_kRwN.js.map +1 -0
- package/dist/{search-method-Dlor0kKQ.js → search-method-Hjmqa4B8.js} +2 -2
- package/dist/{search-method-Dlor0kKQ.js.map → search-method-Hjmqa4B8.js.map} +1 -1
- package/dist/{server-BnMcTE7J.js → server-a2wdjRG1.js} +3 -3
- package/dist/{server-BnMcTE7J.js.map → server-a2wdjRG1.js.map} +1 -1
- package/dist/{stream-agent-turn-Bk79CnTw.d.ts → stream-agent-turn-IIqBKeLB.d.ts} +149 -5
- package/dist/{supervise-DL_Hj1uk.js → supervise-C71s4_OJ.js} +3 -3
- package/dist/{supervise-DL_Hj1uk.js.map → supervise-C71s4_OJ.js.map} +1 -1
- package/dist/{supervisor-YAc4U8HQ.js → supervisor-D4NnNHZd.js} +470 -70
- package/dist/supervisor-D4NnNHZd.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-CuXu5zuS.d.ts → workspace-archive-DpyZV2Cj.d.ts} +38 -2
- package/package.json +5 -4
- package/skills/profile-authoring/SKILL.md +1 -1
- package/dist/runtime-CM3KCe9V.js.map +0 -1
- package/dist/supervisor-YAc4U8HQ.js.map +0 -1
|
@@ -6746,14 +6746,45 @@ async function captureProviderWorkspaceSnapshot(port, context) {
|
|
|
6746
6746
|
...context,
|
|
6747
6747
|
signal: controller.signal
|
|
6748
6748
|
}), "provider workspace retention snapshot");
|
|
6749
|
-
|
|
6750
|
-
const
|
|
6749
|
+
const snapshot = "snapshot" in result ? result.snapshot : result;
|
|
6750
|
+
const provenance = "snapshot" in result ? detachedSnapshot(result.provenance, "provider workspace retention provenance") : {
|
|
6751
|
+
status: "unavailable",
|
|
6752
|
+
missing: ["Capture callback returned no coverage metadata"]
|
|
6753
|
+
};
|
|
6754
|
+
if (!Array.isArray(provenance.missing) || !["reported", "unavailable"].includes(provenance.status)) throw new Error("provider workspace retention provenance is malformed");
|
|
6755
|
+
if (provenance.status === "reported" && provenance.environmentId !== context.environment.id) throw new Error("provider workspace retention provenance names another environment");
|
|
6756
|
+
if (provenance.executionId !== void 0 && provenance.executionId !== context.executionId) throw new Error("provider workspace retention provenance names another execution");
|
|
6757
|
+
const coverageGaps = [...provenance.missing];
|
|
6758
|
+
if (provenance.status !== "reported") coverageGaps.push("Coverage metadata unavailable");
|
|
6759
|
+
if (provenance.executionId !== context.executionId) coverageGaps.push("Exact execution identity missing");
|
|
6760
|
+
if (provenance.workspace?.complete !== true) coverageGaps.push("Workspace inventory incomplete");
|
|
6761
|
+
if (provenance.sessions === void 0) coverageGaps.push("Session inventory missing");
|
|
6762
|
+
if (context.providerSessionId != null && !provenance.sessions?.some((session) => session.id === context.providerSessionId && session.executionId === context.executionId)) coverageGaps.push(`Provider session ${context.providerSessionId} missing from capture`);
|
|
6763
|
+
for (const session of provenance.sessions ?? []) {
|
|
6764
|
+
if (session.executionId !== context.executionId) coverageGaps.push(`Session ${session.id} names another execution`);
|
|
6765
|
+
if (session.transportEvents !== "complete") coverageGaps.push(`Session ${session.id} transport events unavailable`);
|
|
6766
|
+
if (session.backendType !== context.profile.harness) coverageGaps.push(`Session ${session.id} harness identity mismatch`);
|
|
6767
|
+
if (session.nativeStore?.complete !== true || session.nativeStore.inventory?.skippedEntries !== 0) coverageGaps.push(`Session ${session.id} native store incomplete`);
|
|
6768
|
+
if (session.processStreams?.complete !== true) coverageGaps.push(`Session ${session.id} process streams incomplete`);
|
|
6769
|
+
if (session.nativeEvents?.complete !== true) coverageGaps.push(`Session ${session.id} native events incomplete`);
|
|
6770
|
+
if (!/^sha256:[0-9a-f]{64}$/.test(session.sidecarImageDigest ?? "")) coverageGaps.push(`Session ${session.id} sidecar image digest missing`);
|
|
6771
|
+
if (!/^[0-9a-f]{40}$/.test(session.sidecarBundleRevision ?? "")) coverageGaps.push(`Session ${session.id} sidecar bundle revision missing`);
|
|
6772
|
+
}
|
|
6773
|
+
const coverageComplete = coverageGaps.length === 0;
|
|
6774
|
+
requireDurableWorkspaceArtifacts(snapshot);
|
|
6775
|
+
const { archive } = await verifyWorkspaceSnapshotArtifacts(snapshot, port.artifacts);
|
|
6751
6776
|
await verifyAgentCandidateWorkspaceArchive({
|
|
6752
6777
|
role: "candidate",
|
|
6753
|
-
snapshot
|
|
6754
|
-
archive
|
|
6778
|
+
snapshot,
|
|
6779
|
+
archive,
|
|
6780
|
+
...port.limits === void 0 ? {} : { limits: port.limits }
|
|
6755
6781
|
});
|
|
6756
|
-
return
|
|
6782
|
+
return {
|
|
6783
|
+
snapshot,
|
|
6784
|
+
provenance,
|
|
6785
|
+
coverageComplete,
|
|
6786
|
+
...coverageComplete ? {} : { incompleteReason: `provider workspace retention coverage incomplete: ${coverageGaps.join("; ")}` }
|
|
6787
|
+
};
|
|
6757
6788
|
}, controller.signal, `provider workspace retention timed out after ${port.timeoutMs}ms`);
|
|
6758
6789
|
} finally {
|
|
6759
6790
|
clearDeadline();
|
|
@@ -8349,6 +8380,10 @@ function resolveAgentEnvironmentProvider(provider, registry) {
|
|
|
8349
8380
|
/** Adapt a neutral environment provider to the `SandboxClient` interface used by existing loop paths.
|
|
8350
8381
|
* @experimental */
|
|
8351
8382
|
function providerAsSandboxClient(provider, options = {}) {
|
|
8383
|
+
if (options.workspaceRetention !== void 0) {
|
|
8384
|
+
assertProviderWorkspaceRetentionPort(options.workspaceRetention, `providerAsSandboxClient(${provider.name})`);
|
|
8385
|
+
if (options.retentionIdentity === void 0) throw new ValidationError("providerAsSandboxClient: retentionIdentity is required with workspaceRetention");
|
|
8386
|
+
}
|
|
8352
8387
|
return { async create(createOptions) {
|
|
8353
8388
|
const defaults = options.defaults ?? {};
|
|
8354
8389
|
const sandboxInput = createInputFromSandboxOptions(createOptions);
|
|
@@ -8376,10 +8411,15 @@ function providerAsSandboxClient(provider, options = {}) {
|
|
|
8376
8411
|
}
|
|
8377
8412
|
const environment = await provider.create(mapped);
|
|
8378
8413
|
if (options.requireSession && !environment.session) {
|
|
8379
|
-
await environment.destroy?.();
|
|
8414
|
+
if (options.workspaceRetention === void 0) await environment.destroy?.();
|
|
8380
8415
|
throw new ValidationError(`providerAsSandboxClient(${provider.name}): session() is required`);
|
|
8381
8416
|
}
|
|
8382
|
-
return environmentAsSandboxInstance(environment, {
|
|
8417
|
+
return environmentAsSandboxInstance(environment, {
|
|
8418
|
+
requireTerminalEvent: options.requireTerminalEvent ?? true,
|
|
8419
|
+
...options.workspaceRetention === void 0 ? {} : { workspaceRetention: options.workspaceRetention },
|
|
8420
|
+
...options.retentionIdentity === void 0 ? {} : { retentionIdentity: options.retentionIdentity },
|
|
8421
|
+
...options.onWorkspaceCaptured === void 0 ? {} : { onWorkspaceCaptured: options.onWorkspaceCaptured }
|
|
8422
|
+
});
|
|
8383
8423
|
} };
|
|
8384
8424
|
}
|
|
8385
8425
|
/**
|
|
@@ -8537,6 +8577,9 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
8537
8577
|
let destroyed = false;
|
|
8538
8578
|
let workspaceEnvironmentId;
|
|
8539
8579
|
let workspaceSnapshot;
|
|
8580
|
+
let workspaceProvenance;
|
|
8581
|
+
let workspaceCoverageComplete = false;
|
|
8582
|
+
let workspaceIncompleteReason;
|
|
8540
8583
|
let workspacePublishedSnapshot;
|
|
8541
8584
|
let workspaceCaptureFailure;
|
|
8542
8585
|
let workspaceCapturePromise;
|
|
@@ -8546,6 +8589,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
8546
8589
|
let workspaceOutcome;
|
|
8547
8590
|
let workspacePreservationRequired = false;
|
|
8548
8591
|
let workspaceRunActive = false;
|
|
8592
|
+
let providerSessionId = null;
|
|
8549
8593
|
const runtime = options.runtime ?? provider.name;
|
|
8550
8594
|
const createProfile = options.profileForCreate?.(profile) ?? profile;
|
|
8551
8595
|
if (placement && canonicalAgentProfileDigest(createProfile) !== canonicalAgentProfileDigest(profile)) throw new ValidationError("provider placement: profileForCreate cannot change the selected profile");
|
|
@@ -8554,6 +8598,9 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
8554
8598
|
if (workspaceEnvironmentId === next.id) return;
|
|
8555
8599
|
workspaceEnvironmentId = next.id;
|
|
8556
8600
|
workspaceSnapshot = void 0;
|
|
8601
|
+
workspaceProvenance = void 0;
|
|
8602
|
+
workspaceCoverageComplete = false;
|
|
8603
|
+
workspaceIncompleteReason = void 0;
|
|
8557
8604
|
workspacePublishedSnapshot = void 0;
|
|
8558
8605
|
workspaceCaptureFailure = void 0;
|
|
8559
8606
|
workspaceCapturePromise = void 0;
|
|
@@ -8576,6 +8623,9 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
8576
8623
|
}
|
|
8577
8624
|
workspaceRunActive = true;
|
|
8578
8625
|
workspaceSnapshot = void 0;
|
|
8626
|
+
workspaceProvenance = void 0;
|
|
8627
|
+
workspaceCoverageComplete = false;
|
|
8628
|
+
workspaceIncompleteReason = void 0;
|
|
8579
8629
|
workspacePublishedSnapshot = void 0;
|
|
8580
8630
|
workspaceCaptureFailure = void 0;
|
|
8581
8631
|
workspaceCapturePromise = void 0;
|
|
@@ -8595,10 +8645,17 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
8595
8645
|
workspaceCapturePromise = captureProviderWorkspaceSnapshot(workspaceRetention, {
|
|
8596
8646
|
environment: next,
|
|
8597
8647
|
executionId,
|
|
8648
|
+
...node === void 0 ? {} : { node },
|
|
8649
|
+
providerSessionId,
|
|
8650
|
+
nativeSessionId: null,
|
|
8598
8651
|
profile: createProfile,
|
|
8599
8652
|
...outcome === void 0 ? {} : { outcome }
|
|
8600
|
-
}).then((snapshot) => {
|
|
8653
|
+
}).then(({ snapshot, provenance, coverageComplete, incompleteReason }) => {
|
|
8601
8654
|
workspaceSnapshot = snapshot;
|
|
8655
|
+
workspaceProvenance = provenance;
|
|
8656
|
+
workspaceCoverageComplete = coverageComplete ?? false;
|
|
8657
|
+
workspaceIncompleteReason = incompleteReason;
|
|
8658
|
+
if (workspaceRetention.requireCompleteProvenance && !coverageComplete) workspacePreservationRequired = true;
|
|
8602
8659
|
return snapshot;
|
|
8603
8660
|
}).catch((error) => {
|
|
8604
8661
|
workspaceCaptureFailure = error;
|
|
@@ -8618,7 +8675,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
8618
8675
|
if (target === void 0) return { destroyed: true };
|
|
8619
8676
|
if (workspacePreservationRequired) return {
|
|
8620
8677
|
destroyed: false,
|
|
8621
|
-
detail: "provider workspace retention: source preserved because execution failed before a retrievable settled workspace receipt existed",
|
|
8678
|
+
detail: workspaceIncompleteReason ?? "provider workspace retention: source preserved because execution failed before a retrievable settled workspace receipt existed",
|
|
8622
8679
|
permanent: true
|
|
8623
8680
|
};
|
|
8624
8681
|
if (options.workspaceRetention !== void 0) try {
|
|
@@ -8771,6 +8828,9 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
8771
8828
|
onArtifact: (next) => {
|
|
8772
8829
|
artifact = next;
|
|
8773
8830
|
},
|
|
8831
|
+
onProviderSessionId: (id) => {
|
|
8832
|
+
providerSessionId = id;
|
|
8833
|
+
},
|
|
8774
8834
|
onHarnessTranscript: (next) => {
|
|
8775
8835
|
harnessTranscript = next;
|
|
8776
8836
|
},
|
|
@@ -8781,6 +8841,11 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
8781
8841
|
workspacePublishedSnapshot = snapshot;
|
|
8782
8842
|
},
|
|
8783
8843
|
captureWorkspace,
|
|
8844
|
+
workspaceProvenance: () => workspaceProvenance,
|
|
8845
|
+
workspaceCoverage: () => ({
|
|
8846
|
+
complete: workspaceCoverageComplete,
|
|
8847
|
+
incompleteReason: workspaceIncompleteReason
|
|
8848
|
+
}),
|
|
8784
8849
|
destroyEnvironment
|
|
8785
8850
|
});
|
|
8786
8851
|
const refusal = ended.unavailable;
|
|
@@ -8947,6 +9012,7 @@ async function* streamProviderExecutor(args) {
|
|
|
8947
9012
|
signal: linked
|
|
8948
9013
|
};
|
|
8949
9014
|
}
|
|
9015
|
+
args.onProviderSessionId(turn.sessionId ?? null);
|
|
8950
9016
|
const source = await providerExecutionSource(args, turn, linked);
|
|
8951
9017
|
const environment = source.environment;
|
|
8952
9018
|
args.onEnvironment(environment);
|
|
@@ -9052,7 +9118,24 @@ async function* streamProviderExecutor(args) {
|
|
|
9052
9118
|
args.onPublishedSnapshot(retainedWorkspace);
|
|
9053
9119
|
const settledResult = {
|
|
9054
9120
|
...result,
|
|
9055
|
-
...retainedWorkspace === void 0 ? {} : {
|
|
9121
|
+
...retainedWorkspace === void 0 ? {} : {
|
|
9122
|
+
workspaceSnapshot: retainedWorkspace,
|
|
9123
|
+
workspaceCapture: {
|
|
9124
|
+
executionId: args.executionId,
|
|
9125
|
+
...args.node === void 0 ? {} : { node: args.node },
|
|
9126
|
+
environmentId: environment.id,
|
|
9127
|
+
profileDigest: canonicalAgentProfileDigest(args.profile),
|
|
9128
|
+
providerSessionId: turn.sessionId ?? null,
|
|
9129
|
+
nativeSessionId: null,
|
|
9130
|
+
snapshot: retainedWorkspace,
|
|
9131
|
+
provenance: args.workspaceProvenance() ?? {
|
|
9132
|
+
status: "unavailable",
|
|
9133
|
+
missing: ["Capture coverage metadata was not retained"]
|
|
9134
|
+
},
|
|
9135
|
+
coverageComplete: args.workspaceCoverage().complete,
|
|
9136
|
+
...args.workspaceCoverage().incompleteReason === void 0 ? {} : { incompleteReason: args.workspaceCoverage().incompleteReason }
|
|
9137
|
+
}
|
|
9138
|
+
}
|
|
9056
9139
|
};
|
|
9057
9140
|
settled = {
|
|
9058
9141
|
...result.outcome?.status === "failed" ? { outcome: {
|
|
@@ -9485,6 +9568,8 @@ async function sandboxProfileFromReference(profile, resolveProfile) {
|
|
|
9485
9568
|
return resolveProfile(profile);
|
|
9486
9569
|
}
|
|
9487
9570
|
function environmentAsSandboxInstance(environment, options) {
|
|
9571
|
+
let providerSessionId = null;
|
|
9572
|
+
let capture;
|
|
9488
9573
|
return {
|
|
9489
9574
|
id: environment.id,
|
|
9490
9575
|
name: environment.name,
|
|
@@ -9495,6 +9580,7 @@ function environmentAsSandboxInstance(environment, options) {
|
|
|
9495
9580
|
async *streamPrompt(message, promptOptions) {
|
|
9496
9581
|
let terminal = false;
|
|
9497
9582
|
const input = turnInputFromPrompt(message, promptOptions);
|
|
9583
|
+
providerSessionId = input.sessionId ?? null;
|
|
9498
9584
|
let cancellation;
|
|
9499
9585
|
let cancellationStarted = false;
|
|
9500
9586
|
let cancellationFailed = false;
|
|
@@ -9596,6 +9682,32 @@ function environmentAsSandboxInstance(environment, options) {
|
|
|
9596
9682
|
return environmentAsSandboxInstance(forked, options);
|
|
9597
9683
|
} } : {},
|
|
9598
9684
|
async delete() {
|
|
9685
|
+
if (options.workspaceRetention !== void 0) {
|
|
9686
|
+
const identity = options.retentionIdentity;
|
|
9687
|
+
if (identity === void 0) throw new ValidationError("providerAsSandboxClient: retention identity missing before delete");
|
|
9688
|
+
capture ??= captureProviderWorkspaceSnapshot(options.workspaceRetention, {
|
|
9689
|
+
environment,
|
|
9690
|
+
executionId: identity.executionId,
|
|
9691
|
+
...identity.node === void 0 ? {} : { node: identity.node },
|
|
9692
|
+
providerSessionId,
|
|
9693
|
+
nativeSessionId: null,
|
|
9694
|
+
profile: identity.profile
|
|
9695
|
+
});
|
|
9696
|
+
const { snapshot, provenance, coverageComplete, incompleteReason } = await capture;
|
|
9697
|
+
options.onWorkspaceCaptured?.({
|
|
9698
|
+
executionId: identity.executionId,
|
|
9699
|
+
...identity.node === void 0 ? {} : { node: identity.node },
|
|
9700
|
+
environmentId: environment.id,
|
|
9701
|
+
profileDigest: canonicalAgentProfileDigest(identity.profile),
|
|
9702
|
+
providerSessionId,
|
|
9703
|
+
nativeSessionId: null,
|
|
9704
|
+
snapshot,
|
|
9705
|
+
provenance,
|
|
9706
|
+
coverageComplete: coverageComplete ?? false,
|
|
9707
|
+
...incompleteReason === void 0 ? {} : { incompleteReason }
|
|
9708
|
+
});
|
|
9709
|
+
if (options.workspaceRetention.requireCompleteProvenance && !coverageComplete) throw new Error(incompleteReason ?? "provider workspace retention coverage incomplete");
|
|
9710
|
+
}
|
|
9599
9711
|
await environment.destroy?.();
|
|
9600
9712
|
}
|
|
9601
9713
|
};
|
|
@@ -11455,6 +11567,126 @@ function assertBoxlessPromptOptions(options, seam, keys = instrumentPromptKeys)
|
|
|
11455
11567
|
}
|
|
11456
11568
|
}
|
|
11457
11569
|
//#endregion
|
|
11570
|
+
//#region src/runtime/sandbox-evidence-retention.ts
|
|
11571
|
+
/** A failed capture keeps the live source handle available for an explicit retry. */
|
|
11572
|
+
var SandboxEvidenceRetentionError = class extends Error {
|
|
11573
|
+
box;
|
|
11574
|
+
constructor(box, cause) {
|
|
11575
|
+
super(`Sandbox evidence retention failed for box ${String(box.id)}: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
11576
|
+
this.name = "SandboxEvidenceRetentionError";
|
|
11577
|
+
this.box = box;
|
|
11578
|
+
}
|
|
11579
|
+
};
|
|
11580
|
+
/** Capture, verify, durably record, then destroy. A failure leaves the source intact. */
|
|
11581
|
+
async function captureBeforeDestroy(port, context, destroy) {
|
|
11582
|
+
const environment = {
|
|
11583
|
+
id: String(context.box.id),
|
|
11584
|
+
provider: "sandbox"
|
|
11585
|
+
};
|
|
11586
|
+
const result = await captureProviderWorkspaceSnapshot({
|
|
11587
|
+
timeoutMs: port.timeoutMs,
|
|
11588
|
+
...port.limits === void 0 ? {} : { limits: port.limits },
|
|
11589
|
+
artifacts: port.artifacts,
|
|
11590
|
+
capture: ({ signal }) => port.capture({
|
|
11591
|
+
...context,
|
|
11592
|
+
signal
|
|
11593
|
+
})
|
|
11594
|
+
}, {
|
|
11595
|
+
environment,
|
|
11596
|
+
executionId: context.executionId,
|
|
11597
|
+
providerSessionId: context.sandboxSessionIds[0] ?? null,
|
|
11598
|
+
nativeSessionId: null,
|
|
11599
|
+
profile: context.profile
|
|
11600
|
+
});
|
|
11601
|
+
const missing = context.sandboxSessionIds.filter((id) => !result.provenance.sessions?.some((session) => session.id === id && session.executionId === context.executionId));
|
|
11602
|
+
for (const nativeId of context.nativeSessionIds ?? []) if (!result.provenance.sessions?.some((session) => session.nativeSessionId === nativeId)) missing.push(`native/${nativeId}`);
|
|
11603
|
+
for (const sessionId of context.sandboxSessionIds) if ((context.sessionExecutionIds[sessionId]?.length ?? 0) === 0) missing.push(`${sessionId}/execution-id-unobserved`);
|
|
11604
|
+
for (const [sessionId, executionIds] of Object.entries(context.sessionExecutionIds)) {
|
|
11605
|
+
const session = result.provenance.sessions?.find((item) => item.id === sessionId);
|
|
11606
|
+
for (const executionId of executionIds) if (!session?.executionIds?.includes(executionId) || !session.eventCountsByExecutionId?.[executionId]) missing.push(`${sessionId}/${executionId}`);
|
|
11607
|
+
}
|
|
11608
|
+
const coverageComplete = result.coverageComplete === true && missing.length === 0;
|
|
11609
|
+
const incompleteReason = coverageComplete ? void 0 : [result.incompleteReason, ...missing.map((id) => `Sandbox session ${id} missing from capture`)].filter((reason) => reason !== void 0).join("; ");
|
|
11610
|
+
const receipt = {
|
|
11611
|
+
boxId: String(context.box.id),
|
|
11612
|
+
executionId: context.executionId,
|
|
11613
|
+
profileDigest: canonicalAgentProfileDigest(context.profile),
|
|
11614
|
+
scope: "box",
|
|
11615
|
+
sandboxSessionIds: [...context.sandboxSessionIds],
|
|
11616
|
+
...context.nativeSessionIds === void 0 ? {} : { nativeSessionIds: [...context.nativeSessionIds] },
|
|
11617
|
+
sessionExecutionIds: Object.fromEntries(Object.entries(context.sessionExecutionIds).map(([id, executions]) => [id, [...executions]])),
|
|
11618
|
+
snapshot: result.snapshot,
|
|
11619
|
+
provenance: result.provenance,
|
|
11620
|
+
coverageComplete,
|
|
11621
|
+
...incompleteReason === void 0 ? {} : { incompleteReason }
|
|
11622
|
+
};
|
|
11623
|
+
await port.record(receipt);
|
|
11624
|
+
if (!coverageComplete) throw new Error(incompleteReason ?? "Sandbox evidence coverage incomplete");
|
|
11625
|
+
await destroy();
|
|
11626
|
+
return receipt;
|
|
11627
|
+
}
|
|
11628
|
+
/** Execution-scoped inventory of every Sandbox session and turn observed by a loop. */
|
|
11629
|
+
var SandboxEvidenceTracker = class {
|
|
11630
|
+
port;
|
|
11631
|
+
runId;
|
|
11632
|
+
boxes = /* @__PURE__ */ new Map();
|
|
11633
|
+
constructor(port, runId) {
|
|
11634
|
+
this.port = port;
|
|
11635
|
+
this.runId = runId;
|
|
11636
|
+
if (!Number.isSafeInteger(port.timeoutMs) || port.timeoutMs <= 0) throw new ValidationError$1("Sandbox evidence retention.timeoutMs must be a positive safe integer");
|
|
11637
|
+
if (typeof port.artifacts?.read !== "function") throw new ValidationError$1("Sandbox evidence retention.artifacts.read is required");
|
|
11638
|
+
if (typeof port.capture !== "function") throw new ValidationError$1("Sandbox evidence retention.capture is required");
|
|
11639
|
+
if (typeof port.record !== "function") throw new ValidationError$1("Sandbox evidence retention.record is required");
|
|
11640
|
+
}
|
|
11641
|
+
register(box, profile, sessionId) {
|
|
11642
|
+
let state = this.boxes.get(box);
|
|
11643
|
+
if (state === void 0) {
|
|
11644
|
+
state = {
|
|
11645
|
+
profile,
|
|
11646
|
+
sessions: /* @__PURE__ */ new Map()
|
|
11647
|
+
};
|
|
11648
|
+
this.boxes.set(box, state);
|
|
11649
|
+
}
|
|
11650
|
+
if (sessionId !== void 0 && !state.sessions.has(sessionId)) state.sessions.set(sessionId, /* @__PURE__ */ new Set());
|
|
11651
|
+
}
|
|
11652
|
+
recordDispatch(box, sessionId, executionId) {
|
|
11653
|
+
const state = this.boxes.get(box);
|
|
11654
|
+
if (state === void 0) throw new Error("Sandbox evidence dispatched before box registration");
|
|
11655
|
+
const executions = state.sessions.get(sessionId) ?? /* @__PURE__ */ new Set();
|
|
11656
|
+
executions.add(executionId);
|
|
11657
|
+
state.sessions.set(sessionId, executions);
|
|
11658
|
+
}
|
|
11659
|
+
observe(box, event, sessionHint) {
|
|
11660
|
+
const state = this.boxes.get(box);
|
|
11661
|
+
if (state === void 0) throw new Error("Sandbox evidence observed before box registration");
|
|
11662
|
+
const sessionId = typeof event.data.runtimeSessionId === "string" ? event.data.runtimeSessionId : sessionHint;
|
|
11663
|
+
if (sessionId === void 0) return;
|
|
11664
|
+
const executions = state.sessions.get(sessionId) ?? /* @__PURE__ */ new Set();
|
|
11665
|
+
if (typeof event.data.executionId === "string") executions.add(event.data.executionId);
|
|
11666
|
+
state.sessions.set(sessionId, executions);
|
|
11667
|
+
}
|
|
11668
|
+
async destroy(box) {
|
|
11669
|
+
const state = this.boxes.get(box);
|
|
11670
|
+
if (state === void 0) throw new Error(`Sandbox evidence has no registered source ${String(box.id)}`);
|
|
11671
|
+
const sandboxSessionIds = [...state.sessions.keys()].sort();
|
|
11672
|
+
const sessionExecutionIds = Object.fromEntries([...state.sessions.entries()].map(([id, executions]) => [id, [...executions].sort()]));
|
|
11673
|
+
try {
|
|
11674
|
+
await captureBeforeDestroy(this.port, {
|
|
11675
|
+
box,
|
|
11676
|
+
executionId: this.runId,
|
|
11677
|
+
profile: state.profile,
|
|
11678
|
+
sandboxSessionIds,
|
|
11679
|
+
sessionExecutionIds
|
|
11680
|
+
}, async () => {
|
|
11681
|
+
await box.delete();
|
|
11682
|
+
});
|
|
11683
|
+
this.boxes.delete(box);
|
|
11684
|
+
} catch (error) {
|
|
11685
|
+
throw new SandboxEvidenceRetentionError(box, error);
|
|
11686
|
+
}
|
|
11687
|
+
}
|
|
11688
|
+
};
|
|
11689
|
+
//#endregion
|
|
11458
11690
|
//#region src/runtime/sandbox-acquire.ts
|
|
11459
11691
|
/**
|
|
11460
11692
|
* HTTP statuses where create should be retried — gateway timeouts
|
|
@@ -11499,14 +11731,20 @@ async function acquireSandbox(client, options, acquire = {}) {
|
|
|
11499
11731
|
while (now() < deadline) {
|
|
11500
11732
|
throwIfAborted(acquire.signal);
|
|
11501
11733
|
try {
|
|
11502
|
-
|
|
11734
|
+
const box = await client.create(createOpts, acquire.signal === void 0 ? void 0 : { signal: acquire.signal });
|
|
11735
|
+
acquire.onAcquire?.(box);
|
|
11736
|
+
return await waitReadyOrDestroy(box, deadline, pollMs, acquire.signal, now, sleep$1, acquire.beforeDelete);
|
|
11503
11737
|
} catch (err) {
|
|
11738
|
+
if (err instanceof SandboxEvidenceRetentionError) throw err;
|
|
11504
11739
|
throwIfAborted(acquire.signal);
|
|
11505
11740
|
if (!isRetryable(err)) throw err;
|
|
11506
11741
|
lastErr = err;
|
|
11507
11742
|
if (typeof c.list === "function") for (let scan = 0; scan < appearScans && now() < deadline; scan += 1) {
|
|
11508
11743
|
const found = (await c.list().catch(() => []))?.find((b) => b.name === name);
|
|
11509
|
-
if (found)
|
|
11744
|
+
if (found) {
|
|
11745
|
+
acquire.onAcquire?.(found);
|
|
11746
|
+
return await waitReadyOrDestroy(found, deadline, pollMs, acquire.signal, now, sleep$1, acquire.beforeDelete);
|
|
11747
|
+
}
|
|
11510
11748
|
if (scan < appearScans - 1) await sleep$1(pollMs);
|
|
11511
11749
|
}
|
|
11512
11750
|
attempt += 1;
|
|
@@ -11517,11 +11755,12 @@ async function acquireSandbox(client, options, acquire = {}) {
|
|
|
11517
11755
|
}
|
|
11518
11756
|
/** `waitUntilReady`, tearing the box down (best-effort) on any throw so a box
|
|
11519
11757
|
* that never reaches `running` (abort, terminal status, budget) does not leak. */
|
|
11520
|
-
async function waitReadyOrDestroy(box, deadline, pollMs, signal, now, sleep) {
|
|
11758
|
+
async function waitReadyOrDestroy(box, deadline, pollMs, signal, now, sleep, beforeDelete) {
|
|
11521
11759
|
try {
|
|
11522
11760
|
return await waitUntilReady(box, deadline, pollMs, signal, now, sleep);
|
|
11523
11761
|
} catch (err) {
|
|
11524
|
-
await deleteBoxSafe(box);
|
|
11762
|
+
if (beforeDelete === void 0) await deleteBoxSafe(box);
|
|
11763
|
+
else await beforeDelete(box);
|
|
11525
11764
|
throw err;
|
|
11526
11765
|
}
|
|
11527
11766
|
}
|
|
@@ -11731,14 +11970,31 @@ function createSandboxLineage(client, capabilities, options = {}) {
|
|
|
11731
11970
|
const recordMount = options.recordMount ?? (() => {});
|
|
11732
11971
|
const forkConcurrency = Math.max(1, Math.floor(options.maxConcurrency ?? DEFAULT_FORK_CONCURRENCY));
|
|
11733
11972
|
const owned = [];
|
|
11973
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11734
11974
|
const acquireFresh = async (spec, signal) => {
|
|
11735
11975
|
if (signal.aborted) throwAbort();
|
|
11736
|
-
const box = await acquireSandbox(client, buildBackendOptions(spec.profile, spec.sandboxOverrides), {
|
|
11737
|
-
await spec.prepareBox?.(box, {
|
|
11976
|
+
const box = await acquireSandbox(client, buildBackendOptions(spec.profile, spec.sandboxOverrides), {
|
|
11738
11977
|
signal,
|
|
11739
|
-
|
|
11978
|
+
...options.onAcquire === void 0 ? {} : { onAcquire: (source) => options.onAcquire?.(source, spec.profile) },
|
|
11979
|
+
...options.beforeDelete === void 0 ? {} : { beforeDelete: options.beforeDelete }
|
|
11740
11980
|
});
|
|
11741
11981
|
owned.push(box);
|
|
11982
|
+
profiles.set(box, spec.profile);
|
|
11983
|
+
options.onAcquire?.(box, spec.profile);
|
|
11984
|
+
try {
|
|
11985
|
+
await spec.prepareBox?.(box, {
|
|
11986
|
+
signal,
|
|
11987
|
+
recordMount
|
|
11988
|
+
});
|
|
11989
|
+
} catch (error) {
|
|
11990
|
+
try {
|
|
11991
|
+
await destroyBounded(box, options.failOnDestroyError, options.beforeDelete);
|
|
11992
|
+
owned.splice(owned.indexOf(box), 1);
|
|
11993
|
+
} catch (captureError) {
|
|
11994
|
+
throw new AggregateError([error, captureError], "Sandbox preparation and evidence cleanup failed");
|
|
11995
|
+
}
|
|
11996
|
+
throw error;
|
|
11997
|
+
}
|
|
11742
11998
|
return box;
|
|
11743
11999
|
};
|
|
11744
12000
|
return {
|
|
@@ -11759,17 +12015,31 @@ function createSandboxLineage(client, capabilities, options = {}) {
|
|
|
11759
12015
|
await assertSessionLive(handle.box, handle.sessionId);
|
|
11760
12016
|
return promptEvents(streaming, handle.box, prompt, handle.sessionId, signal, promptOptions);
|
|
11761
12017
|
},
|
|
11762
|
-
async fork(parent, prompts, specs, signal, promptOptions) {
|
|
12018
|
+
async fork(parent, prompts, specs, signal, promptOptions, executionIds) {
|
|
12019
|
+
if (executionIds !== void 0 && executionIds.length !== prompts.length) throw new ValidationError$1("SandboxLineage.fork: execution IDs must match prompts");
|
|
12020
|
+
const optionsFor = (index) => executionIds === void 0 ? promptOptions : {
|
|
12021
|
+
...promptOptions ?? {},
|
|
12022
|
+
executionId: executionIds[index]
|
|
12023
|
+
};
|
|
11763
12024
|
if (prompts.length === 0) throw new ValidationError$1("SandboxLineage.fork: prompts must be non-empty");
|
|
11764
12025
|
if (signal.aborted) throwAbort();
|
|
11765
12026
|
const branched = await branchParent(parent.box, prompts.length, forkConcurrency, signal);
|
|
11766
12027
|
if (branched !== void 0) {
|
|
11767
12028
|
owned.push(...branched);
|
|
12029
|
+
const inheritedProfile = profiles.get(parent.box);
|
|
12030
|
+
if (inheritedProfile !== void 0) for (const box of branched) {
|
|
12031
|
+
profiles.set(box, inheritedProfile);
|
|
12032
|
+
options.onAcquire?.(box, inheritedProfile);
|
|
12033
|
+
}
|
|
11768
12034
|
if (branched.length !== prompts.length) throw new ValidationError$1(`SandboxLineage.fork: Sandbox returned ${branched.length} of ${prompts.length} requested children`);
|
|
11769
12035
|
return mapWithConcurrency(branched, forkConcurrency, async (box, i) => {
|
|
11770
12036
|
throwIfAborted(signal);
|
|
11771
12037
|
const spec = specs[i % specs.length];
|
|
11772
12038
|
if (!spec) throw new ValidationError$1("SandboxLineage.fork: no AgentRunSpec for branch");
|
|
12039
|
+
if (inheritedProfile === void 0) {
|
|
12040
|
+
profiles.set(box, spec.profile);
|
|
12041
|
+
options.onAcquire?.(box, spec.profile);
|
|
12042
|
+
}
|
|
11773
12043
|
await spec.prepareBox?.(box, {
|
|
11774
12044
|
signal,
|
|
11775
12045
|
recordMount
|
|
@@ -11780,7 +12050,7 @@ function createSandboxLineage(client, capabilities, options = {}) {
|
|
|
11780
12050
|
box,
|
|
11781
12051
|
sessionId
|
|
11782
12052
|
},
|
|
11783
|
-
events: promptEvents(streaming, box, prompts[i], sessionId, signal,
|
|
12053
|
+
events: promptEvents(streaming, box, prompts[i], sessionId, signal, optionsFor(i))
|
|
11784
12054
|
};
|
|
11785
12055
|
});
|
|
11786
12056
|
}
|
|
@@ -11792,6 +12062,9 @@ function createSandboxLineage(client, capabilities, options = {}) {
|
|
|
11792
12062
|
if (checkpointId !== void 0) {
|
|
11793
12063
|
const box = await forkFromCheckpoint(parent.box, checkpointId, signal);
|
|
11794
12064
|
owned.push(box);
|
|
12065
|
+
const inheritedProfile = profiles.get(parent.box) ?? spec.profile;
|
|
12066
|
+
profiles.set(box, inheritedProfile);
|
|
12067
|
+
options.onAcquire?.(box, inheritedProfile);
|
|
11795
12068
|
await spec.prepareBox?.(box, {
|
|
11796
12069
|
signal,
|
|
11797
12070
|
recordMount
|
|
@@ -11802,7 +12075,7 @@ function createSandboxLineage(client, capabilities, options = {}) {
|
|
|
11802
12075
|
box,
|
|
11803
12076
|
sessionId
|
|
11804
12077
|
},
|
|
11805
|
-
events: promptEvents(streaming, box, prompt, sessionId, signal,
|
|
12078
|
+
events: promptEvents(streaming, box, prompt, sessionId, signal, optionsFor(i))
|
|
11806
12079
|
};
|
|
11807
12080
|
}
|
|
11808
12081
|
const box = await acquireFresh(spec, signal);
|
|
@@ -11812,7 +12085,7 @@ function createSandboxLineage(client, capabilities, options = {}) {
|
|
|
11812
12085
|
box,
|
|
11813
12086
|
sessionId
|
|
11814
12087
|
},
|
|
11815
|
-
events: promptEvents(streaming, box, prompt, sessionId, signal,
|
|
12088
|
+
events: promptEvents(streaming, box, prompt, sessionId, signal, optionsFor(i))
|
|
11816
12089
|
};
|
|
11817
12090
|
});
|
|
11818
12091
|
},
|
|
@@ -11823,13 +12096,18 @@ function createSandboxLineage(client, capabilities, options = {}) {
|
|
|
11823
12096
|
const doomed = [];
|
|
11824
12097
|
for (const box of owned) (keepBoxes.has(box) ? survivors : doomed).push(box);
|
|
11825
12098
|
if (doomed.length === 0) return;
|
|
12099
|
+
const results = await Promise.allSettled(doomed.map((box) => destroyBounded(box, options.failOnDestroyError, options.beforeDelete)));
|
|
12100
|
+
const failed = results.flatMap((result, index) => result.status === "rejected" ? [doomed[index]] : []);
|
|
11826
12101
|
owned.length = 0;
|
|
11827
|
-
owned.push(...survivors);
|
|
11828
|
-
|
|
12102
|
+
owned.push(...survivors, ...failed);
|
|
12103
|
+
if (failed.length > 0) throw new AggregateError(results.filter((result) => result.status === "rejected").map((result) => result.reason), "Sandbox evidence capture failed before prune");
|
|
11829
12104
|
},
|
|
11830
12105
|
async teardown() {
|
|
11831
12106
|
const boxes = owned.splice(0, owned.length);
|
|
11832
|
-
await Promise.allSettled(boxes.map((box) => destroyBounded(box)));
|
|
12107
|
+
const results = await Promise.allSettled(boxes.map((box) => destroyBounded(box, options.failOnDestroyError, options.beforeDelete)));
|
|
12108
|
+
const failed = results.flatMap((result, index) => result.status === "rejected" ? [boxes[index]] : []);
|
|
12109
|
+
owned.push(...failed);
|
|
12110
|
+
if (failed.length > 0) throw new AggregateError(results.filter((result) => result.status === "rejected").map((result) => result.reason), "Sandbox evidence capture failed before teardown");
|
|
11833
12111
|
}
|
|
11834
12112
|
};
|
|
11835
12113
|
}
|
|
@@ -11846,14 +12124,19 @@ async function branchParent(box, count, concurrency, signal) {
|
|
|
11846
12124
|
const branch = box.branch;
|
|
11847
12125
|
if (typeof branch !== "function") return void 0;
|
|
11848
12126
|
const children = [];
|
|
11849
|
-
|
|
11850
|
-
|
|
11851
|
-
|
|
11852
|
-
|
|
11853
|
-
|
|
11854
|
-
|
|
12127
|
+
try {
|
|
12128
|
+
for (let offset = 0; offset < count; offset += concurrency) {
|
|
12129
|
+
throwIfAborted(signal);
|
|
12130
|
+
const requested = Math.min(concurrency, count - offset);
|
|
12131
|
+
const batch = await branch.call(box, requested);
|
|
12132
|
+
children.push(...batch);
|
|
12133
|
+
if (batch.length !== requested) return children;
|
|
12134
|
+
}
|
|
12135
|
+
return children;
|
|
12136
|
+
} catch (error) {
|
|
12137
|
+
if (children.length) return children;
|
|
12138
|
+
throw error;
|
|
11855
12139
|
}
|
|
11856
|
-
return children;
|
|
11857
12140
|
}
|
|
11858
12141
|
/**
|
|
11859
12142
|
* Checkpoint the parent leaving it running, returning the checkpoint id to fork
|
|
@@ -11896,7 +12179,15 @@ async function assertSessionLive(box, sessionId) {
|
|
|
11896
12179
|
if (typeof session !== "function") return;
|
|
11897
12180
|
if (await session.call(box, sessionId).status() === null) throw new ValidationError$1(`SandboxLineage.continue: session ${sessionId} is not known to the sandbox — the platform did not preserve the client-minted session id (or it was reaped). Continuing would run without prior context; refusing to silently lose conversation continuity.`);
|
|
11898
12181
|
}
|
|
11899
|
-
async function destroyBounded(box) {
|
|
12182
|
+
async function destroyBounded(box, failOnError = false, beforeDelete) {
|
|
12183
|
+
if (beforeDelete !== void 0) {
|
|
12184
|
+
await beforeDelete(box);
|
|
12185
|
+
return;
|
|
12186
|
+
}
|
|
12187
|
+
if (failOnError) {
|
|
12188
|
+
await box.delete();
|
|
12189
|
+
return;
|
|
12190
|
+
}
|
|
11900
12191
|
await withTimeout(deleteBoxSafe(box), TEARDOWN_TIMEOUT_MS$1);
|
|
11901
12192
|
}
|
|
11902
12193
|
//#endregion
|
|
@@ -11928,6 +12219,8 @@ async function runAgentRounds(options) {
|
|
|
11928
12219
|
const promptOptions = readPromptOptions(options.ctx.promptOptions, "runAgentRounds: ctx.promptOptions");
|
|
11929
12220
|
const now = options.now ?? Date.now;
|
|
11930
12221
|
const runId = options.runId ?? `loop-${randomSuffix()}`;
|
|
12222
|
+
if (options.evidenceRetention !== void 0 && options.onWorkerBox !== void 0) throw new ValidationError$1("runAgentRounds: evidenceRetention cannot cover sessions dispatched through onWorkerBox");
|
|
12223
|
+
const evidenceTracker = options.evidenceRetention === void 0 ? void 0 : new SandboxEvidenceTracker(options.evidenceRetention, runId);
|
|
11931
12224
|
const loopStart = now();
|
|
11932
12225
|
const driverName = options.driver.name ?? "driver";
|
|
11933
12226
|
const iterations = [];
|
|
@@ -11941,7 +12234,7 @@ async function runAgentRounds(options) {
|
|
|
11941
12234
|
ownedBoxes.push(box);
|
|
11942
12235
|
options.onWorkerBox?.(box);
|
|
11943
12236
|
} : void 0;
|
|
11944
|
-
const lineageState = await setUpLineage(options, maxConcurrency, recordMount, promptOptions);
|
|
12237
|
+
const lineageState = await setUpLineage(options, maxConcurrency, recordMount, promptOptions, evidenceTracker);
|
|
11945
12238
|
emitRunLoopHook(options, {
|
|
11946
12239
|
target: "agent.run",
|
|
11947
12240
|
phase: "before",
|
|
@@ -12035,7 +12328,7 @@ async function runAgentRounds(options) {
|
|
|
12035
12328
|
tokenUsage: zeroTokenUsage()
|
|
12036
12329
|
});
|
|
12037
12330
|
}
|
|
12038
|
-
const lineagePlan = lineageState ? planLineageRound(lineageState, specs, slice, parentIndex, controller.signal) : void 0;
|
|
12331
|
+
const lineagePlan = lineageState ? planLineageRound(lineageState, specs, slice, parentIndex, controller.signal, evidenceTracker !== void 0) : void 0;
|
|
12039
12332
|
await runBatch({
|
|
12040
12333
|
slice,
|
|
12041
12334
|
baseIndex,
|
|
@@ -12054,6 +12347,7 @@ async function runAgentRounds(options) {
|
|
|
12054
12347
|
collectBox,
|
|
12055
12348
|
lineagePlan,
|
|
12056
12349
|
lineageState,
|
|
12350
|
+
evidenceTracker,
|
|
12057
12351
|
recordMount,
|
|
12058
12352
|
...promptOptions === void 0 ? {} : { promptOptions }
|
|
12059
12353
|
});
|
|
@@ -12093,9 +12387,17 @@ async function runAgentRounds(options) {
|
|
|
12093
12387
|
return await decideAndFinalize(options, iterations, loopStart, now, runId, mounts);
|
|
12094
12388
|
} finally {
|
|
12095
12389
|
if (options.ctx.signal) options.ctx.signal.removeEventListener("abort", onOuterAbort);
|
|
12096
|
-
await Promise.allSettled(ownedBoxes.map((
|
|
12390
|
+
const cleanup = await Promise.allSettled(ownedBoxes.map((box) => evidenceTracker === void 0 ? destroySandboxSafe(box, options.ctx.traceEmitter, runId, now) : evidenceTracker.destroy(box)));
|
|
12097
12391
|
if (options.onWorkerBox) options.onWorkerBox(void 0);
|
|
12098
|
-
|
|
12392
|
+
let lineageFailure;
|
|
12393
|
+
try {
|
|
12394
|
+
if (lineageState) await lineageState.lineage.teardown();
|
|
12395
|
+
} catch (error) {
|
|
12396
|
+
lineageFailure = error;
|
|
12397
|
+
}
|
|
12398
|
+
const failures = cleanup.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
12399
|
+
if (lineageFailure !== void 0) failures.push(lineageFailure);
|
|
12400
|
+
if (failures.length) throw new AggregateError(failures, "Sandbox evidence cleanup failed");
|
|
12099
12401
|
}
|
|
12100
12402
|
}
|
|
12101
12403
|
/**
|
|
@@ -12104,7 +12406,7 @@ async function runAgentRounds(options) {
|
|
|
12104
12406
|
* Rejects the lineage + `onWorkerBox` combination: both claim the same
|
|
12105
12407
|
* box-ownership channel, and silently honoring one would leak or double-free.
|
|
12106
12408
|
*/
|
|
12107
|
-
async function setUpLineage(options, maxConcurrency, recordMount, promptOptions) {
|
|
12409
|
+
async function setUpLineage(options, maxConcurrency, recordMount, promptOptions, evidenceTracker) {
|
|
12108
12410
|
const lineageOpts = options.lineage;
|
|
12109
12411
|
if (!lineageOpts || !lineageOpts.sessionContinuity && !lineageOpts.forkFanout) return void 0;
|
|
12110
12412
|
if (options.onWorkerBox) throw new ValidationError$1("runAgentRounds: `lineage` and `onWorkerBox` both own worker boxes — pass only one");
|
|
@@ -12113,7 +12415,12 @@ async function setUpLineage(options, maxConcurrency, recordMount, promptOptions)
|
|
|
12113
12415
|
lineage: createSandboxLineage(options.ctx.sandboxClient, capabilities, {
|
|
12114
12416
|
maxConcurrency,
|
|
12115
12417
|
streaming: lineageOpts.streaming,
|
|
12116
|
-
recordMount
|
|
12418
|
+
recordMount,
|
|
12419
|
+
...evidenceTracker === void 0 ? {} : {
|
|
12420
|
+
failOnDestroyError: true,
|
|
12421
|
+
onAcquire: (box, profile) => evidenceTracker.register(box, profile),
|
|
12422
|
+
beforeDelete: (box) => evidenceTracker.destroy(box)
|
|
12423
|
+
}
|
|
12117
12424
|
}),
|
|
12118
12425
|
options: lineageOpts,
|
|
12119
12426
|
...promptOptions === void 0 ? {} : { promptOptions },
|
|
@@ -12134,7 +12441,12 @@ async function setUpLineage(options, maxConcurrency, recordMount, promptOptions)
|
|
|
12134
12441
|
* Round 0 (parentIndex undefined) always starts fresh — the independence of the
|
|
12135
12442
|
* first batch is preserved.
|
|
12136
12443
|
*/
|
|
12137
|
-
function planLineageRound(state, specs, slice, parentIndex, signal) {
|
|
12444
|
+
function planLineageRound(state, specs, slice, parentIndex, signal, retainEvidence) {
|
|
12445
|
+
const executionIds = retainEvidence ? slice.map(() => randomUuid()) : [];
|
|
12446
|
+
const promptForOffset = (offset) => retainEvidence ? {
|
|
12447
|
+
...state.promptOptions ?? {},
|
|
12448
|
+
executionId: executionIds[offset]
|
|
12449
|
+
} : state.promptOptions;
|
|
12138
12450
|
const lineage = state.lineage;
|
|
12139
12451
|
const parent = parentIndex !== void 0 ? state.handles.get(parentIndex) : void 0;
|
|
12140
12452
|
const promptFor = (offset) => {
|
|
@@ -12149,8 +12461,9 @@ function planLineageRound(state, specs, slice, parentIndex, signal) {
|
|
|
12149
12461
|
};
|
|
12150
12462
|
if (slice.length === 1 && parent && state.options.sessionContinuity) return [{ async acquire() {
|
|
12151
12463
|
return {
|
|
12152
|
-
events: await lineage.continue(parent, promptFor(0), signal,
|
|
12153
|
-
handle: parent
|
|
12464
|
+
events: await lineage.continue(parent, promptFor(0), signal, promptForOffset(0)),
|
|
12465
|
+
handle: parent,
|
|
12466
|
+
...retainEvidence ? { executionId: executionIds[0] } : {}
|
|
12154
12467
|
};
|
|
12155
12468
|
} }];
|
|
12156
12469
|
if (slice.length > 1 && parent && state.options.forkFanout) {
|
|
@@ -12158,17 +12471,23 @@ function planLineageRound(state, specs, slice, parentIndex, signal) {
|
|
|
12158
12471
|
const childSpecs = slice.map((_, offset) => specAt(offset));
|
|
12159
12472
|
let forked;
|
|
12160
12473
|
const ensureForked = () => {
|
|
12161
|
-
forked ??= lineage.fork(parent, prompts, childSpecs, signal, state.promptOptions);
|
|
12474
|
+
forked ??= lineage.fork(parent, prompts, childSpecs, signal, state.promptOptions, retainEvidence ? executionIds : void 0);
|
|
12162
12475
|
return forked;
|
|
12163
12476
|
};
|
|
12164
12477
|
return slice.map((_, offset) => ({ async acquire() {
|
|
12165
12478
|
const branch = (await ensureForked())[offset];
|
|
12166
12479
|
if (!branch) throw new ValidationError$1("runAgentRounds: lineage fork produced no branch for offset");
|
|
12167
|
-
return
|
|
12480
|
+
return {
|
|
12481
|
+
...branch,
|
|
12482
|
+
...retainEvidence ? { executionId: executionIds[offset] } : {}
|
|
12483
|
+
};
|
|
12168
12484
|
} }));
|
|
12169
12485
|
}
|
|
12170
12486
|
return slice.map((_, offset) => ({ async acquire() {
|
|
12171
|
-
return
|
|
12487
|
+
return {
|
|
12488
|
+
...await lineage.start(specAt(offset), promptFor(offset), signal, promptForOffset(offset)),
|
|
12489
|
+
...retainEvidence ? { executionId: executionIds[offset] } : {}
|
|
12490
|
+
};
|
|
12172
12491
|
} }));
|
|
12173
12492
|
}
|
|
12174
12493
|
/**
|
|
@@ -12275,6 +12594,8 @@ async function executeIteration(args) {
|
|
|
12275
12594
|
};
|
|
12276
12595
|
try {
|
|
12277
12596
|
let stream;
|
|
12597
|
+
let sandboxSessionId;
|
|
12598
|
+
let dispatchedExecutionId;
|
|
12278
12599
|
const source = args.lineagePlan?.[args.item.index - args.baseIndex];
|
|
12279
12600
|
if (source) {
|
|
12280
12601
|
const acquired = await source.acquire();
|
|
@@ -12282,17 +12603,28 @@ async function executeIteration(args) {
|
|
|
12282
12603
|
boxAcquiredAt = args.now();
|
|
12283
12604
|
lineageOwned = true;
|
|
12284
12605
|
args.lineageState?.handles.set(args.item.index, acquired.handle);
|
|
12606
|
+
args.evidenceTracker?.register(box, spec.profile, acquired.handle.sessionId);
|
|
12285
12607
|
stream = acquired.events;
|
|
12608
|
+
sandboxSessionId = acquired.handle.sessionId;
|
|
12609
|
+
dispatchedExecutionId = acquired.executionId;
|
|
12286
12610
|
} else {
|
|
12287
|
-
box = await createSandboxForSpec(args.ctx.sandboxClient, spec, args.signal, args.recordMount);
|
|
12611
|
+
box = await createSandboxForSpec(args.ctx.sandboxClient, spec, args.signal, args.recordMount, args.evidenceTracker);
|
|
12288
12612
|
boxAcquiredAt = args.now();
|
|
12289
12613
|
const prompt = spec.taskToPrompt(args.item.task);
|
|
12290
|
-
const
|
|
12291
|
-
|
|
12614
|
+
const sandboxSessionIdForTurn = args.evidenceTracker === void 0 ? void 0 : randomUuid();
|
|
12615
|
+
sandboxSessionId = sandboxSessionIdForTurn;
|
|
12616
|
+
dispatchedExecutionId = args.evidenceTracker === void 0 ? void 0 : randomUuid();
|
|
12617
|
+
const promptOptions = dispatchedExecutionId === void 0 ? args.promptOptions : {
|
|
12618
|
+
...args.promptOptions ?? {},
|
|
12619
|
+
executionId: dispatchedExecutionId
|
|
12620
|
+
};
|
|
12621
|
+
stream = args.streaming === "poll" ? promptEvents("poll", box, prompt, sandboxSessionIdForTurn ?? `${args.runId}-i${args.item.index}`, args.signal, promptOptions) : box.streamPrompt(prompt, {
|
|
12292
12622
|
...promptOptions ?? {},
|
|
12623
|
+
...sandboxSessionIdForTurn === void 0 ? {} : { sessionId: sandboxSessionIdForTurn },
|
|
12293
12624
|
signal: args.signal
|
|
12294
12625
|
});
|
|
12295
12626
|
}
|
|
12627
|
+
if (box !== void 0 && sandboxSessionId !== void 0 && dispatchedExecutionId !== void 0) args.evidenceTracker?.recordDispatch(box, sandboxSessionId, dispatchedExecutionId);
|
|
12296
12628
|
const placement = describeSandboxPlacement(args.ctx.sandboxClient, box);
|
|
12297
12629
|
await emitTrace(args.ctx.traceEmitter, {
|
|
12298
12630
|
kind: "loop.iteration.dispatch",
|
|
@@ -12319,6 +12651,7 @@ async function executeIteration(args) {
|
|
|
12319
12651
|
const outcomeTracker = createAgentRunOutcomeTracker();
|
|
12320
12652
|
for await (const event of stream) {
|
|
12321
12653
|
events.push(event);
|
|
12654
|
+
if (box !== void 0) args.evidenceTracker?.observe(box, event, source ? args.lineageState?.handles.get(args.item.index)?.sessionId : void 0);
|
|
12322
12655
|
outcomeTracker.observe(event);
|
|
12323
12656
|
notifySandboxEventObserver(event, args.ctx.onSandboxEvent, {
|
|
12324
12657
|
iterationIndex: args.item.index,
|
|
@@ -12375,7 +12708,7 @@ async function executeIteration(args) {
|
|
|
12375
12708
|
});
|
|
12376
12709
|
if (lineageOwned) {} else if (args.collectBox && box) args.collectBox(box);
|
|
12377
12710
|
else {
|
|
12378
|
-
const teardown = await destroySandboxSafe(box, args.ctx.traceEmitter, args.runId, args.now);
|
|
12711
|
+
const teardown = args.evidenceTracker === void 0 || box === void 0 ? await destroySandboxSafe(box, args.ctx.traceEmitter, args.runId, args.now) : await args.evidenceTracker.destroy(box).then(() => "deleted");
|
|
12379
12712
|
if (boxAcquiredAt !== void 0 && teardown !== "no-delete-api") {
|
|
12380
12713
|
slot.boxLiveMs = Math.max(0, args.now() - boxAcquiredAt);
|
|
12381
12714
|
if (teardown !== "deleted") slot.boxLiveMsKnown = false;
|
|
@@ -12472,11 +12805,24 @@ function readSandboxId(box) {
|
|
|
12472
12805
|
* loop kernel passes its per-run recorder; other callers (which have no
|
|
12473
12806
|
* `LoopResult` to attach to) omit it and the prepareBox recorder is a no-op.
|
|
12474
12807
|
*/
|
|
12475
|
-
async function createSandboxForSpec(client, spec, signal, recordMount) {
|
|
12808
|
+
async function createSandboxForSpec(client, spec, signal, recordMount, evidenceTracker) {
|
|
12476
12809
|
const opts = buildBackendOptions(spec.profile, spec.sandboxOverrides);
|
|
12477
12810
|
if (signal.aborted) throwAbort();
|
|
12478
|
-
const box = await acquireSandbox(client, opts, {
|
|
12479
|
-
|
|
12811
|
+
const box = await acquireSandbox(client, opts, {
|
|
12812
|
+
signal,
|
|
12813
|
+
...evidenceTracker === void 0 ? {} : {
|
|
12814
|
+
onAcquire: (source) => evidenceTracker.register(source, spec.profile),
|
|
12815
|
+
beforeDelete: (source) => evidenceTracker.destroy(source)
|
|
12816
|
+
}
|
|
12817
|
+
});
|
|
12818
|
+
evidenceTracker?.register(box, spec.profile);
|
|
12819
|
+
try {
|
|
12820
|
+
await invokePrepareBox(spec, box, signal, recordMount);
|
|
12821
|
+
} catch (error) {
|
|
12822
|
+
if (evidenceTracker === void 0) await deleteBoxSafe(box);
|
|
12823
|
+
else await evidenceTracker.destroy(box);
|
|
12824
|
+
throw error;
|
|
12825
|
+
}
|
|
12480
12826
|
return box;
|
|
12481
12827
|
}
|
|
12482
12828
|
/**
|
|
@@ -18229,8 +18575,12 @@ function createSteerableSandboxSession(args) {
|
|
|
18229
18575
|
return progress;
|
|
18230
18576
|
};
|
|
18231
18577
|
async function* stream(task, signal) {
|
|
18578
|
+
let preservationFailure;
|
|
18232
18579
|
const capabilities = await probeSandboxCapabilities(args.sandboxClient);
|
|
18233
|
-
const lineage = createSandboxLineage(args.sandboxClient, capabilities, {
|
|
18580
|
+
const lineage = createSandboxLineage(args.sandboxClient, capabilities, {
|
|
18581
|
+
maxConcurrency: 1,
|
|
18582
|
+
failOnDestroyError: args.failOnDestroyError
|
|
18583
|
+
});
|
|
18234
18584
|
state.teardown = () => lineage.teardown();
|
|
18235
18585
|
const spec = {
|
|
18236
18586
|
profile: args.profile,
|
|
@@ -18390,7 +18740,12 @@ function createSteerableSandboxSession(args) {
|
|
|
18390
18740
|
}
|
|
18391
18741
|
} finally {
|
|
18392
18742
|
state.note = "settled";
|
|
18393
|
-
|
|
18743
|
+
if (args.failOnDestroyError) try {
|
|
18744
|
+
await lineage.teardown();
|
|
18745
|
+
} catch (error) {
|
|
18746
|
+
preservationFailure = error instanceof Error ? error.message : String(error);
|
|
18747
|
+
}
|
|
18748
|
+
else await lineage.teardown().catch(() => {});
|
|
18394
18749
|
state.teardown = void 0;
|
|
18395
18750
|
}
|
|
18396
18751
|
if (state.turns > 0) yield {
|
|
@@ -18415,9 +18770,15 @@ function createSteerableSandboxSession(args) {
|
|
|
18415
18770
|
turns: state.turns,
|
|
18416
18771
|
toolCalls: state.toolCalls,
|
|
18417
18772
|
...state.latestOutcome ? { outcome: state.latestOutcome } : {},
|
|
18418
|
-
...usageFailure === void 0 ? {} : { tokensUnknownReason: usageFailure }
|
|
18773
|
+
...usageFailure === void 0 ? {} : { tokensUnknownReason: usageFailure },
|
|
18774
|
+
...args.workspaceCaptures === void 0 ? {} : { workspaceCaptures: args.workspaceCaptures() },
|
|
18775
|
+
...preservationFailure === void 0 ? {} : { preservationFailure }
|
|
18419
18776
|
};
|
|
18420
|
-
const verdict =
|
|
18777
|
+
const verdict = preservationFailure !== void 0 ? {
|
|
18778
|
+
valid: false,
|
|
18779
|
+
score: 0,
|
|
18780
|
+
notes: preservationFailure
|
|
18781
|
+
} : state.latestOutcome ? projectSandboxOutcome(state.latestOutcome).verdict : void 0;
|
|
18421
18782
|
state.artifact = {
|
|
18422
18783
|
outRef: args.contentRef("sandbox-steerable", {
|
|
18423
18784
|
harness: args.harness,
|
|
@@ -18493,7 +18854,8 @@ function createSteerableSandboxSession(args) {
|
|
|
18493
18854
|
traceSource: () => trace.source,
|
|
18494
18855
|
artifact: () => state.artifact,
|
|
18495
18856
|
async teardown() {
|
|
18496
|
-
await state.teardown?.()
|
|
18857
|
+
if (args.failOnDestroyError) await state.teardown?.();
|
|
18858
|
+
else await state.teardown?.().catch(() => {});
|
|
18497
18859
|
}
|
|
18498
18860
|
};
|
|
18499
18861
|
}
|
|
@@ -19340,6 +19702,8 @@ const sandboxExecutor = (spec, ctx) => {
|
|
|
19340
19702
|
profile: spec.profile,
|
|
19341
19703
|
harness,
|
|
19342
19704
|
sandboxClient: seam.sandboxClient,
|
|
19705
|
+
failOnDestroyError: seam.failOnDestroyError,
|
|
19706
|
+
workspaceCaptures: seam.workspaceCaptures,
|
|
19343
19707
|
inbox,
|
|
19344
19708
|
taskToPrompt: (t) => taskToPrompt(t),
|
|
19345
19709
|
options: seam.steering,
|
|
@@ -20065,6 +20429,8 @@ function snapshotExecutorConfig(config) {
|
|
|
20065
20429
|
case "sandbox": {
|
|
20066
20430
|
assertExactConfigKeys(config, /* @__PURE__ */ new Set([
|
|
20067
20431
|
"backend",
|
|
20432
|
+
"failOnDestroyError",
|
|
20433
|
+
"workspaceCaptures",
|
|
20068
20434
|
"lineage",
|
|
20069
20435
|
"loopCtx",
|
|
20070
20436
|
"maxIterations",
|
|
@@ -20072,10 +20438,11 @@ function snapshotExecutorConfig(config) {
|
|
|
20072
20438
|
"steering",
|
|
20073
20439
|
"validator"
|
|
20074
20440
|
]), "createExecutor sandbox config");
|
|
20075
|
-
const { sandboxClient, loopCtx, validator, ...decisionData } = config;
|
|
20441
|
+
const { sandboxClient, loopCtx, validator, workspaceCaptures, ...decisionData } = config;
|
|
20076
20442
|
const port = {
|
|
20077
20443
|
sandboxClient,
|
|
20078
|
-
...validator === void 0 ? {} : { validator }
|
|
20444
|
+
...validator === void 0 ? {} : { validator },
|
|
20445
|
+
...workspaceCaptures === void 0 ? {} : { workspaceCaptures }
|
|
20079
20446
|
};
|
|
20080
20447
|
if (loopCtx === void 0) {
|
|
20081
20448
|
const snapshot = detachedSnapshot(decisionData, "createExecutor sandbox config");
|
|
@@ -20192,20 +20559,31 @@ function createExecutor(config) {
|
|
|
20192
20559
|
const originalSeam = readSeam(seamed, providerSeamKey, "provider");
|
|
20193
20560
|
const selected = originalSeam.steering ? selectProviderPlacement(spec.profile, originalSeam) : void 0;
|
|
20194
20561
|
const providerSeam = selected?.options ?? originalSeam;
|
|
20195
|
-
if (providerSeam.steering && providerSeam.workspaceRetention !== void 0) throw new ValidationError$1("createExecutor(provider, steering): workspaceRetention cannot be used with steering because the session-owned environment has no single-shot preservation barrier");
|
|
20196
20562
|
const provider = resolveAgentEnvironmentProvider(providerSeam.provider, providerSeam.registry);
|
|
20197
20563
|
if (providerSeam.steering) {
|
|
20198
20564
|
if (providerSeam.taskToTurn) throw new ValidationError$1("createExecutor(provider, steering): taskToTurn is not representable by the text-only steerable session");
|
|
20199
20565
|
if (providerSeam.destroyOnSettle === false) throw new ValidationError$1("createExecutor(provider, steering): destroyOnSettle=false conflicts with the session-owned environment lifecycle");
|
|
20200
20566
|
if (providerSeam.validator) throw new ValidationError$1("createExecutor(provider, steering): validator is not representable with steering — the steerable session is a multi-turn session on one environment, not a scored single-shot leaf, so the score would be silently dropped");
|
|
20201
20567
|
const harness = requiredProviderProfileHarness(spec, providerSeam);
|
|
20568
|
+
const workspaceCaptures = [];
|
|
20202
20569
|
const sandboxClient = providerAsSandboxClient(provider, {
|
|
20203
20570
|
defaults: {
|
|
20204
20571
|
...providerSeam.defaults ?? {},
|
|
20205
20572
|
signal: seamed.signal
|
|
20206
20573
|
},
|
|
20207
20574
|
requireTerminalEvent: providerSeam.requireTerminalEvent,
|
|
20208
|
-
requireSession: true
|
|
20575
|
+
requireSession: true,
|
|
20576
|
+
...providerSeam.workspaceRetention === void 0 ? {} : {
|
|
20577
|
+
workspaceRetention: providerSeam.workspaceRetention,
|
|
20578
|
+
retentionIdentity: {
|
|
20579
|
+
executionId: seamed.node?.nodeId ?? `provider-run-${randomUUID()}`,
|
|
20580
|
+
profile: spec.profile,
|
|
20581
|
+
...seamed.node === void 0 ? {} : { node: seamed.node }
|
|
20582
|
+
},
|
|
20583
|
+
onWorkspaceCaptured: (receipt) => {
|
|
20584
|
+
workspaceCaptures.push(receipt);
|
|
20585
|
+
}
|
|
20586
|
+
}
|
|
20209
20587
|
});
|
|
20210
20588
|
const providerCtx = {
|
|
20211
20589
|
...seamed,
|
|
@@ -20213,6 +20591,8 @@ function createExecutor(config) {
|
|
|
20213
20591
|
...seamed.seams,
|
|
20214
20592
|
[sandboxSeamKey]: {
|
|
20215
20593
|
sandboxClient,
|
|
20594
|
+
failOnDestroyError: providerSeam.workspaceRetention !== void 0,
|
|
20595
|
+
...providerSeam.workspaceRetention === void 0 ? {} : { workspaceCaptures: () => workspaceCaptures },
|
|
20216
20596
|
steering: providerSeam.steering,
|
|
20217
20597
|
...providerSeam.promptOptions === void 0 ? {} : { loopCtx: { promptOptions: providerSeam.promptOptions } }
|
|
20218
20598
|
}
|
|
@@ -22672,13 +23052,23 @@ async function ownerWorkspaceRetentionFailures(events, nodeId, blobs) {
|
|
|
22672
23052
|
if (!("id" in event) || event.id !== nodeId) continue;
|
|
22673
23053
|
if (event.kind === "execution-input") {
|
|
22674
23054
|
flush();
|
|
22675
|
-
current = {
|
|
23055
|
+
current = {
|
|
23056
|
+
environmentIds: /* @__PURE__ */ new Set(),
|
|
23057
|
+
executionByEnvironment: /* @__PURE__ */ new Map()
|
|
23058
|
+
};
|
|
22676
23059
|
} else if (event.kind === "execution-admitted" && event.admission.phase === "environment") {
|
|
22677
23060
|
if (current?.result !== void 0) flush();
|
|
22678
|
-
current ??= {
|
|
23061
|
+
current ??= {
|
|
23062
|
+
environmentIds: /* @__PURE__ */ new Set(),
|
|
23063
|
+
executionByEnvironment: /* @__PURE__ */ new Map()
|
|
23064
|
+
};
|
|
22679
23065
|
current.environmentIds.add(event.admission.environmentId);
|
|
23066
|
+
current.executionByEnvironment.set(event.admission.environmentId, event.admission.executionId);
|
|
22680
23067
|
} else if (event.kind === "execution-result") {
|
|
22681
|
-
current ??= {
|
|
23068
|
+
current ??= {
|
|
23069
|
+
environmentIds: /* @__PURE__ */ new Set(),
|
|
23070
|
+
executionByEnvironment: /* @__PURE__ */ new Map()
|
|
23071
|
+
};
|
|
22682
23072
|
current.result = event;
|
|
22683
23073
|
}
|
|
22684
23074
|
}
|
|
@@ -22702,14 +23092,24 @@ async function ownerWorkspaceRetentionFailures(events, nodeId, blobs) {
|
|
|
22702
23092
|
} catch {
|
|
22703
23093
|
output = void 0;
|
|
22704
23094
|
}
|
|
22705
|
-
|
|
23095
|
+
const snapshot = output !== null && typeof output === "object" ? output.workspaceSnapshot : void 0;
|
|
23096
|
+
const environmentId = [...attempt.environmentIds][0];
|
|
23097
|
+
const executionId = attempt.executionByEnvironment.get(environmentId);
|
|
23098
|
+
if (!hasDurableWorkspaceCapture(output, snapshot, environmentId, executionId)) failures.add(environmentId);
|
|
22706
23099
|
}
|
|
22707
23100
|
return failures;
|
|
22708
23101
|
}
|
|
22709
|
-
/** A stored result
|
|
22710
|
-
function
|
|
22711
|
-
const parsed = agentCandidateWorkspaceSnapshotEvidenceSchema.safeParse(
|
|
22712
|
-
|
|
23102
|
+
/** A stored result authorizes cleanup only for the exact source and complete capture. */
|
|
23103
|
+
function hasDurableWorkspaceCapture(output, snapshot, environmentId, executionId) {
|
|
23104
|
+
const parsed = agentCandidateWorkspaceSnapshotEvidenceSchema.safeParse(snapshot);
|
|
23105
|
+
if (!parsed.success || !("locator" in parsed.data.manifest) || !("locator" in parsed.data.archive)) return false;
|
|
23106
|
+
if (output === null || typeof output !== "object") return false;
|
|
23107
|
+
const capture = output.workspaceCapture;
|
|
23108
|
+
if (capture === null || typeof capture !== "object") return false;
|
|
23109
|
+
const receipt = capture;
|
|
23110
|
+
if (receipt.environmentId !== environmentId || receipt.executionId !== executionId || receipt.coverageComplete !== true) return false;
|
|
23111
|
+
const linked = agentCandidateWorkspaceSnapshotEvidenceSchema.safeParse(receipt.snapshot);
|
|
23112
|
+
return linked.success && linked.data.digest === parsed.data.digest && JSON.stringify(linked.data.manifest) === JSON.stringify(parsed.data.manifest) && JSON.stringify(linked.data.archive) === JSON.stringify(parsed.data.archive);
|
|
22713
23113
|
}
|
|
22714
23114
|
/** Environment ids this owner's provider confirmed gone, from their teardown receipts. */
|
|
22715
23115
|
function destroyedEnvironmentIds(owned) {
|
|
@@ -28223,6 +28623,6 @@ function isNonEmptySpend(s) {
|
|
|
28223
28623
|
return s.iterations > 0 || s.tokens.input > 0 || s.tokens.output > 0 || s.usd > 0 || s.ms > 0 || s.tokensKnown === false || s.usdKnown === false || Object.values(s.resources ?? {}).some((resource) => resource.amount > 0 || !resource.known);
|
|
28224
28624
|
}
|
|
28225
28625
|
//#endregion
|
|
28226
|
-
export { bindScopeRetainedOwnerEnvironmentId as $,
|
|
28626
|
+
export { bindScopeRetainedOwnerEnvironmentId as $, executableAgentSpecSnapshot as $i, canonicalObservedModelParts as $n, sanitizeKnowledgeReadinessReport as $r, isTraceAnalysisStore as $t, driverExecutorFactory as A, zeroSpend as Aa, isNoEntError as Ai, executorFailure as An, readHarnessTranscript as Ar, cliWorktreeExecutor as At, recordScopeOwnerMaterialization as B, teardownSurfaces as Ba, knownMaterializationReceipt as Bi, createSandboxForSpec as Bn, buildLoopSpanNodes as Br, FileSpawnJournal as Bt, createContinuationKeeper as C, randomSuffix as Ca, promptResourceProfileMaterialization as Ci, claimsAuthority as Cn, RunCancellationReason as Cr, startRetainedInteractiveRun as Ct, passedItems as D, throwIfAborted as Da, unsupportedProfileDimensions as Di, peerMailVerbNames as Dn, captureHarnessTranscript as Dr, bindReusableExecutorExecutionId as Dt, failedItems as E, throwAbort as Ea, sandboxActProfileMaterialization as Ei, peerMailTools as En, runAbortable as Er, rollingDispatch as Et, beginScopeOwnerAttempt as F, abortError$2 as Fa, attestRuntimeOwnedScopeOwner as Fi, harnessUsageIsEmpty as Fn, traceContextToEnv as Fr, DEFAULT_SANDBOX_STEERING_MAX_TURNS as Ft, createWorkerSlots as G, runtimeOwnedExecutorExecutionBinding as Gi, probeSandboxCapabilities as Gn, generateSpanId as Gr, encodeResultBlob as Gt, restoreScopeOwnerAcceptedExecution as H, promptOptionsFromAgentTurnInput as Ha, providerAttemptEvidence as Hi, isTerminalDecision as Hn, createOpenInferenceFileExporter as Hr, InMemorySpawnJournal as Ht, createScope as I, awaitAbortable$1 as Ia, authoredProfileDigest as Ii, readCodexRolloutSession as In, defaultRedactor as Ir, createSteerableSandboxSession as It, isWaitOutcome as J, runtimeOwnedPendingExecutorMaterialization as Ji, captureBeforeDestroy as Jn, padTraceId as Jr, materializeTreeView as Jt, openSlotGroup as K, runtimeOwnedExecutorMaterialization as Ki, acquireSandbox as Kn, loopEventToOtelSpan as Kr, insideCursorNamespace as Kt, deriveNodeExecutionIdentity as L, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as La, finalizeRuntimeOwnedPendingExecutor as Li, bridgeRuntimeAttachmentsKey as Ln, defaultRedactorIdentityMaterial as Lr, createRouterTranscript as Lt, withDriverExecutor as M, resourceTelemetry as Ma, readCommittedJsonLines as Mi, bridgeModelRouteRefusal as Mn, createPropagatingTraceEmitter as Mr, createExecutorRegistry as Mt, SUBTREE_RESULT_LIMIT as N, withBudgetResources as Na, writeAllBytes as Ni, addHarnessUsage as Nn, mergeTraceEnv as Nr, snapshotExecutorConfig as Nt, verdictFromJudgeScore as O, unmeteredSpend as Oa, validateProfileMaterialization as Oi, isLiveNodeStatus as On, harnessTranscriptArtifact as Or, captureReusableExecutorConfig as Ot, assertRecursiveReservationPolicy as P, decodeHarnessUsage as Pa, attestRuntimeOwnedPendingExecutor as Pi, createCodexRolloutStoreReader as Pn, readTraceContextFromEnv as Pr, createWorktreeCliExecutor as Pt, waitUntil as Q, executableAgentProfileSnapshot as Qi, runBrainLoop as Qn, sanitizeAgentRuntimeEvent as Qr, captureWorkerTraceEvidence as Qt, meterRuntimeOwnedAccounting as R, armDeadlineTimer as Ra, inheritRuntimeOwnedExecutorAttestation as Ri, bridgeStopSignalKey as Rn, resolveRedactor as Rr, createInPlaceCliExecutor as Rt, composeContinuationNote as S, promptCacheTokenClasses as Sa, promptOnlyProfileMaterialization as Si, PEER_MAIL_WIRE_KEY as Sn, environmentGone as Sr, recoverRetainedInteractiveRun as St, expandQuestions as T, stringifySafe as Ta, renderUnsupported as Ti, isPeerMailEnvelope as Tn, linkAbort as Tr, queueOf as Tt, scopeOwnerExecutorNodeContext as U, providerMessageText as Ua, recordRuntimeOwnedDriveHarnessProviderEvidence as Ui, runAgentRounds as Un, createOtelExporter as Ur, SpawnEventIndex as Ut, recordScopeOwnerPause as V, promptFromAgentTurnInput as Va, newExecutionAttemptId as Vi, defaultSelectWinner as Vn, buildRuntimeEventOtelSpans as Vr, InMemoryResultBlobStore as Vt, settledToIteration as W, runtimeOwnedDriveHarnessProviderEvidence as Wi, createSandboxLineage as Wn, flatOtelSpan as Wr, assertContentAddress as Wt, timerAt as X, unknownExecutionBindingReceipt as Xi, readPromptOptions as Xn, createRuntimeEventCollector as Xr, replaySpawnTree as Xt, pollFor as Y, runtimeOwnedScopeOwnerRuntime as Yi, assertBoxlessPromptOptions as Yn, toOtelAttributes as Yr, pendingWaits as Yt, validateWaitSpec as Z, unknownMaterializationReceipt as Zi, routerBrain as Zn, createRuntimeStreamEventCollector as Zr, WORKER_TOOL_TRACE_SCHEMA_VERSION as Zt, CheckUnavailableError as _, chargedTokens as _a, defineProfileMaterializationContract as _i, createActivityLog as _n, recoverRetainedRun as _r, attachWorker as _t, collectDelivered as a, canonicalStreamEventFromSandboxEvent as aa, removeWorktree as ai, createBudgetPool as an, providerAsSandboxClient as ar, scopeRetainedOwnerContext as at, bestComposite as b, hasCompleteCacheBreakdown as ba, promptControlProfileMaterialization as bi, AUTHORITY_MARKERS as bn, retainedCreateMaterial as br, workerInteractiveBindingsDir as bt, runTree as c, extractLlmCallEvent as ca, harnessInvocation as ci, spendFromUsageEvents as cn, unavailablePauseMs as cr, scopeRetainedOwnerRestorePoint as ct, classifyDriverFailure as d, mapSandboxToolEvent as da, parseCodexTokenUsage as di, readWorkerTraceContext as dn, decodeToolPart as dr, environmentReader as dt, detachedFrozen as ea, sanitizeRuntimeStreamEvent as ei, parseWorkerToolTraceArtifact as en, observedModelMatchesDeclared as er, bindScopeRetainedOwnerProvider as et, runDriverWithRetry as f, notifySandboxEventObserver as fa, CodexExecutionDiagnosticError as fi, workerTraceEnv as fn, sandboxSessionTraceSource as fr, hostDirectoryReader as ft, CONTINUATION_FACTS as g, addSpend as ga, controlProfileMaterialization as gi, DEFAULT_STALL_AFTER_MS as gn, reconnectRetainedRun as gr, workerInteractiveAdmissionFile as gt, CONTINUATIONS_DIR as h, sumSandboxUsage as ha, assertProfileMaterialization as hi, taskToPrompt as hn, errMessage as hr, readWorkerInteractiveAdmissions as ht, bestDelivered as i, assertSandboxServedModel as ia, createWorktree as ii, assertValidBudget as in, providerAsExecutor as ir, reconcileScopeRetainedOwnerEnvironment as it, isDriverSpec as j, addResourceSpend as ja, prepareJsonlAppend as ji, bridgeAdmissionRefusal as jn, contentAddress as jr, createExecutor as jt, driverChild as k, withTimeout as ka, worktreeCliProfileMaterialization as ki, isTerminalNodeStatus as kn, persistHarnessTranscript as kr, cliInPlaceExecutor as kt, DriverAttemptsExhaustedError as l, isSandboxTerminalEvent as la, harnessSupportsReasoningEffort as li, spendFromUsageTotals as ln, unavailableSignalOfFailure as lr, scopeRetainedOwnerResult as lt, upstreamUnavailableSignal as m, sandboxProgressEvents as ma, AGENT_PROFILE_MATERIALIZATION_AXES as mi, workerTraceSeamKey as mn, retainedExecutorSeamKey as mr, interactiveAdmissionSeamKey as mt, createRootHandle as n, projectSandboxOutcome as na, runWorktreeHarness as ni, BudgetReconcileFault as nn, LEAF_CONTINUATION_TASK as nr, noteScopeRetainedOwnerCoordination as nt, pickBestDelivered as o, createSandboxToolPartState as oa, DEFAULT_LOCAL_HARNESS as oi, meterUsageEvent as on, resolveAgentEnvironmentProvider as or, scopeRetainedOwnerPriorSpend as ot, summarizeDriverAttempts as p, sandboxEventServedBackend as pa, terminateProcessTreeAndConfirm as pi, workerTraceHeaders as pn, registerRetainedExecutorPreparation as pr, resolveSpawnResourcePaths as pt, createWaitProbes as q, runtimeOwnedExecutorProviderEvidence as qi, SandboxEvidenceRetentionError as qn, padSpanId as qr, loadSpawnForest as qt, createSupervisor as r, readSandboxOutcome as ra, captureWorktreeDiff as ri, ReservationWaitRefused as rn, createAgentEnvironmentProviderRegistry as rr, prepareScopeRetainedOwnerTask as rt, runFinalizer as s, createSandboxUsageLedger as sa, LOCAL_HARNESSES as si, newUsageTotals as sn, sandboxClientAsProvider as sr, scopeRetainedOwnerResourceReader as st, DEFAULT_MAX_DEPTH as t, detachedSnapshot as ta, runSettledCommand as ti, workerTraceAnalysisStore as tn, DEFAULT_SANDBOX_IDLE_TIMEOUT_SECONDS as tr, consumeScopeRetainedOwnerResult as tt, HarnessTurnFailedError as u, mapSandboxEvent as ua, localHarnessExecutable as ui, WORKER_TRACE_PROPAGATION as un, createPushTraceSource as ur, SPAWN_RESOURCE_PATH_MAX_BYTES as ut, admitContinuationPolicy as v, cloneSpend as va, fullProfileMaterialization as vi, readWorkerProgress as vn, startRetainedRun as vr, readWorkerInteractiveBinding as vt, distillFindings as w, sleep as wa, renderProfileMaterializationIssues as wi, createPeerMailbox as wn, abortError as wr, freeSlots as wt, checkVerdictOf as x, isAbortError$2 as xa, promptModelProfileMaterialization as xi, DEFAULT_PEER_MAIL_LIMITS as xn, destroyInteractiveEnvironment as xr, reconnectRetainedInteractiveRun as xt, admitFinding as y, deleteBoxSafe as ya, profileMaterializationAxes$1 as yi, createInbox as yn, startRetainedRunInEnvironment as yr, workerInteractiveBindingFile as yt, meterRuntimeOwnedProviderAttempt as z, teardownExecutor as za, knownExecutionBindingReceipt as zi, TERMINAL_DECISIONS as zn, buildLoopOtelSpans as zr, FileResultBlobStore as zt };
|
|
28227
28627
|
|
|
28228
|
-
//# sourceMappingURL=supervisor-
|
|
28628
|
+
//# sourceMappingURL=supervisor-D4NnNHZd.js.map
|