@tangle-network/agent-runtime 0.134.2 → 0.134.3

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 (87) hide show
  1. package/dist/{activation-CY_v6Ia7.js → activation-BJS5eud7.js} +3 -3
  2. package/dist/{activation-CY_v6Ia7.js.map → activation-BJS5eud7.js.map} +1 -1
  3. package/dist/agent.d.ts +2 -2
  4. package/dist/agent.js +3 -3
  5. package/dist/{analyst-loop-BKWqQhVI.js → analyst-loop-Dk6_xfhI.js} +2 -2
  6. package/dist/{analyst-loop-BKWqQhVI.js.map → analyst-loop-Dk6_xfhI.js.map} +1 -1
  7. package/dist/analyst-loop.d.ts +1 -1
  8. package/dist/analyst-loop.js +1 -1
  9. package/dist/{authoring-BDICoQby.js → authoring-zj6jq4HE.js} +2 -2
  10. package/dist/{authoring-BDICoQby.js.map → authoring-zj6jq4HE.js.map} +1 -1
  11. package/dist/candidate-execution/index.js +4 -4
  12. package/dist/{candidate-execution-CWMkOz7g.js → candidate-execution-DDOdYrRO.js} +4 -4
  13. package/dist/{candidate-execution-CWMkOz7g.js.map → candidate-execution-DDOdYrRO.js.map} +1 -1
  14. package/dist/{conversation-CrWcNPQg.js → conversation-DYVSghi8.js} +2 -2
  15. package/dist/{conversation-CrWcNPQg.js.map → conversation-DYVSghi8.js.map} +1 -1
  16. package/dist/conversation.d.ts +1 -1
  17. package/dist/conversation.js +1 -1
  18. package/dist/{environment-provider-qDOhdE9M.d.ts → environment-provider-CCASQ5FA.d.ts} +3 -3
  19. package/dist/{environment-provider-CPHwqLLm.js → environment-provider-CLNVqp6H.js} +2 -2
  20. package/dist/{environment-provider-CPHwqLLm.js.map → environment-provider-CLNVqp6H.js.map} +1 -1
  21. package/dist/environment-provider.d.ts +1 -1
  22. package/dist/environment-provider.js +1 -1
  23. package/dist/{graph-D5TKFG8R.js → graph-D0bln4rR.js} +3 -3
  24. package/dist/{graph-D5TKFG8R.js.map → graph-D0bln4rR.js.map} +1 -1
  25. package/dist/{improvement-cycle-XLPktFtP.js → improvement-cycle-fezPL8Th.js} +6 -6
  26. package/dist/{improvement-cycle-XLPktFtP.js.map → improvement-cycle-fezPL8Th.js.map} +1 -1
  27. package/dist/{index-DBZTN4ci.d.ts → index-BDPN51IH.d.ts} +4 -4
  28. package/dist/{index-CgBJtAzI.d.ts → index-Dg4MfLHq.d.ts} +3 -3
  29. package/dist/{index-DiUDbnk-.d.ts → index-gevMEHnE.d.ts} +6 -6
  30. package/dist/index.d.ts +9 -9
  31. package/dist/index.js +13 -13
  32. package/dist/intelligence.d.ts +5 -5
  33. package/dist/intelligence.js +6 -6
  34. package/dist/kernel.d.ts +6 -6
  35. package/dist/kernel.js +10 -10
  36. package/dist/{knowledge-Dv2HMnE6.js → knowledge-BXtZD-pC.js} +5 -5
  37. package/dist/{knowledge-Dv2HMnE6.js.map → knowledge-BXtZD-pC.js.map} +1 -1
  38. package/dist/knowledge.d.ts +1 -1
  39. package/dist/knowledge.js +1 -1
  40. package/dist/{loop-runner-bin-Bieu4QO4.js → loop-runner-bin-CjDcX5ua.js} +4 -4
  41. package/dist/{loop-runner-bin-Bieu4QO4.js.map → loop-runner-bin-CjDcX5ua.js.map} +1 -1
  42. package/dist/{loop-runner-bin-D5JXvb_l.d.ts → loop-runner-bin-DvaXefJJ.d.ts} +3 -3
  43. package/dist/loop-runner-bin.d.ts +1 -1
  44. package/dist/loop-runner-bin.js +1 -1
  45. package/dist/mcp/bin.js +3 -3
  46. package/dist/mcp/index.d.ts +5 -5
  47. package/dist/mcp/index.js +5 -5
  48. package/dist/{openai-tools-CzEiSbPW.d.ts → openai-tools-CF2RMD7_.d.ts} +2 -2
  49. package/dist/{openai-tools-D4Rf0Ciu.js → openai-tools-CycyI0v2.js} +2 -2
  50. package/dist/{openai-tools-D4Rf0Ciu.js.map → openai-tools-CycyI0v2.js.map} +1 -1
  51. package/dist/{prepare-BxP7Hq1l.js → prepare-Cv7NzRZl.js} +2 -2
  52. package/dist/{prepare-BxP7Hq1l.js.map → prepare-Cv7NzRZl.js.map} +1 -1
  53. package/dist/primeintellect/index.d.ts +1 -1
  54. package/dist/profiles.d.ts +1 -1
  55. package/dist/{protected-model-port-B82zDDu5.js → protected-model-port-RnAK2ZrP.js} +2 -2
  56. package/dist/{protected-model-port-B82zDDu5.js.map → protected-model-port-RnAK2ZrP.js.map} +1 -1
  57. package/dist/{redact-6UE6pdNi.d.ts → redact-8ssmxJ0J.d.ts} +3 -3
  58. package/dist/{runtime-Ox-uvtni.js → runtime-Btwztu5V.js} +14 -11
  59. package/dist/runtime-Btwztu5V.js.map +1 -0
  60. package/dist/{runtime-DlxoqEj2.d.ts → runtime-CFD7S185.d.ts} +4 -4
  61. package/dist/{sandbox-events-vIwmuPdl.js → sandbox-events-CA2amHoA.js} +98 -3
  62. package/dist/sandbox-events-CA2amHoA.js.map +1 -0
  63. package/dist/{spawn-journal-TJSlDa2J.js → spawn-journal-ZKEKel8N.js} +10 -4
  64. package/dist/spawn-journal-ZKEKel8N.js.map +1 -0
  65. package/dist/{stream-agent-turn-CJog3ebs.d.ts → stream-agent-turn-8rmaOWtn.d.ts} +3 -3
  66. package/dist/{stream-agent-turn-CdIcf-bn.js → stream-agent-turn-DYBpzMmq.js} +2 -2
  67. package/dist/{stream-agent-turn-CdIcf-bn.js.map → stream-agent-turn-DYBpzMmq.js.map} +1 -1
  68. package/dist/{structural-rollout-CnHKUCVM.js → structural-rollout-BHluS9JC.js} +4 -4
  69. package/dist/{structural-rollout-CnHKUCVM.js.map → structural-rollout-BHluS9JC.js.map} +1 -1
  70. package/dist/{supervise-BNOccEtp.js → supervise-BvjQqKsp.js} +6 -6
  71. package/dist/{supervise-BNOccEtp.js.map → supervise-BvjQqKsp.js.map} +1 -1
  72. package/dist/{supervisor-4r4BYSti.js → supervisor-BsniJxSa.js} +96 -21
  73. package/dist/supervisor-BsniJxSa.js.map +1 -0
  74. package/dist/testing.d.ts +2 -2
  75. package/dist/testing.js +12 -12
  76. package/dist/{types-6zHo67jn.d.ts → types-Cz4m4Iv6.d.ts} +3 -3
  77. package/dist/{types-D4BfurNs.d.ts → types-XtB9WZzr.d.ts} +26 -5
  78. package/dist/{util-CG3ghHfb.js → util-C1bv6yog.js} +60 -2
  79. package/dist/util-C1bv6yog.js.map +1 -0
  80. package/dist/{workspace-archive-BwJQSvGi.js → workspace-archive-DFwzVhbk.js} +2 -2
  81. package/dist/{workspace-archive-BwJQSvGi.js.map → workspace-archive-DFwzVhbk.js.map} +1 -1
  82. package/package.json +1 -1
  83. package/dist/runtime-Ox-uvtni.js.map +0 -1
  84. package/dist/sandbox-events-vIwmuPdl.js.map +0 -1
  85. package/dist/spawn-journal-TJSlDa2J.js.map +0 -1
  86. package/dist/supervisor-4r4BYSti.js.map +0 -1
  87. package/dist/util-CG3ghHfb.js.map +0 -1
