@tangle-network/agent-runtime 0.133.8 → 0.134.2

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 (99) hide show
  1. package/dist/{activation-CbgOt7bK.js → activation-CY_v6Ia7.js} +3 -3
  2. package/dist/{activation-CbgOt7bK.js.map → activation-CY_v6Ia7.js.map} +1 -1
  3. package/dist/agent.d.ts +1 -1
  4. package/dist/agent.js +2 -2
  5. package/dist/{analyst-loop-C189F6v8.js → analyst-loop-BKWqQhVI.js} +2 -2
  6. package/dist/{analyst-loop-C189F6v8.js.map → analyst-loop-BKWqQhVI.js.map} +1 -1
  7. package/dist/analyst-loop.js +1 -1
  8. package/dist/{authoring-DI2ZcORJ.js → authoring-BDICoQby.js} +2 -2
  9. package/dist/{authoring-DI2ZcORJ.js.map → authoring-BDICoQby.js.map} +1 -1
  10. package/dist/candidate-execution/index.js +4 -4
  11. package/dist/{candidate-execution-_u2HIWeX.js → candidate-execution-CWMkOz7g.js} +4 -4
  12. package/dist/{candidate-execution-_u2HIWeX.js.map → candidate-execution-CWMkOz7g.js.map} +1 -1
  13. package/dist/{conversation-kPowfA_A.js → conversation-CrWcNPQg.js} +4 -4
  14. package/dist/{conversation-kPowfA_A.js.map → conversation-CrWcNPQg.js.map} +1 -1
  15. package/dist/conversation.d.ts +1 -1
  16. package/dist/conversation.js +1 -1
  17. package/dist/{environment-provider-DTJA4ZiM.js → environment-provider-CPHwqLLm.js} +2 -2
  18. package/dist/{environment-provider-DTJA4ZiM.js.map → environment-provider-CPHwqLLm.js.map} +1 -1
  19. package/dist/{environment-provider-B-w9VYcF.d.ts → environment-provider-qDOhdE9M.d.ts} +2 -2
  20. package/dist/environment-provider.d.ts +1 -1
  21. package/dist/environment-provider.js +1 -1
  22. package/dist/{errors-DRoXIc7E.js → errors-CVIDr7GQ.js} +9 -1
  23. package/dist/errors-CVIDr7GQ.js.map +1 -0
  24. package/dist/{graph-CnLcp2Tl.js → graph-D5TKFG8R.js} +4 -4
  25. package/dist/{graph-CnLcp2Tl.js.map → graph-D5TKFG8R.js.map} +1 -1
  26. package/dist/{improvement-cycle-ekj_ODWY.js → improvement-cycle-XLPktFtP.js} +9 -9
  27. package/dist/{improvement-cycle-ekj_ODWY.js.map → improvement-cycle-XLPktFtP.js.map} +1 -1
  28. package/dist/{index-DqJa9jGF.d.ts → index-CgBJtAzI.d.ts} +2 -2
  29. package/dist/{index-CP8LBWD1.d.ts → index-DBZTN4ci.d.ts} +4 -4
  30. package/dist/{index-Cgo-tyB8.d.ts → index-DiUDbnk-.d.ts} +29 -6
  31. package/dist/index.d.ts +7 -7
  32. package/dist/index.js +14 -14
  33. package/dist/intelligence.d.ts +4 -4
  34. package/dist/intelligence.js +6 -6
  35. package/dist/kernel.d.ts +6 -6
  36. package/dist/kernel.js +10 -10
  37. package/dist/{knowledge-BdJoVN9q.js → knowledge-Dv2HMnE6.js} +7 -7
  38. package/dist/{knowledge-BdJoVN9q.js.map → knowledge-Dv2HMnE6.js.map} +1 -1
  39. package/dist/knowledge.d.ts +1 -1
  40. package/dist/knowledge.js +1 -1
  41. package/dist/{loop-runner-bin-C1uQcY_O.js → loop-runner-bin-Bieu4QO4.js} +5 -5
  42. package/dist/{loop-runner-bin-C1uQcY_O.js.map → loop-runner-bin-Bieu4QO4.js.map} +1 -1
  43. package/dist/{loop-runner-bin-BX_266wJ.d.ts → loop-runner-bin-D5JXvb_l.d.ts} +3 -3
  44. package/dist/loop-runner-bin.d.ts +1 -1
  45. package/dist/loop-runner-bin.js +1 -1
  46. package/dist/{materialization-D2bdTfkK.js → materialization-BP5zspr2.js} +25 -10
  47. package/dist/materialization-BP5zspr2.js.map +1 -0
  48. package/dist/mcp/bin.js +4 -4
  49. package/dist/mcp/index.d.ts +3 -3
  50. package/dist/mcp/index.js +9 -9
  51. package/dist/mcp/memory-bin.js +1 -1
  52. package/dist/{memory-server-CblxrUKT.js → memory-server-Cdpy7Uu8.js} +3 -3
  53. package/dist/{memory-server-CblxrUKT.js.map → memory-server-Cdpy7Uu8.js.map} +1 -1
  54. package/dist/{model-policy-Bv1DU2fw.js → model-policy-UTTc9Z-A.js} +2 -2
  55. package/dist/{model-policy-Bv1DU2fw.js.map → model-policy-UTTc9Z-A.js.map} +1 -1
  56. package/dist/{openai-tools-BTznyT19.js → openai-tools-D4Rf0Ciu.js} +2 -2
  57. package/dist/{openai-tools-BTznyT19.js.map → openai-tools-D4Rf0Ciu.js.map} +1 -1
  58. package/dist/{prepare-DUbH3GD5.js → prepare-BxP7Hq1l.js} +2 -2
  59. package/dist/{prepare-DUbH3GD5.js.map → prepare-BxP7Hq1l.js.map} +1 -1
  60. package/dist/primeintellect/index.d.ts +1 -1
  61. package/dist/profiles.js +1 -1
  62. package/dist/{protected-model-port-DP7MS63a.js → protected-model-port-B82zDDu5.js} +2 -2
  63. package/dist/{protected-model-port-DP7MS63a.js.map → protected-model-port-B82zDDu5.js.map} +1 -1
  64. package/dist/{redact-BSD-nvTf.d.ts → redact-6UE6pdNi.d.ts} +3 -3
  65. package/dist/{researcher-BiWSFLi6.js → researcher-DBfKdnAz.js} +3 -3
  66. package/dist/{researcher-BiWSFLi6.js.map → researcher-DBfKdnAz.js.map} +1 -1
  67. package/dist/{runtime-D-26vxJt.d.ts → runtime-DlxoqEj2.d.ts} +27 -6
  68. package/dist/{runtime-Br49sl8u.js → runtime-Ox-uvtni.js} +29 -14
  69. package/dist/runtime-Ox-uvtni.js.map +1 -0
  70. package/dist/{snapshot-DY6VGliG.js → snapshot-BOIprwBk.js} +2 -2
  71. package/dist/{snapshot-DY6VGliG.js.map → snapshot-BOIprwBk.js.map} +1 -1
  72. package/dist/{spawn-journal-BX3-4WDm.js → spawn-journal-TJSlDa2J.js} +27 -11
  73. package/dist/spawn-journal-TJSlDa2J.js.map +1 -0
  74. package/dist/{stream-agent-turn-NFWCv1X1.d.ts → stream-agent-turn-CJog3ebs.d.ts} +2 -2
  75. package/dist/{stream-agent-turn-D8YHY0oO.js → stream-agent-turn-CdIcf-bn.js} +4 -4
  76. package/dist/{stream-agent-turn-D8YHY0oO.js.map → stream-agent-turn-CdIcf-bn.js.map} +1 -1
  77. package/dist/{structural-rollout-C4_mifPH.js → structural-rollout-CnHKUCVM.js} +6 -6
  78. package/dist/{structural-rollout-C4_mifPH.js.map → structural-rollout-CnHKUCVM.js.map} +1 -1
  79. package/dist/{supervise-BTwl4Cdi.js → supervise-BNOccEtp.js} +66 -37
  80. package/dist/supervise-BNOccEtp.js.map +1 -0
  81. package/dist/{supervisor-BA87pb7g.js → supervisor-4r4BYSti.js} +75 -22
  82. package/dist/supervisor-4r4BYSti.js.map +1 -0
  83. package/dist/testing.d.ts +2 -2
  84. package/dist/testing.js +12 -12
  85. package/dist/{tool-server-VvSK1K3X.js → tool-server-Dh-NcbHr.js} +2 -2
  86. package/dist/{tool-server-VvSK1K3X.js.map → tool-server-Dh-NcbHr.js.map} +1 -1
  87. package/dist/{types-DJ7k6vHE.d.ts → types-D4BfurNs.d.ts} +9 -2
  88. package/dist/{util-Dr--8wAL.js → util-CG3ghHfb.js} +56 -7
  89. package/dist/util-CG3ghHfb.js.map +1 -0
  90. package/dist/{workspace-archive-WEbaLREb.js → workspace-archive-BwJQSvGi.js} +2 -2
  91. package/dist/{workspace-archive-WEbaLREb.js.map → workspace-archive-BwJQSvGi.js.map} +1 -1
  92. package/package.json +1 -1
  93. package/dist/errors-DRoXIc7E.js.map +0 -1
  94. package/dist/materialization-D2bdTfkK.js.map +0 -1
  95. package/dist/runtime-Br49sl8u.js.map +0 -1
  96. package/dist/spawn-journal-BX3-4WDm.js.map +0 -1
  97. package/dist/supervise-BTwl4Cdi.js.map +0 -1
  98. package/dist/supervisor-BA87pb7g.js.map +0 -1
  99. package/dist/util-Dr--8wAL.js.map +0 -1
