@tangle-network/agent-runtime 0.143.0 → 0.153.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 (113) hide show
  1. package/README.md +32 -0
  2. package/dist/{activation-mi8TgSLM.js → activation-DKxQsHiO.js} +3 -3
  3. package/dist/{activation-mi8TgSLM.js.map → activation-DKxQsHiO.js.map} +1 -1
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +3 -3
  6. package/dist/{analyst-loop-CvkmfhUB.js → analyst-loop-B2kTHKNh.js} +2 -2
  7. package/dist/{analyst-loop-CvkmfhUB.js.map → analyst-loop-B2kTHKNh.js.map} +1 -1
  8. package/dist/analyst-loop.js +1 -1
  9. package/dist/{authoring-DuyShLdw.js → authoring-Tk2xFys0.js} +2 -2
  10. package/dist/{authoring-DuyShLdw.js.map → authoring-Tk2xFys0.js.map} +1 -1
  11. package/dist/candidate-execution/index.js +4 -4
  12. package/dist/{candidate-execution-CD5PoNmC.js → candidate-execution-CB9RJbbJ.js} +4 -4
  13. package/dist/{candidate-execution-CD5PoNmC.js.map → candidate-execution-CB9RJbbJ.js.map} +1 -1
  14. package/dist/{conversation-1hNtDeMM.js → conversation-D64WyWrK.js} +4 -4
  15. package/dist/{conversation-1hNtDeMM.js.map → conversation-D64WyWrK.js.map} +1 -1
  16. package/dist/conversation.d.ts +1 -1
  17. package/dist/conversation.js +1 -1
  18. package/dist/durable.d.ts +102 -4
  19. package/dist/durable.js +259 -10
  20. package/dist/durable.js.map +1 -1
  21. package/dist/{environment-provider-B8eZ85Ga.d.ts → environment-provider-DJG0yIYl.d.ts} +2 -2
  22. package/dist/{environment-provider-DCBJ13VP.js → environment-provider-D_MXw3jK.js} +88 -9
  23. package/dist/environment-provider-D_MXw3jK.js.map +1 -0
  24. package/dist/environment-provider.d.ts +1 -1
  25. package/dist/environment-provider.js +1 -1
  26. package/dist/executable-spec-BUcUcEPk.js +73 -0
  27. package/dist/executable-spec-BUcUcEPk.js.map +1 -0
  28. package/dist/{graph-De_XEsfH.js → graph-M0Qr4863.js} +4 -4
  29. package/dist/{graph-De_XEsfH.js.map → graph-M0Qr4863.js.map} +1 -1
  30. package/dist/{improvement-cycle-Bi-Tf4QF.js → improvement-cycle-CDxlGQGE.js} +7 -7
  31. package/dist/{improvement-cycle-Bi-Tf4QF.js.map → improvement-cycle-CDxlGQGE.js.map} +1 -1
  32. package/dist/{index-B8rKtH3U.d.ts → index-BihHgUAI.d.ts} +4 -4
  33. package/dist/{index-C2caGomG.d.ts → index-Dlz7ejRx.d.ts} +339 -503
  34. package/dist/{index-D4sLkOPY.d.ts → index-LQfgFJoX.d.ts} +2 -2
  35. package/dist/index.d.ts +7 -7
  36. package/dist/index.js +13 -13
  37. package/dist/intelligence.d.ts +4 -4
  38. package/dist/intelligence.js +6 -6
  39. package/dist/kernel.d.ts +6 -6
  40. package/dist/kernel.js +13 -13
  41. package/dist/{knowledge-CVE6Wk1i.js → knowledge-DM-i40b9.js} +10 -7
  42. package/dist/{knowledge-CVE6Wk1i.js.map → knowledge-DM-i40b9.js.map} +1 -1
  43. package/dist/knowledge.d.ts +1 -1
  44. package/dist/knowledge.js +1 -1
  45. package/dist/{loop-runner-bin-BoHdQqLm.d.ts → loop-runner-bin-D-BW51yr.d.ts} +3 -3
  46. package/dist/{loop-runner-bin-DdaI1nLL.js → loop-runner-bin-pD5WJuqJ.js} +4 -4
  47. package/dist/{loop-runner-bin-DdaI1nLL.js.map → loop-runner-bin-pD5WJuqJ.js.map} +1 -1
  48. package/dist/loop-runner-bin.d.ts +1 -1
  49. package/dist/loop-runner-bin.js +1 -1
  50. package/dist/{materialization-P86EciBw.js → materialization-Bo6j3Hg9.js} +257 -61
  51. package/dist/materialization-Bo6j3Hg9.js.map +1 -0
  52. package/dist/mcp/bin.js +3 -3
  53. package/dist/mcp/index.d.ts +3 -3
  54. package/dist/mcp/index.js +6 -6
  55. package/dist/{model-policy-DgRJIJse.js → model-policy-Sw4ywhtL.js} +68 -6
  56. package/dist/model-policy-Sw4ywhtL.js.map +1 -0
  57. package/dist/{openai-tools-BiAWKjh6.js → openai-tools-CWBywy-e.js} +2 -2
  58. package/dist/{openai-tools-BiAWKjh6.js.map → openai-tools-CWBywy-e.js.map} +1 -1
  59. package/dist/{prepare-D3n7cA39.js → prepare-C3eFd3UA.js} +2 -2
  60. package/dist/{prepare-D3n7cA39.js.map → prepare-C3eFd3UA.js.map} +1 -1
  61. package/dist/primeintellect/index.d.ts +1 -1
  62. package/dist/profiles.js +1 -1
  63. package/dist/{protected-model-port-bq6bD9YX.js → protected-model-port-Dn2b6peS.js} +2 -2
  64. package/dist/{protected-model-port-bq6bD9YX.js.map → protected-model-port-Dn2b6peS.js.map} +1 -1
  65. package/dist/{redact-DexTuAiX.d.ts → redact-NAptmqKw.d.ts} +3 -3
  66. package/dist/{researcher-CiSY6Wzb.js → researcher-BMFFPwKb.js} +2 -2
  67. package/dist/{researcher-CiSY6Wzb.js.map → researcher-BMFFPwKb.js.map} +1 -1
  68. package/dist/{run-layout-Be_Z0dF8.js → run-layout-C2jgwsCq.js} +111 -6
  69. package/dist/run-layout-C2jgwsCq.js.map +1 -0
  70. package/dist/{runtime-J6Toky8K.d.ts → runtime-B-5dp5Iz.d.ts} +214 -14
  71. package/dist/{runtime-BnqjbOGX.js → runtime-RY_rvv7t.js} +85 -82
  72. package/dist/runtime-RY_rvv7t.js.map +1 -0
  73. package/dist/{sandbox-events-COwCWUVB.js → sandbox-events-DMijDq2p.js} +49 -2
  74. package/dist/sandbox-events-DMijDq2p.js.map +1 -0
  75. package/dist/{spawn-journal-D2HKUImC.js → spawn-journal-CLguaA2A.js} +8 -43
  76. package/dist/spawn-journal-CLguaA2A.js.map +1 -0
  77. package/dist/{stream-agent-turn-C1Vs_3B9.d.ts → stream-agent-turn-BGyszuPH.d.ts} +2 -2
  78. package/dist/{stream-agent-turn-CXRugSGO.js → stream-agent-turn-D6HoaRPV.js} +90 -14
  79. package/dist/stream-agent-turn-D6HoaRPV.js.map +1 -0
  80. package/dist/{structural-rollout-CJgj9YXH.js → structural-rollout-P1YxFRfl.js} +11 -8
  81. package/dist/structural-rollout-P1YxFRfl.js.map +1 -0
  82. package/dist/{supervise-hCgG6ROJ.js → supervise-BezbzKiJ.js} +1550 -1186
  83. package/dist/supervise-BezbzKiJ.js.map +1 -0
  84. package/dist/{supervisor-s8SfZYbW.js → supervisor-DBVlPONC.js} +597 -194
  85. package/dist/supervisor-DBVlPONC.js.map +1 -0
  86. package/dist/testing.d.ts +2 -2
  87. package/dist/testing.js +12 -12
  88. package/dist/{top-app-BMOSKK06.js → top-app-tKo9OrON.js} +189 -86
  89. package/dist/top-app-tKo9OrON.js.map +1 -0
  90. package/dist/tui/bin.js +1 -1
  91. package/dist/tui/index.d.ts +32 -4
  92. package/dist/tui/index.js +1 -1
  93. package/dist/{types-Df9vulGc.d.ts → types-BPQhQRrC.d.ts} +507 -10
  94. package/dist/{util-C1bv6yog.js → util-Bncw0o_F.js} +41 -2
  95. package/dist/util-Bncw0o_F.js.map +1 -0
  96. package/dist/{workspace-archive-C52LjkeN.js → workspace-archive-Dm73lTfB.js} +2 -2
  97. package/dist/{workspace-archive-C52LjkeN.js.map → workspace-archive-Dm73lTfB.js.map} +1 -1
  98. package/package.json +4 -4
  99. package/dist/environment-provider-DCBJ13VP.js.map +0 -1
  100. package/dist/materialization-P86EciBw.js.map +0 -1
  101. package/dist/model-policy-DgRJIJse.js.map +0 -1
  102. package/dist/retained-run-binding-Dp2e8xne.js +0 -268
  103. package/dist/retained-run-binding-Dp2e8xne.js.map +0 -1
  104. package/dist/run-layout-Be_Z0dF8.js.map +0 -1
  105. package/dist/runtime-BnqjbOGX.js.map +0 -1
  106. package/dist/sandbox-events-COwCWUVB.js.map +0 -1
  107. package/dist/spawn-journal-D2HKUImC.js.map +0 -1
  108. package/dist/stream-agent-turn-CXRugSGO.js.map +0 -1
  109. package/dist/structural-rollout-CJgj9YXH.js.map +0 -1
  110. package/dist/supervise-hCgG6ROJ.js.map +0 -1
  111. package/dist/supervisor-s8SfZYbW.js.map +0 -1
  112. package/dist/top-app-BMOSKK06.js.map +0 -1
  113. package/dist/util-C1bv6yog.js.map +0 -1
