@tangle-network/agent-eval 0.215.0 → 0.216.0

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 (192) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/adapters/http.d.ts +3 -3
  3. package/dist/{agent-profile-BGyt2z8U.d.ts → agent-profile-CIA2Atnt.d.ts} +5 -5
  4. package/dist/{agent-profile-BGyt2z8U.d.ts.map → agent-profile-CIA2Atnt.d.ts.map} +1 -1
  5. package/dist/agreement-irr-DsTURxdr.js +186 -0
  6. package/dist/agreement-irr-DsTURxdr.js.map +1 -0
  7. package/dist/analyst/index.d.ts +487 -14
  8. package/dist/analyst/index.d.ts.map +1 -1
  9. package/dist/analyst/index.js +1545 -10
  10. package/dist/analyst/index.js.map +1 -1
  11. package/dist/{analyze-runs-BlslTkOJ.d.ts → analyze-runs-CSDAh8A7.d.ts} +4 -4
  12. package/dist/{analyze-runs-BlslTkOJ.d.ts.map → analyze-runs-CSDAh8A7.d.ts.map} +1 -1
  13. package/dist/{benchmark-command-CMmeV-_Z.js → benchmark-command-CByl9dxG.js} +18 -34
  14. package/dist/benchmark-command-CByl9dxG.js.map +1 -0
  15. package/dist/benchmarks/index.d.ts +5 -5
  16. package/dist/benchmarks/index.js +3 -3
  17. package/dist/campaign/index.d.ts +7 -7
  18. package/dist/campaign/index.js +5 -5
  19. package/dist/{campaign-Cuw3DQKF.js → campaign-BQ-Jujuj.js} +7 -7
  20. package/dist/{campaign-Cuw3DQKF.js.map → campaign-BQ-Jujuj.js.map} +1 -1
  21. package/dist/{chat-client-Bnx8NZe4.js → chat-client-DthPOYGd.js} +2 -2
  22. package/dist/{chat-client-Bnx8NZe4.js.map → chat-client-DthPOYGd.js.map} +1 -1
  23. package/dist/{chat-json-call-CZI1NoGZ.js → chat-json-call-BrKsyspg.js} +2 -2
  24. package/dist/{chat-json-call-CZI1NoGZ.js.map → chat-json-call-BrKsyspg.js.map} +1 -1
  25. package/dist/cli.js +4 -4
  26. package/dist/cluster-bootstrap-B3JywQQn.js +66 -0
  27. package/dist/cluster-bootstrap-B3JywQQn.js.map +1 -0
  28. package/dist/contract/index.d.ts +11 -11
  29. package/dist/contract/index.js +8 -8
  30. package/dist/{cost-ledger-DbQdN3nO.d.ts → cost-ledger-CO7UyEcQ.d.ts} +3 -8
  31. package/dist/{cost-ledger-DbQdN3nO.d.ts.map → cost-ledger-CO7UyEcQ.d.ts.map} +1 -1
  32. package/dist/{cost-ledger-DFOeLeJi.js → cost-ledger-D2FnJPBF.js} +27 -23
  33. package/dist/cost-ledger-D2FnJPBF.js.map +1 -0
  34. package/dist/{default-registry-BAiTePcB.d.ts → default-registry-BrWh62zf.d.ts} +6 -6
  35. package/dist/{default-registry-BAiTePcB.d.ts.map → default-registry-BrWh62zf.d.ts.map} +1 -1
  36. package/dist/{default-registry-BhYGMVbV.js → default-registry-Cn1LQ2Ve.js} +742 -757
  37. package/dist/default-registry-Cn1LQ2Ve.js.map +1 -0
  38. package/dist/{define-agent-eval-CZdBPUkk.d.ts → define-agent-eval-CEWkX5wZ.d.ts} +8 -8
  39. package/dist/{define-agent-eval-CZdBPUkk.d.ts.map → define-agent-eval-CEWkX5wZ.d.ts.map} +1 -1
  40. package/dist/{define-agent-eval-FGtpqnh4.js → define-agent-eval-Ch3MWX6k.js} +3 -3
  41. package/dist/{define-agent-eval-FGtpqnh4.js.map → define-agent-eval-Ch3MWX6k.js.map} +1 -1
  42. package/dist/diagnosis/index.d.ts +2 -2
  43. package/dist/{dspy-rlm-engine-OMBXVN0u.js → dspy-rlm-engine-D-KX_e64.js} +3 -3
  44. package/dist/{dspy-rlm-engine-OMBXVN0u.js.map → dspy-rlm-engine-D-KX_e64.js.map} +1 -1
  45. package/dist/{engine-BzOR5Ygn.d.ts → engine-C_zNWfM8.d.ts} +5 -5
  46. package/dist/{engine-BzOR5Ygn.d.ts.map → engine-C_zNWfM8.d.ts.map} +1 -1
  47. package/dist/evaluation-Cn2dRZIz.d.ts +75 -0
  48. package/dist/evaluation-Cn2dRZIz.d.ts.map +1 -0
  49. package/dist/evaluation.d.ts +2 -74
  50. package/dist/evaluation.js +1 -1
  51. package/dist/{exact-types-DjhfZglz.d.ts → exact-types-CD0lf5Qd.d.ts} +2 -2
  52. package/dist/{exact-types-DjhfZglz.d.ts.map → exact-types-CD0lf5Qd.d.ts.map} +1 -1
  53. package/dist/experiment/index.d.ts +1 -1
  54. package/dist/{external-optimizer-process-DCZx5PdG.js → external-optimizer-process-nnsY5D_4.js} +2 -2
  55. package/dist/{external-optimizer-process-DCZx5PdG.js.map → external-optimizer-process-nnsY5D_4.js.map} +1 -1
  56. package/dist/{external-optimizer-subprocess-CA3aXT8I.js → external-optimizer-subprocess-DcerlZSG.js} +263 -4
  57. package/dist/external-optimizer-subprocess-DcerlZSG.js.map +1 -0
  58. package/dist/{feedback-trajectory-CX01700m.d.ts → feedback-trajectory-DkaDj0dj.d.ts} +3 -3
  59. package/dist/{feedback-trajectory-CX01700m.d.ts.map → feedback-trajectory-DkaDj0dj.d.ts.map} +1 -1
  60. package/dist/fuzz.d.ts +1 -1
  61. package/dist/fuzz.js +1 -1
  62. package/dist/{index-D0_l25We.d.ts → index-CPJJr98o.d.ts} +2 -2
  63. package/dist/{index-D0_l25We.d.ts.map → index-CPJJr98o.d.ts.map} +1 -1
  64. package/dist/{index-DNgf5gyG.d.ts → index-Ch9VxCpK.d.ts} +2 -2
  65. package/dist/{index-DNgf5gyG.d.ts.map → index-Ch9VxCpK.d.ts.map} +1 -1
  66. package/dist/{index-BTwxP7L0.d.ts → index-DlH0Y9gI.d.ts} +10 -10
  67. package/dist/{index-BTwxP7L0.d.ts.map → index-DlH0Y9gI.d.ts.map} +1 -1
  68. package/dist/{index-D_rfXep9.d.ts → index-NvGBiO8H.d.ts} +10 -10
  69. package/dist/{index-D_rfXep9.d.ts.map → index-NvGBiO8H.d.ts.map} +1 -1
  70. package/dist/{index-BWiAAWrk.d.ts → index-oQ4aHziK.d.ts} +9 -9
  71. package/dist/{index-BWiAAWrk.d.ts.map → index-oQ4aHziK.d.ts.map} +1 -1
  72. package/dist/index.d.ts +25 -25
  73. package/dist/index.js +16 -15
  74. package/dist/index.js.map +1 -1
  75. package/dist/{integrity-zloavsM_.d.ts → integrity-CCAxGVK6.d.ts} +2 -2
  76. package/dist/{integrity-zloavsM_.d.ts.map → integrity-CCAxGVK6.d.ts.map} +1 -1
  77. package/dist/{judge-gate-B1_O0QIs.d.ts → judge-gate-DNcUrRFA.d.ts} +2 -2
  78. package/dist/{judge-gate-B1_O0QIs.d.ts.map → judge-gate-DNcUrRFA.d.ts.map} +1 -1
  79. package/dist/{kind-factory-CMlOx08-.js → kind-factory-CbZ-6tvu.js} +3 -3
  80. package/dist/{kind-factory-CMlOx08-.js.map → kind-factory-CbZ-6tvu.js.map} +1 -1
  81. package/dist/{llm-client-C_o62yG1.js → llm-client-DQveoxSM.js} +2 -2
  82. package/dist/{llm-client-C_o62yG1.js.map → llm-client-DQveoxSM.js.map} +1 -1
  83. package/dist/{llm-judge-Dw0rDpve.js → llm-judge-PXV7Xljl.js} +5 -5
  84. package/dist/{llm-judge-Dw0rDpve.js.map → llm-judge-PXV7Xljl.js.map} +1 -1
  85. package/dist/matrix/index.d.ts +2 -2
  86. package/dist/{matrix-CQwid3kj.d.ts → matrix-CHMiebFx.d.ts} +4 -4
  87. package/dist/{matrix-CQwid3kj.d.ts.map → matrix-CHMiebFx.d.ts.map} +1 -1
  88. package/dist/meta-eval/index.d.ts +2 -2
  89. package/dist/meta-eval/index.js +1 -62
  90. package/dist/meta-eval/index.js.map +1 -1
  91. package/dist/{mint-CDy-brUR.d.ts → mint-DCGoBYhB.d.ts} +2 -2
  92. package/dist/{mint-CDy-brUR.d.ts.map → mint-DCGoBYhB.d.ts.map} +1 -1
  93. package/dist/multishot/golden/index.d.ts +1 -1
  94. package/dist/multishot/index.d.ts +2 -2
  95. package/dist/openapi.json +1 -1
  96. package/dist/pipelines/index.js +1 -1
  97. package/dist/{prime-protocol-B7et3tI7.d.ts → prime-protocol-CEE4BR9N.d.ts} +3 -3
  98. package/dist/{prime-protocol-B7et3tI7.d.ts.map → prime-protocol-CEE4BR9N.d.ts.map} +1 -1
  99. package/dist/{produced-state-C1cTYK6w.js → produced-state-ZCtDBxAE.js} +4 -4
  100. package/dist/{produced-state-C1cTYK6w.js.map → produced-state-ZCtDBxAE.js.map} +1 -1
  101. package/dist/{proposal-findings-CXblsskH.js → proposal-findings-BZiMTzAF.js} +2 -36
  102. package/dist/proposal-findings-BZiMTzAF.js.map +1 -0
  103. package/dist/{registry-BL7H33tj.d.ts → registry-JYfPxcVz.d.ts} +11 -13
  104. package/dist/registry-JYfPxcVz.d.ts.map +1 -0
  105. package/dist/{release-confidence-C4kI7lQi.d.ts → release-confidence-BK2QCB5M.d.ts} +3 -3
  106. package/dist/{release-confidence-C4kI7lQi.d.ts.map → release-confidence-BK2QCB5M.d.ts.map} +1 -1
  107. package/dist/{report-command-CtIIsQKP.js → report-command-y8H6RSX8.js} +23 -7
  108. package/dist/report-command-y8H6RSX8.js.map +1 -0
  109. package/dist/reporting.d.ts +3 -3
  110. package/dist/{researcher-DuIJ9IaA.d.ts → researcher-f6mZhh58.d.ts} +5 -5
  111. package/dist/{researcher-DuIJ9IaA.d.ts.map → researcher-f6mZhh58.d.ts.map} +1 -1
  112. package/dist/{reward-hacking-C6Kp54Av.d.ts → reward-hacking-DHA7c1l8.d.ts} +2 -2
  113. package/dist/{reward-hacking-C6Kp54Av.d.ts.map → reward-hacking-DHA7c1l8.d.ts.map} +1 -1
  114. package/dist/rl.d.ts +8 -8
  115. package/dist/rl.js +1 -1
  116. package/dist/rollout/index.d.ts +2 -2
  117. package/dist/{rubric-predictive-validity-BiNNEjpG.d.ts → rubric-predictive-validity-2SgHxoa5.d.ts} +2 -2
  118. package/dist/{rubric-predictive-validity-BiNNEjpG.d.ts.map → rubric-predictive-validity-2SgHxoa5.d.ts.map} +1 -1
  119. package/dist/{run-record-p2AYTrCn.d.ts → run-record-D1Hw-Jml.d.ts} +2 -2
  120. package/dist/{run-record-p2AYTrCn.d.ts.map → run-record-D1Hw-Jml.d.ts.map} +1 -1
  121. package/dist/search/index.d.ts +2 -2
  122. package/dist/{search-kernel-BWp7hfJn.d.ts → search-kernel-CpcKH5Ih.d.ts} +4 -4
  123. package/dist/{search-kernel-BWp7hfJn.d.ts.map → search-kernel-CpcKH5Ih.d.ts.map} +1 -1
  124. package/dist/{semantic-concept-judge-sDBNg_mI.js → semantic-concept-judge-zQBG9hHU.js} +6 -6
  125. package/dist/{semantic-concept-judge-sDBNg_mI.js.map → semantic-concept-judge-zQBG9hHU.js.map} +1 -1
  126. package/dist/{server-BRpadnVt.js → server-DbcC7xMl.js} +3 -3
  127. package/dist/{server-BRpadnVt.js.map → server-DbcC7xMl.js.map} +1 -1
  128. package/dist/{skillopt-optimization-method-CvaFGm95.js → skillopt-optimization-method-CCtzralq.js} +5 -5
  129. package/dist/{skillopt-optimization-method-CvaFGm95.js.map → skillopt-optimization-method-CCtzralq.js.map} +1 -1
  130. package/dist/{statistical-heldout-DZaTo3gZ.d.ts → statistical-heldout-BeR4bOdg.d.ts} +3 -3
  131. package/dist/{statistical-heldout-DZaTo3gZ.d.ts.map → statistical-heldout-BeR4bOdg.d.ts.map} +1 -1
  132. package/dist/{store-otlp-0AiS29kg.js → store-otlp-DtB4Slsr.js} +2 -2
  133. package/dist/{store-otlp-0AiS29kg.js.map → store-otlp-DtB4Slsr.js.map} +1 -1
  134. package/dist/{store-tool-spans-DuvZ4YWb.d.ts → store-tool-spans-DR1SrCLK.d.ts} +7 -7
  135. package/dist/{store-tool-spans-DuvZ4YWb.d.ts.map → store-tool-spans-DR1SrCLK.d.ts.map} +1 -1
  136. package/dist/{store-tool-spans-BAcBBSM8.js → store-tool-spans-fZIigrpP.js} +3 -3
  137. package/dist/{store-tool-spans-BAcBBSM8.js.map → store-tool-spans-fZIigrpP.js.map} +1 -1
  138. package/dist/{summary-report-CK0ueoJd.d.ts → summary-report-C-CtItCN.d.ts} +2 -2
  139. package/dist/{summary-report-CK0ueoJd.d.ts.map → summary-report-C-CtItCN.d.ts.map} +1 -1
  140. package/dist/supervisor-run/index.d.ts +1 -1
  141. package/dist/supervisor-run/index.d.ts.map +1 -1
  142. package/dist/supervisor-run/index.js +1 -1
  143. package/dist/systemone-CpTLAlqb.d.ts +135 -0
  144. package/dist/systemone-CpTLAlqb.d.ts.map +1 -0
  145. package/dist/{systemone-review-DTClwgmE.js → systemone-review-BZWfrtq1.js} +2 -2
  146. package/dist/{systemone-review-DTClwgmE.js.map → systemone-review-BZWfrtq1.js.map} +1 -1
  147. package/dist/{systemone-review-BReh3mvm.d.ts → systemone-review-B_yo1xsd.d.ts} +2 -2
  148. package/dist/{systemone-review-BReh3mvm.d.ts.map → systemone-review-B_yo1xsd.d.ts.map} +1 -1
  149. package/dist/systemone.d.ts +4 -134
  150. package/dist/systemone.js +1 -1
  151. package/dist/terminal-record-BHocwFw1.js.map +1 -1
  152. package/dist/{tool-groups-DOriCbkR.d.ts → tool-groups-mcxOXVlb.d.ts} +3 -3
  153. package/dist/tool-groups-mcxOXVlb.d.ts.map +1 -0
  154. package/dist/{tool-waste-BYt5rdt8.js → tool-waste-D52PqU9Q.js} +3 -156
  155. package/dist/tool-waste-D52PqU9Q.js.map +1 -0
  156. package/dist/{trace-questions-RCaYLkwH.d.ts → trace-questions-DG7nqLQ7.d.ts} +4 -4
  157. package/dist/{trace-questions-RCaYLkwH.d.ts.map → trace-questions-DG7nqLQ7.d.ts.map} +1 -1
  158. package/dist/trace-repair/index.d.ts +3 -3
  159. package/dist/traces.d.ts +6 -6
  160. package/dist/traces.js +3 -3
  161. package/dist/{types-CMnPcbW5.d.ts → types-B4C5nFw6.d.ts} +6 -6
  162. package/dist/{types-CMnPcbW5.d.ts.map → types-B4C5nFw6.d.ts.map} +1 -1
  163. package/dist/{types-DjOMwGY_.d.ts → types-BqkVmHfv.d.ts} +7 -1
  164. package/dist/types-BqkVmHfv.d.ts.map +1 -0
  165. package/dist/{types-Dj0Qv2qi.d.ts → types-CfZMIzB_.d.ts} +3 -3
  166. package/dist/{types-Dj0Qv2qi.d.ts.map → types-CfZMIzB_.d.ts.map} +1 -1
  167. package/dist/{types-Lub7o6bN.d.ts → types-DBZ7keha.d.ts} +2 -2
  168. package/dist/{types-Lub7o6bN.d.ts.map → types-DBZ7keha.d.ts.map} +1 -1
  169. package/dist/{types-CW5b90JH.js → types-IXD2HJzu.js} +16 -3
  170. package/dist/types-IXD2HJzu.js.map +1 -0
  171. package/dist/{types-KEkKkETv.d.ts → types-oKRhQAde.d.ts} +347 -6
  172. package/dist/types-oKRhQAde.d.ts.map +1 -0
  173. package/dist/wire/index.d.ts +3 -3
  174. package/dist/wire/index.js +1 -1
  175. package/docs/campaign-proposers.md +3 -0
  176. package/docs/concepts.md +1 -0
  177. package/docs/finding-layers.md +69 -0
  178. package/package.json +1 -1
  179. package/dist/benchmark-command-CMmeV-_Z.js.map +0 -1
  180. package/dist/cost-ledger-DFOeLeJi.js.map +0 -1
  181. package/dist/default-registry-BhYGMVbV.js.map +0 -1
  182. package/dist/evaluation.d.ts.map +0 -1
  183. package/dist/external-optimizer-subprocess-CA3aXT8I.js.map +0 -1
  184. package/dist/proposal-findings-CXblsskH.js.map +0 -1
  185. package/dist/registry-BL7H33tj.d.ts.map +0 -1
  186. package/dist/report-command-CtIIsQKP.js.map +0 -1
  187. package/dist/systemone.d.ts.map +0 -1
  188. package/dist/tool-groups-DOriCbkR.d.ts.map +0 -1
  189. package/dist/tool-waste-BYt5rdt8.js.map +0 -1
  190. package/dist/types-CW5b90JH.js.map +0 -1
  191. package/dist/types-DjOMwGY_.d.ts.map +0 -1
  192. package/dist/types-KEkKkETv.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { n as LlmClient } from "./llm-client-C_o62yG1.js";
