@tangle-network/agent-eval 2.0.7 → 2.0.10

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 (314) hide show
  1. package/CHANGELOG.md +80 -16
  2. package/dist/adapters/http.d.ts +2 -2
  3. package/dist/{agent-profile-CRdalpZv.d.ts → agent-profile-_JzxgLDM.d.ts} +11 -5
  4. package/dist/{agent-profile-CRdalpZv.d.ts.map → agent-profile-_JzxgLDM.d.ts.map} +1 -1
  5. package/dist/analyst/index.d.ts +14 -13
  6. package/dist/analyst/index.d.ts.map +1 -1
  7. package/dist/analyst/index.js +34 -13
  8. package/dist/analyst/index.js.map +1 -1
  9. package/dist/analyze-runs-Izz_ZeWg.d.ts +65 -0
  10. package/dist/analyze-runs-Izz_ZeWg.d.ts.map +1 -0
  11. package/dist/{analyze-runs-C_9cXPZn.js → analyze-runs-xhH2Qxoc.js} +6 -5
  12. package/dist/{analyze-runs-C_9cXPZn.js.map → analyze-runs-xhH2Qxoc.js.map} +1 -1
  13. package/dist/app-grade/index.d.ts +4 -4
  14. package/dist/app-grade/index.js +1 -1
  15. package/dist/{benchmark-command-DkBMUDwy.js → benchmark-command-CGQXNFj7.js} +12 -8
  16. package/dist/benchmark-command-CGQXNFj7.js.map +1 -0
  17. package/dist/benchmarks/index.d.ts +4 -4
  18. package/dist/benchmarks/index.js +4 -4
  19. package/dist/builder-eval/index.js +2 -2
  20. package/dist/calibration-CrORXMWx.d.ts +128 -0
  21. package/dist/calibration-CrORXMWx.d.ts.map +1 -0
  22. package/dist/{calibration-Cfoup0xz.js → calibration-Dz8mQb5P.js} +2 -2
  23. package/dist/{calibration-Cfoup0xz.js.map → calibration-Dz8mQb5P.js.map} +1 -1
  24. package/dist/campaign/index.d.ts +8 -8
  25. package/dist/campaign/index.js +13 -12
  26. package/dist/{campaign-DfSWSreo.js → campaign-eus7YRs2.js} +1590 -15
  27. package/dist/campaign-eus7YRs2.js.map +1 -0
  28. package/dist/{campaign-evidence-BojANgU7.d.ts → campaign-evidence-BOcX4w0r.d.ts} +5 -5
  29. package/dist/{campaign-evidence-BojANgU7.d.ts.map → campaign-evidence-BOcX4w0r.d.ts.map} +1 -1
  30. package/dist/{campaign-evidence-D_oBFfLc.js → campaign-evidence-KM5GTsHG.js} +5 -5
  31. package/dist/{campaign-evidence-D_oBFfLc.js.map → campaign-evidence-KM5GTsHG.js.map} +1 -1
  32. package/dist/{cluster-Bj90LK-1.d.ts → chat-client-BlTooBDA.d.ts} +9 -241
  33. package/dist/chat-client-BlTooBDA.d.ts.map +1 -0
  34. package/dist/{chat-client-CvyDOQBv.js → chat-client-Oyot5tyo.js} +2 -2
  35. package/dist/{chat-client-CvyDOQBv.js.map → chat-client-Oyot5tyo.js.map} +1 -1
  36. package/dist/{chat-json-call-DMrwmB-k.js → chat-json-call-DTmv2uNY.js} +2 -2
  37. package/dist/{chat-json-call-DMrwmB-k.js.map → chat-json-call-DTmv2uNY.js.map} +1 -1
  38. package/dist/cli.js +7 -7
  39. package/dist/cluster-BJ0nW3P7.d.ts +241 -0
  40. package/dist/cluster-BJ0nW3P7.d.ts.map +1 -0
  41. package/dist/{cluster-bootstrap-DPzVy3_K.js → cluster-bootstrap-CTC8Dd30.js} +3 -2
  42. package/dist/{cluster-bootstrap-DPzVy3_K.js.map → cluster-bootstrap-CTC8Dd30.js.map} +1 -1
  43. package/dist/{completion-verifier-DsotH2l3.js → completion-verifier-CCPG2Yc0.js} +3 -3
  44. package/dist/{completion-verifier-DsotH2l3.js.map → completion-verifier-CCPG2Yc0.js.map} +1 -1
  45. package/dist/{completion-verifier-Cy38EpGE.d.ts → completion-verifier-CQOC3_bm.d.ts} +2 -2
  46. package/dist/{completion-verifier-Cy38EpGE.d.ts.map → completion-verifier-CQOC3_bm.d.ts.map} +1 -1
  47. package/dist/contract/index.d.ts +14 -12
  48. package/dist/contract/index.js +14 -12
  49. package/dist/contract/index.js.map +1 -1
  50. package/dist/{decision-point-C46p-p9v.js → decision-point-CfqtnGop.js} +3 -3
  51. package/dist/{decision-point-C46p-p9v.js.map → decision-point-CfqtnGop.js.map} +1 -1
  52. package/dist/{default-registry-BWFPtmuI.js → default-registry-Rs5uzlfJ.js} +4 -4
  53. package/dist/{default-registry-BWFPtmuI.js.map → default-registry-Rs5uzlfJ.js.map} +1 -1
  54. package/dist/{default-registry-xoX0PMCb.d.ts → default-registry-X8McMoUV.d.ts} +6 -6
  55. package/dist/{default-registry-xoX0PMCb.d.ts.map → default-registry-X8McMoUV.d.ts.map} +1 -1
  56. package/dist/define-agent-eval-D8ntOXqV.js +96 -0
  57. package/dist/define-agent-eval-D8ntOXqV.js.map +1 -0
  58. package/dist/define-agent-eval-DH5-xi-F.d.ts +52 -0
  59. package/dist/define-agent-eval-DH5-xi-F.d.ts.map +1 -0
  60. package/dist/diagnosis/index.d.ts +3 -3
  61. package/dist/diagnosis/index.js +1 -1
  62. package/dist/{dspy-rlm-engine-r7YpKLhS.js → dspy-rlm-engine-ChE1PUM5.js} +3 -3
  63. package/dist/{dspy-rlm-engine-r7YpKLhS.js.map → dspy-rlm-engine-ChE1PUM5.js.map} +1 -1
  64. package/dist/{emitter-BjW3NnX-.js → emitter-xN9wGTVw.js} +9 -2
  65. package/dist/{emitter-BjW3NnX-.js.map → emitter-xN9wGTVw.js.map} +1 -1
  66. package/dist/{eval-campaign-Cyk-tkLh.js → eval-campaign-BciGnrGy.js} +3 -3
  67. package/dist/{eval-campaign-Cyk-tkLh.js.map → eval-campaign-BciGnrGy.js.map} +1 -1
  68. package/dist/{evaluation-X5E22NQK.d.ts → evaluation-CjZH6gW0.d.ts} +4 -4
  69. package/dist/{evaluation-X5E22NQK.d.ts.map → evaluation-CjZH6gW0.d.ts.map} +1 -1
  70. package/dist/evaluation.d.ts +1 -1
  71. package/dist/{exact-types-DjuabhUV.d.ts → exact-types-BIHqYBYf.d.ts} +2 -2
  72. package/dist/{exact-types-DjuabhUV.d.ts.map → exact-types-BIHqYBYf.d.ts.map} +1 -1
  73. package/dist/{execution-insight-CE20Bxq0.d.ts → execution-insight-YihQrSqd.d.ts} +2 -2
  74. package/dist/{execution-insight-CE20Bxq0.d.ts.map → execution-insight-YihQrSqd.d.ts.map} +1 -1
  75. package/dist/experiment/index.d.ts +5 -5
  76. package/dist/experiment/index.js +10 -184
  77. package/dist/experiment/index.js.map +1 -1
  78. package/dist/{external-optimizer-contracts-ZDBfbZ_s.js → external-optimizer-contracts-BFV8lnhl.js} +7 -2
  79. package/dist/{external-optimizer-contracts-ZDBfbZ_s.js.map → external-optimizer-contracts-BFV8lnhl.js.map} +1 -1
  80. package/dist/{external-optimizer-process-4QdcF7Kd.js → external-optimizer-process-B6emPodQ.js} +3 -3
  81. package/dist/{external-optimizer-process-4QdcF7Kd.js.map → external-optimizer-process-B6emPodQ.js.map} +1 -1
  82. package/dist/{external-optimizer-subprocess-BW0ZWUUr.js → external-optimizer-subprocess-_O06eDVA.js} +35 -376
  83. package/dist/external-optimizer-subprocess-_O06eDVA.js.map +1 -0
  84. package/dist/{feedback-trajectory-BMkJezPc.d.ts → feedback-trajectory-CoQPmSJV.d.ts} +3 -3
  85. package/dist/{feedback-trajectory-BMkJezPc.d.ts.map → feedback-trajectory-CoQPmSJV.d.ts.map} +1 -1
  86. package/dist/finding-scope-B_As3F_v.js +359 -0
  87. package/dist/finding-scope-B_As3F_v.js.map +1 -0
  88. package/dist/{findings-store-DV8WA5nD.js → findings-store-CvYUzQBR.js} +4 -4
  89. package/dist/{findings-store-DV8WA5nD.js.map → findings-store-CvYUzQBR.js.map} +1 -1
  90. package/dist/fuzz.js +1 -1
  91. package/dist/{index-C6TG1LwA.d.ts → index-BSb3fJyZ.d.ts} +318 -131
  92. package/dist/index-BSb3fJyZ.d.ts.map +1 -0
  93. package/dist/{index-CKjqN9_U.d.ts → index-Bk1XEkP7.d.ts} +99 -3
  94. package/dist/index-Bk1XEkP7.d.ts.map +1 -0
  95. package/dist/{index-DAFZRMlF.d.ts → index-BmWw8zN6.d.ts} +10 -8
  96. package/dist/index-BmWw8zN6.d.ts.map +1 -0
  97. package/dist/{index-DKpMyD_Z.d.ts → index-CCOaNmh2.d.ts} +7 -7
  98. package/dist/{index-DKpMyD_Z.d.ts.map → index-CCOaNmh2.d.ts.map} +1 -1
  99. package/dist/{index-xEM_SoCl.d.ts → index-ZffK_5sD.d.ts} +22 -20
  100. package/dist/index-ZffK_5sD.d.ts.map +1 -0
  101. package/dist/{index-BqAPIToS.d.ts → index-aRalB_Ma.d.ts} +3 -3
  102. package/dist/{index-BqAPIToS.d.ts.map → index-aRalB_Ma.d.ts.map} +1 -1
  103. package/dist/index.d.ts +33 -29
  104. package/dist/index.js +28 -25
  105. package/dist/index.js.map +1 -1
  106. package/dist/{analyze-runs-xjKBBqIB.d.ts → insight-report-DYofCMLx.d.ts} +4 -64
  107. package/dist/insight-report-DYofCMLx.d.ts.map +1 -0
  108. package/dist/{integrity-BF0tJK21.js → integrity-DacT3oJ1.js} +2 -2
  109. package/dist/{integrity-BF0tJK21.js.map → integrity-DacT3oJ1.js.map} +1 -1
  110. package/dist/{integrity-B9320cw1.d.ts → integrity-DotDLWtj.d.ts} +2 -2
  111. package/dist/{integrity-B9320cw1.d.ts.map → integrity-DotDLWtj.d.ts.map} +1 -1
  112. package/dist/{judge-gate-DqlzOBOm.js → judge-gate-CpD3wmcf.js} +3 -3
  113. package/dist/{judge-gate-DqlzOBOm.js.map → judge-gate-CpD3wmcf.js.map} +1 -1
  114. package/dist/{llm-client-Dw4x6EdE.js → llm-client-Dk8lBnMh.js} +15 -2
  115. package/dist/{llm-client-Dw4x6EdE.js.map → llm-client-Dk8lBnMh.js.map} +1 -1
  116. package/dist/llm-judge-DYmEdo3M.js +476 -0
  117. package/dist/llm-judge-DYmEdo3M.js.map +1 -0
  118. package/dist/{matrix-CqZSpwgN.d.ts → matrix-BDl7hoBr.d.ts} +6 -2
  119. package/dist/matrix-BDl7hoBr.d.ts.map +1 -0
  120. package/dist/measure-validity-plan-BReXzcVh.d.ts +201 -0
  121. package/dist/measure-validity-plan-BReXzcVh.d.ts.map +1 -0
  122. package/dist/measure-validity-plan-CJkBNzX_.js +154 -0
  123. package/dist/measure-validity-plan-CJkBNzX_.js.map +1 -0
  124. package/dist/meta-eval/index.d.ts +5 -3
  125. package/dist/meta-eval/index.js +808 -15
  126. package/dist/meta-eval/index.js.map +1 -1
  127. package/dist/multishot/golden/index.d.ts +1 -1
  128. package/dist/multishot/index.d.ts +497 -4
  129. package/dist/multishot/index.d.ts.map +1 -1
  130. package/dist/multishot/index.js +1000 -48
  131. package/dist/multishot/index.js.map +1 -1
  132. package/dist/node-transport-DJno8V46.js +62 -0
  133. package/dist/node-transport-DJno8V46.js.map +1 -0
  134. package/dist/openapi.json +1 -1
  135. package/dist/{llm-judge-DQJTQx01.js → optimization-method-4JlbMxd2.js} +38 -513
  136. package/dist/optimization-method-4JlbMxd2.js.map +1 -0
  137. package/dist/{outcome-observations-DL3CC8w1.js → outcome-observations-DEh8_V_P.js} +31 -6
  138. package/dist/outcome-observations-DEh8_V_P.js.map +1 -0
  139. package/dist/outcome-store-CHtuvstd.d.ts +56 -0
  140. package/dist/outcome-store-CHtuvstd.d.ts.map +1 -0
  141. package/dist/{paired-arms-DZhH3FGu.js → paired-arms-CJH5Q0wx.js} +3 -2
  142. package/dist/{paired-arms-DZhH3FGu.js.map → paired-arms-CJH5Q0wx.js.map} +1 -1
  143. package/dist/{paired-promotion-decision-Dn3-jaq4.js → paired-promotion-decision-BtfVwEAk.js} +3 -2
  144. package/dist/{paired-promotion-decision-Dn3-jaq4.js.map → paired-promotion-decision-BtfVwEAk.js.map} +1 -1
  145. package/dist/{paired-promotion-decision-ChHBuuHV.d.ts → paired-promotion-decision-DJlI4z_k.d.ts} +2 -2
  146. package/dist/{paired-promotion-decision-ChHBuuHV.d.ts.map → paired-promotion-decision-DJlI4z_k.d.ts.map} +1 -1
  147. package/dist/{paired-promotion-power-BlzXdgMD.js → paired-promotion-power-DG1avBKf.js} +3 -3
  148. package/dist/{paired-promotion-power-BlzXdgMD.js.map → paired-promotion-power-DG1avBKf.js.map} +1 -1
  149. package/dist/paired-tests-CXcD_B80.js +688 -0
  150. package/dist/paired-tests-CXcD_B80.js.map +1 -0
  151. package/dist/pareto-DIVE5D0T.js +81 -0
  152. package/dist/pareto-DIVE5D0T.js.map +1 -0
  153. package/dist/pipelines/index.d.ts +2 -1
  154. package/dist/pipelines/index.d.ts.map +1 -1
  155. package/dist/pipelines/index.js +1 -1
  156. package/dist/{sequential-BphITa5b.js → power-COie_o6E.js} +181 -4
  157. package/dist/power-COie_o6E.js.map +1 -0
  158. package/dist/{prime-protocol-Cv6_47rh.d.ts → prime-protocol-BRMk6dGI.d.ts} +2 -2
  159. package/dist/{prime-protocol-Cv6_47rh.d.ts.map → prime-protocol-BRMk6dGI.d.ts.map} +1 -1
  160. package/dist/{promotion-gate-CGkxh36r.d.ts → promotion-gate-B0VTBoXg.d.ts} +2 -2
  161. package/dist/{promotion-gate-CGkxh36r.d.ts.map → promotion-gate-B0VTBoXg.d.ts.map} +1 -1
  162. package/dist/{promotion-policy-CxDIh-9p.js → promotion-policy-BgI7PsQn.js} +4 -4
  163. package/dist/{promotion-policy-CxDIh-9p.js.map → promotion-policy-BgI7PsQn.js.map} +1 -1
  164. package/dist/{proposal-findings-DedMih-u.js → proposal-findings-CfRFCFXS.js} +2 -2
  165. package/dist/{proposal-findings-DedMih-u.js.map → proposal-findings-CfRFCFXS.js.map} +1 -1
  166. package/dist/{registry-CIjC6SdV.d.ts → registry-BeInzotS.d.ts} +4 -4
  167. package/dist/{registry-CIjC6SdV.d.ts.map → registry-BeInzotS.d.ts.map} +1 -1
  168. package/dist/{release-confidence-BLHOMK5Q.js → release-confidence-Cndq1hwi.js} +2 -2
  169. package/dist/{release-confidence-BLHOMK5Q.js.map → release-confidence-Cndq1hwi.js.map} +1 -1
  170. package/dist/reporting.d.ts +5 -5
  171. package/dist/reporting.js +6 -5
  172. package/dist/reporting.js.map +1 -1
  173. package/dist/{research-report-D6XIK0eK.d.ts → research-report-CL5_UqCX.d.ts} +2 -2
  174. package/dist/{research-report-D6XIK0eK.d.ts.map → research-report-CL5_UqCX.d.ts.map} +1 -1
  175. package/dist/{researcher---DhHG4J.d.ts → researcher-BOpZP_Ja.d.ts} +4 -4
  176. package/dist/{researcher---DhHG4J.d.ts.map → researcher-BOpZP_Ja.d.ts.map} +1 -1
  177. package/dist/{reward-hacking-DKAflk2c.js → reward-hacking-DMTm1OBd.js} +2 -2
  178. package/dist/{reward-hacking-DKAflk2c.js.map → reward-hacking-DMTm1OBd.js.map} +1 -1
  179. package/dist/rl.d.ts +9 -8
  180. package/dist/rl.d.ts.map +1 -1
  181. package/dist/rl.js +11 -10
  182. package/dist/rl.js.map +1 -1
  183. package/dist/rollout/index.d.ts +2 -2
  184. package/dist/rollout/index.js +1 -1
  185. package/dist/{rollout-B_lrpd9a.js → rollout--rSr43Pd.js} +2 -2
  186. package/dist/{rollout-B_lrpd9a.js.map → rollout--rSr43Pd.js.map} +1 -1
  187. package/dist/{rollout-nodes-Vas6OSxX.js → rollout-nodes-DFxKpIr2.js} +39 -10
  188. package/dist/rollout-nodes-DFxKpIr2.js.map +1 -0
  189. package/dist/{rubric-predictive-validity--6z0q8s6.js → rubric-predictive-validity-BXJ92Jp_.js} +3 -9
  190. package/dist/rubric-predictive-validity-BXJ92Jp_.js.map +1 -0
  191. package/dist/{rubric-predictive-validity-C9wc7f_D.d.ts → rubric-predictive-validity-DH94_0Q1.d.ts} +3 -56
  192. package/dist/rubric-predictive-validity-DH94_0Q1.d.ts.map +1 -0
  193. package/dist/{run-improvement-loop-BfwOUudy.d.ts → run-improvement-loop-BeHu5D9Z.d.ts} +396 -11
  194. package/dist/run-improvement-loop-BeHu5D9Z.d.ts.map +1 -0
  195. package/dist/{run-record-Bqg0NZ_e.js → run-record-CuO8ErrI.js} +3 -2
  196. package/dist/run-record-CuO8ErrI.js.map +1 -0
  197. package/dist/{runtime-rollouts-drQynu3t.js → runtime-rollouts-CE0MbQPq.js} +55 -8
  198. package/dist/runtime-rollouts-CE0MbQPq.js.map +1 -0
  199. package/dist/search/index.d.ts +2 -2
  200. package/dist/search/index.js +2 -2
  201. package/dist/{search-kernel-DJq9bUDU.d.ts → search-kernel-CJZ-ZSV1.d.ts} +3 -3
  202. package/dist/{search-kernel-DJq9bUDU.d.ts.map → search-kernel-CJZ-ZSV1.d.ts.map} +1 -1
  203. package/dist/{pareto-Bg75Gajo.js → search-kernel-mZc79S6N.js} +6 -88
  204. package/dist/search-kernel-mZc79S6N.js.map +1 -0
  205. package/dist/{search-summary-B1x1Vmzh.js → search-summary-CCgP2qXz.js} +4 -4
  206. package/dist/{search-summary-B1x1Vmzh.js.map → search-summary-CCgP2qXz.js.map} +1 -1
  207. package/dist/{define-agent-eval-Cjc0wWnO.d.ts → self-improve-B1fsNejr.d.ts} +8 -54
  208. package/dist/self-improve-B1fsNejr.d.ts.map +1 -0
  209. package/dist/{define-agent-eval-B6uE3gNu.js → self-improve-C_Bcdmv8.js} +9 -97
  210. package/dist/self-improve-C_Bcdmv8.js.map +1 -0
  211. package/dist/{sequential-BhbTSxpt.d.ts → sequential-CHplorpC.d.ts} +2 -2
  212. package/dist/{sequential-BhbTSxpt.d.ts.map → sequential-CHplorpC.d.ts.map} +1 -1
  213. package/dist/{sequential-ux_XrjBf.js → sequential-DR-pnYQ7.js} +3 -3
  214. package/dist/{sequential-ux_XrjBf.js.map → sequential-DR-pnYQ7.js.map} +1 -1
  215. package/dist/{server-1fzBCxMh.js → server-aZFmRucn.js} +3 -3
  216. package/dist/{server-1fzBCxMh.js.map → server-aZFmRucn.js.map} +1 -1
  217. package/dist/{skillopt-optimization-method-D_swD0Cy.js → skillopt-optimization-method-DHk1K757.js} +95 -40
  218. package/dist/skillopt-optimization-method-DHk1K757.js.map +1 -0
  219. package/dist/{statistical-heldout-CaS4T-43.js → statistical-heldout-CL_7mI5C.js} +3 -3
  220. package/dist/{statistical-heldout-CaS4T-43.js.map → statistical-heldout-CL_7mI5C.js.map} +1 -1
  221. package/dist/{statistics-DSidA5I2.js → statistics-AKnVFnK-.js} +233 -700
  222. package/dist/statistics-AKnVFnK-.js.map +1 -0
  223. package/dist/statistics.d.ts +3 -3
  224. package/dist/statistics.js +3 -2
  225. package/dist/{store-tool-spans-DniaFwjM.d.ts → store-tool-spans-M3WxeRrG.d.ts} +4 -4
  226. package/dist/{store-tool-spans-DniaFwjM.d.ts.map → store-tool-spans-M3WxeRrG.d.ts.map} +1 -1
  227. package/dist/{summary-report-CI4J6gxU.js → summary-report-DyBkOC6V.js} +15 -7
  228. package/dist/summary-report-DyBkOC6V.js.map +1 -0
  229. package/dist/summary-report-figures-CJHygLgw.d.ts.map +1 -1
  230. package/dist/supervisor-run/index.d.ts +12 -2
  231. package/dist/supervisor-run/index.d.ts.map +1 -1
  232. package/dist/supervisor-run/index.js +3 -3
  233. package/dist/{systemone-DzY-2Zri.d.ts → systemone-4PadCE4C.d.ts} +8 -7
  234. package/dist/systemone-4PadCE4C.d.ts.map +1 -0
  235. package/dist/{systemone-review-CXecR_m-.d.ts → systemone-review-DpAXWDkL.d.ts} +2 -2
  236. package/dist/{systemone-review-CXecR_m-.d.ts.map → systemone-review-DpAXWDkL.d.ts.map} +1 -1
  237. package/dist/systemone.d.ts +3 -3
  238. package/dist/systemone.js +1 -1
  239. package/dist/{tool-groups-DF6OqhoG.d.ts → tool-groups-SlnoQNyT.d.ts} +2 -2
  240. package/dist/tool-groups-SlnoQNyT.d.ts.map +1 -0
  241. package/dist/tool-waste-B01AMpID.d.ts +121 -0
  242. package/dist/tool-waste-B01AMpID.d.ts.map +1 -0
  243. package/dist/{tool-waste-u7JJ_BlE.js → tool-waste-BZnYSa6J.js} +3 -2
  244. package/dist/{tool-waste-u7JJ_BlE.js.map → tool-waste-BZnYSa6J.js.map} +1 -1
  245. package/dist/{trace-questions-DO8y3J-E.d.ts → trace-questions-ybyF0B6N.d.ts} +2 -2
  246. package/dist/{trace-questions-DO8y3J-E.d.ts.map → trace-questions-ybyF0B6N.d.ts.map} +1 -1
  247. package/dist/trace-repair/index.d.ts +1 -1
  248. package/dist/trace-repair/index.js +1 -1
  249. package/dist/traces.d.ts +4 -4
  250. package/dist/traces.js +1 -1
  251. package/dist/trajectory-B3o6Ald_.d.ts +100 -0
  252. package/dist/trajectory-B3o6Ald_.d.ts.map +1 -0
  253. package/dist/trajectory-replay/index.js +1 -1
  254. package/dist/{tree-DQMlcNFI.js → tree-CiIe-f3f.js} +6 -4
  255. package/dist/{tree-DQMlcNFI.js.map → tree-CiIe-f3f.js.map} +1 -1
  256. package/dist/{types-fuOwNq1C.d.ts → types-B1W3v8dT.d.ts} +3 -2
  257. package/dist/types-B1W3v8dT.d.ts.map +1 -0
  258. package/dist/{types-BMSDkS8l.d.ts → types-D5XtEH9Q.d.ts} +11 -4
  259. package/dist/{types-BMSDkS8l.d.ts.map → types-D5XtEH9Q.d.ts.map} +1 -1
  260. package/dist/types-DK4vNv5q.js.map +1 -1
  261. package/dist/{types-D_PfKC59.d.ts → types-an-CUndX.d.ts} +2 -2
  262. package/dist/{types-D_PfKC59.d.ts.map → types-an-CUndX.d.ts.map} +1 -1
  263. package/dist/{types-BLv2Ngla.d.ts → types-xVtEOBhO.d.ts} +31 -8
  264. package/dist/types-xVtEOBhO.d.ts.map +1 -0
  265. package/dist/wire/index.d.ts +2 -2
  266. package/dist/wire/index.js +1 -1
  267. package/dist/world/index.d.ts +529 -0
  268. package/dist/world/index.d.ts.map +1 -0
  269. package/dist/world/index.js +1356 -0
  270. package/dist/world/index.js.map +1 -0
  271. package/docs/campaign-proposers.md +7 -0
  272. package/docs/concepts.md +2 -0
  273. package/docs/design/statistics-decisions.md +48 -0
  274. package/docs/eval-surface-map.md +5 -2
  275. package/docs/feature-guide.md +3 -1
  276. package/docs/multi-turn-optimization.md +84 -0
  277. package/docs/outcome-validity.md +108 -0
  278. package/docs/public-api.md +89 -34
  279. package/docs/{multi-shot-optimization.md → trajectory-optimization.md} +1 -1
  280. package/docs/world.md +104 -0
  281. package/package.json +6 -1
  282. package/dist/analyze-runs-xjKBBqIB.d.ts.map +0 -1
  283. package/dist/benchmark-command-DkBMUDwy.js.map +0 -1
  284. package/dist/campaign-DfSWSreo.js.map +0 -1
  285. package/dist/cluster-Bj90LK-1.d.ts.map +0 -1
  286. package/dist/define-agent-eval-B6uE3gNu.js.map +0 -1
  287. package/dist/define-agent-eval-Cjc0wWnO.d.ts.map +0 -1
  288. package/dist/external-optimizer-subprocess-BW0ZWUUr.js.map +0 -1
  289. package/dist/index-C6TG1LwA.d.ts.map +0 -1
  290. package/dist/index-CKjqN9_U.d.ts.map +0 -1
  291. package/dist/index-DAFZRMlF.d.ts.map +0 -1
  292. package/dist/index-xEM_SoCl.d.ts.map +0 -1
  293. package/dist/interval-CWyxqDpE.d.ts +0 -43
  294. package/dist/interval-CWyxqDpE.d.ts.map +0 -1
  295. package/dist/llm-judge-DQJTQx01.js.map +0 -1
  296. package/dist/matrix-CqZSpwgN.d.ts.map +0 -1
  297. package/dist/outcome-observations-DL3CC8w1.js.map +0 -1
  298. package/dist/pareto-Bg75Gajo.js.map +0 -1
  299. package/dist/rollout-nodes-Vas6OSxX.js.map +0 -1
  300. package/dist/rubric-predictive-validity--6z0q8s6.js.map +0 -1
  301. package/dist/rubric-predictive-validity-C9wc7f_D.d.ts.map +0 -1
  302. package/dist/run-improvement-loop-BfwOUudy.d.ts.map +0 -1
  303. package/dist/run-record-Bqg0NZ_e.js.map +0 -1
  304. package/dist/runtime-rollouts-drQynu3t.js.map +0 -1
  305. package/dist/sequential-BphITa5b.js.map +0 -1
  306. package/dist/skillopt-optimization-method-D_swD0Cy.js.map +0 -1
  307. package/dist/statistics-DSidA5I2.js.map +0 -1
  308. package/dist/summary-report-CI4J6gxU.js.map +0 -1
  309. package/dist/systemone-DzY-2Zri.d.ts.map +0 -1
  310. package/dist/tool-groups-DF6OqhoG.d.ts.map +0 -1
  311. package/dist/tool-waste-CIhtU1ad.d.ts +0 -217
  312. package/dist/tool-waste-CIhtU1ad.d.ts.map +0 -1
  313. package/dist/types-BLv2Ngla.d.ts.map +0 -1
  314. package/dist/types-fuOwNq1C.d.ts.map +0 -1