@@ -1,11 +1,11 @@
1
1
  import { f as ValidationError, r as BackendTransportError, u as RuntimeRunStateError } from "./errors-CVIDr7GQ.js";
2
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
- import { a as notifySandboxEventObserver, n as extractLlmCallEvent } from "./sandbox-events-vIwmuPdl.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-ZKEKel8N.js";
4
+ import { _ as zeroTokenUsage, a as hasCompleteCacheBreakdown, c as promptCacheTokenClasses, d as sleep, f as stringifySafe, g as withTimeout, h as usdEstimatedOf, i as deleteBoxSafe, l as randomSuffix, m as throwIfAborted, n as chargedTokens, p as throwAbort, r as cloneTokenUsage, s as mapWithConcurrency, t as addTokenUsage, u as randomUuid } from "./util-C1bv6yog.js";
5
+ import { a as notifySandboxEventObserver, n as extractLlmCallEvent } from "./sandbox-events-CA2amHoA.js";
6
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
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";
8
+ import { i as resolveAgentEnvironmentProvider, n as providerAsExecutor, r as providerAsSandboxClient } from "./environment-provider-CLNVqp6H.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";
@@ -4661,7 +4661,8 @@ async function executeIteration(args) {
4661
4661
  addTokenUsage(slot.tokenUsage, {
4662
4662
  input: llmCall.tokensIn,
4663
4663
  output: llmCall.tokensOut,
4664
- ...llmCall.tokensKnown === false ? { tokensKnown: false } : {}
4664
+ ...llmCall.tokensKnown === false ? { tokensKnown: false } : {},
4665
+ ...promptCacheTokenClasses(llmCall.tokensIn, llmCall.promptCache)
4665
4666
  });
4666
4667
  args.ctx.runHandle?.observe(llmCall);
4667
4668
  }
