@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,11 +1,11 @@
1
- import { f as ValidationError, r as BackendTransportError, u as RuntimeRunStateError } from "./errors-DRoXIc7E.js";
2
- import { t as detachedSnapshot } from "./snapshot-DY6VGliG.js";
3
- import { S as contentAddress, a as aggregateProviderModelEvidence, c as pendingWaits, g as runtimeOwnedNestedDriverTreeRoot, h as nestedDriverTreeRoot, l as replaySpawnTree, m as driverRuntime, o as loadSpawnForest, p as attestNestedDriverTreeOwner, s as materializeTreeView, v as captureWorkerTraceEvidence } from "./spawn-journal-BX3-4WDm.js";
4
- import { c as randomUuid, d as throwAbort, f as throwIfAborted, l as sleep, m as zeroTokenUsage, n as cloneTokenUsage, o as mapWithConcurrency, p as withTimeout, r as deleteBoxSafe, s as randomSuffix, t as addTokenUsage, u as stringifySafe } from "./util-Dr--8wAL.js";
1
+ import { f as ValidationError, r as BackendTransportError, u as RuntimeRunStateError } from "./errors-CVIDr7GQ.js";
2
+ import { t as detachedSnapshot } from "./snapshot-BOIprwBk.js";
3
+ import { S as contentAddress, a as aggregateProviderModelEvidence, c as pendingWaits, g as runtimeOwnedNestedDriverTreeRoot, h as nestedDriverTreeRoot, l as replaySpawnTree, m as driverRuntime, o as loadSpawnForest, p as attestNestedDriverTreeOwner, s as materializeTreeView, v as captureWorkerTraceEvidence } from "./spawn-journal-TJSlDa2J.js";
4
+ import { a as hasCompleteCacheBreakdown, c as randomSuffix, d as stringifySafe, f as throwAbort, h as zeroTokenUsage, i as deleteBoxSafe, l as randomUuid, m as withTimeout, n as chargedTokens, p as throwIfAborted, r as cloneTokenUsage, s as mapWithConcurrency, t as addTokenUsage, u as sleep } from "./util-CG3ghHfb.js";
5
5
  import { a as notifySandboxEventObserver, n as extractLlmCallEvent } from "./sandbox-events-vIwmuPdl.js";
6
- import { a as concreteProfileModel, l as resolveRouterRetryPolicy, o as profileBridgeWireModel, s as profileModelExecutionSettings, t as assertExecutableAgentProfile, u as agentHarness } from "./model-policy-Bv1DU2fw.js";
7
- import { C as unknownMaterializationReceipt, S as unknownExecutionBindingReceipt, T as executableAgentSpecSnapshot, _ as runtimeOwnedExecutorExecutionBinding, a as authoredProfileDigest, b as runtimeOwnedPendingExecutorMaterialization, c as knownExecutionBindingReceipt, f as recordRuntimeOwnedProviderAttemptStart, h as runtimeOwnedDeferredExecutorRuntime, l as knownMaterializationReceipt, m as recordRuntimeOwnedProviderModel, n as attestRuntimeOwnedExecutor, o as finalizeRuntimeOwnedPendingExecutor, p as recordRuntimeOwnedProviderIdentityConflict, r as attestRuntimeOwnedPendingExecutor, t as attestRuntimeOwnedDeferredExecutor, u as newExecutionAttemptId, v as runtimeOwnedExecutorMaterialization, w as executableAgentProfileSnapshot, x as runtimeOwnedScopeOwnerRuntime, y as runtimeOwnedExecutorProviderEvidence } from "./materialization-D2bdTfkK.js";
8
- import { i as resolveAgentEnvironmentProvider, n as providerAsExecutor, r as providerAsSandboxClient } from "./environment-provider-DTJA4ZiM.js";
6
+ import { a as concreteProfileModel, l as resolveRouterRetryPolicy, o as profileBridgeWireModel, s as profileModelExecutionSettings, t as assertExecutableAgentProfile, u as agentHarness } from "./model-policy-UTTc9Z-A.js";
7
+ import { C as unknownExecutionBindingReceipt, E as executableAgentSpecSnapshot, S as runtimeOwnedScopeOwnerRuntime, T as executableAgentProfileSnapshot, a as authoredProfileDigest, b as runtimeOwnedExecutorProviderEvidence, c as knownExecutionBindingReceipt, f as recordRuntimeOwnedProviderAttemptStart, g as runtimeOwnedDeferredExecutorRuntime, h as recordRuntimeOwnedProviderModel, l as knownMaterializationReceipt, m as recordRuntimeOwnedProviderIdentityConflict, n as attestRuntimeOwnedExecutor, o as finalizeRuntimeOwnedPendingExecutor, p as recordRuntimeOwnedProviderDispatchNotStarted, r as attestRuntimeOwnedPendingExecutor, t as attestRuntimeOwnedDeferredExecutor, u as newExecutionAttemptId, v as runtimeOwnedExecutorExecutionBinding, w as unknownMaterializationReceipt, x as runtimeOwnedPendingExecutorMaterialization, y as runtimeOwnedExecutorMaterialization } from "./materialization-BP5zspr2.js";
8
+ import { i as resolveAgentEnvironmentProvider, n as providerAsExecutor, r as providerAsSandboxClient } from "./environment-provider-CPHwqLLm.js";
9
9
  import { i as notifyRuntimeHookEvent } from "./runtime-hooks-C7iJOWm3.js";