@@ -1,371 +1,17 @@
1
1
  import { c as errorMessage } from "./errors-DeEEV9Vx.js";
2
2
  import { i as assertServedModelPolicy, r as assertServedModel, t as ModelSubstitutionError } from "./served-model-BXmeKm7D.js";
3
- import { a as findingTreatmentSchema, c as findingEvidenceRefSchema, i as findingConditionsSchema, s as findingCalibrationSchema } from "./finding-composition-CyWSTcAY.js";
4
3
  import { t as canonicalJson } from "./verdict-cache-BPaYxfG8.js";
5
- import { c as costForTokenPricing, t as CostLedger } from "./cost-ledger-C5CCidPm.js";
4
+ import { c as costForTokenPricing } from "./cost-ledger-C5CCidPm.js";
6
5
  import { t as deepFreezeCanonicalJson } from "./deep-freeze-CK8-2W7p.js";
7
- import { n as appendSearchLedgerLine, r as tryWithSearchLedgerFileLock } from "./search-ledger-file-QuIbgz6b.js";
8
- import { n as FINDING_SCOPE_FIELDS, t as ANALYST_SEVERITIES } from "./types-_tlhWGUq.js";
9
6
  import { n as isRecord } from "./json-DtvZNAU9.js";
10
- import { d as resolveExternalOptimizerProcessLimits, i as assertJsonValue, o as freezeJsonSnapshot, r as assertExternalOptimizerModelBudget } from "./external-optimizer-contracts-ZDBfbZ_s.js";
7
+ import { a as assertJsonValue, f as resolveExternalOptimizerProcessLimits, i as assertExternalOptimizerModelBudget, r as EXTERNAL_OPTIMIZER_REFUSAL_HEADER, s as freezeJsonSnapshot } from "./external-optimizer-contracts-BFV8lnhl.js";
11
8
  import { t as isNonnegativeFiniteNumber } from "./nonnegative-number-lEYbOsuh.js";
