@tangle-network/agent-runtime 0.196.0 → 0.198.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.
Files changed (102) hide show
  1. package/README.md +1 -2
  2. package/dist/{activation-BxMZybuo.js → activation-CwdO0ml2.js} +2 -2
  3. package/dist/{activation-BxMZybuo.js.map → activation-CwdO0ml2.js.map} +1 -1
  4. package/dist/{improve-DZs0KXhK.d.ts → activation-DFRTurvU.d.ts} +99 -5
  5. package/dist/agent.d.ts +1 -1
  6. package/dist/agent.js +2 -2
  7. package/dist/candidate-execution/index.d.ts +370 -2
  8. package/dist/candidate-execution/index.js +828 -4
  9. package/dist/candidate-execution/index.js.map +1 -0
  10. package/dist/{coordination-driver-zkCrfEbS.js → coordination-driver-Cf638-6q.js} +2 -5
  11. package/dist/{coordination-driver-zkCrfEbS.js.map → coordination-driver-Cf638-6q.js.map} +1 -1
  12. package/dist/{delegate-D7sonS78.js → delegate-Bez07Dlh.js} +2 -2
  13. package/dist/{delegate-D7sonS78.js.map → delegate-Bez07Dlh.js.map} +1 -1
  14. package/dist/durable.d.ts +110 -6
  15. package/dist/durable.js +404 -47
  16. package/dist/durable.js.map +1 -1
  17. package/dist/{graph-BuS-NxXD.js → graph-DBk3Unto.js} +3 -3
  18. package/dist/{graph-BuS-NxXD.js.map → graph-DBk3Unto.js.map} +1 -1
  19. package/dist/{improvement-cycle-Tw5nYT5R.js → improvement-cycle-Bma8TJs-.js} +8 -10
  20. package/dist/{improvement-cycle-Tw5nYT5R.js.map → improvement-cycle-Bma8TJs-.js.map} +1 -1
  21. package/dist/{index-CYOJsxSg.d.ts → index-D8LWK3Ha.d.ts} +6 -7
  22. package/dist/index.d.ts +694 -16
  23. package/dist/index.js +1780 -17
  24. package/dist/index.js.map +1 -1
  25. package/dist/intelligence.d.ts +3 -7
  26. package/dist/intelligence.js +5 -6
  27. package/dist/intelligence.js.map +1 -1
  28. package/dist/kernel.d.ts +2 -5
  29. package/dist/kernel.js +8 -10
  30. package/dist/{loop-runner-bin-XKMc3Ld-.js → loop-runner-bin-Bd3dHQuw.js} +3 -3
  31. package/dist/{loop-runner-bin-XKMc3Ld-.js.map → loop-runner-bin-Bd3dHQuw.js.map} +1 -1
  32. package/dist/{loop-runner-bin-DwrSB04m.d.ts → loop-runner-bin-Bn-0o_4k.d.ts} +3 -3
  33. package/dist/loop-runner-bin.d.ts +1 -1
  34. package/dist/loop-runner-bin.js +1 -1
  35. package/dist/mcp/bin.js +3 -3
  36. package/dist/mcp/index.d.ts +2 -3
  37. package/dist/mcp/index.js +4 -5
  38. package/dist/mcp/index.js.map +1 -1
  39. package/dist/{prepare-DDGp0-rW.js → prepare-CAO1yXov.js} +2407 -2407
  40. package/dist/prepare-CAO1yXov.js.map +1 -0
  41. package/dist/{protected-model-port-DxFN8DLS.js → protected-model-port-B5avcRiQ.js} +2 -2
  42. package/dist/{protected-model-port-DxFN8DLS.js.map → protected-model-port-B5avcRiQ.js.map} +1 -1
  43. package/dist/{provision-supervisor-CpMMShE_.js → provision-supervisor-C97q5NN_.js} +3 -6
  44. package/dist/{provision-supervisor-CpMMShE_.js.map → provision-supervisor-C97q5NN_.js.map} +1 -1
  45. package/dist/{redact-Cbl2O-4N.js → redact-CVyxp2AU.js} +5232 -2525
  46. package/dist/redact-CVyxp2AU.js.map +1 -0
  47. package/dist/{runtime-DqRieJ6e.js → runtime-BrTBBSfC.js} +427 -23
  48. package/dist/runtime-BrTBBSfC.js.map +1 -0
  49. package/dist/{server-BjB6ay4N.js → server-CO4bvAwe.js} +4 -4
  50. package/dist/{server-BjB6ay4N.js.map → server-CO4bvAwe.js.map} +1 -1
  51. package/dist/{types-DFLZMaeh.d.ts → stream-agent-turn-CLOQr497.d.ts} +1986 -6
  52. package/dist/{structural-rollout-DPbZWgEm.js → structural-rollout-D__lmWXe.js} +1101 -8
  53. package/dist/structural-rollout-D__lmWXe.js.map +1 -0
  54. package/dist/{supervise-D9aNi8_f.js → supervise-KSe4JEcg.js} +30 -7
  55. package/dist/supervise-KSe4JEcg.js.map +1 -0
  56. package/dist/testing.d.ts +2 -2
  57. package/dist/testing.js +13 -13
  58. package/dist/tui/index.d.ts +1 -1
  59. package/dist/tui/index.js +1 -1
  60. package/dist/{workspace-archive-Ybomp7AN.js → workspace-archive-BMOnloFf.js} +3 -3
  61. package/dist/{workspace-archive-Ybomp7AN.js.map → workspace-archive-BMOnloFf.js.map} +1 -1
  62. package/package.json +4 -31
  63. package/dist/activation-DyWB0K6E.d.ts +0 -98
  64. package/dist/authored-code-URmkdgjv.js +0 -37
  65. package/dist/authored-code-URmkdgjv.js.map +0 -1
  66. package/dist/candidate-execution-nvqVIMyS.js +0 -829
  67. package/dist/candidate-execution-nvqVIMyS.js.map +0 -1
  68. package/dist/conversation-BxJ0SIBM.js +0 -1363
  69. package/dist/conversation-BxJ0SIBM.js.map +0 -1
  70. package/dist/conversation.d.ts +0 -2
  71. package/dist/conversation.js +0 -2
  72. package/dist/environment-provider-1fKZh2zl.js +0 -2281
  73. package/dist/environment-provider-1fKZh2zl.js.map +0 -1
  74. package/dist/environment-provider-B-I2jlQy.d.ts +0 -143
  75. package/dist/environment-provider.d.ts +0 -2
  76. package/dist/environment-provider.js +0 -2
  77. package/dist/graph.d.ts +0 -753
  78. package/dist/graph.js +0 -2111
  79. package/dist/graph.js.map +0 -1
  80. package/dist/index-CUosKU4N.d.ts +0 -372
  81. package/dist/index-D9mb6fn2.d.ts +0 -691
  82. package/dist/index-ZnxSe6iK.d.ts +0 -138
  83. package/dist/jsonl-file-BEpaEYjT.js +0 -141
  84. package/dist/jsonl-file-BEpaEYjT.js.map +0 -1
  85. package/dist/knowledge-CPzT_Ve7.js +0 -428
  86. package/dist/knowledge-CPzT_Ve7.js.map +0 -1
  87. package/dist/knowledge.d.ts +0 -2
  88. package/dist/knowledge.js +0 -2
  89. package/dist/materialization-Cy0oM8tb.js +0 -672
  90. package/dist/materialization-Cy0oM8tb.js.map +0 -1
  91. package/dist/prepare-DDGp0-rW.js.map +0 -1
  92. package/dist/primeintellect/index.d.ts +0 -218
  93. package/dist/primeintellect/index.js +0 -739
  94. package/dist/primeintellect/index.js.map +0 -1
  95. package/dist/redact-Cbl2O-4N.js.map +0 -1
  96. package/dist/runtime-0xNaV6TJ.d.ts +0 -1699
  97. package/dist/runtime-DqRieJ6e.js.map +0 -1
  98. package/dist/stream-agent-turn-Dt5mZpc3.js +0 -1103
  99. package/dist/stream-agent-turn-Dt5mZpc3.js.map +0 -1
  100. package/dist/stream-agent-turn-urHpmO_Z.d.ts +0 -160
  101. package/dist/structural-rollout-DPbZWgEm.js.map +0 -1
  102. package/dist/supervise-D9aNi8_f.js.map +0 -1