@@ -5033,6 +5034,44 @@ function hashJson(value) {
5033
5034
  return (h >>> 0).toString(16).padStart(8, "0");
5034
5035
  }
5035
5036
  //#endregion
5037
+ //#region src/runtime/supervise/cost-estimate.ts
5038
+ /**
5039
+ * Pricing for work that arrived without a provider receipt.
5040
+ *
5041
+ * A turn whose provider reported no billed dollars used to reach the dollar channel as a
5042
+ * known `$0`, so a run that certainly spent money reported a dollar total of zero. A catalog
5043
+ * price is not a receipt, so what this module produces is always marked, never promoted.
5044
+ */
5045
+ /**
5046
+ * Price one unit of work that no provider receipt covered.
5047
+ *
5048
+ * The event always carries `usdKnown: false`: a catalog price approximates what a provider
5049
+ * WOULD bill, never measures what it did. The priced amount is repeated in `usdEstimated` so
5050
+ * a consumer can subtract it from `usd` and recover the dollars a provider actually billed.
5051
+ *
5052
+ * A model with no catalog entry yields `usd: 0` with `usdKnown: false` and no `usdEstimated`.
5053
+ * The turn then reads as unknown dollars, which is true, rather than as a free turn.
5054
+ */
5055
+ function priceUnreceiptedWork(work) {
5056
+ const unknown = {
5057
+ kind: "cost",
5058
+ usd: 0,
5059
+ usdKnown: false
5060
+ };
5061
+ const { inputTokens, outputTokens, model } = work;
5062
+ if (model === void 0 || !isModelPriced(model)) return unknown;
5063
+ if (!Number.isFinite(inputTokens) || !Number.isFinite(outputTokens)) return unknown;
5064
+ if (inputTokens < 0 || outputTokens < 0) return unknown;
5065
+ const usd = estimateCost(inputTokens, outputTokens, model);
5066
+ if (!Number.isFinite(usd) || usd <= 0) return unknown;
5067
+ return {
5068
+ kind: "cost",
5069
+ usd,
5070
+ usdKnown: false,
5071
+ usdEstimated: usd
5072
+ };
5073
+ }
5074
+ //#endregion
5036
5075
  //#region src/runtime/supervise/inbox.ts