12
- import { createRequire } from "node:module";
13
9
  import { randomBytes } from "node:crypto";
14
- import { z } from "zod";
15
10
  import { isAbsolute, join, resolve } from "node:path";
16
11
  import { tmpdir } from "node:os";
17
12
  import { spawn } from "node:child_process";
18
13
  import { lstat, mkdtemp, open, rm, writeFile } from "node:fs/promises";
19
14
  import { createServer } from "node:http";
20
- // src/campaign/storage.ts
21
- /** Node-filesystem storage — the default. Lazily requires `node:fs` so the
22
- * module imports cleanly in non-Node runtimes (where the caller passes
23
- * `inMemoryCampaignStorage` instead and never constructs this).
24
- *
25
- * `createRequire(import.meta.url)` is the ESM-native lazy require — a bare
26
- * `require` is a ReferenceError under `"type": "module"`, which is exactly
27
- * the shape this package publishes. */
28
- function fsCampaignStorage() {
29
- const { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } = createRequire(import.meta.url)("node:fs");
30
- return {
31
- kind: "filesystem",
32
- ensureDir(dir) {
33
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
34
- },
35
- exists(path) {
36
- return existsSync(path);
37
- },
38
- read(path) {
39
- try {
40
- return readFileSync(path, "utf8");
41
- } catch {
42
- return;
43
- }
44
- },
45
- write(path, content) {
46
- writeFileSync(path, content);
47
- },
48
- append(path, content, expectedBytes) {
49
- const result = tryWithSearchLedgerFileLock(path, () => {
50
- let actualBytes = 0;
51
- try {
52
- actualBytes = statSync(path).size;
53
- } catch (error) {
54
- if (error.code !== "ENOENT") throw error;
55
- }
56
- if (actualBytes !== expectedBytes) return void 0;
57
- appendSearchLedgerLine(path, content);
58
- return expectedBytes + Buffer.byteLength(content);
59
- });
60
- return result.acquired ? result.value : void 0;
61
- }
62
- };
63
- }
64
- /** In-memory storage for filesystem-less runtimes. Artifacts + trace spans
65
- * live in a `Map` for the duration of the run; the `CampaignResult` is
66
- * fully populated, but nothing is persisted to disk. */
67
- function inMemoryCampaignStorage() {
68
- const files = /* @__PURE__ */ new Map();
69
- const dirs = /* @__PURE__ */ new Set();
70
- return {
71
- kind: "memory",
72
- ensureDir(dir) {
73
- dirs.add(dir);
74
- },
75
- exists(path) {
76
- return files.has(path) || dirs.has(path);
77
- },
78
- read(path) {
79
- const value = files.get(path);
80
- if (value === void 0) return void 0;
81
- return typeof value === "string" ? value : new TextDecoder().decode(value);
82
- },
83
- write(path, content) {
84
- files.set(path, content);
85
- },
86
- append(path, content, expectedBytes) {
87
- const current = files.get(path);
88
- const currentText = current === void 0 ? "" : typeof current === "string" ? current : new TextDecoder().decode(current);
89
- const currentBytes = new TextEncoder().encode(currentText).byteLength;
90
- if (currentBytes !== expectedBytes) return void 0;
91
- files.set(path, `${currentText}${content}`);
92
- return currentBytes + new TextEncoder().encode(content).byteLength;
93
- }
94
- };
95
- }
96
- /** Open the durable spend account stored beside a logical run. */
97
- function createRunCostLedger(input) {
98
- const path = join(input.runDir, "cost-ledger.jsonl");
99
- if (input.ensureRunDir ?? true) input.storage.ensureDir(input.runDir);
100
- return new CostLedger({
101
- costCeilingUsd: input.costCeilingUsd,
102
- persistence: {
103
- read: () => {
104
- const stored = input.storage.read(path);
105
- if (stored === void 0 && input.storage.exists(path)) throw new Error(`CostLedger: cannot read existing event log '${path}'`);
106
- const events = stored ?? "";
107
- return {
108
- revision: String(new TextEncoder().encode(events).byteLength),
109
- events
110
- };
111
- },
112
- append: (expectedRevision, event) => {
113
- const expectedBytes = Number(expectedRevision);
114
- if (!Number.isSafeInteger(expectedBytes) || expectedBytes < 0) throw new Error(`CostLedger: invalid storage revision '${expectedRevision}'`);
115
- const next = input.storage.append(path, event, expectedBytes);
116
- return next === void 0 ? void 0 : String(next);
117
- }
118
- }
119
- });
120
- }
121
- // src/analyst/finding-scope.ts
122
- /**
123
- * What a finding is about and what it was measured on — AnalystFinding 1.1.0.
124
- *
125
- * A 1.0.0 finding states a claim with no layer and no population, so "a flat
126
- * team beat a deep hierarchy", measured on 4 runs of one play where run 2
127
- * inherited run 1's code, reads exactly like a lab-wide rule. Schema 1.1.0
128
- * makes the population part of the record:
129
- *
130
- * - `layer` names the level the claim is about, on one ladder from a single
131
- * event up to the whole lab, plus `meta` for findings about the measurement
132
- * itself (a judge, a ruler, an analyst).
133
- * - `scope` names the measured population, its size and time window, and the
134
- * domain path it was drawn from.
135
- * - `method` says whether the claim was computed, measured or judged; a
136
- * judged claim without calibration reads as uncalibrated.
137
- * - `evidence_units` lists the measured units with their lineage. When it is
138
- * present the stored `scope.n` and `scope.population` must equal it, so the
139
- * declared population cannot drift from the evidence.
140
- *
141
- * A claim moves above the layer it was measured at only through `promote`.
142
- */
143
- /**
144
- * The layer ladder, lowest first. `problem` is what discovery-lab calls a
145
- * theatre. `meta` sits outside the ladder: it is about the instrument, not the
146
- * agents, so it never promotes and never bounds another layer.
147
- */
148
- const FINDING_LAYERS = [
149
- "event",
150
- "turn",
151
- "agent",
152
- "team",
153
- "run",
154
- "play",
155
- "problem",
156
- "domain",
157
- "lab",
158
- "meta"
159
- ];
160
- /** Rank on the ladder; `meta` has none. */
161
- function findingLayerRank(layer) {
162
- return layer === "meta" ? null : FINDING_LAYERS.indexOf(layer);
163
- }
164
- const nonEmpty = z.string().refine((value) => value.trim().length > 0, { message: "must be a non-empty string" });
165
- const timestamp = z.string().refine((value) => Number.isFinite(Date.parse(value)), { message: "must be a valid timestamp" });
166
- const finite = z.number().refine(Number.isFinite, { message: "must be finite" });
167
- const unitRate = finite.refine((value) => value >= 0 && value <= 1, { message: "must be in [0,1]" });
168
- const layerSchema = z.enum(FINDING_LAYERS);
169
- const scopeSchema = z.object({
170
- population: z.array(nonEmpty),
171
- n: z.number().int().nonnegative(),
172
- window: z.object({
173
- from: timestamp,
174
- to: timestamp
175
- }).strict(),
176
- domain_path: z.array(nonEmpty).min(1).optional()
177
- }).strict();
178
- const methodSchema = z.object({
179
- kind: z.enum([
180
- "computed",
181
- "measured",
182
- "judged"
183
- ]),
184
- name: nonEmpty,
185
- version: nonEmpty,
186
- calibration: findingCalibrationSchema.optional()
187
- }).strict();
188
- const measureSchema = z.object({
189
- name: nonEmpty,
190
- value: finite,
191
- unit: z.string(),
192
- interval: z.tuple([finite, finite]).optional(),
193
- level: finite.refine((value) => value > 0 && value < 1, { message: "must be in (0,1)" }).optional()
194
- }).strict();
195
- const evidenceUnitSchema = z.object({
196
- id: nonEmpty,
197
- layer: layerSchema,
198
- derived_from: nonEmpty.nullable().optional()
199
- }).strict();
200
- const findingObject = z.object({
201
- schema_version: z.enum(["1.0.0", "1.1.0"]),
202
- finding_id: nonEmpty,
203
- analyst_id: nonEmpty,
204
- produced_at: timestamp,
205
- severity: z.enum(ANALYST_SEVERITIES),
206
- area: nonEmpty,
207
- claim: nonEmpty,
208
- rationale: z.string().optional(),
209
- evidence_refs: z.array(findingEvidenceRefSchema),
210
- recommended_action: z.string().optional(),
211
- validation_plan: z.string().optional(),
212
- confidence: unitRate,
213
- subject: z.string().optional(),
214
- derived_from_judge: z.boolean().optional(),
215
- metadata: z.record(z.string(), z.unknown()).optional(),
216
- layer: layerSchema.optional(),
217
- scope: scopeSchema.optional(),
218
- method: methodSchema.optional(),
219
- measure: measureSchema.optional(),
220
- confounders: z.array(nonEmpty).optional(),
221
- valid_for: nonEmpty.optional(),
222
- claim_id: nonEmpty.optional(),
223
- evidence_units: z.array(evidenceUnitSchema).min(1).optional(),
224
- treatment: z.array(findingTreatmentSchema).optional(),
225
- conditions: z.array(findingConditionsSchema).optional()
226
- }).strict();
227
- function checkFinding(finding, context) {
228
- const issue = (path, message) => context.addIssue({
229
- code: "custom",
230
- path,
231
- message
232
- });
233
- if (finding.schema_version === "1.0.0") {
234
- for (const field of FINDING_SCOPE_FIELDS) if (finding[field] !== void 0) issue([field], `${field} requires schema_version 1.1.0`);
235
- return;
236
- }
237
- if (finding.layer === void 0) issue(["layer"], "1.1.0 findings require a layer");
238
- if (finding.scope === void 0) issue(["scope"], "1.1.0 findings require a scope");
239
- if (finding.method === void 0) issue(["method"], "1.1.0 findings require a method");
240
- const { scope, measure, evidence_units: units } = finding;
241
- if (scope) {
242
- if (Date.parse(scope.window.from) > Date.parse(scope.window.to)) issue(["scope", "window"], "window.from must not be after window.to");
243
- if (new Set(scope.population).size !== scope.population.length) issue(["scope", "population"], "population ids must be unique");
244
- if (scope.population.length > 0 && scope.population.length !== scope.n) issue(["scope", "n"], `n ${scope.n} does not match ${scope.population.length} population ids`);
245
- }
246
- if (measure?.interval && measure.interval[0] > measure.interval[1]) issue(["measure", "interval"], "interval lower bound exceeds its upper bound");
247
- if (measure?.level !== void 0 && measure.interval === void 0) issue(["measure", "level"], "level describes an interval; none is present");
248
- if (finding.method?.kind !== "judged" && finding.method?.calibration !== void 0) issue(["method", "calibration"], "only judged findings carry a calibration");
249
- for (const field of ["treatment", "conditions"]) {
250
- const values = finding[field];
251
- if (values && new Set(values.map((value) => value.id)).size !== values.length) issue([field], "composition ids must be unique");
252
- }
253
- if (!units) return;
254
- const ids = units.map((unit) => unit.id);
255
- if (new Set(ids).size !== ids.length) issue(["evidence_units"], "unit ids must be unique");
256
- if (scope) {
257
- if (scope.n !== ids.length) issue(["scope", "n"], `n ${scope.n} does not match ${ids.length} evidence units`);
258
- const population = [...scope.population].sort();
259
- const unitIds = [...ids].sort();
260
- if (population.length !== unitIds.length || population.some((id, index) => id !== unitIds[index])) issue(["scope", "population"], "population must name exactly the evidence units");
261
- }
262
- const findingRank = finding.layer === void 0 ? null : findingLayerRank(finding.layer);
263
- if (findingRank === null) return;
264
- for (const [index, unit] of units.entries()) {
265
- const unitRank = findingLayerRank(unit.layer);
266
- if (unitRank !== null && unitRank > findingRank) issue([
267
- "evidence_units",
268
- index,
269
- "layer"
270
- ], `a ${finding.layer} finding cannot rest on a ${unit.layer} unit`);
271
- }
272
- }
273
- /** The one validator for stored findings of either schema version. Unknown fields fail. */
274
- const AnalystFindingSchema = findingObject.superRefine(checkFinding);
275
- /** A finding admitted as candidate-generation input; same rules plus its origin. */
276
- const ProposalFindingSchema = findingObject.extend({ proposal_origin: z.enum(["search", "production"]) }).strict().superRefine(checkFinding);
277
- /** Validate one stored finding of schema 1.0.0 or 1.1.0. */
278
- function parseAnalystFinding(value) {
279
- const parsed = AnalystFindingSchema.safeParse(value);
280
- if (parsed.success) return {
281
- succeeded: true,
282
- value: parsed.data
283
- };
284
- const issue = parsed.error.issues[0];
285
- return {
286
- succeeded: false,
287
- error: {
288
- path: (issue?.path ?? []).map(String).join("."),
289
- message: issue?.message ?? "finding does not match the schema"
290
- }
291
- };
292
- }
293
- function readFindingScope(finding) {
294
- if (finding.schema_version === "1.0.0" || !finding.scope || !finding.layer) return {
295
- layer: "unknown",
296
- n: "unknown",
297
- independent_n: "unknown",
298
- domain_path: null,
299
- labels: ["unscoped"]
300
- };
301
- const labels = [];
302
- if (finding.scope.n < 2) labels.push("anecdote");
303
- if (finding.method?.kind === "judged" && finding.method.calibration === void 0) labels.push("uncalibrated");
304
- const units = finding.evidence_units;
305
- if (units?.some((unit) => unit.derived_from === void 0)) labels.push("lineage-unknown");
306
- return {
307
- layer: finding.layer,
308
- n: finding.scope.n,
309
- independent_n: units ? independentUnitCount(units) : "unknown",
310
- domain_path: finding.scope.domain_path ?? null,
311
- labels
312
- };
313
- }
314
- /** Root token shared by every unit whose lineage was not recorded. */
315
- const UNKNOWN_LINEAGE = "?unknown-lineage";
316
- /**
317
- * Lineage root of each unit, keyed by unit id. A unit derived from another
318
- * unit in the list shares that unit's root; a unit derived from an id outside
319
- * the list takes that id as its root; unknown lineage maps to one shared root.
320
- */
321
- function lineageRoots(units) {
322
- const byId = new Map(units.map((unit) => [unit.id, unit]));
323
- const roots = /* @__PURE__ */ new Map();
324
- for (const unit of units) {
325
- let current = unit;
326
- let root = unit.id;
327
- const seen = /* @__PURE__ */ new Set();
328
- while (current && !seen.has(current.id)) {
329
- seen.add(current.id);
330
- if (current.derived_from === void 0) {
331
- root = UNKNOWN_LINEAGE;
332
- break;
333
- }
334
- if (current.derived_from === null) {
335
- root = current.id;
336
- break;
337
- }
338
- root = current.derived_from;
339
- current = byId.get(current.derived_from);
340
- }
341
- roots.set(unit.id, root);
342
- }
343
- return roots;
344
- }
345
- /** Units with distinct lineage roots. */
346
- function independentUnitCount(units) {
347
- return new Set(lineageRoots(units).values()).size;
348
- }
349
- /** One entry per unit id, sorted; a later copy that records lineage fills an earlier unknown. */
350
- function mergeEvidenceUnits(units) {
351
- const byId = /* @__PURE__ */ new Map();
352
- for (const unit of units) {
353
- const existing = byId.get(unit.id);
354
- if (!existing || existing.derived_from === void 0 && unit.derived_from !== void 0) byId.set(unit.id, { ...unit });
355
- }
356
- return [...byId.values()].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
357
- }
358
- /** The window spanning every finding's scope window. */
359
- function spanningWindow(findings) {
360
- const windows = findings.map((finding) => finding.scope.window);
361
- return {
362
- from: windows.map((w) => w.from).reduce((a, b) => Date.parse(b) < Date.parse(a) ? b : a),
363
- to: windows.map((w) => w.to).reduce((a, b) => Date.parse(b) > Date.parse(a) ? b : a)
364
- };
365
- }
366
- function mostSevere(findings) {
367
- return ANALYST_SEVERITIES[Math.min(...findings.map((finding) => ANALYST_SEVERITIES.indexOf(finding.severity)))];
368
- }
369
15
  // src/campaign/external-optimizer-http.ts