@@ -1,37 +1,395 @@
1
- import { E as detachedFrozen } from "./materialization-Cy0oM8tb.js";
1
+ import { $r as executableAgentProfileSnapshot, $t as defaultSelectWinner, Bt as insideCursorNamespace, Cn as randomSuffix, K as rollingDispatch, Mr as parseCommittedJsonLines, Nr as prepareJsonlAppend, Pr as writeAllBytes, Rt as InMemoryResultBlobStore, Tn as stringifySafe, Xt as contentAddress, _n as chargedTokens, _t as createPushTraceSource, a as createSupervisor, an as assertBoxlessPromptOptions, b as settledToIteration, bn as hasCompleteCacheBreakdown, cn as runBrainLoop, ei as executableAgentSpecSnapshot, f as withDriverExecutor, gn as addSpend, jr as isNoEntError, kn as zeroSpend, ln as canonicalObservedModelParts, lt as createWorktreeCliExecutor, nn as createSandboxLineage, on as readPromptOptions, ot as createExecutor, qt as isTraceAnalysisStore, rn as probeSandboxCapabilities, sn as routerBrain, st as createExecutorRegistry, ti as detachedFrozen, tn as runAgentRounds, vn as cloneSpend, wn as sleep, xn as isAbortError, zt as InMemorySpawnJournal } from "./redact-CVyxp2AU.js";
2
2
  import { m as ValidationError, n as AnalystError, s as PlannerError } from "./errors-DodWX-cb.js";
3
- import "./stream-agent-turn-Dt5mZpc3.js";
4
- import { f as sha256Bytes, i as redactProtectedValue, o as canonicalCandidateDigest$1, r as redactProtectedReason, u as immutableCandidateValue } from "./protected-redaction-wGo44k2K.js";
3
+ import { C as observe, O as strategyAuthorMethod, T as profileChatClient, b as sample, v as refine, x as sampleThenRefine, y as runAgentic } from "./structural-rollout-D__lmWXe.js";
5
4
  import { l as notifySandboxEventObserver } from "./sandbox-events-DbC2WKKS.js";
6
- import { a as executableAgentProfileSnapshot, i as writeAllBytes, n as parseCommittedJsonLines, o as executableAgentSpecSnapshot, r as prepareJsonlAppend, t as isNoEntError } from "./jsonl-file-BEpaEYjT.js";
7
5
  import { c as profileModelExecutionSettings, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, t as assertExecutableAgentProfile } from "./model-policy-DKDyr-fc.js";
