@tangle-network/agent-runtime 0.320.1 → 0.322.1
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-BKglRwjB.js → activation-CBv_0LUh.js} +2 -2
- package/dist/{activation-BKglRwjB.js.map → activation-CBv_0LUh.js.map} +1 -1
- package/dist/{activation-BSwcsNSQ.d.ts → activation-CZGz2kuu.d.ts} +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/candidate-execution/index.js +3 -3
- package/dist/{coordination-driver-D85RWATT.js → coordination-driver-C2Zm5lU4.js} +71 -3
- package/dist/coordination-driver-C2Zm5lU4.js.map +1 -0
- package/dist/{delegate-BHRR-4hh.js → delegate-BV7AVmbB.js} +2 -2
- package/dist/{delegate-BHRR-4hh.js.map → delegate-BV7AVmbB.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +3 -3
- package/dist/{graph-BGMcJJP1.js → graph-CH3YiPog.js} +4 -4
- package/dist/{graph-BGMcJJP1.js.map → graph-CH3YiPog.js.map} +1 -1
- package/dist/{improvement-cycle-0cnwWPFY.js → improvement-cycle-CD1h5GSM.js} +5 -5
- package/dist/{improvement-cycle-0cnwWPFY.js.map → improvement-cycle-CD1h5GSM.js.map} +1 -1
- package/dist/{index-t672ISFX.d.ts → index-CGNQWpge.d.ts} +877 -551
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -7
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +6 -6
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-CFudOt5T.js → loop-runner-bin-CFxE376A.js} +3 -3
- package/dist/{loop-runner-bin-CFudOt5T.js.map → loop-runner-bin-CFxE376A.js.map} +1 -1
- package/dist/{loop-runner-bin-Fgmf_PQU.d.ts → loop-runner-bin-C_jaLCUO.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-DCfdg0UD.d.ts → openai-tools-D1PDoBOz.d.ts} +2 -2
- package/dist/{prepare-DjCLEN-q.js → prepare-CFQLx9e3.js} +2 -2
- package/dist/{prepare-DjCLEN-q.js.map → prepare-CFQLx9e3.js.map} +1 -1
- package/dist/{profile-DmVM4Gxb.js → profile-BTbpdL9h.js} +40 -4
- package/dist/profile-BTbpdL9h.js.map +1 -0
- package/dist/profiles.d.ts +1 -1
- package/dist/{protected-model-port-D1fcnYdj.js → protected-model-port-f1N2f0Uq.js} +3 -3
- package/dist/{protected-model-port-D1fcnYdj.js.map → protected-model-port-f1N2f0Uq.js.map} +1 -1
- package/dist/{provision-supervisor-BUMhF1yb.js → provision-supervisor-ftJZhqBU.js} +3 -3
- package/dist/{provision-supervisor-BUMhF1yb.js.map → provision-supervisor-ftJZhqBU.js.map} +1 -1
- package/dist/{runtime-B47V5Omi.js → runtime-EiTCboO2.js} +465 -12
- package/dist/runtime-EiTCboO2.js.map +1 -0
- package/dist/{search-executor-DjKdQluM.js → search-executor-ECJ2TmC-.js} +2 -2
- package/dist/{search-executor-DjKdQluM.js.map → search-executor-ECJ2TmC-.js.map} +1 -1
- package/dist/{server-Gpgr0WP-.js → server-C2k5wX4k.js} +3 -3
- package/dist/{server-Gpgr0WP-.js.map → server-C2k5wX4k.js.map} +1 -1
- package/dist/{supervise-C2ThvLgZ.js → supervise-BjrRk-AN.js} +194 -133
- package/dist/supervise-BjrRk-AN.js.map +1 -0
- package/dist/{supervisor-CCtmmmOz.js → supervisor-BMMdI4T-.js} +606 -81
- package/dist/supervisor-BMMdI4T-.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +13 -13
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/package.json +6 -6
- package/skills/profile-authoring/SKILL.md +1 -0
- package/dist/coordination-driver-D85RWATT.js.map +0 -1
- package/dist/profile-DmVM4Gxb.js.map +0 -1
- package/dist/runtime-B47V5Omi.js.map +0 -1
- package/dist/supervise-C2ThvLgZ.js.map +0 -1
- package/dist/supervisor-CCtmmmOz.js.map +0 -1
|
@@ -17,9 +17,10 @@ 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 { clearImmediate, setImmediate } from "node:timers";
|
|
20
|
+
import { clearImmediate, setImmediate as setImmediate$1 } from "node:timers";
|
|
21
21
|
import { z } from "zod";
|
|
22
22
|
import { Readable } from "node:stream";
|
|
23
|
+
import { LedgerCanonicalizationError, canonicalString, jsonDocument, merkleLeafHash, merkleRoot, merkleSalt } from "@tangle-network/agent-eval/ledger-core";
|
|
23
24
|
import { SDKError, generateIdempotencyKey, withRetry } from "@tangle-network/agent-core";
|
|
24
25
|
import { collectAgentFinalMessageText, collectAgentResponseText } from "@tangle-network/sandbox";
|
|
25
26
|
import { request } from "node:http";
|
|
@@ -740,13 +741,17 @@ function sandboxTerminalUsageField(type) {
|
|
|
740
741
|
* so a sentinel `NaN` from a misbehaving backend cannot poison the ledger.
|
|
741
742
|
*/
|
|
742
743
|
function extractLlmCallEvent(event, agentRunName) {
|
|
744
|
+
const data = canonicalUsageData(event);
|
|
745
|
+
return data === void 0 ? void 0 : buildLlmCall(data, agentRunName);
|
|
746
|
+
}
|
|
747
|
+
function canonicalUsageData(event) {
|
|
743
748
|
if (!event || typeof event !== "object") return void 0;
|
|
744
749
|
const type = String(event.type ?? "");
|
|
745
750
|
const data = event.data && typeof event.data === "object" ? event.data : {};
|
|
746
|
-
if (type === "llm_call" || type === "cost.usage" || type === "usage") return
|
|
751
|
+
if (type === "llm_call" || type === "cost.usage" || type === "usage") return usageReceiptData(data, plainRecord$1(data.usage));
|
|
747
752
|
if (type === "error" || isSandboxTerminalEvent(type)) {
|
|
748
753
|
const field = type === "error" ? "tokenUsage" : sandboxTerminalUsageField(type);
|
|
749
|
-
return
|
|
754
|
+
return usageReceiptData(data, plainRecord$1(data[field]) ?? plainRecord$1(data[field === "usage" ? "tokenUsage" : "usage"]));
|
|
750
755
|
}
|
|
751
756
|
}
|
|
752
757
|
/** A {@link SandboxUsageLedger} for one worker. Pass the worker's harness to decode with that
|
|
@@ -758,7 +763,10 @@ function createSandboxUsageLedger(harness) {
|
|
|
758
763
|
const receipts = /* @__PURE__ */ new Map();
|
|
759
764
|
const settledTokens = zeroTokenUsage();
|
|
760
765
|
let turnTokens = zeroTokenUsage();
|
|
766
|
+
let turnUsageUnknown = false;
|
|
767
|
+
let settledUsage;
|
|
761
768
|
return {
|
|
769
|
+
settledUsage: () => settledUsage === void 0 ? void 0 : { ...settledUsage },
|
|
762
770
|
tokenUsage() {
|
|
763
771
|
const total = cloneTokenUsage(settledTokens);
|
|
764
772
|
addTokenUsage(total, turnTokens);
|
|
@@ -771,13 +779,17 @@ function createSandboxUsageLedger(harness) {
|
|
|
771
779
|
const receipt = creditCanonicalUsage(event, call, credited, receipts, (receipt, mode) => {
|
|
772
780
|
refineCanonicalTokens(turnTokens, call, receipt, mode);
|
|
773
781
|
});
|
|
774
|
-
if (receipt?.tokensKnown === false)
|
|
782
|
+
if (receipt?.tokensKnown === false) {
|
|
783
|
+
turnTokens.tokensKnown = false;
|
|
784
|
+
turnUsageUnknown = true;
|
|
785
|
+
}
|
|
775
786
|
return receipt;
|
|
776
787
|
}
|
|
777
788
|
let usage;
|
|
778
789
|
try {
|
|
779
790
|
usage = decodeHarnessUsage(event, harness);
|
|
780
791
|
} catch (err) {
|
|
792
|
+
turnUsageUnknown = true;
|
|
781
793
|
return {
|
|
782
794
|
type: "llm_call",
|
|
783
795
|
model: agentRunName,
|
|
@@ -793,16 +805,25 @@ function createSandboxUsageLedger(harness) {
|
|
|
793
805
|
const canonical = sawCanonical;
|
|
794
806
|
held = [];
|
|
795
807
|
sawCanonical = false;
|
|
808
|
+
const receipt = !canonical && reports.length > 0 ? harnessUsageLlmCall(reports, agentRunName) : void 0;
|
|
809
|
+
if (receipt) creditCanonicalUsage({
|
|
810
|
+
type: "llm_call",
|
|
811
|
+
data: {}
|
|
812
|
+
}, receipt, credited, receipts, (credit, mode) => refineCanonicalTokens(turnTokens, receipt, credit, mode));
|
|
813
|
+
settledUsage = !turnUsageUnknown && credited.tokensIn !== void 0 && credited.tokensOut !== void 0 ? {
|
|
814
|
+
inputTokens: credited.tokensIn,
|
|
815
|
+
outputTokens: credited.tokensOut,
|
|
816
|
+
...credited.totalTokens === void 0 ? {} : { totalTokens: credited.totalTokens },
|
|
817
|
+
...credited.reasoningTokens === void 0 ? {} : { reasoningTokens: credited.reasoningTokens },
|
|
818
|
+
...credited["promptCache.readTokens"] === void 0 ? {} : { cacheReadInputTokens: credited["promptCache.readTokens"] },
|
|
819
|
+
...credited["promptCache.writeTokens"] === void 0 ? {} : { cacheCreationInputTokens: credited["promptCache.writeTokens"] },
|
|
820
|
+
...credited.costUsd === void 0 ? {} : { cost: credited.costUsd }
|
|
821
|
+
} : void 0;
|
|
796
822
|
for (const key of Object.keys(credited)) delete credited[key];
|
|
797
823
|
receipts.clear();
|
|
798
|
-
const receipt = !canonical && reports.length > 0 ? harnessUsageLlmCall(reports, agentRunName) : void 0;
|
|
799
|
-
if (receipt) addTokenUsage(turnTokens, {
|
|
800
|
-
input: receipt.tokensIn ?? 0,
|
|
801
|
-
output: receipt.tokensOut ?? 0,
|
|
802
|
-
...promptCacheTokenClasses(receipt.tokensIn, receipt.promptCache)
|
|
803
|
-
});
|
|
804
824
|
addTokenUsage(settledTokens, turnTokens);
|
|
805
825
|
turnTokens = zeroTokenUsage();
|
|
826
|
+
turnUsageUnknown = false;
|
|
806
827
|
return receipt;
|
|
807
828
|
}
|
|
808
829
|
};
|
|
@@ -817,6 +838,11 @@ function creditCanonicalUsage(event, call, credited, receipts, onCredit) {
|
|
|
817
838
|
const mode = canonicalSandboxUsageMode(event);
|
|
818
839
|
const result = { ...call };
|
|
819
840
|
const data = plainRecord$1(event.data) ?? {};
|
|
841
|
+
const usageData = canonicalUsageData(event) ?? {};
|
|
842
|
+
const supplemental = Object.fromEntries(["totalTokens", "reasoningTokens"].flatMap((key) => {
|
|
843
|
+
const value = usageData[key];
|
|
844
|
+
return value === void 0 ? [] : [[key, typeof value === "number" && Number.isFinite(value) ? value : null]];
|
|
845
|
+
}));
|
|
820
846
|
const explicitTokensUnknown = [
|
|
821
847
|
data,
|
|
822
848
|
plainRecord$1(data.usage),
|
|
@@ -827,7 +853,8 @@ function creditCanonicalUsage(event, call, credited, receipts, onCredit) {
|
|
|
827
853
|
if (event.id) {
|
|
828
854
|
const signature = JSON.stringify({
|
|
829
855
|
mode,
|
|
830
|
-
call
|
|
856
|
+
call,
|
|
857
|
+
supplemental
|
|
831
858
|
});
|
|
832
859
|
const previous = receipts.get(event.id);
|
|
833
860
|
if (previous === signature) return void 0;
|
|
@@ -860,6 +887,8 @@ function creditCanonicalUsage(event, call, credited, receipts, onCredit) {
|
|
|
860
887
|
"costUsd",
|
|
861
888
|
"estimatedCostUsd"
|
|
862
889
|
]) if (call[key] !== void 0) result[key] = credit(key, call[key]);
|
|
890
|
+
for (const [key, value] of Object.entries(supplemental)) if (typeof value !== "number") reason = `usage receipt has an invalid ${key}`;
|
|
891
|
+
else credit(key, value);
|
|
863
892
|
if (call.promptCache) result.promptCache = Object.fromEntries(Object.entries(call.promptCache).map(([key, value]) => [key, typeof value === "number" ? credit(`promptCache.${key}`, value) : value]));
|
|
864
893
|
if (reason !== void 0) {
|
|
865
894
|
result.usdKnown = false;
|
|
@@ -1234,6 +1263,10 @@ const TERMINAL_FAILURE = /^(error|errored|failed|failure|cancelled|canceled|time
|
|
|
1234
1263
|
* surfaced in-band, never dropped).
|
|
1235
1264
|
* - bare `tool*` event types (`tool.call`, `tool_result`, …) — stateless:
|
|
1236
1265
|
* `*result*` types project to `tool_result`, the rest to `tool_call`.
|
|
1266
|
+
* - codex `raw` events whose inner `item.started` / `item.updated` /
|
|
1267
|
+
* `item.completed` carries a command, MCP, collaboration, web search or
|
|
1268
|
+
* file change item — stateful on the item id, like a tool part. Other raw
|
|
1269
|
+
* events, including opencode's raw `tool_use` echoes, project nothing.
|
|
1237
1270
|
*
|
|
1238
1271
|
* Returns `[]` for every non-tool event.
|
|
1239
1272
|
*
|
|
@@ -1248,6 +1281,7 @@ function mapSandboxToolEvent(event, state) {
|
|
|
1248
1281
|
if (String(part.type ?? "") !== "tool") return [];
|
|
1249
1282
|
return projectToolPart(part, state, typeof event.id === "string" ? event.id : void 0);
|
|
1250
1283
|
}
|
|
1284
|
+
if (type === "raw") return projectCodexItem(data, state);
|
|
1251
1285
|
if (CANONICAL_STREAM_EVENT_TYPES.has(type)) return [];
|
|
1252
1286
|
if (type.includes("tool")) {
|
|
1253
1287
|
const callId = pickString(data, [
|
|
@@ -1322,6 +1356,63 @@ function projectToolPart(part, state, eventId) {
|
|
|
1322
1356
|
}
|
|
1323
1357
|
return out;
|
|
1324
1358
|
}
|
|
1359
|
+
/** Codex item types that are tool calls. Reasoning, messages and todo lists are not. */
|
|
1360
|
+
const CODEX_TOOL_ITEMS = /* @__PURE__ */ new Set([
|
|
1361
|
+
"command_execution",
|
|
1362
|
+
"mcp_tool_call",
|
|
1363
|
+
"collab_tool_call",
|
|
1364
|
+
"web_search",
|
|
1365
|
+
"file_change"
|
|
1366
|
+
]);
|
|
1367
|
+
/** Item fields that describe the call's progress or outcome rather than what it was asked to do. */
|
|
1368
|
+
const CODEX_ITEM_OUTCOME_FIELDS = /* @__PURE__ */ new Set([
|
|
1369
|
+
"id",
|
|
1370
|
+
"type",
|
|
1371
|
+
"status",
|
|
1372
|
+
"result",
|
|
1373
|
+
"error",
|
|
1374
|
+
"aggregated_output",
|
|
1375
|
+
"exit_code"
|
|
1376
|
+
]);
|
|
1377
|
+
/**
|
|
1378
|
+
* Project a codex `item.started` / `item.updated` / `item.completed` tool item through the same
|
|
1379
|
+
* per-call state as a tool part, keyed on the item id: one `tool_call` on its first frame and one
|
|
1380
|
+
* `tool_result` when it completes. Tool names follow Eval's codex intake: `server/tool` for MCP.
|
|
1381
|
+
*/
|
|
1382
|
+
function projectCodexItem(data, state) {
|
|
1383
|
+
if (data.backend !== "codex" || !data.event || typeof data.event !== "object") return [];
|
|
1384
|
+
const inner = data.event;
|
|
1385
|
+
const phase = inner.type;
|
|
1386
|
+
if (phase !== "item.started" && phase !== "item.updated" && phase !== "item.completed") return [];
|
|
1387
|
+
if (!inner.item || typeof inner.item !== "object") return [];
|
|
1388
|
+
const item = inner.item;
|
|
1389
|
+
const itemType = pickString(item, ["type"]);
|
|
1390
|
+
if (itemType === void 0 || !CODEX_TOOL_ITEMS.has(itemType)) return [];
|
|
1391
|
+
const error = item.error && typeof item.error === "object" ? pickString(item.error, ["message"]) ?? `${itemType} failed` : void 0;
|
|
1392
|
+
const failed = item.status === "failed" || error !== void 0 || itemType === "command_execution" && typeof item.exit_code === "number" && item.exit_code !== 0;
|
|
1393
|
+
const status = phase !== "item.completed" ? "running" : failed ? "failed" : "completed";
|
|
1394
|
+
const input = Object.fromEntries(Object.entries(item).filter(([key]) => !CODEX_ITEM_OUTCOME_FIELDS.has(key)));
|
|
1395
|
+
const output = item.result ?? item.aggregated_output ?? item.changes;
|
|
1396
|
+
return projectToolPart({
|
|
1397
|
+
...typeof item.id === "string" ? { callID: item.id } : {},
|
|
1398
|
+
tool: codexToolName(itemType, item),
|
|
1399
|
+
state: {
|
|
1400
|
+
status,
|
|
1401
|
+
input,
|
|
1402
|
+
...output === void 0 || output === null ? {} : { output },
|
|
1403
|
+
...status === "failed" ? { error: error ?? `${itemType} failed` } : {}
|
|
1404
|
+
}
|
|
1405
|
+
}, state, void 0);
|
|
1406
|
+
}
|
|
1407
|
+
function codexToolName(itemType, item) {
|
|
1408
|
+
if (itemType === "mcp_tool_call") {
|
|
1409
|
+
const name = [pickString(item, ["server"]), pickString(item, ["tool"])].filter((part) => part !== void 0).join("/");
|
|
1410
|
+
return name === "" ? "mcp" : name;
|
|
1411
|
+
}
|
|
1412
|
+
if (itemType === "collab_tool_call") return pickString(item, ["tool"]) ?? "subagent";
|
|
1413
|
+
if (itemType === "web_search" || itemType === "file_change") return itemType;
|
|
1414
|
+
return pickString(item, ["name"]) ?? itemType;
|
|
1415
|
+
}
|
|
1325
1416
|
function pickString(data, keys) {
|
|
1326
1417
|
for (const key of keys) {
|
|
1327
1418
|
const value = data[key];
|
|
@@ -10605,6 +10696,17 @@ function servedIdentityParts(model) {
|
|
|
10605
10696
|
snapshot
|
|
10606
10697
|
};
|
|
10607
10698
|
}
|
|
10699
|
+
/**
|
|
10700
|
+
* A trace root is valid only beside the output it commits to, with a well-formed root, artifact
|
|
10701
|
+
* reference and leaf count (at least the summary leaf). Records written before trace roots carry
|
|
10702
|
+
* none and stay valid.
|
|
10703
|
+
*/
|
|
10704
|
+
function assertTraceRoot(event, root) {
|
|
10705
|
+
if (!("traceRoot" in event) || event.traceRoot === void 0) return;
|
|
10706
|
+
const receipt = event.traceRoot;
|
|
10707
|
+
const fields = receipt !== null && typeof receipt === "object" ? receipt : {};
|
|
10708
|
+
if (typeof event.outRef !== "string" || typeof fields.root !== "string" || !/^sha256:[0-9a-f]{64}$/.test(fields.root) || typeof fields.ref !== "string" || !/^sha256:[0-9a-f]{64}$/.test(fields.ref) || typeof fields.leafCount !== "number" || !Number.isSafeInteger(fields.leafCount) || fields.leafCount < 1) throw new Error(`spawn journal corrupted: ${event.kind} for node '${event.id}' carries a malformed trace root in tree '${root}'`);
|
|
10709
|
+
}
|
|
10608
10710
|
/** One validation implementation for memory, durable append, and cold replay. */
|
|
10609
10711
|
/** @internal shared with the SQL-backed store. */
|
|
10610
10712
|
var SpawnEventIndex = class {
|
|
@@ -10617,6 +10719,7 @@ var SpawnEventIndex = class {
|
|
|
10617
10719
|
assert(event) {
|
|
10618
10720
|
const node = this.nodes.get(event.id);
|
|
10619
10721
|
this.assertRetained(node, event);
|
|
10722
|
+
assertTraceRoot(event, this.root);
|
|
10620
10723
|
if (event.kind === "execution-evidence") {
|
|
10621
10724
|
if (!node?.spawned || !/^sha256:[0-9a-f]{64}$/.test(event.outRef)) throw new Error("spawn journal corrupted: executor evidence has no spawned node or valid content reference");
|
|
10622
10725
|
}
|
|
@@ -11103,6 +11206,218 @@ function traceEvidenceFor(event) {
|
|
|
11103
11206
|
};
|
|
11104
11207
|
}
|
|
11105
11208
|
//#endregion
|
|
11209
|
+
//#region src/runtime/supervise/credential-refusal.ts
|
|
11210
|
+
/**
|
|
11211
|
+
* The account owner refused an unsupported credential route before dispatch. This is the
|
|
11212
|
+
* provider SDK's machine contract, not an HTTP status, class-name guess, or prose match.
|
|
11213
|
+
*/
|
|
11214
|
+
function isCredentialRefusal(error) {
|
|
11215
|
+
if (!(error instanceof Error)) return false;
|
|
11216
|
+
try {
|
|
11217
|
+
return Object.getOwnPropertyDescriptor(error, "code")?.value === "model_credential_refused";
|
|
11218
|
+
} catch {
|
|
11219
|
+
return false;
|
|
11220
|
+
}
|
|
11221
|
+
}
|
|
11222
|
+
//#endregion
|
|
11223
|
+
//#region src/runtime/supervise/trace-root.ts
|
|
11224
|
+
/**
|
|
11225
|
+
* Trace roots: one Merkle root over the events a turn archived, so a single event can be proven
|
|
11226
|
+
* against the hash its journal record carries without reading the rest of the archive.
|
|
11227
|
+
*
|
|
11228
|
+
* The leaves are the archived events in stored order, each hashed with its own random salt, then
|
|
11229
|
+
* one summary leaf that counts the events and the tool calls among them. The artifact keeps every
|
|
11230
|
+
* leaf and salt and is stored under its content address in the run's result blob store, beside
|
|
11231
|
+
* the archive it commits to. A verifier recomputes leaf `i` from `events[i]` of the `outRef` blob
|
|
11232
|
+
* and `salts[i]`, checks it against `leaves[i]`, and checks `merkleRoot(leaves)` against the root
|
|
11233
|
+
* the journal recorded. Leaf identity is `(outRef, index)`: an event's own `id` is a session
|
|
11234
|
+
* buffer offset and is absent on terminal events.
|
|
11235
|
+
*
|
|
11236
|
+
* One event array has one root per node. A result always gets its own. Evidence whose events the
|
|
11237
|
+
* node already rooted gets none: a retained owner's deferred workspace capture stores the turn it
|
|
11238
|
+
* just committed again, with the workspace fields added, under another `outRef`. A second root
|
|
11239
|
+
* over the same events would give one turn two count candidates and two run-root leaves.
|
|
11240
|
+
*
|
|
11241
|
+
* Salts are random, so a trace root can never be recomputed from the archive alone. Recovery and
|
|
11242
|
+
* replay copy the recorded receipt; they never derive a new one.
|
|
11243
|
+
*/
|
|
11244
|
+
/** Schema identifier of a stored {@link TraceRootArtifact}. */
|
|
11245
|
+
const TRACE_ROOT_SCHEMA = "agent-runtime.trace-root.v1";
|
|
11246
|
+
/** Schema identifier of the {@link TraceSummary} carried by a trace root's last leaf. */
|
|
11247
|
+
const TRACE_SUMMARY_SCHEMA = "agent-runtime.trace-summary.v1";
|
|
11248
|
+
/** @internal */
|
|
11249
|
+
function traceRootWriter(blobs, nodeId) {
|
|
11250
|
+
const roots = /* @__PURE__ */ new Map();
|
|
11251
|
+
/** Digests of the event arrays this node holds a stored root for. */
|
|
11252
|
+
const rooted = /* @__PURE__ */ new Set();
|
|
11253
|
+
const persist = async (outRef, out, evidence) => {
|
|
11254
|
+
const events = archivedEvents(out);
|
|
11255
|
+
if (events === void 0) return void 0;
|
|
11256
|
+
if (evidence) {
|
|
11257
|
+
await Promise.allSettled([...roots.values()]);
|
|
11258
|
+
if (rooted.has(await eventsDigest(events))) return void 0;
|
|
11259
|
+
}
|
|
11260
|
+
const stored = await persistTraceRoot(blobs, nodeId, outRef, events);
|
|
11261
|
+
if (stored === void 0) return void 0;
|
|
11262
|
+
rooted.add(stored.digest);
|
|
11263
|
+
return stored.receipt;
|
|
11264
|
+
};
|
|
11265
|
+
const memoized = (outRef, out, evidence) => {
|
|
11266
|
+
const known = roots.get(outRef);
|
|
11267
|
+
if (known !== void 0) return known;
|
|
11268
|
+
const pending = persist(outRef, out, evidence);
|
|
11269
|
+
roots.set(outRef, pending);
|
|
11270
|
+
pending.catch(() => roots.delete(outRef));
|
|
11271
|
+
return pending;
|
|
11272
|
+
};
|
|
11273
|
+
return {
|
|
11274
|
+
write: (outRef, out) => memoized(outRef, out, false),
|
|
11275
|
+
writeEvidence: (outRef, out) => memoized(outRef, out, true),
|
|
11276
|
+
async recorded(outRef) {
|
|
11277
|
+
if (outRef === void 0) return void 0;
|
|
11278
|
+
return roots.get(outRef)?.catch(() => void 0);
|
|
11279
|
+
}
|
|
11280
|
+
};
|
|
11281
|
+
}
|
|
11282
|
+
async function persistTraceRoot(blobs, nodeId, outRef, events) {
|
|
11283
|
+
let built;
|
|
11284
|
+
try {
|
|
11285
|
+
built = await traceRootArtifact(nodeId, outRef, events);
|
|
11286
|
+
} catch (error) {
|
|
11287
|
+
if (error instanceof LedgerCanonicalizationError) return void 0;
|
|
11288
|
+
throw error;
|
|
11289
|
+
}
|
|
11290
|
+
const { artifact, digest } = built;
|
|
11291
|
+
await nextTurn();
|
|
11292
|
+
const ref = contentAddress(artifact);
|
|
11293
|
+
await nextTurn();
|
|
11294
|
+
await blobs.put(ref, artifact);
|
|
11295
|
+
return {
|
|
11296
|
+
receipt: {
|
|
11297
|
+
root: artifact.root,
|
|
11298
|
+
ref,
|
|
11299
|
+
leafCount: artifact.leafCount
|
|
11300
|
+
},
|
|
11301
|
+
digest
|
|
11302
|
+
};
|
|
11303
|
+
}
|
|
11304
|
+
function archivedEvents(out) {
|
|
11305
|
+
if (out === null || typeof out !== "object" || Array.isArray(out)) return void 0;
|
|
11306
|
+
const events = out.events;
|
|
11307
|
+
return Array.isArray(events) ? events : void 0;
|
|
11308
|
+
}
|
|
11309
|
+
/** The longest stretch of hashing between yields to the event loop. Hashing runs about 40 µs per
|
|
11310
|
+
* event, and the largest archived turn holds 65,276 events: unbroken, that blocked the process
|
|
11311
|
+
* for 2.7 s while sibling turns, coordination calls and heartbeats waited. A slice is measured
|
|
11312
|
+
* in time, not events, because one event can be megabytes. */
|
|
11313
|
+
const SLICE_MS = 10;
|
|
11314
|
+
/** Yields to the event loop once a slice has run `SLICE_MS`; `undefined` while it has not. */
|
|
11315
|
+
function slicer() {
|
|
11316
|
+
let started = performance.now();
|
|
11317
|
+
return () => {
|
|
11318
|
+
if (performance.now() - started < SLICE_MS) return void 0;
|
|
11319
|
+
return nextTurn().then(() => {
|
|
11320
|
+
started = performance.now();
|
|
11321
|
+
});
|
|
11322
|
+
};
|
|
11323
|
+
}
|
|
11324
|
+
function nextTurn() {
|
|
11325
|
+
return new Promise((resolve) => setImmediate(resolve));
|
|
11326
|
+
}
|
|
11327
|
+
/** The identity of an event array as stored: the digest of each event's stored JSON, in order.
|
|
11328
|
+
* Two arrays with one digest have the same leaves' content. */
|
|
11329
|
+
async function eventsDigest(events) {
|
|
11330
|
+
const hash = createHash("sha256");
|
|
11331
|
+
const slice = slicer();
|
|
11332
|
+
for (const event of events) {
|
|
11333
|
+
const yielded = slice();
|
|
11334
|
+
if (yielded !== void 0) await yielded;
|
|
11335
|
+
hash.update(storedText(event)).update("\n");
|
|
11336
|
+
}
|
|
11337
|
+
return hash.digest("hex");
|
|
11338
|
+
}
|
|
11339
|
+
async function traceRootArtifact(nodeId, outRef, archived) {
|
|
11340
|
+
const salts = [];
|
|
11341
|
+
const leaves = [];
|
|
11342
|
+
const tree = merkleTree();
|
|
11343
|
+
const identity = createHash("sha256");
|
|
11344
|
+
const tools = createSandboxToolPartState();
|
|
11345
|
+
const toolCalls = /* @__PURE__ */ new Map();
|
|
11346
|
+
const slice = slicer();
|
|
11347
|
+
for (const event of archived) {
|
|
11348
|
+
const yielded = slice();
|
|
11349
|
+
if (yielded !== void 0) await yielded;
|
|
11350
|
+
const text = storedText(event);
|
|
11351
|
+
identity.update(text).update("\n");
|
|
11352
|
+
const stored = JSON.parse(text);
|
|
11353
|
+
const salt = merkleSalt();
|
|
11354
|
+
const leaf = merkleLeafHash(canonicalString(jsonDocument(stored)), salt);
|
|
11355
|
+
salts.push(salt);
|
|
11356
|
+
leaves.push(leaf);
|
|
11357
|
+
tree.push(leaf);
|
|
11358
|
+
for (const projected of mapSandboxToolEvent(stored, tools)) {
|
|
11359
|
+
if (projected.type !== "tool_call") continue;
|
|
11360
|
+
toolCalls.set(projected.toolName, (toolCalls.get(projected.toolName) ?? 0) + 1);
|
|
11361
|
+
}
|
|
11362
|
+
}
|
|
11363
|
+
const summary = {
|
|
11364
|
+
schema: TRACE_SUMMARY_SCHEMA,
|
|
11365
|
+
events: archived.length,
|
|
11366
|
+
toolCalls: Object.fromEntries(toolCalls)
|
|
11367
|
+
};
|
|
11368
|
+
const salt = merkleSalt();
|
|
11369
|
+
const leaf = merkleLeafHash(canonicalString(summary), salt);
|
|
11370
|
+
salts.push(salt);
|
|
11371
|
+
leaves.push(leaf);
|
|
11372
|
+
tree.push(leaf);
|
|
11373
|
+
return {
|
|
11374
|
+
artifact: {
|
|
11375
|
+
schema: TRACE_ROOT_SCHEMA,
|
|
11376
|
+
nodeId,
|
|
11377
|
+
outRef,
|
|
11378
|
+
root: tree.root(),
|
|
11379
|
+
leafCount: leaves.length,
|
|
11380
|
+
salts,
|
|
11381
|
+
leaves,
|
|
11382
|
+
summary
|
|
11383
|
+
},
|
|
11384
|
+
digest: identity.digest("hex")
|
|
11385
|
+
};
|
|
11386
|
+
}
|
|
11387
|
+
/**
|
|
11388
|
+
* `merkleRoot(leaves)` built as the leaves arrive, so its interior hashes run inside the sliced
|
|
11389
|
+
* leaf loop instead of in one block after it (0.4 s for 65,277 leaves). It keeps the perfect
|
|
11390
|
+
* subtrees of RFC 9162, largest first, and joins two with ledger-core's own interior hash,
|
|
11391
|
+
* `merkleRoot([left, right])`; the root folds them from the right, as RFC 9162 splits at the
|
|
11392
|
+
* largest power of two.
|
|
11393
|
+
*/
|
|
11394
|
+
function merkleTree() {
|
|
11395
|
+
const peaks = [];
|
|
11396
|
+
return {
|
|
11397
|
+
push(leaf) {
|
|
11398
|
+
let hash = leaf;
|
|
11399
|
+
let size = 1;
|
|
11400
|
+
while (peaks.at(-1)?.size === size) {
|
|
11401
|
+
hash = merkleRoot([peaks.pop().hash, hash]);
|
|
11402
|
+
size *= 2;
|
|
11403
|
+
}
|
|
11404
|
+
peaks.push({
|
|
11405
|
+
hash,
|
|
11406
|
+
size
|
|
11407
|
+
});
|
|
11408
|
+
},
|
|
11409
|
+
root() {
|
|
11410
|
+
let root = peaks.at(-1).hash;
|
|
11411
|
+
for (let index = peaks.length - 2; index >= 0; index -= 1) root = merkleRoot([peaks[index].hash, root]);
|
|
11412
|
+
return root;
|
|
11413
|
+
}
|
|
11414
|
+
};
|
|
11415
|
+
}
|
|
11416
|
+
/** One array item as `JSON.stringify` writes it: `JSON.parse` of it is what `events[i]` holds. */
|
|
11417
|
+
function storedText(event) {
|
|
11418
|
+
return JSON.stringify(event) ?? "null";
|
|
11419
|
+
}
|
|
11420
|
+
//#endregion
|
|
11106
11421
|
//#region src/runtime/supervise/upstream-unavailable.ts
|
|
11107
11422
|
/**
|
|
11108
11423
|
* An upstream that cannot serve NOW: how Runtime recognizes one, and how long an agent waits for it.
|
|
@@ -11189,14 +11504,17 @@ function jitteredMs(ms, random) {
|
|
|
11189
11504
|
const retainedExecutorSeamKey = "runtime.retainedExecutor";
|
|
11190
11505
|
/** @internal A capture may finish after cancellation; its durable citation remains appendable. */
|
|
11191
11506
|
function executorEvidenceWriter(args) {
|
|
11507
|
+
const traceRoots = args.traceRoots ?? traceRootWriter(args.blobs, args.nodeId);
|
|
11192
11508
|
return async (out) => {
|
|
11193
11509
|
const snapshot = detachedSnapshot(out, "executor evidence");
|
|
11194
11510
|
const outRef = contentAddress(snapshot);
|
|
11195
11511
|
await args.blobs.put(outRef, snapshot);
|
|
11512
|
+
const traceRoot = await traceRoots.writeEvidence(outRef, snapshot);
|
|
11196
11513
|
await args.journal.appendEvent(args.rootId, {
|
|
11197
11514
|
kind: "execution-evidence",
|
|
11198
11515
|
id: args.nodeId,
|
|
11199
11516
|
outRef,
|
|
11517
|
+
...traceRoot === void 0 ? {} : { traceRoot },
|
|
11200
11518
|
seq: args.nextSequence(),
|
|
11201
11519
|
at: new Date(args.now()).toISOString()
|
|
11202
11520
|
});
|
|
@@ -11255,14 +11573,8 @@ function readString(value, key) {
|
|
|
11255
11573
|
const read = Reflect.get(value, key);
|
|
11256
11574
|
return typeof read === "string" ? read : void 0;
|
|
11257
11575
|
}
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
*
|
|
11261
|
-
* `phase` says whether a 4xx or a client deadline can mean "refused before it ran": only at
|
|
11262
|
-
* admission. After admission the same status means the provider cannot resolve what it
|
|
11263
|
-
* admitted, and the honest name is the refusal.
|
|
11264
|
-
*/
|
|
11265
|
-
function classifyRetainedPendingCause(cause, phase = "execution") {
|
|
11576
|
+
const credentialAdmissionRefusals = /* @__PURE__ */ new WeakSet();
|
|
11577
|
+
function classifyPendingCause(cause, phase, onCredentialRefusal) {
|
|
11266
11578
|
const seen = /* @__PURE__ */ new Set();
|
|
11267
11579
|
const queue = [{
|
|
11268
11580
|
value: cause,
|
|
@@ -11274,7 +11586,13 @@ function classifyRetainedPendingCause(cause, phase = "execution") {
|
|
|
11274
11586
|
const { value, phase: at } = queue.shift();
|
|
11275
11587
|
if (typeof value !== "object" || value === null || seen.has(value)) continue;
|
|
11276
11588
|
seen.add(value);
|
|
11277
|
-
if (value instanceof RetainedExecutionPendingError)
|
|
11589
|
+
if (value instanceof RetainedExecutionPendingError) {
|
|
11590
|
+
if (credentialAdmissionRefusals.has(value)) {
|
|
11591
|
+
if (at === "execution") return "unobservable";
|
|
11592
|
+
onCredentialRefusal?.();
|
|
11593
|
+
}
|
|
11594
|
+
return value.pendingCause;
|
|
11595
|
+
}
|
|
11278
11596
|
const name = readString(value, "name");
|
|
11279
11597
|
const code = readString(value, "code");
|
|
11280
11598
|
const status = readNumber(value, "status") ?? readNumber(value, "statusCode");
|
|
@@ -11288,6 +11606,11 @@ function classifyRetainedPendingCause(cause, phase = "execution") {
|
|
|
11288
11606
|
}
|
|
11289
11607
|
if (name === "ZodError" || Array.isArray(Reflect.get(value, "issues")) || code === "JSON_BOUND_VIOLATION") return at === "admission" ? "request-rejected" : "provider-contract";
|
|
11290
11608
|
if (code === "DISPATCH_NOT_ADMITTED") return at === "admission" ? "request-rejected" : "provider-contract";
|
|
11609
|
+
if (isCredentialRefusal(value)) {
|
|
11610
|
+
if (at === "execution") return "unobservable";
|
|
11611
|
+
onCredentialRefusal?.();
|
|
11612
|
+
return "request-rejected";
|
|
11613
|
+
}
|
|
11291
11614
|
if (code !== void 0 && transportCodes.has(code)) return "transport";
|
|
11292
11615
|
if (name === "NetworkError" || name === "ServerError") return "transport";
|
|
11293
11616
|
if (status === void 0 && at === "admission" && code !== void 0 && UNAVAILABLE_CODES.has(code.toLowerCase())) return "request-rejected";
|
|
@@ -11326,11 +11649,15 @@ var RetainedExecutionPendingError = class extends Error {
|
|
|
11326
11649
|
pendingCause;
|
|
11327
11650
|
phase;
|
|
11328
11651
|
constructor(cause, pendingCause = "execution") {
|
|
11329
|
-
|
|
11652
|
+
let credentialRefused = false;
|
|
11653
|
+
const resolved = pendingCause === "admission" || pendingCause === "execution" ? classifyPendingCause(cause, pendingCause, () => {
|
|
11654
|
+
credentialRefused = true;
|
|
11655
|
+
}) : pendingCause;
|
|
11330
11656
|
super(causeMessages[resolved], { cause });
|
|
11331
11657
|
this.name = "RetainedExecutionPendingError";
|
|
11332
11658
|
this.pendingCause = resolved;
|
|
11333
11659
|
this.phase = pendingCause === "admission" ? "admission" : "execution";
|
|
11660
|
+
if (credentialRefused) credentialAdmissionRefusals.add(this);
|
|
11334
11661
|
}
|
|
11335
11662
|
};
|
|
11336
11663
|
/** The execution id of a leaf's later invocation, derived from its `execution-input` sequence so
|
|
@@ -11677,7 +12004,7 @@ function providerAsSandboxClient(provider, options = {}) {
|
|
|
11677
12004
|
}
|
|
11678
12005
|
return { async create(createOptions) {
|
|
11679
12006
|
const defaults = options.defaults ?? {};
|
|
11680
|
-
const sandboxInput = createInputFromSandboxOptions(createOptions);
|
|
12007
|
+
const sandboxInput = createInputFromSandboxOptions(createOptions, options.mapCreateOptions !== void 0);
|
|
11681
12008
|
const customInput = options.mapCreateOptions?.(createOptions) ?? {};
|
|
11682
12009
|
const mapped = {
|
|
11683
12010
|
...defaults,
|
|
@@ -11696,16 +12023,17 @@ function providerAsSandboxClient(provider, options = {}) {
|
|
|
11696
12023
|
};
|
|
11697
12024
|
if (mapped.backend === void 0) delete mapped.backend;
|
|
11698
12025
|
if (mapped.profile === void 0) throw new ValidationError(`providerAsSandboxClient(${provider.name}): profile required in defaults or CreateSandboxOptions.backend.profile`);
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
}
|
|
12026
|
+
const needsMcp = hasRuntimeMcpAttachments(mapped);
|
|
12027
|
+
const capabilities = options.requireSession || needsMcp ? await provider.capabilities() : void 0;
|
|
12028
|
+
assertRuntimeMcpAttachments(provider.name, mapped, capabilities);
|
|
12029
|
+
if (options.requireSession && (!capabilities?.streaming.live || !capabilities.sessions.continue)) throw new ValidationError(`providerAsSandboxClient(${provider.name}): live session continuation is required`);
|
|
11703
12030
|
const environment = await provider.create(mapped);
|
|
11704
12031
|
if (options.requireSession && !environment.session) {
|
|
11705
12032
|
if (options.workspaceRetention === void 0) await environment.destroy?.();
|
|
11706
12033
|
throw new ValidationError(`providerAsSandboxClient(${provider.name}): session() is required`);
|
|
11707
12034
|
}
|
|
11708
12035
|
return environmentAsSandboxInstance(environment, {
|
|
12036
|
+
...typeof mapped.profile === "string" ? {} : { profile: mapped.profile },
|
|
11709
12037
|
requireTerminalEvent: options.requireTerminalEvent ?? true,
|
|
11710
12038
|
...options.workspaceRetention === void 0 ? {} : { workspaceRetention: options.workspaceRetention },
|
|
11711
12039
|
...options.retentionIdentity === void 0 ? {} : { retentionIdentity: options.retentionIdentity },
|
|
@@ -11945,6 +12273,7 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
11945
12273
|
return snapshot;
|
|
11946
12274
|
}).catch((error) => {
|
|
11947
12275
|
workspaceCaptureFailure = error;
|
|
12276
|
+
noteCaptureFailure(error);
|
|
11948
12277
|
throw error;
|
|
11949
12278
|
});
|
|
11950
12279
|
}
|
|
@@ -11995,6 +12324,18 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
11995
12324
|
schedule();
|
|
11996
12325
|
};
|
|
11997
12326
|
let nativeHoldsTranscript = false;
|
|
12327
|
+
const noteCaptureFailure = (error) => {
|
|
12328
|
+
if (nativeHoldsTranscript || harnessTranscript.status !== "unavailable") return;
|
|
12329
|
+
if (harnessTranscript.reason !== "capture-did-not-run" && harnessTranscript.reason !== "enumeration-failed") return;
|
|
12330
|
+
harnessTranscript = {
|
|
12331
|
+
status: "unavailable",
|
|
12332
|
+
reason: "enumeration-failed",
|
|
12333
|
+
skipped: [{
|
|
12334
|
+
path: workspaceExecutionId,
|
|
12335
|
+
reason: errorText(error instanceof Error ? error.message : error)
|
|
12336
|
+
}]
|
|
12337
|
+
};
|
|
12338
|
+
};
|
|
11998
12339
|
const stopNativeMirror = async () => {
|
|
11999
12340
|
if (nativeTimer !== void 0) clearTimeout(nativeTimer);
|
|
12000
12341
|
nativeTimer = void 0;
|
|
@@ -12040,7 +12381,9 @@ function createProviderExecutor(provider, profile, ctx, options, placement) {
|
|
|
12040
12381
|
if (nativeHoldsTranscript && !(copy.status === "retained" && copy.fileCount > 0)) return;
|
|
12041
12382
|
harnessTranscript = copy;
|
|
12042
12383
|
nativeHoldsTranscript = true;
|
|
12043
|
-
} catch {
|
|
12384
|
+
} catch (error) {
|
|
12385
|
+
noteCaptureFailure(error);
|
|
12386
|
+
}
|
|
12044
12387
|
}).finally(() => {
|
|
12045
12388
|
if (nativeInFlight === tracked) nativeInFlight = void 0;
|
|
12046
12389
|
});
|
|
@@ -12677,7 +13020,10 @@ async function* streamProviderExecutor(args) {
|
|
|
12677
13020
|
const verdict = await args.options.validator?.validate(result, {
|
|
12678
13021
|
iteration: 0,
|
|
12679
13022
|
...args.node === void 0 ? {} : { node: args.node },
|
|
12680
|
-
box: environmentAsSandboxInstance(environment, {
|
|
13023
|
+
box: environmentAsSandboxInstance(environment, {
|
|
13024
|
+
profile: args.profile,
|
|
13025
|
+
requireTerminalEvent: args.options.requireTerminalEvent ?? true
|
|
13026
|
+
}),
|
|
12681
13027
|
signal: linked
|
|
12682
13028
|
});
|
|
12683
13029
|
const deferCapture = ownerTakesCapture();
|
|
@@ -12875,7 +13221,7 @@ async function* streamProviderExecutor(args) {
|
|
|
12875
13221
|
} else if (input > 0 || output > 0 || receipt.tokensKnown === false) pendingUnpricedWork = true;
|
|
12876
13222
|
}
|
|
12877
13223
|
}
|
|
12878
|
-
/** Subscription selection needs
|
|
13224
|
+
/** Subscription selection needs its complete profile and one identity for each fresh turn. */
|
|
12879
13225
|
function subscriptionTurnProfile(turn, profile) {
|
|
12880
13226
|
if (profile.model?.metadata?.credentialSource !== "subscription") return turn;
|
|
12881
13227
|
const backend = promptOptionsFromAgentTurnInput(turn).backend ?? {};
|
|
@@ -12883,14 +13229,26 @@ function subscriptionTurnProfile(turn, profile) {
|
|
|
12883
13229
|
if (turn.profile !== void 0 && canonicalAgentProfileDigest(turn.profile) !== digest || backend.profile !== void 0 && canonicalAgentProfileDigest(backend.profile) !== digest) throw new ValidationError("provider subscription turn cannot replace its exact AgentProfile");
|
|
12884
13230
|
return {
|
|
12885
13231
|
...turn,
|
|
12886
|
-
profile
|
|
13232
|
+
profile,
|
|
13233
|
+
...turn.turnId === void 0 && turn.lastEventId === void 0 && turn.controlRef === void 0 ? { turnId: randomUUID() } : {}
|
|
12887
13234
|
};
|
|
12888
13235
|
}
|
|
13236
|
+
function hasRuntimeMcpAttachments(input) {
|
|
13237
|
+
const mcp = input?.runtimeAttachments?.mcp;
|
|
13238
|
+
return mcp !== void 0 && Object.keys(mcp).length > 0;
|
|
13239
|
+
}
|
|
13240
|
+
function assertRuntimeMcpAttachments(provider, input, capabilities) {
|
|
13241
|
+
if (!hasRuntimeMcpAttachments(input)) return;
|
|
13242
|
+
const create = capabilities?.create;
|
|
13243
|
+
if (!create || !("runtimeAttachments" in create) || create.runtimeAttachments?.mcp !== true) throw new ValidationError(`provider ${provider} does not advertise create.runtimeAttachments.mcp; no environment was created`);
|
|
13244
|
+
}
|
|
12889
13245
|
/** One retained dispatch owns creation, replay, result identity, and cancellation. */
|
|
12890
13246
|
async function providerExecutionSource(args, turn, signal) {
|
|
12891
13247
|
const selectedTurn = subscriptionTurnProfile(turn, args.profile);
|
|
12892
13248
|
AgentTurnInputSchema.parse(selectedTurn);
|
|
12893
|
-
const
|
|
13249
|
+
const needsMcp = hasRuntimeMcpAttachments(args.options.defaults);
|
|
13250
|
+
const capabilities = args.retention || needsMcp ? await args.provider.capabilities() : void 0;
|
|
13251
|
+
assertRuntimeMcpAttachments(args.provider.name, args.options.defaults, capabilities);
|
|
12894
13252
|
if (!(args.retention !== void 0 && capabilities?.retainedControl !== void 0)) {
|
|
12895
13253
|
if (args.recovering) throw new Error(`provider ${args.provider.name} cannot recover retained executions`);
|
|
12896
13254
|
const environment = await args.provider.create({
|
|
@@ -12937,7 +13295,7 @@ async function providerExecutionSource(args, turn, signal) {
|
|
|
12937
13295
|
...priorSession === void 0 ? {} : {
|
|
12938
13296
|
existingEnvironmentId: priorSession.environmentId,
|
|
12939
13297
|
identity: {
|
|
12940
|
-
sessionId: priorSession.sessionId,
|
|
13298
|
+
sessionId: retention.newSession ? mintRetainedIdentity(environmentKey, turnId).sessionId : priorSession.sessionId,
|
|
12941
13299
|
executionId: mintRetainedIdentity(environmentKey, turnId).executionId
|
|
12942
13300
|
}
|
|
12943
13301
|
}
|
|
@@ -13067,14 +13425,14 @@ async function providerExecutionSource(args, turn, signal) {
|
|
|
13067
13425
|
observationBudgetExceeded = true;
|
|
13068
13426
|
break;
|
|
13069
13427
|
}
|
|
13070
|
-
if (observedFrames > 0 && observedFrames % RETAINED_OBSERVATION_BATCH_EVENTS === 0) await awaitAbortable$1(new Promise((resolve) => setImmediate(resolve)), signal);
|
|
13428
|
+
if (observedFrames > 0 && observedFrames % RETAINED_OBSERVATION_BATCH_EVENTS === 0) await awaitAbortable$1(new Promise((resolve) => setImmediate$1(resolve)), signal);
|
|
13071
13429
|
let next;
|
|
13072
13430
|
let wake;
|
|
13073
13431
|
try {
|
|
13074
13432
|
const remaining = observationIdleMs - (Date.now() - lastObservedAt);
|
|
13075
13433
|
if (remaining <= 0) throw new RetainedReadTimeoutError("event stream", observationIdleMs);
|
|
13076
13434
|
const exactWake = new Promise((resolve) => {
|
|
13077
|
-
wake = setImmediate(() => {
|
|
13435
|
+
wake = setImmediate$1(() => {
|
|
13078
13436
|
readExactResult().then(() => resolve({ kind: "exact-result" }), () => resolve({ kind: "exact-result" }));
|
|
13079
13437
|
});
|
|
13080
13438
|
});
|
|
@@ -13187,7 +13545,44 @@ async function providerExecutionSource(args, turn, signal) {
|
|
|
13187
13545
|
throw error;
|
|
13188
13546
|
}
|
|
13189
13547
|
}
|
|
13190
|
-
function createInputFromSandboxOptions(options) {
|
|
13548
|
+
function createInputFromSandboxOptions(options, customMapping) {
|
|
13549
|
+
if (!customMapping) {
|
|
13550
|
+
const mapped = /* @__PURE__ */ new Set([
|
|
13551
|
+
"backend",
|
|
13552
|
+
"environment",
|
|
13553
|
+
"git",
|
|
13554
|
+
"cwd",
|
|
13555
|
+
"resources",
|
|
13556
|
+
"env",
|
|
13557
|
+
"secrets",
|
|
13558
|
+
"metadata",
|
|
13559
|
+
"name",
|
|
13560
|
+
"idempotencyKey"
|
|
13561
|
+
]);
|
|
13562
|
+
const unsupported = Object.entries(options ?? {}).filter(([key, value]) => value !== void 0 && !mapped.has(key)).map(([key]) => key);
|
|
13563
|
+
for (const [prefix, value, keys] of [[
|
|
13564
|
+
"backend",
|
|
13565
|
+
options?.backend,
|
|
13566
|
+
[
|
|
13567
|
+
"type",
|
|
13568
|
+
"profile",
|
|
13569
|
+
"model"
|
|
13570
|
+
]
|
|
13571
|
+
], [
|
|
13572
|
+
"git",
|
|
13573
|
+
options?.git,
|
|
13574
|
+
["url", "ref"]
|
|
13575
|
+
]]) for (const [key, field] of Object.entries(value ?? {})) if (field !== void 0 && !keys.includes(key)) unsupported.push(`${prefix}.${key}`);
|
|
13576
|
+
const model = options?.backend?.model;
|
|
13577
|
+
if (model !== void 0) {
|
|
13578
|
+
for (const [key, value] of Object.entries(model)) if (value !== void 0 && !["provider", "model"].includes(key)) unsupported.push(`backend.model.${key}`);
|
|
13579
|
+
const profile = options?.backend?.profile;
|
|
13580
|
+
if (model.provider !== void 0 && model.provider !== profile?.model?.provider?.trim()) unsupported.push("backend.model.provider");
|
|
13581
|
+
if (model.model !== void 0 && model.model !== concreteProfileModel(profile ?? {})) unsupported.push("backend.model.model");
|
|
13582
|
+
}
|
|
13583
|
+
if (options?.secrets === "all") unsupported.push("secrets=all");
|
|
13584
|
+
if (unsupported.length > 0) throw new ValidationError(`providerAsSandboxClient: Sandbox create controls require mapCreateOptions: ${unsupported.join(", ")}`);
|
|
13585
|
+
}
|
|
13191
13586
|
const profile = options?.backend?.profile;
|
|
13192
13587
|
const backend = options?.backend?.type;
|
|
13193
13588
|
const cwd = options?.cwd === void 0 ? void 0 : canonicalWorkspaceCwd({
|
|
@@ -13209,8 +13604,7 @@ function createInputFromSandboxOptions(options) {
|
|
|
13209
13604
|
...Array.isArray(options?.secrets) ? { secrets: options.secrets } : {},
|
|
13210
13605
|
...options?.metadata ? { metadata: options.metadata } : {},
|
|
13211
13606
|
...options?.name ? { name: options.name } : {},
|
|
13212
|
-
...options?.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {}
|
|
13213
|
-
providerOptions: { sandboxCreateOptions: options ?? {} }
|
|
13607
|
+
...options?.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {}
|
|
13214
13608
|
};
|
|
13215
13609
|
}
|
|
13216
13610
|
function environmentAsSandboxInstance(environment, options) {
|
|
@@ -13235,7 +13629,7 @@ function environmentAsSandboxInstance(environment, options) {
|
|
|
13235
13629
|
},
|
|
13236
13630
|
async *streamPrompt(message, promptOptions) {
|
|
13237
13631
|
let terminal = false;
|
|
13238
|
-
const input = turnInputFromPrompt(message, promptOptions);
|
|
13632
|
+
const input = turnInputFromPrompt(message, promptOptions, options.profile);
|
|
13239
13633
|
providerSessionId = input.sessionId ?? null;
|
|
13240
13634
|
noteControlRef(input.controlRef);
|
|
13241
13635
|
let cancellation;
|
|
@@ -13292,25 +13686,30 @@ function environmentAsSandboxInstance(environment, options) {
|
|
|
13292
13686
|
if (options.requireTerminalEvent && !terminal) throw new ValidationError(`providerAsSandboxClient(${environment.provider}): stream ended without a terminal result/done/status event`);
|
|
13293
13687
|
},
|
|
13294
13688
|
async prompt(message, promptOptions) {
|
|
13295
|
-
|
|
13689
|
+
let lastResultText;
|
|
13296
13690
|
let text = "";
|
|
13297
|
-
|
|
13691
|
+
const usageLedger = createSandboxUsageLedger();
|
|
13298
13692
|
let terminal = false;
|
|
13299
13693
|
const failures = createProviderFailureLedger();
|
|
13300
|
-
const input = turnInputFromPrompt(message, promptOptions);
|
|
13694
|
+
const input = turnInputFromPrompt(message, promptOptions, options.profile);
|
|
13301
13695
|
providerSessionId = input.sessionId ?? null;
|
|
13302
13696
|
noteControlRef(input.controlRef);
|
|
13303
13697
|
for await (const event of environment.stream(input)) {
|
|
13304
|
-
|
|
13698
|
+
lastResultText = resultTextFromData(event.data) ?? lastResultText;
|
|
13305
13699
|
if (isTerminalEnvironmentEvent(event)) terminal = true;
|
|
13306
|
-
|
|
13700
|
+
const sandboxEvent = sandboxEventFromEnvironmentEvent(event);
|
|
13701
|
+
failures.observe(event, sandboxEvent);
|
|
13702
|
+
const usageEvent = usageSandboxEvent(event);
|
|
13703
|
+
if (usageEvent) usageLedger.observe(usageEvent, environment.id);
|
|
13704
|
+
usageLedger.observe(sandboxEvent, environment.id);
|
|
13307
13705
|
text += textFromEnvironmentEvent(event);
|
|
13308
|
-
usage = mergeTokenUsage(usage, event.usage);
|
|
13309
13706
|
}
|
|
13310
13707
|
if (options.requireTerminalEvent && !terminal) throw new ValidationError(`providerAsSandboxClient(${environment.provider}): prompt ended without a terminal result/done/status event`);
|
|
13708
|
+
usageLedger.settleTurn(environment.id);
|
|
13709
|
+
const usage = usageLedger.settledUsage();
|
|
13311
13710
|
const outcome = failures.finish();
|
|
13312
13711
|
return {
|
|
13313
|
-
response:
|
|
13712
|
+
response: lastResultText ?? text,
|
|
13314
13713
|
success: outcome?.success ?? true,
|
|
13315
13714
|
status: outcome?.status ?? "success",
|
|
13316
13715
|
durationMs: 0,
|
|
@@ -13319,14 +13718,14 @@ function environmentAsSandboxInstance(environment, options) {
|
|
|
13319
13718
|
};
|
|
13320
13719
|
},
|
|
13321
13720
|
...environment.dispatch && environment.session ? { async dispatchPrompt(message, promptOptions) {
|
|
13322
|
-
const session = await environment.dispatch?.(turnInputFromPrompt(message, promptOptions));
|
|
13721
|
+
const session = await environment.dispatch?.(turnInputFromPrompt(message, promptOptions, options.profile));
|
|
13323
13722
|
if (!session) throw new ValidationError("providerAsSandboxClient: dispatch returned no session");
|
|
13324
13723
|
noteControlRef(session.controlRef);
|
|
13325
13724
|
return sandboxDispatchResultFromSessionRef(session);
|
|
13326
13725
|
} } : {},
|
|
13327
13726
|
...environment.session ? { session(id, sessionOptions) {
|
|
13328
13727
|
noteControlRef(sessionOptions?.controlRef);
|
|
13329
|
-
return sandboxSessionFromAgentSession(environment.session?.(id, sessionOptions), sessionOptions?.controlRef);
|
|
13728
|
+
return sandboxSessionFromAgentSession(environment.session?.(id, sessionOptions), sessionOptions?.controlRef, options.profile);
|
|
13330
13729
|
} } : {},
|
|
13331
13730
|
...environment.read ? { read: environment.read.bind(environment) } : {},
|
|
13332
13731
|
...environment.write ? { write: environment.write.bind(environment) } : {},
|
|
@@ -13380,7 +13779,7 @@ function environmentAsSandboxInstance(environment, options) {
|
|
|
13380
13779
|
}
|
|
13381
13780
|
};
|
|
13382
13781
|
}
|
|
13383
|
-
function sandboxSessionFromAgentSession(session, expectedControlRef) {
|
|
13782
|
+
function sandboxSessionFromAgentSession(session, expectedControlRef, profile) {
|
|
13384
13783
|
if (!session) throw new ValidationError("providerAsSandboxClient: session is unavailable");
|
|
13385
13784
|
const controlRef = resolveSessionControlRef(session.controlRef, expectedControlRef);
|
|
13386
13785
|
return {
|
|
@@ -13407,7 +13806,7 @@ function sandboxSessionFromAgentSession(session, expectedControlRef) {
|
|
|
13407
13806
|
return promptResultFromAgentTurnResult(await session.result());
|
|
13408
13807
|
},
|
|
13409
13808
|
async prompt(message, options) {
|
|
13410
|
-
return promptResultFromAgentTurnResult(await session.prompt(turnInputFromPrompt(message, options)));
|
|
13809
|
+
return promptResultFromAgentTurnResult(await session.prompt(turnInputFromPrompt(message, options, profile)));
|
|
13411
13810
|
},
|
|
13412
13811
|
...session.respondToInteraction ? { async respondToInteraction(command, options) {
|
|
13413
13812
|
assertInteractionCommandScope(command, controlRef);
|
|
@@ -13654,8 +14053,8 @@ function tokenUsageData(usage) {
|
|
|
13654
14053
|
...usage.cost !== void 0 ? { totalCostUsd: usage.cost } : {}
|
|
13655
14054
|
};
|
|
13656
14055
|
}
|
|
13657
|
-
function turnInputFromPrompt(message, options) {
|
|
13658
|
-
|
|
14056
|
+
function turnInputFromPrompt(message, options, profile) {
|
|
14057
|
+
const input = {
|
|
13659
14058
|
...typeof message === "string" ? { prompt: message } : { parts: message },
|
|
13660
14059
|
...options?.sessionId ? { sessionId: options.sessionId } : {},
|
|
13661
14060
|
...options?.model ? { model: options.model } : {},
|
|
@@ -13670,6 +14069,7 @@ function turnInputFromPrompt(message, options) {
|
|
|
13670
14069
|
...options?.signal ? { signal: options.signal } : {},
|
|
13671
14070
|
...options?.backend ? { providerOptions: { backend: options.backend } } : {}
|
|
13672
14071
|
};
|
|
14072
|
+
return profile === void 0 ? input : subscriptionTurnProfile(input, profile);
|
|
13673
14073
|
}
|
|
13674
14074
|
function resolveSessionControlRef(actual, expected, options = {}) {
|
|
13675
14075
|
if (expected === void 0) {
|
|
@@ -13823,19 +14223,6 @@ function isUsageType(type) {
|
|
|
13823
14223
|
function isNestedUsageType(type) {
|
|
13824
14224
|
return isSandboxTerminalEvent(type) && sandboxTerminalUsageField(type) === "usage";
|
|
13825
14225
|
}
|
|
13826
|
-
function mergeTokenUsage(left, right) {
|
|
13827
|
-
if (!left) return right;
|
|
13828
|
-
if (!right) return left;
|
|
13829
|
-
return {
|
|
13830
|
-
inputTokens: left.inputTokens + right.inputTokens,
|
|
13831
|
-
outputTokens: left.outputTokens + right.outputTokens,
|
|
13832
|
-
...left.totalTokens !== void 0 || right.totalTokens !== void 0 ? { totalTokens: (left.totalTokens ?? 0) + (right.totalTokens ?? 0) } : {},
|
|
13833
|
-
...left.cacheReadInputTokens !== void 0 || right.cacheReadInputTokens !== void 0 ? { cacheReadInputTokens: (left.cacheReadInputTokens ?? 0) + (right.cacheReadInputTokens ?? 0) } : {},
|
|
13834
|
-
...left.cacheCreationInputTokens !== void 0 || right.cacheCreationInputTokens !== void 0 ? { cacheCreationInputTokens: (left.cacheCreationInputTokens ?? 0) + (right.cacheCreationInputTokens ?? 0) } : {},
|
|
13835
|
-
...left.reasoningTokens !== void 0 || right.reasoningTokens !== void 0 ? { reasoningTokens: (left.reasoningTokens ?? 0) + (right.reasoningTokens ?? 0) } : {},
|
|
13836
|
-
...left.cost !== void 0 || right.cost !== void 0 ? { cost: (left.cost ?? 0) + (right.cost ?? 0) } : {}
|
|
13837
|
-
};
|
|
13838
|
-
}
|
|
13839
14226
|
function stringValue(value) {
|
|
13840
14227
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
13841
14228
|
}
|
|
@@ -21039,14 +21426,15 @@ function routerTurnRequestIdentity(identity, turnIndex) {
|
|
|
21039
21426
|
* the recorded usage events are yielded; the terminal artifact is read from
|
|
21040
21427
|
* `resultArtifact()` after the stream drains.
|
|
21041
21428
|
*/
|
|
21042
|
-
const sandboxExecutor = (spec, ctx) =>
|
|
21429
|
+
const sandboxExecutor = (spec, ctx) => sandboxExecutorForPath(spec, ctx, "sandbox");
|
|
21430
|
+
function sandboxExecutorForPath(spec, ctx, modelPath) {
|
|
21043
21431
|
if (spec.harness === null) throw new ValidationError$1("sandboxExecutor: harness is null (router/inline) — wrong executor");
|
|
21044
21432
|
const harness = spec.harness;
|
|
21045
21433
|
const seam = readSeam(ctx, sandboxSeamKey, "sandbox");
|
|
21046
21434
|
if (!seam.sandboxClient || typeof seam.sandboxClient.create !== "function") throw new ValidationError$1("sandboxExecutor: SandboxSeam.sandboxClient.create required");
|
|
21047
21435
|
const maxIterations = seam.maxIterations ?? 1;
|
|
21048
21436
|
if (!Number.isFinite(maxIterations) || maxIterations <= 0) throw new ValidationError$1("sandboxExecutor: maxIterations must be > 0");
|
|
21049
|
-
const sandboxTokenLimits = enforceTokenLimits(profileModelExecutionSettings(spec.profile, "sandboxExecutor").tokenLimits, "sandbox", "sandboxExecutor");
|
|
21437
|
+
const sandboxTokenLimits = enforceTokenLimits(profileModelExecutionSettings(spec.profile, "sandboxExecutor", modelPath).tokenLimits, "sandbox", "sandboxExecutor");
|
|
21050
21438
|
const traceEnv = {
|
|
21051
21439
|
...workerLineage({
|
|
21052
21440
|
harness,
|
|
@@ -21175,7 +21563,7 @@ const sandboxExecutor = (spec, ctx) => {
|
|
|
21175
21563
|
return artifact;
|
|
21176
21564
|
}
|
|
21177
21565
|
}, sandboxMaterialization, sandboxBinding);
|
|
21178
|
-
}
|
|
21566
|
+
}
|
|
21179
21567
|
async function* streamSandboxLeaf(args) {
|
|
21180
21568
|
const linked = linkAbort(args.signal, args.controller.signal);
|
|
21181
21569
|
const agentRun = {
|
|
@@ -21974,6 +22362,7 @@ function createExecutor(config) {
|
|
|
21974
22362
|
const sandboxClient = providerAsSandboxClient(provider, {
|
|
21975
22363
|
defaults: {
|
|
21976
22364
|
...providerSeam.defaults ?? {},
|
|
22365
|
+
idempotencyKey: providerSeam.defaults?.idempotencyKey ?? seamed.node?.attemptId ?? randomUUID(),
|
|
21977
22366
|
signal: seamed.signal
|
|
21978
22367
|
},
|
|
21979
22368
|
requireTerminalEvent: providerSeam.requireTerminalEvent,
|
|
@@ -22010,10 +22399,10 @@ function createExecutor(config) {
|
|
|
22010
22399
|
}
|
|
22011
22400
|
}
|
|
22012
22401
|
};
|
|
22013
|
-
const executor =
|
|
22402
|
+
const executor = sandboxExecutorForPath({
|
|
22014
22403
|
...spec,
|
|
22015
22404
|
harness
|
|
22016
|
-
}, providerCtx);
|
|
22405
|
+
}, providerCtx, "provider");
|
|
22017
22406
|
const wrapper = inheritRuntimeOwnedExecutorAttestation(executor, {
|
|
22018
22407
|
...executor,
|
|
22019
22408
|
runtime: providerSeam.runtime ?? provider.name
|
|
@@ -22363,6 +22752,7 @@ function admitContinuationPolicy(policy, context) {
|
|
|
22363
22752
|
if (usd === void 0 || !finite(usd.perContinuation) || !finite(usd.perRun) || usd.perContinuation <= 0 || usd.perRun < usd.perContinuation) throw new ValidationError$1(`${context}: continuation.panel 'on' needs panelUsd with 0 < perContinuation <= perRun`);
|
|
22364
22753
|
}
|
|
22365
22754
|
if (policy.append !== void 0 && typeof policy.append !== "function") throw new ValidationError$1(`${context}: continuation.append must be a function`);
|
|
22755
|
+
if (policy.session !== void 0 && policy.session !== "native" && policy.session !== "fresh") throw new ValidationError$1(`${context}: continuation.session must be 'native' or 'fresh'`);
|
|
22366
22756
|
admitContinuationProfile(policy.profile, context);
|
|
22367
22757
|
return deadlineMs;
|
|
22368
22758
|
}
|
|
@@ -23847,6 +24237,7 @@ function settlementFields(subject, settlement) {
|
|
|
23847
24237
|
reason: settlement.reason,
|
|
23848
24238
|
...settlement.retainedPendingCause === void 0 ? {} : { retainedPendingCause: settlement.retainedPendingCause },
|
|
23849
24239
|
...settlement.outRef ? { outRef: settlement.outRef } : {},
|
|
24240
|
+
...settlement.outRef && settlement.traceRoot ? { traceRoot: settlement.traceRoot } : {},
|
|
23850
24241
|
...settlement.providerModel ? { providerModel: settlement.providerModel } : {},
|
|
23851
24242
|
...subject.budgetViolation ? { budgetViolation: subject.budgetViolation } : {},
|
|
23852
24243
|
trace: settlement.trace,
|
|
@@ -23982,6 +24373,7 @@ async function healReleasedSlots(opts, signal, now) {
|
|
|
23982
24373
|
...floor.infra === void 0 ? {} : { infra: floor.infra },
|
|
23983
24374
|
trace: floor.trace,
|
|
23984
24375
|
...floor.outRef ? { outRef: floor.outRef } : {},
|
|
24376
|
+
...floor.traceRoot ? { traceRoot: floor.traceRoot } : {},
|
|
23985
24377
|
...floor.providerModel ? { providerModel: floor.providerModel } : {},
|
|
23986
24378
|
...floor.harnessTranscript ? { harnessTranscript: floor.harnessTranscript } : {},
|
|
23987
24379
|
...floor.retainedPendingCause ? { retainedPendingCause: floor.retainedPendingCause } : {}
|
|
@@ -24099,6 +24491,7 @@ async function prepareInterruptedExecutors(opts, events, signal, now, parentId =
|
|
|
24099
24491
|
id: result.id,
|
|
24100
24492
|
status: reason === void 0 ? "done" : "down",
|
|
24101
24493
|
outRef: result.outRef,
|
|
24494
|
+
...result.traceRoot === void 0 ? {} : { traceRoot: result.traceRoot },
|
|
24102
24495
|
...reason === void 0 ? {} : { reason },
|
|
24103
24496
|
...infra === void 0 ? {} : { infra },
|
|
24104
24497
|
spent: result.spent,
|
|
@@ -24612,6 +25005,7 @@ function registerScopeRetainedOwner(scope, args) {
|
|
|
24612
25005
|
const acceptedRef = [...attempt].reverse().find((event) => event.kind === "execution-result");
|
|
24613
25006
|
const priorSession = taskEvent === void 0 ? void 0 : committedSession(events, start);
|
|
24614
25007
|
let sequence = Math.max(0, ...events.map((event) => "seq" in event ? event.seq : 0));
|
|
25008
|
+
const traceRoots = traceRootWriter(args.blobs, args.nodeId);
|
|
24615
25009
|
const state = {
|
|
24616
25010
|
args,
|
|
24617
25011
|
admissions,
|
|
@@ -24631,6 +25025,9 @@ function registerScopeRetainedOwner(scope, args) {
|
|
|
24631
25025
|
get priorSession() {
|
|
24632
25026
|
return state.priorSession;
|
|
24633
25027
|
},
|
|
25028
|
+
get newSession() {
|
|
25029
|
+
return state.freshSessions === true && state.priorSession !== void 0;
|
|
25030
|
+
},
|
|
24634
25031
|
preserveEnvironment: true,
|
|
24635
25032
|
admissions,
|
|
24636
25033
|
get restoreWorkspace() {
|
|
@@ -24673,7 +25070,8 @@ function registerScopeRetainedOwner(scope, args) {
|
|
|
24673
25070
|
rootId: args.rootId,
|
|
24674
25071
|
nodeId: args.nodeId,
|
|
24675
25072
|
nextSequence: () => state.nextSequence(),
|
|
24676
|
-
now: args.now
|
|
25073
|
+
now: args.now,
|
|
25074
|
+
traceRoots
|
|
24677
25075
|
}),
|
|
24678
25076
|
onWorkspaceCapture: workspaceCaptureWriter({
|
|
24679
25077
|
journal: args.journal,
|
|
@@ -24694,10 +25092,12 @@ function registerScopeRetainedOwner(scope, args) {
|
|
|
24694
25092
|
const outRef = contentAddress(result.out);
|
|
24695
25093
|
await args.blobs.put(outRef, result.out);
|
|
24696
25094
|
scope.signal.throwIfAborted();
|
|
25095
|
+
const traceRoot = await traceRoots.write(outRef, result.out);
|
|
24697
25096
|
const event = {
|
|
24698
25097
|
kind: "execution-result",
|
|
24699
25098
|
id: args.nodeId,
|
|
24700
25099
|
outRef,
|
|
25100
|
+
...traceRoot === void 0 ? {} : { traceRoot },
|
|
24701
25101
|
spent: detachedSnapshot(result.spent, "retained owner spend"),
|
|
24702
25102
|
...result.verdict ? { verdict: result.verdict } : {},
|
|
24703
25103
|
...result.outcome ? { outcome: result.outcome } : {},
|
|
@@ -25924,11 +26324,14 @@ async function reconcileScopeRetainedOwnerEnvironment(scope) {
|
|
|
25924
26324
|
environmentId
|
|
25925
26325
|
};
|
|
25926
26326
|
}
|
|
25927
|
-
/** Resume the original backend prompt; rebuilt coordination observations cannot replace it.
|
|
25928
|
-
|
|
26327
|
+
/** Resume the original backend prompt; rebuilt coordination observations cannot replace it.
|
|
26328
|
+
* `session: 'fresh'` makes every invocation after the first start a new harness session in the
|
|
26329
|
+
* environment it continues. */
|
|
26330
|
+
async function prepareScopeRetainedOwnerTask(scope, task, session = "native") {
|
|
25929
26331
|
const state = owners.get(scope);
|
|
25930
26332
|
if (!state) return task;
|
|
25931
26333
|
const { args } = state;
|
|
26334
|
+
state.freshSessions = session === "fresh";
|
|
25932
26335
|
scope.signal.throwIfAborted();
|
|
25933
26336
|
const owned = (await args.journal.loadTree(args.rootId) ?? []).filter((event) => event.id === args.nodeId);
|
|
25934
26337
|
const latestInput = [...owned].reverse().find((event) => event.kind === "execution-input");
|
|
@@ -26267,6 +26670,77 @@ function checkedSeatSelection(stage, selected) {
|
|
|
26267
26670
|
return selected;
|
|
26268
26671
|
}
|
|
26269
26672
|
//#endregion
|
|
26673
|
+
//#region src/runtime/supervise/worker-events.ts
|
|
26674
|
+
const MAX_EVENTS = 256;
|
|
26675
|
+
const MAX_BYTES = 262144;
|
|
26676
|
+
/** One worker's already-redacted live output. Accounting stays on Scope's existing usage channel. */
|
|
26677
|
+
var WorkerEvents = class {
|
|
26678
|
+
#epoch = randomUUID();
|
|
26679
|
+
#entries = [];
|
|
26680
|
+
#next = 0;
|
|
26681
|
+
#capturing = false;
|
|
26682
|
+
start() {
|
|
26683
|
+
this.#capturing = true;
|
|
26684
|
+
}
|
|
26685
|
+
#bytes = 0;
|
|
26686
|
+
append(event, at) {
|
|
26687
|
+
let entry = {
|
|
26688
|
+
sequence: this.#next++,
|
|
26689
|
+
at,
|
|
26690
|
+
event: defaultRedactor(event)
|
|
26691
|
+
};
|
|
26692
|
+
let bytes;
|
|
26693
|
+
try {
|
|
26694
|
+
bytes = Buffer.byteLength(JSON.stringify(entry));
|
|
26695
|
+
} catch {
|
|
26696
|
+
entry = {
|
|
26697
|
+
sequence: entry.sequence,
|
|
26698
|
+
at,
|
|
26699
|
+
event: null,
|
|
26700
|
+
omitted: "event-not-serializable"
|
|
26701
|
+
};
|
|
26702
|
+
bytes = Buffer.byteLength(JSON.stringify(entry));
|
|
26703
|
+
}
|
|
26704
|
+
if (bytes > MAX_BYTES) {
|
|
26705
|
+
entry = {
|
|
26706
|
+
sequence: entry.sequence,
|
|
26707
|
+
at,
|
|
26708
|
+
event: null,
|
|
26709
|
+
omitted: "event-too-large"
|
|
26710
|
+
};
|
|
26711
|
+
bytes = Buffer.byteLength(JSON.stringify(entry));
|
|
26712
|
+
}
|
|
26713
|
+
this.#entries.push({
|
|
26714
|
+
entry,
|
|
26715
|
+
bytes
|
|
26716
|
+
});
|
|
26717
|
+
this.#bytes += bytes;
|
|
26718
|
+
while (this.#entries.length > MAX_EVENTS || this.#bytes > MAX_BYTES) this.#bytes -= this.#entries.shift().bytes;
|
|
26719
|
+
}
|
|
26720
|
+
read(cursor) {
|
|
26721
|
+
if (!this.#capturing) return {
|
|
26722
|
+
status: "unavailable",
|
|
26723
|
+
reason: "not-captured"
|
|
26724
|
+
};
|
|
26725
|
+
if (cursor && (!Number.isSafeInteger(cursor.next) || cursor.next < 0)) throw new Error("worker event cursor must name a non-negative safe integer");
|
|
26726
|
+
const reset = cursor !== void 0 && cursor.epoch !== this.#epoch;
|
|
26727
|
+
const first = this.#entries[0]?.entry.sequence ?? this.#next;
|
|
26728
|
+
const start = reset ? first : cursor?.next ?? first;
|
|
26729
|
+
if (!reset && start > this.#next) throw new Error("worker event cursor is ahead of this stream");
|
|
26730
|
+
return {
|
|
26731
|
+
status: "available",
|
|
26732
|
+
entries: this.#entries.filter(({ entry }) => entry.sequence >= start).map(({ entry }) => structuredClone(entry)),
|
|
26733
|
+
cursor: {
|
|
26734
|
+
epoch: this.#epoch,
|
|
26735
|
+
next: this.#next
|
|
26736
|
+
},
|
|
26737
|
+
reset,
|
|
26738
|
+
historyExpired: start < first || cursor === void 0 && first > 0,
|
|
26739
|
+
remaining: 0
|
|
26740
|
+
};
|
|
26741
|
+
}
|
|
26742
|
+
};
|
|
26743
|
+
//#endregion
|
|
26270
26744
|
//#region src/runtime/supervise/scope.ts
|
|
26271
26745
|
/**
|
|
26272
26746
|
*
|
|
@@ -26805,6 +27279,7 @@ function createScope(args) {
|
|
|
26805
27279
|
const recoveryReady = recovery?.spawned.ownedTreeRoot === void 0 || budgetGranted !== void 0 ? void 0 : new Promise((resolve) => {
|
|
26806
27280
|
markRecoveryReady = resolve;
|
|
26807
27281
|
});
|
|
27282
|
+
const traceRoots = traceRootWriter(args.blobs, id);
|
|
26808
27283
|
const retainedWrites = /* @__PURE__ */ new Set();
|
|
26809
27284
|
let retainedWritesClosed = false;
|
|
26810
27285
|
const retainedWrite = (write) => {
|
|
@@ -26849,10 +27324,12 @@ function createScope(args) {
|
|
|
26849
27324
|
const outRef = contentAddress(result.out);
|
|
26850
27325
|
await args.blobs.put(outRef, result.out);
|
|
26851
27326
|
controller.signal.throwIfAborted();
|
|
27327
|
+
const traceRoot = await traceRoots.write(outRef, result.out);
|
|
26852
27328
|
await args.journal.appendEvent(args.root, {
|
|
26853
27329
|
kind: "execution-result",
|
|
26854
27330
|
id,
|
|
26855
27331
|
outRef,
|
|
27332
|
+
...traceRoot === void 0 ? {} : { traceRoot },
|
|
26856
27333
|
spent: result.spent,
|
|
26857
27334
|
...result.verdict ? { verdict: result.verdict } : {},
|
|
26858
27335
|
...result.outcome ? { outcome: result.outcome } : {},
|
|
@@ -26898,7 +27375,8 @@ function createScope(args) {
|
|
|
26898
27375
|
rootId: args.root,
|
|
26899
27376
|
nodeId: id,
|
|
26900
27377
|
nextSequence: () => ordinal,
|
|
26901
|
-
now
|
|
27378
|
+
now,
|
|
27379
|
+
traceRoots
|
|
26902
27380
|
}),
|
|
26903
27381
|
onPause,
|
|
26904
27382
|
onWorkspaceCapture,
|
|
@@ -26980,6 +27458,7 @@ function createScope(args) {
|
|
|
26980
27458
|
live.teardownAttempts += 1;
|
|
26981
27459
|
});
|
|
26982
27460
|
const live = {
|
|
27461
|
+
events: new WorkerEvents(),
|
|
26983
27462
|
id,
|
|
26984
27463
|
status: permit.granted ? "acquiring" : "queued",
|
|
26985
27464
|
runtime: executor.runtime,
|
|
@@ -26990,6 +27469,7 @@ function createScope(args) {
|
|
|
26990
27469
|
...opts.assignmentId === void 0 ? {} : { assignmentId: opts.assignmentId },
|
|
26991
27470
|
...opts.key !== void 0 ? { key: opts.key } : {},
|
|
26992
27471
|
spent: zeroSpend(),
|
|
27472
|
+
traceRoots,
|
|
26993
27473
|
settled: void 0,
|
|
26994
27474
|
delivered: false,
|
|
26995
27475
|
executorDone: false,
|
|
@@ -27209,12 +27689,20 @@ function createScope(args) {
|
|
|
27209
27689
|
const ready = await readInteractiveReadyUntilWorkerEnds(live.readInteractiveReady, childRun, controller.signal);
|
|
27210
27690
|
if (ready !== void 0 && (ready.status === "available" || ready.reason !== "interactive-session-not-started")) writeWorkerInteractiveBinding(args.interactiveBindingDir, id, opts.label, args.root, ready, now);
|
|
27211
27691
|
});
|
|
27212
|
-
const settled = childRun.then(async (
|
|
27692
|
+
const settled = childRun.then(async (ran) => {
|
|
27693
|
+
const traceRoot = await live.traceRoots.recorded(ran.outRef);
|
|
27694
|
+
const s = traceRoot === void 0 ? ran : {
|
|
27695
|
+
...ran,
|
|
27696
|
+
traceRoot
|
|
27697
|
+
};
|
|
27213
27698
|
let resolution = s;
|
|
27214
27699
|
try {
|
|
27215
27700
|
await interactiveBindingCommitted;
|
|
27216
27701
|
} catch {
|
|
27217
|
-
resolution =
|
|
27702
|
+
resolution = {
|
|
27703
|
+
...downRecord("interactive worker binding persistence failed", true, s.trace, s.metered, s.providerModel, s.outRef, s.harnessTranscript),
|
|
27704
|
+
...s.traceRoot === void 0 ? {} : { traceRoot: s.traceRoot }
|
|
27705
|
+
};
|
|
27218
27706
|
}
|
|
27219
27707
|
live.resolved = resolution;
|
|
27220
27708
|
return resolution;
|
|
@@ -27418,6 +27906,37 @@ function createScope(args) {
|
|
|
27418
27906
|
nextResolved,
|
|
27419
27907
|
send,
|
|
27420
27908
|
progress,
|
|
27909
|
+
observeTree: () => {
|
|
27910
|
+
const view = makeTreeView(args.parentId, children);
|
|
27911
|
+
const nodes = new Map((args.resumeFrom?.view.nodes ?? []).map((node) => [node.id, node]));
|
|
27912
|
+
for (const node of view.nodes) nodes.set(node.id, node);
|
|
27913
|
+
for (const child of children.values()) {
|
|
27914
|
+
const nested = child.readNestedScope?.();
|
|
27915
|
+
if (nested) for (const node of (nested.observeTree?.() ?? nested.view).nodes) nodes.set(node.id, node);
|
|
27916
|
+
}
|
|
27917
|
+
const all = [...nodes.values()];
|
|
27918
|
+
return {
|
|
27919
|
+
root: view.root,
|
|
27920
|
+
nodes: all,
|
|
27921
|
+
inFlight: all.filter((node) => [
|
|
27922
|
+
"queued",
|
|
27923
|
+
"acquiring",
|
|
27924
|
+
"running"
|
|
27925
|
+
].includes(node.status)).length
|
|
27926
|
+
};
|
|
27927
|
+
},
|
|
27928
|
+
observeEvents: (nodeId, cursor) => {
|
|
27929
|
+
const child = children.get(nodeId);
|
|
27930
|
+
if (child) return child.events.read(cursor);
|
|
27931
|
+
for (const candidate of children.values()) {
|
|
27932
|
+
const page = (candidate.readNestedScope?.())?.observeEvents?.(nodeId, cursor);
|
|
27933
|
+
if (page && (page.status === "available" || page.reason !== "unknown-worker")) return page;
|
|
27934
|
+
}
|
|
27935
|
+
return {
|
|
27936
|
+
status: "unavailable",
|
|
27937
|
+
reason: args.resumeFrom?.view.nodes.some((node) => node.id === nodeId) ? "not-captured" : "unknown-worker"
|
|
27938
|
+
};
|
|
27939
|
+
},
|
|
27421
27940
|
traceSource,
|
|
27422
27941
|
interactive,
|
|
27423
27942
|
cancel,
|
|
@@ -27636,7 +28155,7 @@ function createScope(args) {
|
|
|
27636
28155
|
const nested = child.readNestedScope?.();
|
|
27637
28156
|
if (nested !== void 0) await closeRetainedSlots(nested);
|
|
27638
28157
|
}
|
|
27639
|
-
const open = [...children.values()].filter((child) => child.recoveryPending === true &&
|
|
28158
|
+
const open = [...children.values()].filter((child) => child.recoveryPending === true && isTerminalNodeStatus(child.status) && child.retainedExecution !== "released" && child.retainedExecution !== "release-unconfirmed");
|
|
27640
28159
|
if (open.length === 0) return;
|
|
27641
28160
|
const prior = await args.journal.loadTree(args.root) ?? [];
|
|
27642
28161
|
for (const child of open) await closeRetainedSlot(child, "release-unconfirmed", prior);
|
|
@@ -28122,6 +28641,7 @@ async function finalizeSettlement(child, settlement, seq, args, now) {
|
|
|
28122
28641
|
id: child.id,
|
|
28123
28642
|
status: "done",
|
|
28124
28643
|
outRef: settlement.outRef,
|
|
28644
|
+
...settlement.traceRoot === void 0 ? {} : { traceRoot: settlement.traceRoot },
|
|
28125
28645
|
...settlement.verdict ? { verdict: settlement.verdict } : {},
|
|
28126
28646
|
spent: settlement.spent,
|
|
28127
28647
|
...settlement.providerModel ? { providerModel: settlement.providerModel } : {},
|
|
@@ -28201,6 +28721,7 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
|
|
|
28201
28721
|
const out = detachedSnapshot(result.out, "scope child output");
|
|
28202
28722
|
const outRef = contentAddress(out);
|
|
28203
28723
|
await blobs.put(outRef, out);
|
|
28724
|
+
await live.traceRoots.write(outRef, out);
|
|
28204
28725
|
retainedOutputRef = outRef;
|
|
28205
28726
|
if (usageError !== void 0) throw usageError;
|
|
28206
28727
|
return {
|
|
@@ -28271,6 +28792,7 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
|
|
|
28271
28792
|
const ran = recovering ? executor.recover(task, childAbort.signal) : executor.execute(task, childAbort.signal);
|
|
28272
28793
|
let artifact;
|
|
28273
28794
|
if (isAsyncIterable(ran)) {
|
|
28795
|
+
live.events.start();
|
|
28274
28796
|
const spend = await foldStream(ran, async (running) => {
|
|
28275
28797
|
live.spent = running;
|
|
28276
28798
|
live.lastActivityAt = now();
|
|
@@ -28281,7 +28803,7 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
|
|
|
28281
28803
|
seq: nextProgressSeq(),
|
|
28282
28804
|
at: new Date(now()).toISOString()
|
|
28283
28805
|
});
|
|
28284
|
-
}, childAbort.signal, priorSpent);
|
|
28806
|
+
}, childAbort.signal, priorSpent, (event) => live.events.append(event, now()));
|
|
28285
28807
|
live.spent = spend;
|
|
28286
28808
|
const reported = executor.resultArtifact();
|
|
28287
28809
|
artifact = await retainOutput(reported, preserveUnknownTelemetry(spend, reported.spent));
|
|
@@ -28645,7 +29167,7 @@ function freezeCorrelation(value) {
|
|
|
28645
29167
|
* turns deep from one that had produced nothing. It also means a worker that THROWS mid-stream
|
|
28646
29168
|
* now reconciles its real partial spend instead of refunding work the provider already billed.
|
|
28647
29169
|
*/
|
|
28648
|
-
async function foldStream(stream, onProgress, signal, priorSpent) {
|
|
29170
|
+
async function foldStream(stream, onProgress, signal, priorSpent, onEvent) {
|
|
28649
29171
|
const totals = newUsageTotals(priorSpent);
|
|
28650
29172
|
const iterator = stream[Symbol.asyncIterator]();
|
|
28651
29173
|
try {
|
|
@@ -28653,6 +29175,7 @@ async function foldStream(stream, onProgress, signal, priorSpent) {
|
|
|
28653
29175
|
const next = signal ? await awaitAbortable(Promise.resolve(iterator.next()), signal) : await iterator.next();
|
|
28654
29176
|
if (next.done) break;
|
|
28655
29177
|
const ev = next.value;
|
|
29178
|
+
if (ev.kind === "progress") onEvent?.(ev.progress);
|
|
28656
29179
|
meterUsageEvent(totals, ev);
|
|
28657
29180
|
await onProgress?.({
|
|
28658
29181
|
...addResourceSpend(totals.resources),
|
|
@@ -29372,6 +29895,7 @@ function upstreamUnavailableSignal(error) {
|
|
|
29372
29895
|
const admission = retainedAdmissionCause(error);
|
|
29373
29896
|
if (admission !== void 0) return upstreamUnavailableSignal(admission);
|
|
29374
29897
|
if (!(error instanceof Error)) return void 0;
|
|
29898
|
+
if (isCredentialRefusal(error)) return void 0;
|
|
29375
29899
|
if (isProviderSchemaRejection(error)) return void 0;
|
|
29376
29900
|
if (error instanceof CheckUnavailableError) return "check-unavailable";
|
|
29377
29901
|
if (error instanceof HarnessTurnFailedError) {
|
|
@@ -29436,6 +29960,7 @@ function classifyDriverFailure(error, signal) {
|
|
|
29436
29960
|
if (admission !== void 0) return classifyDriverFailure(admission, signal);
|
|
29437
29961
|
if (error instanceof Error && errorProperty(error, "name") === "AbortError") return "terminal";
|
|
29438
29962
|
if (error instanceof Error && isProviderSchemaRejection(error)) return "terminal";
|
|
29963
|
+
if (isCredentialRefusal(error)) return "terminal";
|
|
29439
29964
|
if (error instanceof HarnessTurnFailedError) {
|
|
29440
29965
|
if (error.errorCode !== void 0 && DETERMINISTIC_BRIDGE_CODES.has(error.errorCode)) return "terminal";
|
|
29441
29966
|
if (isUpstreamUnavailable(error)) return "unavailable";
|
|
@@ -29477,7 +30002,7 @@ function retainedAdmissionCause(error) {
|
|
|
29477
30002
|
if (errorProperty(value, "name") === "RetainedRunProviderContractError") return void 0;
|
|
29478
30003
|
const status = errorHttpStatus(value);
|
|
29479
30004
|
if (status !== void 0 && status >= 400) return error.pendingCause === "request-rejected" || UNAVAILABLE_STATUSES.has(status) ? value : void 0;
|
|
29480
|
-
if (error.pendingCause === "request-rejected" && (value instanceof AgentEvalError$1 || isProviderSchemaRejection(value) || isDispatchNotAdmitted(value) || capacityCode(value) !== void 0)) return value;
|
|
30005
|
+
if (error.pendingCause === "request-rejected" && (value instanceof AgentEvalError$1 || isProviderSchemaRejection(value) || isDispatchNotAdmitted(value) || isCredentialRefusal(value) || capacityCode(value) !== void 0)) return value;
|
|
29481
30006
|
const members = Reflect.get(value, "errors");
|
|
29482
30007
|
if (Array.isArray(members)) queue.push(...members.slice(0, 12 - steps));
|
|
29483
30008
|
queue.push(value.cause);
|
|
@@ -31009,6 +31534,6 @@ function isNonEmptySpend(s) {
|
|
|
31009
31534
|
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);
|
|
31010
31535
|
}
|
|
31011
31536
|
//#endregion
|
|
31012
|
-
export { environmentReader as $,
|
|
31537
|
+
export { environmentReader as $, runtimeOwnedExecutorProviderEvidence as $i, captureWorkerTraceEvidence as $n, flatOtelSpan as $r, PEER_MAIL_WIRE_KEY as $t, scopeOwnerExecutorNodeContext as A, promptControlProfileMaterialization as Ai, resolveAgentEnvironmentProvider as An, persistHarnessTranscript as Ar, captureReusableExecutorConfig as At, consumeScopeRetainedOwnerResult as B, attestRuntimeOwnedPendingExecutor as Bi, FileResultBlobStore as Bn, ROUTER_PRICE_SOURCE as Br, createInPlaceCliExecutor as Bt, deriveNodeExecutionIdentity as C, abortError$1 as Ca, AGENT_PROFILE_MATERIALIZATION_AXES as Ci, readPromptOptions as Cn, openSlotGroup as Cr, createContinuationKeeper as Ct, recordScopeOwnerMaterialization as D, providerMessageText as Da, defineProfileMaterializationContract as Di, createAgentEnvironmentProviderRegistry as Dn, runAbortable as Dr, passedItems as Dt, recordScopeOwnerDriverAttempt as E, promptOptionsFromAgentTurnInput as Ea, controlProfileMaterialization as Ei, LEAF_CONTINUATION_TASK as En, linkAbort as Er, failedItems as Et, seatExecutionProfile as F, renderUnsupported as Fi, retainedExecutorSeamKey as Fn, createCodeModeTools as Fr, snapshotExecutorConfig as Ft, scopeRetainedOwnerContext as G, knownExecutionBindingReceipt as Gi, loadSpawnForest as Gn, defaultRedactor as Gr, workerTraceSeamKey as Gt, prepareScopeRetainedOwnerSeatSwitch as H, authoredProfileDigest as Hi, InMemoryResultBlobStore as Hn, mergeTraceEnv as Hr, readWorkerTraceContext as Ht, abandonScopeRetainedOwnerInvocation as I, sandboxActProfileMaterialization as Ii, unavailablePauseMs as In, describeCodeModeTools as Ir, createWorktreeCliExecutor as It, scopeRetainedOwnerResourceReader as J, providerAttemptEvidence as Ji, isNoEntError as Jn, buildLoopOtelSpans as Jr, createActivityLog as Jt, scopeRetainedOwnerJournalRoot as K, knownMaterializationReceipt as Ki, materializeTreeView as Kn, defaultRedactorIdentityMaterial as Kr, taskToPrompt as Kt, beginScopeRetainedOwnerDrive as L, unsupportedProfileDimensions as Li, unavailableSignalOfFailure as Ln, runCodeMode as Lr, DEFAULT_SANDBOX_STEERING_MAX_TURNS as Lt, SeatChain as M, promptOnlyProfileMaterialization as Mi, decodeToolPart as Mn, resolveHarnessTranscriptCapture as Mr, cliWorktreeExecutor as Mt, SeatChainExhaustedError as N, promptResourceProfileMaterialization as Ni, sandboxSessionTraceSource as Nn, retainHarnessTranscript as Nr, createExecutor as Nt, recordScopeOwnerPause as O, fullProfileMaterialization as Oi, providerAsExecutor as On, captureHarnessTranscript as Or, verdictFromJudgeScore as Ot, authoredSeatStages as P, renderProfileMaterializationIssues as Pi, registerRetainedExecutorPreparation as Pn, contentAddress as Pr, createExecutorRegistry as Pt, SPAWN_RESOURCE_PATH_MAX_BYTES as Q, runtimeOwnedExecutorMaterialization as Qi, WORKER_TOOL_TRACE_SCHEMA_VERSION as Qn, createOtelExporter as Qr, DEFAULT_PEER_MAIL_LIMITS as Qt, bindScopeRetainedOwnerEnvironmentId as R, validateProfileMaterialization as Ri, TRACE_ROOT_SCHEMA as Rn, priceTokens as Rr, createSteerableSandboxSession as Rt, createScope as S, decodeHarnessUsage as Sa, terminateProcessTreeAndConfirm as Si, assertBoxlessPromptOptions as Sn, createWorkerSlots as Sr, checkVerdictOf as St, meterRuntimeOwnedProviderAttempt as T, promptFromAgentTurnInput as Ta, assertProfileMaterializes as Ti, runBrainLoop as Tn, abortError as Tr, expandQuestions as Tt, prepareScopeRetainedOwnerTask as U, finalizeRuntimeOwnedPendingExecutor as Ui, InMemorySpawnJournal as Un, readTraceContextFromEnv as Ur, workerTraceEnv as Ut, noteScopeRetainedOwnerCoordination as V, attestRuntimeOwnedScopeOwner as Vi, FileSpawnJournal as Vn, createPropagatingTraceEmitter as Vr, WORKER_TRACE_PROPAGATION as Vt, reconcileScopeRetainedOwnerEnvironment as W, inheritRuntimeOwnedExecutorAttestation as Wi, insideCursorNamespace as Wn, traceContextToEnv as Wr, workerTraceHeaders as Wt, scopeRetainedOwnerResult as X, runtimeOwnedDriveHarnessProviderEvidence as Xi, readCommittedJsonLines as Xn, buildRuntimeEventOtelSpans as Xr, createInbox as Xt, scopeRetainedOwnerRestorePoint as Y, recordRuntimeOwnedDriveHarnessProviderEvidence as Yi, prepareJsonlAppend as Yn, buildLoopSpanNodes as Yr, readWorkerProgress as Yt, scopeRetainedOwnerTurnEnded as Z, runtimeOwnedExecutorExecutionBinding as Zi, writeAllBytes as Zn, createOpenInferenceFileExporter as Zr, AUTHORITY_MARKERS as Zt, isDriverSpec as _, mapSandboxToolEvent as _a, harnessInvocation as _i, runAgentRounds as _n, startRetainedRun as _r, CONTINUATION_FACTS as _t, collectDelivered as a, executableAgentSpecSnapshot as aa, createRuntimeEventCollector as ai, isLiveNodeStatus as an, ReservationWaitRefused as ar, interactiveAdmissionSeamKey as at, assertRecursiveReservationPolicy as b, sandboxProgressEvents as ba, parseCodexTokenUsage as bi, SandboxEvidenceRetentionError as bn, destroyInteractiveEnvironment as br, admitFinding as bt, runTree as c, projectSandboxOutcome as ca, sanitizeKnowledgeReadinessReport as ci, bridgeModelRouteRefusal as cn, meterUsageEvent as cr, reconnectRetainedInteractiveRun as ct, classifyDriverFailure as d, canonicalStreamEventFromSandboxEvent as da, runWorktreeHarness as di, harnessUsageIsEmpty as dn, spendFromUsageTotals as dr, freeSlots as dt, runtimeOwnedPendingExecutorMaterialization as ea, generateSpanId as ei, claimsAuthority as en, isTraceAnalysisStore as er, hostDirectoryReader as et, runDriverWithRetry as f, createSandboxToolPartState as fa, captureWorktreeDiff as fi, readCodexRolloutSession as fn, bridgeRuntimeAttachmentsKey as fr, queueOf as ft, driverExecutorFactory as g, mapSandboxEvent as ga, LOCAL_HARNESSES as gi, isTerminalDecision as gn, recoverRetainedRun as gr, CONTINUATIONS_DIR as gt, driverChild as h, isSandboxTerminalEvent as ha, DEFAULT_LOCAL_HARNESS as hi, defaultSelectWinner as hn, reconnectRetainedRun as hr, mapExecutorResult as ht, bestDelivered as i, executableAgentProfileSnapshot as ia, toOtelAttributes as ii, peerMailVerbNames as in, BudgetReconcileFault as ir, providerVisibleProfile as it, settledToIteration as j, promptModelProfileMaterialization as ji, createPushTraceSource as jn, readHarnessTranscript as jr, cliInPlaceExecutor as jt, restoreScopeOwnerAcceptedExecution as k, profileMaterializationAxes$1 as ki, providerAsSandboxClient as kn, harnessTranscriptArtifact as kr, bindReusableExecutorExecutionId as kt, DriverAttemptsExhaustedError as l, readSandboxOutcome as la, sanitizeRuntimeStreamEvent as li, addHarnessUsage as ln, newUsageTotals as lr, recoverRetainedInteractiveRun as lt, upstreamUnavailableSignal as m, extractLlmCallEvent as ma, removeWorktree as mi, createSandboxForSpec as mn, errMessage as mr, gateOnDeliverable as mt, createRootHandle as n, unknownExecutionBindingReceipt as na, padSpanId as ni, isPeerMailEnvelope as nn, workerTraceAnalysisStore as nr, coordinationMcpAlias as nt, pickBestDelivered as o, detachedFrozen as oa, createRuntimeStreamEventCollector as oi, isTerminalNodeStatus as on, assertValidBudget as or, attachWorker as ot, summarizeDriverAttempts as p, createSandboxUsageLedger as pa, createWorktree as pi, TERMINAL_DECISIONS as pn, bridgeStopSignalKey as pr, rollingDispatch as pt, scopeRetainedOwnerPriorSpend as q, newExecutionAttemptId as qi, replaySpawnTree as qn, resolveRedactor as qr, DEFAULT_STALL_AFTER_MS as qt, createSupervisor as r, unknownMaterializationReceipt as ra, padTraceId as ri, peerMailTools as rn, executorFailure as rr, coordinationProfileToolPrefix as rt, runFinalizer as s, detachedSnapshot as sa, sanitizeAgentRuntimeEvent as si, bridgeAdmissionRefusal as sn, createBudgetPool as sr, readWorkerInteractiveBinding as st, DEFAULT_MAX_DEPTH as t, runtimeOwnedScopeOwnerRuntime as ta, loopEventToOtelSpan as ti, createPeerMailbox as tn, parseWorkerToolTraceArtifact as tr, resolveSpawnResourcePaths as tt, HarnessTurnFailedError as u, assertSandboxServedModel as ua, runSettledCommand as ui, createCodexRolloutStoreReader as un, spendFromUsageEvents as ur, startRetainedInteractiveRun as ut, withDriverExecutor as v, notifySandboxEventObserver as va, harnessSupportsReasoningEffort as vi, createSandboxLineage as vn, startRetainedRunInEnvironment as vr, CheckUnavailableError as vt, meterRuntimeOwnedAccounting as w, awaitAbortable$1 as wa, assertProfileMaterialization as wi, routerBrain as wn, RunCancellationReason as wr, distillFindings as wt, beginScopeOwnerAttempt as x, sumSandboxUsage as xa, CodexExecutionDiagnosticError as xi, captureBeforeDestroy as xn, environmentGone as xr, bestComposite as xt, SUBTREE_RESULT_LIMIT as y, sandboxEventServedBackend as ya, localHarnessExecutable as yi, acquireSandbox as yn, retainedCreateMaterial as yr, admitContinuationPolicy as yt, bindScopeRetainedOwnerProvider as z, worktreeCliProfileMaterialization as zi, TRACE_SUMMARY_SCHEMA as zn, routerTokenPrice as zr, createRouterTranscript as zt };
|
|
31013
31538
|
|
|
31014
|
-
//# sourceMappingURL=supervisor-
|
|
31539
|
+
//# sourceMappingURL=supervisor-BMMdI4T-.js.map
|