10
10
  import { estimateCost, isModelPriced } from "@tangle-network/agent-eval";
11
11
  import { AGENT_PROFILE_MATERIALIZATION_AXES, REASONING_EFFORTS, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, profileMaterializationAxes, profileMaterializationAxes as profileMaterializationAxes$1, sha256DigestSchema } from "@tangle-network/agent-interface";
@@ -6668,6 +6668,7 @@ const sandboxExecutor = (spec, ctx) => {
6668
6668
  }
6669
6669
  };
6670
6670
  if (seam.steering) {
6671
+ if (seam.validator) throw new ValidationError("sandboxExecutor: validator is not representable with steering — the steerable session is not a runAgentRounds composition, so the score would be silently dropped");
6671
6672
  const inbox = createInbox();
6672
6673
  const session = createSteerableSandboxSession({
6673
6674
  controller,
@@ -6719,6 +6720,7 @@ const sandboxExecutor = (spec, ctx) => {
6719
6720
  maxIterations,
6720
6721
  controller,
6721
6722
  loopCtx: seam.loopCtx,
6723
+ ...seam.validator ? { validator: seam.validator } : {},
6722
6724
  traceEnv,
6723
6725
  onArtifact: (a) => {
6724
6726
  artifact = a;
@@ -6758,6 +6760,7 @@ async function* streamSandboxLeaf(args) {
6758
6760
  driver: args.driver,
6759
6761
  agentRun,
6760
6762
  output: args.output,
6763
+ ...args.validator ? { validator: args.validator } : {},
6761
6764
  task: args.task,
6762
6765
  maxIterations: args.maxIterations,
6763
6766
  maxConcurrency: 1,
@@ -7135,6 +7138,7 @@ const bridgeExecutor = (spec, ctx) => {
7135
7138
  trace.record(step);
7136
7139
  },
7137
7140
  onProviderAttemptStart: () => recordRuntimeOwnedProviderAttemptStart(executor),
7141
+ onProviderDispatchNotStarted: () => recordRuntimeOwnedProviderDispatchNotStarted(executor),
7138
7142
  onProviderModel: (model) => recordRuntimeOwnedProviderModel(executor, model),
7139
7143
  onProviderIdentityConflict: () => recordRuntimeOwnedProviderIdentityConflict(executor),
7140
7144
  onArtifact: (a) => {
@@ -7464,6 +7468,7 @@ async function* streamBridgeSession(args) {
7464
7468
  publishProfileMaterialization();
7465
7469
  } catch (error) {
7466
7470
  publishProfileMaterialization();
7471
+ if (isTrustedPreProviderRejection(error)) args.onProviderDispatchNotStarted();
7467
7472
  if (interruptSig.aborted && !args.signal.aborted && !args.controller.signal.aborted) {
7468
7473
  if (!await cancelBridgeRunToTerminal(seam, activeRun, "infinity", external)) throw new ValidationError(`bridgeExecutor: interrupted run ${activeRun.id} did not reach terminal state`);
7469
7474
  interrupted = true;
@@ -7565,9 +7570,11 @@ async function* streamDurableBridgeRun(args) {
7565
7570
  }
7566
7571
  if (!res.ok) {
7567
7572
  const body = (await res.text()).slice(0, 300);
7573
+ const providerDispatch = providerDispatchFromErrorBody(body);
7568
7574
  throw new BackendTransportError("bridge", `bridgeExecutor: bridge ${res.status}: ${body}`, {
7569
7575
  status: res.status,
7570
- body
7576
+ body,
7577
+ ...providerDispatch === "not_started" ? { providerDispatch } : {}
7571
7578
  });
7572
7579
  }
7573
7580
  if (!res.body) throw new ValidationError("bridgeExecutor: bridge response had no body to stream");
@@ -7820,6 +7827,27 @@ async function cancelBridgeRunToTerminal(seam, run, grace, stopSignal) {
7820
7827
  function errorMessage(error) {
7821
7828
  return error instanceof Error ? error.message : String(error);
7822
7829
  }
7830
+ /** Only Router's exact one-sided fact proves that provider dispatch did not start. */
7831
+ function isTrustedPreProviderRejection(error) {
7832
+ return error instanceof BackendTransportError && error.providerDispatch === "not_started";
7833
+ }
7834
+ /** Read only the Router-owned one-sided field from an error body. */
7835
+ function providerDispatchFromErrorBody(body) {
7836
+ let parsed;
7837
+ try {
7838
+ parsed = JSON.parse(body);
7839
+ } catch {
7840
+ return;
7841
+ }
7842
+ if (typeof parsed !== "object" || parsed === null) return void 0;
7843
+ const error = parsed.error;
7844
+ if (typeof error !== "object" || error === null) return void 0;
7845
+ return error.provider_dispatch === "not_started" ? "not_started" : void 0;
7846
+ }
7847
+ function bridgeUpstreamError(error, prefix) {
7848
+ const providerDispatch = error.provider_dispatch === "not_started" ? "not_started" : void 0;
7849
+ return new BackendTransportError("bridge", `${prefix}: ${error.message ?? error.type ?? "unknown"}`, providerDispatch === void 0 ? void 0 : { providerDispatch });
7850
+ }
7823
7851
  function mergeBridgeObservedModel(current, next) {
7824
7852
  if (current === void 0 || current === next) return next;
7825
7853
  const merged = mergeObservedModelIdentity(current, next);
@@ -8116,7 +8144,7 @@ function parseSseStreamTail(buf) {
8116
8144
  } catch {
8117
8145
  return;
8118
8146
  }
8119
- if (parsed.error) throw new ValidationError(`bridgeExecutor: bridge upstream error: ${parsed.error.message ?? parsed.error.type ?? "unknown"}`);
8147
+ if (parsed.error) throw bridgeUpstreamError(parsed.error, "bridgeExecutor: bridge upstream error");
8120
8148
  }
8121
8149
  /** Parse one SSE frame into a numbered run event, terminal marker, or unnumbered keepalive. */
8122
8150
  function parseSseFrame(frame) {
@@ -8151,7 +8179,7 @@ function parseSseFrame(frame) {
8151
8179
  if (parsed.error) return {
8152
8180
  kind: "event",
8153
8181
  id,
8154
- error: new BackendTransportError("bridge", `bridgeExecutor: bridge stream error: ${parsed.error.message ?? parsed.error.type ?? "unknown"}`)
8182
+ error: bridgeUpstreamError(parsed.error, "bridgeExecutor: bridge stream error")
8155
8183
  };
8156
8184
  const out = {};
8157
8185
  if (parsed.model !== void 0) {
@@ -8530,14 +8558,19 @@ function snapshotExecutorConfig(config) {
8530
8558
  "loopCtx",
8531
8559
  "maxIterations",
8532
8560
  "sandboxClient",
8533
- "steering"
8561
+ "steering",
8562
+ "validator"
8534
8563
  ]), "createExecutor sandbox config");
8535
- const { sandboxClient, loopCtx, ...decisionData } = config;
8564
+ const { sandboxClient, loopCtx, validator, ...decisionData } = config;
8565
+ const port = {
8566
+ sandboxClient,
8567
+ ...validator === void 0 ? {} : { validator }
8568
+ };
8536
8569
  if (loopCtx === void 0) {
8537
8570
  const snapshot = detachedSnapshot(decisionData, "createExecutor sandbox config");
8538
8571
  return Object.freeze({
8539
8572
  ...snapshot,
8540
- sandboxClient
8573
+ ...port
8541
8574
  });
8542
8575
  }
8543
8576
  const { hooks, traceEmitter, onSandboxEvent, runHandle, ...loopDecisionData } = loopCtx;
@@ -8548,7 +8581,7 @@ function snapshotExecutorConfig(config) {
8548
8581
  const loopSnapshot = snapshot.loopCtx;
8549
8582
  return Object.freeze({
8550
8583
  ...snapshot,
8551
- sandboxClient,
8584
+ ...port,
8552
8585
  loopCtx: Object.freeze({
8553
8586
  ...loopSnapshot,
8554
8587
  ...hooks === void 0 ? {} : { hooks },
@@ -8944,6 +8977,19 @@ function mergeAbortSignals(...signals) {
8944
8977
  * spend, and refunds the unspent remainder to `free`. Tokens and usd are separate
8945
8978
  * channels (`LoopTokenUsage` has no `usd`); iterations are conserved alongside them.
8946
8979
  *
8980
+ * The token unit is `chargedTokens`: every token counted ONCE, when it first enters the context
8981
+ * (`input − cacheRead + output`, which is `freshInput + cacheWrite + output` under a complete
8982
+ * split). A cached prefix is re-presented content that was already charged when it was written, so
8983
+ * charging a cache read again would charge the same tokens twice — on a real fleet cache is 98% of
8984
+ * the rolled-up prompt total, which made a declared cap bite about 56x early. No price weight
8985
+ * enters the token channel; money is budgeted separately on `maxUsd`. The unit is additive, so a
8986
+ * child's settlement charges what its turns charged and a rolled-up report agrees with the pool.
8987
+ * Prompt tokens the provider never classified are charged in full, and
8988
+ * `readout().cacheBreakdownKnown` then reads false, so the balance reads as an upper bound on
8989
+ * newly-presented work rather than a measurement. The pool trusts a reported cache read the same way
8990
+ * it trusts a reported `input`: the token channel is an accounting unit, not a trust boundary
8991
+ * against a provider that misreports its own usage.
8992
+ *
8947
8993
  * Pure and deterministic: `now()` is injected, there is no I/O, and no wall-clock or
8948
8994
  * RNG read. A `reserve`/`reconcile` ticket is single-use (fail-loud on double or
8949
8995
  * unknown reconcile) so a child can never refund twice. Reconciling an OPEN ticket always
@@ -8993,7 +9039,12 @@ function assertValidSpend(spend, label) {
8993
9039
  }
8994
9040
  for (const [field, value] of [["tokensKnown", spend.tokens.tokensKnown], ["cacheBreakdownKnown", spend.tokens.cacheBreakdownKnown]]) if (value !== void 0 && value !== false) throw new Error(`${label}.tokens.${field} must be false when present`);
8995
9041
  const { freshInput, cacheRead, cacheWrite } = spend.tokens;
8996
- if (freshInput !== void 0 && cacheRead !== void 0 && cacheWrite !== void 0 && freshInput + cacheRead + cacheWrite !== spend.tokens.input) throw new Error(`${label}.tokens cache classes must sum to input`);
9042
+ if (freshInput !== void 0 && cacheRead !== void 0 && cacheWrite !== void 0) {
9043
+ const classified = freshInput + cacheRead + cacheWrite;
9044
+ if (spend.tokens.cacheBreakdownKnown !== false) {
9045
+ if (classified !== spend.tokens.input) throw new Error(`${label}.tokens cache classes must sum to input`);
9046
+ } else if (classified > spend.tokens.input) throw new Error(`${label}.tokens cache classes must not exceed input`);
9047
+ }
8997
9048
  for (const [field, value] of [["usd", spend.usd], ["ms", spend.ms]]) if (!Number.isFinite(value) || value < 0) throw new Error(`${label}.${field} must be a non-negative finite number`);
8998
9049
  }
8999
9050
  /** Fold a normalized `UsageEvent` array into a `Spend`. Tokens and usd are separate
@@ -9044,9 +9095,6 @@ async function foldUsage(events) {
9044
9095
  ms: 0
9045
9096
  };
9046
9097
  }
9047
- function totalTokens(usage) {
9048
- return usage.input + usage.output;
9049
- }
9050
9098
  /**
9051
9099
  * Create a conserved reservation pool from a root `Budget`. `now()` is injected so the
9052
9100
  * deadline readout is deterministic; defaults to `Date.now` for non-test callers. The
@@ -9061,6 +9109,7 @@ function createBudgetPool(root, now = Date.now, restore = {}) {
9061
9109
  let reservedTokens = 0;
9062
9110
  let committedTokens = 0;
9063
9111
  let tokensTainted = false;
9112
+ let cacheBreakdownTainted = false;
9064
9113
  const usdCapped = root.maxUsd !== void 0;
9065
9114
  let freeUsd = root.maxUsd ?? 0;
9066
9115
  let reservedUsd = 0;
@@ -9126,7 +9175,7 @@ function createBudgetPool(root, now = Date.now, restore = {}) {
9126
9175
  assertValidSpend(spent, `budget pool ticket ${ticket.id} spend`);
9127
9176
  const { tokens: rTokens, usd: rUsd, iterations: rIterations } = ticket.reserved;
9128
9177
  const unknownUnderCap = usdCapped && spent.usdKnown === false;
9129
- const spentTokens = totalTokens(spent.tokens);
9178
+ const spentTokens = chargedTokens(spent.tokens);
9130
9179
  const usdBudgeted = ticket.reserved.usdBudgeted !== false;
9131
9180
  let violation;
9132
9181
  if (spentTokens > rTokens) violation = `ticket ${ticket.id} spent ${spentTokens} tokens > reserved ${rTokens}`;
@@ -9135,6 +9184,7 @@ function createBudgetPool(root, now = Date.now, restore = {}) {
9135
9184
  else if (unknownUnderCap) violation = `ticket ${ticket.id} reported unknown dollar cost under a dollar-capped budget`;
9136
9185
  open.delete(ticket.id);
9137
9186
  if (spent.tokensKnown === false) tokensTainted = true;
9187
+ if (!hasCompleteCacheBreakdown(spent.tokens)) cacheBreakdownTainted = true;
9138
9188
  if (spent.usdKnown === false) usdMeasured = false;
9139
9189
  reservedTokens -= rTokens;
9140
9190
  committedTokens += spentTokens;
@@ -9156,8 +9206,9 @@ function createBudgetPool(root, now = Date.now, restore = {}) {
9156
9206
  assertValidSpend(spend, "observed spend");
9157
9207
  if (usdCapped && spend.usdKnown === false) throw new ValidationError("budget pool: cannot observe unknown dollar cost under a dollar-capped budget");
9158
9208
  if (spend.tokensKnown === false) tokensTainted = true;
9209
+ if (!hasCompleteCacheBreakdown(spend.tokens)) cacheBreakdownTainted = true;
9159
9210
  if (spend.usdKnown === false) usdMeasured = false;
9160
- const tokens = totalTokens(spend.tokens);
9211
+ const tokens = chargedTokens(spend.tokens);
9161
9212
  freeTokens -= tokens;
9162
9213
  committedTokens += tokens;
9163
9214
  freeIterations -= spend.iterations;
@@ -9169,6 +9220,7 @@ function createBudgetPool(root, now = Date.now, restore = {}) {
9169
9220
  return {
9170
9221
  tokensLeft: freeTokens,
9171
9222
  tokensKnown: !tokensTainted,
9223
+ cacheBreakdownKnown: !cacheBreakdownTainted,
9172
9224
  usdLeft: usdCapped ? usdTainted ? 0 : freeUsd : 0,
9173
9225
  usdCapped,
9174
9226
  usdKnown: usdMeasured && !usdTainted,
@@ -9184,8 +9236,9 @@ function createBudgetPool(root, now = Date.now, restore = {}) {
9184
9236
  assertValidSpend(restore.committed, "budget restore committed");
9185
9237
  const committed = restore.committed;
9186
9238
  if (committed.tokensKnown === false) tokensTainted = true;
9239
+ if (!hasCompleteCacheBreakdown(committed.tokens)) cacheBreakdownTainted = true;
9187
9240
  if (committed.usdKnown === false) usdMeasured = false;
9188
- const tokens = totalTokens(committed.tokens);
9241
+ const tokens = chargedTokens(committed.tokens);
9189
9242
  freeTokens -= tokens;
9190
9243
  committedTokens += tokens;
9191
9244
  freeIterations -= committed.iterations;
@@ -12396,4 +12449,4 @@ function isNonEmptySpend(s) {
12396
12449
  //#endregion
12397
12450
  export { createSandboxForSpec as $, sandboxActProfileMaterialization as $t, spendFromUsageEvents as A, sanitizeRuntimeStreamEvent as At, readWorkerTraceContext as B, parseCodexTokenUsage as Bt, freeSlots as C, padSpanId as Ct, teardownExecutor as D, createRuntimeStreamEventCollector as Dt, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as E, createRuntimeEventCollector as Et, createExecutor as F, removeWorktree as Ft, createSteerableSandboxSession as G, defineProfileMaterializationContract as Gt, workerTraceHeaders as H, AGENT_PROFILE_MATERIALIZATION_AXES as Ht, createExecutorRegistry as I, DEFAULT_LOCAL_HARNESS as It, sandboxSessionTraceSource as J, promptControlProfileMaterialization as Jt, createPushTraceSource as K, fullProfileMaterialization as Kt, snapshotExecutorConfig as L, LOCAL_HARNESSES as Lt, bridgeStopSignalKey as M, runWorktreeHarness as Mt, captureReusableExecutorConfig as N, captureWorktreeDiff as Nt, assertValidBudget as O, sanitizeAgentRuntimeEvent as Ot, cliWorktreeExecutor as P, createWorktree as Pt, createInbox as Q, renderProfileMaterializationIssues as Qt, createWorktreeCliExecutor as R, harnessSupportsReasoningEffort as Rt, effectiveConcurrency as S, loopEventToOtelSpan as St, rollingDispatch as T, toOtelAttributes as Tt, workerTraceSeamKey as U, assertProfileMaterialization as Ut, workerTraceEnv as V, CodexExecutionDiagnosticError as Vt, DEFAULT_SANDBOX_STEERING_MAX_TURNS as W, controlProfileMaterialization as Wt, createActivityLog as X, promptOnlyProfileMaterialization as Xt, DEFAULT_STALL_AFTER_MS as Y, promptModelProfileMaterialization as Yt, readWorkerProgress as Z, promptResourceProfileMaterialization as Zt, isWaitOutcome as _, createOpenInferenceFileExporter as _t, pickBestDelivered as a, routerBrain as at, validateWaitSpec as b, flatOtelSpan as bt, driverChild as c, observedModelMatchesDeclared as ct, deriveNodeExecutionIdentity as d, readTraceContextFromEnv as dt, validateProfileMaterialization as en, defaultSelectWinner as et, meterRuntimeOwnedProviderAttempt as f, traceContextToEnv as ft, createWaitProbes as g, buildRuntimeEventOtelSpans as gt, settledToIteration as h, buildLoopSpanNodes as ht, collectDelivered as i, acquireSandbox as it, bindReusableExecutorExecutionId as j, runSettledCommand as jt, createBudgetPool as k, sanitizeKnowledgeReadinessReport as kt, withDriverExecutor as l, createPropagatingTraceEmitter as lt, scopeOwnerExecutorNodeContext as m, buildLoopOtelSpans as mt, createSupervisor as n, createSandboxLineage as nt, runFinalizer as o, runBrainLoop as ot, recordScopeOwnerMaterialization as p, INTELLIGENCE_WIRE_VERSION as pt, decodeToolPart as q, profileMaterializationAxes$1 as qt, bestDelivered as r, probeSandboxCapabilities as rt, runTree as s, canonicalObservedModel as st, createRootHandle as t, worktreeCliProfileMaterialization as tn, runAgentRounds as tt, createScope as u, mergeTraceEnv as ut, pollFor as v, createOtelExporter as vt, queueOf as w, padTraceId as wt, waitUntil as x, generateSpanId as xt, timerAt as y, exportEvalRuns as yt, WORKER_TRACE_PROPAGATION as z, localHarnessExecutable as zt };
12398
12451
 
12399
- //# sourceMappingURL=supervisor-BA87pb7g.js.map
12452
+ //# sourceMappingURL=supervisor-4r4BYSti.js.map