@@ -1,10 +1,10 @@
1
- import { E as SandboxClient, i as ExecCtx } from "./types-6zHo67jn.js";
2
- import { Q as UsageEvent, U as Spend, d as ExecutorFactory, gn as ExecutorProgress, ln as TraceSource, m as ExecutorRegistry } from "./types-DJ7k6vHE.js";
3
- import { i as AgentEnvironmentProvider, o as AgentEnvironmentProviderRegistry, w as ProviderExecutorOptions } from "./environment-provider-B-w9VYcF.js";
1
+ import { E as SandboxClient, i as ExecCtx, k as Validator } from "./types-6zHo67jn.js";
2
+ import { Q as UsageEvent, U as Spend, d as ExecutorFactory, gn as ExecutorProgress, ln as TraceSource, m as ExecutorRegistry } from "./types-D4BfurNs.js";
3
+ import { i as AgentEnvironmentProvider, o as AgentEnvironmentProviderRegistry, w as ProviderExecutorOptions } from "./environment-provider-qDOhdE9M.js";
4
4
  import { AgentProfile, AgentProfileMcpServer, HarnessType, ReasoningEffort } from "@tangle-network/agent-interface";
5
5
  import { WorkspacePlanReceipt } from "@tangle-network/agent-profile-materialize";