@@ -1,24 +1,24 @@
1
- import { C as sameControlCoordinates, S as isTerminalSessionStatus, _ as exactSession, a as assertEventBinding, b as freezeControlRef, c as assertSequence, d as awaitAbortable, f as cancellationRequest, g as exactControlRef, h as exactContinuedControlRef, i as assertCanonicalEventBinding, l as assertStableText, m as delay, n as abortError, o as assertInteractionBinding, p as copyControlRef, r as assertBoundaryBinding, s as assertResultBinding, t as RetainedRunProviderContractError, u as assertWaitDuration, v as exactSessionCancel, w as freshTurnInput, x as hasDurableCancel, y as exactSessionResult } from "./retained-run-binding-Dp2e8xne.js";
1
+ import { A as assertInteractionBinding, B as exactControlRef, D as assertBoundaryBinding, E as abortError, F as awaitAbortable, G as hasDurableCancel, H as exactSessionCancel, I as cancellationRequest, J as freshTurnInput, K as isTerminalSessionStatus, L as copyControlRef, M as assertSequence, N as assertStableText, O as assertCanonicalEventBinding, P as assertWaitDuration, R as delay, T as RetainedRunProviderContractError, U as exactSessionResult, V as exactSession, W as freezeControlRef, j as assertResultBinding, k as assertEventBinding, q as sameControlCoordinates, z as exactContinuedControlRef } from "./materialization-Bo6j3Hg9.js";
2
2
  import { c as RetainedInteractiveAdmissionError, d as RetainedRunDispatchBindingError, l as RetainedInteractiveBindingError, m as ValidationError, n as AnalystError, s as PlannerError, u as RetainedRunAdmissionError } from "./errors-CDZ8XsVj.js";