1
+ import { n as LlmClient } from "./llm-client-DQveoxSM.js";
2
2
  //#region src/analyst/chat-client.ts
3
3
  /**
4
4
  * Provider-neutral chat contract for every model call made by agent-eval.
@@ -114,4 +114,4 @@ function openAiCompatibleClient(opts) {
114
114
  //#endregion
115
115
  export { createChatClient as t };
116
116
 
117
- //# sourceMappingURL=chat-client-Bnx8NZe4.js.map
117
+ //# sourceMappingURL=chat-client-DthPOYGd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chat-client-Bnx8NZe4.js","names":[],"sources":["../src/analyst/chat-client.ts"],"sourcesContent":["/**\n * Provider-neutral chat contract for every model call made by agent-eval.\n *\n * The caller owns model execution. Evaluation code receives canonical requests\n * and results without importing a provider SDK, and agent-eval reads no\n * environment variable to find a provider credential: every transport is bound\n * at the call site.\n *\n * Two ways to bind one. `custom` and `sandbox-sdk` take a `chat` function the\n * caller wrote. `openai-compatible` takes an endpoint and a credential the\n * caller passes as values, and agent-eval issues the HTTP request itself.\n *\n * WHY THE THIRD ONE EXISTS. Every consumer that wanted a plain OpenAI-style\n * endpoint had to hand-write the same fetch loop — retry on 429 and 5xx,\n * `json_schema` degrade, fenced-JSON stripping, and, load-bearing here, the\n * `servedModel` echo that `assertServedModel` and `assertCrossFamilyServed`\n * read. A hand-written transport that omits `servedModel` makes both identity\n * checks read `unreported`, so the two-vendor judge rule they enforce silently\n * measures nothing. Measured motive: agent-eval 0.172.1 exported no such\n * transport, so a two-model judge panel in discovery-lab reached\n * `createChatClient({ transport: 'custom', baseUrl, apiKey })` — fields that\n * exist on no transport option — and every call threw\n * `TypeError: opts.chat is not a function`, which surfaced as\n * `aggregateJudgeVerdicts: all 2 judges failed`.\n *\n * The credential still never comes from agent-eval's environment. `baseUrl`\n * and the bearer are required arguments with no default and no fallback, so a\n * misconfigured caller gets a refusal at construction, never a call to an\n * endpoint it did not name.\n */\n\nimport {\n type LlmCallRequest,\n type LlmCallResult,\n LlmClient,\n type LlmClientOptions,\n} from '../llm-client'\n\n/**\n * Unified chat interface using the package's canonical LLM request and result.\n */\nexport interface ChatClient {\n /** Display name of the bound transport, included in telemetry. */\n readonly transport: ChatTransport\n /** Default model when the caller omits one. */\n readonly defaultModel?: string\n /** Total provider attempts this transport can make for one chat call. */\n readonly maximumAttempts?: number\n\n /** Implementations must enforce `req.maxTokens` when it is present. */\n chat(req: ChatRequest, opts?: ChatCallOpts): Promise<ChatResponse>\n}\n\nexport type ChatTransport =\n | 'sandbox-sdk' // box.streamPrompt() — chat completion via sandbox SDK\n | 'custom' // caller-adapted SDK or transport\n | 'openai-compatible' // caller-named /v1 endpoint, driven by this package\n | 'mock' // test-time injection\n\nexport interface ChatRequest extends Omit<LlmCallRequest, 'model'> {\n /** Optional — falls back to ChatClient.defaultModel. */\n model?: string\n}\n\nexport type ChatResponse = LlmCallResult\n\nexport interface ChatCallOpts {\n /** Cancel the in-flight request. */\n signal?: AbortSignal\n /** Hard USD ceiling for this single call (informational; the underlying transport may not enforce). */\n maxCostUsd?: number\n /** Correlation tag carried into request headers when the transport allows. */\n correlationId?: string\n /** Stable provider idempotency key for retries/redrives of one paid call. */\n idempotencyKey?: string\n}\n\n// ── Factory ─────────────────────────────────────────────────────────\n\nexport type CreateChatClientOpts =\n | SandboxSdkTransportOpts\n | CustomTransportOpts\n | OpenAiCompatibleTransportOpts\n | MockTransportOpts\n\ninterface BaseTransportOpts {\n defaultModel?: string\n /** Total provider attempts. Required for opaque transports used in capped runs. */\n maximumAttempts?: number\n}\n\n/**\n * Sandbox-SDK transport. The caller supplies a canonical chat function for an\n * already-configured Sandbox handle, so agent-eval does not import the SDK.\n */\nexport interface SandboxSdkTransportOpts extends BaseTransportOpts {\n transport: 'sandbox-sdk'\n chat: (req: ChatRequest, opts?: ChatCallOpts) => Promise<ChatResponse>\n}\n\n/** Caller-adapted SDK or transport returning the canonical ChatResponse shape. */\nexport interface CustomTransportOpts extends BaseTransportOpts {\n transport: 'custom'\n chat: (req: ChatRequest, opts?: ChatCallOpts) => Promise<ChatResponse>\n}\n\n/**\n * OpenAI-compatible HTTP transport: the caller names a `/v1` endpoint and\n * hands over a bearer, and this package drives `POST {baseUrl}/chat/completions`.\n *\n * Use this instead of hand-rolling a `custom` transport around `fetch`. The\n * result carries `servedModel` — the model id the provider echoed, verbatim —\n * which is the only field `assertServedModel` and `assertCrossFamilyServed`\n * can read to witness a gateway answering from a different model than the one\n * requested.\n *\n * `baseUrl` ends at the `/v1` prefix; the `/chat/completions` path is this\n * package's to append. A `baseUrl` that already carries the path is a\n * construction error, not a request to a doubled URL.\n *\n * Exactly one credential form is required — `apiKey`, `bearer`, or\n * `authHeader`. There is no environment fallback: agent-eval never goes\n * looking for a key.\n */\nexport interface OpenAiCompatibleTransportOpts\n extends BaseTransportOpts,\n Pick<\n LlmClientOptions,\n | 'assertServedModel'\n | 'customTokenPricing'\n | 'deadlineMs'\n | 'defaultTimeoutMs'\n | 'fetch'\n | 'jsonPayloadMode'\n | 'jsonSchemaTransport'\n | 'minIntervalMs'\n | 'provider'\n | 'rawSink'\n | 'signal'\n | 'thinking'\n > {\n transport: 'openai-compatible'\n /** Endpoint ending at the `/v1` prefix. Required — there is no default endpoint. */\n baseUrl: string\n /** Bearer credential. One of `apiKey`, `bearer`, or `authHeader` is required. */\n apiKey?: string\n /** Bearer credential, alternate spelling. */\n bearer?: string\n /** Non-bearer authorization header, for endpoints that want their own scheme. */\n authHeader?: { name: string; value: string }\n}\n\n/**\n * Mock transport for tests. The handler receives the request and returns\n * whatever the test wants. No retries, no JSON-schema degrade.\n */\nexport interface MockTransportOpts extends BaseTransportOpts {\n transport: 'mock'\n handler: (req: ChatRequest, opts?: ChatCallOpts) => Promise<ChatResponse>\n}\n\n/**\n * Build a ChatClient bound to a specific transport. The returned client\n * is safe to share across analysts in a single registry run.\n */\nexport function createChatClient(opts: CreateChatClientOpts): ChatClient {\n switch (opts.transport) {\n case 'sandbox-sdk':\n return {\n transport: 'sandbox-sdk',\n defaultModel: opts.defaultModel,\n maximumAttempts: opts.maximumAttempts,\n chat: async (req, callOpts) => opts.chat(resolveModel(req, opts.defaultModel), callOpts),\n }\n case 'custom':\n return {\n transport: 'custom',\n defaultModel: opts.defaultModel,\n maximumAttempts: opts.maximumAttempts,\n chat: async (req, callOpts) => opts.chat(resolveModel(req, opts.defaultModel), callOpts),\n }\n case 'openai-compatible':\n return openAiCompatibleClient(opts)\n case 'mock':\n return {\n transport: 'mock',\n defaultModel: opts.defaultModel,\n maximumAttempts: 1,\n chat: async (req, callOpts) => opts.handler(resolveModel(req, opts.defaultModel), callOpts),\n }\n }\n}\n\nfunction resolveModel(req: ChatRequest, defaultModel: string | undefined): ChatRequest {\n if (req.model) return req\n if (!defaultModel) {\n throw new Error(\n 'ChatClient.chat: no model on request and no defaultModel on the client. ' +\n 'Either pass req.model or bind defaultModel at createChatClient().',\n )\n }\n return { ...req, model: defaultModel }\n}\n\n/**\n * Build the OpenAI-compatible client, refusing a half-configured one first.\n *\n * Both refusals are construction-time on purpose. A missing credential or a\n * doubled path is a caller mistake that a request would turn into a 401 or a\n * 404 from an endpoint the caller did not intend to reach — the failure then\n * reads as a provider problem instead of a configuration one.\n */\nfunction openAiCompatibleClient(opts: OpenAiCompatibleTransportOpts): ChatClient {\n const baseUrl = opts.baseUrl?.trim().replace(/\\/+$/, '') ?? ''\n if (!baseUrl) {\n throw new Error(\n \"createChatClient({ transport: 'openai-compatible' }): baseUrl is required and has no default.\",\n )\n }\n if (/\\/chat\\/completions$/.test(baseUrl)) {\n throw new Error(\n \"createChatClient({ transport: 'openai-compatible' }): baseUrl ends at the /v1 prefix; \" +\n `this package appends /chat/completions. Got ${baseUrl}`,\n )\n }\n if (!opts.apiKey?.trim() && !opts.bearer?.trim() && !opts.authHeader) {\n throw new Error(\n \"createChatClient({ transport: 'openai-compatible' }): one of apiKey, bearer, or authHeader \" +\n 'is required. agent-eval reads no environment variable for a credential.',\n )\n }\n\n const clientOptions: LlmClientOptions = {\n baseUrl,\n ...(opts.apiKey ? { apiKey: opts.apiKey } : {}),\n ...(opts.bearer ? { bearer: opts.bearer } : {}),\n ...(opts.authHeader ? { authHeader: opts.authHeader } : {}),\n ...(opts.maximumAttempts === undefined ? {} : { maximumAttempts: opts.maximumAttempts }),\n ...(opts.assertServedModel === undefined ? {} : { assertServedModel: opts.assertServedModel }),\n ...(opts.customTokenPricing === undefined\n ? {}\n : { customTokenPricing: opts.customTokenPricing }),\n ...(opts.deadlineMs === undefined ? {} : { deadlineMs: opts.deadlineMs }),\n ...(opts.defaultTimeoutMs === undefined ? {} : { defaultTimeoutMs: opts.defaultTimeoutMs }),\n ...(opts.fetch === undefined ? {} : { fetch: opts.fetch }),\n ...(opts.jsonPayloadMode === undefined ? {} : { jsonPayloadMode: opts.jsonPayloadMode }),\n ...(opts.jsonSchemaTransport === undefined\n ? {}\n : { jsonSchemaTransport: opts.jsonSchemaTransport }),\n ...(opts.minIntervalMs === undefined ? {} : { minIntervalMs: opts.minIntervalMs }),\n ...(opts.provider === undefined ? {} : { provider: opts.provider }),\n ...(opts.rawSink === undefined ? {} : { rawSink: opts.rawSink }),\n ...(opts.signal === undefined ? {} : { signal: opts.signal }),\n ...(opts.thinking === undefined ? {} : { thinking: opts.thinking }),\n }\n const client = new LlmClient(clientOptions)\n\n return {\n transport: 'openai-compatible',\n ...(opts.defaultModel ? { defaultModel: opts.defaultModel } : {}),\n maximumAttempts: client.maximumAttempts,\n chat: async (req, callOpts) => {\n const resolved = resolveModel(req, opts.defaultModel)\n return client.call(resolved as LlmCallRequest, {\n ...(callOpts?.signal ? { signal: callOpts.signal } : {}),\n ...(callOpts?.idempotencyKey ? { idempotencyKey: callOpts.idempotencyKey } : {}),\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqKA,SAAgB,iBAAiB,MAAwC;CACvE,QAAQ,KAAK,WAAb;EACE,KAAK,eACH,OAAO;GACL,WAAW;GACX,cAAc,KAAK;GACnB,iBAAiB,KAAK;GACtB,MAAM,OAAO,KAAK,aAAa,KAAK,KAAK,aAAa,KAAK,KAAK,YAAY,GAAG,QAAQ;EACzF;EACF,KAAK,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":3,"file":"chat-client-DthPOYGd.js","names":[],"sources":["../src/analyst/chat-client.ts"],"sourcesContent":["/**\n * Provider-neutral chat contract for every model call made by agent-eval.\n *\n * The caller owns model execution. Evaluation code receives canonical requests\n * and results without importing a provider SDK, and agent-eval reads no\n * environment variable to find a provider credential: every transport is bound\n * at the call site.\n *\n * Two ways to bind one. `custom` and `sandbox-sdk` take a `chat` function the\n * caller wrote. `openai-compatible` takes an endpoint and a credential the\n * caller passes as values, and agent-eval issues the HTTP request itself.\n *\n * WHY THE THIRD ONE EXISTS. Every consumer that wanted a plain OpenAI-style\n * endpoint had to hand-write the same fetch loop — retry on 429 and 5xx,\n * `json_schema` degrade, fenced-JSON stripping, and, load-bearing here, the\n * `servedModel` echo that `assertServedModel` and `assertCrossFamilyServed`\n * read. A hand-written transport that omits `servedModel` makes both identity\n * checks read `unreported`, so the two-vendor judge rule they enforce silently\n * measures nothing. Measured motive: agent-eval 0.172.1 exported no such\n * transport, so a two-model judge panel in discovery-lab reached\n * `createChatClient({ transport: 'custom', baseUrl, apiKey })` — fields that\n * exist on no transport option — and every call threw\n * `TypeError: opts.chat is not a function`, which surfaced as\n * `aggregateJudgeVerdicts: all 2 judges failed`.\n *\n * The credential still never comes from agent-eval's environment. `baseUrl`\n * and the bearer are required arguments with no default and no fallback, so a\n * misconfigured caller gets a refusal at construction, never a call to an\n * endpoint it did not name.\n */\n\nimport {\n type LlmCallRequest,\n type LlmCallResult,\n LlmClient,\n type LlmClientOptions,\n} from '../llm-client'\n\n/**\n * Unified chat interface using the package's canonical LLM request and result.\n */\nexport interface ChatClient {\n /** Display name of the bound transport, included in telemetry. */\n readonly transport: ChatTransport\n /** Default model when the caller omits one. */\n readonly defaultModel?: string\n /** Total provider attempts this transport can make for one chat call. */\n readonly maximumAttempts?: number\n\n /** Implementations must enforce `req.maxTokens` when it is present. */\n chat(req: ChatRequest, opts?: ChatCallOpts): Promise<ChatResponse>\n}\n\nexport type ChatTransport =\n | 'sandbox-sdk' // box.streamPrompt() — chat completion via sandbox SDK\n | 'custom' // caller-adapted SDK or transport\n | 'openai-compatible' // caller-named /v1 endpoint, driven by this package\n | 'mock' // test-time injection\n\nexport interface ChatRequest extends Omit<LlmCallRequest, 'model'> {\n /** Optional — falls back to ChatClient.defaultModel. */\n model?: string\n}\n\nexport type ChatResponse = LlmCallResult\n\nexport interface ChatCallOpts {\n /** Cancel the in-flight request. */\n signal?: AbortSignal\n /** Hard USD ceiling for this single call (informational; the underlying transport may not enforce). */\n maxCostUsd?: number\n /** Correlation tag carried into request headers when the transport allows. */\n correlationId?: string\n /** Stable provider idempotency key for retries/redrives of one paid call. */\n idempotencyKey?: string\n}\n\n// ── Factory ─────────────────────────────────────────────────────────\n\nexport type CreateChatClientOpts =\n | SandboxSdkTransportOpts\n | CustomTransportOpts\n | OpenAiCompatibleTransportOpts\n | MockTransportOpts\n\ninterface BaseTransportOpts {\n defaultModel?: string\n /** Total provider attempts. Required for opaque transports used in capped runs. */\n maximumAttempts?: number\n}\n\n/**\n * Sandbox-SDK transport. The caller supplies a canonical chat function for an\n * already-configured Sandbox handle, so agent-eval does not import the SDK.\n */\nexport interface SandboxSdkTransportOpts extends BaseTransportOpts {\n transport: 'sandbox-sdk'\n chat: (req: ChatRequest, opts?: ChatCallOpts) => Promise<ChatResponse>\n}\n\n/** Caller-adapted SDK or transport returning the canonical ChatResponse shape. */\nexport interface CustomTransportOpts extends BaseTransportOpts {\n transport: 'custom'\n chat: (req: ChatRequest, opts?: ChatCallOpts) => Promise<ChatResponse>\n}\n\n/**\n * OpenAI-compatible HTTP transport: the caller names a `/v1` endpoint and\n * hands over a bearer, and this package drives `POST {baseUrl}/chat/completions`.\n *\n * Use this instead of hand-rolling a `custom` transport around `fetch`. The\n * result carries `servedModel` — the model id the provider echoed, verbatim —\n * which is the only field `assertServedModel` and `assertCrossFamilyServed`\n * can read to witness a gateway answering from a different model than the one\n * requested.\n *\n * `baseUrl` ends at the `/v1` prefix; the `/chat/completions` path is this\n * package's to append. A `baseUrl` that already carries the path is a\n * construction error, not a request to a doubled URL.\n *\n * Exactly one credential form is required — `apiKey`, `bearer`, or\n * `authHeader`. There is no environment fallback: agent-eval never goes\n * looking for a key.\n */\nexport interface OpenAiCompatibleTransportOpts\n extends BaseTransportOpts,\n Pick<\n LlmClientOptions,\n | 'assertServedModel'\n | 'customTokenPricing'\n | 'deadlineMs'\n | 'defaultTimeoutMs'\n | 'fetch'\n | 'jsonPayloadMode'\n | 'jsonSchemaTransport'\n | 'minIntervalMs'\n | 'provider'\n | 'rawSink'\n | 'signal'\n | 'thinking'\n > {\n transport: 'openai-compatible'\n /** Endpoint ending at the `/v1` prefix. Required — there is no default endpoint. */\n baseUrl: string\n /** Bearer credential. One of `apiKey`, `bearer`, or `authHeader` is required. */\n apiKey?: string\n /** Bearer credential, alternate spelling. */\n bearer?: string\n /** Non-bearer authorization header, for endpoints that want their own scheme. */\n authHeader?: { name: string; value: string }\n}\n\n/**\n * Mock transport for tests. The handler receives the request and returns\n * whatever the test wants. No retries, no JSON-schema degrade.\n */\nexport interface MockTransportOpts extends BaseTransportOpts {\n transport: 'mock'\n handler: (req: ChatRequest, opts?: ChatCallOpts) => Promise<ChatResponse>\n}\n\n/**\n * Build a ChatClient bound to a specific transport. The returned client\n * is safe to share across analysts in a single registry run.\n */\nexport function createChatClient(opts: CreateChatClientOpts): ChatClient {\n switch (opts.transport) {\n case 'sandbox-sdk':\n return {\n transport: 'sandbox-sdk',\n defaultModel: opts.defaultModel,\n maximumAttempts: opts.maximumAttempts,\n chat: async (req, callOpts) => opts.chat(resolveModel(req, opts.defaultModel), callOpts),\n }\n case 'custom':\n return {\n transport: 'custom',\n defaultModel: opts.defaultModel,\n maximumAttempts: opts.maximumAttempts,\n chat: async (req, callOpts) => opts.chat(resolveModel(req, opts.defaultModel), callOpts),\n }\n case 'openai-compatible':\n return openAiCompatibleClient(opts)\n case 'mock':\n return {\n transport: 'mock',\n defaultModel: opts.defaultModel,\n maximumAttempts: 1,\n chat: async (req, callOpts) => opts.handler(resolveModel(req, opts.defaultModel), callOpts),\n }\n }\n}\n\nfunction resolveModel(req: ChatRequest, defaultModel: string | undefined): ChatRequest {\n if (req.model) return req\n if (!defaultModel) {\n throw new Error(\n 'ChatClient.chat: no model on request and no defaultModel on the client. ' +\n 'Either pass req.model or bind defaultModel at createChatClient().',\n )\n }\n return { ...req, model: defaultModel }\n}\n\n/**\n * Build the OpenAI-compatible client, refusing a half-configured one first.\n *\n * Both refusals are construction-time on purpose. A missing credential or a\n * doubled path is a caller mistake that a request would turn into a 401 or a\n * 404 from an endpoint the caller did not intend to reach — the failure then\n * reads as a provider problem instead of a configuration one.\n */\nfunction openAiCompatibleClient(opts: OpenAiCompatibleTransportOpts): ChatClient {\n const baseUrl = opts.baseUrl?.trim().replace(/\\/+$/, '') ?? ''\n if (!baseUrl) {\n throw new Error(\n \"createChatClient({ transport: 'openai-compatible' }): baseUrl is required and has no default.\",\n )\n }\n if (/\\/chat\\/completions$/.test(baseUrl)) {\n throw new Error(\n \"createChatClient({ transport: 'openai-compatible' }): baseUrl ends at the /v1 prefix; \" +\n `this package appends /chat/completions. Got ${baseUrl}`,\n )\n }\n if (!opts.apiKey?.trim() && !opts.bearer?.trim() && !opts.authHeader) {\n throw new Error(\n \"createChatClient({ transport: 'openai-compatible' }): one of apiKey, bearer, or authHeader \" +\n 'is required. agent-eval reads no environment variable for a credential.',\n )\n }\n\n const clientOptions: LlmClientOptions = {\n baseUrl,\n ...(opts.apiKey ? { apiKey: opts.apiKey } : {}),\n ...(opts.bearer ? { bearer: opts.bearer } : {}),\n ...(opts.authHeader ? { authHeader: opts.authHeader } : {}),\n ...(opts.maximumAttempts === undefined ? {} : { maximumAttempts: opts.maximumAttempts }),\n ...(opts.assertServedModel === undefined ? {} : { assertServedModel: opts.assertServedModel }),\n ...(opts.customTokenPricing === undefined\n ? {}\n : { customTokenPricing: opts.customTokenPricing }),\n ...(opts.deadlineMs === undefined ? {} : { deadlineMs: opts.deadlineMs }),\n ...(opts.defaultTimeoutMs === undefined ? {} : { defaultTimeoutMs: opts.defaultTimeoutMs }),\n ...(opts.fetch === undefined ? {} : { fetch: opts.fetch }),\n ...(opts.jsonPayloadMode === undefined ? {} : { jsonPayloadMode: opts.jsonPayloadMode }),\n ...(opts.jsonSchemaTransport === undefined\n ? {}\n : { jsonSchemaTransport: opts.jsonSchemaTransport }),\n ...(opts.minIntervalMs === undefined ? {} : { minIntervalMs: opts.minIntervalMs }),\n ...(opts.provider === undefined ? {} : { provider: opts.provider }),\n ...(opts.rawSink === undefined ? {} : { rawSink: opts.rawSink }),\n ...(opts.signal === undefined ? {} : { signal: opts.signal }),\n ...(opts.thinking === undefined ? {} : { thinking: opts.thinking }),\n }\n const client = new LlmClient(clientOptions)\n\n return {\n transport: 'openai-compatible',\n ...(opts.defaultModel ? { defaultModel: opts.defaultModel } : {}),\n maximumAttempts: client.maximumAttempts,\n chat: async (req, callOpts) => {\n const resolved = resolveModel(req, opts.defaultModel)\n return client.call(resolved as LlmCallRequest, {\n ...(callOpts?.signal ? { signal: callOpts.signal } : {}),\n ...(callOpts?.idempotencyKey ? { idempotencyKey: callOpts.idempotencyKey } : {}),\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqKA,SAAgB,iBAAiB,MAAwC;CACvE,QAAQ,KAAK,WAAb;EACE,KAAK,eACH,OAAO;GACL,WAAW;GACX,cAAc,KAAK;GACnB,iBAAiB,KAAK;GACtB,MAAM,OAAO,KAAK,aAAa,KAAK,KAAK,aAAa,KAAK,KAAK,YAAY,GAAG,QAAQ;EACzF;EACF,KAAK,UACH,OAAO;GACL,WAAW;GACX,cAAc,KAAK;GACnB,iBAAiB,KAAK;GACtB,MAAM,OAAO,KAAK,aAAa,KAAK,KAAK,aAAa,KAAK,KAAK,YAAY,GAAG,QAAQ;EACzF;EACF,KAAK,qBACH,OAAO,uBAAuB,IAAI;EACpC,KAAK,QACH,OAAO;GACL,WAAW;G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;EACzF,GAAI,KAAK,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM;EACxD,GAAI,KAAK,oBAAoB,KAAA,IAAY,CAAC,IAAI,EAAE,iBAAiB,KAAK,gBAAgB;EACtF,GAAI,KAAK,wBAAwB,KAAA,IAC7B,CAAC,IACD,EAAE,qBAAqB,KAAK,oBAAoB;EACpD,GAAI,KAAK,kBAAkB,KAAA,IAAY,CAAC,IAAI,EAAE,eAAe,KAAK,cAAc;EAChF,GAAI,KAAK,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,KAAK,SAAS;EACjE,GAAI,KAAK,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,KAAK,QAAQ;EAC9D,GAAI,KAAK,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO;EAC3D,GAAI,KAAK,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,KAAK,SAAS;CACnE;CACA,MAAM,SAAS,IAAI,UAAU,aAAa;CAE1C,OAAO;EACL,WAAW;EACX,GAAI,KAAK,eAAe,EAAE,cAAc,KAAK,aAAa,IAAI,CAAC;EAC/D,iBAAiB,OAAO;EACxB,MAAM,OAAO,KAAK,aAAa;GAC7B,MAAM,WAAW,aAAa,KAAK,KAAK,YAAY;GACpD,OAAO,OAAO,KAAK,UAA4B;IAC7C,GAAI,UAAU,SAAS,EAAE,QAAQ,SAAS,OAAO,IAAI,CAAC;IACtD,GAAI,UAAU,iBAAiB,EAAE,gBAAgB,SAAS,eAAe,IAAI,CAAC;GAChF,CAAC;EACH;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { c as extractJsonPayload, o as costReceiptFromLlm, s as costReceiptFromLlmError, u as maximumChargeForLlmRequest } from "./llm-client-C_o62yG1.js";
1
+ import { c as extractJsonPayload, o as costReceiptFromLlm, s as costReceiptFromLlmError, u as maximumChargeForLlmRequest } from "./llm-client-DQveoxSM.js";
2
2
  //#region src/chat-json-call.ts
