@tangle-network/agent-runtime 0.295.3 → 0.296.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-CkulncPi.js → activation-Bsa9KIms.js} +3 -3
- package/dist/{activation-CkulncPi.js.map → activation-Bsa9KIms.js.map} +1 -1
- package/dist/{activation-DZMqUGrJ.d.ts → activation-rMt8OhcX.d.ts} +3 -3
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/{bundle-CDR0caM4.js → bundle-C9v5TH_H.js} +2 -2
- package/dist/{bundle-CDR0caM4.js.map → bundle-C9v5TH_H.js.map} +1 -1
- package/dist/candidate-execution/index.js +5 -5
- package/dist/{coordination-driver-B_rF6bAa.js → coordination-driver-BTwCdKrl.js} +2 -2
- package/dist/{coordination-driver-B_rF6bAa.js.map → coordination-driver-BTwCdKrl.js.map} +1 -1
- package/dist/{delegate-_h6a-sZR.js → delegate-CXkgU67D.js} +2 -2
- package/dist/{delegate-_h6a-sZR.js.map → delegate-CXkgU67D.js.map} +1 -1
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +3 -3
- package/dist/{graph-CN9gCxcw.js → graph-CqKrLWkl.js} +4 -4
- package/dist/{graph-CN9gCxcw.js.map → graph-CqKrLWkl.js.map} +1 -1
- package/dist/{improvement-cycle-EMHB3l51.js → improvement-cycle-7rd18eW9.js} +6 -6
- package/dist/{improvement-cycle-EMHB3l51.js.map → improvement-cycle-7rd18eW9.js.map} +1 -1
- package/dist/{index-D5p4txpC.d.ts → index-3GzNNtI9.d.ts} +4 -4
- package/dist/index.d.ts +6 -6
- package/dist/index.js +9 -9
- package/dist/intelligence.d.ts +3 -3
- package/dist/intelligence.js +8 -8
- package/dist/kernel.d.ts +4 -4
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-CIxUa3W_.d.ts → loop-runner-bin-BjRHJLW9.d.ts} +3 -3
- package/dist/{loop-runner-bin-BK5brrNK.js → loop-runner-bin-CmduY4JY.js} +3 -3
- package/dist/{loop-runner-bin-BK5brrNK.js.map → loop-runner-bin-CmduY4JY.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +5 -5
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-Dlws03EW.d.ts → openai-tools-CrfETZkV.d.ts} +2 -2
- package/dist/{prepare-Dzkj4AGj.js → prepare-CGVNMb1o.js} +3 -3
- package/dist/{prepare-Dzkj4AGj.js.map → prepare-CGVNMb1o.js.map} +1 -1
- package/dist/{profile-BubsrYhR.js → profile-BetOB4_Q.js} +2 -2
- package/dist/{profile-BubsrYhR.js.map → profile-BetOB4_Q.js.map} +1 -1
- package/dist/profiles.d.ts +2 -2
- package/dist/{protected-model-port-_Daje74V.js → protected-model-port-CuVHkhti.js} +4 -4
- package/dist/{protected-model-port-_Daje74V.js.map → protected-model-port-CuVHkhti.js.map} +1 -1
- package/dist/{provision-supervisor-BJ6-8M97.js → provision-supervisor-B-7DnLBR.js} +3 -3
- package/dist/{provision-supervisor-BJ6-8M97.js.map → provision-supervisor-B-7DnLBR.js.map} +1 -1
- package/dist/{runtime-Bcx8STGY.js → runtime-DicgLBWl.js} +9 -9
- package/dist/{runtime-Bcx8STGY.js.map → runtime-DicgLBWl.js.map} +1 -1
- package/dist/{search-method-rGfFP5yr.js → search-method-CLfmCMeT.js} +3 -3
- package/dist/{search-method-rGfFP5yr.js.map → search-method-CLfmCMeT.js.map} +1 -1
- package/dist/{server-B-DKa3MD.js → server-DHHeobZh.js} +3 -3
- package/dist/{server-B-DKa3MD.js.map → server-DHHeobZh.js.map} +1 -1
- package/dist/{stream-agent-turn-D6lDcAYs.d.ts → stream-agent-turn-LDA8JK7E.d.ts} +5 -178
- package/dist/{substrate-VEJrCLxe.d.ts → substrate-Bd4FFbim.d.ts} +2 -2
- package/dist/{supervise-CIyd8B3f.js → supervise-B5r5oZZ1.js} +4 -4
- package/dist/{supervise-CIyd8B3f.js.map → supervise-B5r5oZZ1.js.map} +1 -1
- package/dist/{supervisor-DnoT3-_F.js → supervisor-Rov7xW0j.js} +409 -58
- package/dist/supervisor-Rov7xW0j.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +14 -14
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{types-C2MBdgd_.d.ts → types-CwGpKzG1.d.ts} +285 -9
- package/dist/{workspace-streams-D4TMTrJV.js → workspace-streams-D5gHJdTb.js} +78 -60
- package/dist/workspace-streams-D5gHJdTb.js.map +1 -0
- package/package.json +1 -1
- package/dist/supervisor-DnoT3-_F.js.map +0 -1
- package/dist/workspace-streams-D4TMTrJV.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { c as RetainedInteractiveAdmissionError, d as RetainedRunDispatchBindingError, f as RuntimeRunStateError, i as ConfigError, l as RetainedInteractiveBindingError, m as ValidationError$1, r as BackendTransportError, t as AgentEvalError$1, u as RetainedRunAdmissionError } from "./errors-DodWX-cb.js";
|
|
2
2
|
import { runTaskQueue } from "./task-queue.js";
|
|
3
3
|
import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, d as assertRouterAutoDeclaration, f as assertRouterAutoResponse, g as observedModelMatchesDeclared, h as observedModelHasSnapshot, l as profileProviderModel, m as mergeObservedModelIdentity, o as enforceTokenLimits, s as profileBridgeWireModel, t as assertExecutableAgentProfile, u as resolveRouterRetryPolicy } from "./model-policy-DydyWTQg.js";
|
|
4
|
-
import {
|
|
4
|
+
import { D as verifiedArtifactChunks, E as verifyWorkspaceSnapshotArtifacts, c as verifyAgentCandidateWorkspaceArchive, i as verifyAgentCandidateWorkspaceArtifacts, j as deepFreezeCandidate, r as readAgentCandidateWorkspaceArtifactFiles } from "./workspace-streams-D5gHJdTb.js";
|
|
5
5
|
import { n as assertNoSymlinkDescendant, r as publishExclusiveDurableFile } from "./durable-file-DWQA4ooo.js";
|
|
6
6
|
import { i as notifyRuntimeHookEvent } from "./runtime-hooks-tXpAarhW.js";
|
|
7
|
-
import { AGENT_PROFILE_MATERIALIZATION_AXES, AgentEnvironmentCapabilitiesSchema, AgentExactRunControlRefSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStatusSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentNativeContextContinuationResultSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, AgentTurnInputSchema, AgentTurnResultSchema, CanonicalStreamEventSchema, ContextTransferRequestSchema, InteractionAcknowledgementSchema, InteractionResponseCommandSchema, NativeContextBoundaryProofSchema, NativeContextContinuationRequestSchema, REASONING_EFFORTS, RuntimeEventEnvelopeSchema, TerminalReplayWindowSchema, TerminalSessionRefSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentNativeContextContinuationResultMatchesRequest, agentProfileSchema, agentRunCancellationAcknowledgementMatchesRequest, agentRunCancellationRequestDigest, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalWorkspaceCwd, exactAgentInteractiveSessionStart, harnessTypeSchema, nativeContextContinuationTurnDigest, nativeReasoningControl, profileMaterializationAxes, profileMaterializationAxes as profileMaterializationAxes$1, renderInputPartsAsText, sha256DigestSchema, workspaceCheckpointRequestDigest, workspaceCheckpointResultMatchesRequest, workspaceCleanupAcknowledgementMatches, workspaceCleanupRequestDigest } from "@tangle-network/agent-interface";
|
|
7
|
+
import { AGENT_PROFILE_MATERIALIZATION_AXES, AgentEnvironmentCapabilitiesSchema, AgentExactRunControlRefSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStatusSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentNativeContextContinuationResultSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, AgentTurnInputSchema, AgentTurnResultSchema, CanonicalStreamEventSchema, ContextTransferRequestSchema, InteractionAcknowledgementSchema, InteractionResponseCommandSchema, NativeContextBoundaryProofSchema, NativeContextContinuationRequestSchema, REASONING_EFFORTS, RuntimeEventEnvelopeSchema, TerminalReplayWindowSchema, TerminalSessionRefSchema, agentCandidateArtifactRefSchema, agentCandidateWorkspaceManifestMaterialSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentNativeContextContinuationResultMatchesRequest, agentProfileSchema, agentRunCancellationAcknowledgementMatchesRequest, agentRunCancellationRequestDigest, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalWorkspaceCwd, exactAgentInteractiveSessionStart, harnessTypeSchema, nativeContextContinuationTurnDigest, nativeReasoningControl, profileMaterializationAxes, profileMaterializationAxes as profileMaterializationAxes$1, renderInputPartsAsText, sha256DigestSchema, workspaceCheckpointRequestDigest, workspaceCheckpointResultMatchesRequest, workspaceCleanupAcknowledgementMatches, workspaceCleanupRequestDigest } from "@tangle-network/agent-interface";
|
|
8
8
|
import { estimateCost, isModelPriced, isToolSpan, toolSpansToTraceAnalysisStore } from "@tangle-network/agent-eval";
|
|
9
9
|
import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
|
|
10
10
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
@@ -17,8 +17,8 @@ import { homedir, hostname, tmpdir } from "node:os";
|
|
|
17
17
|
import { stripVTControlCharacters } from "node:util";
|
|
18
18
|
import { ATTR, deriveHexId, isW3CSpanId, isW3CTraceId } from "@tangle-network/agent-trace-contract";
|
|
19
19
|
import { REDACTION_VERSION as REDACTION_VERSION$1, redact } from "@tangle-network/agent-eval/traces";
|
|
20
|
-
import { Readable } from "node:stream";
|
|
21
20
|
import { z } from "zod";
|
|
21
|
+
import { Readable } from "node:stream";
|
|
22
22
|
import { SDKError, generateIdempotencyKey, withRetry } from "@tangle-network/agent-core";
|
|
23
23
|
import { collectAgentFinalMessageText, collectAgentResponseText } from "@tangle-network/sandbox";
|
|
24
24
|
import { request } from "node:http";
|
|
@@ -2011,18 +2011,82 @@ function readSandboxOutcome(value) {
|
|
|
2011
2011
|
//#endregion
|
|
2012
2012
|
//#region src/runtime/supervise/snapshot.ts
|
|
2013
2013
|
/** Deeply detach and freeze untrusted data at a runtime decision boundary. The clone prevents the
|
|
2014
|
-
* caller from mutating it later; the freeze prevents downstream code from mutating the snapshot.
|
|
2014
|
+
* caller from mutating it later; the freeze prevents downstream code from mutating the snapshot.
|
|
2015
|
+
* Strings are immutable, so the snapshot shares the caller's strings instead of copying them. */
|
|
2015
2016
|
function detachedSnapshot(value, context) {
|
|
2017
|
+
let clone;
|
|
2016
2018
|
try {
|
|
2017
|
-
|
|
2019
|
+
clone = structuredClone(value);
|
|
2018
2020
|
} catch (error) {
|
|
2019
2021
|
throw new ValidationError$1(`${context}: input must be structured-cloneable`, { cause: error });
|
|
2020
2022
|
}
|
|
2023
|
+
return deepFreeze(shareSourceStrings(value, clone));
|
|
2021
2024
|
}
|
|
2022
2025
|
/** Detach a value from its caller and freeze it, without the `ValidationError` framing
|
|
2023
2026
|
* {@link detachedSnapshot} adds. For a boundary that has already validated its input. */
|
|
2024
2027
|
function detachedFrozen(value) {
|
|
2025
|
-
return deepFreeze(structuredClone(value));
|
|
2028
|
+
return deepFreeze(shareSourceStrings(value, structuredClone(value)));
|
|
2029
|
+
}
|
|
2030
|
+
/**
|
|
2031
|
+
* Point each string in a fresh structured clone at the equal string in its source.
|
|
2032
|
+
*
|
|
2033
|
+
* `structuredClone` copies every string, and a copied string buys no isolation: only objects and
|
|
2034
|
+
* arrays can change through a shared reference. A spawned profile passes several boundaries, and
|
|
2035
|
+
* each one kept its own copy: in a reproduction of Discovery's hosted coordinator, a child profile
|
|
2036
|
+
* that mounts a 5.3 MB file packet was held four times per spawned child. A scope keeps every
|
|
2037
|
+
* child it spawned, so the heap grew about 22 MB per spawn, and hosted coordinators died with V8
|
|
2038
|
+
* heap OOM after 37 spawns.
|
|
2039
|
+
*
|
|
2040
|
+
* The walk pairs only own data properties of plain objects and arrays. Accessors, Maps, Sets and
|
|
2041
|
+
* other cloned types keep the clone's values. A string is replaced only by a string equal to it,
|
|
2042
|
+
* so the snapshot holds exactly the clone's value. The snapshot keeps the source's strings alive.
|
|
2043
|
+
*/
|
|
2044
|
+
function shareSourceStrings(source, clone) {
|
|
2045
|
+
const visited = /* @__PURE__ */ new Set();
|
|
2046
|
+
const visit = (from, to) => {
|
|
2047
|
+
if (from === null || to === null || typeof from !== "object" || typeof to !== "object") return;
|
|
2048
|
+
const array = Array.isArray(to);
|
|
2049
|
+
if (array !== Array.isArray(from)) return;
|
|
2050
|
+
if (!array && Object.getPrototypeOf(to) !== Object.prototype) return;
|
|
2051
|
+
if (visited.has(to)) return;
|
|
2052
|
+
visited.add(to);
|
|
2053
|
+
const target = to;
|
|
2054
|
+
for (const key of Object.keys(target)) {
|
|
2055
|
+
const own = Object.getOwnPropertyDescriptor(from, key);
|
|
2056
|
+
if (own === void 0 || !("value" in own)) continue;
|
|
2057
|
+
const cloned = target[key];
|
|
2058
|
+
if (typeof cloned === "string") {
|
|
2059
|
+
if (own.value === cloned) target[key] = own.value;
|
|
2060
|
+
} else visit(own.value, cloned);
|
|
2061
|
+
}
|
|
2062
|
+
};
|
|
2063
|
+
visit(source, clone);
|
|
2064
|
+
return clone;
|
|
2065
|
+
}
|
|
2066
|
+
/**
|
|
2067
|
+
* Replace each string in a freshly parsed JSON value with an equal string already in `pool`, and
|
|
2068
|
+
* add the new ones. One recovery pass parses every interrupted child's profile from its own blob,
|
|
2069
|
+
* so children that carry the same file packet would otherwise hold one copy each. The value is
|
|
2070
|
+
* updated in place, so it must belong to the caller; frozen objects are left as they are.
|
|
2071
|
+
*/
|
|
2072
|
+
function shareParsedStrings(value, pool) {
|
|
2073
|
+
const visit = (node) => {
|
|
2074
|
+
if (node === null || typeof node !== "object" || Object.isFrozen(node)) return;
|
|
2075
|
+
if (!Array.isArray(node) && Object.getPrototypeOf(node) !== Object.prototype) return;
|
|
2076
|
+
const target = node;
|
|
2077
|
+
for (const key of Object.keys(target)) {
|
|
2078
|
+
const item = target[key];
|
|
2079
|
+
if (typeof item !== "string") {
|
|
2080
|
+
visit(item);
|
|
2081
|
+
continue;
|
|
2082
|
+
}
|
|
2083
|
+
const shared = pool.get(item);
|
|
2084
|
+
if (shared === void 0) pool.set(item, item);
|
|
2085
|
+
else target[key] = shared;
|
|
2086
|
+
}
|
|
2087
|
+
};
|
|
2088
|
+
visit(value);
|
|
2089
|
+
return value;
|
|
2026
2090
|
}
|
|
2027
2091
|
function deepFreeze(value, seen = /* @__PURE__ */ new Set()) {
|
|
2028
2092
|
if (value === null || typeof value !== "object" || ArrayBuffer.isView(value) || seen.has(value)) return value;
|
|
@@ -6027,39 +6091,277 @@ function stableStringify(value) {
|
|
|
6027
6091
|
return `{${Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`).join(",")}}`;
|
|
6028
6092
|
}
|
|
6029
6093
|
//#endregion
|
|
6094
|
+
//#region src/runtime/retained-harness-transcript.ts
|
|
6095
|
+
const digest = z.custom((value) => typeof value === "string" && /^sha256:[0-9a-f]{64}$/.test(value));
|
|
6096
|
+
const count = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
6097
|
+
const text = z.string().min(1);
|
|
6098
|
+
const node = z.custom((value) => {
|
|
6099
|
+
if (value === null || typeof value !== "object") return false;
|
|
6100
|
+
return [
|
|
6101
|
+
"rootId",
|
|
6102
|
+
"parentId",
|
|
6103
|
+
"nodeId",
|
|
6104
|
+
"attemptId"
|
|
6105
|
+
].every((key) => typeof Reflect.get(value, key) === "string");
|
|
6106
|
+
});
|
|
6107
|
+
const sourceSchema = z.object({
|
|
6108
|
+
executionId: text,
|
|
6109
|
+
controlRef: AgentExactRunControlRefSchema.optional(),
|
|
6110
|
+
node: node.optional(),
|
|
6111
|
+
environmentId: text,
|
|
6112
|
+
profileDigest: digest,
|
|
6113
|
+
providerSessionId: text.nullable(),
|
|
6114
|
+
nativeSessionId: text.nullable(),
|
|
6115
|
+
coverageComplete: z.boolean(),
|
|
6116
|
+
incompleteReason: z.string().optional()
|
|
6117
|
+
});
|
|
6118
|
+
const attributionSchema = z.object({
|
|
6119
|
+
providerSessionId: text,
|
|
6120
|
+
sourceId: text.optional(),
|
|
6121
|
+
rootScope: z.enum(["session-home", "workspace-session"]),
|
|
6122
|
+
nativePath: text
|
|
6123
|
+
});
|
|
6124
|
+
const fileSchema = z.object({
|
|
6125
|
+
path: text,
|
|
6126
|
+
bytes: count,
|
|
6127
|
+
sha256: digest,
|
|
6128
|
+
attribution: attributionSchema
|
|
6129
|
+
});
|
|
6130
|
+
const skippedSchema = z.object({
|
|
6131
|
+
path: text,
|
|
6132
|
+
reason: text
|
|
6133
|
+
});
|
|
6134
|
+
const retainedSchema = z.object({
|
|
6135
|
+
kind: z.literal("retained-harness-transcript"),
|
|
6136
|
+
schemaVersion: z.literal(1),
|
|
6137
|
+
harness: text,
|
|
6138
|
+
source: sourceSchema,
|
|
6139
|
+
provider: z.string().optional(),
|
|
6140
|
+
capturedAt: z.string().optional(),
|
|
6141
|
+
snapshot: z.object({
|
|
6142
|
+
kind: z.literal("agent-candidate-workspace-snapshot"),
|
|
6143
|
+
digest,
|
|
6144
|
+
manifest: agentCandidateArtifactRefSchema,
|
|
6145
|
+
archive: agentCandidateArtifactRefSchema
|
|
6146
|
+
}),
|
|
6147
|
+
files: z.array(fileSchema),
|
|
6148
|
+
skipped: z.array(skippedSchema),
|
|
6149
|
+
missing: z.array(z.string())
|
|
6150
|
+
});
|
|
6151
|
+
const defaults = {
|
|
6152
|
+
maxFileBytes: 2 * 1024 * 1024,
|
|
6153
|
+
maxTotalBytes: 16 * 1024 * 1024,
|
|
6154
|
+
maxFiles: 1e3,
|
|
6155
|
+
maxManifestBytes: 16 * 1024 * 1024
|
|
6156
|
+
};
|
|
6157
|
+
/** Validate persisted descriptors before trusting their identity, locators, or inventory. */
|
|
6158
|
+
function parseRetainedHarnessTranscript(value) {
|
|
6159
|
+
const parsed = retainedSchema.safeParse(value);
|
|
6160
|
+
if (!parsed.success) throw new ValidationError$1(`Invalid retained harness transcript: ${parsed.error.message}`);
|
|
6161
|
+
const paths = /* @__PURE__ */ new Set();
|
|
6162
|
+
for (const file of parsed.data.files) {
|
|
6163
|
+
if (paths.has(file.path)) throw new ValidationError$1(`Retained transcript repeats native identity: ${file.path}`);
|
|
6164
|
+
paths.add(file.path);
|
|
6165
|
+
if (file.path !== nativeIdentity(file.attribution)) throw new ValidationError$1(`Retained transcript native identity does not match its attribution: ${file.path}`);
|
|
6166
|
+
}
|
|
6167
|
+
return deepFreezeCandidate(parsed.data);
|
|
6168
|
+
}
|
|
6169
|
+
function nativeIdentity(attribution) {
|
|
6170
|
+
return [
|
|
6171
|
+
attribution.providerSessionId,
|
|
6172
|
+
attribution.sourceId ?? "",
|
|
6173
|
+
attribution.rootScope
|
|
6174
|
+
].map(encodeURIComponent).join("/") + "/" + attribution.nativePath;
|
|
6175
|
+
}
|
|
6176
|
+
/** Describe already-verified retention, without reading the environment or copying archive bytes. */
|
|
6177
|
+
function retainHarnessTranscript(receipt, harness) {
|
|
6178
|
+
try {
|
|
6179
|
+
return retainedCapture(receipt, harness);
|
|
6180
|
+
} catch (error) {
|
|
6181
|
+
if (error instanceof ValidationError$1) throw error;
|
|
6182
|
+
throw new ValidationError$1(`Invalid retained transcript receipt: ${error instanceof Error ? error.message : String(error)}`);
|
|
6183
|
+
}
|
|
6184
|
+
}
|
|
6185
|
+
function retainedCapture(receipt, harness) {
|
|
6186
|
+
const { snapshot, provenance, ...source } = receipt;
|
|
6187
|
+
const files = [];
|
|
6188
|
+
const skipped = [];
|
|
6189
|
+
const missing = [...provenance.missing];
|
|
6190
|
+
for (const session of provenance.sessions ?? []) {
|
|
6191
|
+
if (session.executionId !== receipt.executionId || session.backendType !== harness) throw new ValidationError$1("Retained transcript session has a different execution or harness");
|
|
6192
|
+
if (!session.nativeStore) {
|
|
6193
|
+
missing.push(`Session ${session.id} native inventory unavailable`);
|
|
6194
|
+
continue;
|
|
6195
|
+
}
|
|
6196
|
+
if (!session.nativeStore.complete) missing.push(`Session ${session.id} native inventory incomplete`);
|
|
6197
|
+
for (const entry of session.nativeStore.entries) {
|
|
6198
|
+
if (entry.kind !== "file") continue;
|
|
6199
|
+
const attribution = {
|
|
6200
|
+
providerSessionId: session.id,
|
|
6201
|
+
...entry.sourceId === void 0 ? {} : { sourceId: entry.sourceId },
|
|
6202
|
+
rootScope: entry.rootScope,
|
|
6203
|
+
nativePath: entry.path
|
|
6204
|
+
};
|
|
6205
|
+
const parsed = fileSchema.safeParse({
|
|
6206
|
+
path: nativeIdentity(attribution),
|
|
6207
|
+
bytes: entry.sizeBytes,
|
|
6208
|
+
sha256: entry.sha256,
|
|
6209
|
+
attribution
|
|
6210
|
+
});
|
|
6211
|
+
if (parsed.success) files.push(parsed.data);
|
|
6212
|
+
else {
|
|
6213
|
+
const reason = `Native inventory cannot identify verified bytes: ${parsed.error.message}`;
|
|
6214
|
+
skipped.push({
|
|
6215
|
+
path: nativeIdentity(attribution),
|
|
6216
|
+
reason
|
|
6217
|
+
});
|
|
6218
|
+
missing.push(`${nativeIdentity(attribution)}: ${reason}`);
|
|
6219
|
+
}
|
|
6220
|
+
}
|
|
6221
|
+
for (const entry of session.nativeStore.excludedPaths) skipped.push({
|
|
6222
|
+
path: nativeIdentity({
|
|
6223
|
+
providerSessionId: session.id,
|
|
6224
|
+
...entry.sourceId === void 0 ? {} : { sourceId: entry.sourceId },
|
|
6225
|
+
rootScope: entry.rootScope,
|
|
6226
|
+
nativePath: entry.path
|
|
6227
|
+
}),
|
|
6228
|
+
reason: entry.reason
|
|
6229
|
+
});
|
|
6230
|
+
}
|
|
6231
|
+
if (files.length === 0) missing.push("No native files declared by provider capture");
|
|
6232
|
+
const descriptor = parseRetainedHarnessTranscript({
|
|
6233
|
+
kind: "retained-harness-transcript",
|
|
6234
|
+
schemaVersion: 1,
|
|
6235
|
+
harness,
|
|
6236
|
+
source,
|
|
6237
|
+
...provenance.provider === void 0 ? {} : { provider: provenance.provider },
|
|
6238
|
+
...provenance.capturedAt === void 0 ? {} : { capturedAt: provenance.capturedAt },
|
|
6239
|
+
snapshot: {
|
|
6240
|
+
kind: snapshot.kind,
|
|
6241
|
+
digest: snapshot.digest,
|
|
6242
|
+
manifest: snapshot.manifest,
|
|
6243
|
+
archive: snapshot.archive
|
|
6244
|
+
},
|
|
6245
|
+
files,
|
|
6246
|
+
skipped,
|
|
6247
|
+
missing
|
|
6248
|
+
});
|
|
6249
|
+
if (files.length === 0) return deepFreezeCandidate({
|
|
6250
|
+
status: "unavailable",
|
|
6251
|
+
reason: source.coverageComplete && skipped.length === 0 ? "no-transcript" : "nothing-carried",
|
|
6252
|
+
skipped: [...skipped, ...missing.map((reason) => ({
|
|
6253
|
+
path: receipt.executionId,
|
|
6254
|
+
reason
|
|
6255
|
+
}))]
|
|
6256
|
+
});
|
|
6257
|
+
return deepFreezeCandidate({
|
|
6258
|
+
status: "retained",
|
|
6259
|
+
descriptor,
|
|
6260
|
+
fileCount: files.length,
|
|
6261
|
+
totalBytes: files.reduce((sum, file) => sum + file.bytes, 0),
|
|
6262
|
+
skippedCount: skipped.length
|
|
6263
|
+
});
|
|
6264
|
+
}
|
|
6265
|
+
async function resolveHarnessTranscriptCapture(capture, options = {}) {
|
|
6266
|
+
if (capture.status === "unavailable") return void 0;
|
|
6267
|
+
if (capture.status === "captured") {
|
|
6268
|
+
for (const file of capture.artifact.files) if (Buffer.byteLength(file.content, "utf8") !== file.bytes) throw new ValidationError$1(`Transcript file has an invalid byte count: ${file.path}`);
|
|
6269
|
+
if (options.content !== false) return capture.artifact;
|
|
6270
|
+
return {
|
|
6271
|
+
...capture.artifact,
|
|
6272
|
+
files: capture.artifact.files.map(({ path, bytes, content }) => ({
|
|
6273
|
+
path,
|
|
6274
|
+
bytes,
|
|
6275
|
+
sha256: `sha256:${createHash("sha256").update(content).digest("hex")}`
|
|
6276
|
+
}))
|
|
6277
|
+
};
|
|
6278
|
+
}
|
|
6279
|
+
const descriptor = parseRetainedHarnessTranscript(capture.descriptor);
|
|
6280
|
+
if (options.content === false) {
|
|
6281
|
+
const { snapshot: _snapshot, kind: _kind, ...metadata } = descriptor;
|
|
6282
|
+
return metadata;
|
|
6283
|
+
}
|
|
6284
|
+
if (!options.artifacts) throw new ValidationError$1("Retained transcript content requires an ArtifactPort");
|
|
6285
|
+
const limits = {
|
|
6286
|
+
...defaults,
|
|
6287
|
+
...options.limits
|
|
6288
|
+
};
|
|
6289
|
+
for (const [name, value] of Object.entries(limits)) if (!Number.isSafeInteger(value) || value < 0) throw new ValidationError$1(`Invalid transcript read limit: ${name}`);
|
|
6290
|
+
if (descriptor.snapshot.manifest.byteLength > limits.maxManifestBytes) throw new ValidationError$1("Retained transcript manifest exceeds maxManifestBytes");
|
|
6291
|
+
const manifestChunks = [];
|
|
6292
|
+
for await (const chunk of verifiedArtifactChunks(descriptor.snapshot.manifest, options.artifacts, options.signal)) manifestChunks.push(Uint8Array.from(chunk));
|
|
6293
|
+
const material = agentCandidateWorkspaceManifestMaterialSchema.parse(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(manifestChunks))));
|
|
6294
|
+
const snapshot = {
|
|
6295
|
+
...descriptor.snapshot,
|
|
6296
|
+
material
|
|
6297
|
+
};
|
|
6298
|
+
const byContent = /* @__PURE__ */ new Map();
|
|
6299
|
+
for (const file of material.files) byContent.set(`${file.sha256}:${file.byteLength}`, file.path);
|
|
6300
|
+
const selected = [];
|
|
6301
|
+
const skipped = [...descriptor.skipped];
|
|
6302
|
+
let total = 0;
|
|
6303
|
+
for (const file of descriptor.files) {
|
|
6304
|
+
const archivePath = byContent.get(`${file.sha256}:${file.bytes}`);
|
|
6305
|
+
if (archivePath === void 0) throw new ValidationError$1(`Retained native file is missing from archive: ${file.path}`);
|
|
6306
|
+
const reason = file.bytes > limits.maxFileBytes ? "read-limit:maxFileBytes" : selected.length >= limits.maxFiles ? "read-limit:maxFiles" : total + file.bytes > limits.maxTotalBytes ? "read-limit:maxTotalBytes" : void 0;
|
|
6307
|
+
if (reason) skipped.push({
|
|
6308
|
+
path: file.path,
|
|
6309
|
+
reason
|
|
6310
|
+
});
|
|
6311
|
+
else {
|
|
6312
|
+
selected.push({
|
|
6313
|
+
file,
|
|
6314
|
+
archivePath
|
|
6315
|
+
});
|
|
6316
|
+
total += file.bytes;
|
|
6317
|
+
}
|
|
6318
|
+
}
|
|
6319
|
+
const contents = await readAgentCandidateWorkspaceArtifactFiles({
|
|
6320
|
+
role: "candidate",
|
|
6321
|
+
snapshot,
|
|
6322
|
+
artifacts: options.artifacts,
|
|
6323
|
+
paths: [...new Set(selected.map(({ archivePath }) => archivePath))],
|
|
6324
|
+
maxReadBytes: limits.maxTotalBytes,
|
|
6325
|
+
...options.workspaceLimits === void 0 ? {} : { limits: options.workspaceLimits },
|
|
6326
|
+
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
6327
|
+
});
|
|
6328
|
+
const files = [];
|
|
6329
|
+
for (const { file, archivePath } of selected) {
|
|
6330
|
+
const bytes = contents.get(archivePath);
|
|
6331
|
+
if (bytes === void 0) throw new ValidationError$1(`Verified native file was not returned: ${file.path}`);
|
|
6332
|
+
try {
|
|
6333
|
+
const content = new TextDecoder("utf-8", {
|
|
6334
|
+
fatal: true,
|
|
6335
|
+
ignoreBOM: true
|
|
6336
|
+
}).decode(bytes);
|
|
6337
|
+
if (content.includes("\0")) throw new Error("NUL in native file");
|
|
6338
|
+
files.push({
|
|
6339
|
+
path: file.path,
|
|
6340
|
+
bytes: file.bytes,
|
|
6341
|
+
content
|
|
6342
|
+
});
|
|
6343
|
+
} catch {
|
|
6344
|
+
skipped.push({
|
|
6345
|
+
path: file.path,
|
|
6346
|
+
reason: "binary-or-invalid-utf8; bytes remain retained in workspace archive"
|
|
6347
|
+
});
|
|
6348
|
+
}
|
|
6349
|
+
}
|
|
6350
|
+
return deepFreezeCandidate({
|
|
6351
|
+
schemaVersion: 1,
|
|
6352
|
+
harness: descriptor.harness,
|
|
6353
|
+
files,
|
|
6354
|
+
skipped
|
|
6355
|
+
});
|
|
6356
|
+
}
|
|
6357
|
+
//#endregion
|
|
6030
6358
|
//#region src/runtime/harness-transcript.ts
|
|
6031
6359
|
/**
|
|
6032
|
-
*
|
|
6033
|
-
*
|
|
6034
|
-
*
|
|
6035
|
-
*
|
|
6036
|
-
*
|
|
6037
|
-
* run record. The settled `trace` receipt covers the supervisor's own tool spans only —
|
|
6038
|
-
* `toolName`, `args`, `status`, `callId`, with `startedAt === endedAt` — so it carries no
|
|
6039
|
-
* assistant text, no reasoning, and no tool results, and `status: 'available'` never meant
|
|
6040
|
-
* the transcript survived. See tangle-network/agent-runtime#1214.
|
|
6041
|
-
*
|
|
6042
|
-
* The port already has what this needs: `AgentEnvironment.read?(path, { signal })`
|
|
6043
|
-
* returns a file's content as a string. Two constraints shape the design:
|
|
6044
|
-
*
|
|
6045
|
-
* - `read` is OPTIONAL and, on the Tangle provider, gated behind
|
|
6046
|
-
* `capabilities.workspace.read && box.read`. An environment without it is reported as
|
|
6047
|
-
* `unsupported` rather than silently producing an empty artifact — the whole point of
|
|
6048
|
-
* #1214 is that a receipt must not claim coverage it does not have.
|
|
6049
|
-
* - `read` takes one path and gives no directory listing, so enumeration goes through
|
|
6050
|
-
* `exec`. An environment with `read` but no `exec` cannot be enumerated and is also
|
|
6051
|
-
* reported, not guessed at.
|
|
6052
|
-
*
|
|
6053
|
-
* Storage is NOT the executor's business. The executor holds the in-memory capture and hands it
|
|
6054
|
-
* to the scope through `Executor.harnessTranscript()`; the scope persists it under its own
|
|
6055
|
-
* content ref with `persistHarnessTranscript` and settles the receipt. No provider or destroy
|
|
6056
|
-
* site learns about storage, the result blob never carries the files, and replay rehydrates a
|
|
6057
|
-
* pointer — the bytes are read only by `harnessTranscriptArtifact`, when someone opens them.
|
|
6058
|
-
*
|
|
6059
|
-
* Credentials are excluded by construction: enumeration lists only the transcript globs
|
|
6060
|
-
* for the harness, and any path matching DENY is dropped even if a producer moved a
|
|
6061
|
-
* credential file inside a session directory. The helper never reads `auth.json`,
|
|
6062
|
-
* `.credentials.json`, `credentials`, or a dotenv file.
|
|
6360
|
+
* Persist a harness transcript receipt beside the supervisor tool trace.
|
|
6361
|
+
* Provider workspace retention supplies an attributed descriptor whose bytes stay in the
|
|
6362
|
+
* original verified archive. Environments without retention use the bounded read/exec
|
|
6363
|
+
* fallback below. Neither path embeds transcript content in settlement events.
|
|
6364
|
+
* Readers request metadata without archive I/O, or explicitly resolve bounded text content.
|
|
6063
6365
|
*/
|
|
6064
6366
|
/** Where each harness keeps the session files that hold the conversation. */
|
|
6065
6367
|
const HARNESS_ROOTS = Object.freeze({
|
|
@@ -6138,6 +6440,7 @@ function readHarnessTranscript(executor) {
|
|
|
6138
6440
|
if (reported === void 0) return harnessTranscriptUnavailable("capture-did-not-run");
|
|
6139
6441
|
const capture = reported;
|
|
6140
6442
|
if (capture.status === "captured" && capture.artifact) return capture;
|
|
6443
|
+
if (capture.status === "retained" && capture.descriptor) return capture;
|
|
6141
6444
|
if (capture.status === "unavailable" && capture.reason) return capture;
|
|
6142
6445
|
return harnessTranscriptUnavailable("executor-exposes-no-transcript");
|
|
6143
6446
|
}
|
|
@@ -6446,32 +6749,58 @@ function harnessTranscriptFromLines(harness, name, lines) {
|
|
|
6446
6749
|
* source that collected it. A capture that is already unavailable passes through untouched.
|
|
6447
6750
|
*/
|
|
6448
6751
|
async function persistHarnessTranscript(capture, blobs) {
|
|
6449
|
-
if (capture.status
|
|
6450
|
-
const
|
|
6752
|
+
if (capture.status === "unavailable") return capture;
|
|
6753
|
+
const artifact = capture.status === "captured" ? capture.artifact : parseRetainedHarnessTranscript(capture.descriptor);
|
|
6754
|
+
const transcriptRef = contentAddress(artifact);
|
|
6451
6755
|
try {
|
|
6452
|
-
await blobs.put(transcriptRef,
|
|
6756
|
+
await blobs.put(transcriptRef, artifact);
|
|
6453
6757
|
} catch {
|
|
6454
6758
|
return unavailable$2("transcript-persistence-failed");
|
|
6455
6759
|
}
|
|
6456
6760
|
return Object.freeze({
|
|
6457
6761
|
status: "available",
|
|
6458
6762
|
transcriptRef,
|
|
6459
|
-
harness:
|
|
6763
|
+
harness: artifact.harness,
|
|
6460
6764
|
fileCount: capture.fileCount,
|
|
6461
6765
|
totalBytes: capture.totalBytes,
|
|
6462
|
-
skippedCount: capture.skippedCount
|
|
6766
|
+
skippedCount: capture.skippedCount,
|
|
6767
|
+
...capture.status === "retained" ? {
|
|
6768
|
+
coverageComplete: capture.descriptor.source.coverageComplete && capture.descriptor.missing.length === 0,
|
|
6769
|
+
missing: capture.descriptor.missing
|
|
6770
|
+
} : {}
|
|
6463
6771
|
});
|
|
6464
6772
|
}
|
|
6465
|
-
|
|
6466
|
-
* Rehydrate the exact persisted transcript a receipt points at, or `undefined` when the receipt
|
|
6467
|
-
* says there is none. Throws only when the receipt claims a blob the store does not hold — that
|
|
6468
|
-
* is corruption, not absence, and must not read as "no transcript".
|
|
6469
|
-
*/
|
|
6470
|
-
async function harnessTranscriptArtifact(evidence, blobs) {
|
|
6773
|
+
async function harnessTranscriptArtifact(evidence, blobs, options = {}) {
|
|
6471
6774
|
if (evidence.status !== "available") return void 0;
|
|
6472
6775
|
const raw = await blobs.get(evidence.transcriptRef);
|
|
6473
|
-
|
|
6474
|
-
|
|
6776
|
+
let capture;
|
|
6777
|
+
if (isHarnessTranscriptArtifact(raw)) capture = {
|
|
6778
|
+
status: "captured",
|
|
6779
|
+
artifact: raw,
|
|
6780
|
+
fileCount: raw.files.length,
|
|
6781
|
+
totalBytes: raw.files.reduce((sum, file) => sum + file.bytes, 0),
|
|
6782
|
+
skippedCount: raw.skipped.length
|
|
6783
|
+
};
|
|
6784
|
+
else {
|
|
6785
|
+
if (raw === null || typeof raw !== "object" || Reflect.get(raw, "kind") !== "retained-harness-transcript") throw new ValidationError$1(`harnessTranscriptArtifact: blob store has no transcript artifact for '${evidence.transcriptRef}'`);
|
|
6786
|
+
const descriptor = parseRetainedHarnessTranscript(raw);
|
|
6787
|
+
if (contentAddress(descriptor) !== evidence.transcriptRef) throw new ValidationError$1("Retained transcript descriptor does not match its transcriptRef");
|
|
6788
|
+
capture = {
|
|
6789
|
+
status: "retained",
|
|
6790
|
+
descriptor,
|
|
6791
|
+
fileCount: descriptor.files.length,
|
|
6792
|
+
totalBytes: descriptor.files.reduce((sum, file) => sum + file.bytes, 0),
|
|
6793
|
+
skippedCount: descriptor.skipped.length
|
|
6794
|
+
};
|
|
6795
|
+
}
|
|
6796
|
+
if (contentAddress(raw) !== evidence.transcriptRef) throw new ValidationError$1("Transcript artifact does not match its transcriptRef");
|
|
6797
|
+
return options.content === false ? resolveHarnessTranscriptCapture(capture, {
|
|
6798
|
+
...options,
|
|
6799
|
+
content: false
|
|
6800
|
+
}) : resolveHarnessTranscriptCapture(capture, {
|
|
6801
|
+
...options,
|
|
6802
|
+
content: true
|
|
6803
|
+
});
|
|
6475
6804
|
}
|
|
6476
6805
|
/** Every entry, not just the arrays: a blob with `files: [null]` is corruption, not a transcript. */
|
|
6477
6806
|
function isHarnessTranscriptArtifact(value) {
|
|
@@ -10891,6 +11220,28 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
10891
11220
|
workspaceProvenance = provenance;
|
|
10892
11221
|
workspaceCoverageComplete = coverageComplete ?? false;
|
|
10893
11222
|
workspaceIncompleteReason = incompleteReason;
|
|
11223
|
+
try {
|
|
11224
|
+
harnessTranscript = createProfile.harness === void 0 ? harnessTranscriptUnavailable("unknown-harness") : retainHarnessTranscript(providerWorkspaceCaptureReceipt({
|
|
11225
|
+
executionId: workspaceExecutionId,
|
|
11226
|
+
profile: createProfile,
|
|
11227
|
+
...node === void 0 ? {} : { node },
|
|
11228
|
+
workspaceControlRef: () => workspaceControlRef,
|
|
11229
|
+
workspaceProvenance: () => provenance,
|
|
11230
|
+
workspaceCoverage: () => ({
|
|
11231
|
+
complete: coverageComplete ?? false,
|
|
11232
|
+
incompleteReason
|
|
11233
|
+
})
|
|
11234
|
+
}, next, snapshot, providerSessionId), createProfile.harness);
|
|
11235
|
+
} catch (error) {
|
|
11236
|
+
harnessTranscript = {
|
|
11237
|
+
status: "unavailable",
|
|
11238
|
+
reason: "retained-projection-failed",
|
|
11239
|
+
skipped: [{
|
|
11240
|
+
path: workspaceExecutionId,
|
|
11241
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
11242
|
+
}]
|
|
11243
|
+
};
|
|
11244
|
+
}
|
|
10894
11245
|
if (workspaceRetention.requireCompleteProvenance && !coverageComplete) workspacePreservationRequired = true;
|
|
10895
11246
|
return snapshot;
|
|
10896
11247
|
}).catch((error) => {
|
|
@@ -11206,7 +11557,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
11206
11557
|
environment = target;
|
|
11207
11558
|
resetWorkspaceState(target);
|
|
11208
11559
|
}
|
|
11209
|
-
if (harnessTranscript.status !== "captured" && !releaseReadTried) {
|
|
11560
|
+
if (options.workspaceRetention === void 0 && harnessTranscript.status !== "captured" && !releaseReadTried) {
|
|
11210
11561
|
releaseReadTried = true;
|
|
11211
11562
|
const capture = await captureHarnessTranscript(target, profile.harness, signal);
|
|
11212
11563
|
if (capture.status === "captured") harnessTranscript = capture;
|
|
@@ -11350,8 +11701,7 @@ async function* streamProviderExecutor(args) {
|
|
|
11350
11701
|
}
|
|
11351
11702
|
if ((args.options.requireTerminalEvent ?? true) && !terminal) throw new ValidationError(`providerAsExecutor(${args.provider.name}): stream ended without a terminal result/done/status event`);
|
|
11352
11703
|
if (args.carried === void 0) yield { kind: "iteration" };
|
|
11353
|
-
|
|
11354
|
-
args.onHarnessTranscript(harnessTranscript);
|
|
11704
|
+
if (args.options.workspaceRetention === void 0) args.onHarnessTranscript(await captureHarnessTranscript(environment, args.profile.harness, linked));
|
|
11355
11705
|
const outcome = failures.finish();
|
|
11356
11706
|
const result = {
|
|
11357
11707
|
...resultFromEvents(archive.events(), text),
|
|
@@ -11436,7 +11786,7 @@ async function* streamProviderExecutor(args) {
|
|
|
11436
11786
|
if (captureError instanceof Error && captureError !== error) failure = captureError.cause === void 0 ? Object.assign(captureError, { cause: failure }) : new AggregateError([captureError, failure], captureError.message, { cause: captureError });
|
|
11437
11787
|
else failure = captureError;
|
|
11438
11788
|
}
|
|
11439
|
-
args.onHarnessTranscript(await captureHarnessTranscript(environment, args.profile.harness, linked));
|
|
11789
|
+
if (args.options.workspaceRetention === void 0) args.onHarnessTranscript(await captureHarnessTranscript(environment, args.profile.harness, linked));
|
|
11440
11790
|
} finally {
|
|
11441
11791
|
if ((!source.retained || settled !== void 0 && !failed) && !(source.retained && args.retention?.preserveEnvironment) && !(unavailable !== void 0 && !failed) && (args.options.destroyOnSettle ?? true)) {
|
|
11442
11792
|
const cleanup = await args.destroyEnvironment();
|
|
@@ -21893,6 +22243,7 @@ async function prepareInterruptedExecutors(opts, events, signal, now, parentId =
|
|
|
21893
22243
|
const terminal = new Set(events.filter(closesCursorSlot).map((event) => event.id));
|
|
21894
22244
|
const interrupted = events.filter((event) => event.kind === "spawned" && event.parent === parentId && !terminal.has(event.id));
|
|
21895
22245
|
const recoveries = [];
|
|
22246
|
+
const parsedStrings = /* @__PURE__ */ new Map();
|
|
21896
22247
|
const accepted = [];
|
|
21897
22248
|
const rootBudget = events.find((event) => event.kind === "spawned" && event.parent === void 0)?.budget;
|
|
21898
22249
|
for (const node of interrupted) {
|
|
@@ -21927,8 +22278,8 @@ async function prepareInterruptedExecutors(opts, events, signal, now, parentId =
|
|
|
21927
22278
|
if (!opts.recoverExecutor || admissions.length === 0 && !node.ownedTreeRoot && (opts.journal.appendEvents === void 0 || latestInput === void 0)) continue;
|
|
21928
22279
|
const taskRef = inputs[0]?.taskRef;
|
|
21929
22280
|
if (!node.profileRef || !taskRef || !node.identity?.profileDigest || !node.identity.taskDigest) throw new RuntimeRunStateError(`cannot recover '${node.id}' without exact profile and task bytes`);
|
|
21930
|
-
const profile = agentProfileSchema.parse(await opts.blobs.get(node.profileRef));
|
|
21931
|
-
const task = await opts.blobs.get(taskRef);
|
|
22281
|
+
const profile = shareParsedStrings(agentProfileSchema.parse(await opts.blobs.get(node.profileRef)), parsedStrings);
|
|
22282
|
+
const task = shareParsedStrings(await opts.blobs.get(taskRef), parsedStrings);
|
|
21932
22283
|
if (canonicalAgentProfileDigest(profile) !== node.identity.profileDigest || canonicalCandidateDigest(task) !== node.identity.taskDigest) throw new RuntimeRunStateError(`recovery inputs for '${node.id}' do not match its admitted identity`);
|
|
21933
22284
|
let prepared;
|
|
21934
22285
|
if (node.ownedTreeRoot !== void 0) {
|
|
@@ -28540,6 +28891,6 @@ function isNonEmptySpend(s) {
|
|
|
28540
28891
|
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);
|
|
28541
28892
|
}
|
|
28542
28893
|
//#endregion
|
|
28543
|
-
export { bindScopeRetainedOwnerProvider as $,
|
|
28894
|
+
export { bindScopeRetainedOwnerProvider as $, detachedFrozen as $i, parseWorkerToolTraceArtifact as $n, sanitizeRuntimeStreamEvent as $r, isPeerMailEnvelope as $t, driverExecutorFactory as A, addResourceSpend as Aa, prepareJsonlAppend as Ai, resolveAgentEnvironmentProvider as An, contentAddress as Ar, createExecutor as At, recordScopeOwnerDriverAttempt as B, promptFromAgentTurnInput as Ba, newExecutionAttemptId as Bi, InMemoryResultBlobStore as Bn, buildRuntimeEventOtelSpans as Br, workerTraceEnv as Bt, createContinuationKeeper as C, sleep as Ca, renderProfileMaterializationIssues as Ci, readPromptOptions as Cn, runAbortable as Cr, freeSlots as Ct, passedItems as D, unmeteredSpend as Da, validateProfileMaterialization as Di, createAgentEnvironmentProviderRegistry as Dn, readHarnessTranscript as Dr, captureReusableExecutorConfig as Dt, failedItems as E, throwIfAborted as Ea, unsupportedProfileDimensions as Ei, LEAF_CONTINUATION_TASK as En, persistHarnessTranscript as Er, bindReusableExecutorExecutionId as Et, beginScopeOwnerAttempt as F, awaitAbortable$1 as Fa, authoredProfileDigest as Fi, sandboxSessionTraceSource as Fn, defaultRedactor as Fr, createSteerableSandboxSession as Ft, settledToIteration as G, runtimeOwnedExecutorMaterialization as Gi, insideCursorNamespace as Gn, loopEventToOtelSpan as Gr, createActivityLog as Gt, recordScopeOwnerPause as H, providerMessageText as Ha, recordRuntimeOwnedDriveHarnessProviderEvidence as Hi, SpawnEventIndex as Hn, createOtelExporter as Hr, workerTraceSeamKey as Ht, createScope as I, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as Ia, finalizeRuntimeOwnedPendingExecutor as Ii, registerRetainedExecutorPreparation as In, defaultRedactorIdentityMaterial as Ir, createRouterTranscript as It, pollFor as J, runtimeOwnedScopeOwnerRuntime as Ji, pendingWaits as Jn, toOtelAttributes as Jr, AUTHORITY_MARKERS as Jt, createWaitProbes as K, runtimeOwnedExecutorProviderEvidence as Ki, loadSpawnForest as Kn, padSpanId as Kr, readWorkerProgress as Kt, deriveNodeExecutionIdentity as L, armDeadlineTimer as La, inheritRuntimeOwnedExecutorAttestation as Li, retainedExecutorSeamKey as Ln, resolveRedactor as Lr, createInPlaceCliExecutor as Lt, withDriverExecutor as M, withBudgetResources as Ma, writeAllBytes as Mi, unavailableSignalOfFailure as Mn, mergeTraceEnv as Mr, snapshotExecutorConfig as Mt, SUBTREE_RESULT_LIMIT as N, decodeHarnessUsage as Na, attestRuntimeOwnedPendingExecutor as Ni, createPushTraceSource as Nn, readTraceContextFromEnv as Nr, createWorktreeCliExecutor as Nt, verdictFromJudgeScore as O, withTimeout as Oa, worktreeCliProfileMaterialization as Oi, providerAsExecutor as On, resolveHarnessTranscriptCapture as Or, cliInPlaceExecutor as Ot, assertRecursiveReservationPolicy as P, abortError$2 as Pa, attestRuntimeOwnedScopeOwner as Pi, decodeToolPart as Pn, traceContextToEnv as Pr, DEFAULT_SANDBOX_STEERING_MAX_TURNS as Pt, bindScopeRetainedOwnerEnvironmentId as Q, executableAgentSpecSnapshot as Qi, isTraceAnalysisStore as Qn, sanitizeKnowledgeReadinessReport as Qr, createPeerMailbox as Qt, meterRuntimeOwnedAccounting as R, teardownExecutor as Ra, knownExecutionBindingReceipt as Ri, FileResultBlobStore as Rn, buildLoopOtelSpans as Rr, WORKER_TRACE_PROPAGATION as Rt, composeContinuationNote as S, randomSuffix as Sa, promptResourceProfileMaterialization as Si, assertBoxlessPromptOptions as Sn, linkAbort as Sr, startRetainedInteractiveRun as St, expandQuestions as T, throwAbort as Ta, sandboxActProfileMaterialization as Ti, runBrainLoop as Tn, harnessTranscriptArtifact as Tr, rollingDispatch as Tt, restoreScopeOwnerAcceptedExecution as U, runtimeOwnedDriveHarnessProviderEvidence as Ui, assertContentAddress as Un, flatOtelSpan as Ur, taskToPrompt as Ut, recordScopeOwnerMaterialization as V, promptOptionsFromAgentTurnInput as Va, providerAttemptEvidence as Vi, InMemorySpawnJournal as Vn, createOpenInferenceFileExporter as Vr, workerTraceHeaders as Vt, scopeOwnerExecutorNodeContext as W, runtimeOwnedExecutorExecutionBinding as Wi, encodeResultBlob as Wn, generateSpanId as Wr, DEFAULT_STALL_AFTER_MS as Wt, validateWaitSpec as X, unknownMaterializationReceipt as Xi, WORKER_TOOL_TRACE_SCHEMA_VERSION as Xn, createRuntimeStreamEventCollector as Xr, PEER_MAIL_WIRE_KEY as Xt, timerAt as Y, unknownExecutionBindingReceipt as Yi, replaySpawnTree as Yn, createRuntimeEventCollector as Yr, DEFAULT_PEER_MAIL_LIMITS as Yt, waitUntil as Z, executableAgentProfileSnapshot as Zi, captureWorkerTraceEvidence as Zn, sanitizeAgentRuntimeEvent as Zr, claimsAuthority as Zt, CheckUnavailableError as _, cloneSpend as _a, fullProfileMaterialization as _i, createSandboxLineage as _n, environmentGone as _r, readWorkerInteractiveBinding as _t, collectDelivered as a, createSandboxToolPartState as aa, DEFAULT_LOCAL_HARNESS as ai, bridgeModelRouteRefusal as an, createBudgetPool as ar, scopeRetainedOwnerPriorSpend as at, bestComposite as b, isAbortError$2 as ba, promptModelProfileMaterialization as bi, SandboxEvidenceRetentionError as bn, RunCancellationReason as br, reconnectRetainedInteractiveRun as bt, runTree as c, isSandboxTerminalEvent as ca, harnessSupportsReasoningEffort as ci, harnessUsageIsEmpty as cn, spendFromUsageEvents as cr, scopeRetainedOwnerResult as ct, classifyDriverFailure as d, notifySandboxEventObserver as da, CodexExecutionDiagnosticError as di, bridgeStopSignalKey as dn, reconnectRetainedRun as dr, hostDirectoryReader as dt, detachedSnapshot as ea, runSettledCommand as ei, peerMailTools as en, workerTraceAnalysisStore as er, consumeScopeRetainedOwnerResult as et, runDriverWithRetry as f, sandboxEventServedBackend as fa, terminateProcessTreeAndConfirm as fi, TERMINAL_DECISIONS as fn, recoverRetainedRun as fr, resolveSpawnResourcePaths as ft, CONTINUATION_FACTS as g, chargedTokens as ga, defineProfileMaterializationContract as gi, runAgentRounds as gn, destroyInteractiveEnvironment as gr, attachWorker as gt, CONTINUATIONS_DIR as h, addSpend as ha, controlProfileMaterialization as hi, isTerminalDecision as hn, retainedCreateMaterial as hr, workerInteractiveAdmissionFile as ht, bestDelivered as i, canonicalStreamEventFromSandboxEvent as ia, removeWorktree as ii, bridgeAdmissionRefusal as in, assertValidBudget as ir, scopeRetainedOwnerContext as it, isDriverSpec as j, resourceTelemetry as ja, readCommittedJsonLines as ji, unavailablePauseMs as jn, createPropagatingTraceEmitter as jr, createExecutorRegistry as jt, driverChild as k, zeroSpend as ka, isNoEntError as ki, providerAsSandboxClient as kn, retainHarnessTranscript as kr, cliWorktreeExecutor as kt, DriverAttemptsExhaustedError as l, mapSandboxEvent as la, localHarnessExecutable as li, readCodexRolloutSession as ln, spendFromUsageTotals as lr, SPAWN_RESOURCE_PATH_MAX_BYTES as lt, upstreamUnavailableSignal as m, sumSandboxUsage as ma, assertProfileMaterialization as mi, defaultSelectWinner as mn, startRetainedRunInEnvironment as mr, readWorkerInteractiveAdmissions as mt, createRootHandle as n, readSandboxOutcome as na, captureWorktreeDiff as ni, isLiveNodeStatus as nn, BudgetReconcileFault as nr, prepareScopeRetainedOwnerTask as nt, pickBestDelivered as o, createSandboxUsageLedger as oa, LOCAL_HARNESSES as oi, addHarnessUsage as on, meterUsageEvent as or, scopeRetainedOwnerResourceReader as ot, summarizeDriverAttempts as p, sandboxProgressEvents as pa, AGENT_PROFILE_MATERIALIZATION_AXES as pi, createSandboxForSpec as pn, startRetainedRun as pr, interactiveAdmissionSeamKey as pt, isWaitOutcome as q, runtimeOwnedPendingExecutorMaterialization as qi, materializeTreeView as qn, padTraceId as qr, createInbox as qt, createSupervisor as r, assertSandboxServedModel as ra, createWorktree as ri, isTerminalNodeStatus as rn, ReservationWaitRefused as rr, reconcileScopeRetainedOwnerEnvironment as rt, runFinalizer as s, extractLlmCallEvent as sa, harnessInvocation as si, createCodexRolloutStoreReader as sn, newUsageTotals as sr, scopeRetainedOwnerRestorePoint as st, DEFAULT_MAX_DEPTH as t, projectSandboxOutcome as ta, runWorktreeHarness as ti, peerMailVerbNames as tn, executorFailure as tr, noteScopeRetainedOwnerCoordination as tt, HarnessTurnFailedError as u, mapSandboxToolEvent as ua, parseCodexTokenUsage as ui, bridgeRuntimeAttachmentsKey as un, errMessage as ur, environmentReader as ut, admitContinuationPolicy as v, deleteBoxSafe as va, profileMaterializationAxes$1 as vi, probeSandboxCapabilities as vn, createWorkerSlots as vr, workerInteractiveBindingFile as vt, distillFindings as w, stringifySafe as wa, renderUnsupported as wi, routerBrain as wn, captureHarnessTranscript as wr, queueOf as wt, checkVerdictOf as x, promptCacheTokenClasses as xa, promptOnlyProfileMaterialization as xi, captureBeforeDestroy as xn, abortError as xr, recoverRetainedInteractiveRun as xt, admitFinding as y, hasCompleteCacheBreakdown as ya, promptControlProfileMaterialization as yi, acquireSandbox as yn, openSlotGroup as yr, workerInteractiveBindingsDir as yt, meterRuntimeOwnedProviderAttempt as z, teardownSurfaces as za, knownMaterializationReceipt as zi, FileSpawnJournal as zn, buildLoopSpanNodes as zr, readWorkerTraceContext as zt };
|
|
28544
28895
|
|
|
28545
|
-
//# sourceMappingURL=supervisor-
|
|
28896
|
+
//# sourceMappingURL=supervisor-Rov7xW0j.js.map
|