3
- import "./stream-agent-turn-CXRugSGO.js";
3
+ import "./stream-agent-turn-D6HoaRPV.js";
4
4
  import { t as detachedSnapshot } from "./snapshot-cK9K420n.js";
5
- import { S as contentAddress, i as InMemorySpawnJournal, r as InMemoryResultBlobStore, y as isTraceAnalysisStore } from "./spawn-journal-D2HKUImC.js";
6
- import { _ as zeroTokenUsage, a as hasCompleteCacheBreakdown, d as sleep, f as stringifySafe, h as usdEstimatedOf, l as randomSuffix, n as chargedTokens, o as isAbortError, r as cloneTokenUsage, t as addTokenUsage } from "./util-C1bv6yog.js";
5
+ import { S as contentAddress, i as InMemorySpawnJournal, r as InMemoryResultBlobStore, y as isTraceAnalysisStore } from "./spawn-journal-CLguaA2A.js";
6
+ import { c as isAbortError, d as randomSuffix, i as cloneSpend, m as stringifySafe, p as sleep, r as chargedTokens, s as hasCompleteCacheBreakdown, t as addSpend, v as zeroSpend } from "./util-Bncw0o_F.js";
7
7
  import { i as redactProtectedValue, r as redactProtectedReason } from "./protected-redaction--F3v1oo8.js";