3
3
  /** Parse a JSON answer out of a model response. The transport may fence it. */
4
4
  function parseJsonAnswer(response, actor) {
@@ -60,4 +60,4 @@ async function paidJsonChat(input) {
60
60
  //#endregion
61
61
  export { paidJsonChat as n, paidChat as t };
62
62
 
63
- //# sourceMappingURL=chat-json-call-CZI1NoGZ.js.map
63
+ //# sourceMappingURL=chat-json-call-BrKsyspg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chat-json-call-CZI1NoGZ.js","names":[],"sources":["../src/chat-json-call.ts"],"sourcesContent":["/**\n * One paid model call through a caller-owned `ChatClient`, metered by the\n * cost ledger.\n *\n * agent-eval executes no paid model: the transport is supplied by the caller\n * and the credential never enters this package. What stays here is the\n * accounting around the call — the priced maximum reserved before it runs, the\n * stable call id forwarded as the provider idempotency key, the receipt\n * settled from the response, and an honest unknown-usage receipt when the\n * transport failed.\n *\n * The judges, the wire judge endpoint, and the in-process trace-analysis\n * engine all make the same call in the same order; this is the one copy of\n * that sequence. `paidChat` is the sequence; `paidJsonChat` adds the JSON\n * answer parse that a structured caller needs.\n */\n\nimport type { ChatClient, ChatResponse } from './analyst/chat-client'\nimport type { CostChannel, CostLedgerHandle, CostReceipt, CustomTokenPricing } from './cost-ledger'\nimport {\n costReceiptFromLlm,\n costReceiptFromLlmError,\n extractJsonPayload,\n type LlmCallRequest,\n maximumChargeForLlmRequest,\n} from './llm-client'\n\nexport interface PaidChatInput {\n /** Caller-owned transport. One `chat()` call. */\n chat: ChatClient\n /** The exact canonical request, including its JSON-mode or schema fields. */\n request: LlmCallRequest\n ledger: CostLedgerHandle\n channel: CostChannel\n phase: string\n actor: string\n tags?: Record<string, string>\n signal?: AbortSignal\n /** Endpoint rates used when the transport reports no billed amount. */\n pricing?: CustomTokenPricing\n}\n\nexport type PaidJsonChatInput = PaidChatInput\n\nexport type PaidChatResult =\n | { succeeded: true; response: ChatResponse; receipt: CostReceipt }\n | { succeeded: false; error: Error; receipt?: CostReceipt }\n\nexport type PaidJsonChatResult<T> =\n | { succeeded: true; value: T; response: ChatResponse; receipt: CostReceipt }\n | { succeeded: false; error: Error; receipt?: CostReceipt }\n\n/** Parse a JSON answer out of a model response. The transport may fence it. */\nfunction parseJsonAnswer<T>(response: ChatResponse, actor: string): T {\n try {\n return JSON.parse(extractJsonPayload(response.content)) as T\n } catch (error) {\n throw new Error(\n `${actor}: model answer was not JSON — ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n}\n\n/** Reserve, execute, and settle one caller-owned chat call. */\nexport async function paidChat(input: PaidChatInput): Promise<PaidChatResult> {\n const paid = await input.ledger.runPaidCall({\n channel: input.channel,\n phase: input.phase,\n actor: input.actor,\n model: input.request.model,\n ...(input.tags && Object.keys(input.tags).length > 0 ? { tags: input.tags } : {}),\n maximumCharge: maximumChargeForLlmRequest(input.request, {\n ...(input.chat.maximumAttempts === undefined\n ? {}\n : { maximumAttempts: input.chat.maximumAttempts }),\n ...(input.pricing ? { customTokenPricing: input.pricing } : {}),\n }),\n ...(input.signal ? { signal: input.signal } : {}),\n execute: (signal, callId) => input.chat.chat(input.request, { signal, idempotencyKey: callId }),\n receipt: (response) => costReceiptFromLlm(response, input.pricing),\n receiptFromError: (error) => costReceiptFromLlmError(error, input.pricing),\n })\n if (!paid.succeeded) {\n return {\n succeeded: false,\n error: paid.error,\n ...(paid.receipt ? { receipt: paid.receipt } : {}),\n }\n }\n return { succeeded: true, response: paid.value, receipt: paid.receipt }\n}\n\nexport async function paidJsonChat<T>(input: PaidJsonChatInput): Promise<PaidJsonChatResult<T>> {\n const paid = await paidChat(input)\n if (!paid.succeeded) return paid\n // The call completed and was billed. A malformed answer is a contract\n // failure AFTER the money was spent, so it keeps the settled receipt instead\n // of reporting the spend as unknown.\n try {\n return {\n succeeded: true,\n value: parseJsonAnswer<T>(paid.response, input.actor),\n response: paid.response,\n receipt: paid.receipt,\n }\n } catch (error) {\n return {\n succeeded: false,\n error: error instanceof Error ? error : new Error(String(error)),\n receipt: paid.receipt,\n }\n }\n}\n"],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AW,OAAO;CAI5B,IAAI;EACF,OAAO;GACL,WAAW;GACX,OAAO,gBAAmB,KAAK,UAAU,MAAM,KAAK;GACpD,UAAU,KAAK;GACf,SAAS,KAAK;EAChB;CACF,SAAS,OAAO;EACd,OAAO;GACL,WAAW;GACX,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;GAC/D,SAAS,KAAK;EAChB;CACF;AACF"}
1
+ {"version":3,"file":"chat-json-call-BrKsyspg.js","names":[],"sources":["../src/chat-json-call.ts"],"sourcesContent":["/**\n * One paid model call through a caller-owned `ChatClient`, metered by the\n * cost ledger.\n *\n * agent-eval executes no paid model: the transport is supplied by the caller\n * and the credential never enters this package. What stays here is the\n * accounting around the call — the priced maximum reserved before it runs, the\n * stable call id forwarded as the provider idempotency key, the receipt\n * settled from the response, and an honest unknown-usage receipt when the\n * transport failed.\n *\n * The judges, the wire judge endpoint, and the in-process trace-analysis\n * engine all make the same call in the same order; this is the one copy of\n * that sequence. `paidChat` is the sequence; `paidJsonChat` adds the JSON\n * answer parse that a structured caller needs.\n */\n\nimport type { ChatClient, ChatResponse } from './analyst/chat-client'\nimport type { CostChannel, CostLedgerHandle, CostReceipt, CustomTokenPricing } from './cost-ledger'\nimport {\n costReceiptFromLlm,\n costReceiptFromLlmError,\n extractJsonPayload,\n type LlmCallRequest,\n maximumChargeForLlmRequest,\n} from './llm-client'\n\nexport interface PaidChatInput {\n /** Caller-owned transport. One `chat()` call. */\n chat: ChatClient\n /** The exact canonical request, including its JSON-mode or schema fields. */\n request: LlmCallRequest\n ledger: CostLedgerHandle\n channel: CostChannel\n phase: string\n actor: string\n tags?: Record<string, string>\n signal?: AbortSignal\n /** Endpoint rates used when the transport reports no billed amount. */\n pricing?: CustomTokenPricing\n}\n\nexport type PaidJsonChatInput = PaidChatInput\n\nexport type PaidChatResult =\n | { succeeded: true; response: ChatResponse; receipt: CostReceipt }\n | { succeeded: false; error: Error; receipt?: CostReceipt }\n\nexport type PaidJsonChatResult<T> =\n | { succeeded: true; value: T; response: ChatResponse; receipt: CostReceipt }\n | { succeeded: false; error: Error; receipt?: CostReceipt }\n\n/** Parse a JSON answer out of a model response. The transport may fence it. */\nfunction parseJsonAnswer<T>(response: ChatResponse, actor: string): T {\n try {\n return JSON.parse(extractJsonPayload(response.content)) as T\n } catch (error) {\n throw new Error(\n `${actor}: model answer was not JSON — ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n}\n\n/** Reserve, execute, and settle one caller-owned chat call. */\nexport async function paidChat(input: PaidChatInput): Promise<PaidChatResult> {\n const paid = await input.ledger.runPaidCall({\n channel: input.channel,\n phase: input.phase,\n actor: input.actor,\n model: input.request.model,\n ...(input.tags && Object.keys(input.tags).length > 0 ? { tags: input.tags } : {}),\n maximumCharge: maximumChargeForLlmRequest(input.request, {\n ...(input.chat.maximumAttempts === undefined\n ? {}\n : { maximumAttempts: input.chat.maximumAttempts }),\n ...(input.pricing ? { customTokenPricing: input.pricing } : {}),\n }),\n ...(input.signal ? { signal: input.signal } : {}),\n execute: (signal, callId) => input.chat.chat(input.request, { signal, idempotencyKey: callId }),\n receipt: (response) => costReceiptFromLlm(response, input.pricing),\n receiptFromError: (error) => costReceiptFromLlmError(error, input.pricing),\n })\n if (!paid.succeeded) {\n return {\n succeeded: false,\n error: paid.error,\n ...(paid.receipt ? { receipt: paid.receipt } : {}),\n }\n }\n return { succeeded: true, response: paid.value, receipt: paid.receipt }\n}\n\nexport async function paidJsonChat<T>(input: PaidJsonChatInput): Promise<PaidJsonChatResult<T>> {\n const paid = await paidChat(input)\n if (!paid.succeeded) return paid\n // The call completed and was billed. A malformed answer is a contract\n // failure AFTER the money was spent, so it keeps the settled receipt instead\n // of reporting the spend as unknown.\n try {\n return {\n succeeded: true,\n value: parseJsonAnswer<T>(paid.response, input.actor),\n response: paid.response,\n receipt: paid.receipt,\n }\n } catch (error) {\n return {\n succeeded: false,\n error: error instanceof Error ? error : new Error(String(error)),\n receipt: paid.receipt,\n }\n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,KAAK,WAAW,OAAO;CAI5B,IAAI;EACF,OAAO;GACL,WAAW;GACX,OAAO,gBAAmB,KAAK,UAAU,MAAM,KAAK;GACpD,UAAU,KAAK;GACf,SAAS,KAAK;EAChB;CACF,SAAS,OAAO;EACd,OAAO;GACL,WAAW;GACX,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;GAC/D,SAAS,KAAK;EAChB;CACF;AACF"}
package/dist/cli.js CHANGED
@@ -4,11 +4,11 @@ import { i as replaySearchLedgerText } from "./search-ledger-d7V8o9Lk.js";
4
4
  import { t as renderSearchSummary } from "./search-summary-CBvz3u_S.js";
5
5
  import { c as hostedTenantFromEnv, g as SearchRunKindSchema, r as shipSearchLedger, t as SearchShipConflictError, u as SEARCH_LEDGER_BATCH_MAX_BYTES } from "./search-shipper-er4pK5_Y.js";
6
6
  import { i as runRolloutReleaseCli } from "./hf-dataset-BR2yhuNn.js";
7
- import { t as createChatClient } from "./chat-client-Bnx8NZe4.js";
8
- import { t as runAnalystBenchmarkCommand } from "./benchmark-command-CMmeV-_Z.js";
9
- import { a as runRpcBatch, o as runRpcOnce, p as handleVersion, r as startServerAsync, s as buildOpenApi } from "./server-BRpadnVt.js";
7
+ import { t as createChatClient } from "./chat-client-DthPOYGd.js";
8
+ import { t as runAnalystBenchmarkCommand } from "./benchmark-command-CByl9dxG.js";
9
+ import { a as runRpcBatch, o as runRpcOnce, p as handleVersion, r as startServerAsync, s as buildOpenApi } from "./server-DbcC7xMl.js";
10
10
  import { C as editCredit, S as front, _ as surfaceTextEdits, c as metaSearch, d as renderMetaSearchText, m as landscape, n as taskMatrix, o as skillManifold, p as formatLandscape, r as formatSkillManifold, t as tree, w as editCreditText } from "./tree-rXLW3M_4.js";
11
- import { t as runSupervisorRunCommand } from "./report-command-CtIIsQKP.js";
11
+ import { t as runSupervisorRunCommand } from "./report-command-y8H6RSX8.js";
12
12
  import { createHash } from "node:crypto";
13
13
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
14
14
  import { dirname, join } from "node:path";
@@ -0,0 +1,66 @@
1
+ import { s as ValidationError } from "./errors-Dngq5h35.js";
2
+ import { i as makeRng } from "./internal-CRHwS9iz.js";
3
+ //#region src/meta-eval/cluster-bootstrap.ts
4
+ /**
5
+ * Percentile cluster bootstrap of an observation mean. Whole clusters are resampled with
6
+ * replacement and each resample's statistic is Σ values / Σ observations over the drawn
7
+ * clusters, so observations that share a source move together and a large cluster cannot
8
+ * pose as many independent results. For a paired comparison pass the per-observation
9
+ * difference (candidate − baseline) under the observation's cluster.
10
+ *
11
+ * With one cluster the interval collapses to the point estimate: there is no between-cluster
12
+ * spread to measure, which callers must treat as no interval, not as certainty.
13
+ */
14
+ function clusterBootstrapMean(observations, options = {}) {
15
+ const confidence = options.confidence ?? .95;
16
+ const resamples = options.resamples ?? 2e3;
17
+ if (!(confidence > 0 && confidence < 1)) throw new ValidationError(`clusterBootstrapMean: confidence must be in (0,1), got ${confidence}`);
18
+ if (!Number.isInteger(resamples) || resamples < 1) throw new ValidationError(`clusterBootstrapMean: resamples must be a positive integer, got ${resamples}`);
19
+ if (!observations.length) throw new ValidationError("clusterBootstrapMean: requires at least one observation");
20
+ const sums = /* @__PURE__ */ new Map();
21
+ const values = [];
22
+ for (const [index, observation] of observations.entries()) {
23
+ if (typeof observation?.cluster !== "string" || observation.cluster === "") throw new ValidationError(`clusterBootstrapMean: observation ${index} needs a cluster id`);
24
+ if (!Number.isFinite(observation.value)) throw new ValidationError(`clusterBootstrapMean: observation ${index} value must be finite`);
25
+ const cell = sums.get(observation.cluster) ?? {
26
+ sum: 0,
27
+ count: 0
28
+ };
29
+ cell.sum += observation.value;
30
+ cell.count += 1;
31
+ sums.set(observation.cluster, cell);
32
+ values.push(observation.value);
33
+ }
34
+ const cells = [...sums.values()];
35
+ const mean = cells.reduce((acc, cell) => acc + cell.sum, 0) / observations.length;
36
+ const k = cells.length;
37
+ const rng = makeRng(options.seed, values);
38
+ const samples = new Array(resamples);
39
+ for (let b = 0; b < resamples; b++) {
40
+ let sum = 0;
41
+ let count = 0;
42
+ for (let draw = 0; draw < k; draw++) {
43
+ const cell = cells[Math.floor(rng() * k)];
44
+ sum += cell.sum;
45
+ count += cell.count;
46
+ }
47
+ samples[b] = sum / count;
48
+ }
49
+ samples.sort((a, b) => a - b);
50
+ const alpha = 1 - confidence;
51
+ const lowIdx = Math.floor(alpha / 2 * resamples);
52
+ const highIdx = Math.min(resamples - 1, Math.ceil((1 - alpha / 2) * resamples) - 1);
53
+ return {
54
+ n: observations.length,
55
+ clusters: k,
56
+ mean,
57
+ low: samples[lowIdx],
58
+ high: samples[Math.max(highIdx, lowIdx)],
59
+ confidence,
60
+ resamples
61
+ };
62
+ }
63
+ //#endregion
64
+ export { clusterBootstrapMean as t };
65
+
66
+ //# sourceMappingURL=cluster-bootstrap-B3JywQQn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cluster-bootstrap-B3JywQQn.js","names":[],"sources":["../src/meta-eval/cluster-bootstrap.ts"],"sourcesContent":["import { ValidationError } from '../errors'\nimport { makeRng } from '../statistics/internal'\n\n/** One observation and the source cluster it belongs to. */\nexport interface ClusteredObservation {\n cluster: string\n value: number\n}\n\nexport interface ClusterBootstrapOptions {\n /** Confidence level. Default 0.95. */\n confidence?: number\n /** Bootstrap resample count. Default 2000. */\n resamples?: number\n /** Deterministic seed. If omitted, derived from the values so the interval is reproducible. */\n seed?: number\n}\n\nexport interface ClusterBootstrapResult {\n n: number\n clusters: number\n /** Mean over observations, each observation weighted equally. */\n mean: number\n low: number\n high: number\n confidence: number\n resamples: number\n}\n\n/**\n * Percentile cluster bootstrap of an observation mean. Whole clusters are resampled with\n * replacement and each resample's statistic is Σ values / Σ observations over the drawn\n * clusters, so observations that share a source move together and a large cluster cannot\n * pose as many independent results. For a paired comparison pass the per-observation\n * difference (candidate − baseline) under the observation's cluster.\n *\n * With one cluster the interval collapses to the point estimate: there is no between-cluster\n * spread to measure, which callers must treat as no interval, not as certainty.\n */\nexport function clusterBootstrapMean(\n observations: readonly ClusteredObservation[],\n options: ClusterBootstrapOptions = {},\n): ClusterBootstrapResult {\n const confidence = options.confidence ?? 0.95\n const resamples = options.resamples ?? 2000\n if (!(confidence > 0 && confidence < 1)) {\n throw new ValidationError(\n `clusterBootstrapMean: confidence must be in (0,1), got ${confidence}`,\n )\n }\n if (!Number.isInteger(resamples) || resamples < 1) {\n throw new ValidationError(\n `clusterBootstrapMean: resamples must be a positive integer, got ${resamples}`,\n )\n }\n if (!observations.length) {\n throw new ValidationError('clusterBootstrapMean: requires at least one observation')\n }\n\n const sums = new Map<string, { sum: number; count: number }>()\n const values: number[] = []\n for (const [index, observation] of observations.entries()) {\n if (typeof observation?.cluster !== 'string' || observation.cluster === '') {\n throw new ValidationError(`clusterBootstrapMean: observation ${index} needs a cluster id`)\n }\n if (!Number.isFinite(observation.value)) {\n throw new ValidationError(`clusterBootstrapMean: observation ${index} value must be finite`)\n }\n const cell = sums.get(observation.cluster) ?? { sum: 0, count: 0 }\n cell.sum += observation.value\n cell.count += 1\n sums.set(observation.cluster, cell)\n values.push(observation.value)\n }\n\n const cells = [...sums.values()]\n const total = cells.reduce((acc, cell) => acc + cell.sum, 0)\n const mean = total / observations.length\n const k = cells.length\n const rng = makeRng(options.seed, values)\n const samples = new Array<number>(resamples)\n for (let b = 0; b < resamples; b++) {\n let sum = 0\n let count = 0\n for (let draw = 0; draw < k; draw++) {\n const cell = cells[Math.floor(rng() * k)]!\n sum += cell.sum\n count += cell.count\n }\n samples[b] = sum / count\n }\n samples.sort((a, b) => a - b)\n const alpha = 1 - confidence\n const lowIdx = Math.floor((alpha / 2) * resamples)\n const highIdx = Math.min(resamples - 1, Math.ceil((1 - alpha / 2) * resamples) - 1)\n return {\n n: observations.length,\n clusters: k,\n mean,\n low: samples[lowIdx]!,\n high: samples[Math.max(highIdx, lowIdx)]!,\n confidence,\n resamples,\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAuCA,SAAgB,qBACd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AAC;GACvC,OAAO,KAAK;GACZ,SAAS,KAAK;EAChB;EACA,QAAQ,KAAK,MAAM;CACrB;CACA,QAAQ,MAAM,GAAG,MAAM,IAAI,CAAC;CAC5B,MAAM,QAAQ,IAAI;CAClB,MAAM,SAAS,KAAK,MAAO,QAAQ,IAAK,SAAS;CACjD,MAAM,UAAU,KAAK,IAAI,YAAY,GAAG,KAAK,MAAM,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC;CAClF,OAAO;EACL,GAAG,aAAa;EAChB,UAAU;EACV;EACA,KAAK,QAAQ;EACb,MAAM,QAAQ,KAAK,IAAI,SAAS,MAAM;EACtC;EACA;CACF;AACF"}
@@ -1,14 +1,14 @@
1
- import { c as CostLedgerHandle } from "../cost-ledger-DbQdN3nO.js";
2
- import { _ as ProposalFinding, i as AnalystFinding, v as ProposalFindingOrigin, x as makeProposalFinding } from "../types-KEkKkETv.js";
3
- import { A as createChatClient, T as CreateChatClientOpts, x as ChatClient } from "../types-Lub7o6bN.js";
4
- import { $ as paretoSignificanceGate, G as BuildEvidenceVectorOptions, J as ParetoSignificanceGateOptions, K as EvidenceVector, Q as paretoPolicy, U as AxisEvidence, W as AxisVerdict, X as PromotionPolicy, Y as PromotionObjective, Z as buildEvidenceVector, q as ObjectiveSource } from "../statistical-heldout-DZaTo3gZ.js";
5
- import { C as JudgeDimension, H as SurfaceProposer, M as OptimizerConfig, R as Scenario, S as JudgeConfig, V as SessionScript, _ as GateDecision, a as CampaignResult, b as GenerationRecord, c as CampaignTraceWriter, d as DispatchContext, f as DispatchFn, g as GateContribution, h as GateContext, i as CampaignCostMeter, j as MutableSurface, l as CodeSurface, m as GateCheckStatus, n as CampaignArtifactWriter, p as Gate, r as CampaignCellResult, t as CampaignAggregates, v as GateResult, w as JudgeScore, y as GenerationCandidate } from "../types-CMnPcbW5.js";
6
- import { $i as RunImprovementLoopOptions, $r as GepaOptimizationRecipe, Bi as ReferenceEquivalenceJudgeInput, Ci as compareOptimizationMethods, Dr as DefaultProductionGateOptions, Er as DefaultProductionGateCheck, Fa as campaignSplitDigest, Gi as runReferenceEquivalenceJudge, Gr as SkillOptOptimizationMethodConfig, Hi as ReferenceEquivalenceJudgeResult, Ji as llmJudge, Jr as skillOptOptimizationMethod, Ki as LlmJudgeDimension, Kr as SkillOptRunnerCommand, Oa as FinalEvidencePolicy, Or as DefaultProductionRewardHackingOptions, Qi as transientDispatchFailure, Qr as GepaOptimizationMethodConfig, Ri as REFERENCE_EQUIVALENCE_INPUT_LIMITS, Si as OptimizationTokenUsage, Ti as ComparisonCost, Tr as heldOutGate, Ui as ReferenceEquivalenceScenario, Vi as ReferenceEquivalenceJudgeOptions, Wi as createReferenceEquivalenceJudge, Wr as composeGate, Xr as GepaEngineOptions, Yr as GepaAdaptiveEngineRun, Zr as GepaEngineRun, _a as runCampaign, _i as OptimizationMethodProvenance, ai as ExternalTextOptimizationMethodConfig, ci as ExternalOptimizationExample, di as CompareOptimizationMethodsOptions, ea as RunImprovementLoopResult, ei as GepaRunnerCommand, fa as RunEvalOptions, fi as OptimizationMethod, ga as RunCampaignOptions, ha as CampaignCellRetryPolicy, hi as OptimizationMethodInput, ii as externalTextOptimizationMethod, ka as FinalEvidenceUse, kr as defaultProductionGate, li as ExternalTextEvaluationResponse, ma as CampaignCellFailureReceipt, ni as OpenAICompatibleOptimizerModel, oi as ExternalTextOptimizerContext, pa as runEval, pi as OptimizationMethodComparison, qi as LlmJudgeOptions, qr as SkillOptTrainerConfig, ri as OptimizerModelBudget, si as ExternalTextOptimizerResult, ta as runImprovementLoop, ti as gepaOptimizationMethod, vi as OptimizationMethodResult, wr as HeldOutGateOptions, xi as OptimizationPackageSource, zi as REFERENCE_EQUIVALENCE_JUDGE_VERSION } from "../index-D_rfXep9.js";
7
- import { $t as fsCampaignStorage, Zt as CampaignStorage, en as inMemoryCampaignStorage } from "../search-kernel-BWp7hfJn.js";
1
+ import { c as CostLedgerHandle } from "../cost-ledger-CO7UyEcQ.js";
2
+ import { a as AnalystFinding, b as ProposalFinding, w as makeProposalFinding, x as ProposalFindingOrigin } from "../types-oKRhQAde.js";
3
+ import { A as createChatClient, T as CreateChatClientOpts, x as ChatClient } from "../types-DBZ7keha.js";
4
+ import { $ as paretoSignificanceGate, G as BuildEvidenceVectorOptions, J as ParetoSignificanceGateOptions, K as EvidenceVector, Q as paretoPolicy, U as AxisEvidence, W as AxisVerdict, X as PromotionPolicy, Y as PromotionObjective, Z as buildEvidenceVector, q as ObjectiveSource } from "../statistical-heldout-BeR4bOdg.js";
5
+ import { C as JudgeDimension, H as SurfaceProposer, M as OptimizerConfig, R as Scenario, S as JudgeConfig, V as SessionScript, _ as GateDecision, a as CampaignResult, b as GenerationRecord, c as CampaignTraceWriter, d as DispatchContext, f as DispatchFn, g as GateContribution, h as GateContext, i as CampaignCostMeter, j as MutableSurface, l as CodeSurface, m as GateCheckStatus, n as CampaignArtifactWriter, p as Gate, r as CampaignCellResult, t as CampaignAggregates, v as GateResult, w as JudgeScore, y as GenerationCandidate } from "../types-B4C5nFw6.js";
6
+ import { $i as RunImprovementLoopOptions, $r as GepaOptimizationRecipe, Bi as ReferenceEquivalenceJudgeInput, Ci as compareOptimizationMethods, Dr as DefaultProductionGateOptions, Er as DefaultProductionGateCheck, Fa as campaignSplitDigest, Gi as runReferenceEquivalenceJudge, Gr as SkillOptOptimizationMethodConfig, Hi as ReferenceEquivalenceJudgeResult, Ji as llmJudge, Jr as skillOptOptimizationMethod, Ki as LlmJudgeDimension, Kr as SkillOptRunnerCommand, Oa as FinalEvidencePolicy, Or as DefaultProductionRewardHackingOptions, Qi as transientDispatchFailure, Qr as GepaOptimizationMethodConfig, Ri as REFERENCE_EQUIVALENCE_INPUT_LIMITS, Si as OptimizationTokenUsage, Ti as ComparisonCost, Tr as heldOutGate, Ui as ReferenceEquivalenceScenario, Vi as ReferenceEquivalenceJudgeOptions, Wi as createReferenceEquivalenceJudge, Wr as composeGate, Xr as GepaEngineOptions, Yr as GepaAdaptiveEngineRun, Zr as GepaEngineRun, _a as runCampaign, _i as OptimizationMethodProvenance, ai as ExternalTextOptimizationMethodConfig, ci as ExternalOptimizationExample, di as CompareOptimizationMethodsOptions, ea as RunImprovementLoopResult, ei as GepaRunnerCommand, fa as RunEvalOptions, fi as OptimizationMethod, ga as RunCampaignOptions, ha as CampaignCellRetryPolicy, hi as OptimizationMethodInput, ii as externalTextOptimizationMethod, ka as FinalEvidenceUse, kr as defaultProductionGate, li as ExternalTextEvaluationResponse, ma as CampaignCellFailureReceipt, ni as OpenAICompatibleOptimizerModel, oi as ExternalTextOptimizerContext, pa as runEval, pi as OptimizationMethodComparison, qi as LlmJudgeOptions, qr as SkillOptTrainerConfig, ri as OptimizerModelBudget, si as ExternalTextOptimizerResult, ta as runImprovementLoop, ti as gepaOptimizationMethod, vi as OptimizationMethodResult, wr as HeldOutGateOptions, xi as OptimizationPackageSource, zi as REFERENCE_EQUIVALENCE_JUDGE_VERSION } from "../index-NvGBiO8H.js";
7
+ import { $t as fsCampaignStorage, Zt as CampaignStorage, en as inMemoryCampaignStorage } from "../search-kernel-CpcKH5Ih.js";
8
8
  import { i as InMemoryOutcomeStore, n as FileSystemOutcomeStore, o as OutcomeStore, r as FileSystemOutcomeStoreOptions, t as DeploymentOutcome } from "../outcome-store-CNt4iZ67.js";
9
9
  import { r as HostedTenant } from "../client-BzL9niqi.js";
10
- import { _ as ReleaseSummary, a as summarizeExecution, c as ExecutionInsight, d as InsightReport, f as InterRaterInsight, g as Recommendation, h as OutcomeCorrelationInsight, i as analyzeRuns, l as FailureClassTally, m as LiftInsight, n as ExecutionReport, o as CostProvenanceSummary, p as JudgeInsight, r as SummarizeExecutionOptions, s as ExecutionErrorOutcomeCell, t as AnalyzeRunsOptions, u as FailureClusterInsight, v as ScalarDistribution, y as TokenUsageInsight } from "../analyze-runs-BlslTkOJ.js";
11
- import { _ as SelfImproveMethodResult, a as DefinedAgentEval, c as SelfImproveMethodOptions, d as SelfImproveProposerOptions, f as SelfImproveProposerResult, g as SelfImproveMethodProvenance, h as selfImprove, i as DefineAgentEvalOptions, l as SelfImproveOptions, m as SelfImproveRunError, n as AgentEvalEvaluateOptions, o as defineAgentEval, p as SelfImproveResult, r as AgentEvalImproveOptions, s as SelfImproveBudget, t as AgentEvalAgent, u as SelfImproveProgressEvent } from "../define-agent-eval-CZdBPUkk.js";
12
- import { $ as FromRunRecordDirOptions, A as CodeAgentSessionActionKind, At as verifyCandidateExperimentComparison, B as AgentTraceConversation, C as fromOpenCodeSession, Ct as evaluatePairedMeasurements, D as parseCodeAgentJsonlFile, Dt as sealCandidateBenchmarkTask, E as parseCodeAgentJsonl, Et as sealCandidateBenchmarkSuite, F as CodeAgentSessionSource, G as AuthoringProvenance, H as AgentTraceIndex, I as CodeAgentSessionTerminalStatus, J as partitionRunsByAuthoringModel, K as PartitionByAuthoringModelResult, L as observeCodeAgentSession, M as CodeAgentSessionActionSurface, N as CodeAgentSessionExecutionReceipt, O as streamCodeAgentJsonlFile, Ot as sealCandidateExperiment, P as CodeAgentSessionObservation, Q as evalReportingSuite, R as AgentTraceContributor, S as fromKimiCodeSession, St as SealCandidateBenchmarkSuiteOptions, T as fromPiSession, Tt as runCandidateExperiment, U as AgentTraceRange, V as AgentTraceFile, W as AgentTraceRecord, X as EvalReportingSuiteOptions, Y as EvalReportingSuiteInput, Z as EvalReportingSuiteResult, _ as CodeAgentSessionIntakeResult, _t as EvaluatePairedMeasurementsOptions, a as FromFeedbackTableOptions, at as CompareAgentProfileImprovementExperimentOptions, b as fromClaudeCodeSession, bt as PairedMeasurementEvaluation, c as CodeAgentStoreObservation, ct as measuredComparisonFromAgentProfileImprovementExperiment, d as CodeAgentStoreScope, dt as sealAgentProfileImprovementSuite, et as FromRunRecordDirResult, f as CodeAgentStoreSession, ft as sealAgentProfileImprovementTask, g as CodeAgentSessionIntakeOptions, gt as CompareCandidateExperimentOptions, h as CodeAgentSessionDiagnostic, ht as CandidateExperimentRun, i as FeedbackTableRow, it as AgentProfileImprovementExperimentRun, j as CodeAgentSessionActionStatus, k as CodeAgentSessionAction, kt as verifyCandidateExperiment, l as CodeAgentStoreRejection, lt as runAgentProfileImprovementExperiment, m as CodeAgentJsonlLine, mt as CandidateExperimentExecutionInput, n as fromOtelSpans, nt as fromRunRecordDir, o as FromFeedbackTableResult, ot as RunAgentProfileImprovementExperimentOptions, p as observeCodeAgentStore, pt as verifyAgentProfileImprovementExperimentComparison, q as parseAgentTrace, r as FeedbackTableMeta, rt as AgentProfileImprovementExperimentExecutionInput, s as fromFeedbackTable, st as SealAgentProfileImprovementSuiteOptions, t as FromOtelSpansOptions, tt as RunRecordRejection, u as CodeAgentStoreRejections, ut as sealAgentProfileImprovementExperiment, v as CodeAgentSessionMetrics, vt as PairedMeasurement, w as fromPiGraphSession, wt as measuredComparisonFromCandidateExperiment, x as fromCodexSession, xt as RunCandidateExperimentOptions, y as ParsedCodeAgentJsonl, yt as PairedMeasurementAdapter, z as AgentTraceContributorType } from "../index-BTwxP7L0.js";
13
- import { n as buildDefaultAnalystRegistry, t as DefaultAnalystRegistryOptions } from "../default-registry-BAiTePcB.js";
10
+ import { _ as ReleaseSummary, a as summarizeExecution, c as ExecutionInsight, d as InsightReport, f as InterRaterInsight, g as Recommendation, h as OutcomeCorrelationInsight, i as analyzeRuns, l as FailureClassTally, m as LiftInsight, n as ExecutionReport, o as CostProvenanceSummary, p as JudgeInsight, r as SummarizeExecutionOptions, s as ExecutionErrorOutcomeCell, t as AnalyzeRunsOptions, u as FailureClusterInsight, v as ScalarDistribution, y as TokenUsageInsight } from "../analyze-runs-CSDAh8A7.js";
11
+ import { _ as SelfImproveMethodResult, a as DefinedAgentEval, c as SelfImproveMethodOptions, d as SelfImproveProposerOptions, f as SelfImproveProposerResult, g as SelfImproveMethodProvenance, h as selfImprove, i as DefineAgentEvalOptions, l as SelfImproveOptions, m as SelfImproveRunError, n as AgentEvalEvaluateOptions, o as defineAgentEval, p as SelfImproveResult, r as AgentEvalImproveOptions, s as SelfImproveBudget, t as AgentEvalAgent, u as SelfImproveProgressEvent } from "../define-agent-eval-CEWkX5wZ.js";
12
+ import { $ as FromRunRecordDirOptions, A as CodeAgentSessionActionKind, At as verifyCandidateExperimentComparison, B as AgentTraceConversation, C as fromOpenCodeSession, Ct as evaluatePairedMeasurements, D as parseCodeAgentJsonlFile, Dt as sealCandidateBenchmarkTask, E as parseCodeAgentJsonl, Et as sealCandidateBenchmarkSuite, F as CodeAgentSessionSource, G as AuthoringProvenance, H as AgentTraceIndex, I as CodeAgentSessionTerminalStatus, J as partitionRunsByAuthoringModel, K as PartitionByAuthoringModelResult, L as observeCodeAgentSession, M as CodeAgentSessionActionSurface, N as CodeAgentSessionExecutionReceipt, O as streamCodeAgentJsonlFile, Ot as sealCandidateExperiment, P as CodeAgentSessionObservation, Q as evalReportingSuite, R as AgentTraceContributor, S as fromKimiCodeSession, St as SealCandidateBenchmarkSuiteOptions, T as fromPiSession, Tt as runCandidateExperiment, U as AgentTraceRange, V as AgentTraceFile, W as AgentTraceRecord, X as EvalReportingSuiteOptions, Y as EvalReportingSuiteInput, Z as EvalReportingSuiteResult, _ as CodeAgentSessionIntakeResult, _t as EvaluatePairedMeasurementsOptions, a as FromFeedbackTableOptions, at as CompareAgentProfileImprovementExperimentOptions, b as fromClaudeCodeSession, bt as PairedMeasurementEvaluation, c as CodeAgentStoreObservation, ct as measuredComparisonFromAgentProfileImprovementExperiment, d as CodeAgentStoreScope, dt as sealAgentProfileImprovementSuite, et as FromRunRecordDirResult, f as CodeAgentStoreSession, ft as sealAgentProfileImprovementTask, g as CodeAgentSessionIntakeOptions, gt as CompareCandidateExperimentOptions, h as CodeAgentSessionDiagnostic, ht as CandidateExperimentRun, i as FeedbackTableRow, it as AgentProfileImprovementExperimentRun, j as CodeAgentSessionActionStatus, k as CodeAgentSessionAction, kt as verifyCandidateExperiment, l as CodeAgentStoreRejection, lt as runAgentProfileImprovementExperiment, m as CodeAgentJsonlLine, mt as CandidateExperimentExecutionInput, n as fromOtelSpans, nt as fromRunRecordDir, o as FromFeedbackTableResult, ot as RunAgentProfileImprovementExperimentOptions, p as observeCodeAgentStore, pt as verifyAgentProfileImprovementExperimentComparison, q as parseAgentTrace, r as FeedbackTableMeta, rt as AgentProfileImprovementExperimentExecutionInput, s as fromFeedbackTable, st as SealAgentProfileImprovementSuiteOptions, t as FromOtelSpansOptions, tt as RunRecordRejection, u as CodeAgentStoreRejections, ut as sealAgentProfileImprovementExperiment, v as CodeAgentSessionMetrics, vt as PairedMeasurement, w as fromPiGraphSession, wt as measuredComparisonFromCandidateExperiment, x as fromCodexSession, xt as RunCandidateExperimentOptions, y as ParsedCodeAgentJsonl, yt as PairedMeasurementAdapter, z as AgentTraceContributorType } from "../index-DlH0Y9gI.js";
13
+ import { n as buildDefaultAnalystRegistry, t as DefaultAnalystRegistryOptions } from "../default-registry-BrWh62zf.js";
14
14
  export { type AgentEvalAgent, type AgentEvalEvaluateOptions, type AgentEvalImproveOptions, type AgentProfileImprovementExperimentExecutionInput, type AgentProfileImprovementExperimentRun, type AgentTraceContributor, type AgentTraceContributorType, type AgentTraceConversation, type AgentTraceFile, type AgentTraceIndex, type AgentTraceRange, type AgentTraceRecord, type AnalystFinding, type AnalyzeRunsOptions, type AuthoringProvenance, type AxisEvidence, type AxisVerdict, type BuildEvidenceVectorOptions, type CampaignAggregates, type CampaignArtifactWriter, type CampaignCellFailureReceipt, type CampaignCellResult, type CampaignCellRetryPolicy, type CampaignCostMeter, type CampaignResult, type CampaignStorage, type CampaignTraceWriter, type CandidateExperimentExecutionInput, type CandidateExperimentRun, type ChatClient, type CodeAgentJsonlLine, type CodeAgentSessionAction, type CodeAgentSessionActionKind, type CodeAgentSessionActionStatus, type CodeAgentSessionActionSurface, type CodeAgentSessionDiagnostic, type CodeAgentSessionExecutionReceipt, type CodeAgentSessionIntakeOptions, type CodeAgentSessionIntakeResult, type CodeAgentSessionMetrics, type CodeAgentSessionObservation, type CodeAgentSessionSource, type CodeAgentSessionTerminalStatus, type CodeAgentStoreObservation, type CodeAgentStoreRejection, type CodeAgentStoreRejections, type CodeAgentStoreScope, type CodeAgentStoreSession, type CodeSurface, type CompareAgentProfileImprovementExperimentOptions, type CompareCandidateExperimentOptions, type CompareOptimizationMethodsOptions, type ComparisonCost, type CostLedgerHandle, type CostProvenanceSummary, type CreateChatClientOpts, type DefaultAnalystRegistryOptions, type DefaultProductionGateCheck, type DefaultProductionGateOptions, type DefaultProductionRewardHackingOptions, type DefineAgentEvalOptions, type DefinedAgentEval, type DeploymentOutcome, type DispatchFn as Dispatch, type DispatchContext, type EvalReportingSuiteInput, type EvalReportingSuiteOptions, type EvalReportingSuiteResult, type EvaluatePairedMeasurementsOptions, type EvidenceVector, type ExecutionErrorOutcomeCell, type ExecutionInsight, type ExecutionReport, type ExternalOptimizationExample, type ExternalTextEvaluationResponse, type ExternalTextOptimizationMethodConfig, type ExternalTextOptimizerContext, type ExternalTextOptimizerResult, type FailureClassTally, type FailureClusterInsight, type FeedbackTableMeta, type FeedbackTableRow, FileSystemOutcomeStore, type FileSystemOutcomeStoreOptions, type FinalEvidencePolicy, type FinalEvidenceUse, type FromFeedbackTableOptions, type FromFeedbackTableResult, type FromOtelSpansOptions, type FromRunRecordDirOptions, type FromRunRecordDirResult, type Gate, type GateCheckStatus, type GateContext, type GateContribution, type GateDecision, type GateResult, type GenerationCandidate, type GenerationRecord, type GepaAdaptiveEngineRun, type GepaEngineOptions, type GepaEngineRun, type GepaOptimizationMethodConfig, type GepaOptimizationRecipe, type GepaRunnerCommand, type HeldOutGateOptions, type HostedTenant, InMemoryOutcomeStore, type InsightReport, type InterRaterInsight, type JudgeConfig, type JudgeDimension, type JudgeInsight, type JudgeScore, type LiftInsight, type LlmJudgeDimension, type LlmJudgeOptions, type MutableSurface, type ObjectiveSource, type OpenAICompatibleOptimizerModel, type OptimizationMethod, type OptimizationMethodComparison, type OptimizationMethodInput, type OptimizationMethodProvenance, type OptimizationMethodResult, type OptimizationPackageSource, type OptimizationTokenUsage, type OptimizerConfig, type OptimizerModelBudget, type OutcomeCorrelationInsight, type OutcomeStore, type PairedMeasurement, type PairedMeasurementAdapter, type PairedMeasurementEvaluation, type ParetoSignificanceGateOptions, type ParsedCodeAgentJsonl, type PartitionByAuthoringModelResult, type PromotionObjective, type PromotionPolicy, type ProposalFinding, type ProposalFindingOrigin, REFERENCE_EQUIVALENCE_INPUT_LIMITS, REFERENCE_EQUIVALENCE_JUDGE_VERSION, type Recommendation, type ReferenceEquivalenceJudgeInput, type ReferenceEquivalenceJudgeOptions, type ReferenceEquivalenceJudgeResult, type ReferenceEquivalenceScenario, type ReleaseSummary, type RunAgentProfileImprovementExperimentOptions, type RunCampaignOptions, type RunCandidateExperimentOptions, type RunEvalOptions, type RunImprovementLoopOptions, type RunImprovementLoopResult, type RunRecordRejection, type ScalarDistribution, type Scenario, type SealAgentProfileImprovementSuiteOptions, type SealCandidateBenchmarkSuiteOptions, type SelfImproveBudget, type SelfImproveMethodOptions, type SelfImproveMethodProvenance, type SelfImproveMethodResult, type SelfImproveOptions, type SelfImproveProgressEvent, type SelfImproveProposerOptions, type SelfImproveProposerResult, type SelfImproveResult, SelfImproveRunError, type SessionScript, type SkillOptOptimizationMethodConfig, type SkillOptRunnerCommand, type SkillOptTrainerConfig, type SummarizeExecutionOptions, type SurfaceProposer, type TokenUsageInsight, analyzeRuns, buildDefaultAnalystRegistry, buildEvidenceVector, campaignSplitDigest, compareOptimizationMethods, composeGate, createChatClient, createReferenceEquivalenceJudge, defaultProductionGate, defineAgentEval, evalReportingSuite, evaluatePairedMeasurements, externalTextOptimizationMethod, fromClaudeCodeSession, fromCodexSession, fromFeedbackTable, fromKimiCodeSession, fromOpenCodeSession, fromOtelSpans, fromPiGraphSession, fromPiSession, fromRunRecordDir, fsCampaignStorage, gepaOptimizationMethod, heldOutGate, inMemoryCampaignStorage, llmJudge, makeProposalFinding, measuredComparisonFromAgentProfileImprovementExperiment, measuredComparisonFromCandidateExperiment, observeCodeAgentSession, observeCodeAgentStore, paretoPolicy, paretoSignificanceGate, parseAgentTrace, parseCodeAgentJsonl, parseCodeAgentJsonlFile, partitionRunsByAuthoringModel, runAgentProfileImprovementExperiment, runCampaign, runCandidateExperiment, runEval, runImprovementLoop, runReferenceEquivalenceJudge, sealAgentProfileImprovementExperiment, sealAgentProfileImprovementSuite, sealAgentProfileImprovementTask, sealCandidateBenchmarkSuite, sealCandidateBenchmarkTask, sealCandidateExperiment, selfImprove, skillOptOptimizationMethod, streamCodeAgentJsonlFile, summarizeExecution, transientDispatchFailure, verifyAgentProfileImprovementExperimentComparison, verifyCandidateExperiment, verifyCandidateExperimentComparison };
@@ -4,19 +4,19 @@ import { t as decidePairedPromotion } from "../paired-promotion-decision-BN6IQTi
4
4
  import { a as heldoutSignificance } from "../statistical-heldout-1Gbmex7v.js";
5
5
  import { n as summarizeExecution, t as analyzeRuns } from "../analyze-runs-3xpby3p2.js";
6
6
  import { a as parseRunRecordSafe } from "../run-record-DlTZ_lqe.js";
7
- import { K as defaultProductionGate, a as transientDispatchFailure, c as compareOptimizationMethods, h as runImprovementLoop, nt as runEval, rt as runCampaign, t as llmJudge } from "../llm-judge-Dw0rDpve.js";
7
+ import { K as defaultProductionGate, a as transientDispatchFailure, c as compareOptimizationMethods, h as runImprovementLoop, nt as runEval, rt as runCampaign, t as llmJudge } from "../llm-judge-PXV7Xljl.js";
8
8
  import { i as isModelPriced, n as estimateCost } from "../metrics-BKaPBtIG.js";
9
- import { i as CostLedger } from "../cost-ledger-DFOeLeJi.js";
9
+ import { i as CostLedger } from "../cost-ledger-D2FnJPBF.js";
10
10
  import { G as campaignSplitDigest } from "../campaign-evidence-OcUciD-N.js";
11
11
  import { h as mapConcurrentRange } from "../journal-DvKCvjty.js";
12
- import { C as inMemoryCampaignStorage, S as fsCampaignStorage } from "../external-optimizer-subprocess-CA3aXT8I.js";
13
- import { n as SelfImproveRunError, r as selfImprove, t as defineAgentEval } from "../define-agent-eval-FGtpqnh4.js";
14
- import { t as buildDefaultAnalystRegistry } from "../default-registry-BhYGMVbV.js";
12
+ import { F as inMemoryCampaignStorage, P as fsCampaignStorage } from "../external-optimizer-subprocess-DcerlZSG.js";
13
+ import { o as makeProposalFinding } from "../types-IXD2HJzu.js";
14
+ import { n as SelfImproveRunError, r as selfImprove, t as defineAgentEval } from "../define-agent-eval-Ch3MWX6k.js";
15
+ import { t as buildDefaultAnalystRegistry } from "../default-registry-Cn1LQ2Ve.js";
15
16
  import { t as extractUsage } from "../extract-usage-BrnzRJ6H.js";
16
- import { i as makeProposalFinding } from "../types-CW5b90JH.js";
17
- import { t as createChatClient } from "../chat-client-Bnx8NZe4.js";
17
+ import { t as createChatClient } from "../chat-client-DthPOYGd.js";
18
18
  import { n as InMemoryOutcomeStore, t as FileSystemOutcomeStore } from "../outcome-store-DUcMj-3D.js";
19
- import { c as heldOutGate, g as runReferenceEquivalenceJudge, h as createReferenceEquivalenceJudge, l as composeGate, m as REFERENCE_EQUIVALENCE_JUDGE_VERSION, n as gepaOptimizationMethod, p as REFERENCE_EQUIVALENCE_INPUT_LIMITS, t as skillOptOptimizationMethod, u as externalTextOptimizationMethod } from "../skillopt-optimization-method-CvaFGm95.js";
19
+ import { c as heldOutGate, g as runReferenceEquivalenceJudge, h as createReferenceEquivalenceJudge, l as composeGate, m as REFERENCE_EQUIVALENCE_JUDGE_VERSION, n as gepaOptimizationMethod, p as REFERENCE_EQUIVALENCE_INPUT_LIMITS, t as skillOptOptimizationMethod, u as externalTextOptimizationMethod } from "../skillopt-optimization-method-CCtzralq.js";
20
20
  import { n as paretoPolicy, r as paretoSignificanceGate, t as buildEvidenceVector } from "../promotion-policy-CWW35UWq.js";
21
21
  import { t as fromOtelSpans } from "../otel-spans-C8YIJWy1.js";
22
22
  import { createHash } from "node:crypto";
@@ -230,13 +230,8 @@ declare class CostLedger {
230
230
  private captureFailure;
231
231
  private commitReceipt;
232
232
  private resolveMaximum;
233
- private hasBudgetBreachingSettledCall;
234
- /**
235
- * Total settled cost with each unknown-cost call charged its reserved
236
- * maximum. A provider that omits a call's cost cannot make the ceiling check
237
- * under-count: the call is bounded by what it was allowed to spend.
238
- */
239
- private conservativeSettledCostUsd;
233
+ /** Compute admission totals in record order without building reporting rollups. */
234
+ private admissionState;
240
235
  private appendRecord;
241
236
  private ensureCostLimitPersisted;
242
237
  private appendEvent;
@@ -259,4 +254,4 @@ declare function costForUsage(model: string, usage: CostUsage): CostResult;
259
254
  declare function costForTokenPricing(pricing: CustomTokenPricing, usage: Pick<CostUsage, 'inputTokens' | 'outputTokens' | 'cachedTokens' | 'cacheWriteTokens'>): number;
260
255
  //#endregion
261
256
  export { PendingCostCall as C, costForUsage as D, costForTokenPricing as E, modelPriceKey as O, PaidCallResult as S, RunPaidCallInput as T, CostReservationExceededError as _, CostChannel as a, CustomTokenPricing as b, CostLedgerHandle as c, CostLedgerPersistenceError as d, CostLedgerSummary as f, CostReceiptInput as g, CostReceiptCaptureError as h, CostCeilingReachedError as i, CostLedgerOptions as l, CostReceipt as m, CostAccountingIncompleteError as n, CostLedger as o, CostProvenance as p, CostCallConflictError as r, CostLedgerFilter as s, ChannelRollup as t, CostLedgerPersistence as u, CostResult as v, PendingCostCallView as w, MaximumCharge as x, CostUsage as y };
262
- //# sourceMappingURL=cost-ledger-DbQdN3nO.d.ts.map
257
+ //# sourceMappingURL=cost-ledger-CO7UyEcQ.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cost-ledger-DbQdN3nO.d.ts","names":[],"sources":["../src/cost-ledger.ts"],"mappings":";;KAIY;;KAGA;EACN;EAAkB;;EAClB;EAAmB;;EACnB;EAAoB;;UAET;EACf;;EAEA;;EAEA;;EAEA;;EAEA;;UAGQ;EACR;EACA,SAAS;EACT;EACA;EACA;EACA;EACA,OAAO;EACP;;UAGe,wBAAwB;EACvC;;UAGe,4BAA4B;EAC3C;;UAGe,oBAAoB,cAAc;EACjD;EACA;EACA;EACA;;EAEA;IACE;IACA;IACA;IACA;;;EAGF;;EAEA;;;EAGA;;UAKe,yBAAyB;EACxC;;E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edger = class {
108
108
  callId,
109
109
  error: new CostCallConflictError(`CostLedger: callId '${callId}' already exists`)
110
110
  };
111
- const summary = this.summary();
112
- if (summary.unresolvedCalls > 0) return {
111
+ const admission = this.admissionState();
112
+ if (admission.unresolvedCalls > 0) return {
113
113
  succeeded: false,
114
114
  callId,
115
- error: new CostAccountingIncompleteError(`CostLedger: ${summary.unresolvedCalls} unresolved call(s) must be reconciled before new paid work`)
115
+ error: new CostAccountingIncompleteError(`CostLedger: ${admission.unresolvedCalls} unresolved call(s) must be reconciled before new paid work`)
116
116
  };
117
117
  if (this.costCeilingUsd === void 0) break;
118
- if (this.hasBudgetBreachingSettledCall()) return {
118
+ if (admission.budgetBreached) return {
119
119
  succeeded: false,
120
120
  callId,
121
121
  error: new CostAccountingIncompleteError(`CostLedger: a settled call exceeded its enforced maximum; refusing paid call '${input.actor}' during '${input.phase}'`)
122
122
  };
123
- const committedCostUsd = this.conservativeSettledCostUsd();
123
+ const { committedCostUsd } = admission;
124
124
  if (committedCostUsd + maximumCostUsd > this.costCeilingUsd) return {
125
125
  succeeded: false,
126
126
  callId,
127
127
  error: new CostCeilingReachedError(this.costCeilingUsd, committedCostUsd, maximumCostUsd, input.phase, input.actor)
128
128
  };
129
- if (committedCostUsd + summary.reservedCostUsd + maximumCostUsd <= this.costCeilingUsd) break;
129
+ if (committedCostUsd + admission.reservedCostUsd + maximumCostUsd <= this.costCeilingUsd) break;
130
130
  await this.waitForReservationRelease(input.signal);
131
131
  }
132
132
  pending = {
@@ -188,8 +188,8 @@ var CostLedger = class {
188
188
  }
189
189
  /** Settle a call left pending by a crashed process after reconciling with the provider. */
190
190
  reconcile(callId, observed, options = {}) {
191
- const pending = [...this.records.values()].find((record) => record.callId === callId && record.status === "pending");
192
- if (!pending) throw new CostCallConflictError(`CostLedger: no pending call '${callId}'`);
191
+ const pending = this.records.get(callId);
192
+ if (pending?.status !== "pending") throw new CostCallConflictError(`CostLedger: no pending call '${callId}'`);
193
193
  if (this.activeCallIds.has(callId)) throw new CostCallConflictError(`CostLedger: call '${callId}' is still active`);
194
194
  this.ensureCostLimitPersisted(callId);
195
195
  return this.commitReceipt(pending, observed, options.failed === true || options.error !== void 0, options.error);
@@ -407,21 +407,25 @@ var CostLedger = class {
407
407
  }
408
408
  return priced.costUsd;
409
409
  }
410
- hasBudgetBreachingSettledCall() {
411
- return [...this.records.values()].some((record) => record.status === "settled" && record.maximumCostUsd !== void 0 && record.costUsd > record.maximumCostUsd);
412
- }
413
- /**
414
- * Total settled cost with each unknown-cost call charged its reserved
415
- * maximum. A provider that omits a call's cost cannot make the ceiling check
416
- * under-count: the call is bounded by what it was allowed to spend.
417
- */
418
- conservativeSettledCostUsd() {
419
- let total = 0;
420
- for (const record of this.records.values()) {
421
- if (record.status !== "settled") continue;
422
- total += record.costUnknown ? record.maximumCostUsd ?? record.costUsd : record.costUsd;
410
+ /** Compute admission totals in record order without building reporting rollups. */
411
+ admissionState() {
412
+ let unresolvedCalls = 0;
413
+ let reservedCostUsd = 0;
414
+ let committedCostUsd = 0;
415
+ let budgetBreached = false;
416
+ for (const record of this.records.values()) if (record.status === "pending") {
417
+ if (!this.activeCallIds.has(record.callId) || this.lateCallIds.has(record.callId)) unresolvedCalls += 1;
418
+ reservedCostUsd += record.maximumCostUsd ?? 0;
419
+ } else {
420
+ if (record.maximumCostUsd !== void 0 && record.costUsd > record.maximumCostUsd) budgetBreached = true;
421
+ committedCostUsd += record.costUnknown ? record.maximumCostUsd ?? record.costUsd : record.costUsd;
423
422
  }
424
- return total;
423
+ return {
424
+ unresolvedCalls,
425
+ reservedCostUsd,
426
+ committedCostUsd,
427
+ budgetBreached
428
+ };
425
429
  }
426
430
  appendRecord(record) {
427
431
  const callId = record.callId;
@@ -895,4 +899,4 @@ function assertString(value, name) {
895
899
  //#endregion
896
900
  export { CostLedgerPersistenceError as a, costForTokenPricing as c, CostLedger as i, costForUsage as l, CostCallConflictError as n, CostReceiptCaptureError as o, CostCeilingReachedError as r, CostReservationExceededError as s, CostAccountingIncompleteError as t, modelPriceKey as u };
897
901
 
898
- //# sourceMappingURL=cost-ledger-DFOeLeJi.js.map
902
+ //# sourceMappingURL=cost-ledger-D2FnJPBF.js.map