370
16
  function listenLocal(server) {
371
17
  return new Promise((resolvePromise, reject) => {
@@ -386,8 +32,11 @@ function closeServer(server) {
386
32
  server.close((error) => error ? reject(error) : resolvePromise());
387
33
  });
388
34
  }
389
- function sendJson(response, status, body) {
390
- response.writeHead(status, { "content-type": "application/json; charset=utf-8" });
35
+ function sendJson(response, status, body, headers = {}) {
36
+ response.writeHead(status, {
37
+ ...headers,
38
+ "content-type": "application/json; charset=utf-8"
39
+ });
391
40
  response.end(JSON.stringify(body));
392
41
  }
393
42
  /**
@@ -397,9 +46,9 @@ function sendJson(response, status, body) {
397
46
  * already ended — must not write again; Node throws `ERR_STREAM_WRITE_AFTER_END`
398
47
  * and the throw escapes into the server's error path rather than the caller's.
399
48
  */
400
- function sendJsonIfOpen(response, status, body) {
49
+ function sendJsonIfOpen(response, status, body, headers = {}) {
401
50
  if (response.destroyed || response.writableEnded) return;
402
- sendJson(response, status, body);
51
+ sendJson(response, status, body, headers);
403
52
  }
404
53
  /**
405
54
  * Wait until every in-flight handler has settled.
@@ -1425,13 +1074,13 @@ const MODEL_PROXY_PATHS = /* @__PURE__ */ new Set(["/v1/chat/completions", "/v1/
1425
1074
  async function handleModelProxyRequest(args) {
1426
1075
  const { controller, request, response } = args;
1427
1076
  let wire = "openai";
1428
- const respondError = (status, message, errorType) => {
1077
+ const respondError = (status, message, errorType, headers = {}) => {
1429
1078
  if (wire === "anthropic") {
1430
1079
  const mapped = status === 429 ? 402 : status;
1431
- sendJsonIfOpen(response, mapped, anthropicErrorEnvelope(errorType ?? anthropicErrorTypeForStatus(mapped), message));
1080
+ sendJsonIfOpen(response, mapped, anthropicErrorEnvelope(errorType ?? anthropicErrorTypeForStatus(mapped), message), headers);
1432
1081
  return;
1433
1082
  }
1434
- sendJsonIfOpen(response, status, { error: message });
1083
+ sendJsonIfOpen(response, status, { error: message }, headers);
1435
1084
  };
1436
1085
  try {
1437
1086
  const path = request.url ? new URL(request.url, "http://127.0.0.1").pathname : "";
@@ -1452,7 +1101,7 @@ async function handleModelProxyRequest(args) {
1452
1101
  const maximumCostUsd = args.args.budget.pricing ? costForTokenPricing(args.args.budget.pricing, maximumUsage) : void 0;
1453
1102
  const reservation = args.nextReservation(maximumCostUsd, wire);
1454
1103
  if (!reservation.accepted) {
1455
- respondError(429, reservation.reason);
1104
+ respondError(429, reservation.reason, void 0, { [EXTERNAL_OPTIMIZER_REFUSAL_HEADER]: reservation.kind });
1456
1105
  return;
1457
1106
  }
1458
1107
  const timeout = setTimeout(() => controller.abort(), args.args.budget.requestTimeoutMs ?? 3e5);
@@ -1591,11 +1240,13 @@ async function startExternalOptimizerModelProxy(args) {
1591
1240
  const wireCounts = {
1592
1241
  openai: {
1593
1242
  requestAttempts: 0,
1594
- successfulCompletions: 0
1243
+ successfulCompletions: 0,
1244
+ refusedRequests: 0
1595
1245
  },
1596
1246
  anthropic: {
1597
1247
  requestAttempts: 0,
1598
- successfulCompletions: 0
1248
+ successfulCompletions: 0,
1249
+ refusedRequests: 0
1599
1250
  }
1600
1251
  };
1601
1252
  let modelCallInvocations = 0;
@@ -1629,14 +1280,22 @@ async function startExternalOptimizerModelProxy(args) {
1629
1280
  token,
1630
1281
  args,
1631
1282
  nextReservation: (maximumCostUsd, wire) => {
1632
- if (totalRequestCount >= args.budget.maxRequests) return {
1633
- accepted: false,
1634
- reason: "optimizer model request limit reached"
1635
- };
1636
- if (args.budget.maxCostUsd !== void 0 && maximumCostUsd !== void 0 && committedForBudget + reservedForBudget + maximumCostUsd > args.budget.maxCostUsd + Number.EPSILON) return {
1637
- accepted: false,
1638
- reason: "optimizer model cost limit reached"
1639
- };
1283
+ if (totalRequestCount >= args.budget.maxRequests) {
1284
+ wireCounts[wire].refusedRequests += 1;
1285
+ return {
1286
+ accepted: false,
1287
+ kind: "request-limit",
1288
+ reason: "optimizer model request limit reached"
1289
+ };
1290
+ }
1291
+ if (args.budget.maxCostUsd !== void 0 && maximumCostUsd !== void 0 && committedForBudget + reservedForBudget + maximumCostUsd > args.budget.maxCostUsd + Number.EPSILON) {
1292
+ wireCounts[wire].refusedRequests += 1;
1293
+ return {
1294
+ accepted: false,
1295
+ kind: "cost-limit",
1296
+ reason: "optimizer model cost limit reached"
1297
+ };
1298
+ }
1640
1299
  requestCount += 1;
1641
1300
  wireCounts[wire].requestAttempts += 1;
1642
1301
  totalRequestCount += 1;
@@ -2013,6 +1672,6 @@ function summarizeProcessOutput(capture, max = 4e3) {
2013
1672
  const tailChars = max - headChars;
2014
1673
  return `${compact.slice(0, headChars)}...[${compact.length - max} chars omitted]...${compact.slice(-tailChars)}`;
2015
1674
  }
2016
- export { inMemoryCampaignStorage as S, parseAnalystFinding as _, closeServer as a, createRunCostLedger as b, waitForActiveHandlers as c, ProposalFindingSchema as d, UNKNOWN_LINEAGE as f, mostSevere as g, mergeEvidenceUnits as h, startExternalOptimizerModelProxy as i, AnalystFindingSchema as l, lineageRoots as m, closeExternalOptimizerResources as n, listenLocal as o, independentUnitCount as p, runWithCleanup as r, sendJsonIfOpen as s, runExternalOptimizerProcess as t, FINDING_LAYERS as u, readFindingScope as v, fsCampaignStorage as x, spanningWindow as y };
1675
+ export { closeServer as a, waitForActiveHandlers as c, startExternalOptimizerModelProxy as i, closeExternalOptimizerResources as n, listenLocal as o, runWithCleanup as r, sendJsonIfOpen as s, runExternalOptimizerProcess as t };
2017
1676
 
2018
- //# sourceMappingURL=external-optimizer-subprocess-BW0ZWUUr.js.map
1677
+ //# sourceMappingURL=external-optimizer-subprocess-_O06eDVA.js.map