8
- import { d as parseCanonicalTransportEvent, s as notifySandboxEventObserver, u as extractTransportEventIdentity } from "./sandbox-events-COwCWUVB.js";
9
- import { E as executableAgentSpecSnapshot, T as executableAgentProfileSnapshot } from "./materialization-P86EciBw.js";
10
- import { c as profileProviderModel, i as concreteModelId, s as profileModelExecutionSettings, t as assertExecutableAgentProfile } from "./model-policy-DgRJIJse.js";
11
- import { E as rollingDispatch, I as createExecutor, L as createExecutorRegistry, _t as runBrainLoop, ft as runAgentRounds, g as settledToIteration, gt as routerBrain, l as withDriverExecutor, mt as probeSandboxCapabilities, n as createSupervisor, pt as createSandboxLineage, q as createPushTraceSource, ut as defaultSelectWinner, vt as canonicalObservedModel, z as createWorktreeCliExecutor } from "./supervisor-s8SfZYbW.js";
12
- import "./environment-provider-DCBJ13VP.js";
8
+ import { d as extractTransportEventIdentity, f as parseCanonicalTransportEvent, s as notifySandboxEventObserver } from "./sandbox-events-DMijDq2p.js";
9
+ import { n as executableAgentSpecSnapshot, t as executableAgentProfileSnapshot } from "./executable-spec-BUcUcEPk.js";
10
+ import { c as profileModelExecutionSettings, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, t as assertExecutableAgentProfile } from "./model-policy-Sw4ywhtL.js";
11
+ import { B as createExecutorRegistry, E as rollingDispatch, H as createWorktreeCliExecutor, X as createPushTraceSource, _t as probeSandboxCapabilities, bt as runBrainLoop, g as settledToIteration, gt as createSandboxLineage, ht as runAgentRounds, l as withDriverExecutor, n as createSupervisor, pt as defaultSelectWinner, xt as canonicalObservedModel, yt as routerBrain, z as createExecutor } from "./supervisor-DBVlPONC.js";
12
+ import "./environment-provider-D_MXw3jK.js";
13
13
  import { i as notifyRuntimeHookEvent } from "./runtime-hooks-tXpAarhW.js";