8
- import { C as settledToIteration, Ht as InMemorySpawnJournal, Vt as InMemoryResultBlobStore, Wt as insideCursorNamespace, Y as rollingDispatch, Zt as isTraceAnalysisStore, a as createSupervisor, an as runAgentRounds, bt as createPushTraceSource, dn as routerBrain, en as contentAddress, fn as runBrainLoop, ft as createWorktreeCliExecutor, h as withDriverExecutor, ln as assertBoxlessPromptOptions, lt as createExecutor, on as createSandboxLineage, pn as canonicalObservedModelParts, rn as defaultSelectWinner, sn as probeSandboxCapabilities, un as readPromptOptions, ut as createExecutorRegistry } from "./redact-Cbl2O-4N.js";
9
- import { E as zeroSpend, _ as randomSuffix, b as sleep, l as chargedTokens, m as isAbortError, p as hasCompleteCacheBreakdown, s as addSpend, u as cloneSpend, x as stringifySafe } from "./environment-provider-1fKZh2zl.js";
10
6
  import { i as notifyRuntimeHookEvent } from "./runtime-hooks-tXpAarhW.js";
11
- import { C as observe, O as strategyAuthorMethod, T as profileChatClient, b as sample, v as refine, x as sampleThenRefine, y as runAgentic } from "./structural-rollout-DPbZWgEm.js";
12
- import { b as mapExecutorResult, n as supervise, y as gateOnDeliverable } from "./supervise-D9aNi8_f.js";
13
- import "./coordination-driver-zkCrfEbS.js";
7
+ import { f as sha256Bytes, i as redactProtectedValue, o as canonicalCandidateDigest$1, r as redactProtectedReason, u as immutableCandidateValue } from "./protected-redaction-wGo44k2K.js";
8
+ import { b as mapExecutorResult, n as supervise, y as gateOnDeliverable } from "./supervise-KSe4JEcg.js";
9
+ import "./coordination-driver-Cf638-6q.js";
14
10
  import "./run-layout-B8I_LXN-.js";
15
- import "./provision-supervisor-CpMMShE_.js";
16
- import { t as assertAuthoredCode } from "./authored-code-URmkdgjv.js";
17
- import "./delegate-D7sonS78.js";
18
- import "./graph-BuS-NxXD.js";
11
+ import "./provision-supervisor-C97q5NN_.js";
12
+ import "./delegate-Bez07Dlh.js";
13
+ import "./graph-DBk3Unto.js";
19
14
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
20
15
  import { CODING_HARNESSES, DEFAULT_TRACE_ANALYST_KINDS, InMemoryTraceStore, OUTPUT_VALUE, benjaminiHochberg, buildTrajectory, computeFindingId as computeFindingId$1, confidenceInterval, createTraceAnalyst, expandProfileAxes, makeFinding as makeFinding$1, pairedBootstrap, paretoFrontier, wilcoxonSignedRank, wilson } from "@tangle-network/agent-eval";
16
+ import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
21
17
  import { createHash, randomUUID } from "node:crypto";
