@tangle-network/agent-eval 1.0.22 → 1.0.24

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 (233) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/dist/adapters/http.d.ts +2 -2
  3. package/dist/{agent-profile-DU5InUT9.d.ts → agent-profile-DC_v4p1f.d.ts} +3 -3
  4. package/dist/{agent-profile-DU5InUT9.d.ts.map → agent-profile-DC_v4p1f.d.ts.map} +1 -1
  5. package/dist/analyst/index.d.ts +14 -14
  6. package/dist/analyst/index.js +9 -9
  7. package/dist/{analyze-runs-jLTRKuoK.js → analyze-runs-BCSHzqna.js} +2 -2
  8. package/dist/{analyze-runs-jLTRKuoK.js.map → analyze-runs-BCSHzqna.js.map} +1 -1
  9. package/dist/{analyze-runs-DYYe18Gw.d.ts → analyze-runs-DGr7mpC3.d.ts} +5 -5
  10. package/dist/{analyze-runs-DYYe18Gw.d.ts.map → analyze-runs-DGr7mpC3.d.ts.map} +1 -1
  11. package/dist/app-grade/index.d.ts +4 -4
  12. package/dist/app-grade/index.js +3 -3
  13. package/dist/{benchmark-command-DkUpd9Q6.js → benchmark-command-DRAHkn4D.js} +8 -9
  14. package/dist/{benchmark-command-DkUpd9Q6.js.map → benchmark-command-DRAHkn4D.js.map} +1 -1
  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 +8 -8
  19. package/dist/{campaign-C2mmydmx.js → campaign-C9QC27C2.js} +12 -12
  20. package/dist/{campaign-C2mmydmx.js.map → campaign-C9QC27C2.js.map} +1 -1
  21. package/dist/{campaign-evidence-NtH29ctt.js → campaign-evidence-CVNKiK0q.js} +2 -2
  22. package/dist/{campaign-evidence-NtH29ctt.js.map → campaign-evidence-CVNKiK0q.js.map} +1 -1
  23. package/dist/{chat-client-Zz97O3NB.js → chat-client-9XLgWrQ7.js} +5 -3
  24. package/dist/chat-client-9XLgWrQ7.js.map +1 -0
  25. package/dist/{chat-json-call-Dgi7-RH-.js → chat-json-call-CaNO3k0A.js} +2 -2
  26. package/dist/{chat-json-call-Dgi7-RH-.js.map → chat-json-call-CaNO3k0A.js.map} +1 -1
  27. package/dist/cli.js +8 -8
  28. package/dist/{cluster-Cd0MRbr9.d.ts → cluster-CkzP4h3T.d.ts} +4 -2
  29. package/dist/{cluster-Cd0MRbr9.d.ts.map → cluster-CkzP4h3T.d.ts.map} +1 -1
  30. package/dist/{completion-verifier-DFyYFezn.js → completion-verifier-BYLOcQt7.js} +5 -4
  31. package/dist/completion-verifier-BYLOcQt7.js.map +1 -0
  32. package/dist/{completion-verifier-BEpsr3N4.d.ts → completion-verifier-CJVDPv2T.d.ts} +3 -2
  33. package/dist/{completion-verifier-BEpsr3N4.d.ts.map → completion-verifier-CJVDPv2T.d.ts.map} +1 -1
  34. package/dist/contract/index.d.ts +11 -11
  35. package/dist/contract/index.js +11 -13
  36. package/dist/contract/index.js.map +1 -1
  37. package/dist/{cost-ledger-DfhStGcZ.js → cost-ledger-1CwUnVOd.js} +145 -3
  38. package/dist/cost-ledger-1CwUnVOd.js.map +1 -0
  39. package/dist/{decision-point-Di2LATNH.js → decision-point-CQOczIIH.js} +2 -2
  40. package/dist/{decision-point-Di2LATNH.js.map → decision-point-CQOczIIH.js.map} +1 -1
  41. package/dist/{default-registry-aPvwtzEM.d.ts → default-registry-C_Akmpui.d.ts} +7 -7
  42. package/dist/{default-registry-aPvwtzEM.d.ts.map → default-registry-C_Akmpui.d.ts.map} +1 -1
  43. package/dist/{default-registry-CdFbxPnr.js → default-registry-D-xd7KxV.js} +5 -5
  44. package/dist/{default-registry-CdFbxPnr.js.map → default-registry-D-xd7KxV.js.map} +1 -1
  45. package/dist/{define-agent-eval-BROmIwn1.js → define-agent-eval-BLVewqJm.js} +8 -8
  46. package/dist/{define-agent-eval-BROmIwn1.js.map → define-agent-eval-BLVewqJm.js.map} +1 -1
  47. package/dist/{define-agent-eval-DGWBgCid.d.ts → define-agent-eval-nNPC7cD5.d.ts} +7 -7
  48. package/dist/{define-agent-eval-DGWBgCid.d.ts.map → define-agent-eval-nNPC7cD5.d.ts.map} +1 -1
  49. package/dist/diagnosis/index.d.ts +2 -2
  50. package/dist/diagnosis/index.js +1 -1
  51. package/dist/{dspy-rlm-engine-cWyn8G1a.js → dspy-rlm-engine-BS_jxE0P.js} +4 -4
  52. package/dist/{dspy-rlm-engine-cWyn8G1a.js.map → dspy-rlm-engine-BS_jxE0P.js.map} +1 -1
  53. package/dist/{engine-BF8naBn7.d.ts → engine-B0gr15-l.d.ts} +2 -2
  54. package/dist/{engine-BF8naBn7.d.ts.map → engine-B0gr15-l.d.ts.map} +1 -1
  55. package/dist/{eval-campaign-Dq8DEKmy.js → eval-campaign-DpkToY_w.js} +2 -2
  56. package/dist/eval-campaign-DpkToY_w.js.map +1 -0
  57. package/dist/{evaluation-bU_bhlv-.js → evaluation-C_GJvEEG.js} +2 -2
  58. package/dist/{evaluation-bU_bhlv-.js.map → evaluation-C_GJvEEG.js.map} +1 -1
  59. package/dist/{evaluation-CFKj_IlJ.d.ts → evaluation-mk3u_ZJC.d.ts} +4 -4
  60. package/dist/{evaluation-CFKj_IlJ.d.ts.map → evaluation-mk3u_ZJC.d.ts.map} +1 -1
  61. package/dist/evaluation.d.ts +1 -1
  62. package/dist/evaluation.js +1 -1
  63. package/dist/{exact-types-VAFjtOQN.d.ts → exact-types-Blq7YvsK.d.ts} +2 -2
  64. package/dist/{exact-types-VAFjtOQN.d.ts.map → exact-types-Blq7YvsK.d.ts.map} +1 -1
  65. package/dist/experiment/index.d.ts +3 -3
  66. package/dist/experiment/index.js +2 -2
  67. package/dist/{external-optimizer-process-2ImGH_LR.js → external-optimizer-process-m9xln7zN.js} +2 -2
  68. package/dist/{external-optimizer-process-2ImGH_LR.js.map → external-optimizer-process-m9xln7zN.js.map} +1 -1
  69. package/dist/{external-optimizer-subprocess-_C_2yriN.js → external-optimizer-subprocess-GO6s84Ov.js} +3 -3
  70. package/dist/{external-optimizer-subprocess-_C_2yriN.js.map → external-optimizer-subprocess-GO6s84Ov.js.map} +1 -1
  71. package/dist/{feedback-trajectory-DTj8eVTR.d.ts → feedback-trajectory-D3oISeGl.d.ts} +3 -3
  72. package/dist/{feedback-trajectory-DTj8eVTR.d.ts.map → feedback-trajectory-D3oISeGl.d.ts.map} +1 -1
  73. package/dist/{findings-store-BSuaV3dN.js → findings-store-CTy71Lnr.js} +5 -5
  74. package/dist/{findings-store-BSuaV3dN.js.map → findings-store-CTy71Lnr.js.map} +1 -1
  75. package/dist/fuzz.js +1 -1
  76. package/dist/hosted/index.js +1 -1
  77. package/dist/{index-DNXFzSpc.d.ts → index-BN6htPVi.d.ts} +2 -2
  78. package/dist/{index-DNXFzSpc.d.ts.map → index-BN6htPVi.d.ts.map} +1 -1
  79. package/dist/{index-BlTbxHlY.d.ts → index-BdFlQP54.d.ts} +4 -4
  80. package/dist/{index-BlTbxHlY.d.ts.map → index-BdFlQP54.d.ts.map} +1 -1
  81. package/dist/{index-QLDWZTxI.d.ts → index-CxuK3sxA.d.ts} +9 -9
  82. package/dist/{index-QLDWZTxI.d.ts.map → index-CxuK3sxA.d.ts.map} +1 -1
  83. package/dist/{index-YS58LHlx.d.ts → index-Dodw93oW.d.ts} +25 -181
  84. package/dist/index-Dodw93oW.d.ts.map +1 -0
  85. package/dist/{index-DX87wzX3.d.ts → index-IE8O0HNr.d.ts} +9 -9
  86. package/dist/{index-DX87wzX3.d.ts.map → index-IE8O0HNr.d.ts.map} +1 -1
  87. package/dist/{index-B62BaRzH.d.ts → index-KAYaJtMA.d.ts} +4 -4
  88. package/dist/{index-B62BaRzH.d.ts.map → index-KAYaJtMA.d.ts.map} +1 -1
  89. package/dist/{index-Bp3w4fWc.d.ts → index-cp5gkylN.d.ts} +12 -12
  90. package/dist/{index-Bp3w4fWc.d.ts.map → index-cp5gkylN.d.ts.map} +1 -1
  91. package/dist/index.d.ts +30 -30
  92. package/dist/index.js +72 -30
  93. package/dist/index.js.map +1 -1
  94. package/dist/{integrity-CrmnGB2T.d.ts → integrity-zeWMeTQt.d.ts} +2 -2
  95. package/dist/{integrity-CrmnGB2T.d.ts.map → integrity-zeWMeTQt.d.ts.map} +1 -1
  96. package/dist/{judge-gate-CrN0PaAL.js → judge-gate-DsoI5tx7.js} +2 -2
  97. package/dist/{judge-gate-CrN0PaAL.js.map → judge-gate-DsoI5tx7.js.map} +1 -1
  98. package/dist/{kind-factory-CV0FNCMM.js → kind-factory-CJXaE1oF.js} +2 -2
  99. package/dist/{kind-factory-CV0FNCMM.js.map → kind-factory-CJXaE1oF.js.map} +1 -1
  100. package/dist/{llm-client-DMMSg-Ro.js → llm-client-Bj-TooRS.js} +11 -11
  101. package/dist/{llm-client-DMMSg-Ro.js.map → llm-client-Bj-TooRS.js.map} +1 -1
  102. package/dist/{llm-judge-C813vmpc.js → llm-judge-DzAT7Wka.js} +11 -11
  103. package/dist/{llm-judge-C813vmpc.js.map → llm-judge-DzAT7Wka.js.map} +1 -1
  104. package/dist/{matrix-C-GxIgeJ.d.ts → matrix-Diw3yJCG.d.ts} +3 -4
  105. package/dist/matrix-Diw3yJCG.d.ts.map +1 -0
  106. package/dist/meta-eval/index.d.ts +3 -3
  107. package/dist/meta-eval/index.js +2 -2
  108. package/dist/{mint-yF51iBgY.js → mint-Ck92efNo.js} +2 -2
  109. package/dist/{mint-yF51iBgY.js.map → mint-Ck92efNo.js.map} +1 -1
  110. package/dist/multishot/golden/index.d.ts +1 -1
  111. package/dist/multishot/index.d.ts +3 -2
  112. package/dist/multishot/index.d.ts.map +1 -1
  113. package/dist/multishot/index.js +3 -3
  114. package/dist/multishot/index.js.map +1 -1
  115. package/dist/openapi.json +1 -1
  116. package/dist/{paired-promotion-decision-DJU3fZxH.d.ts → paired-promotion-decision-COeOgNHG.d.ts} +2 -2
  117. package/dist/{paired-promotion-decision-DJU3fZxH.d.ts.map → paired-promotion-decision-COeOgNHG.d.ts.map} +1 -1
  118. package/dist/paired-promotion-power-D03cUj9E.js +289 -0
  119. package/dist/paired-promotion-power-D03cUj9E.js.map +1 -0
  120. package/dist/{pareto-fJZg8pXm.js → pareto-UzjB3ZBk.js} +5 -288
  121. package/dist/pareto-UzjB3ZBk.js.map +1 -0
  122. package/dist/{prime-protocol-D1NkJRuD.d.ts → prime-protocol-bRbh6dqd.d.ts} +2 -2
  123. package/dist/{prime-protocol-D1NkJRuD.d.ts.map → prime-protocol-bRbh6dqd.d.ts.map} +1 -1
  124. package/dist/{promotion-gate-Da0xV4sa.d.ts → promotion-gate-XglbDCNo.d.ts} +3 -3
  125. package/dist/{promotion-gate-Da0xV4sa.d.ts.map → promotion-gate-XglbDCNo.d.ts.map} +1 -1
  126. package/dist/{proposal-findings-DWs94yT8.js → proposal-findings-CS6LoGGp.js} +2 -2
  127. package/dist/{proposal-findings-DWs94yT8.js.map → proposal-findings-CS6LoGGp.js.map} +1 -1
  128. package/dist/{registry-BAcEbzKm.d.ts → registry-Pfeqsr5k.d.ts} +4 -4
  129. package/dist/{registry-BAcEbzKm.d.ts.map → registry-Pfeqsr5k.d.ts.map} +1 -1
  130. package/dist/{release-confidence-DGtuPDxJ.js → release-confidence-B4Xxdpmn.js} +2 -2
  131. package/dist/{release-confidence-DGtuPDxJ.js.map → release-confidence-B4Xxdpmn.js.map} +1 -1
  132. package/dist/reporting.d.ts +5 -5
  133. package/dist/reporting.js +2 -2
  134. package/dist/{researcher-CSlc84Bp.d.ts → researcher-DlyjP5uq.d.ts} +6 -6
  135. package/dist/{researcher-CSlc84Bp.d.ts.map → researcher-DlyjP5uq.d.ts.map} +1 -1
  136. package/dist/{reward-ST4PXNXF.d.ts → reward-ap_R9mCH.d.ts} +2 -2
  137. package/dist/{reward-ST4PXNXF.d.ts.map → reward-ap_R9mCH.d.ts.map} +1 -1
  138. package/dist/{reward-hacking-C9hPVT0Q.d.ts → reward-hacking-CIdVwVe4.d.ts} +2 -2
  139. package/dist/{reward-hacking-C9hPVT0Q.d.ts.map → reward-hacking-CIdVwVe4.d.ts.map} +1 -1
  140. package/dist/rl.d.ts +11 -11
  141. package/dist/rl.js +5 -5
  142. package/dist/rl.js.map +1 -1
  143. package/dist/rollout/index.d.ts +3 -3
  144. package/dist/rollout/index.js +2 -2
  145. package/dist/{rollout-DKa54qer.js → rollout-Dh5q6CPA.js} +3 -3
  146. package/dist/{rollout-DKa54qer.js.map → rollout-Dh5q6CPA.js.map} +1 -1
  147. package/dist/{rubric-predictive-validity-B3RzbwOx.d.ts → rubric-predictive-validity-Bbi88Aut.d.ts} +2 -2
  148. package/dist/{rubric-predictive-validity-B3RzbwOx.d.ts.map → rubric-predictive-validity-Bbi88Aut.d.ts.map} +1 -1
  149. package/dist/{run-record-CFbnkE1K.js → run-record-DTTx9Ktr.js} +2 -2
  150. package/dist/{run-record-CFbnkE1K.js.map → run-record-DTTx9Ktr.js.map} +1 -1
  151. package/dist/{run-record-CpLS4Uid.js → run-record-DmX_ESC5.js} +7 -5
  152. package/dist/run-record-DmX_ESC5.js.map +1 -0
  153. package/dist/{run-record-D2BFMPGl.d.ts → run-record-pBlhZizT.d.ts} +8 -8
  154. package/dist/{run-record-D2BFMPGl.d.ts.map → run-record-pBlhZizT.d.ts.map} +1 -1
  155. package/dist/search/index.d.ts +2 -2
  156. package/dist/search/index.d.ts.map +1 -1
  157. package/dist/search/index.js +2 -2
  158. package/dist/{search-kernel-CQGLbmgn.d.ts → search-kernel-6P1dRpJ4.d.ts} +4 -4
  159. package/dist/{search-kernel-CQGLbmgn.d.ts.map → search-kernel-6P1dRpJ4.d.ts.map} +1 -1
  160. package/dist/{search-ledger-Dk-yk5Li.js → search-ledger-9liYyZf5.js} +2 -2
  161. package/dist/{search-ledger-Dk-yk5Li.js.map → search-ledger-9liYyZf5.js.map} +1 -1
  162. package/dist/{search-shipper-Dm-_Dtvy.js → search-shipper-B6tMNx1I.js} +2 -2
  163. package/dist/{search-shipper-Dm-_Dtvy.js.map → search-shipper-B6tMNx1I.js.map} +1 -1
  164. package/dist/{search-summary-sPWiYtSl.js → search-summary-CISbbxyr.js} +2 -2
  165. package/dist/{search-summary-sPWiYtSl.js.map → search-summary-CISbbxyr.js.map} +1 -1
  166. package/dist/{sequential-CAksw6EU.js → sequential-Ko7T-zvu.js} +65 -28
  167. package/dist/sequential-Ko7T-zvu.js.map +1 -0
  168. package/dist/sequential-OeSwJ2uG.d.ts +246 -0
  169. package/dist/sequential-OeSwJ2uG.d.ts.map +1 -0
  170. package/dist/{server-DFVwfoZq.js → server-BorE0Y3O.js} +16 -5
  171. package/dist/server-BorE0Y3O.js.map +1 -0
  172. package/dist/{skillopt-optimization-method-QO1nU8Kz.js → skillopt-optimization-method-BtX7xXDd.js} +7 -7
  173. package/dist/{skillopt-optimization-method-QO1nU8Kz.js.map → skillopt-optimization-method-BtX7xXDd.js.map} +1 -1
  174. package/dist/{statistical-heldout-CvOwNqt9.d.ts → statistical-heldout-vjrs8iyO.d.ts} +6 -6
  175. package/dist/{statistical-heldout-CvOwNqt9.d.ts.map → statistical-heldout-vjrs8iyO.d.ts.map} +1 -1
  176. package/dist/statistics.d.ts +2 -2
  177. package/dist/{store-otlp-C-jyj3WX.js → store-otlp-CmgKDr0O.js} +2 -2
  178. package/dist/{store-otlp-C-jyj3WX.js.map → store-otlp-CmgKDr0O.js.map} +1 -1
  179. package/dist/{store-tool-spans-B3z_Qb5u.d.ts → store-tool-spans-BemsQEhd.d.ts} +6 -6
  180. package/dist/{store-tool-spans-B3z_Qb5u.d.ts.map → store-tool-spans-BemsQEhd.d.ts.map} +1 -1
  181. package/dist/{store-tool-spans-DalWlKY8.js → store-tool-spans-CW24axM0.js} +3 -3
  182. package/dist/{store-tool-spans-DalWlKY8.js.map → store-tool-spans-CW24axM0.js.map} +1 -1
  183. package/dist/{summary-report-DyZquTaH.d.ts → summary-report-vdhE20Zf.d.ts} +4 -4
  184. package/dist/{summary-report-DyZquTaH.d.ts.map → summary-report-vdhE20Zf.d.ts.map} +1 -1
  185. package/dist/supervisor-run/index.d.ts +1 -1
  186. package/dist/{systemone-DVk-Crtu.d.ts → systemone-DFUN9DL1.d.ts} +7 -7
  187. package/dist/{systemone-DVk-Crtu.d.ts.map → systemone-DFUN9DL1.d.ts.map} +1 -1
  188. package/dist/{systemone-review-CToBl1oa.d.ts → systemone-review-4CKmHvr5.d.ts} +2 -2
  189. package/dist/{systemone-review-CToBl1oa.d.ts.map → systemone-review-4CKmHvr5.d.ts.map} +1 -1
  190. package/dist/systemone.d.ts +3 -3
  191. package/dist/systemone.js +2 -2
  192. package/dist/{tool-groups-R5RO9OHn.d.ts → tool-groups-Dpl3picW.d.ts} +3 -3
  193. package/dist/tool-groups-Dpl3picW.d.ts.map +1 -0
  194. package/dist/{trace-questions-BY6taxnl.d.ts → trace-questions-oT2fZWJ8.d.ts} +3 -3
  195. package/dist/{trace-questions-BY6taxnl.d.ts.map → trace-questions-oT2fZWJ8.d.ts.map} +1 -1
  196. package/dist/trace-repair/index.d.ts +2 -2
  197. package/dist/traces.d.ts +6 -6
  198. package/dist/traces.js +5 -11
  199. package/dist/traces.js.map +1 -1
  200. package/dist/{tree-C-N2kP-8.js → tree-D2cNtu9m.js} +10 -10
  201. package/dist/tree-D2cNtu9m.js.map +1 -0
  202. package/dist/{types-kBMNdo1X.d.ts → types-6GuPL-Vt.d.ts} +3 -3
  203. package/dist/{types-kBMNdo1X.d.ts.map → types-6GuPL-Vt.d.ts.map} +1 -1
  204. package/dist/{types-ip2D3-Ib.d.ts → types-C9yEqDjQ.d.ts} +6 -6
  205. package/dist/{types-ip2D3-Ib.d.ts.map → types-C9yEqDjQ.d.ts.map} +1 -1
  206. package/dist/{types-BsdcSWnf.d.ts → types-CP3rkpir.d.ts} +3 -3
  207. package/dist/{types-BsdcSWnf.d.ts.map → types-CP3rkpir.d.ts.map} +1 -1
  208. package/dist/{types-DUVhW5V1.d.ts → types-CwHU7U9J.d.ts} +2 -2
  209. package/dist/{types-DUVhW5V1.d.ts.map → types-CwHU7U9J.d.ts.map} +1 -1
  210. package/dist/wire/index.d.ts +4 -4
  211. package/dist/wire/index.d.ts.map +1 -1
  212. package/dist/wire/index.js +1 -1
  213. package/docs/adopt-stack.md +9 -0
  214. package/docs/eval-fixtures.md +2 -2
  215. package/docs/search-ledger.md +1 -0
  216. package/docs/wire-protocol.md +1 -1
  217. package/package.json +1 -1
  218. package/dist/chat-client-Zz97O3NB.js.map +0 -1
  219. package/dist/completion-verifier-DFyYFezn.js.map +0 -1
  220. package/dist/cost-ledger-DfhStGcZ.js.map +0 -1
  221. package/dist/eval-campaign-Dq8DEKmy.js.map +0 -1
  222. package/dist/index-YS58LHlx.d.ts.map +0 -1
  223. package/dist/matrix-C-GxIgeJ.d.ts.map +0 -1
  224. package/dist/metrics-zALlR17s.js +0 -146
  225. package/dist/metrics-zALlR17s.js.map +0 -1
  226. package/dist/pareto-fJZg8pXm.js.map +0 -1
  227. package/dist/run-record-CpLS4Uid.js.map +0 -1
  228. package/dist/sequential-B9p6uoV8.d.ts +0 -168
  229. package/dist/sequential-B9p6uoV8.d.ts.map +0 -1
  230. package/dist/sequential-CAksw6EU.js.map +0 -1
  231. package/dist/server-DFVwfoZq.js.map +0 -1
  232. package/dist/tool-groups-R5RO9OHn.d.ts.map +0 -1
  233. package/dist/tree-C-N2kP-8.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"eval-campaign-Dq8DEKmy.js","names":[],"sources":["../src/eval-campaign.ts"],"sourcesContent":["/**\n * EvalCampaign — opinionated matrix runner that wires the four\n * capture-integrity directives by construction.\n *\n * The canonical benchmark shape — matrix runner → for each\n * (variant, scenario, seed) → start a TraceEmitter → call LLMs → end the\n * run → analyze — has a bug class at the integration boundary: raw\n * events not captured, route silently wrong, integrity not asserted,\n * analyst never run. The directives in `SKILL.md § Capture integrity`\n * are the mitigations.\n *\n * `EvalCampaign` is the structural fix — consumers don't wire the\n * integrity surface themselves; the campaign owns it. Specifically:\n *\n * - constructs a per-run `TraceStore` and `RawProviderSink` via factories\n * - builds the run's `ChatClient` through `chatFactory`, handing it the\n * run's raw sink and trace context — a transport built any other way has\n * no raw HTTP envelope, and `assertRunCaptured` says so\n * - calls `assertRunCaptured` after every `endRun` and routes failures\n * through a configurable policy (`throw` / `mark_failed` / `log`)\n * - assembles per-run `RunRecord`s and runs `researchReport` at the end\n * so the campaign artifact is launch-decision-grade by default\n * - embeds the campaign fingerprint (a SHA-256 over the canonicalised\n * run set) and optional `preregistrationHash` in the report\n *\n * The runner contract is intentionally narrow: produce a `CampaignRunOutcome`\n * given a fully-wired `CampaignRunContext`. Everything orchestration-shaped\n * lives in the campaign. This is the inversion-of-control point — consumers\n * stop writing matrix runners and start writing scenario-runners.\n *\n * Out of scope for v1 (tracked in `docs/research-report-methodology.md`):\n *\n * - Distributed/cluster execution (concurrency is local async)\n * - Adaptive sampling / sequential interim looks\n * - Resume from partial state across crashes\n * - LLM-call retry beyond what the caller's transport already does\n */\n\nimport {\n type AgentProfileCell,\n type AgentProfileCellInput,\n buildAgentProfileCell,\n verifyAgentProfileCell,\n} from './agent-profile-cell'\nimport type { ChatClient } from './analyst/chat-client'\nimport { hashJson } from './pre-registration'\nimport type {\n JudgeScoresRecord,\n RunCostProvenance,\n RunJudgeMetadata,\n RunOutcome,\n RunRecord,\n RunSplitTag,\n RunTaskFailure,\n RunTokenUsage,\n} from './run-record'\nimport { validateRunRecord } from './run-record'\nimport { type ResearchReport, type ResearchReportOptions, researchReport } from './summary-report'\nimport type { RunCompleteHook } from './trace/emitter'\nimport { TraceEmitter } from './trace/emitter'\nimport {\n assertRunCaptured,\n RunIntegrityError,\n type RunIntegrityExpectations,\n type RunIntegrityReport,\n} from './trace/integrity'\nimport { FileSystemRawProviderSink, type RawProviderSink } from './trace/raw-provider-sink'\nimport type { TraceStore } from './trace/store'\n\n// ── Public types ─────────────────────────────────────────────────────────\n\nexport interface CampaignVariant<V> {\n id: string\n payload: V\n}\n\nexport interface CampaignScenario {\n scenarioId: string\n /** Free-form metadata propagated to runs and reports. */\n tags?: Record<string, string>\n}\n\nexport interface CampaignRunContext<V> {\n /** Stable run id. The campaign generates this; the runner does not. */\n runId: string\n /** Logical experiment id (campaignId by default; overridable per-run via opts). */\n experimentId: string\n variant: V\n variantId: string\n scenarioId: string\n scenarioTags: Record<string, string>\n seed: number\n splitTag: RunSplitTag\n /**\n * The TraceEmitter for this run, with `onRunComplete` hooks pre-wired\n * (analyst auto-execution if configured, plus integrity check). The\n * runner MUST call `emitter.startRun` before doing any work and either\n * `emitter.endRun` or `emitter.abortRun` before returning.\n */\n emitter: TraceEmitter\n store: TraceStore\n rawSink: RawProviderSink\n /**\n * The run's model transport, built by `chatFactory` with this run's\n * `rawSink` and `runId` already bound.\n */\n chat: ChatClient\n}\n\n/** What the campaign binds into the run's transport. */\nexport interface CampaignChatWiring {\n /**\n * Raw provider sink for this run. Bind it into the transport: the campaign's\n * integrity check requires every LLM span to carry a matching raw request\n * event, so a transport built without it fails `assertRunCaptured`.\n */\n rawSink: RawProviderSink\n runId: string\n}\n\ninterface CampaignRunOutcomeFields {\n /** Did the run pass? Mirrors `RunOutcome.pass` semantics. */\n pass: boolean\n /** Score for the run on its split. Maps to `searchScore` or `holdoutScore`. */\n score: number\n /** Cost in USD, or null when the runner could not capture it. */\n costUsd: number | null\n /** Source of the cost amount. */\n costProvenance: RunCostProvenance\n tokenUsage: RunTokenUsage\n /** Snapshot model id (e.g. `claude-sonnet-4-6@2025-04-15`). */\n model: string\n /** sha256 of the effective prompt sent to the model. */\n promptHash: string\n /** sha256 of the effective config (model, temperature, tools, judges, splits). */\n configHash: string\n /** Optional extra numeric metrics to land in `outcome.raw`. */\n raw?: Record<string, number>\n /** Optional judge metadata when a judge was used. */\n judgeMetadata?: RunJudgeMetadata\n /**\n * Optional per-judge / per-dim breakdown for ensemble-judged runs.\n * Propagated to `outcome.judgeScores` on the resulting `RunRecord`.\n * Single-judge or scalar-only runs leave this unset.\n */\n judgeScores?: JudgeScoresRecord\n /**\n * Agent profile cell observed by the runner. When supplied, it overrides\n * `EvalCampaignOptions.agentProfile` for this run and must match the\n * outcome's `model` and `promptHash`.\n */\n agentProfile?: AgentProfileCell | AgentProfileCellInput\n}\n\n/** Campaign result with the same task-failure invariant as `RunRecord`. */\nexport type CampaignRunOutcome = CampaignRunOutcomeFields & RunTaskFailure\n\nexport type CampaignRunner<V> = (ctx: CampaignRunContext<V>) => Promise<CampaignRunOutcome>\n\nexport type CampaignIntegrityPolicy = 'throw' | 'mark_failed' | 'log'\n\nexport interface EvalCampaignOptions<V> {\n /**\n * Stable id for the campaign. Used as the default `experimentId` on\n * every run, and folded into the campaign fingerprint.\n */\n campaignId: string\n variants: CampaignVariant<V>[]\n scenarios: CampaignScenario[]\n /** Default `[0, 1, 2]`. */\n seeds?: number[]\n /** Default `'holdout'` — the split that anchors a launch decision. */\n splitTag?: RunSplitTag\n /** Git SHA the campaign is run against. Mandatory; `RunRecord` rejects unset. */\n commitSha: string\n /**\n * Build the model transport for one run. agent-eval executes no paid model:\n * the caller owns the transport and the credential never enters this\n * package. The campaign calls this once per run and passes the run's raw\n * provider sink and `runId`, so a transport that binds them captures the\n * raw HTTP envelope `assertRunCaptured` checks for.\n */\n chatFactory: (wiring: CampaignChatWiring) => ChatClient\n /**\n * Caller-declared identity of the execution route, folded into the campaign\n * fingerprint so two campaigns run against different endpoints do not share\n * one identity. agent-eval no longer knows the endpoint; the owner of\n * execution names it.\n */\n executionRef?: string\n /**\n * Per-run TraceStore factory. Common shape: a fresh store per run keyed\n * on `runId`. Implementations that share a store across the campaign\n * are valid — the campaign only writes through `emitter`.\n */\n storeFactory: (params: CampaignFactoryParams) => TraceStore\n /**\n * Per-run RawProviderSink factory. Defaults to `FileSystemRawProviderSink`\n * rooted at `${workDir}/raw-events/${runId}` if `workDir` is supplied;\n * otherwise required. Forensic capture is non-negotiable in a campaign\n * run — pass `NoopRawProviderSink` explicitly if you want to opt out.\n */\n rawSinkFactory?: (params: CampaignFactoryParams) => RawProviderSink\n /**\n * Filesystem root for default `rawSinkFactory`. Ignored if\n * `rawSinkFactory` is supplied.\n */\n workDir?: string\n /**\n * Extra `onRunComplete` hooks the campaign appends (after its own\n * integrity-check hook). Pass `traceAnalystOnRunComplete(...)` here.\n */\n onRunComplete?: RunCompleteHook[]\n /**\n * Per-run integrity expectations. Defaults to:\n * `{ llmSpansMin: 1, requireRawCoverageOfLlmSpans: true, requireOutcome: true }`.\n * Override (e.g. `{ llmSpansMin: 0 }`) for runs that don't call LLMs.\n */\n integrity?: RunIntegrityExpectations\n /** Behaviour when integrity fails. Default `'mark_failed'`. */\n onIntegrityFailure?: CampaignIntegrityPolicy\n /**\n * Per-run runner. Receives a fully-wired context; produces an outcome\n * the campaign converts into a `RunRecord`.\n */\n runner: CampaignRunner<V>\n /**\n * If set, the campaign computes `researchReport` at the end. `comparator`\n * is a `variantId`. Other fields are forwarded verbatim.\n */\n report?: { comparator?: string } & Omit<\n ResearchReportOptions,\n 'comparator' | 'preregistrationHash' | 'generatedAt'\n >\n /**\n * Hash of a signed `HypothesisManifest` (see `pre-registration.ts`).\n * Embedded in the campaign fingerprint and the research report.\n */\n preregistrationHash?: string\n /** Local concurrency. Default `1` (sequential). */\n concurrency?: number\n /**\n * Override the time source. Tests pass a mock to make wallMs deterministic.\n */\n now?: () => number\n /** Override the runId generator. Tests pin this. */\n runId?: (params: CampaignFactoryParams) => string\n /**\n * Agent profile cell for campaign runs. Static profiles can pass an object;\n * routers or variant-specific harnesses can pass a factory. The campaign\n * stamps the built cell onto every `RunRecord` and rejects profile/model or\n * profile/prompt contradictions.\n */\n agentProfile?:\n | AgentProfileCell\n | AgentProfileCellInput\n | ((\n params: CampaignFactoryParams & {\n variant: V\n scenarioTags: Record<string, string>\n },\n ) =>\n | AgentProfileCell\n | AgentProfileCellInput\n | Promise<AgentProfileCell | AgentProfileCellInput>)\n}\n\nexport interface CampaignFactoryParams {\n campaignId: string\n runId: string\n variantId: string\n scenarioId: string\n seed: number\n}\n\nexport interface FailedRun {\n runId: string\n variantId: string\n scenarioId: string\n seed: number\n reason: string\n error?: string\n}\n\nexport interface EvalCampaignResult {\n campaignId: string\n /** SHA-256 over canonicalised `(variantIds, scenarioIds, seeds, comparator, splitTag, executionRef, preregistrationHash)`. */\n campaignFingerprint: string\n preregistrationHash: string | null\n /** Successful runs only. Failed runs land in `failedRuns`. */\n runs: RunRecord[]\n /** Integrity reports for every successful run. */\n integrityReports: RunIntegrityReport[]\n failedRuns: FailedRun[]\n /** Computed when `report` is set on options. */\n report?: ResearchReport\n startedAt: string\n endedAt: string\n}\n\n// ── Implementation ───────────────────────────────────────────────────────\n\nconst DEFAULT_INTEGRITY: RunIntegrityExpectations = {\n llmSpansMin: 1,\n requireRawCoverageOfLlmSpans: true,\n requireOutcome: true,\n}\n\ntype CampaignCell<V> = { variant: CampaignVariant<V>; scenario: CampaignScenario; seed: number }\n\ntype CampaignRunResult = { record: RunRecord; integrity: RunIntegrityReport }\n\n/** Resolved options shared by every step of one campaign. */\ninterface CampaignSettings {\n seeds: number[]\n splitTag: RunSplitTag\n concurrency: number\n integrity: RunIntegrityExpectations\n onIntegrityFailure: CampaignIntegrityPolicy\n now: () => number\n executionRef: string | null\n preregistrationHash: string | null\n rawSinkFactory: (params: CampaignFactoryParams) => RawProviderSink\n}\n\n/**\n * Mutable state of one campaign's worker pool.\n *\n * A genuine (non-CellExecutionError) error from any worker is a bug, not a\n * run-level failure. We must NOT let `Promise.all` reject mid-flight and\n * orphan the other workers' in-progress runs (emitters never finalized,\n * sinks/handles leak, partial work silently discarded). Instead: capture the\n * first genuine error, stop dispatching new cells so in-flight workers wind\n * down, finalize every still-open run, then re-throw the aggregated error.\n */\ninterface CampaignPool<V> {\n opts: EvalCampaignOptions<V>\n settings: CampaignSettings\n cells: CampaignCell<V>[]\n cursor: number\n aborting: boolean\n genuineErrors: unknown[]\n /**\n * Emitters for runs that are currently mid-flight, keyed by runId. A worker\n * registers its emitter before invoking the runner and removes it once the\n * run is finalized (via endRun/abortRun, success or failure). Anything left\n * here after the pool settles is an orphan we must abort.\n */\n openRuns: Map<string, TraceEmitter>\n runs: RunRecord[]\n integrityReports: RunIntegrityReport[]\n failedRuns: FailedRun[]\n}\n\nexport async function runEvalCampaign<V>(\n opts: EvalCampaignOptions<V>,\n): Promise<EvalCampaignResult> {\n assertCampaignPreflight(opts)\n const settings = resolveCampaignSettings(opts)\n const campaignFingerprint = await fingerprintCampaign(opts, settings)\n\n const startedAt = new Date(settings.now()).toISOString()\n const pool: CampaignPool<V> = {\n opts,\n settings,\n cells: planCampaignCells(opts, settings.seeds),\n cursor: 0,\n aborting: false,\n genuineErrors: [],\n openRuns: new Map(),\n runs: [],\n integrityReports: [],\n failedRuns: [],\n }\n await drainCampaignPool(pool)\n\n const report = await buildCampaignReport(opts, settings, pool.runs)\n const endedAt = new Date(settings.now()).toISOString()\n\n return {\n campaignId: opts.campaignId,\n campaignFingerprint,\n preregistrationHash: settings.preregistrationHash,\n runs: pool.runs,\n integrityReports: pool.integrityReports,\n failedRuns: pool.failedRuns,\n report,\n startedAt,\n endedAt,\n }\n}\n\n/** Reject structurally invalid campaigns before any work starts. */\nfunction assertCampaignPreflight<V>(opts: EvalCampaignOptions<V>): void {\n if (opts.variants.length === 0) {\n throw new Error('runEvalCampaign: variants must be non-empty.')\n }\n if (opts.scenarios.length === 0) {\n throw new Error('runEvalCampaign: scenarios must be non-empty.')\n }\n const variantIds = new Set<string>()\n for (const v of opts.variants) {\n if (variantIds.has(v.id)) {\n throw new Error(`runEvalCampaign: duplicate variant id \"${v.id}\".`)\n }\n variantIds.add(v.id)\n }\n const scenarioIds = new Set<string>()\n for (const s of opts.scenarios) {\n if (scenarioIds.has(s.scenarioId)) {\n throw new Error(`runEvalCampaign: duplicate scenarioId \"${s.scenarioId}\".`)\n }\n scenarioIds.add(s.scenarioId)\n }\n if (opts.report?.comparator && !variantIds.has(opts.report.comparator)) {\n throw new Error(\n `runEvalCampaign: report.comparator \"${opts.report.comparator}\" is not a configured variantId.`,\n )\n }\n if (!opts.commitSha) {\n throw new Error('runEvalCampaign: commitSha is required (every RunRecord needs it).')\n }\n}\n\n/** Apply defaults to the optional campaign options. */\nfunction resolveCampaignSettings<V>(opts: EvalCampaignOptions<V>): CampaignSettings {\n return {\n seeds: opts.seeds ?? [0, 1, 2],\n splitTag: opts.splitTag ?? 'holdout',\n concurrency: Math.max(1, opts.concurrency ?? 1),\n integrity: { ...DEFAULT_INTEGRITY, ...(opts.integrity ?? {}) },\n onIntegrityFailure: opts.onIntegrityFailure ?? 'mark_failed',\n now: opts.now ?? (() => Date.now()),\n executionRef: opts.executionRef ?? null,\n preregistrationHash: opts.preregistrationHash ?? null,\n rawSinkFactory: opts.rawSinkFactory ?? defaultRawSinkFactory(opts.workDir),\n }\n}\n\n/** SHA-256 over the canonicalised matrix definition. */\nfunction fingerprintCampaign<V>(\n opts: EvalCampaignOptions<V>,\n settings: CampaignSettings,\n): Promise<string> {\n return hashJson({\n campaignId: opts.campaignId,\n variants: opts.variants.map((v) => v.id).sort(),\n scenarios: opts.scenarios.map((s) => s.scenarioId).sort(),\n seeds: [...settings.seeds].sort((a, b) => a - b),\n splitTag: settings.splitTag,\n comparator: opts.report?.comparator ?? null,\n executionRef: settings.executionRef,\n preregistrationHash: settings.preregistrationHash,\n })\n}\n\n/** Expand variants x scenarios x seeds, variant-major. */\nfunction planCampaignCells<V>(opts: EvalCampaignOptions<V>, seeds: number[]): CampaignCell<V>[] {\n const cells: CampaignCell<V>[] = []\n for (const variant of opts.variants) {\n for (const scenario of opts.scenarios) {\n for (const seed of seeds) {\n cells.push({ variant, scenario, seed })\n }\n }\n }\n return cells\n}\n\n/**\n * Run the bounded-concurrency worker pool to completion, finalize any run left\n * open, and re-throw the genuine errors the workers captured.\n */\nasync function drainCampaignPool<V>(pool: CampaignPool<V>): Promise<void> {\n const workers = Array.from(\n { length: Math.min(pool.settings.concurrency, pool.cells.length) },\n () => campaignWorker(pool),\n )\n // allSettled (not all): a genuine error in one worker must not reject the\n // pool mid-flight and orphan the others. Each worker captures its own\n // genuine error into `genuineErrors` and returns; we re-throw below.\n await Promise.allSettled(workers)\n\n // Finalize any run still open after the pool wound down. With the\n // stop-dispatch flag these are the runs that were mid-flight in peer workers\n // when the first genuine error fired — abort them so their emitters finalize\n // (hooks fire, store records a terminal status) instead of leaking.\n for (const [runId, emitter] of pool.openRuns) {\n await finalizeAbort(emitter, runId, 'campaign aborted: genuine error in a sibling run')\n }\n pool.openRuns.clear()\n\n if (pool.genuineErrors.length > 0) {\n throw pool.genuineErrors.length === 1\n ? pool.genuineErrors[0]\n : new AggregateError(\n pool.genuineErrors,\n `runEvalCampaign: ${pool.genuineErrors.length} runs failed with genuine (non-run-level) errors`,\n )\n }\n}\n\n/** Pull cells off the shared cursor until none remain or the pool is aborting. */\nasync function campaignWorker<V>(pool: CampaignPool<V>): Promise<void> {\n while (!pool.aborting) {\n const i = pool.cursor++\n if (i >= pool.cells.length) return\n const cell = pool.cells[i]!\n try {\n const result = await runCampaignCell(pool, cell)\n pool.runs.push(result.record)\n pool.integrityReports.push(result.integrity)\n } catch (err) {\n if (err instanceof CellExecutionError) {\n pool.failedRuns.push(err.failed)\n if (err.integrity) pool.integrityReports.push(err.integrity)\n } else {\n // Genuine bug — not a runner failure, not an integrity failure.\n // Capture it and stop dispatching so peers wind down gracefully;\n // re-thrown after the pool settles. Do not surface here — that would\n // reject Promise.all and orphan the other workers' runs.\n pool.genuineErrors.push(err)\n pool.aborting = true\n return\n }\n }\n }\n}\n\n/** Run one matrix cell: runner, integrity check, then the validated RunRecord. */\nasync function runCampaignCell<V>(\n pool: CampaignPool<V>,\n cell: CampaignCell<V>,\n): Promise<CampaignRunResult> {\n const { opts, settings } = pool\n const runId = (opts.runId ?? defaultRunId)({\n campaignId: opts.campaignId,\n runId: '', // unused by default generator\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n })\n const factoryParams: CampaignFactoryParams = {\n campaignId: opts.campaignId,\n runId,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n }\n const store = opts.storeFactory(factoryParams)\n const rawSink = settings.rawSinkFactory(factoryParams)\n\n const emitter = new TraceEmitter(store, {\n runId,\n now: opts.now,\n onRunComplete: opts.onRunComplete,\n })\n // Track this run as open so a genuine error elsewhere in the pool can\n // finalize it instead of orphaning it. Removed in the finally below.\n pool.openRuns.set(runId, emitter)\n\n const chat = opts.chatFactory({ rawSink, runId })\n\n const ctx: CampaignRunContext<V> = {\n runId,\n experimentId: opts.campaignId,\n variant: cell.variant.payload,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n scenarioTags: cell.scenario.tags ?? {},\n seed: cell.seed,\n splitTag: settings.splitTag,\n emitter,\n store,\n rawSink,\n chat,\n }\n\n try {\n const wallStart = settings.now()\n const outcome = await invokeCampaignRunner(opts, cell, ctx)\n const wallMs = settings.now() - wallStart\n\n const integrityReport = await assertRunCaptured(store, runId, {\n ...settings.integrity,\n rawSink,\n })\n if (!integrityReport.ok) admitOrRejectIntegrity(settings, cell, runId, integrityReport)\n\n const record = buildCampaignRunRecord(opts, settings, cell, runId, outcome, wallMs)\n await stampAgentProfile(opts, cell, record, runId, outcome)\n return { record: validateRunRecord(record), integrity: integrityReport }\n } finally {\n // This run's worker has finished with it (success, run-level failure, or\n // genuine error). It is no longer the pool's job to finalize — drop it so\n // the post-settle sweep doesn't double-abort a finalized run.\n pool.openRuns.delete(runId)\n }\n}\n\n/** Invoke the runner; a throw aborts the run and becomes a run-level failure. */\nasync function invokeCampaignRunner<V>(\n opts: EvalCampaignOptions<V>,\n cell: CampaignCell<V>,\n ctx: CampaignRunContext<V>,\n): Promise<CampaignRunOutcome> {\n try {\n return await opts.runner(ctx)\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n // The runner threw mid-execution. Abort the run so the emitter\n // finalizes. The only benign abortRun failure is \"the runner never\n // started the run\" (nothing to finalize). A store-write failure (disk\n // full, FS error) is a genuine diagnostic — surface it rather than\n // masking it as a plain runner failure.\n await finalizeAbort(ctx.emitter, ctx.runId, message)\n throw new CellExecutionError({\n runId: ctx.runId,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n reason: 'runner_threw',\n error: message,\n })\n }\n}\n\n/** Apply the integrity-failure policy to a report that is not ok. */\nfunction admitOrRejectIntegrity<V>(\n settings: CampaignSettings,\n cell: CampaignCell<V>,\n runId: string,\n integrityReport: RunIntegrityReport,\n): void {\n switch (settings.onIntegrityFailure) {\n case 'throw':\n throw new RunIntegrityError(integrityReport)\n case 'mark_failed':\n throw new CellExecutionError(\n {\n runId,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n reason: 'integrity_failed',\n error: integrityReport.issues.map((i) => i.code).join(', '),\n },\n integrityReport,\n )\n case 'log':\n // Caller wants the run admitted with a flagged report; fall through.\n break\n }\n}\n\n/** Assemble the RunRecord for a successful run, before profile stamping. */\nfunction buildCampaignRunRecord<V>(\n opts: EvalCampaignOptions<V>,\n settings: CampaignSettings,\n cell: CampaignCell<V>,\n runId: string,\n outcome: CampaignRunOutcome,\n wallMs: number,\n): RunRecord {\n const recordOutcome: RunOutcome = {\n raw: outcome.raw ?? {},\n }\n if (settings.splitTag === 'holdout') recordOutcome.holdoutScore = outcome.score\n else recordOutcome.searchScore = outcome.score\n if (outcome.judgeScores !== undefined) recordOutcome.judgeScores = outcome.judgeScores\n\n return {\n runId,\n experimentId: opts.campaignId,\n candidateId: cell.variant.id,\n seed: cell.seed,\n model: outcome.model,\n promptHash: outcome.promptHash,\n configHash: outcome.configHash,\n commitSha: opts.commitSha,\n wallMs,\n costUsd: outcome.costUsd,\n costProvenance: outcome.costProvenance,\n tokenUsage: outcome.tokenUsage,\n terminalOutcome: 'succeeded',\n judgeMetadata: outcome.judgeMetadata,\n outcome: recordOutcome,\n ...(outcome.failureClass ? { failureClass: outcome.failureClass } : {}),\n failureMode: outcome.failureMode,\n splitTag: settings.splitTag,\n scenarioId: cell.scenario.scenarioId,\n }\n}\n\n/** Resolve the run's agent profile (outcome first, then options) and stamp it on the record. */\nasync function stampAgentProfile<V>(\n opts: EvalCampaignOptions<V>,\n cell: CampaignCell<V>,\n record: RunRecord,\n runId: string,\n outcome: CampaignRunOutcome,\n): Promise<void> {\n const profileSource =\n outcome.agentProfile ??\n (typeof opts.agentProfile === 'function'\n ? await opts.agentProfile({\n campaignId: opts.campaignId,\n runId,\n variantId: cell.variant.id,\n scenarioId: cell.scenario.scenarioId,\n seed: cell.seed,\n variant: cell.variant.payload,\n scenarioTags: cell.scenario.tags ?? {},\n })\n : opts.agentProfile)\n if (profileSource !== undefined) {\n const agentProfile = await resolveAgentProfileCell(profileSource)\n assertAgentProfileMatchesRun(agentProfile, outcome.model, outcome.promptHash)\n record.agentProfile = agentProfile\n }\n}\n\n/** Build the optional research report over the successful runs. */\nasync function buildCampaignReport<V>(\n opts: EvalCampaignOptions<V>,\n settings: CampaignSettings,\n runs: RunRecord[],\n): Promise<ResearchReport | undefined> {\n if (!opts.report) return undefined\n const reportOpts: ResearchReportOptions = {\n ...opts.report,\n comparator: opts.report.comparator,\n split: settings.splitTag === 'dev' ? 'search' : settings.splitTag,\n generatedAt: new Date(settings.now()).toISOString(),\n preregistrationHash: settings.preregistrationHash ?? undefined,\n }\n return researchReport(runs, reportOpts)\n}\n\n// ── Internal ─────────────────────────────────────────────────────────────\n\nclass CellExecutionError extends Error {\n readonly failed: FailedRun\n readonly integrity?: RunIntegrityReport\n constructor(failed: FailedRun, integrity?: RunIntegrityReport) {\n super(`cell ${failed.variantId}/${failed.scenarioId}@${failed.seed} failed: ${failed.reason}`)\n this.failed = failed\n this.integrity = integrity\n }\n}\n\n/**\n * Abort a run whose owning work threw or was orphaned by a sibling's genuine\n * error, finalizing the emitter so hooks fire and the store records a terminal\n * status. Safe to call unconditionally: it only aborts runs that are still\n * `running`. Two no-op cases are intentional and benign:\n *\n * - the run was never started (absent from the store) — nothing to finalize\n * - the run is already terminal (`completed` / `failed` / `aborted`) —\n * finalizing again would overwrite the real outcome (e.g. flip a passed run\n * to `aborted` with `{ pass: false, notes: reason }`), so we leave it alone\n *\n * Any OTHER failure of the store read or the abort write (disk full, FS fault,\n * backend down) is a genuine diagnostic and propagates rather than being\n * swallowed.\n */\nasync function finalizeAbort(emitter: TraceEmitter, runId: string, reason: string): Promise<void> {\n const existing = await emitter.traceStore.getRun(runId)\n if (existing === undefined) return // run never started; nothing to abort\n if (existing.status !== 'running') return // already finalized; never overwrite a real outcome\n // The emitter never throws on a failed store write; it counts it. A failed\n // abort write is a genuine diagnostic here, so read the count and surface it.\n const droppedBefore = emitter.captureStats().dropped\n await emitter.abortRun(reason)\n const after = emitter.captureStats()\n if (after.dropped > droppedBefore) {\n throw new Error(`finalizeAbort: run ${runId} could not be finalized: ${after.lastError}`)\n }\n}\n\nfunction defaultRawSinkFactory(workDir: string | undefined) {\n return (params: CampaignFactoryParams): RawProviderSink => {\n if (!workDir) {\n throw new Error(\n 'runEvalCampaign: rawSinkFactory not supplied and workDir not set. Pass either to enable raw provider capture, or pass `new NoopRawProviderSink()` via rawSinkFactory to opt out explicitly.',\n )\n }\n return new FileSystemRawProviderSink({\n dir: `${workDir}/raw-events/${params.runId}`,\n })\n }\n}\n\nasync function resolveAgentProfileCell(\n input: AgentProfileCell | AgentProfileCellInput,\n): Promise<AgentProfileCell> {\n if (isAgentProfileCell(input)) {\n if (!(await verifyAgentProfileCell(input))) {\n throw new Error(`runEvalCampaign: agentProfile.cellId does not match its content`)\n }\n return input\n }\n return buildAgentProfileCell(input)\n}\n\nfunction isAgentProfileCell(\n input: AgentProfileCell | AgentProfileCellInput,\n): input is AgentProfileCell {\n return 'schemaVersion' in input && 'cellId' in input\n}\n\nfunction assertAgentProfileMatchesRun(\n profile: AgentProfileCell,\n model: string,\n promptHash: string,\n): void {\n if (profile.model !== undefined && profile.model !== model) {\n throw new Error(\n `runEvalCampaign: agentProfile.model \"${profile.model}\" does not match outcome.model \"${model}\"`,\n )\n }\n if (profile.promptHash !== undefined && profile.promptHash !== promptHash) {\n throw new Error(\n `runEvalCampaign: agentProfile.promptHash \"${profile.promptHash}\" does not match outcome.promptHash \"${promptHash}\"`,\n )\n }\n}\n\nfunction defaultRunId(params: CampaignFactoryParams): string {\n // Stable across re-runs: fingerprint of (campaignId, variantId, scenarioId, seed).\n // Caller can override via opts.runId for non-deterministic IDs.\n const base = `${params.campaignId}::${params.variantId}::${params.scenarioId}::${params.seed}`\n // TWO 32-bit FNV-1a accumulators with different offsets, concatenated for a\n // 64-bit-wide id. Not crypto-grade; stability and uniqueness are what this\n // needs. Frozen: the value names a persisted cell, and the second\n // accumulator's offset is part of the identity, so no single-accumulator\n // helper can replace it.\n let h1 = 0x811c9dc5\n let h2 = 0x12345678\n for (let i = 0; i < base.length; i++) {\n const c = base.charCodeAt(i)\n h1 = Math.imul(h1 ^ c, 0x01000193) >>> 0\n h2 = Math.imul(h2 ^ c, 0x9e3779b1) >>> 0\n }\n return `run-${h1.toString(16).padStart(8, '0')}${h2.toString(16).padStart(8, '0')}`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8SA,MAAM,oBAA8C;CAClD,aAAa;CACb,8BAA8B;CAC9B,gBAAgB;AAClB;AAgDA,eAAsB,gBACpB,MAC6B;CAC7B,wBAAwB,IAAI;CAC5B,MAAM,WAAW,wBAAwB,IAAI;CAC7C,MAAM,sBAAsB,MAAM,oBAAoB,MAAM,QAAQ;CAEpE,MAAM,YAAY,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,YAAY;CACvD,MAAM,OAAwB;EAC5B;EACA;EACA,OAAO,kBAAkB,MAAM,SAAS,KAAK;EAC7C,QAAQ;EACR,UAAU;EACV,eAAe,CAAC;EAChB,0BAAU,IAAI,IAAI;EAClB,MAAM,CAAC;EACP,kBAAkB,CAAC;EACnB,YAAY,CAAC;CACf;CACA,MAA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ACM;CACN,IAAI,QAAQ,UAAU,KAAA,KAAa,QAAQ,UAAU,OACnD,MAAM,IAAI,MACR,wCAAwC,QAAQ,MAAM,kCAAkC,MAAM,EAChG;CAEF,IAAI,QAAQ,eAAe,KAAA,KAAa,QAAQ,eAAe,YAC7D,MAAM,IAAI,MACR,6CAA6C,QAAQ,WAAW,uCAAuC,WAAW,EACpH;AAEJ;AAEA,SAAS,aAAa,QAAuC;CAG3D,MAAM,OAAO,GAAG,OAAO,WAAW,IAAI,OAAO,UAAU,IAAI,OAAO,WAAW,IAAI,OAAO;CAMxF,IAAI,KAAK;CACT,IAAI,KAAK;CACT,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,IAAI,KAAK,WAAW,CAAC;EAC3B,KAAK,KAAK,KAAK,KAAK,GAAG,QAAU,MAAM;EACvC,KAAK,KAAK,KAAK,KAAK,GAAG,UAAU,MAAM;CACzC;CACA,OAAO,OAAO,GAAG,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,IAAI,GAAG,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;AAClF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-YS58LHlx.d.ts","names":[],"sources":["../src/cost-ledger/errors.ts","../src/cost-ledger/pricing.ts","../src/llm-client/accounting.ts","../src/llm-client/errors.ts","../src/llm-client/json.ts","../src/llm-client/resilience.ts","../src/analyst/policy-edit.ts","../src/capability-headroom.ts","../src/cost-tracker.ts","../src/detectors/index.ts","../src/error-count-extractor.ts","../src/knowledge/types.ts","../src/leaderboard.ts","../src/paired-delta-test.ts","../src/partition-held-out.ts","../src/product-benchmark/export.ts","../src/product-benchmark/index.ts","../src/runtime-trajectory.ts","../src/active-learning.ts","../src/bounded-process.ts","../src/command-runner.ts","../src/discover-personas.ts","../src/improvement-verdict.ts","../src/propose-review.ts","../src/reflective-mutation.ts","../src/eval-trace-store.ts","../src/integrity/preflight.ts","../src/model-seats.ts","../src/prompt-registry.ts","../src/reference-replay.ts","../src/steering.ts","../src/run-score.ts","../src/steering-optimizer.ts","../src/counterfactual.ts","../src/scorecard.ts","../src/trace-contracts/types.ts","../src/trace-contracts/builder.ts","../src/trace-contracts/evaluate.ts","../src/trace-contracts/explain.ts","../src/trace-contracts/spec.ts","../src/action-policy.ts","../src/contamination-guard.ts","../src/deploy-gate-layer.ts","../src/hidden-criteria-grading.ts","../src/integrity/single-backend.ts","../src/intent-match-judge.ts","../src/judge-ensemble.ts","../src/judge-retry.ts","../src/judge-panel.ts","../src/keyword-coverage-judge.ts","../src/oracle.ts","../src/paired-promotion-power.ts","../src/treatment-gate.ts","../src/verdict-cache.ts","../src/profile/baselines.ts","../src/profile/index.ts","../src/budget-guard.ts","../src/client.ts","../src/control-runtime.ts","../src/control-runtime/policy.ts","../src/knowledge/readiness.ts","../src/metrics.ts","../src/anti-slop.ts","../src/sandbox-assertions.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAMa,gCAAgC;EAEzC,YAAA,oBACA,sBACA,sBACA,eACA;;cAQS,sCAAsC;UCblC;EACf;EACA;;iBAGc,aAAa,eAAe,OAAO,YAAY;;iBAc/C,oBACd,SAAS,oBACT,OAAO,KAAK;iBCtBE,2BACd,SAAS,KACP,0GAGF,UAAS,kBACR;;;;;;iBAoCa,mBACd,QAAQ,eACR,qBAAqB,qBACpB;;iBA6Ba,wBACd,OAAO,OACP,qBAAqB,qBACpB;cChFU,qBAAqB;WAGd;WACA;WACA;EAHhB,YAAA,iBACgB,gBACA,cACA;;;;;cASP,yBAAyB;WAGlB,QAAQ;EADxB,YAAA,iBACgB,QAAQ,eACxB;IAAY;;;;;;;;iBCXA,gBAAgB;;;;;;;;;;;;iBCgFhB,oBAAoB;KClFxB;cAEN;KAaM,yBAAyB;cAE/B;KAUM,kCAAkC;KAClC;KACA;KACA;UAEK;EACf,SAAS;;;EAGT;;;EAGA,mBAAmB;;EAEnB;;KAGU;EAEN;EACA;E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ts","names":[],"sources":["../src/multishot/types.ts","../src/multishot/judges.ts","../src/multishot/multishot.ts","../src/multishot/matrix.ts"],"mappings":";;;;UAIiB;EACf;EACA;EACA;EACA,YAAY;IAAQ;IAAY;IAAc,MAAM;;;UAGrC;EACf;EACA;EACA;IAAc;IAAc,MAAM;;EAClC;;UAGe;EACf,YAAY;EACZ,WAAW;EACX;EACA;;;EAGA;;;;;;;;EAQA,iBAAiB;;UAGF;EACf;EACA;IACE;IACA;IACA,YAAY;;;;;;UAOC;EACf;EACA,UAAU,MAAM;EAChB,QAAQ;EACR;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;IAAY;IAAc;;;UAGX;EACf;IAAW;IAAyB,aAAa;;EACjD;IAAU;IAAwB;;;;EAGlC;;;;EAIA;;;;;;;;KASU,sBACV,KAAK,8BACF,QAAQ;KAED,yBACV,MAAM,yBACN;;EAEE,WAAW;EACX,SAAS;MAER;EAAU;EAAiB;;UAEf;;EAEf;;GAEC;;;;;;;;UASc,eAAe,iBAAiB;;EAE/C,eAAe,SAAS;;;EAGxB,2BAA2B,SAAS;;cAGzB,kCAAkC;WACjB;EAAA,YAAA;;cAMjB,gCAAgC;EAC/B,YAAA;;;;;;;;;;;;;;;;;;;iBAgCE,0BAA0B,yBAAyB,SAAS;cCvI/D;UAEI,qBAAqB;;EAEpC;;;EAGA,WAAW;;EAEX;;EAEA,YAAY;;EAEZ;;;EAGA,cAAc,OAAO;;EAErB;;UAGe;;EAEf,OAAO;;EAEP,MAAM;;iBAGc,SAAS,QAC7B,OAAO,qBAAqB,SAC5B,OAAO,SACN,QAAQ;;;iBAsIK,iBAAiB,eAAe;;iBAKhC,iBAAiB,eAAe;UCxK/B,oBAAoB,iBAAiB;EACpD,SAAS;EACT,SAAS;;;EAGT,QAAQ,eAAe;;EAEvB,QAAQ;;EAER,gBAAgB,eAAe;;;;EAI/B,mBAAmB;EACnB;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;EAGA,gBAAg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
6
- output: .01
7
- },
8
- "gpt-4o-mini": {
9
- input: 15e-5,
10
- output: 6e-4
11
- },
12
- "gpt-4-turbo": {
13
- input: .01,
14
- output: .03
15
- },
16
- "claude-sonnet-4-20250514": {
17
- input: .003,
18
- output: .015
19
- },
20
- "claude-opus-4-20250514": {
21
- input: .015,
22
- output: .075
23
- },
24
- "claude-3-haiku-20240307": {
25
- input: 25e-5,
26
- output: .00125
27
- },
28
- "glm-5.3": {
29
- input: .00168,
30
- output: .00528
31
- },
32
- "gpt-6-luna": {
33
- input: 1e-4,
34
- output: 5e-4
35
- },
36
- "gpt-5-mini": {
37
- input: 25e-5,
38
- output: .002
39
- }
40
- };
41
- /** Family-level pricing fallbacks (per-1K), matched against a normalized id
42
- * after exact lookup misses. Ordered — first match wins. Covers the model
43
- * ids actually used through the Tangle router + cli-bridge harnesses, none
44
- * of which appear in the exact table above — without this they priced to a
45
- * silent $0, blanking every cost/Pareto axis downstream. */
46
- const FAMILY_PRICING = [
47
- [/^stealth\//, {
48
- input: 0,
49
- output: 0
50
- }],
51
- [/claude.*opus/, {
52
- input: .015,
53
- output: .075
54
- }],
55
- [/claude.*haiku/, {
56
- input: 8e-4,
57
- output: .004
58
- }],
59
- [/claude.*sonnet|claude-code|claude-sonnet/, {
60
- input: .003,
61
- output: .015
62
- }],
63
- [/gpt-4o-mini/, {
64
- input: 15e-5,
65
- output: 6e-4
66
- }],
67
- [/gpt-5|gpt-4\.1|o[134]\b/, {
68
- input: .00125,
69
- output: .01
70
- }],
71
- [/gpt-4o|gpt-4/, {
72
- input: .0025,
73
- output: .01
74
- }],
75
- [/deepseek/, {
76
- input: 3e-4,
77
- output: .0011
78
- }],
79
- [/glm|zhipu|zai/, {
80
- input: 6e-4,
81
- output: .0022
82
- }],
83
- [/kimi|moonshot/, {
84
- input: 6e-4,
85
- output: .0025
86
- }],
87
- [/qwen/, {
88
- input: 4e-4,
89
- output: .0012
90
- }],
91
- [/gemini.*flash/, {
92
- input: 1e-4,
93
- output: 4e-4
94
- }],
95
- [/gemini/, {
96
- input: .00125,
97
- output: .005
98
- }],
99
- [/llama/, {
100
- input: 2e-4,
101
- output: 6e-4
102
- }]
103
- ];
104
- /** Normalize a model id for pricing: drop `@snapshot` and trailing
105
- * `-YYYY-MM-DD` dated-snapshot suffixes, lowercase, and return the complete
106
- * id plus its final served-model segment for exact-row lookup. */
107
- function normalizedModelIds(model) {
108
- const id = (model.split("@")[0] ?? model).trim().toLowerCase().replace(/-(?:19|20)\d{2}-\d{2}-\d{2}$/, "");
109
- const finalSegment = id.slice(id.lastIndexOf("/") + 1);
110
- return finalSegment === id ? [id] : [id, finalSegment];
111
- }
112
- /** Resolve pricing for a model id: exact table, then family fallback.
113
- * Returns null when the id matches nothing (caller decides — never a
114
- * silent-zero masquerading as a real $0 cost). */
115
- function resolveModelPricing(model) {
116
- if (MODEL_PRICING[model]) return MODEL_PRICING[model];
117
- const ids = normalizedModelIds(model);
118
- for (const id of ids) if (MODEL_PRICING[id]) return MODEL_PRICING[id];
119
- for (const [pattern, price] of FAMILY_PRICING) if (ids.some((id) => pattern.test(id))) return price;
120
- return null;
121
- }
122
- /** True when `model` has known pricing: distinguishes a real $0 from unpriced. */
123
- function isModelPriced(model) {
124
- return resolveModelPricing(model) !== null;
125
- }
126
- const warnedUnpricedModels = /* @__PURE__ */ new Set();
127
- /** Estimate token count from string length (chars / 4 approximation) */
128
- function estimateTokens(text) {
129
- return Math.ceil(text.length / 4);
130
- }
131
- /** Calculate cost in USD from token counts and model. Unknown models warn once
132
- * (not a silent zero) and return 0; cost-sensitive callers gate on {@link isModelPriced}. */
133
- function estimateCost(inputTokens, outputTokens, model) {
134
- const pricing = resolveModelPricing(model);
135
- if (!pricing) {
136
- if (!warnedUnpricedModels.has(model)) {
137
- warnedUnpricedModels.add(model);
138
- console.warn(`estimateCost: no pricing for "${model}" — returning 0; add it to MODEL_PRICING`);
139
- }
140
- return 0;
141
- }
142
- return inputTokens / 1e3 * pricing.input + outputTokens / 1e3 * pricing.output;
143
- }
144
- export { resolveModelPricing as a, isModelPriced as i, estimateCost as n, estimateTokens as r, MODEL_PRICING as t };
145
-
146
- //# sourceMappingURL=metrics-zALlR17s.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"metrics-zALlR17s.js","names":[],"sources":["../src/metrics.ts"],"sourcesContent":["interface TokenPrice {\n input: number\n output: number\n}\n\n/** Per-1K token pricing for exact model ids. */\nexport const MODEL_PRICING: Record<string, TokenPrice> = {\n 'gpt-4o': { input: 0.0025, output: 0.01 },\n 'gpt-4o-mini': { input: 0.00015, output: 0.0006 },\n 'gpt-4-turbo': { input: 0.01, output: 0.03 },\n 'claude-sonnet-4-20250514': { input: 0.003, output: 0.015 },\n 'claude-opus-4-20250514': { input: 0.015, output: 0.075 },\n 'claude-3-haiku-20240307': { input: 0.00025, output: 0.00125 },\n // Router response-header rates observed for the exact served model on\n // 2026-08-15. Keep this exact row ahead of the deliberately coarse family\n // fallback so glm-5.3 campaign costs are not understated by ~2.5x.\n 'glm-5.3': { input: 0.00168, output: 0.00528 },\n // Tangle Router's published rate (`GET /v1/models`) on 2026-10-09:\n // $0.10 / $0.50 per Mtok. Exact, because the coarse gpt-5 family row would\n // overstate it 12x on input and 20x on output.\n 'gpt-6-luna': { input: 0.0001, output: 0.0005 },\n // Router receipts for the served id `gpt-5-mini-2025-08-07` solve exactly\n // to $0.25 / $2 per Mtok; the gpt-5 family row is 5x too high.\n 'gpt-5-mini': { input: 0.00025, output: 0.002 },\n}\n\n/** Family-level pricing fallbacks (per-1K), matched against a normalized id\n * after exact lookup misses. Ordered — first match wins. Covers the model\n * ids actually used through the Tangle router + cli-bridge harnesses, none\n * of which appear in the exact table above — without this they priced to a\n * silent $0, blanking every cost/Pareto axis downstream. */\nconst FAMILY_PRICING: Array<[RegExp, TokenPrice]> = [\n // OpenRouter stealth previews (`stealth/union-alpha`, …) bill $0 during\n // their preview window. A real zero row lets the budget ledger admit them;\n // an unpriced id is refused before the first call.\n [/^stealth\\//, { input: 0, output: 0 }],\n [/claude.*opus/, { input: 0.015, output: 0.075 }],\n [/claude.*haiku/, { input: 0.0008, output: 0.004 }],\n [/claude.*sonnet|claude-code|claude-sonnet/, { input: 0.003, output: 0.015 }],\n [/gpt-4o-mini/, { input: 0.00015, output: 0.0006 }],\n [/gpt-5|gpt-4\\.1|o[134]\\b/, { input: 0.00125, output: 0.01 }],\n [/gpt-4o|gpt-4/, { input: 0.0025, output: 0.01 }],\n [/deepseek/, { input: 0.0003, output: 0.0011 }],\n [/glm|zhipu|zai/, { input: 0.0006, output: 0.0022 }],\n [/kimi|moonshot/, { input: 0.0006, output: 0.0025 }],\n [/qwen/, { input: 0.0004, output: 0.0012 }],\n [/gemini.*flash/, { input: 0.0001, output: 0.0004 }],\n [/gemini/, { input: 0.00125, output: 0.005 }],\n [/llama/, { input: 0.0002, output: 0.0006 }],\n]\n\n/** Normalize a model id for pricing: drop `@snapshot` and trailing\n * `-YYYY-MM-DD` dated-snapshot suffixes, lowercase, and return the complete\n * id plus its final served-model segment for exact-row lookup. */\nfunction normalizedModelIds(model: string): string[] {\n const stripped = (model.split('@')[0] ?? model).trim().toLowerCase()\n const id = stripped.replace(/-(?:19|20)\\d{2}-\\d{2}-\\d{2}$/, '')\n const finalSegment = id.slice(id.lastIndexOf('/') + 1)\n return finalSegment === id ? [id] : [id, finalSegment]\n}\n\n/** Resolve pricing for a model id: exact table, then family fallback.\n * Returns null when the id matches nothing (caller decides — never a\n * silent-zero masquerading as a real $0 cost). */\nexport function resolveModelPricing(model: string): TokenPrice | null {\n if (MODEL_PRICING[model]) return MODEL_PRICING[model]\n const ids = normalizedModelIds(model)\n for (const id of ids) {\n if (MODEL_PRICING[id]) return MODEL_PRICING[id]\n }\n for (const [pattern, price] of FAMILY_PRICING) {\n if (ids.some((id) => pattern.test(id))) return price\n }\n return null\n}\n\n/** True when `model` has known pricing: distinguishes a real $0 from unpriced. */\nexport function isModelPriced(model: string): boolean {\n return resolveModelPricing(model) !== null\n}\n\nconst warnedUnpricedModels = new Set<string>()\n\n/** Estimate token count from string length (chars / 4 approximation) */\nexport function estimateTokens(text: string): number {\n return Math.ceil(text.length / 4)\n}\n\n/** Calculate cost in USD from token counts and model. Unknown models warn once\n * (not a silent zero) and return 0; cost-sensitive callers gate on {@link isModelPriced}. */\nexport function estimateCost(inputTokens: number, outputTokens: number, model: string): number {\n const pricing = resolveModelPricing(model)\n if (!pricing) {\n if (!warnedUnpricedModels.has(model)) {\n warnedUnpricedModels.add(model)\n console.warn(`estimateCost: no pricing for \"${model}\" — returning 0; add it to MODEL_PRICING`)\n }\n return 0\n }\n return (inputTokens / 1000) * pricing.input + (outputTokens / 1000) * pricing.output\n}\n"],"mappings":";;AAMA,MAAa,gBAA4C;CACvD,UAAU;EAAE,OAAO;EAAQ,QAAQ;CAAK;CACxC,eAAe;EAAE,OAAO;EAAS,QAAQ;CAAO;CAChD,eAAe;EAAE,OAAO;EAAM,QAAQ;CAAK;CAC3C,4BAA4B;EAAE,OAAO;EAAO,QAAQ;CAAM;CAC1D,0BAA0B;EAAE,OAAO;EAAO,QAAQ;CAAM;CACxD,2BAA2B;EAAE,OAAO;EAAS,QAAQ;CAAQ;CAI7D,WAAW;EAAE,OAAO;EAAS,QAAQ;CAAQ;CAI7C,cAAc;EAAE,OAAO;EAAQ,QAAQ;CAAO;CAG9C,cAAc;EAAE,OAAO;EAAS,QAAQ;CAAM;AAChD;;;;;;AAOA,MAAM,iBAA8C;CAIlD,CAAC,cAAc;EAAE,OAAO;EAAG,QAAQ;CAAE,CAAC;CACtC,CAAC,gBAAgB;EAAE,OAAO;EAAO,QAAQ;CAAM,CAAC;CAChD,CAAC,iBAAiB;EAAE,OAAO;EAAQ,QAAQ;CAAM,CAAC;CAClD,CAAC,4CAA4C;EAAE,OAAO;EAAO,QAAQ;CAAM,CAAC;CAC5E,CAAC,eAAe;EAAE,OAAO;EAAS,QAAQ;CAAO,CAAC;CAClD,CAAC,2BAA2B;EAAE,OAAO;EAAS,QAAQ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