14
- 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-CJgj9YXH.js";
15
- import { It as gateOnDeliverable, Lt as mapExecutorResult, n as supervise } from "./supervise-hCgG6ROJ.js";
16
- import "./authoring-DuyShLdw.js";
17
- import "./graph-De_XEsfH.js";
14
+ 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-P1YxFRfl.js";
15
+ import { At as mapExecutorResult, kt as gateOnDeliverable, n as supervise } from "./supervise-BezbzKiJ.js";
16
+ import "./authoring-Tk2xFys0.js";
17
+ import "./graph-M0Qr4863.js";
18
18
  import { AgentEnvironmentCapabilitiesSchema, AgentExactRunControlRefSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStatusSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentNativeContextContinuationResultSchema, AgentTurnResultSchema, InteractionAcknowledgementSchema, InteractionResponseCommandSchema, NativeContextBoundaryProofSchema, NativeContextContinuationRequestSchema, RuntimeEventEnvelopeSchema, TerminalReplayWindowSchema, TerminalSessionRefSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentNativeContextContinuationResultMatchesRequest, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, exactAgentInteractiveSessionStart, nativeContextContinuationTurnDigest, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
19
- import { CODING_HARNESSES, InMemoryTraceStore, OUTPUT_VALUE, benjaminiHochberg, buildTrajectory, computeFindingId as computeFindingId$1, confidenceInterval, expandProfileAxes, makeFinding as makeFinding$1, pairedBootstrap, paretoFrontier, wilcoxonSignedRank, wilson } from "@tangle-network/agent-eval";
19
+ import { CODING_HARNESSES, DEFAULT_TRACE_ANALYST_KINDS, InMemoryTraceStore, OUTPUT_VALUE, benjaminiHochberg, buildTrajectory, computeFindingId as computeFindingId$1, confidenceInterval, expandProfileAxes, makeFinding as makeFinding$1, pairedBootstrap, paretoFrontier, wilcoxonSignedRank, wilson } from "@tangle-network/agent-eval";
20
20
  import { heldoutSignificance, runProfileMatrix } from "@tangle-network/agent-eval/campaign";
21
- import { createHash } from "node:crypto";
21
+ import { createHash, randomUUID } from "node:crypto";
22
22
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
23
23
  import { mkdir, readFile, realpath, writeFile } from "node:fs/promises";
24
24
  import { appendFileSync, chmodSync, constants, copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readlinkSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
@@ -1390,7 +1390,7 @@ function localSandboxClient(opts) {
1390
1390
  routerKey: router.key,
1391
1391
  model,
1392
1392
  ...settings.retry !== void 0 ? { retry: settings.retry } : {},
1393
- ...settings.maxTokens !== void 0 ? { maxTokens: settings.maxTokens } : {},
1393
+ ...enforceTokenLimits(settings.tokenLimits, "router", "localSandboxClient").applied,
1394
1394
  ...settings.stream !== void 0 ? { stream: settings.stream } : {}
1395
1395
  }, {
1396
1396
  ...settings.temperature !== void 0 ? { temperature: settings.temperature } : {},
@@ -3074,7 +3074,7 @@ async function trajectoryReport(journal, blobs, root, options = {}) {
3074
3074
  const events = await journal.loadTree(root);
3075
3075
  if (events === void 0) throw new Error(`trajectoryReport: no journaled tree for root '${root}'`);
3076
3076
  const spawns = events.filter(isNodeCreation).sort(bySeq);
3077
- const closes = events.filter((ev) => ev.kind !== "spawned" && ev.kind !== "waiting" && ev.kind !== "metered" && ev.kind !== "materialized" && ev.kind !== "execution-bound" && ev.kind !== "edge" && ev.kind !== "trace-unpropagated").sort(bySeq);
3077
+ const closes = events.filter((ev) => ev.kind !== "spawned" && ev.kind !== "waiting" && ev.kind !== "metered" && ev.kind !== "materialized" && ev.kind !== "execution-bound" && ev.kind !== "edge" && ev.kind !== "teardown-unconfirmed" && ev.kind !== "trace-unpropagated").sort(bySeq);
3078
3078
  const nodes = /* @__PURE__ */ new Map();
3079
3079
  for (const ev of spawns) nodes.set(ev.id, {
3080
3080
  id: ev.id,
@@ -3104,7 +3104,7 @@ async function trajectoryReport(journal, blobs, root, options = {}) {
3104
3104
  for (const ev of events) {
3105
3105
  if (ev.kind !== "metered") continue;
3106
3106
  const node = requireNode(nodes, ev.id, root);
3107
- node.ownSpend = addNodeSpend(node.ownSpend, ev.spend);
3107
+ node.ownSpend = addSpend(node.ownSpend, ev.spend);
3108
3108
  }
3109
3109
  if (!nodes.has(root)) throw new Error(`trajectoryReport: root '${root}' has no spawned event in its journaled tree (corrupted log)`);
3110
3110
  for (const ev of spawns) {
@@ -3181,8 +3181,8 @@ function rollUpSpend(nodes, root) {
3181
3181
  });
3182
3182
  continue;
3183
3183
  }
3184
- const sum = cloneSpend(node.ownSpend);
3185
- for (const child of node.children) addSpend(sum, requireSpend(rolled, child, root));
3184
+ let sum = cloneSpend(node.ownSpend);
3185
+ for (const child of node.children) sum = addSpend(sum, requireSpend(rolled, child, root));
3186
3186
  rolled.set(frame.id, sum);
3187
3187
  }
3188
3188
  return rolled;
@@ -3226,51 +3226,6 @@ function countStatuses(reported) {
3226
3226
  for (const node of reported) counts[node.status] += 1;
3227
3227
  return counts;
3228
3228
  }
3229
- function zeroSpend() {
3230
- return {
3231
- iterations: 0,
3232
- tokens: zeroTokenUsage(),
3233
- usd: 0,
3234
- ms: 0
3235
- };
3236
- }
3237
- /** Add a `metered` event's spend onto a node's accumulated ownSpend (per channel). */
3238
- function addNodeSpend(a, b) {
3239
- return {
3240
- iterations: a.iterations + b.iterations,
3241
- tokens: (() => {
3242
- const tokens = cloneTokenUsage(a.tokens);
3243
- addTokenUsage(tokens, b.tokens);
3244
- return tokens;
3245
- })(),
3246
- ...a.tokensKnown === false || b.tokensKnown === false ? { tokensKnown: false } : {},
3247
- usd: a.usd + b.usd,
3248
- ...a.usdKnown === false || b.usdKnown === false ? { usdKnown: false } : {},
3249
- ...usdEstimatedOf(a, b),
3250
- ms: a.ms + b.ms
3251
- };
3252
- }
3253
- function cloneSpend(spend) {
3254
- return {
3255
- iterations: spend.iterations,
3256
- tokens: cloneTokenUsage(spend.tokens),
3257
- ...spend.tokensKnown === false ? { tokensKnown: false } : {},
3258
- usd: spend.usd,
3259
- ...spend.usdKnown === false ? { usdKnown: false } : {},
3260
- ...spend.usdEstimated !== void 0 ? { usdEstimated: spend.usdEstimated } : {},
3261
- ms: spend.ms
3262
- };
3263
- }
3264
- /** Add `delta` into `acc` in place across every conserved channel. */
3265
- function addSpend(acc, delta) {
3266
- acc.iterations += delta.iterations;
3267
- addTokenUsage(acc.tokens, delta.tokens);
3268
- if (delta.tokensKnown === false) acc.tokensKnown = false;
3269
- acc.usd += delta.usd;
3270
- if (delta.usdKnown === false) acc.usdKnown = false;
3271
- if (delta.usdEstimated !== void 0) acc.usdEstimated = (acc.usdEstimated ?? 0) + delta.usdEstimated;
3272
- acc.ms += delta.ms;
3273
- }
3274
3229
  function spreadOf(values) {
3275
3230
  if (values.length === 0) return 0;
3276
3231
  return Math.max(...values) - Math.min(...values);
@@ -4069,11 +4024,26 @@ async function dispatchRetainedRun(options) {
4069
4024
  sessionId: identity.sessionId,
4070
4025
  executionId: identity.executionId
4071
4026
  });
4072
- const reference = await environment.dispatch(freshTurnInput(options.turn, {
4073
- turnId: options.turn.turnId,
4074
- detach: true,
4075
- ...identity
4076
- }));
4027
+ const destroyIfCreated = async (cause) => {
4028
+ if (environment.creation !== "created") throw cause;
4029
+ try {
4030
+ await environment.destroy?.();
4031
+ } catch (cleanupError) {
4032
+ throw new AggregateError([cause, cleanupError], "retained run dispatch failed and the environment it created could not be destroyed");
4033
+ }
4034
+ throw cause;
4035
+ };
4036
+ let reference;
4037
+ try {
4038
+ reference = await environment.dispatch(freshTurnInput(options.turn, {
4039
+ turnId: options.turn.turnId,
4040
+ detach: true,
4041
+ ...identity
4042
+ }));
4043
+ } catch (error) {
4044
+ await destroyIfCreated(error);
4045
+ throw error;
4046
+ }
4077
4047
  let exact;
4078
4048
  try {
4079
4049
  if (reference.provider !== void 0 && reference.provider !== options.provider.name) throw new Error("provider dispatch returned a session reference for another provider");
@@ -4086,7 +4056,7 @@ async function dispatchRetainedRun(options) {
4086
4056
  if (controlRef.executionId !== identity.executionId) throw new Error("provider bound another execution than the requested identity");
4087
4057
  exact = exactSession(environment, controlRef);
4088
4058
  } catch (error) {
4089
- throw new RetainedRunDispatchBindingError({
4059
+ const bindingError = new RetainedRunDispatchBindingError({
4090
4060
  provider: options.provider.name,
4091
4061
  environmentId: environment.id,
4092
4062
  sessionId: identity.sessionId,
@@ -4096,6 +4066,8 @@ async function dispatchRetainedRun(options) {
4096
4066
  ...reference.provider === void 0 ? {} : { provider: reference.provider },
4097
4067
  ...reference.controlRef === void 0 ? {} : { controlRef: reference.controlRef }
4098
4068
  }, { cause: error });
4069
+ await destroyIfCreated(bindingError);
4070
+ throw bindingError;
4099
4071
  }
4100
4072
  await admitDurably(options.onAdmission, {
4101
4073
  phase: "dispatched",
@@ -4676,13 +4648,13 @@ async function runBenchmark(cfg) {
4676
4648
  resolved: false,
4677
4649
  progression: [],
4678
4650
  usd: 0,
4679
- usdKnown: true,
4651
+ usdKnown: false,
4680
4652
  ms: 0,
4681
4653
  tokens: {
4682
4654
  input: 0,
4683
4655
  output: 0
4684
4656
  },
4685
- tokensKnown: true
4657
+ tokensKnown: false
4686
4658
  };
4687
4659
  }
4688
4660
  row = {
@@ -6291,6 +6263,43 @@ function traceSurfaceCalls(base) {
6291
6263
  traceSource: trace.source
6292
6264
  };
6293
6265
  }
6266
+ /**
6267
+ * Adapt an `agent-eval` `AnalystRegistry` into the lens shape `supervise({ analysts })` takes.
6268
+ *
6269
+ * The two registries were never structurally compatible: eval's class exposes `list()` and
6270
+ * `run(runId, inputs, opts)` and returns an `AnalystRunResult`, while `supervise` wants `kinds`
6271
+ * and `run(kindId, trace)`. So `'kinds' in buildDefaultAnalystRegistry()` is `false` and the five
6272
+ * calibrated lenses in `DEFAULT_TRACE_ANALYST_KINDS` were unreachable from any supervised run —
6273
+ * every consumer hand-rolled a lens instead (#630).
6274
+ *
6275
+ * The adapter lives HERE, not in eval, for one reason: eval must never import runtime, and runtime
6276
+ * already owns both shapes — it consumes `AnalystFinding` / `AnalystRunResult` from eval for its
6277
+ * analyst loop and defines the supervise lens itself. Writing it in eval would mean eval declaring
6278
+ * a duck-typed copy of a type this package already exports.
6279
+ *
6280
+ * `kinds` is the DEFINITION list, not `registry.list()`, because `Analyst` carries no `area` while
6281
+ * `TraceAnalystDefinition` does — `list()` cannot supply the field the lens shape requires. Every
6282
+ * id must be registered: an unknown kind throws at adapt time rather than returning nothing at run
6283
+ * time, when the driver would read the silence as "no findings".
6284
+ */
6285
+ function analystsFromRegistry(registry, kinds = DEFAULT_TRACE_ANALYST_KINDS, opts) {
6286
+ const registered = new Set(registry.list().map((analyst) => analyst.id));
6287
+ const missing = kinds.map((kind) => kind.id).filter((id) => !registered.has(id));
6288
+ if (missing.length > 0) throw new ValidationError(`analystsFromRegistry: ${missing.map((id) => JSON.stringify(id)).join(", ")} ${missing.length === 1 ? "is" : "are"} not registered; the registry has ${[...registered].map((id) => JSON.stringify(id)).join(", ") || "<none>"}`);
6289
+ return {
6290
+ kinds: kinds.map((kind) => ({
6291
+ id: kind.id,
6292
+ description: kind.description,
6293
+ area: kind.area
6294
+ })),
6295
+ run: async (kindId, trace) => {
6296
+ return (await registry.run(`supervise-analyst-${kindId}-${randomUUID()}`, { traceStore: trace }, {
6297
+ ...opts?.runOpts,
6298
+ only: [kindId]
6299
+ })).findings;
6300
+ }
6301
+ };
6302
+ }
6294
6303
  /** The default self-improvement LENS — authored content, not a code path. On each settled worker it hands
6295
6304
  * the driver the still-FAILING tests (not just a score), so the next spawn targets the persistently-hard
6296
6305
  * cases. Swap `analysts` to change what the driver improves from — that's the one knob. */
@@ -6431,7 +6440,7 @@ async function superviseSurface(profile, task, opts) {
6431
6440
  maxIterations: (innerTurns + 2) * 5 + 16,
6432
6441
  maxTokens: 1e9
6433
6442
  };
6434
- const workerMaxTokens = profileMaxTokens(opts.worker.profile) ?? Math.max(1, Math.floor(budget.maxTokens / 8));
6443
+ const workerMaxTokens = Math.max(1, Math.floor(budget.maxTokens / 8));
6435
6444
  const makeWorkerAgent = (rawProfile) => {
6436
6445
  const p = rawProfile ?? {};
6437
6446
  return {
@@ -6476,12 +6485,6 @@ async function superviseSurface(profile, task, opts) {
6476
6485
  completions: sp.iterations
6477
6486
  };
6478
6487
  }
6479
- function profileMaxTokens(profile) {
6480
- const value = profile.model?.metadata?.maxTokens;
6481
- if (value === void 0) return void 0;
6482
- if (!Number.isSafeInteger(value) || value < 1) throw new Error("superviseSurface: AgentProfile.model.metadata.maxTokens must be a positive safe integer");
6483
- return value;
6484
- }
6485
6488
  //#endregion
6486
6489
  //#region src/runtime/surface-diff.ts
6487
6490
  /**
@@ -7095,6 +7098,6 @@ function tail(s) {
7095
7098
  return s.slice(-400);
7096
7099
  }
7097
7100
  //#endregion
7098
- export { runPersonified as $, pickChampion as A, stopSentinel as At, runBenchmark as B, connectStdioMcp as Bt, analyzeTrace as C, inlineSandboxClient as Ct, chatWorkerSeam as D, completionAuthorizes as Dt, chatTransportExecutor as E, superviseDispatch as Et, strategyAuthorContract as F, renderLeaderboardSvg as Ft, reconnectRetainedRun as G, mcpSecretEnvMetadataKey as Gt, reconnectRetainedInteractiveRun as H, createMcpEnvironment as Ht, strategyAuthorSystemPrompt as I, renderPairwiseMarkdown as It, startRetainedRunInEnvironment as J, secretEnvOfMcpServer as Jt, recoverRetainedRun as K, resolveMcpServerLaunch as Kt, SandboxRunAbortError as L, auditIntent as Lt, selectChampion as M, pairwiseSignificance as Mt, assertStrategyContract as N, renderLeaderboardHtml as Nt, createChatSessionStore as O, deterministicCompletion as Ot, authorStrategy as P, renderLeaderboardMarkdown as Pt, definePersona as Q, openSandboxRun as R, defaultAuditorInstruction as Rt, withUntrackedArtifacts as S, localSandboxClient as St, runCoderChecks as T, loopDispatch as Tt, recoverRetainedInteractiveRun as U, sanitizeMcpToolSchema as Ut, claimRetainedInteractiveControl as V, materializeLocalMcp as Vt, startRetainedInteractiveRun as W, envKeyProvider as Wt, equalKOnCost as X, promotionGate as Y, trajectoryReport as Z, VERIFY_TAIL_CHARS as _, registryScopeAnalyst as _t, localShell as a, renderCorpusToInstructions as at, settledWorkerOut as b, defineLeaderboard as bt, createVerifierEnvironment as c, loopUntil as ct, harvestSurfaceDiffs as d, selectValidWinner as dt, builtinShapes as et, failuresAnalyst as f, verify as ft, NOTE_MAX_CHARS as g, createScopeAnalyst as gt, EVIDENCE_MAX_CHARS as h, buildSteerContext as ht, jjWorkspace as i, InMemoryCorpus as it, runStrategyEvolution as j, leaderboard as jt, discriminatingMeans as k, sentinelCompletion as kt, boxSurfaceReader as l, panel as lt, worktreeFanout as m, assertTraceDerivedFindings as mt, makeFinding$1 as n, registerShape as nt, runInWorkspace as o, fanout as ot, superviseSurface as p, widen as pt, startRetainedRun as q, resolveSecretEnv as qt, gitWorkspace as r, FileCorpus as rt, createWaterfallCollector as s, flatWidenGate as st, computeFindingId$1 as t, createShapeRegistry as tt, fsSurfaceReader as u, pipeline as ut, closingWorkerNote as v, inProcessSandboxClient as vt, patchDelivered as w, loopCampaignDispatch as wt, copyUntrackedIntoClone as x, resolveSandboxClient as xt, composeWorkerEvidence as y, harvestCorpus as yt, printBenchmarkReport as z, McpSpawnFault as zt };
7101
+ export { definePersona as $, discriminatingMeans as A, sentinelCompletion as At, printBenchmarkReport as B, McpSpawnFault as Bt, withUntrackedArtifacts as C, localSandboxClient as Ct, chatTransportExecutor as D, superviseDispatch as Dt, runCoderChecks as E, loopDispatch as Et, authorStrategy as F, renderLeaderboardMarkdown as Ft, startRetainedInteractiveRun as G, envKeyProvider as Gt, claimRetainedInteractiveControl as H, materializeLocalMcp as Ht, strategyAuthorContract as I, renderLeaderboardSvg as It, startRetainedRun as J, resolveSecretEnv as Jt, reconnectRetainedRun as K, mcpSecretEnvMetadataKey as Kt, strategyAuthorSystemPrompt as L, renderPairwiseMarkdown as Lt, runStrategyEvolution as M, leaderboard as Mt, selectChampion as N, pairwiseSignificance as Nt, chatWorkerSeam as O, completionAuthorizes as Ot, assertStrategyContract as P, renderLeaderboardHtml as Pt, trajectoryReport as Q, SandboxRunAbortError as R, auditIntent as Rt, copyUntrackedIntoClone as S, resolveSandboxClient as St, patchDelivered as T, loopCampaignDispatch as Tt, reconnectRetainedInteractiveRun as U, createMcpEnvironment as Ut, runBenchmark as V, connectStdioMcp as Vt, recoverRetainedInteractiveRun as W, sanitizeMcpToolSchema as Wt, promotionGate as X, startRetainedRunInEnvironment as Y, secretEnvOfMcpServer as Yt, equalKOnCost as Z, NOTE_MAX_CHARS as _, createScopeAnalyst as _t, localShell as a, InMemoryCorpus as at, composeWorkerEvidence as b, harvestCorpus as bt, createVerifierEnvironment as c, flatWidenGate as ct, harvestSurfaceDiffs as d, pipeline as dt, runPersonified as et, analystsFromRegistry as f, selectValidWinner as ft, EVIDENCE_MAX_CHARS as g, buildSteerContext as gt, worktreeFanout as h, assertTraceDerivedFindings as ht, jjWorkspace as i, FileCorpus as it, pickChampion as j, stopSentinel as jt, createChatSessionStore as k, deterministicCompletion as kt, boxSurfaceReader as l, loopUntil as lt, superviseSurface as m, widen as mt, makeFinding$1 as n, createShapeRegistry as nt, runInWorkspace as o, renderCorpusToInstructions as ot, failuresAnalyst as p, verify as pt, recoverRetainedRun as q, resolveMcpServerLaunch as qt, gitWorkspace as r, registerShape as rt, createWaterfallCollector as s, fanout as st, computeFindingId$1 as t, builtinShapes as tt, fsSurfaceReader as u, panel as ut, VERIFY_TAIL_CHARS as v, registryScopeAnalyst as vt, analyzeTrace as w, inlineSandboxClient as wt, settledWorkerOut as x, defineLeaderboard as xt, closingWorkerNote as y, inProcessSandboxClient as yt, openSandboxRun as z, defaultAuditorInstruction as zt };
7099
7102
 
7100
- //# sourceMappingURL=runtime-BnqjbOGX.js.map
7103
+ //# sourceMappingURL=runtime-RY_rvv7t.js.map