5037
5076
  function parseDown(msg) {
5038
5077
  if (!msg || typeof msg !== "object") return void 0;
@@ -5473,14 +5512,15 @@ function createSteerableSandboxSession(args) {
5473
5512
  const input = call.tokensIn ?? 0;
5474
5513
  const output = call.tokensOut ?? 0;
5475
5514
  if (input || output || !callTokensKnown) {
5476
- tokens.input += input;
5477
- tokens.output += output;
5478
- yield {
5515
+ const usage = {
5479
5516
  kind: "tokens",
5480
5517
  input,
5481
5518
  output,
5482
- ...callTokensKnown ? {} : { tokensKnown: false }
5519
+ ...callTokensKnown ? {} : { tokensKnown: false },
5520
+ ...promptCacheTokenClasses(call.tokensIn, call.promptCache)
5483
5521
  };
5522
+ addTokenUsage(tokens, usage);
5523
+ yield usage;
5484
5524
  }
5485
5525
  if (typeof call.costUsd === "number" && call.costUsd > 0) {
5486
5526
  usd += call.costUsd;
@@ -7288,6 +7328,7 @@ async function* streamBridgeSession(args) {
7288
7328
  let tokensKnown = true;
7289
7329
  let usd = 0;
7290
7330
  let usdKnown = true;
7331
+ let estimatedUsdCharged = 0;
7291
7332
  let estimatedUsd = 0;
7292
7333
  let sawEstimatedUsd = false;
7293
7334
  let turns = 0;
@@ -7365,6 +7406,8 @@ async function* streamBridgeSession(args) {
7365
7406
  let turnUsdKnown = true;
7366
7407
  let turnKnownCostSubtotal = 0;
7367
7408
  let turnEstimatedCostSubtotal = 0;
7409
+ let turnInputTokens = 0;
7410
+ let turnOutputTokens = 0;
7368
7411
  let interrupted = false;
7369
7412
  let profileMaterializationPublished = false;
7370
7413
  const publishProfileMaterialization = () => {
@@ -7423,6 +7466,8 @@ async function* streamBridgeSession(args) {
7423
7466
  if (chunk.usage) {
7424
7467
  sawTurnTokenUsage = true;
7425
7468
  if (!chunk.usage.known) turnTokensKnown = false;
7469
+ turnInputTokens += chunk.usage.input;
7470
+ turnOutputTokens += chunk.usage.output;
7426
7471
  const usageEvent = {
7427
7472
  kind: "tokens",
7428
7473
  input: chunk.usage.input,
@@ -7436,8 +7481,8 @@ async function* streamBridgeSession(args) {
7436
7481
  yield usageEvent;
7437
7482
  if (chunk.usage.promptCache) {
7438
7483
  if (chunk.usage.promptCache.freshInput !== void 0) promptCache.freshInput = (promptCache.freshInput ?? 0) + chunk.usage.promptCache.freshInput;
7439
- if (chunk.usage.promptCache.readInput !== void 0) promptCache.readInput = (promptCache.readInput ?? 0) + chunk.usage.promptCache.readInput;
7440
- if (chunk.usage.promptCache.writeInput !== void 0) promptCache.writeInput = (promptCache.writeInput ?? 0) + chunk.usage.promptCache.writeInput;
7484
+ if (chunk.usage.promptCache.readInput !== void 0) promptCache.readTokens = (promptCache.readTokens ?? 0) + chunk.usage.promptCache.readInput;
7485
+ if (chunk.usage.promptCache.writeInput !== void 0) promptCache.writeTokens = (promptCache.writeTokens ?? 0) + chunk.usage.promptCache.writeInput;
7441
7486
  }
7442
7487
  }
7443
7488
  if (chunk.costKnown !== void 0) {
@@ -7490,11 +7535,20 @@ async function* streamBridgeSession(args) {
7490
7535
  });
7491
7536
  if (!sawTurnTokenUsage || !turnTokensKnown) tokensKnown = false;
7492
7537
  if (!sawTurnCostStatus || !turnUsdKnown) usdKnown = false;
7493
- if (!sawTurnCostStatus || !turnUsdKnown) yield {
7494
- kind: "cost",
7495
- usd: 0,
7496
- usdKnown: false
7497
- };
7538
+ if (!sawTurnCostStatus || !turnUsdKnown) {
7539
+ const priced = turnKnownCostSubtotal === 0 ? priceUnreceiptedWork({
7540
+ inputTokens: turnInputTokens,
7541
+ outputTokens: turnOutputTokens,
7542
+ model: observedModel ?? seam.providerModel
7543
+ }) : {
7544
+ kind: "cost",
7545
+ usd: 0,
7546
+ usdKnown: false
7547
+ };
7548
+ if (priced.usdEstimated !== void 0) estimatedUsdCharged += priced.usdEstimated;
7549
+ usd += priced.usd;
7550
+ yield priced;
7551
+ }
7498
7552
  yield { kind: "iteration" };
7499
7553
  if (!interrupted && turnText) lastText = turnText;
7500
7554
  if (interrupted) {
@@ -7514,6 +7568,7 @@ async function* streamBridgeSession(args) {
7514
7568
  ...tokensKnown ? {} : { tokensKnown: false },
7515
7569
  usd,
7516
7570
  ...usdKnown ? {} : { usdKnown: false },
7571
+ ...estimatedUsdCharged > 0 ? { usdEstimated: estimatedUsdCharged } : {},
7517
7572
  ms: Date.now() - started
7518
7573
  };
7519
7574
  const out = {
@@ -9046,6 +9101,11 @@ function assertValidSpend(spend, label) {
9046
9101
  } else if (classified > spend.tokens.input) throw new Error(`${label}.tokens cache classes must not exceed input`);
9047
9102
  }
9048
9103
  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`);
9104
+ if (spend.usdEstimated !== void 0) {
9105
+ if (!Number.isFinite(spend.usdEstimated) || spend.usdEstimated < 0) throw new Error(`${label}.usdEstimated must be a non-negative finite number`);
9106
+ if (spend.usdEstimated > spend.usd) throw new Error(`${label}.usdEstimated must not exceed ${label}.usd`);
9107
+ if (spend.usdKnown !== false) throw new Error(`${label}.usdEstimated requires ${label}.usdKnown false`);
9108
+ }
9049
9109
  }
9050
9110
  /** Fold a normalized `UsageEvent` array into a `Spend`. Tokens and usd are separate
9051
9111
  * channels; iterations come from `'iteration'` events. Pure; `ms` stays zero (the
@@ -9054,6 +9114,7 @@ function spendFromUsageEvents(events) {
9054
9114
  const tokens = zeroTokenUsage();
9055
9115
  let tokensKnown = true;
9056
9116
  let usd = 0;
9117
+ let usdEstimated = 0;
9057
9118
  let usdKnown = true;
9058
9119
  let iterations = 0;
9059
9120
  for (const ev of events) if (ev.kind === "tokens") {
@@ -9061,6 +9122,7 @@ function spendFromUsageEvents(events) {
9061
9122
  if (ev.tokensKnown === false) tokensKnown = false;
9062
9123
  } else if (ev.kind === "cost") {
9063
9124
  usd += ev.usd;
9125
+ usdEstimated += ev.usdEstimated ?? 0;
9064
9126
  if (ev.usdKnown === false) usdKnown = false;
9065
9127
  } else iterations += 1;
9066
9128
  return {
@@ -9069,6 +9131,7 @@ function spendFromUsageEvents(events) {
9069
9131
  ...tokensKnown ? {} : { tokensKnown: false },
9070
9132
  usd,
9071
9133
  ...usdKnown ? {} : { usdKnown: false },
9134
+ ...usdEstimated > 0 ? { usdEstimated } : {},
9072
9135
  ms: 0
9073
9136
  };
9074
9137
  }
@@ -9077,6 +9140,7 @@ async function foldUsage(events) {
9077
9140
  const tokens = zeroTokenUsage();
9078
9141
  let tokensKnown = true;
9079
9142
  let usd = 0;
9143
+ let usdEstimated = 0;
9080
9144
  let usdKnown = true;
9081
9145
  let iterations = 0;
9082
9146
  for await (const ev of events) if (ev.kind === "tokens") {
@@ -9084,6 +9148,7 @@ async function foldUsage(events) {
9084
9148
  if (ev.tokensKnown === false) tokensKnown = false;
9085
9149
  } else if (ev.kind === "cost") {
9086
9150
  usd += ev.usd;
9151
+ usdEstimated += ev.usdEstimated ?? 0;
9087
9152
  if (ev.usdKnown === false) usdKnown = false;
9088
9153
  } else iterations += 1;
9089
9154
  return {
@@ -9092,6 +9157,7 @@ async function foldUsage(events) {
9092
9157
  ...tokensKnown ? {} : { tokensKnown: false },
9093
9158
  usd,
9094
9159
  ...usdKnown ? {} : { usdKnown: false },
9160
+ ...usdEstimated > 0 ? { usdEstimated } : {},
9095
9161
  ms: 0
9096
9162
  };
9097
9163
  }
@@ -9180,8 +9246,8 @@ function createBudgetPool(root, now = Date.now, restore = {}) {
9180
9246
  let violation;
9181
9247
  if (spentTokens > rTokens) violation = `ticket ${ticket.id} spent ${spentTokens} tokens > reserved ${rTokens}`;
9182
9248
  else if (spent.iterations > rIterations) violation = `ticket ${ticket.id} spent ${spent.iterations} iterations > reserved ${rIterations}`;
9183
- else if (usdCapped && usdBudgeted && spent.usd > rUsd) violation = `ticket ${ticket.id} spent $${spent.usd} > reserved $${rUsd}`;
9184
9249
  else if (unknownUnderCap) violation = `ticket ${ticket.id} reported unknown dollar cost under a dollar-capped budget`;
9250
+ else if (usdCapped && usdBudgeted && spent.usd > rUsd) violation = `ticket ${ticket.id} spent $${spent.usd} > reserved $${rUsd}`;
9185
9251
  open.delete(ticket.id);
9186
9252
  if (spent.tokensKnown === false) tokensTainted = true;
9187
9253
  if (!hasCompleteCacheBreakdown(spent.tokens)) cacheBreakdownTainted = true;
@@ -10392,7 +10458,7 @@ function createScope(args) {
10392
10458
  return;
10393
10459
  }
10394
10460
  }
10395
- async function meterInternal(spend, detail, providerModel) {
10461
+ async function meterInternal(spend, detail, providerModel, accountingOnly = false) {
10396
10462
  if (args.signal.aborted) throw new ValidationError("scope.meter: cannot record new driver work after scope abort");
10397
10463
  const seq = meterSeq++;
10398
10464
  let observeError;
@@ -10405,6 +10471,7 @@ function createScope(args) {
10405
10471
  kind: "metered",
10406
10472
  id: args.parentId,
10407
10473
  spend,
10474
+ ...accountingOnly ? { accountingOnly: true } : {},
10408
10475
  ...providerModel === void 0 ? {} : { providerModel: detachedSnapshot(providerModel, "runtime provider model evidence") },
10409
10476
  seq,
10410
10477
  at: new Date(now()).toISOString()
@@ -10454,7 +10521,7 @@ function createScope(args) {
10454
10521
  };
10455
10522
  }
10456
10523
  };
10457
- runtimeOwnedProviderMeters.set(scope, async (spend, providerModel, detail) => meterInternal(spend, detail, providerModel));
10524
+ runtimeOwnedProviderMeters.set(scope, async (spend, providerModel, detail, accountingOnly) => meterInternal(spend, detail, providerModel, accountingOnly));
10458
10525
  if (args.ownerMaterialization !== void 0) {
10459
10526
  const authoredProfile = args.ownerMaterialization.authoredProfile === void 0 ? void 0 : detachedSnapshot(args.ownerMaterialization.authoredProfile, "scope owner authored profile");
10460
10527
  ownerMaterializationStates.set(scope, {
@@ -10482,6 +10549,12 @@ function meterRuntimeOwnedProviderAttempt(scope, spend, providerModel, detail) {
10482
10549
  if (meter === void 0) throw new ValidationError("scope: Runtime-owned provider meter is not bound to this scope");
10483
10550
  return meter(spend, providerModel, detail);
10484
10551
  }
10552
+ /** @internal Meter Runtime-owned accounting that does not represent provider execution. */
10553
+ function meterRuntimeOwnedAccounting(scope, spend, detail) {
10554
+ const meter = runtimeOwnedProviderMeters.get(scope);
10555
+ if (meter === void 0) throw new ValidationError("scope: Runtime-owned provider meter is not bound to this scope");
10556
+ return meter(spend, void 0, detail, true);
10557
+ }
10485
10558
  const ownerMaterializationStates = /* @__PURE__ */ new WeakMap();
10486
10559
  /**
10487
10560
  * @internal Publish exact root-manager materialization from a runtime-owned adapter after dynamic
@@ -12422,6 +12495,7 @@ function accumulate(a, b) {
12422
12495
  if (b.tokensKnown === false) a.tokensKnown = false;
12423
12496
  a.usd += b.usd;
12424
12497
  if (b.usdKnown === false) a.usdKnown = false;
12498
+ if (b.usdEstimated !== void 0) a.usdEstimated = (a.usdEstimated ?? 0) + b.usdEstimated;
12425
12499
  a.ms += b.ms;
12426
12500
  }
12427
12501
  /** Sum two conserved-spend tallies per channel — the child-work journal sum + the drivers' own
@@ -12437,6 +12511,7 @@ function addSpend(a, b) {
12437
12511
  ...a.tokensKnown === false || b.tokensKnown === false ? { tokensKnown: false } : {},
12438
12512
  usd: a.usd + b.usd,
12439
12513
  ...a.usdKnown === false || b.usdKnown === false ? { usdKnown: false } : {},
12514
+ ...usdEstimatedOf(a, b),
12440
12515
  ms: a.ms + b.ms
12441
12516
  };
12442
12517
  }
@@ -12447,6 +12522,6 @@ function isNonEmptySpend(s) {
12447
12522
  return s.iterations > 0 || s.tokens.input > 0 || s.tokens.output > 0 || s.usd > 0 || s.ms > 0 || s.tokensKnown === false || s.usdKnown === false;
12448
12523
  }
12449
12524
  //#endregion
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 };
12525
+ export { createInbox as $, renderProfileMaterializationIssues as $t, createBudgetPool as A, sanitizeKnowledgeReadinessReport as At, WORKER_TRACE_PROPAGATION as B, localHarnessExecutable as Bt, effectiveConcurrency as C, loopEventToOtelSpan as Ct, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as D, createRuntimeEventCollector as Dt, rollingDispatch as E, toOtelAttributes as Et, cliWorktreeExecutor as F, createWorktree as Ft, DEFAULT_SANDBOX_STEERING_MAX_TURNS as G, controlProfileMaterialization as Gt, workerTraceEnv as H, CodexExecutionDiagnosticError as Ht, createExecutor as I, removeWorktree as It, decodeToolPart as J, profileMaterializationAxes$1 as Jt, createSteerableSandboxSession as K, defineProfileMaterializationContract as Kt, createExecutorRegistry as L, DEFAULT_LOCAL_HARNESS as Lt, bindReusableExecutorExecutionId as M, runSettledCommand as Mt, bridgeStopSignalKey as N, runWorktreeHarness as Nt, teardownExecutor as O, createRuntimeStreamEventCollector as Ot, captureReusableExecutorConfig as P, captureWorktreeDiff as Pt, readWorkerProgress as Q, promptResourceProfileMaterialization as Qt, snapshotExecutorConfig as R, LOCAL_HARNESSES as Rt, waitUntil as S, generateSpanId as St, queueOf as T, padTraceId as Tt, workerTraceHeaders as U, AGENT_PROFILE_MATERIALIZATION_AXES as Ut, readWorkerTraceContext as V, parseCodexTokenUsage as Vt, workerTraceSeamKey as W, assertProfileMaterialization as Wt, DEFAULT_STALL_AFTER_MS as X, promptModelProfileMaterialization as Xt, sandboxSessionTraceSource as Y, promptControlProfileMaterialization as Yt, createActivityLog as Z, promptOnlyProfileMaterialization as Zt, createWaitProbes as _, buildRuntimeEventOtelSpans as _t, pickBestDelivered as a, acquireSandbox as at, timerAt as b, exportEvalRuns as bt, driverChild as c, canonicalObservedModel as ct, deriveNodeExecutionIdentity as d, mergeTraceEnv as dt, sandboxActProfileMaterialization as en, createSandboxForSpec as et, meterRuntimeOwnedAccounting as f, readTraceContextFromEnv as ft, settledToIteration as g, buildLoopSpanNodes as gt, scopeOwnerExecutorNodeContext as h, buildLoopOtelSpans as ht, collectDelivered as i, probeSandboxCapabilities as it, spendFromUsageEvents as j, sanitizeRuntimeStreamEvent as jt, assertValidBudget as k, sanitizeAgentRuntimeEvent as kt, withDriverExecutor as l, observedModelMatchesDeclared as lt, recordScopeOwnerMaterialization as m, INTELLIGENCE_WIRE_VERSION as mt, createSupervisor as n, worktreeCliProfileMaterialization as nn, runAgentRounds as nt, runFinalizer as o, routerBrain as ot, meterRuntimeOwnedProviderAttempt as p, traceContextToEnv as pt, createPushTraceSource as q, fullProfileMaterialization as qt, bestDelivered as r, createSandboxLineage as rt, runTree as s, runBrainLoop as st, createRootHandle as t, validateProfileMaterialization as tn, defaultSelectWinner as tt, createScope as u, createPropagatingTraceEmitter as ut, isWaitOutcome as v, createOpenInferenceFileExporter as vt, freeSlots as w, padSpanId as wt, validateWaitSpec as x, flatOtelSpan as xt, pollFor as y, createOtelExporter as yt, createWorktreeCliExecutor as z, harnessSupportsReasoningEffort as zt };
12451
12526
 
12452
- //# sourceMappingURL=supervisor-4r4BYSti.js.map
12527
+ //# sourceMappingURL=supervisor-BsniJxSa.js.map