18
+ import { execFileSync, spawn, spawnSync } from "node:child_process";
22
19
  import { appendFileSync, chmodSync, constants, copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readlinkSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
23
- import { mkdir, readFile, realpath, writeFile } from "node:fs/promises";
24
20
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
25
- import { heldoutSignificance, runProfileMatrix } from "@tangle-network/agent-eval/campaign";
26
- import { execFileSync, spawn, spawnSync } from "node:child_process";
21
+ import { mkdir, readFile, realpath, writeFile } from "node:fs/promises";
27
22
  import { tmpdir } from "node:os";
28
- import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
23
+ import { isDeepStrictEqual } from "node:util";
29
24
  import { collectAgentResponseText } from "@tangle-network/sandbox";
25
+ import { heldoutSignificance, runProfileMatrix } from "@tangle-network/agent-eval/campaign";
30
26
  import { createInterface } from "node:readline";
31
27
  import { pathToFileURL } from "node:url";
32
28
  import { gzipSync } from "node:zlib";
33
29
  import { createContext, runInContext } from "node:vm";
34
30
  import { stuckLoopView, toolWasteView } from "@tangle-network/agent-eval/pipelines";
31
+ //#region src/runtime/tangle-sandbox-exact-process-provider.ts
32
+ const exactProcessProviderMarker = "agent-runtime.exact-process-provider";
33
+ const exactProcessEgressMarker = "agent-runtime.exact-process-egress";
34
+ /**
35
+ * Adapt Tangle Sandbox's managed control runtime to Runtime's exact-process provider.
36
+ *
37
+ * The adapter deliberately exposes no ordinary agent environment: an exact experiment
38
+ * must start a fresh Sandbox with no managed agent and launch its declared argv directly.
39
+ */
40
+ function createTangleSandboxExactProcessProvider(client, options = {}) {
41
+ const name = options.name ?? "tangle-sandbox-exact-process";
42
+ if (!name.trim()) throw new Error("Tangle Sandbox exact-process provider name must not be empty");
43
+ return {
44
+ name,
45
+ exactProcess: {
46
+ async create(input) {
47
+ throwIfAborted(input.signal);
48
+ assertNoProviderOptions(input.providerOptions);
49
+ const egressPolicy = sandboxEgressPolicy(input.egress);
50
+ const metadata = exactMetadata(input.metadata, name, egressPolicy);
51
+ const sandbox = await client.create({
52
+ environment: requiredText(input.image, "exact-process image"),
53
+ agent: false,
54
+ bare: false,
55
+ ephemeral: true,
56
+ egressPolicy,
57
+ resources: sandboxResources(input),
58
+ maxLifetimeSeconds: sandboxLifetimeSeconds(input.maxLifetimeMs),
59
+ metadata,
60
+ idempotencyKey: requiredText(input.idempotencyKey, "exact-process idempotency key")
61
+ }, {
62
+ ...input.provisionTimeoutMs === void 0 ? {} : { timeoutMs: positiveInteger(input.provisionTimeoutMs, "provision timeout") },
63
+ ...input.signal === void 0 ? {} : { signal: input.signal }
64
+ });
65
+ try {
66
+ throwIfAborted(input.signal);
67
+ assertExactSandboxMetadata(sandbox, metadata);
68
+ await assertExactSandboxEgress(sandbox, egressPolicy);
69
+ } catch (error) {
70
+ await discardInvalidSandbox(sandbox, error);
71
+ }
72
+ return sandboxAsExactProcessEnvironment(sandbox, name);
73
+ },
74
+ async get(id) {
75
+ const sandbox = await client.get(id);
76
+ if (!sandbox || !isExactSandbox(sandbox, name)) return null;
77
+ await assertExactSandboxEgress(sandbox, egressFromMetadata(sandbox.metadata));
78
+ return sandboxAsExactProcessEnvironment(sandbox, name);
79
+ },
80
+ async list(query) {
81
+ assertNoProviderOptions(query?.providerOptions);
82
+ const sandboxes = await client.list();
83
+ return Promise.all(sandboxes.filter((sandbox) => isExactSandbox(sandbox, name)).filter((sandbox) => metadataMatches(sandbox.metadata, query?.metadata)).map(async (sandbox) => {
84
+ await assertExactSandboxEgress(sandbox, egressFromMetadata(sandbox.metadata));
85
+ return sandboxAsExactProcessEnvironment(sandbox, name);
86
+ }));
87
+ }
88
+ },
89
+ capabilities: exactProcessOnlyCapabilities,
90
+ async create() {
91
+ throw new Error(`agent environment provider "${name}" supports exactProcess.create() only`);
92
+ }
93
+ };
94
+ }
95
+ function sandboxAsExactProcessEnvironment(sandbox, provider) {
96
+ return {
97
+ id: requiredText(sandbox.id, "Sandbox id"),
98
+ provider,
99
+ ...sandbox.metadata ? { metadata: sandbox.metadata } : {},
100
+ process: {
101
+ async list() {
102
+ return (await sandbox.process.list()).map((status) => exactProcessStatus(status));
103
+ },
104
+ async get(pid) {
105
+ const process = await sandbox.process.get(pid);
106
+ return process ? sandboxProcessAsExactProcess(process) : null;
107
+ },
108
+ async spawn(input, options) {
109
+ return sandboxProcessAsExactProcess(await afterAbortCheck(options?.signal, () => sandbox.process.spawnExact(input.executable, [...input.args], {
110
+ cwd: input.cwd,
111
+ env: { ...input.env },
112
+ inheritEnv: false,
113
+ ...input.stdin === void 0 ? {} : { stdin: input.stdin },
114
+ timeoutMs: input.timeoutMs
115
+ })));
116
+ }
117
+ },
118
+ async writeFile(path, bytes, options) {
119
+ if (sandbox.fs.supportsWriteMode !== true) throw new Error("Tangle Sandbox does not declare exact file-mode support");
120
+ await afterAbortCheck(options.signal, () => sandbox.fs.write(path, Buffer.from(bytes).toString("base64"), {
121
+ encoding: "base64",
122
+ mode: fileMode(options.mode)
123
+ }));
124
+ },
125
+ async readFile(path, options) {
126
+ const maxBytes = nonnegativeInteger(options.maxBytes, "exact-process file read maximum");
127
+ const initialSize = nonnegativeInteger((await afterAbortCheck(options.signal, () => sandbox.fs.stat(path))).size, `Tangle Sandbox file size for "${path}"`);
128
+ if (initialSize > maxBytes) throw new Error(`Tangle Sandbox file "${path}" exceeds the ${maxBytes}-byte exact read maximum`);
129
+ const result = await afterAbortCheck(options.signal, () => sandbox.fs.readBatch([path], { encoding: "base64" }));
130
+ const failure = result.errors.find((entry) => entry.path === path);
131
+ if (failure) throw new Error(`Tangle Sandbox failed to read "${path}": ${failure.error}`);
132
+ const files = result.files.filter((entry) => entry.path === path);
133
+ if (files.length !== 1) throw new Error(`Tangle Sandbox returned ${files.length} files for exact read "${path}"`);
134
+ const file = files[0];
135
+ if (file.encoding !== "base64") throw new Error(`Tangle Sandbox returned non-binary content for exact read "${path}"`);
136
+ const size = nonnegativeInteger(file.size, `Tangle Sandbox file size for "${path}"`);
137
+ if (size !== initialSize) throw new Error(`Tangle Sandbox file "${path}" changed during exact read`);
138
+ if (size > maxBytes) throw new Error(`Tangle Sandbox file "${path}" exceeds the ${maxBytes}-byte exact read maximum`);
139
+ const bytes = Buffer.from(file.content, "base64");
140
+ if (bytes.byteLength !== size || bytes.toString("base64") !== file.content) throw new Error(`Tangle Sandbox returned an invalid binary payload for exact read "${path}"`);
141
+ return Uint8Array.from(bytes);
142
+ },
143
+ async destroy() {
144
+ await sandbox.delete();
145
+ }
146
+ };
147
+ }
148
+ function sandboxProcessAsExactProcess(process) {
149
+ const pid = positiveInteger(process.pid, "Tangle Sandbox process pid");
150
+ return {
151
+ pid,
152
+ async status() {
153
+ return exactProcessStatus(await process.status(), pid);
154
+ },
155
+ async wait() {
156
+ const waitExitCode = await process.wait();
157
+ if (!Number.isSafeInteger(waitExitCode)) throw new Error("Tangle Sandbox process wait returned an invalid exit code");
158
+ const status = exactProcessStatus(await process.status(), pid);
159
+ if (status.running || !status.termination) throw new Error("Tangle Sandbox process wait returned before terminal status");
160
+ if (status.termination.kind === "exit" && status.termination.exitCode !== waitExitCode) throw new Error("Tangle Sandbox process wait and status disagree on exit code");
161
+ return status.termination;
162
+ },
163
+ async kill() {
164
+ await process.kill("SIGKILL", { tree: true });
165
+ },
166
+ async *stdout() {
167
+ yield* process.stdout();
168
+ },
169
+ async *stderr() {
170
+ yield* process.stderr();
171
+ }
172
+ };
173
+ }
174
+ function exactProcessStatus(status, expectedPid) {
175
+ const pid = positiveInteger(status.pid, "Tangle Sandbox process pid");
176
+ if (expectedPid !== void 0 && pid !== expectedPid) throw new Error("Tangle Sandbox process status changed process identity");
177
+ if (typeof status.running !== "boolean") throw new Error("Tangle Sandbox process status is missing running state");
178
+ if (!Number.isSafeInteger(status.exitCode)) throw new Error("Tangle Sandbox process status is missing an integer exit code");
179
+ const exitSignal = optionalText(status.exitSignal, "Tangle Sandbox process exit signal");
180
+ if (status.running) {
181
+ if (status.exitCode !== -1) throw new Error("Tangle Sandbox running process must report exit code -1");
182
+ if (exitSignal) throw new Error("Tangle Sandbox running process must not report an exit signal");
183
+ return {
184
+ pid,
185
+ running: true,
186
+ exitCode: -1
187
+ };
188
+ }
189
+ const termination = exitSignal ? {
190
+ kind: "signal",
191
+ signal: exitSignal
192
+ } : status.exitCode >= 0 ? {
193
+ kind: "exit",
194
+ exitCode: status.exitCode
195
+ } : void 0;
196
+ if (!termination) throw new Error("Tangle Sandbox stopped process has no terminal reason");
197
+ return {
198
+ pid,
199
+ running: false,
200
+ exitCode: status.exitCode,
201
+ ...exitSignal ? { exitSignal } : {},
202
+ termination
203
+ };
204
+ }
205
+ function exactMetadata(metadata, provider, egressPolicy) {
206
+ for (const marker of [exactProcessProviderMarker, exactProcessEgressMarker]) if (Object.hasOwn(metadata, marker)) throw new Error(`exact-process metadata must not set "${marker}"`);
207
+ return {
208
+ ...metadata,
209
+ [exactProcessProviderMarker]: provider,
210
+ [exactProcessEgressMarker]: serializeEgressPolicy(egressPolicy)
211
+ };
212
+ }
213
+ function isExactSandbox(sandbox, provider) {
214
+ return sandbox.metadata?.[exactProcessProviderMarker] === provider;
215
+ }
216
+ function metadataMatches(metadata, expected) {
217
+ return expected === void 0 || Object.entries(expected).every(([key, value]) => isDeepStrictEqual(metadata?.[key], value));
218
+ }
219
+ function assertExactSandboxMetadata(sandbox, expected) {
220
+ if (!metadataMatches(sandbox.metadata, expected)) throw new Error("Tangle Sandbox did not persist exact-process metadata");
221
+ }
222
+ function egressFromMetadata(metadata) {
223
+ const encoded = metadata?.[exactProcessEgressMarker];
224
+ if (typeof encoded !== "string") throw new Error("Tangle Sandbox exact-process environment is missing egress metadata");
225
+ try {
226
+ const parsed = JSON.parse(encoded);
227
+ if (!parsed || typeof parsed !== "object") throw new Error("expected egress object");
228
+ const policy = parsed;
229
+ if (policy.mode === "blocked" && policy.allowDomains === void 0) return { mode: "blocked" };
230
+ if (policy.mode === "strict" && policy.includeImplicitDomains === false && Array.isArray(policy.allowDomains) && policy.allowDomains.every((domain) => typeof domain === "string")) {
231
+ const allowDomains = sortedDomains(policy.allowDomains);
232
+ if (new Set(allowDomains).size === allowDomains.length) return {
233
+ mode: "strict",
234
+ allowDomains,
235
+ includeImplicitDomains: false
236
+ };
237
+ }
238
+ } catch {
239
+ throw new Error("Tangle Sandbox exact-process environment has invalid egress metadata");
240
+ }
241
+ throw new Error("Tangle Sandbox exact-process environment has invalid egress metadata");
242
+ }
243
+ async function assertExactSandboxEgress(sandbox, expected) {
244
+ const actual = (await sandbox.egress.get()).policy;
245
+ if (actual.mode !== expected.mode) throw new Error(`Tangle Sandbox egress mismatch: expected ${expected.mode}, received ${actual.mode}`);
246
+ if (expected.mode === "blocked") {
247
+ const allowDomains = actual.allowDomains;
248
+ if (actual.mode === "blocked" && (allowDomains === void 0 || Array.isArray(allowDomains) && allowDomains.length === 0)) return;
249
+ throw new Error("Tangle Sandbox blocked egress retained an allowlist");
250
+ }
251
+ if (actual.mode !== "strict") throw new Error("Tangle Sandbox did not return strict egress policy");
252
+ const expectedDomains = sortedDomains(expected.allowDomains);
253
+ if (!isDeepStrictEqual(sortedDomains(actual.allowDomains ?? []), expectedDomains)) throw new Error("Tangle Sandbox strict egress differs from the exact allowlist");
254
+ if (actual.includeImplicitDomains !== false) throw new Error("Tangle Sandbox strict egress retained implicit domains");
255
+ }
256
+ function sandboxEgressPolicy(input) {
257
+ if (input.mode === "blocked") return { mode: "blocked" };
258
+ const allowDomains = input.allowDomains.map((domain) => requiredText(domain, "strict egress domain"));
259
+ if (new Set(allowDomains).size !== allowDomains.length) throw new Error("strict egress domains must not contain duplicates");
260
+ return {
261
+ mode: "strict",
262
+ allowDomains,
263
+ includeImplicitDomains: false
264
+ };
265
+ }
266
+ function serializeEgressPolicy(policy) {
267
+ return JSON.stringify(policy.mode === "blocked" ? { mode: "blocked" } : {
268
+ mode: "strict",
269
+ allowDomains: sortedDomains(policy.allowDomains),
270
+ includeImplicitDomains: false
271
+ });
272
+ }
273
+ function sandboxResources(input) {
274
+ const cpuCores = positiveNumber(input.resources.cpu, "exact-process cpu");
275
+ const memoryMB = positiveInteger(input.resources.memoryMb, "exact-process memory");
276
+ const diskMb = positiveInteger(input.resources.diskMb, "exact-process disk");
277
+ if (diskMb % 1024 !== 0) throw new Error("Tangle Sandbox exact-process disk must be a whole GiB");
278
+ return {
279
+ cpuCores,
280
+ memoryMB,
281
+ diskGB: diskMb / 1024
282
+ };
283
+ }
284
+ function sandboxLifetimeSeconds(maxLifetimeMs) {
285
+ const milliseconds = positiveInteger(maxLifetimeMs, "exact-process maximum lifetime");
286
+ if (milliseconds % 1e3 !== 0) throw new Error("Tangle Sandbox exact-process maximum lifetime must be a whole number of seconds");
287
+ return milliseconds / 1e3;
288
+ }
289
+ function fileMode(value) {
290
+ const mode = nonnegativeInteger(value, "exact-process file mode");
291
+ if (mode > 4095) throw new Error("exact-process file mode exceeds POSIX mode bits");
292
+ return mode;
293
+ }
294
+ function assertNoProviderOptions(providerOptions) {
295
+ if (providerOptions && Object.keys(providerOptions).length > 0) throw new Error("Tangle Sandbox exact-process provider does not accept providerOptions");
296
+ }
297
+ function exactProcessOnlyCapabilities() {
298
+ return {
299
+ profile: {
300
+ namedProfiles: false,
301
+ systemPrompt: {
302
+ replace: false,
303
+ append: false
304
+ },
305
+ instructions: false,
306
+ tools: false,
307
+ permissions: false,
308
+ mcp: false,
309
+ subagents: false,
310
+ resources: {
311
+ files: false,
312
+ instructions: false,
313
+ tools: false,
314
+ skills: false,
315
+ agents: false,
316
+ commands: false
317
+ },
318
+ hooks: false,
319
+ modes: false,
320
+ runtimeUpdate: false,
321
+ validation: false
322
+ },
323
+ streaming: {
324
+ live: false,
325
+ replay: false,
326
+ detach: false,
327
+ turnIdempotency: false
328
+ },
329
+ sessions: {
330
+ continue: false,
331
+ list: false,
332
+ messages: false
333
+ },
334
+ workspace: {
335
+ read: false,
336
+ write: false,
337
+ exec: false,
338
+ git: false,
339
+ upload: false,
340
+ download: false
341
+ },
342
+ branching: {
343
+ checkpoint: false,
344
+ fork: false
345
+ },
346
+ placement: false,
347
+ usage: false,
348
+ confidential: false,
349
+ exactProcess: { egress: ["blocked", "strict"] }
350
+ };
351
+ }
352
+ async function discardInvalidSandbox(sandbox, cause) {
353
+ try {
354
+ await sandbox.delete();
355
+ } catch (destroyError) {
356
+ throw new AggregateError([cause, destroyError], "Tangle Sandbox exact-process creation failed and cleanup failed");
357
+ }
358
+ throw cause;
359
+ }
360
+ function sortedDomains(domains) {
361
+ return [...domains].sort((left, right) => left.localeCompare(right));
362
+ }
363
+ function requiredText(value, label) {
364
+ if (typeof value !== "string" || !value.trim()) throw new Error(`${label} must be a non-empty string`);
365
+ return value;
366
+ }
367
+ function optionalText(value, label) {
368
+ if (value === void 0) return void 0;
369
+ return requiredText(value, label);
370
+ }
371
+ function positiveNumber(value, label) {
372
+ if (!Number.isFinite(value) || value <= 0) throw new Error(`${label} must be positive`);
373
+ return value;
374
+ }
375
+ function positiveInteger(value, label) {
376
+ if (!Number.isSafeInteger(value) || value < 1) throw new Error(`${label} must be a positive integer`);
377
+ return value;
378
+ }
379
+ function nonnegativeInteger(value, label) {
380
+ if (!Number.isSafeInteger(value) || value < 0) throw new Error(`${label} must be a non-negative integer`);
381
+ return value;
382
+ }
383
+ function throwIfAborted(signal) {
384
+ signal?.throwIfAborted();
385
+ }
386
+ async function afterAbortCheck(signal, operation) {
387
+ throwIfAborted(signal);
388
+ const result = await operation();
389
+ throwIfAborted(signal);
390
+ return result;
391
+ }
392
+ //#endregion
35
393
  //#region src/runtime/key-provider.ts
36
394
  /** The env-backed provider: reads the (dotenvx-loaded) process env. Empty /
37
395
  * whitespace-only values count as absent — fail loud, not with a blank key. */
@@ -1259,9 +1617,9 @@ function loopDispatch(opts) {
1259
1617
  *
1260
1618
  * It is deliberately for NON-box executors only — a real sandbox harness already
1261
1619
  * IS a `SandboxClient` (boxes, sessions, fs, fork are real there). Here each
1262
- * `streamPrompt` runs the executor once and emits the terminal
1263
- * `{type:'result', data:{finalText, tokenUsage, costUsd}}` event that
1264
- * `answerOutput`/the kernel's cost ledger already parse — no sessions, no fs,
1620
+ * `streamPrompt` runs the executor once and emits its result plus the canonical
1621
+ * `done` event. The result carries output and usage; `done` confirms execution settled.
1622
+ * There are no sessions, no fs,
1265
1623
  * no fork (those degrade gracefully via the optional `SandboxClient` methods).
1266
1624
  */
1267
1625
  function isAsyncIterable$1(v) {
@@ -1354,6 +1712,10 @@ function inlineSandboxClient(factory, defaults = {}) {
1354
1712
  ...out?.promptCache ? { promptCache: out.promptCache } : {}
1355
1713
  }
1356
1714
  };
1715
+ yield {
1716
+ type: "done",
1717
+ data: { outcome: { type: "completed" } }
1718
+ };
1357
1719
  } finally {
1358
1720
  callerSignal?.removeEventListener("abort", onAbort);
1359
1721
  await exec.teardown("brutalKill").catch(() => {});
@@ -1859,7 +2221,12 @@ async function harvestCorpus(opts) {
1859
2221
  runsObserved: 0,
1860
2222
  findings: 0,
1861
2223
  learned: 0,
1862
- failures: []
2224
+ failures: [],
2225
+ usage: {
2226
+ input: 0,
2227
+ output: 0,
2228
+ known: true
2229
+ }
1863
2230
  };
1864
2231
  const iterator = Symbol.asyncIterator in Object(opts.runs) ? opts.runs[Symbol.asyncIterator]() : (async function* () {
1865
2232
  yield* opts.runs;
@@ -1890,7 +2257,11 @@ async function harvestCorpus(opts) {
1890
2257
  report.runsObserved += 1;
1891
2258
  report.findings += obs.findings.length;
1892
2259
  report.learned += obs.learned.length;
2260
+ report.usage.input += obs.usage.input;
2261
+ report.usage.output += obs.usage.output;
2262
+ report.usage.known &&= obs.usage.known;
1893
2263
  } catch (e) {
2264
+ report.usage.known = false;
1894
2265
  report.failures.push({
1895
2266
  runId: input.runId ?? `run-${consumed}`,
1896
2267
  error: e instanceof Error ? e.message.slice(0, 300) : String(e)
@@ -4032,6 +4403,39 @@ function errorMessage(error) {
4032
4403
  return error instanceof Error ? error.message : String(error);
4033
4404
  }
4034
4405
  //#endregion
4406
+ //#region src/runtime/authored-code.ts
4407
+ /**
4408
+ * The ONE lint over model-authored source.
4409
+ *
4410
+ * Two features have a model write code the runtime then runs: `authorStrategy` (an authored
4411
+ * optimization strategy, since 0.60) and code mode's `execute` (a program over the coordination
4412
+ * verbs). Both need the same refusals; this module is the single copy both import.
4413
+ *
4414
+ * A LINT, NOT A SANDBOX — it reads text and cannot constrain what running code does, and trivial
4415
+ * concatenation defeats any token match. Its only job is refusing the obvious escapes so a typo or
4416
+ * a lazy model does not run; it is never the security boundary. Isolation, where required, is the
4417
+ * execution boundary's job (a jailed runner, a sandboxed loader), never this check's.
4418
+ */
4419
+ /** Refuse the obvious escapes in authored source. See the module doc for what this is NOT. */
4420
+ function assertAuthoredCode(code, options = {}) {
4421
+ const context = options.context ?? "authored code";
4422
+ const allowed = options.allowedImports ?? [];
4423
+ for (const line of code.split("\n")) {
4424
+ if (!/^\s*import\s/.test(line)) continue;
4425
+ if (!allowed.some((specifier) => line.includes(`'${specifier}'`) || line.includes(`"${specifier}"`))) throw new ValidationError(`${context} rejected: foreign import — ${line.trim().slice(0, 120)}${allowed.length === 0 ? " (no import is allowed here)" : ` (allowed: ${allowed.join(", ")})`}`);
4426
+ }
4427
+ for (const [pattern, what] of [
4428
+ [/\brequire\s*\(/, "require()"],
4429
+ [/\bimport\s*\(/, "dynamic import()"],
4430
+ [/\beval\s*\(/, "eval()"],
4431
+ [/new\s+Function\s*\(/, "new Function()"],
4432
+ [/\bprocess\s*[.[]/, "process access"],
4433
+ [/\bglobalThis\s*[.[]/, "globalThis access"],
4434
+ [/\bfetch\s*\(/, "network access"],
4435
+ [/child_process|node:fs|node:net|node:http|worker_threads/, "node builtin access"]
4436
+ ]) if (pattern.test(code)) throw new ValidationError(`${context} rejected: ${what}`);
4437
+ }
4438
+ //#endregion
4035
4439
  //#region src/runtime/strategy-author.ts
4036
4440
  /**
4037
4441
  * authorStrategy — the agent-authored layer as a package primitive (software-3.0): an
@@ -6434,6 +6838,6 @@ function tail(s) {
6434
6838
  return s.slice(-400);
6435
6839
  }
6436
6840
  //#endregion
6437
- export { InMemoryCorpus as $, chatWorkerSeam as A, renderLeaderboardSvg as At, SandboxRunAbortError as B, mcpSecretEnvMetadataKey as Bt, withUntrackedArtifacts as C, deterministicCompletion as Ct, codeModeSupervisorTools as D, pairwiseSignificance as Dt, runCoderChecks as E, leaderboard as Et, selectChampion as F, connectStdioMcp as Ft, equalKOnCost as G, printBenchmarkReport as H, resolveSecretEnv as Ht, assertStrategyContract as I, materializeLocalMcp as It, runPersonified as J, trajectoryReport as K, authorStrategy as L, createMcpEnvironment as Lt, discriminatingMeans as M, auditIntent as Mt, pickChampion as N, defaultAuditorInstruction as Nt, unsafeInProcessRunner as O, renderLeaderboardHtml as Ot, runStrategyEvolution as P, McpSpawnFault as Pt, FileCorpus as Q, strategyAuthorContract as R, sanitizeMcpToolSchema as Rt, copyUntrackedIntoClone as S, completionAuthorizes as St, patchDelivered as T, stopSentinel as Tt, runBenchmark as U, secretEnvOfMcpServer as Ut, openSandboxRun as V, resolveMcpServerLaunch as Vt, promotionGate as W, createShapeRegistry as X, builtinShapes as Y, registerShape as Z, NOTE_MAX_CHARS as _, localSandboxClient as _t, localShell as a, pipeline as at, composeWorkerEvidence as b, loopDispatch as bt, createVerifierEnvironment as c, widen as ct, harvestSurfaceDiffs as d, createScopeAnalyst as dt, renderCorpusToInstructions as et, analystsFromRegistry as f, registryScopeAnalyst as ft, EVIDENCE_MAX_CHARS as g, resolveSandboxClient as gt, worktreeFanout as h, defineLeaderboard as ht, jjWorkspace as i, panel as it, createChatSessionStore as j, renderPairwiseMarkdown as jt, chatTransportExecutor as k, renderLeaderboardMarkdown as kt, boxSurfaceReader as l, assertTraceDerivedFindings as lt, superviseSurface as m, harvestCorpus as mt, makeFinding$1 as n, flatWidenGate as nt, runInWorkspace as o, selectValidWinner as ot, failuresAnalyst as p, inProcessSandboxClient as pt, definePersona as q, gitWorkspace as r, loopUntil as rt, createWaterfallCollector as s, verify as st, computeFindingId$1 as t, fanout as tt, fsSurfaceReader as u, buildSteerContext as ut, VERIFY_TAIL_CHARS as v, inlineSandboxClient as vt, analyzeTrace as w, sentinelCompletion as wt, settledWorkerOut as x, superviseDispatch as xt, closingWorkerNote as y, loopCampaignDispatch as yt, strategyAuthorSystemPrompt as z, envKeyProvider as zt };
6841
+ export { InMemoryCorpus as $, chatWorkerSeam as A, renderLeaderboardSvg as At, SandboxRunAbortError as B, mcpSecretEnvMetadataKey as Bt, withUntrackedArtifacts as C, deterministicCompletion as Ct, codeModeSupervisorTools as D, pairwiseSignificance as Dt, runCoderChecks as E, leaderboard as Et, selectChampion as F, connectStdioMcp as Ft, equalKOnCost as G, printBenchmarkReport as H, resolveSecretEnv as Ht, assertStrategyContract as I, materializeLocalMcp as It, runPersonified as J, trajectoryReport as K, authorStrategy as L, createMcpEnvironment as Lt, discriminatingMeans as M, auditIntent as Mt, pickChampion as N, defaultAuditorInstruction as Nt, unsafeInProcessRunner as O, renderLeaderboardHtml as Ot, runStrategyEvolution as P, McpSpawnFault as Pt, FileCorpus as Q, strategyAuthorContract as R, sanitizeMcpToolSchema as Rt, copyUntrackedIntoClone as S, completionAuthorizes as St, patchDelivered as T, stopSentinel as Tt, runBenchmark as U, secretEnvOfMcpServer as Ut, openSandboxRun as V, resolveMcpServerLaunch as Vt, promotionGate as W, createTangleSandboxExactProcessProvider as Wt, createShapeRegistry as X, builtinShapes as Y, registerShape as Z, NOTE_MAX_CHARS as _, localSandboxClient as _t, localShell as a, pipeline as at, composeWorkerEvidence as b, loopDispatch as bt, createVerifierEnvironment as c, widen as ct, harvestSurfaceDiffs as d, createScopeAnalyst as dt, renderCorpusToInstructions as et, analystsFromRegistry as f, registryScopeAnalyst as ft, EVIDENCE_MAX_CHARS as g, resolveSandboxClient as gt, worktreeFanout as h, defineLeaderboard as ht, jjWorkspace as i, panel as it, createChatSessionStore as j, renderPairwiseMarkdown as jt, chatTransportExecutor as k, renderLeaderboardMarkdown as kt, boxSurfaceReader as l, assertTraceDerivedFindings as lt, superviseSurface as m, harvestCorpus as mt, makeFinding$1 as n, flatWidenGate as nt, runInWorkspace as o, selectValidWinner as ot, failuresAnalyst as p, inProcessSandboxClient as pt, definePersona as q, gitWorkspace as r, loopUntil as rt, createWaterfallCollector as s, verify as st, computeFindingId$1 as t, fanout as tt, fsSurfaceReader as u, buildSteerContext as ut, VERIFY_TAIL_CHARS as v, inlineSandboxClient as vt, analyzeTrace as w, sentinelCompletion as wt, settledWorkerOut as x, superviseDispatch as xt, closingWorkerNote as y, loopCampaignDispatch as yt, strategyAuthorSystemPrompt as z, envKeyProvider as zt };
6438
6842
 
6439
- //# sourceMappingURL=runtime-DqRieJ6e.js.map
6843
+ //# sourceMappingURL=runtime-BrTBBSfC.js.map