6
6
  import { ChildProcess } from "node:child_process";
7
- import { BackendType } from "@tangle-network/sandbox";
7
+ import { BackendType, SandboxEvent } from "@tangle-network/sandbox";
8
8
  //#region src/runtime/router-retry-policy.d.ts
9
9
  /** Exact retry controls accepted at `AgentProfile.model.metadata.retry`. */
10
10
  interface RouterRetryPolicy {
@@ -702,6 +702,22 @@ interface SandboxSeam {
702
702
  /** Hard cap on the composed loop's iterations. The budget pool reserves against
703
703
  * the spawn `Budget.maxIterations`; this is the leaf's own ceiling. Default 1. */
704
704
  maxIterations?: number;
705
+ /**
706
+ * OPT-IN executable score for this worker. Forwarded to the composed
707
+ * `runAgentRounds` as its `validator`, so the kernel calls `validate` while the
708
+ * iteration's box is still alive: `ValidationCtx.box` is a LIVE `SandboxInstance`
709
+ * and the check can run commands or read files in the container it is scoring.
710
+ * Every other supervised hook fires after teardown and can only read the artifact.
711
+ *
712
+ * The resulting verdict becomes the winner's verdict, which this executor already
713
+ * surfaces on its `ExecutorResult`. Absent, nothing changes: the loop runs
714
+ * unscored and the leaf falls back to its own settle verdict.
715
+ *
716
+ * Not representable with `steering` — a steerable session is a multi-turn session
717
+ * on one box, not a `runAgentRounds` composition, so the pair is rejected instead
718
+ * of silently dropping the score.
719
+ */
720
+ validator?: Validator<SandboxLeafOut>;
705
721
  /**
706
722
  * OPT-IN: run this worker as a multi-turn, STEERABLE session instead of the historical
707
723
  * single-shot `runAgentRounds` composition. Setting it gives the sandbox worker an `Executor.deliver`
@@ -909,6 +925,11 @@ interface RouterToolsSeam {
909
925
  durationMs?: number;
910
926
  }) => void;
911
927
  }
928
+ /** Parsed output of the sandbox leaf: the iteration's raw event stream. What a
929
+ * `SandboxSeam.validator` receives as its `output` argument. */
930
+ interface SandboxLeafOut {
931
+ events: SandboxEvent[];
932
+ }
912
933
  /**
913
934
  * The leaf `createWorktreeCliExecutor` as a backend-as-data factory: a supervisor-authored
914
935
  * `AgentProfile` driving claude / codex / opencode on its own worktree. `budgetExempt` like
@@ -956,5 +977,5 @@ declare function createExecutor(config: ExecutorConfig): ExecutorFactory<unknown
956
977
  */
957
978
  declare function createExecutorRegistry(): ExecutorRegistry;
958
979
  //#endregion
959
- export { removeWorktree as $, WorktreeCommandResult as A, RunLocalHarnessOptions as B, ResolvedMcpServerLaunch as C, resolveSecretEnv as D, resolveMcpServerLaunch as E, CodexTokenUsage as F, CreateWorktreeOptions as G, localHarnessExecutable as H, DEFAULT_LOCAL_HARNESS as I, GitRunner as J, DiffOptions as K, LOCAL_HARNESSES as L, WorktreeProfileMaterializationReceipt as M, CodexExecutionEvidence as N, secretEnvOfMcpServer as O, CodexExecutionPolicy as P, createWorktree as Q, LocalHarness as R, KeyProvider as S, mcpSecretEnvMetadataKey as T, parseCodexTokenUsage as U, harnessSupportsReasoningEffort as V, runLocalHarness as W, WorktreeHandle as X, RemoveWorktreeOptions as Y, captureWorktreeDiff as Z, SteerableSandboxSession as _, CliWorktreeSeam as a, ToolLoopCompactionOptions as at, InboxMessage as b, RouterSeam as c, cliWorktreeExecutor as d, RouterTransportConfig as et, createExecutor as f, SteerableSandboxArgs as g, SandboxSteeringOptions as h, CliWorktreeBridgeSeam as i, ToolLoopCompaction as it, WorktreeHarnessResult as j, WorktreeCheckRunner as k, RouterToolsSeam as l, DEFAULT_SANDBOX_STEERING_MAX_TURNS as m, BridgeSeam as n, ToolLoopCallContext as nt, ExecutorConfig as o, ToolLoopMessageRecord as ot, createExecutorRegistry as p, DiffResult as q, CliSeam as r, ToolLoopChat as rt, ProviderSeam as s, ToolLoopToolCall as st, BridgeModelCredential as t, ToolSpec as tt, SandboxSeam as u, createSteerableSandboxSession as v, envKeyProvider as w, createInbox as x, Inbox as y, LocalHarnessResult as z };
960
- //# sourceMappingURL=runtime-D-26vxJt.d.ts.map
980
+ export { createWorktree as $, WorktreeCheckRunner as A, LocalHarnessResult as B, KeyProvider as C, resolveMcpServerLaunch as D, mcpSecretEnvMetadataKey as E, CodexExecutionPolicy as F, runLocalHarness as G, harnessSupportsReasoningEffort as H, CodexTokenUsage as I, DiffResult as J, CreateWorktreeOptions as K, DEFAULT_LOCAL_HARNESS as L, WorktreeHarnessResult as M, WorktreeProfileMaterializationReceipt as N, resolveSecretEnv as O, CodexExecutionEvidence as P, captureWorktreeDiff as Q, LOCAL_HARNESSES as R, createInbox as S, envKeyProvider as T, localHarnessExecutable as U, RunLocalHarnessOptions as V, parseCodexTokenUsage as W, RemoveWorktreeOptions as X, GitRunner as Y, WorktreeHandle as Z, SteerableSandboxArgs as _, CliWorktreeSeam as a, ToolLoopCompaction as at, Inbox as b, RouterSeam as c, ToolLoopToolCall as ct, SandboxSeam as d, removeWorktree as et, cliWorktreeExecutor as f, SandboxSteeringOptions as g, DEFAULT_SANDBOX_STEERING_MAX_TURNS as h, CliWorktreeBridgeSeam as i, ToolLoopChat as it, WorktreeCommandResult as j, secretEnvOfMcpServer as k, RouterToolsSeam as l, createExecutorRegistry as m, BridgeSeam as n, ToolSpec as nt, ExecutorConfig as o, ToolLoopCompactionOptions as ot, createExecutor as p, DiffOptions as q, CliSeam as r, ToolLoopCallContext as rt, ProviderSeam as s, ToolLoopMessageRecord as st, BridgeModelCredential as t, RouterTransportConfig as tt, SandboxLeafOut as u, SteerableSandboxSession as v, ResolvedMcpServerLaunch as w, InboxMessage as x, createSteerableSandboxSession as y, LocalHarness as z };
981
+ //# sourceMappingURL=runtime-DlxoqEj2.d.ts.map
@@ -1,18 +1,18 @@
1
- import { c as RetainedRunAdmissionError, f as ValidationError, l as RetainedRunDispatchBindingError, n as AnalystError, s as PlannerError } from "./errors-DRoXIc7E.js";
2
- import "./stream-agent-turn-D8YHY0oO.js";
3
- import { S as contentAddress, i as InMemorySpawnJournal, r as InMemoryResultBlobStore, y as isTraceAnalysisStore } from "./spawn-journal-BX3-4WDm.js";
4
- import { a as isAbortError, i as hasCompleteCacheBreakdown, l as sleep, m as zeroTokenUsage, n as cloneTokenUsage, s as randomSuffix, t as addTokenUsage, u as stringifySafe } from "./util-Dr--8wAL.js";
1
+ import { c as RetainedRunAdmissionError, f as ValidationError, l as RetainedRunDispatchBindingError, n as AnalystError, s as PlannerError } from "./errors-CVIDr7GQ.js";
2
+ import "./stream-agent-turn-CdIcf-bn.js";
3
+ import { S as contentAddress, i as InMemorySpawnJournal, r as InMemoryResultBlobStore, y as isTraceAnalysisStore } from "./spawn-journal-TJSlDa2J.js";
4
+ import { a as hasCompleteCacheBreakdown, c as randomSuffix, d as stringifySafe, h as zeroTokenUsage, n as chargedTokens, o as isAbortError, r as cloneTokenUsage, t as addTokenUsage, u as sleep } from "./util-CG3ghHfb.js";
5
5
  import { i as redactProtectedValue, r as redactProtectedReason } from "./protected-redaction--F3v1oo8.js";
6
6
  import { a as notifySandboxEventObserver, c as parseCanonicalTransportEvent, s as extractTransportEventIdentity } from "./sandbox-events-vIwmuPdl.js";
7
- import { c as profileProviderModel, i as concreteModelId, s as profileModelExecutionSettings, t as assertExecutableAgentProfile } from "./model-policy-Bv1DU2fw.js";
8
- import { T as executableAgentSpecSnapshot, w as executableAgentProfileSnapshot } from "./materialization-D2bdTfkK.js";
9
- import { F as createExecutor, I as createExecutorRegistry, K as createPushTraceSource, R as createWorktreeCliExecutor, T as rollingDispatch, at as routerBrain, et as defaultSelectWinner, h as settledToIteration, l as withDriverExecutor, n as createSupervisor, nt as createSandboxLineage, ot as runBrainLoop, rt as probeSandboxCapabilities, st as canonicalObservedModel, tt as runAgentRounds } from "./supervisor-BA87pb7g.js";
10
- import "./environment-provider-DTJA4ZiM.js";
7
+ import { c as profileProviderModel, i as concreteModelId, s as profileModelExecutionSettings, t as assertExecutableAgentProfile } from "./model-policy-UTTc9Z-A.js";
8
+ import { E as executableAgentSpecSnapshot, T as executableAgentProfileSnapshot } from "./materialization-BP5zspr2.js";
9
+ import { F as createExecutor, I as createExecutorRegistry, K as createPushTraceSource, R as createWorktreeCliExecutor, T as rollingDispatch, at as routerBrain, et as defaultSelectWinner, h as settledToIteration, l as withDriverExecutor, n as createSupervisor, nt as createSandboxLineage, ot as runBrainLoop, rt as probeSandboxCapabilities, st as canonicalObservedModel, tt as runAgentRounds } from "./supervisor-4r4BYSti.js";
10
+ import "./environment-provider-CPHwqLLm.js";
11
11
  import { i as notifyRuntimeHookEvent } from "./runtime-hooks-C7iJOWm3.js";
12
- 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-C4_mifPH.js";
13
- import { It as gateOnDeliverable, Lt as mapExecutorResult, n as supervise } from "./supervise-BTwl4Cdi.js";
14
- import "./authoring-DI2ZcORJ.js";
15
- import "./graph-CnLcp2Tl.js";
12
+ 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-CnHKUCVM.js";
13
+ import { It as gateOnDeliverable, Lt as mapExecutorResult, n as supervise } from "./supervise-BNOccEtp.js";
14
+ import "./authoring-BDICoQby.js";
15
+ import "./graph-D5TKFG8R.js";
16
16
  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";
17
17
  import { heldoutSignificance, runProfileMatrix } from "@tangle-network/agent-eval/campaign";
18
18
  import { AgentEnvironmentCapabilitiesSchema, AgentExactRunControlRefSchema, AgentNativeContextContinuationResultSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, AgentTurnResultSchema, InteractionAcknowledgementSchema, InteractionResponseCommandSchema, NativeContextBoundaryProofSchema, NativeContextContinuationRequestSchema, RuntimeEventEnvelopeSchema, agentNativeContextContinuationResultMatchesRequest, agentProfileSchema, agentRunCancellationAcknowledgementMatchesRequest, agentRunCancellationRequestDigest, canonicalAgentProfileDigest, canonicalCandidateDigest, nativeContextContinuationTurnDigest, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
@@ -1097,6 +1097,10 @@ function collectProviderModels(evidence, validate) {
1097
1097
  const canonical = /* @__PURE__ */ new Set();
1098
1098
  const observedRaw = /* @__PURE__ */ new Set();
1099
1099
  for (const attempt of evidence.attempts) {
1100
+ if (attempt.providerDispatch === "not_started") {
1101
+ if (attempt.observations.length > 0 || attempt.identityConflict === true) return { kind: "unknown" };
1102
+ continue;
1103
+ }
1100
1104
  if (attempt === null || typeof attempt !== "object" || !Array.isArray(attempt.observations) || attempt.observations.length === 0 || attempt.identityConflict === true) return { kind: "unknown" };
1101
1105
  let attemptBase;
1102
1106
  let attemptSnapshot;
@@ -3120,13 +3124,18 @@ async function trajectoryReport(journal, blobs, root, options = {}) {
3120
3124
  * within-tolerance when the per-channel spread (max − min across arms) over the median is
3121
3125
  * `≤ tolerance`. Pure over the reports — no I/O. Fails loud on an empty arm list (nothing to
3122
3126
  * compare) so a vacuous "equal" is never returned.
3127
+ *
3128
+ * The token channel uses `chargedTokens`, the same unit the conserved pool spends, so the cross-run
3129
+ * check and the within-run pool cannot disagree about what an arm cost. Charging the rolled-up
3130
+ * prompt total instead would rate an arm by how often it re-read a cached prefix: two arms given
3131
+ * identical work would read as unequal compute whenever their cache hit rates differed.
3123
3132
  */
3124
3133
  function equalKOnCost(arms, options = {}) {
3125
3134
  if (arms.length === 0) throw new Error("equalKOnCost: no arms to compare");
3126
3135
  const tolerance = options.tolerance ?? defaultEqualKTolerance;
3127
3136
  const armCosts = arms.map((arm) => ({
3128
3137
  label: arm.label,
3129
- tokens: arm.report.total.tokens.input + arm.report.total.tokens.output,
3138
+ tokens: chargedTokens(arm.report.total.tokens),
3130
3139
  usd: arm.report.total.usd,
3131
3140
  iterations: arm.report.total.iterations
3132
3141
  }));
@@ -3971,6 +3980,7 @@ async function startRetainedRunInEnvironment(options) {
3971
3980
  if (!environment) throw new Error(`provider "${options.provider.name}" no longer holds environment "${options.environment.id}"`);
3972
3981
  if (environment.id !== options.environment.id || environment.provider !== options.provider.name) throw new Error("provider reconstructed a different retained environment");
3973
3982
  if (!environment.dispatch || !environment.session) throw new Error(`provider "${options.provider.name}" does not expose detached session control`);
3983
+ await assertRetainedEnvironmentOwnership(options.provider, environment.id, options.environment.idempotencyKey);
3974
3984
  return dispatchRetainedRun({
3975
3985
  provider: options.provider,
3976
3986
  environment,
@@ -3982,6 +3992,11 @@ async function startRetainedRunInEnvironment(options) {
3982
3992
  now: options.now
3983
3993
  });
3984
3994
  }
3995
+ async function assertRetainedEnvironmentOwnership(provider, environmentId, idempotencyKey) {
3996
+ if (!provider.list) throw new Error(`provider "${provider.name}" cannot prove retained environment ownership by metadata`);
3997
+ const matches = (await provider.list({ metadata: { retainedIdempotencyKey: idempotencyKey } })).filter((summary) => summary.id === environmentId && summary.provider === provider.name);
3998
+ if (matches.length !== 1 || matches[0]?.metadata?.retainedIdempotencyKey !== idempotencyKey) throw new Error(`provider "${provider.name}" could not bind environment "${environmentId}" to its retained idempotency key`);
3999
+ }
3985
4000
  async function dispatchRetainedRun(options) {
3986
4001
  const { environment, identity } = options;
3987
4002
  await admitDurably(options.onAdmission, {
@@ -6654,4 +6669,4 @@ function tail(s) {
6654
6669
  //#endregion
6655
6670
  export { FileCorpus as $, pickChampion as A, renderLeaderboardMarkdown as At, runBenchmark as B, envKeyProvider as Bt, analyzeTrace as C, completionAuthorizes as Ct, chatWorkerSeam as D, leaderboard as Dt, chatTransportExecutor as E, stopSentinel as Et, strategyAuthorContract as F, McpSpawnFault as Ft, promotionGate as G, recoverRetainedRun as H, resolveMcpServerLaunch as Ht, strategyAuthorSystemPrompt as I, connectStdioMcp as It, definePersona as J, equalKOnCost as K, SandboxRunAbortError as L, materializeLocalMcp as Lt, selectChampion as M, renderPairwiseMarkdown as Mt, assertStrategyContract as N, auditIntent as Nt, createChatSessionStore as O, pairwiseSignificance as Ot, authorStrategy as P, defaultAuditorInstruction as Pt, registerShape as Q, openSandboxRun as R, createMcpEnvironment as Rt, withUntrackedArtifacts as S, superviseDispatch as St, runCoderChecks as T, sentinelCompletion as Tt, startRetainedRun as U, resolveSecretEnv as Ut, reconnectRetainedRun as V, mcpSecretEnvMetadataKey as Vt, startRetainedRunInEnvironment as W, secretEnvOfMcpServer as Wt, builtinShapes as X, runPersonified as Y, createShapeRegistry as Z, VERIFY_TAIL_CHARS as _, resolveSandboxClient as _t, localShell as a, panel as at, settledWorkerOut as b, loopCampaignDispatch as bt, createVerifierEnvironment as c, verify as ct, harvestSurfaceDiffs as d, buildSteerContext as dt, InMemoryCorpus as et, failuresAnalyst as f, createScopeAnalyst as ft, NOTE_MAX_CHARS as g, defineLeaderboard as gt, EVIDENCE_MAX_CHARS as h, harvestCorpus as ht, jjWorkspace as i, loopUntil as it, runStrategyEvolution as j, renderLeaderboardSvg as jt, discriminatingMeans as k, renderLeaderboardHtml as kt, boxSurfaceReader as l, widen as lt, worktreeFanout as m, inProcessSandboxClient as mt, makeFinding$1 as n, fanout as nt, runInWorkspace as o, pipeline as ot, superviseSurface as p, registryScopeAnalyst as pt, trajectoryReport as q, gitWorkspace as r, flatWidenGate as rt, createWaterfallCollector as s, selectValidWinner as st, computeFindingId$1 as t, renderCorpusToInstructions as tt, fsSurfaceReader as u, assertTraceDerivedFindings as ut, closingWorkerNote as v, localSandboxClient as vt, patchDelivered as w, deterministicCompletion as wt, copyUntrackedIntoClone as x, loopDispatch as xt, composeWorkerEvidence as y, inlineSandboxClient as yt, printBenchmarkReport as z, sanitizeMcpToolSchema as zt };
6656
6671
 
6657
- //# sourceMappingURL=runtime-Br49sl8u.js.map
6672
+ //# sourceMappingURL=runtime-Ox-uvtni.js.map