@tangle-network/agent-runtime 0.277.0 → 0.280.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-CbxhVtVV.js → activation-C97Cq4Q_.js} +2 -2
- package/dist/{activation-CbxhVtVV.js.map → activation-C97Cq4Q_.js.map} +1 -1
- package/dist/{activation-puw9_ahP.d.ts → activation-y-60DXF4.d.ts} +140 -105
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/{coordination-driver-ZfUf-H4H.js → coordination-driver-CraAV-22.js} +2 -2
- package/dist/{coordination-driver-ZfUf-H4H.js.map → coordination-driver-CraAV-22.js.map} +1 -1
- package/dist/{delegate-DXOyzIq0.js → delegate-W1Ws_Wp0.js} +2 -2
- package/dist/{delegate-DXOyzIq0.js.map → delegate-W1Ws_Wp0.js.map} +1 -1
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +2 -2
- package/dist/{graph-sGWwXC6E.js → graph-DlL_X4HX.js} +4 -4
- package/dist/{graph-sGWwXC6E.js.map → graph-DlL_X4HX.js.map} +1 -1
- package/dist/{improvement-cycle-DQyN0__A.js → improvement-cycle-DXMU-2Y4.js} +649 -213
- package/dist/improvement-cycle-DXMU-2Y4.js.map +1 -0
- package/dist/{index-CmAFFnsd.d.ts → index-Dm8SHDGW.d.ts} +9 -7
- package/dist/index.d.ts +9 -9
- package/dist/index.js +55 -14
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +3 -3
- package/dist/intelligence.js +3 -3
- package/dist/kernel.d.ts +4 -4
- package/dist/kernel.js +8 -8
- package/dist/{loop-runner-bin-BTnEDWj3.js → loop-runner-bin-CT_-jSSg.js} +3 -3
- package/dist/{loop-runner-bin-BTnEDWj3.js.map → loop-runner-bin-CT_-jSSg.js.map} +1 -1
- package/dist/{loop-runner-bin-DGUASE9O.d.ts → loop-runner-bin-D6khQtoC.d.ts} +3 -3
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +5 -5
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-Gc8p4PBq.d.ts → openai-tools-H8QPhTVE.d.ts} +2 -2
- package/dist/platform.d.ts +91 -1
- package/dist/platform.js +162 -6
- package/dist/platform.js.map +1 -1
- package/dist/profiles.d.ts +2 -2
- package/dist/{provision-supervisor-BgjtrTlv.js → provision-supervisor-BEmE95Mt.js} +3 -3
- package/dist/{provision-supervisor-BgjtrTlv.js.map → provision-supervisor-BEmE95Mt.js.map} +1 -1
- package/dist/{runtime-DoFvrisL.js → runtime-Du7j-nDD.js} +8 -8
- package/dist/{runtime-DoFvrisL.js.map → runtime-Du7j-nDD.js.map} +1 -1
- package/dist/{server-D2d83_iS.js → server-DZvGznAn.js} +3 -3
- package/dist/{server-D2d83_iS.js.map → server-DZvGznAn.js.map} +1 -1
- package/dist/{stream-agent-turn-BqU5Sfbw.d.ts → stream-agent-turn-Bk79CnTw.d.ts} +2 -2
- package/dist/{structural-rollout-VR-j5t9d.js → structural-rollout-Cl4TvomY.js} +2 -2
- package/dist/{structural-rollout-VR-j5t9d.js.map → structural-rollout-Cl4TvomY.js.map} +1 -1
- package/dist/{substrate-CfE3oUB9.d.ts → substrate-CHQ5GYnU.d.ts} +2 -2
- package/dist/{supervise-BoCOUAmr.js → supervise-CWrLq2-F.js} +25 -11
- package/dist/supervise-CWrLq2-F.js.map +1 -0
- package/dist/{supervisor-CjNbOcLO.js → supervisor-BXXjVCbW.js} +378 -110
- package/dist/supervisor-BXXjVCbW.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-CI7ve2sA.d.ts → types-D56jQad-.d.ts} +70 -59
- package/package.json +10 -7
- package/dist/improvement-cycle-DQyN0__A.js.map +0 -1
- package/dist/supervise-BoCOUAmr.js.map +0 -1
- package/dist/supervisor-CjNbOcLO.js.map +0 -1
|
@@ -3,7 +3,7 @@ import { a as concreteProfileModel, c as profileModelExecutionSettings, d as age
|
|
|
3
3
|
import { i as verifyAgentCandidateWorkspaceArchive, x as verifyWorkspaceSnapshotArtifacts } from "./workspace-archive-C9lgf77y.js";
|
|
4
4
|
import { i as notifyRuntimeHookEvent } from "./runtime-hooks-tXpAarhW.js";
|
|
5
5
|
import { n as assertNoSymlinkDescendant, r as publishExclusiveDurableFile } from "./durable-file-DWQA4ooo.js";
|
|
6
|
-
import { AGENT_PROFILE_MATERIALIZATION_AXES, AgentEnvironmentCapabilitiesSchema, AgentExactRunControlRefSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStatusSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentNativeContextContinuationResultSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, AgentTurnInputSchema, AgentTurnResultSchema, CanonicalStreamEventSchema, ContextTransferRequestSchema, InteractionAcknowledgementSchema, InteractionResponseCommandSchema, NativeContextBoundaryProofSchema, NativeContextContinuationRequestSchema, REASONING_EFFORTS, RuntimeEventEnvelopeSchema, TerminalReplayWindowSchema, TerminalSessionRefSchema, WorkspaceRequestSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentNativeContextContinuationResultMatchesRequest, agentProfileSchema, agentRunCancellationAcknowledgementMatchesRequest, agentRunCancellationRequestDigest, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalWorkspaceCwd, exactAgentInteractiveSessionStart, harnessSystemPromptIntents, harnessTypeSchema, nativeContextContinuationTurnDigest, nativeReasoningControl, profileMaterializationAxes, profileMaterializationAxes as profileMaterializationAxes$1, renderInputPartsAsText, sha256DigestSchema, workspaceCwdPathForBase } from "@tangle-network/agent-interface";
|
|
6
|
+
import { AGENT_PROFILE_MATERIALIZATION_AXES, AgentEnvironmentCapabilitiesSchema, AgentExactRunControlRefSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStatusSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentNativeContextContinuationResultSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, AgentTurnInputSchema, AgentTurnResultSchema, CanonicalStreamEventSchema, ContextTransferRequestSchema, InteractionAcknowledgementSchema, InteractionResponseCommandSchema, NativeContextBoundaryProofSchema, NativeContextContinuationRequestSchema, REASONING_EFFORTS, RuntimeEventEnvelopeSchema, TerminalReplayWindowSchema, TerminalSessionRefSchema, WorkspaceRequestSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentNativeContextContinuationResultMatchesRequest, agentProfileSchema, agentRunCancellationAcknowledgementMatchesRequest, agentRunCancellationRequestDigest, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalWorkspaceCwd, exactAgentInteractiveSessionStart, harnessSystemPromptIntents, harnessTypeSchema, nativeContextContinuationTurnDigest, nativeReasoningControl, profileMaterializationAxes, profileMaterializationAxes as profileMaterializationAxes$1, renderInputPartsAsText, sha256DigestSchema, workspaceCheckpointRequestDigest, workspaceCheckpointResultMatchesRequest, workspaceCleanupAcknowledgementMatches, workspaceCleanupRequestDigest, workspaceCwdPathForBase } from "@tangle-network/agent-interface";
|
|
7
7
|
import { estimateCost, isModelPriced, isToolSpan, toolSpansToTraceAnalysisStore } from "@tangle-network/agent-eval";
|
|
8
8
|
import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
|
|
9
9
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
@@ -5839,71 +5839,48 @@ function generateSpanId() {
|
|
|
5839
5839
|
else for (let i = 0; i < 8; i++) bytes[i] = Math.floor(Math.random() * 256);
|
|
5840
5840
|
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
5841
5841
|
}
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
const DEFAULT_INTELLIGENCE_BASE = "https://intelligence.tangle.tools";
|
|
5842
|
+
//#endregion
|
|
5843
|
+
//#region src/redact.ts
|
|
5845
5844
|
/**
|
|
5846
|
-
*
|
|
5847
|
-
*
|
|
5848
|
-
*
|
|
5849
|
-
*
|
|
5850
|
-
*
|
|
5845
|
+
* Redaction for values that may leave the Runtime process. The built-in
|
|
5846
|
+
* redactor is agent-eval's redaction core (`@tangle-network/agent-eval/traces`,
|
|
5847
|
+
* default profile): credentials found by field name or value shape are
|
|
5848
|
+
* replaced whole, email, card, SSN and phone values in place, and token counts
|
|
5849
|
+
* such as `inputTokens` or `max_tokens` are kept. A customer with
|
|
5850
|
+
* domain-specific PII supplies their own `redact` hook.
|
|
5851
|
+
*
|
|
5852
|
+
* This is narrower than `src/sanitize.ts`, which drops fields of the runtime's
|
|
5853
|
+
* *event envelope* unless the caller opts in: here the value is opaque customer
|
|
5854
|
+
* payload, so the scrub is value-shaped, not schema-shaped.
|
|
5855
|
+
*
|
|
5856
|
+
* @experimental
|
|
5851
5857
|
*/
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
const url = `${(config?.base ?? (typeof process !== "undefined" ? process.env.TANGLE_INTELLIGENCE_URL : void 0) ?? DEFAULT_INTELLIGENCE_BASE).replace(/\/+$/, "")}/v1/ingest/eval-runs`;
|
|
5862
|
-
const count = events.length;
|
|
5863
|
-
const res = await fetch(url, {
|
|
5864
|
-
method: "POST",
|
|
5865
|
-
headers: {
|
|
5866
|
-
"content-type": "application/json",
|
|
5867
|
-
authorization: `Bearer ${apiKey}`,
|
|
5868
|
-
"X-Tangle-Wire-Version": INTELLIGENCE_WIRE_VERSION,
|
|
5869
|
-
...config?.idempotencyKey ? { "Idempotency-Key": config.idempotencyKey } : {}
|
|
5870
|
-
},
|
|
5871
|
-
body: JSON.stringify({
|
|
5872
|
-
wireVersion: INTELLIGENCE_WIRE_VERSION,
|
|
5873
|
-
events
|
|
5874
|
-
})
|
|
5875
|
-
});
|
|
5876
|
-
const invalid = (reason) => {
|
|
5877
|
-
throw new Error(`exportEvalRuns: ${reason} (HTTP ${res.status})`);
|
|
5878
|
-
};
|
|
5879
|
-
let parsed;
|
|
5880
|
-
try {
|
|
5881
|
-
parsed = await res.json();
|
|
5882
|
-
} catch {
|
|
5883
|
-
return invalid("Unreadable eval-runs acknowledgement");
|
|
5884
|
-
}
|
|
5885
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return invalid("Invalid eval-runs acknowledgement");
|
|
5886
|
-
const { accepted, rejected } = parsed;
|
|
5887
|
-
if (!Number.isSafeInteger(accepted) || accepted < 0 || accepted > count || !Array.isArray(rejected)) return invalid("Invalid eval-runs acknowledgement counts");
|
|
5888
|
-
const indices = /* @__PURE__ */ new Set();
|
|
5889
|
-
const validated = [];
|
|
5890
|
-
for (const item of rejected) {
|
|
5891
|
-
if (item === null || typeof item !== "object" || Array.isArray(item) || !Number.isSafeInteger(item.index) || item.index < 0 || item.index >= count || indices.has(item.index) || typeof item.reason !== "string" || !item.reason.trim()) return invalid("Invalid eval-runs acknowledgement rejection");
|
|
5892
|
-
indices.add(item.index);
|
|
5893
|
-
validated.push({
|
|
5894
|
-
index: item.index,
|
|
5895
|
-
reason: item.reason
|
|
5896
|
-
});
|
|
5897
|
-
}
|
|
5898
|
-
if (accepted + validated.length !== count) return invalid("Incomplete eval-runs acknowledgement");
|
|
5899
|
-
if (!res.ok && accepted !== 0) return invalid("Failed HTTP response claimed accepted eval-runs");
|
|
5858
|
+
/**
|
|
5859
|
+
* The built-in redactor. Cycle-safe, depth-bounded and total: it never throws
|
|
5860
|
+
* on customer input and never mutates it.
|
|
5861
|
+
*/
|
|
5862
|
+
function defaultRedactor(value) {
|
|
5863
|
+
return redact(value).value;
|
|
5864
|
+
}
|
|
5865
|
+
/** Stable identity input for saved work that depends on built-in redaction behavior. */
|
|
5866
|
+
function defaultRedactorIdentityMaterial() {
|
|
5900
5867
|
return {
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
rejected: validated
|
|
5868
|
+
core: "@tangle-network/agent-eval/traces redact",
|
|
5869
|
+
profile: "default",
|
|
5870
|
+
version: REDACTION_VERSION$1
|
|
5905
5871
|
};
|
|
5906
5872
|
}
|
|
5873
|
+
/**
|
|
5874
|
+
* Resolve the redactor a client uses. A caller-supplied hook handles
|
|
5875
|
+
* domain-specific values first, then the built-in scrubber still removes
|
|
5876
|
+
* credentials and personal data. Returning `false` is the explicit opt-out for
|
|
5877
|
+
* already-reviewed public values.
|
|
5878
|
+
*/
|
|
5879
|
+
function resolveRedactor(redact) {
|
|
5880
|
+
if (redact === false) return (value) => value;
|
|
5881
|
+
if (!redact) return defaultRedactor;
|
|
5882
|
+
return (value) => defaultRedactor(redact(value));
|
|
5883
|
+
}
|
|
5907
5884
|
//#endregion
|
|
5908
5885
|
//#region src/mcp/trace-propagation.ts
|
|
5909
5886
|
/**
|
|
@@ -5970,6 +5947,7 @@ function readTraceContextFromEnv(env = process.env) {
|
|
|
5970
5947
|
*/
|
|
5971
5948
|
function createPropagatingTraceEmitter(ctx) {
|
|
5972
5949
|
const exporter = createOtelExporter();
|
|
5950
|
+
const redactor = resolveRedactor(void 0);
|
|
5973
5951
|
const buffers = /* @__PURE__ */ new Map();
|
|
5974
5952
|
return {
|
|
5975
5953
|
emitter: { emit(event) {
|
|
@@ -5980,7 +5958,7 @@ function createPropagatingTraceEmitter(ctx) {
|
|
|
5980
5958
|
if (event.kind === "loop.ended") {
|
|
5981
5959
|
const events = buffers.get(event.runId) ?? [event];
|
|
5982
5960
|
buffers.delete(event.runId);
|
|
5983
|
-
for (const span of buildLoopOtelSpans(events, ctx.traceId, ctx.parentSpanId)) exporter.exportSpan(ctx.unpropagated === true ? {
|
|
5961
|
+
for (const span of buildLoopOtelSpans(events, ctx.traceId, ctx.parentSpanId, redactor)) exporter.exportSpan(ctx.unpropagated === true ? {
|
|
5984
5962
|
...span,
|
|
5985
5963
|
attributes: [...span.attributes ?? [], {
|
|
5986
5964
|
key: "tangle.trace.unpropagated",
|
|
@@ -6621,48 +6599,6 @@ function publicCreateOptions(create) {
|
|
|
6621
6599
|
};
|
|
6622
6600
|
}
|
|
6623
6601
|
//#endregion
|
|
6624
|
-
//#region src/redact.ts
|
|
6625
|
-
/**
|
|
6626
|
-
* Redaction for values that may leave the Runtime process. The built-in
|
|
6627
|
-
* redactor is agent-eval's redaction core (`@tangle-network/agent-eval/traces`,
|
|
6628
|
-
* default profile): credentials found by field name or value shape are
|
|
6629
|
-
* replaced whole, email, card, SSN and phone values in place, and token counts
|
|
6630
|
-
* such as `inputTokens` or `max_tokens` are kept. A customer with
|
|
6631
|
-
* domain-specific PII supplies their own `redact` hook.
|
|
6632
|
-
*
|
|
6633
|
-
* This is narrower than `src/sanitize.ts`, which drops fields of the runtime's
|
|
6634
|
-
* *event envelope* unless the caller opts in: here the value is opaque customer
|
|
6635
|
-
* payload, so the scrub is value-shaped, not schema-shaped.
|
|
6636
|
-
*
|
|
6637
|
-
* @experimental
|
|
6638
|
-
*/
|
|
6639
|
-
/**
|
|
6640
|
-
* The built-in redactor. Cycle-safe, depth-bounded and total: it never throws
|
|
6641
|
-
* on customer input and never mutates it.
|
|
6642
|
-
*/
|
|
6643
|
-
function defaultRedactor(value) {
|
|
6644
|
-
return redact(value).value;
|
|
6645
|
-
}
|
|
6646
|
-
/** Stable identity input for saved work that depends on built-in redaction behavior. */
|
|
6647
|
-
function defaultRedactorIdentityMaterial() {
|
|
6648
|
-
return {
|
|
6649
|
-
core: "@tangle-network/agent-eval/traces redact",
|
|
6650
|
-
profile: "default",
|
|
6651
|
-
version: REDACTION_VERSION$1
|
|
6652
|
-
};
|
|
6653
|
-
}
|
|
6654
|
-
/**
|
|
6655
|
-
* Resolve the redactor a client uses. A caller-supplied hook handles
|
|
6656
|
-
* domain-specific values first, then the built-in scrubber still removes
|
|
6657
|
-
* credentials and personal data. Returning `false` is the explicit opt-out for
|
|
6658
|
-
* already-reviewed public values.
|
|
6659
|
-
*/
|
|
6660
|
-
function resolveRedactor(redact) {
|
|
6661
|
-
if (redact === false) return (value) => value;
|
|
6662
|
-
if (!redact) return defaultRedactor;
|
|
6663
|
-
return (value) => defaultRedactor(redact(value));
|
|
6664
|
-
}
|
|
6665
|
-
//#endregion
|
|
6666
6602
|
//#region src/runtime/supervise/abortable.ts
|
|
6667
6603
|
/** Provenance of an explicit cancellation, preserved through every abort link. */
|
|
6668
6604
|
var RunCancellationReason = class extends Error {
|
|
@@ -8331,6 +8267,44 @@ function unavailablePauseMs(consecutive, policy = {}) {
|
|
|
8331
8267
|
return Math.min(ceiling, first * 2 ** Math.max(0, consecutive - 1));
|
|
8332
8268
|
}
|
|
8333
8269
|
//#endregion
|
|
8270
|
+
//#region src/runtime/supervise/workspace-checkpoint.ts
|
|
8271
|
+
/** Workspace-relative path of the marker Runtime writes before every checkpoint. */
|
|
8272
|
+
const WORKSPACE_CHECKPOINT_MARKER_PATH = ".agent-runtime-checkpoint";
|
|
8273
|
+
/** Bound on one checkpoint: environment lookup, marker write, and the provider operation. */
|
|
8274
|
+
const WORKSPACE_CHECKPOINT_TIMEOUT_MS = 12e4;
|
|
8275
|
+
/** Write the marker. False when the environment cannot take it, so no restore can be verified. */
|
|
8276
|
+
async function writeWorkspaceMarker(environment, marker, signal) {
|
|
8277
|
+
if (typeof environment.write !== "function") return false;
|
|
8278
|
+
try {
|
|
8279
|
+
await environment.write(marker.path, marker.content, { signal });
|
|
8280
|
+
return true;
|
|
8281
|
+
} catch {
|
|
8282
|
+
return false;
|
|
8283
|
+
}
|
|
8284
|
+
}
|
|
8285
|
+
/** Read the marker back from a restored environment and compare it byte for byte. */
|
|
8286
|
+
async function verifyWorkspaceMarker(environment, marker, signal) {
|
|
8287
|
+
if (marker === void 0) return {
|
|
8288
|
+
verified: false,
|
|
8289
|
+
detail: "the checkpoint has no marker: the source could not take one"
|
|
8290
|
+
};
|
|
8291
|
+
if (typeof environment.read !== "function") return {
|
|
8292
|
+
verified: false,
|
|
8293
|
+
detail: "the restored environment does not expose read"
|
|
8294
|
+
};
|
|
8295
|
+
try {
|
|
8296
|
+
return await environment.read(marker.path, { signal }) === marker.content ? { verified: true } : {
|
|
8297
|
+
verified: false,
|
|
8298
|
+
detail: "the marker in the restored environment differs from the checkpoint"
|
|
8299
|
+
};
|
|
8300
|
+
} catch (error) {
|
|
8301
|
+
return {
|
|
8302
|
+
verified: false,
|
|
8303
|
+
detail: `the marker could not be read: ${error instanceof Error ? error.message : String(error)}`.slice(0, 500)
|
|
8304
|
+
};
|
|
8305
|
+
}
|
|
8306
|
+
}
|
|
8307
|
+
//#endregion
|
|
8334
8308
|
//#region src/runtime/environment-provider.ts
|
|
8335
8309
|
var ValidationError = class extends Error {
|
|
8336
8310
|
constructor(message, options) {
|
|
@@ -9263,9 +9237,14 @@ async function providerExecutionSource(args, turn, signal) {
|
|
|
9263
9237
|
const priorSession = retention.priorSession;
|
|
9264
9238
|
const environmentKey = priorSession?.idempotencyKey ?? `runtime:${args.executionId}`;
|
|
9265
9239
|
const turnId = `${args.executionId}:turn:0`;
|
|
9240
|
+
const restore = priorSession === void 0 ? retention.restoreWorkspace : void 0;
|
|
9266
9241
|
const material = {
|
|
9267
9242
|
environment: {
|
|
9268
9243
|
...args.options.defaults,
|
|
9244
|
+
...restore === void 0 ? {} : { workspace: {
|
|
9245
|
+
...args.options.defaults?.workspace,
|
|
9246
|
+
checkpoint: restore.checkpoint
|
|
9247
|
+
} },
|
|
9269
9248
|
profile: args.createProfile,
|
|
9270
9249
|
idempotencyKey: environmentKey,
|
|
9271
9250
|
signal
|
|
@@ -9346,6 +9325,14 @@ async function providerExecutionSource(args, turn, signal) {
|
|
|
9346
9325
|
args.onPending(true);
|
|
9347
9326
|
const environment = await args.provider.get?.(handle.controlRef.environmentId);
|
|
9348
9327
|
if (!environment) throw new Error("retained provider environment is unavailable");
|
|
9328
|
+
if (restore !== void 0 && !args.recovering) {
|
|
9329
|
+
const found = await verifyWorkspaceMarker(environment, restore.marker, signal);
|
|
9330
|
+
await retention.onWorkspaceRestored?.({
|
|
9331
|
+
environmentId: environment.id,
|
|
9332
|
+
checkpoint: restore.checkpoint,
|
|
9333
|
+
...found
|
|
9334
|
+
});
|
|
9335
|
+
}
|
|
9349
9336
|
const session = exactSession(environment, handle.controlRef).session;
|
|
9350
9337
|
async function* events() {
|
|
9351
9338
|
let observationFailure;
|
|
@@ -17549,6 +17536,10 @@ const outsideKinds = /* @__PURE__ */ new Set([
|
|
|
17549
17536
|
"teardown-pending",
|
|
17550
17537
|
"teardown-confirmed",
|
|
17551
17538
|
"environment-teardown",
|
|
17539
|
+
"workspace-checkpoint-requested",
|
|
17540
|
+
"workspace-checkpoint",
|
|
17541
|
+
"workspace-checkpoint-cleanup",
|
|
17542
|
+
"workspace-restored",
|
|
17552
17543
|
"trace-unpropagated",
|
|
17553
17544
|
"paused",
|
|
17554
17545
|
"node-inputs-resolved",
|
|
@@ -17620,6 +17611,10 @@ async function replaySpawnTree(journal, blobs, root) {
|
|
|
17620
17611
|
if (ev.kind === "teardown-unconfirmed") continue;
|
|
17621
17612
|
if (ev.kind === "teardown-pending" || ev.kind === "teardown-confirmed") continue;
|
|
17622
17613
|
if (ev.kind === "environment-teardown") continue;
|
|
17614
|
+
if (ev.kind === "workspace-checkpoint-requested") continue;
|
|
17615
|
+
if (ev.kind === "workspace-checkpoint") continue;
|
|
17616
|
+
if (ev.kind === "workspace-checkpoint-cleanup") continue;
|
|
17617
|
+
if (ev.kind === "workspace-restored") continue;
|
|
17623
17618
|
if (ev.kind === "trace-unpropagated") continue;
|
|
17624
17619
|
if (ev.kind === "paused") continue;
|
|
17625
17620
|
if (ev.kind === "node-inputs-resolved") continue;
|
|
@@ -22201,6 +22196,23 @@ function registerScopeRetainedOwner(scope, args) {
|
|
|
22201
22196
|
},
|
|
22202
22197
|
preserveEnvironment: true,
|
|
22203
22198
|
admissions,
|
|
22199
|
+
get restoreWorkspace() {
|
|
22200
|
+
return state.restore;
|
|
22201
|
+
},
|
|
22202
|
+
onWorkspaceRestored: async (receipt) => {
|
|
22203
|
+
await args.journal.appendEvent(args.rootId, {
|
|
22204
|
+
kind: "workspace-restored",
|
|
22205
|
+
id: args.nodeId,
|
|
22206
|
+
provider: receipt.checkpoint.provider,
|
|
22207
|
+
environmentId: receipt.environmentId,
|
|
22208
|
+
checkpointId: receipt.checkpoint.checkpointId,
|
|
22209
|
+
sourceEnvironmentId: receipt.checkpoint.source.environmentId,
|
|
22210
|
+
verified: receipt.verified,
|
|
22211
|
+
...receipt.detail === void 0 ? {} : { detail: receipt.detail },
|
|
22212
|
+
seq: state.nextSequence(),
|
|
22213
|
+
at: new Date(args.now()).toISOString()
|
|
22214
|
+
});
|
|
22215
|
+
},
|
|
22204
22216
|
onAdmission: async (admission) => {
|
|
22205
22217
|
scope.signal.throwIfAborted();
|
|
22206
22218
|
const prior = admissions.find((record) => record.phase === admission.phase);
|
|
@@ -22335,6 +22347,222 @@ function scopeRetainedOwnerResourceReader(scope) {
|
|
|
22335
22347
|
}
|
|
22336
22348
|
};
|
|
22337
22349
|
}
|
|
22350
|
+
/**
|
|
22351
|
+
* Note that the owner's manager made a coordination call, and checkpoint its workspace when the
|
|
22352
|
+
* last checkpoint is older than {@link WORKSPACE_CHECKPOINT_MIN_INTERVAL_MS}.
|
|
22353
|
+
*
|
|
22354
|
+
* A coordination call is where a manager commits work: it spawns, waits for, reads, or submits.
|
|
22355
|
+
* The checkpoint runs in the background and never delays the call. A failed checkpoint leaves the
|
|
22356
|
+
* previous one as the restore point; a provider or environment that cannot checkpoint stops the
|
|
22357
|
+
* attempts for this owner.
|
|
22358
|
+
*/
|
|
22359
|
+
function noteScopeRetainedOwnerCoordination(scope) {
|
|
22360
|
+
const state = owners.get(scope);
|
|
22361
|
+
if (state?.provider === void 0 || state.checkpointsUnavailable !== void 0) return;
|
|
22362
|
+
if (state.checkpointing !== void 0 || scope.signal.aborted) return;
|
|
22363
|
+
const now = state.args.now();
|
|
22364
|
+
if (state.lastCheckpointAt !== void 0 && now - state.lastCheckpointAt < 6e4) return;
|
|
22365
|
+
state.lastCheckpointAt = now;
|
|
22366
|
+
state.checkpointing = checkpointOwnerWorkspace(scope, state).catch(() => void 0).finally(() => {
|
|
22367
|
+
delete state.checkpointing;
|
|
22368
|
+
});
|
|
22369
|
+
}
|
|
22370
|
+
async function checkpointOwnerWorkspace(scope, state) {
|
|
22371
|
+
const { provider, args } = state;
|
|
22372
|
+
if (provider === void 0) return;
|
|
22373
|
+
if (!provider.get) {
|
|
22374
|
+
state.checkpointsUnavailable = `provider ${provider.name} cannot reconstruct an environment`;
|
|
22375
|
+
return;
|
|
22376
|
+
}
|
|
22377
|
+
if ((await provider.capabilities()).create?.workspaceCheckpoint !== true) {
|
|
22378
|
+
state.checkpointsUnavailable = `provider ${provider.name} cannot create an environment from a checkpoint`;
|
|
22379
|
+
return;
|
|
22380
|
+
}
|
|
22381
|
+
const dispatched = [...state.admissions].reverse().find((admission) => admission.phase === "dispatched");
|
|
22382
|
+
if (dispatched?.phase !== "dispatched") return;
|
|
22383
|
+
const source = dispatched.controlRef;
|
|
22384
|
+
const signal = AbortSignal.any([scope.signal, AbortSignal.timeout(WORKSPACE_CHECKPOINT_TIMEOUT_MS)]);
|
|
22385
|
+
const get = provider.get.bind(provider);
|
|
22386
|
+
const environment = await runAbortable(() => get(source.environmentId), signal, "retained owner checkpoint timed out");
|
|
22387
|
+
if (environment === null || environment.id !== source.environmentId || environment.provider !== provider.name) return;
|
|
22388
|
+
const branching = environment.workspaceBranching;
|
|
22389
|
+
if (branching === void 0) {
|
|
22390
|
+
state.checkpointsUnavailable = `environment ${environment.id} offers no durable checkpoint`;
|
|
22391
|
+
return;
|
|
22392
|
+
}
|
|
22393
|
+
const seq = state.nextSequence();
|
|
22394
|
+
const at = new Date(args.now()).toISOString();
|
|
22395
|
+
const name = `owner-checkpoint-${seq}`;
|
|
22396
|
+
const marker = {
|
|
22397
|
+
path: WORKSPACE_CHECKPOINT_MARKER_PATH,
|
|
22398
|
+
content: `${JSON.stringify({
|
|
22399
|
+
node: args.nodeId,
|
|
22400
|
+
checkpoint: name,
|
|
22401
|
+
at
|
|
22402
|
+
})}\n`
|
|
22403
|
+
};
|
|
22404
|
+
const marked = await writeWorkspaceMarker(environment, marker, signal);
|
|
22405
|
+
const material = {
|
|
22406
|
+
source,
|
|
22407
|
+
name
|
|
22408
|
+
};
|
|
22409
|
+
const request = {
|
|
22410
|
+
...material,
|
|
22411
|
+
idempotencyKey: `${args.nodeId}:workspace-checkpoint:${seq}`,
|
|
22412
|
+
requestDigest: workspaceCheckpointRequestDigest(material)
|
|
22413
|
+
};
|
|
22414
|
+
state.checkpointHandles ??= /* @__PURE__ */ new Map();
|
|
22415
|
+
state.checkpointHandles.set(environment.id, branching);
|
|
22416
|
+
await args.journal.appendEvent(args.rootId, {
|
|
22417
|
+
kind: "workspace-checkpoint-requested",
|
|
22418
|
+
id: args.nodeId,
|
|
22419
|
+
provider: provider.name,
|
|
22420
|
+
environmentId: environment.id,
|
|
22421
|
+
request,
|
|
22422
|
+
...marked ? { marker } : {},
|
|
22423
|
+
seq,
|
|
22424
|
+
at
|
|
22425
|
+
});
|
|
22426
|
+
const result = await runAbortable(() => branching.checkpoint(request, { signal }), signal, "retained owner checkpoint timed out");
|
|
22427
|
+
if (result.status !== "created" && result.status !== "replayed") return;
|
|
22428
|
+
if (!workspaceCheckpointResultMatchesRequest(request, result)) return;
|
|
22429
|
+
scope.signal.throwIfAborted();
|
|
22430
|
+
await args.journal.appendEvent(args.rootId, {
|
|
22431
|
+
kind: "workspace-checkpoint",
|
|
22432
|
+
id: args.nodeId,
|
|
22433
|
+
provider: provider.name,
|
|
22434
|
+
environmentId: environment.id,
|
|
22435
|
+
checkpoint: result.checkpoint,
|
|
22436
|
+
...marked ? { marker } : {},
|
|
22437
|
+
seq: state.nextSequence(),
|
|
22438
|
+
at
|
|
22439
|
+
});
|
|
22440
|
+
await deleteCheckpoints(state, branching, pendingCheckpoints(await args.journal.loadTree(args.rootId) ?? [], state).filter((event) => event.environmentId === environment.id).slice(0, -2), signal);
|
|
22441
|
+
}
|
|
22442
|
+
/** Reconstruct authority for this source only; a replacement cannot own its snapshots. */
|
|
22443
|
+
async function checkpointHandle(state, sourceEnvironmentId, signal) {
|
|
22444
|
+
const cached = state.checkpointHandles?.get(sourceEnvironmentId);
|
|
22445
|
+
if (cached !== void 0) return cached;
|
|
22446
|
+
const provider = state.provider;
|
|
22447
|
+
if (provider === void 0) return void 0;
|
|
22448
|
+
try {
|
|
22449
|
+
const branching = await runAbortable(async () => {
|
|
22450
|
+
if (provider.workspaceBranching) return await provider.workspaceBranching.forEnvironment(sourceEnvironmentId, { signal }) ?? void 0;
|
|
22451
|
+
const source = await provider.get?.(sourceEnvironmentId);
|
|
22452
|
+
return source?.id === sourceEnvironmentId && source.provider === provider.name ? source.workspaceBranching : void 0;
|
|
22453
|
+
}, signal, "retained owner checkpoint handle lookup timed out");
|
|
22454
|
+
if (branching !== void 0) {
|
|
22455
|
+
state.checkpointHandles ??= /* @__PURE__ */ new Map();
|
|
22456
|
+
state.checkpointHandles.set(sourceEnvironmentId, branching);
|
|
22457
|
+
}
|
|
22458
|
+
return branching;
|
|
22459
|
+
} catch {
|
|
22460
|
+
return;
|
|
22461
|
+
}
|
|
22462
|
+
}
|
|
22463
|
+
/** An aborted observation cannot prove that the provider never created a snapshot. */
|
|
22464
|
+
async function reconcileCheckpointRequests(state, events) {
|
|
22465
|
+
const operationKey = (operation) => JSON.stringify([operation.idempotencyKey, operation.requestDigest]);
|
|
22466
|
+
const resolved = new Set(events.flatMap((event) => event.kind === "workspace-checkpoint" && event.id === state.args.nodeId && event.provider === state.provider?.name ? [operationKey(event.checkpoint)] : []));
|
|
22467
|
+
const pending = events.filter((event) => event.kind === "workspace-checkpoint-requested" && event.id === state.args.nodeId && event.provider === state.provider?.name && !resolved.has(operationKey(event.request)));
|
|
22468
|
+
const unconfirmed = [];
|
|
22469
|
+
for (const event of pending) {
|
|
22470
|
+
const signal = AbortSignal.timeout(3e4);
|
|
22471
|
+
try {
|
|
22472
|
+
const branching = await checkpointHandle(state, event.environmentId, signal);
|
|
22473
|
+
if (branching === void 0) throw new Error("source-scoped checkpoint handle unavailable");
|
|
22474
|
+
const result = await runAbortable(() => branching.lookupCheckpoint({
|
|
22475
|
+
idempotencyKey: event.request.idempotencyKey,
|
|
22476
|
+
requestDigest: event.request.requestDigest
|
|
22477
|
+
}, { signal }), signal, "retained owner checkpoint lookup timed out");
|
|
22478
|
+
if (result.status !== "found" || !workspaceCheckpointResultMatchesRequest(event.request, result)) throw new Error("checkpoint operation outcome is unresolved");
|
|
22479
|
+
const recovered = {
|
|
22480
|
+
kind: "workspace-checkpoint",
|
|
22481
|
+
id: event.id,
|
|
22482
|
+
provider: event.provider,
|
|
22483
|
+
environmentId: event.environmentId,
|
|
22484
|
+
checkpoint: result.checkpoint,
|
|
22485
|
+
...event.marker === void 0 ? {} : { marker: event.marker },
|
|
22486
|
+
seq: state.nextSequence(),
|
|
22487
|
+
at: event.at
|
|
22488
|
+
};
|
|
22489
|
+
await state.args.journal.appendEvent(state.args.rootId, recovered);
|
|
22490
|
+
events.push(recovered);
|
|
22491
|
+
} catch {
|
|
22492
|
+
unconfirmed.push(event);
|
|
22493
|
+
}
|
|
22494
|
+
}
|
|
22495
|
+
return unconfirmed;
|
|
22496
|
+
}
|
|
22497
|
+
function pendingCheckpoints(events, state) {
|
|
22498
|
+
const confirmed = new Set(events.flatMap((event) => event.kind === "workspace-checkpoint-cleanup" && event.id === state.args.nodeId && event.provider === state.provider?.name && event.confirmed ? [JSON.stringify([event.environmentId, event.checkpointId])] : []));
|
|
22499
|
+
return events.filter((event) => event.kind === "workspace-checkpoint" && event.id === state.args.nodeId && event.provider === state.provider?.name && !confirmed.has(JSON.stringify([event.environmentId, event.checkpoint.checkpointId])));
|
|
22500
|
+
}
|
|
22501
|
+
/** Only the source-scoped handle can attest deletion, including after its source is lost. */
|
|
22502
|
+
async function deleteCheckpoints(state, branching, checkpoints, signal) {
|
|
22503
|
+
const unconfirmed = [];
|
|
22504
|
+
for (const event of checkpoints) {
|
|
22505
|
+
const material = {
|
|
22506
|
+
kind: "checkpoint",
|
|
22507
|
+
targetId: event.checkpoint.checkpointId,
|
|
22508
|
+
provider: event.checkpoint.provider
|
|
22509
|
+
};
|
|
22510
|
+
const request = {
|
|
22511
|
+
...material,
|
|
22512
|
+
operationId: `${event.checkpoint.idempotencyKey}:delete`,
|
|
22513
|
+
requestDigest: workspaceCleanupRequestDigest(material)
|
|
22514
|
+
};
|
|
22515
|
+
let confirmed = false;
|
|
22516
|
+
try {
|
|
22517
|
+
if (branching === void 0) throw new Error("source-scoped checkpoint handle unavailable");
|
|
22518
|
+
const acknowledgement = await runAbortable(() => branching.deleteCheckpoint(request, { signal }), signal, "retained owner checkpoint cleanup timed out");
|
|
22519
|
+
confirmed = workspaceCleanupAcknowledgementMatches(request, acknowledgement) && (acknowledgement.status === "deleted" || acknowledgement.status === "already_absent");
|
|
22520
|
+
} catch {}
|
|
22521
|
+
if (!confirmed) unconfirmed.push(event);
|
|
22522
|
+
await state.args.journal.appendEvent(state.args.rootId, {
|
|
22523
|
+
kind: "workspace-checkpoint-cleanup",
|
|
22524
|
+
id: state.args.nodeId,
|
|
22525
|
+
provider: event.provider,
|
|
22526
|
+
environmentId: event.environmentId,
|
|
22527
|
+
checkpointId: event.checkpoint.checkpointId,
|
|
22528
|
+
confirmed,
|
|
22529
|
+
seq: state.nextSequence(),
|
|
22530
|
+
at: new Date(state.args.now()).toISOString()
|
|
22531
|
+
});
|
|
22532
|
+
}
|
|
22533
|
+
return unconfirmed;
|
|
22534
|
+
}
|
|
22535
|
+
/**
|
|
22536
|
+
* The checkpoint a new environment of this owner starts from: the latest one journaled before
|
|
22537
|
+
* the invocation's input, taken from an environment the provider has since lost. Only such an
|
|
22538
|
+
* environment needs one; a live environment is continued, never copied.
|
|
22539
|
+
*/
|
|
22540
|
+
function restoreBefore(owned, inputIndex) {
|
|
22541
|
+
const destroyed = destroyedEnvironmentIds(owned);
|
|
22542
|
+
return owned.slice(0, inputIndex < 0 ? owned.length : inputIndex).filter((event) => event.kind === "workspace-checkpoint" && destroyed.has(event.environmentId)).at(-1);
|
|
22543
|
+
}
|
|
22544
|
+
async function restoreCapable(provider) {
|
|
22545
|
+
if (provider === void 0) return false;
|
|
22546
|
+
try {
|
|
22547
|
+
return (await provider.capabilities()).create?.workspaceCheckpoint === true;
|
|
22548
|
+
} catch {
|
|
22549
|
+
return false;
|
|
22550
|
+
}
|
|
22551
|
+
}
|
|
22552
|
+
/**
|
|
22553
|
+
* What the owner's next new environment will hold of the lost one, read before the drive so the
|
|
22554
|
+
* re-entered director is told: the checkpoint's time, or undefined when there is nothing to
|
|
22555
|
+
* restore.
|
|
22556
|
+
*/
|
|
22557
|
+
async function scopeRetainedOwnerRestorePoint(scope) {
|
|
22558
|
+
const state = owners.get(scope);
|
|
22559
|
+
if (state === void 0 || !await restoreCapable(state.provider)) return void 0;
|
|
22560
|
+
const latest = restoreBefore((await state.args.journal.loadTree(state.args.rootId) ?? []).filter((event) => event.id === state.args.nodeId), -1);
|
|
22561
|
+
return latest === void 0 ? void 0 : {
|
|
22562
|
+
checkpointId: latest.checkpoint.checkpointId,
|
|
22563
|
+
takenAt: latest.at
|
|
22564
|
+
};
|
|
22565
|
+
}
|
|
22338
22566
|
/** @internal Whether another owner release could still destroy what the last one left. */
|
|
22339
22567
|
function retainedOwnerReleaseRetriable(scope) {
|
|
22340
22568
|
return owners.get(scope)?.releaseRetriable ?? false;
|
|
@@ -22344,7 +22572,11 @@ async function releaseScopeRetainedOwnerEnvironment(scope) {
|
|
|
22344
22572
|
const state = owners.get(scope);
|
|
22345
22573
|
if (!state?.provider) return [];
|
|
22346
22574
|
const { provider, args } = state;
|
|
22347
|
-
|
|
22575
|
+
state.checkpointsUnavailable ??= "released";
|
|
22576
|
+
await state.checkpointing?.catch(() => void 0);
|
|
22577
|
+
const events = [...await args.journal.loadTree(args.rootId) ?? []];
|
|
22578
|
+
const requestFailures = await reconcileCheckpointRequests(state, events);
|
|
22579
|
+
const pendingSources = new Set(requestFailures.map((event) => event.environmentId));
|
|
22348
22580
|
const released = new Set(events.flatMap((event) => event.kind === "environment-teardown" && event.id === args.nodeId && event.provider === provider.name && event.destroyed ? [event.environmentId] : []));
|
|
22349
22581
|
const environments = new Set(events.flatMap((event) => event.id === args.nodeId && event.kind === "execution-admitted" && event.admission.phase === "environment" ? [event.admission.environmentId] : []));
|
|
22350
22582
|
const retentionFailures = state.workspaceRetention || events.some((event) => event.kind === "execution-input" && event.id === args.nodeId && event.workspaceRetention === true) ? await ownerWorkspaceRetentionFailures(events, args.nodeId, args.blobs) : /* @__PURE__ */ new Set();
|
|
@@ -22352,12 +22584,20 @@ async function releaseScopeRetainedOwnerEnvironment(scope) {
|
|
|
22352
22584
|
const preserved = [];
|
|
22353
22585
|
let lastDetail;
|
|
22354
22586
|
let retriable = false;
|
|
22587
|
+
const checkpointFailures = [];
|
|
22588
|
+
const pending = pendingCheckpoints(events, state).filter((event) => !retentionFailures.has(event.environmentId));
|
|
22589
|
+
for (const sourceEnvironmentId of new Set(pending.map((event) => event.environmentId))) {
|
|
22590
|
+
const signal = AbortSignal.timeout(3e4);
|
|
22591
|
+
const branching = await checkpointHandle(state, sourceEnvironmentId, signal);
|
|
22592
|
+
checkpointFailures.push(...await deleteCheckpoints(state, branching, pending.filter((event) => event.environmentId === sourceEnvironmentId), signal));
|
|
22593
|
+
}
|
|
22594
|
+
for (const event of checkpointFailures) pendingSources.add(event.environmentId);
|
|
22355
22595
|
for (const environmentId of environments) {
|
|
22356
22596
|
if (released.has(environmentId)) continue;
|
|
22357
22597
|
let destroyed = false;
|
|
22358
22598
|
let detail;
|
|
22359
|
-
if (retentionFailures.has(environmentId)) {
|
|
22360
|
-
detail = "provider workspace retention: source preserved because the owner execution has no verified workspace receipt";
|
|
22599
|
+
if (retentionFailures.has(environmentId) || pendingSources.has(environmentId)) {
|
|
22600
|
+
detail = pendingSources.has(environmentId) ? "checkpoint cleanup unresolved: source preserved for exact lookup and cleanup" : "provider workspace retention: source preserved because the owner execution has no verified workspace receipt";
|
|
22361
22601
|
preserved.push(environmentId);
|
|
22362
22602
|
lastDetail = detail;
|
|
22363
22603
|
} else {
|
|
@@ -22400,6 +22640,19 @@ async function releaseScopeRetainedOwnerEnvironment(scope) {
|
|
|
22400
22640
|
});
|
|
22401
22641
|
}
|
|
22402
22642
|
state.releaseRetriable = retriable;
|
|
22643
|
+
const checkpointTeardowns = [...checkpointFailures.map((event) => ({
|
|
22644
|
+
id: args.nodeId,
|
|
22645
|
+
label: "scope owner workspace checkpoint",
|
|
22646
|
+
runtime: provider.name,
|
|
22647
|
+
status: "done",
|
|
22648
|
+
detail: `checkpoint cleanup unconfirmed: ${event.checkpoint.checkpointId} from ${event.environmentId}`
|
|
22649
|
+
})), ...requestFailures.map((event) => ({
|
|
22650
|
+
id: args.nodeId,
|
|
22651
|
+
label: "scope owner checkpoint request",
|
|
22652
|
+
runtime: provider.name,
|
|
22653
|
+
status: "done",
|
|
22654
|
+
detail: `checkpoint request unresolved: ${event.request.idempotencyKey} from ${event.environmentId}`
|
|
22655
|
+
}))];
|
|
22403
22656
|
return unconfirmed.length > 0 || preserved.length > 0 ? [{
|
|
22404
22657
|
id: args.nodeId,
|
|
22405
22658
|
label: "scope owner",
|
|
@@ -22415,7 +22668,7 @@ async function releaseScopeRetainedOwnerEnvironment(scope) {
|
|
|
22415
22668
|
keptFor: "evidence"
|
|
22416
22669
|
})) },
|
|
22417
22670
|
...lastDetail === void 0 ? {} : { detail: lastDetail }
|
|
22418
|
-
}] :
|
|
22671
|
+
}, ...checkpointTeardowns] : checkpointTeardowns;
|
|
22419
22672
|
}
|
|
22420
22673
|
/** Group owner admissions by input and require a verified workspace receipt before deletion. */
|
|
22421
22674
|
async function ownerWorkspaceRetentionFailures(events, nodeId, blobs) {
|
|
@@ -22584,11 +22837,26 @@ async function prepareScopeRetainedOwnerTask(scope, task) {
|
|
|
22584
22837
|
}
|
|
22585
22838
|
if (state.priorSession !== void 0 && destroyed.has(state.priorSession.environmentId)) delete state.priorSession;
|
|
22586
22839
|
state.prepared = true;
|
|
22840
|
+
const capable = await restoreCapable(state.provider);
|
|
22841
|
+
const restoreFor = (inputIndex) => {
|
|
22842
|
+
if (!capable || state.priorSession !== void 0) return void 0;
|
|
22843
|
+
const point = restoreBefore(owned, inputIndex);
|
|
22844
|
+
return point === void 0 ? void 0 : {
|
|
22845
|
+
checkpoint: point.checkpoint,
|
|
22846
|
+
...point.marker === void 0 ? {} : { marker: point.marker }
|
|
22847
|
+
};
|
|
22848
|
+
};
|
|
22587
22849
|
if (state.taskRef !== void 0) {
|
|
22588
22850
|
const original = await args.blobs.get(state.taskRef);
|
|
22589
22851
|
if (original === void 0 || contentAddress(original) !== state.taskRef) throw new ValidationError$1("retained owner task is missing or corrupt");
|
|
22852
|
+
const restore = restoreFor(owned.findIndex((event) => event.kind === "execution-input" && event.seq === state.inputSequence));
|
|
22853
|
+
if (restore === void 0) delete state.restore;
|
|
22854
|
+
else state.restore = restore;
|
|
22590
22855
|
return original;
|
|
22591
22856
|
}
|
|
22857
|
+
const restore = restoreFor(-1);
|
|
22858
|
+
if (restore === void 0) delete state.restore;
|
|
22859
|
+
else state.restore = restore;
|
|
22592
22860
|
const snapshot = detachedSnapshot(task, "retained owner task");
|
|
22593
22861
|
const taskRef = contentAddress(snapshot);
|
|
22594
22862
|
await args.blobs.put(taskRef, snapshot);
|
|
@@ -27965,6 +28233,6 @@ function isNonEmptySpend(s) {
|
|
|
27965
28233
|
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);
|
|
27966
28234
|
}
|
|
27967
28235
|
//#endregion
|
|
27968
|
-
export { bindScopeRetainedOwnerProvider as $, detachedSnapshot as $i,
|
|
28236
|
+
export { bindScopeRetainedOwnerProvider as $, detachedSnapshot as $i, LEAF_CONTINUATION_TASK as $n, runWorktreeHarness as $r, parseWorkerToolTraceArtifact as $t, driverExecutorFactory as A, resourceTelemetry as Aa, readCommittedJsonLines as Ai, bridgeAdmissionRefusal as An, mergeTraceEnv as Ar, createExecutor as At, recordScopeOwnerMaterialization as B, promptOptionsFromAgentTurnInput as Ba, providerAttemptEvidence as Bi, defaultSelectWinner as Bn, createOtelExporter as Br, InMemoryResultBlobStore as Bt, createContinuationKeeper as C, stringifySafe as Ca, sandboxActProfileMaterialization as Ci, createPeerMailbox as Cn, runAbortable as Cr, freeSlots as Ct, passedItems as D, withTimeout as Da, isNoEntError as Di, isLiveNodeStatus as Dn, readHarnessTranscript as Dr, captureReusableExecutorConfig as Dt, failedItems as E, unmeteredSpend as Ea, worktreeCliProfileMaterialization as Ei, peerMailVerbNames as En, persistHarnessTranscript as Er, bindReusableExecutorExecutionId as Et, beginScopeOwnerAttempt as F, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as Fa, finalizeRuntimeOwnedPendingExecutor as Fi, readCodexRolloutSession as Fn, resolveRedactor as Fr, createSteerableSandboxSession as Ft, createWorkerSlots as G, runtimeOwnedExecutorProviderEvidence as Gi, acquireSandbox as Gn, padTraceId as Gr, insideCursorNamespace as Gt, restoreScopeOwnerAcceptedExecution as H, runtimeOwnedDriveHarnessProviderEvidence as Hi, runAgentRounds as Hn, generateSpanId as Hr, SpawnEventIndex as Ht, createScope as I, armDeadlineTimer as Ia, inheritRuntimeOwnedExecutorAttestation as Ii, bridgeRuntimeAttachmentsKey as In, buildLoopOtelSpans as Ir, createRouterTranscript as It, pollFor as J, unknownExecutionBindingReceipt as Ji, routerBrain as Jn, createRuntimeStreamEventCollector as Jr, pendingWaits as Jt, createWaitProbes as K, runtimeOwnedPendingExecutorMaterialization as Ki, assertBoxlessPromptOptions as Kn, toOtelAttributes as Kr, loadSpawnForest as Kt, deriveNodeExecutionIdentity as L, teardownExecutor as La, knownExecutionBindingReceipt as Li, bridgeStopSignalKey as Ln, buildLoopSpanNodes as Lr, createInPlaceCliExecutor as Lt, withDriverExecutor as M, decodeHarnessUsage as Ma, attestRuntimeOwnedPendingExecutor as Mi, addHarnessUsage as Mn, traceContextToEnv as Mr, snapshotExecutorConfig as Mt, SUBTREE_RESULT_LIMIT as N, abortError$2 as Na, attestRuntimeOwnedScopeOwner as Ni, createCodexRolloutStoreReader as Nn, defaultRedactor as Nr, createWorktreeCliExecutor as Nt, verdictFromJudgeScore as O, zeroSpend as Oa, parseCommittedJsonLines as Oi, isTerminalNodeStatus as On, contentAddress as Or, cliInPlaceExecutor as Ot, assertRecursiveReservationPolicy as P, awaitAbortable$1 as Pa, authoredProfileDigest as Pi, harnessUsageIsEmpty as Pn, defaultRedactorIdentityMaterial as Pr, DEFAULT_SANDBOX_STEERING_MAX_TURNS as Pt, bindScopeRetainedOwnerEnvironmentId as Q, detachedFrozen as Qi, DEFAULT_SANDBOX_IDLE_TIMEOUT_SECONDS as Qn, runSettledCommand as Qr, isTraceAnalysisStore as Qt, meterRuntimeOwnedAccounting as R, teardownSurfaces as Ra, knownMaterializationReceipt as Ri, TERMINAL_DECISIONS as Rn, buildRuntimeEventOtelSpans as Rr, FileResultBlobStore as Rt, composeContinuationNote as S, sleep as Sa, renderUnsupported as Si, claimsAuthority as Sn, linkAbort as Sr, startRetainedInteractiveRun as St, expandQuestions as T, throwIfAborted as Ta, validateProfileMaterialization as Ti, peerMailTools as Tn, harnessTranscriptArtifact as Tr, rollingDispatch as Tt, scopeOwnerExecutorNodeContext as U, runtimeOwnedExecutorExecutionBinding as Ui, createSandboxLineage as Un, loopEventToOtelSpan as Ur, assertContentAddress as Ut, recordScopeOwnerPause as V, providerMessageText as Va, recordRuntimeOwnedDriveHarnessProviderEvidence as Vi, isTerminalDecision as Vn, flatOtelSpan as Vr, InMemorySpawnJournal as Vt, settledToIteration as W, runtimeOwnedExecutorMaterialization as Wi, probeSandboxCapabilities as Wn, padSpanId as Wr, encodeResultBlob as Wt, validateWaitSpec as X, executableAgentProfileSnapshot as Xi, canonicalObservedModelParts as Xn, sanitizeKnowledgeReadinessReport as Xr, WORKER_TOOL_TRACE_SCHEMA_VERSION as Xt, timerAt as Y, unknownMaterializationReceipt as Yi, runBrainLoop as Yn, sanitizeAgentRuntimeEvent as Yr, replaySpawnTree as Yt, waitUntil as Z, executableAgentSpecSnapshot as Zi, observedModelMatchesDeclared as Zn, sanitizeRuntimeStreamEvent as Zr, captureWorkerTraceEvidence as Zt, CheckUnavailableError as _, deleteBoxSafe as _a, promptControlProfileMaterialization as _i, readWorkerProgress as _n, retainedCreateMaterial as _r, readWorkerInteractiveBinding as _t, collectDelivered as a, createSandboxUsageLedger as aa, harnessInvocation as ai, meterUsageEvent as an, unavailablePauseMs as ar, scopeRetainedOwnerPriorSpend as at, bestComposite as b, promptCacheTokenClasses as ba, promptResourceProfileMaterialization as bi, DEFAULT_PEER_MAIL_LIMITS as bn, RunCancellationReason as br, reconnectRetainedInteractiveRun as bt, runTree as c, mapSandboxEvent as ca, parseCodexTokenUsage as ci, spendFromUsageTotals as cn, decodeToolPart as cr, scopeRetainedOwnerResult as ct, classifyDriverFailure as d, sandboxEventServedBackend as da, AGENT_PROFILE_MATERIALIZATION_AXES as di, workerTraceEnv as dn, retainedExecutorSeamKey as dr, hostDirectoryReader as dt, projectSandboxOutcome as ea, captureWorktreeDiff as ei, workerTraceAnalysisStore as en, createAgentEnvironmentProviderRegistry as er, consumeScopeRetainedOwnerResult as et, runDriverWithRetry as f, sandboxProgressEvents as fa, assertProfileMaterialization as fi, workerTraceHeaders as fn, errMessage as fr, resolveSpawnResourcePaths as ft, CONTINUATION_FACTS as g, cloneSpend as ga, profileMaterializationAxes$1 as gi, createActivityLog as gn, startRetainedRunInEnvironment as gr, attachWorker as gt, CONTINUATIONS_DIR as h, chargedTokens as ha, fullProfileMaterialization as hi, DEFAULT_STALL_AFTER_MS as hn, startRetainedRun as hr, workerInteractiveAdmissionFile as ht, bestDelivered as i, createSandboxToolPartState as ia, LOCAL_HARNESSES as ii, createBudgetPool as in, sandboxClientAsProvider as ir, scopeRetainedOwnerContext as it, isDriverSpec as j, withBudgetResources as ja, writeAllBytes as ji, bridgeModelRouteRefusal as jn, readTraceContextFromEnv as jr, createExecutorRegistry as jt, driverChild as k, addResourceSpend as ka, prepareJsonlAppend as ki, executorFailure as kn, createPropagatingTraceEmitter as kr, cliWorktreeExecutor as kt, DriverAttemptsExhaustedError as l, mapSandboxToolEvent as la, CodexExecutionDiagnosticError as li, WORKER_TRACE_PROPAGATION as ln, sandboxSessionTraceSource as lr, SPAWN_RESOURCE_PATH_MAX_BYTES as lt, upstreamUnavailableSignal as m, addSpend as ma, defineProfileMaterializationContract as mi, taskToPrompt as mn, recoverRetainedRun as mr, readWorkerInteractiveAdmissions as mt, createRootHandle as n, assertSandboxServedModel as na, removeWorktree as ni, ReservationWaitRefused as nn, providerAsSandboxClient as nr, prepareScopeRetainedOwnerTask as nt, pickBestDelivered as o, extractLlmCallEvent as oa, harnessSupportsReasoningEffort as oi, newUsageTotals as on, unavailableSignalOfFailure as or, scopeRetainedOwnerResourceReader as ot, summarizeDriverAttempts as p, sumSandboxUsage as pa, controlProfileMaterialization as pi, workerTraceSeamKey as pn, reconnectRetainedRun as pr, interactiveAdmissionSeamKey as pt, isWaitOutcome as q, runtimeOwnedScopeOwnerRuntime as qi, readPromptOptions as qn, createRuntimeEventCollector as qr, materializeTreeView as qt, createSupervisor as r, canonicalStreamEventFromSandboxEvent as ra, DEFAULT_LOCAL_HARNESS as ri, assertValidBudget as rn, resolveAgentEnvironmentProvider as rr, reconcileScopeRetainedOwnerEnvironment as rt, runFinalizer as s, isSandboxTerminalEvent as sa, localHarnessExecutable as si, spendFromUsageEvents as sn, createPushTraceSource as sr, scopeRetainedOwnerRestorePoint as st, DEFAULT_MAX_DEPTH as t, readSandboxOutcome as ta, createWorktree as ti, BudgetReconcileFault as tn, providerAsExecutor as tr, noteScopeRetainedOwnerCoordination as tt, HarnessTurnFailedError as u, notifySandboxEventObserver as ua, terminateProcessTreeAndConfirm as ui, readWorkerTraceContext as un, registerRetainedExecutorPreparation as ur, environmentReader as ut, admitContinuationPolicy as v, hasCompleteCacheBreakdown as va, promptModelProfileMaterialization as vi, createInbox as vn, destroyInteractiveEnvironment as vr, workerInteractiveBindingFile as vt, distillFindings as w, throwAbort as wa, unsupportedProfileDimensions as wi, isPeerMailEnvelope as wn, captureHarnessTranscript as wr, queueOf as wt, checkVerdictOf as x, randomSuffix as xa, renderProfileMaterializationIssues as xi, PEER_MAIL_WIRE_KEY as xn, abortError as xr, recoverRetainedInteractiveRun as xt, admitFinding as y, isAbortError$2 as ya, promptOnlyProfileMaterialization as yi, AUTHORITY_MARKERS as yn, environmentGone as yr, workerInteractiveBindingsDir as yt, meterRuntimeOwnedProviderAttempt as z, promptFromAgentTurnInput as za, newExecutionAttemptId as zi, createSandboxForSpec as zn, createOpenInferenceFileExporter as zr, FileSpawnJournal as zt };
|
|
27969
28237
|
|
|
27970
|
-
//# sourceMappingURL=supervisor-
|
|
28238
|
+
//# sourceMappingURL=supervisor-BXXjVCbW.js.map
|