@tangle-network/agent-eval 0.93.0 → 0.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1087) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +44 -30
  3. package/dist/action-policy.d.ts +24 -0
  4. package/dist/action-policy.d.ts.map +1 -0
  5. package/dist/action-policy.test.d.ts +2 -0
  6. package/dist/action-policy.test.d.ts.map +1 -0
  7. package/dist/active-learning.d.ts +41 -0
  8. package/dist/active-learning.d.ts.map +1 -0
  9. package/dist/adapters/http.d.ts +15 -21
  10. package/dist/adapters/http.d.ts.map +1 -0
  11. package/dist/adapters/http.js.map +1 -1
  12. package/dist/adapters/langchain.d.ts +7 -13
  13. package/dist/adapters/langchain.d.ts.map +1 -0
  14. package/dist/adapters/otel.d.ts +13 -24
  15. package/dist/adapters/otel.d.ts.map +1 -0
  16. package/dist/agent-profile-cell.d.ts +101 -0
  17. package/dist/agent-profile-cell.d.ts.map +1 -0
  18. package/dist/agent-profile.d.ts +27 -0
  19. package/dist/agent-profile.d.ts.map +1 -0
  20. package/dist/agent-profile.test.d.ts +2 -0
  21. package/dist/agent-profile.test.d.ts.map +1 -0
  22. package/dist/analyst/adapters.d.ts +62 -0
  23. package/dist/analyst/adapters.d.ts.map +1 -0
  24. package/dist/analyst/analyst.test.d.ts +2 -0
  25. package/dist/analyst/analyst.test.d.ts.map +1 -0
  26. package/dist/analyst/ax-service.d.ts +27 -0
  27. package/dist/analyst/ax-service.d.ts.map +1 -0
  28. package/dist/analyst/behavioral-analyst.d.ts +28 -0
  29. package/dist/analyst/behavioral-analyst.d.ts.map +1 -0
  30. package/dist/analyst/chat-client.d.ts +91 -0
  31. package/dist/analyst/chat-client.d.ts.map +1 -0
  32. package/dist/analyst/default-registry.d.ts +27 -0
  33. package/dist/analyst/default-registry.d.ts.map +1 -0
  34. package/dist/analyst/default-registry.test.d.ts +2 -0
  35. package/dist/analyst/default-registry.test.d.ts.map +1 -0
  36. package/dist/analyst/finding-signature.d.ts +48 -0
  37. package/dist/analyst/finding-signature.d.ts.map +1 -0
  38. package/dist/analyst/finding-subject.d.ts +146 -0
  39. package/dist/analyst/finding-subject.d.ts.map +1 -0
  40. package/dist/analyst/finding-subject.test.d.ts +2 -0
  41. package/dist/analyst/finding-subject.test.d.ts.map +1 -0
  42. package/dist/analyst/findings-store.d.ts +75 -0
  43. package/dist/analyst/findings-store.d.ts.map +1 -0
  44. package/dist/analyst/index.d.ts +28 -256
  45. package/dist/analyst/index.d.ts.map +1 -0
  46. package/dist/analyst/index.js +6 -66
  47. package/dist/analyst/index.js.map +1 -1
  48. package/dist/{kind-factory-5b7xXXOr.d.ts → analyst/kind-factory.d.ts} +11 -63
  49. package/dist/analyst/kind-factory.d.ts.map +1 -0
  50. package/dist/analyst/kinds/failure-mode.d.ts +19 -0
  51. package/dist/analyst/kinds/failure-mode.d.ts.map +1 -0
  52. package/dist/analyst/kinds/improvement.d.ts +23 -0
  53. package/dist/analyst/kinds/improvement.d.ts.map +1 -0
  54. package/dist/analyst/kinds/index.d.ts +22 -0
  55. package/dist/analyst/kinds/index.d.ts.map +1 -0
  56. package/dist/analyst/kinds/kinds.test.d.ts +2 -0
  57. package/dist/analyst/kinds/kinds.test.d.ts.map +1 -0
  58. package/dist/analyst/kinds/knowledge-gap.d.ts +28 -0
  59. package/dist/analyst/kinds/knowledge-gap.d.ts.map +1 -0
  60. package/dist/analyst/kinds/knowledge-poisoning.d.ts +22 -0
  61. package/dist/analyst/kinds/knowledge-poisoning.d.ts.map +1 -0
  62. package/dist/analyst/kinds/skill-usage.d.ts +84 -0
  63. package/dist/analyst/kinds/skill-usage.d.ts.map +1 -0
  64. package/dist/analyst/kinds/skill-usage.test.d.ts +2 -0
  65. package/dist/analyst/kinds/skill-usage.test.d.ts.map +1 -0
  66. package/dist/analyst/parse-tolerant.d.ts +26 -0
  67. package/dist/analyst/parse-tolerant.d.ts.map +1 -0
  68. package/dist/analyst/parse-tolerant.test.d.ts +2 -0
  69. package/dist/analyst/parse-tolerant.test.d.ts.map +1 -0
  70. package/dist/analyst/registry.budget.test.d.ts +2 -0
  71. package/dist/analyst/registry.budget.test.d.ts.map +1 -0
  72. package/dist/{default-registry-zoGHUQEH.d.ts → analyst/registry.d.ts} +8 -37
  73. package/dist/analyst/registry.d.ts.map +1 -0
  74. package/dist/analyst/steer-firewall.d.ts +35 -0
  75. package/dist/analyst/steer-firewall.d.ts.map +1 -0
  76. package/dist/analyst/steer-firewall.test.d.ts +2 -0
  77. package/dist/analyst/steer-firewall.test.d.ts.map +1 -0
  78. package/dist/analyst/structure-findings.d.ts +37 -0
  79. package/dist/analyst/structure-findings.d.ts.map +1 -0
  80. package/dist/analyst/structure-findings.test.d.ts +2 -0
  81. package/dist/analyst/structure-findings.test.d.ts.map +1 -0
  82. package/dist/analyst/tool-groups.d.ts +34 -0
  83. package/dist/analyst/tool-groups.d.ts.map +1 -0
  84. package/dist/{types-2VVIL04s.d.ts → analyst/types.d.ts} +19 -112
  85. package/dist/analyst/types.d.ts.map +1 -0
  86. package/dist/anti-slop.d.ts +59 -0
  87. package/dist/anti-slop.d.ts.map +1 -0
  88. package/dist/artifact-validator.d.ts +74 -0
  89. package/dist/artifact-validator.d.ts.map +1 -0
  90. package/dist/attestation.d.ts +63 -0
  91. package/dist/attestation.d.ts.map +1 -0
  92. package/dist/attestation.test.d.ts +2 -0
  93. package/dist/attestation.test.d.ts.map +1 -0
  94. package/dist/authenticity/index.d.ts +15 -16
  95. package/dist/authenticity/index.d.ts.map +1 -0
  96. package/dist/authenticity/index.test.d.ts +2 -0
  97. package/dist/authenticity/index.test.d.ts.map +1 -0
  98. package/dist/auto-pr.d.ts +120 -0
  99. package/dist/auto-pr.d.ts.map +1 -0
  100. package/dist/{baseline-DE36-Np7.d.ts → baseline.d.ts} +8 -44
  101. package/dist/baseline.d.ts.map +1 -0
  102. package/dist/behavior-dsl.d.ts +73 -0
  103. package/dist/behavior-dsl.d.ts.map +1 -0
  104. package/dist/belief-state/calibration.d.ts +10 -0
  105. package/dist/belief-state/calibration.d.ts.map +1 -0
  106. package/dist/belief-state/calibration.test.d.ts +2 -0
  107. package/dist/belief-state/calibration.test.d.ts.map +1 -0
  108. package/dist/belief-state/code-agent-corpus.d.ts +66 -0
  109. package/dist/belief-state/code-agent-corpus.d.ts.map +1 -0
  110. package/dist/belief-state/code-agent-corpus.test.d.ts +2 -0
  111. package/dist/belief-state/code-agent-corpus.test.d.ts.map +1 -0
  112. package/dist/belief-state/code-agent-evidence.d.ts +22 -0
  113. package/dist/belief-state/code-agent-evidence.d.ts.map +1 -0
  114. package/dist/belief-state/code-agent-evidence.test.d.ts +2 -0
  115. package/dist/belief-state/code-agent-evidence.test.d.ts.map +1 -0
  116. package/dist/belief-state/extract.d.ts +7 -0
  117. package/dist/belief-state/extract.d.ts.map +1 -0
  118. package/dist/belief-state/extract.test.d.ts +2 -0
  119. package/dist/belief-state/extract.test.d.ts.map +1 -0
  120. package/dist/belief-state/index.d.ts +14 -604
  121. package/dist/belief-state/index.d.ts.map +1 -0
  122. package/dist/belief-state/index.js +1 -1
  123. package/dist/belief-state/ope.d.ts +17 -0
  124. package/dist/belief-state/ope.d.ts.map +1 -0
  125. package/dist/belief-state/ope.test.d.ts +2 -0
  126. package/dist/belief-state/ope.test.d.ts.map +1 -0
  127. package/dist/belief-state/phase0-measurement.d.ts +55 -0
  128. package/dist/belief-state/phase0-measurement.d.ts.map +1 -0
  129. package/dist/belief-state/report.d.ts +17 -0
  130. package/dist/belief-state/report.d.ts.map +1 -0
  131. package/dist/belief-state/report.test.d.ts +2 -0
  132. package/dist/belief-state/report.test.d.ts.map +1 -0
  133. package/dist/belief-state/research-evidence.d.ts +23 -0
  134. package/dist/belief-state/research-evidence.d.ts.map +1 -0
  135. package/dist/belief-state/research-evidence.test.d.ts +2 -0
  136. package/dist/belief-state/research-evidence.test.d.ts.map +1 -0
  137. package/dist/belief-state/runtime-benchmark-corpus.d.ts +32 -0
  138. package/dist/belief-state/runtime-benchmark-corpus.d.ts.map +1 -0
  139. package/dist/belief-state/runtime-hooks.d.ts +87 -0
  140. package/dist/belief-state/runtime-hooks.d.ts.map +1 -0
  141. package/dist/belief-state/runtime-hooks.test.d.ts +2 -0
  142. package/dist/belief-state/runtime-hooks.test.d.ts.map +1 -0
  143. package/dist/belief-state/selective.d.ts +15 -0
  144. package/dist/belief-state/selective.d.ts.map +1 -0
  145. package/dist/belief-state/selective.test.d.ts +2 -0
  146. package/dist/belief-state/selective.test.d.ts.map +1 -0
  147. package/dist/belief-state/shadow-probe.d.ts +80 -0
  148. package/dist/belief-state/shadow-probe.d.ts.map +1 -0
  149. package/dist/belief-state/shadow-probe.test.d.ts +2 -0
  150. package/dist/belief-state/shadow-probe.test.d.ts.map +1 -0
  151. package/dist/belief-state/types.d.ts +195 -0
  152. package/dist/belief-state/types.d.ts.map +1 -0
  153. package/dist/belief-state/types.test.d.ts +2 -0
  154. package/dist/belief-state/types.test.d.ts.map +1 -0
  155. package/dist/benchmark.d.ts +14 -0
  156. package/dist/benchmark.d.ts.map +1 -0
  157. package/dist/benchmarks/index.d.ts +23 -4
  158. package/dist/benchmarks/index.d.ts.map +1 -0
  159. package/dist/benchmarks/routing/dataset.d.ts +34 -0
  160. package/dist/benchmarks/routing/dataset.d.ts.map +1 -0
  161. package/dist/benchmarks/routing/index.d.ts +34 -0
  162. package/dist/benchmarks/routing/index.d.ts.map +1 -0
  163. package/dist/benchmarks/types.d.ts +49 -0
  164. package/dist/benchmarks/types.d.ts.map +1 -0
  165. package/dist/bisector.d.ts +81 -0
  166. package/dist/bisector.d.ts.map +1 -0
  167. package/dist/budget-guard.d.ts +31 -0
  168. package/dist/budget-guard.d.ts.map +1 -0
  169. package/dist/builder-eval/builder-session.d.ts +111 -0
  170. package/dist/builder-eval/builder-session.d.ts.map +1 -0
  171. package/dist/builder-eval/correlation.d.ts +32 -0
  172. package/dist/builder-eval/correlation.d.ts.map +1 -0
  173. package/dist/builder-eval/index.d.ts +5 -250
  174. package/dist/builder-eval/index.d.ts.map +1 -0
  175. package/dist/builder-eval/index.js +2 -2
  176. package/dist/builder-eval/project-registry.d.ts +51 -0
  177. package/dist/builder-eval/project-registry.d.ts.map +1 -0
  178. package/dist/builder-eval/three-layer-eval.d.ts +55 -0
  179. package/dist/builder-eval/three-layer-eval.d.ts.map +1 -0
  180. package/dist/campaign/analyst-surface.d.ts +108 -0
  181. package/dist/campaign/analyst-surface.d.ts.map +1 -0
  182. package/dist/campaign/analyst-surface.test.d.ts +2 -0
  183. package/dist/campaign/analyst-surface.test.d.ts.map +1 -0
  184. package/dist/campaign/auto-pr.d.ts +46 -0
  185. package/dist/campaign/auto-pr.d.ts.map +1 -0
  186. package/dist/campaign/distillation/agreement-judge.d.ts +69 -0
  187. package/dist/campaign/distillation/agreement-judge.d.ts.map +1 -0
  188. package/dist/campaign/distillation/cli.d.ts +35 -0
  189. package/dist/campaign/distillation/cli.d.ts.map +1 -0
  190. package/dist/campaign/distillation/distillation.test.d.ts +2 -0
  191. package/dist/campaign/distillation/distillation.test.d.ts.map +1 -0
  192. package/dist/campaign/distillation/gold-scenarios.d.ts +54 -0
  193. package/dist/campaign/distillation/gold-scenarios.d.ts.map +1 -0
  194. package/dist/campaign/distillation/run-distillation.d.ts +119 -0
  195. package/dist/campaign/distillation/run-distillation.d.ts.map +1 -0
  196. package/dist/campaign/gates/compose.d.ts +12 -0
  197. package/dist/campaign/gates/compose.d.ts.map +1 -0
  198. package/dist/campaign/gates/default-production-gate.d.ts +58 -0
  199. package/dist/campaign/gates/default-production-gate.d.ts.map +1 -0
  200. package/dist/campaign/gates/heldout-gate.d.ts +12 -0
  201. package/dist/campaign/gates/heldout-gate.d.ts.map +1 -0
  202. package/dist/campaign/gates/promotion-policy.d.ts +125 -0
  203. package/dist/campaign/gates/promotion-policy.d.ts.map +1 -0
  204. package/dist/campaign/gates/promotion-policy.test.d.ts +2 -0
  205. package/dist/campaign/gates/promotion-policy.test.d.ts.map +1 -0
  206. package/dist/campaign/gates/sequential.d.ts +146 -0
  207. package/dist/campaign/gates/sequential.d.ts.map +1 -0
  208. package/dist/campaign/gates/sequential.test.d.ts +2 -0
  209. package/dist/campaign/gates/sequential.test.d.ts.map +1 -0
  210. package/dist/campaign/gates/statistical-heldout.d.ts +99 -0
  211. package/dist/campaign/gates/statistical-heldout.d.ts.map +1 -0
  212. package/dist/campaign/gates/statistical-heldout.test.d.ts +2 -0
  213. package/dist/campaign/gates/statistical-heldout.test.d.ts.map +1 -0
  214. package/dist/campaign/index.d.ts +38 -1341
  215. package/dist/campaign/index.d.ts.map +1 -0
  216. package/dist/campaign/index.js +1865 -1318
  217. package/dist/campaign/index.js.map +1 -1
  218. package/dist/campaign/labeled-store/fs-adapter.d.ts +59 -0
  219. package/dist/campaign/labeled-store/fs-adapter.d.ts.map +1 -0
  220. package/dist/campaign/presets/compare-proposers.d.ts +146 -0
  221. package/dist/campaign/presets/compare-proposers.d.ts.map +1 -0
  222. package/dist/campaign/presets/playback.d.ts +120 -0
  223. package/dist/campaign/presets/playback.d.ts.map +1 -0
  224. package/dist/campaign/presets/playback.test.d.ts +2 -0
  225. package/dist/campaign/presets/playback.test.d.ts.map +1 -0
  226. package/dist/campaign/presets/run-eval.d.ts +14 -0
  227. package/dist/campaign/presets/run-eval.d.ts.map +1 -0
  228. package/dist/campaign/presets/run-improvement-loop.d.ts +63 -0
  229. package/dist/campaign/presets/run-improvement-loop.d.ts.map +1 -0
  230. package/dist/campaign/presets/run-improvement-loop.test.d.ts +2 -0
  231. package/dist/campaign/presets/run-improvement-loop.test.d.ts.map +1 -0
  232. package/dist/campaign/presets/run-optimization.d.ts +92 -0
  233. package/dist/campaign/presets/run-optimization.d.ts.map +1 -0
  234. package/dist/campaign/presets/run-profile-matrix.d.ts +151 -0
  235. package/dist/campaign/presets/run-profile-matrix.d.ts.map +1 -0
  236. package/dist/campaign/presets/run-skill-opt.d.ts +96 -0
  237. package/dist/campaign/presets/run-skill-opt.d.ts.map +1 -0
  238. package/dist/campaign/proposers/_findings-text.d.ts +22 -0
  239. package/dist/campaign/proposers/_findings-text.d.ts.map +1 -0
  240. package/dist/campaign/proposers/ace.d.ts +33 -0
  241. package/dist/campaign/proposers/ace.d.ts.map +1 -0
  242. package/dist/campaign/proposers/ace.test.d.ts +2 -0
  243. package/dist/campaign/proposers/ace.test.d.ts.map +1 -0
  244. package/dist/campaign/proposers/analysis-edit.d.ts +32 -0
  245. package/dist/campaign/proposers/analysis-edit.d.ts.map +1 -0
  246. package/dist/campaign/proposers/evolutionary.d.ts +20 -0
  247. package/dist/campaign/proposers/evolutionary.d.ts.map +1 -0
  248. package/dist/campaign/proposers/fapo.d.ts +120 -0
  249. package/dist/campaign/proposers/fapo.d.ts.map +1 -0
  250. package/dist/campaign/proposers/gepa.d.ts +86 -0
  251. package/dist/campaign/proposers/gepa.d.ts.map +1 -0
  252. package/dist/campaign/proposers/halo.d.ts +44 -0
  253. package/dist/campaign/proposers/halo.d.ts.map +1 -0
  254. package/dist/campaign/proposers/halo.test.d.ts +2 -0
  255. package/dist/campaign/proposers/halo.test.d.ts.map +1 -0
  256. package/dist/campaign/proposers/memory.d.ts +47 -0
  257. package/dist/campaign/proposers/memory.d.ts.map +1 -0
  258. package/dist/campaign/proposers/memory.test.d.ts +2 -0
  259. package/dist/campaign/proposers/memory.test.d.ts.map +1 -0
  260. package/dist/campaign/proposers/skill-opt.d.ts +88 -0
  261. package/dist/campaign/proposers/skill-opt.d.ts.map +1 -0
  262. package/dist/campaign/proposers/trace-analyst.d.ts +48 -0
  263. package/dist/campaign/proposers/trace-analyst.d.ts.map +1 -0
  264. package/dist/campaign/proposers/trace-analyst.test.d.ts +2 -0
  265. package/dist/campaign/proposers/trace-analyst.test.d.ts.map +1 -0
  266. package/dist/campaign/provenance.d.ts +185 -0
  267. package/dist/campaign/provenance.d.ts.map +1 -0
  268. package/dist/campaign/run-campaign.d.ts +90 -0
  269. package/dist/campaign/run-campaign.d.ts.map +1 -0
  270. package/dist/campaign/score-utils.d.ts +26 -0
  271. package/dist/campaign/score-utils.d.ts.map +1 -0
  272. package/dist/campaign/skill-patch.d.ts +62 -0
  273. package/dist/campaign/skill-patch.d.ts.map +1 -0
  274. package/dist/campaign/storage.d.ts +38 -0
  275. package/dist/campaign/storage.d.ts.map +1 -0
  276. package/dist/{types-BU-7W85F.d.ts → campaign/types.d.ts} +98 -99
  277. package/dist/campaign/types.d.ts.map +1 -0
  278. package/dist/campaign/worktree/index.d.ts +53 -0
  279. package/dist/campaign/worktree/index.d.ts.map +1 -0
  280. package/dist/canary.d.ts +101 -0
  281. package/dist/canary.d.ts.map +1 -0
  282. package/dist/causal-attribution.d.ts +45 -0
  283. package/dist/causal-attribution.d.ts.map +1 -0
  284. package/dist/{chunk-TWS7AZEY.js → chunk-2T4EZACH.js} +2 -2
  285. package/dist/chunk-2T4EZACH.js.map +1 -0
  286. package/dist/{chunk-LMZQ2Z4U.js → chunk-56GC6VYO.js} +126 -1
  287. package/dist/chunk-56GC6VYO.js.map +1 -0
  288. package/dist/{chunk-QG2OVF2D.js → chunk-77T4STFI.js} +154 -112
  289. package/dist/chunk-77T4STFI.js.map +1 -0
  290. package/dist/{chunk-ZFIBGEOL.js → chunk-7QTQKIDD.js} +179 -178
  291. package/dist/chunk-7QTQKIDD.js.map +1 -0
  292. package/dist/{chunk-UMMZHCPB.js → chunk-AQ5WQAIV.js} +26 -9
  293. package/dist/chunk-AQ5WQAIV.js.map +1 -0
  294. package/dist/{chunk-CVVHBFGN.js → chunk-CWNP4DV4.js} +53 -5
  295. package/dist/chunk-CWNP4DV4.js.map +1 -0
  296. package/dist/{chunk-QS3RBQPI.js → chunk-D5KBVULY.js} +2 -2
  297. package/dist/chunk-DJWX3GVS.js +81 -0
  298. package/dist/chunk-DJWX3GVS.js.map +1 -0
  299. package/dist/{chunk-S6OZEZQK.js → chunk-HMA63UEO.js} +37 -9
  300. package/dist/{chunk-S6OZEZQK.js.map → chunk-HMA63UEO.js.map} +1 -1
  301. package/dist/{chunk-UHMJT4T7.js → chunk-IZCEK2HR.js} +2 -2
  302. package/dist/{chunk-6SOJM3VR.js → chunk-KKWJD5E6.js} +21 -21
  303. package/dist/chunk-KKWJD5E6.js.map +1 -0
  304. package/dist/{chunk-KWRRMR3J.js → chunk-LO6IOIJ2.js} +10 -10
  305. package/dist/chunk-LO6IOIJ2.js.map +1 -0
  306. package/dist/{chunk-L3JOU6XM.js → chunk-NACM5RS7.js} +3 -3
  307. package/dist/{chunk-E4GH6USR.js → chunk-NZEQVRH5.js} +2 -2
  308. package/dist/chunk-NZEQVRH5.js.map +1 -0
  309. package/dist/{chunk-XY4DDNEG.js → chunk-PSWWQXHF.js} +14 -89
  310. package/dist/chunk-PSWWQXHF.js.map +1 -0
  311. package/dist/{chunk-4FBZZIYD.js → chunk-QTMYW64F.js} +2 -2
  312. package/dist/{chunk-D3V5B42D.js → chunk-S4SYLDFX.js} +7 -4
  313. package/dist/chunk-S4SYLDFX.js.map +1 -0
  314. package/dist/{chunk-47X6LRCE.js → chunk-UFSG7ACU.js} +10 -7
  315. package/dist/chunk-UFSG7ACU.js.map +1 -0
  316. package/dist/{chunk-CY6U5S3X.js → chunk-URWVKRCS.js} +2 -2
  317. package/dist/{chunk-GSH6QNNS.js → chunk-X74V6ESX.js} +102 -79
  318. package/dist/chunk-X74V6ESX.js.map +1 -0
  319. package/dist/{chunk-QAY5UIJO.js → chunk-YBIGNSCZ.js} +178 -59
  320. package/dist/chunk-YBIGNSCZ.js.map +1 -0
  321. package/dist/{chunk-Y47J2LJ3.js → chunk-Z6L6YSU6.js} +5 -5
  322. package/dist/{chunk-T375SUOZ.js → chunk-ZOPLCJSY.js} +86 -31
  323. package/dist/chunk-ZOPLCJSY.js.map +1 -0
  324. package/dist/ci-gate.d.ts +44 -0
  325. package/dist/ci-gate.d.ts.map +1 -0
  326. package/dist/cli.d.ts +2 -0
  327. package/dist/cli.d.ts.map +1 -0
  328. package/dist/cli.js +2 -2
  329. package/dist/client.d.ts +77 -0
  330. package/dist/client.d.ts.map +1 -0
  331. package/dist/client.test.d.ts +2 -0
  332. package/dist/client.test.d.ts.map +1 -0
  333. package/dist/command-runner.d.ts +74 -0
  334. package/dist/command-runner.d.ts.map +1 -0
  335. package/dist/command-runner.test.d.ts +2 -0
  336. package/dist/command-runner.test.d.ts.map +1 -0
  337. package/dist/completion-verifier.d.ts +147 -0
  338. package/dist/completion-verifier.d.ts.map +1 -0
  339. package/dist/completion-verifier.test.d.ts +9 -0
  340. package/dist/completion-verifier.test.d.ts.map +1 -0
  341. package/dist/concurrency.d.ts +23 -0
  342. package/dist/concurrency.d.ts.map +1 -0
  343. package/dist/contamination-guard.d.ts +81 -0
  344. package/dist/contamination-guard.d.ts.map +1 -0
  345. package/dist/{analyze-runs-DwCEkpO_.d.ts → contract/analyze-runs.d.ts} +9 -10
  346. package/dist/contract/analyze-runs.d.ts.map +1 -0
  347. package/dist/contract/define-agent-eval.d.ts +52 -0
  348. package/dist/contract/define-agent-eval.d.ts.map +1 -0
  349. package/dist/contract/diff.d.ts +114 -0
  350. package/dist/contract/diff.d.ts.map +1 -0
  351. package/dist/contract/index.d.ts +106 -640
  352. package/dist/contract/index.d.ts.map +1 -0
  353. package/dist/contract/index.js +131 -21
  354. package/dist/contract/index.js.map +1 -1
  355. package/dist/{insight-report-BBwvOh6x.d.ts → contract/insight-report.d.ts} +16 -19
  356. package/dist/contract/insight-report.d.ts.map +1 -0
  357. package/dist/contract/insight-types-fwd.d.ts +7 -0
  358. package/dist/contract/insight-types-fwd.d.ts.map +1 -0
  359. package/dist/contract/intake/agent-trace.d.ts +97 -0
  360. package/dist/contract/intake/agent-trace.d.ts.map +1 -0
  361. package/dist/{code-agent-session-BO8nCnv3.d.ts → contract/intake/code-agent-session.d.ts} +15 -17
  362. package/dist/contract/intake/code-agent-session.d.ts.map +1 -0
  363. package/dist/contract/intake/feedback-table.d.ts +87 -0
  364. package/dist/contract/intake/feedback-table.d.ts.map +1 -0
  365. package/dist/contract/intake/index.d.ts +22 -0
  366. package/dist/contract/intake/index.d.ts.map +1 -0
  367. package/dist/contract/intake/otel-spans.d.ts +33 -0
  368. package/dist/contract/intake/otel-spans.d.ts.map +1 -0
  369. package/dist/contract/self-improve.d.ts +284 -0
  370. package/dist/contract/self-improve.d.ts.map +1 -0
  371. package/dist/{control-runtime-DuFBYg7A.d.ts → control-runtime.d.ts} +23 -26
  372. package/dist/control-runtime.d.ts.map +1 -0
  373. package/dist/control-runtime.test.d.ts +2 -0
  374. package/dist/control-runtime.test.d.ts.map +1 -0
  375. package/dist/control.d.ts +11 -9
  376. package/dist/control.d.ts.map +1 -0
  377. package/dist/control.js +2 -2
  378. package/dist/convergence.d.ts +29 -0
  379. package/dist/convergence.d.ts.map +1 -0
  380. package/dist/{cost-ledger-DuSqlw5B.d.ts → cost-ledger.d.ts} +10 -11
  381. package/dist/cost-ledger.d.ts.map +1 -0
  382. package/dist/cost-ledger.test.d.ts +2 -0
  383. package/dist/cost-ledger.test.d.ts.map +1 -0
  384. package/dist/cost-report.d.ts +43 -0
  385. package/dist/cost-report.d.ts.map +1 -0
  386. package/dist/cost-report.test.d.ts +2 -0
  387. package/dist/cost-report.test.d.ts.map +1 -0
  388. package/dist/cost-tracker.d.ts +76 -0
  389. package/dist/cost-tracker.d.ts.map +1 -0
  390. package/dist/{counterfactual-Dwibr5IW.d.ts → counterfactual.d.ts} +12 -13
  391. package/dist/counterfactual.d.ts.map +1 -0
  392. package/dist/cross-trace-diff.d.ts +56 -0
  393. package/dist/cross-trace-diff.d.ts.map +1 -0
  394. package/dist/{dataset-BbGkaN2I.d.ts → dataset.d.ts} +11 -14
  395. package/dist/dataset.d.ts.map +1 -0
  396. package/dist/deploy-gate-layer.d.ts +125 -0
  397. package/dist/deploy-gate-layer.d.ts.map +1 -0
  398. package/dist/deploy-gate-layer.test.d.ts +2 -0
  399. package/dist/deploy-gate-layer.test.d.ts.map +1 -0
  400. package/dist/description-length-gate.d.ts +119 -0
  401. package/dist/description-length-gate.d.ts.map +1 -0
  402. package/dist/detectors/edge.test.d.ts +2 -0
  403. package/dist/detectors/edge.test.d.ts.map +1 -0
  404. package/dist/detectors/index.d.ts +81 -0
  405. package/dist/detectors/index.d.ts.map +1 -0
  406. package/dist/detectors/index.test.d.ts +2 -0
  407. package/dist/detectors/index.test.d.ts.map +1 -0
  408. package/dist/diagnose/causal-sweep.d.ts +100 -0
  409. package/dist/diagnose/causal-sweep.d.ts.map +1 -0
  410. package/dist/diagnose/index.d.ts +36 -0
  411. package/dist/diagnose/index.d.ts.map +1 -0
  412. package/dist/diagnose/remediation.d.ts +68 -0
  413. package/dist/diagnose/remediation.d.ts.map +1 -0
  414. package/dist/diagnose/repair.d.ts +77 -0
  415. package/dist/diagnose/repair.d.ts.map +1 -0
  416. package/dist/diagnose.d.ts +1 -251
  417. package/dist/diagnose.js +2 -2
  418. package/dist/discover-personas.d.ts +35 -0
  419. package/dist/discover-personas.d.ts.map +1 -0
  420. package/dist/driver.d.ts +95 -0
  421. package/dist/driver.d.ts.map +1 -0
  422. package/dist/driver.test.d.ts +8 -0
  423. package/dist/driver.test.d.ts.map +1 -0
  424. package/dist/dual-agent-bench.d.ts +81 -0
  425. package/dist/dual-agent-bench.d.ts.map +1 -0
  426. package/dist/error-count-extractor.d.ts +47 -0
  427. package/dist/error-count-extractor.d.ts.map +1 -0
  428. package/dist/error-count-extractor.test.d.ts +2 -0
  429. package/dist/error-count-extractor.test.d.ts.map +1 -0
  430. package/dist/{errors-CzMUYo7b.d.ts → errors.d.ts} +10 -11
  431. package/dist/errors.d.ts.map +1 -0
  432. package/dist/{researcher-DE6Gpnb4.d.ts → eval-campaign.d.ts} +34 -156
  433. package/dist/eval-campaign.d.ts.map +1 -0
  434. package/dist/eval-campaign.test.d.ts +2 -0
  435. package/dist/eval-campaign.test.d.ts.map +1 -0
  436. package/dist/eval-tools.d.ts +55 -0
  437. package/dist/eval-tools.d.ts.map +1 -0
  438. package/dist/eval-trace-store.d.ts +107 -0
  439. package/dist/eval-trace-store.d.ts.map +1 -0
  440. package/dist/eval-trace-store.test.d.ts +2 -0
  441. package/dist/eval-trace-store.test.d.ts.map +1 -0
  442. package/dist/executor.d.ts +38 -0
  443. package/dist/executor.d.ts.map +1 -0
  444. package/dist/executor.test.d.ts +10 -0
  445. package/dist/executor.test.d.ts.map +1 -0
  446. package/dist/experiment-tracker.d.ts +178 -0
  447. package/dist/experiment-tracker.d.ts.map +1 -0
  448. package/dist/experiment-tracker.test.d.ts +2 -0
  449. package/dist/experiment-tracker.test.d.ts.map +1 -0
  450. package/dist/failure-taxonomy.d.ts +38 -0
  451. package/dist/failure-taxonomy.d.ts.map +1 -0
  452. package/dist/{feedback-trajectory-D9OVLrg9.d.ts → feedback-trajectory.d.ts} +36 -38
  453. package/dist/feedback-trajectory.d.ts.map +1 -0
  454. package/dist/feedback-trajectory.test.d.ts +2 -0
  455. package/dist/feedback-trajectory.test.d.ts.map +1 -0
  456. package/dist/flow-layer.d.ts +90 -0
  457. package/dist/flow-layer.d.ts.map +1 -0
  458. package/dist/flow-layer.test.d.ts +2 -0
  459. package/dist/flow-layer.test.d.ts.map +1 -0
  460. package/dist/fuzz/capsule.d.ts +46 -0
  461. package/dist/fuzz/capsule.d.ts.map +1 -0
  462. package/dist/fuzz/cube.d.ts +36 -0
  463. package/dist/fuzz/cube.d.ts.map +1 -0
  464. package/dist/fuzz/explorer-cost.test.d.ts +2 -0
  465. package/dist/fuzz/explorer-cost.test.d.ts.map +1 -0
  466. package/dist/fuzz/explorer.d.ts +64 -0
  467. package/dist/fuzz/explorer.d.ts.map +1 -0
  468. package/dist/fuzz/fuzz-agent.d.ts +16 -0
  469. package/dist/fuzz/fuzz-agent.d.ts.map +1 -0
  470. package/dist/fuzz/fuzz-agent.test.d.ts +2 -0
  471. package/dist/fuzz/fuzz-agent.test.d.ts.map +1 -0
  472. package/dist/fuzz/gates.d.ts +33 -0
  473. package/dist/fuzz/gates.d.ts.map +1 -0
  474. package/dist/fuzz/index.d.ts +26 -0
  475. package/dist/fuzz/index.d.ts.map +1 -0
  476. package/dist/fuzz/policies.d.ts +28 -0
  477. package/dist/fuzz/policies.d.ts.map +1 -0
  478. package/dist/fuzz/tools.d.ts +20 -0
  479. package/dist/fuzz/tools.d.ts.map +1 -0
  480. package/dist/fuzz/types.d.ts +307 -0
  481. package/dist/fuzz/types.d.ts.map +1 -0
  482. package/dist/fuzz.d.ts +1 -547
  483. package/dist/golden-matcher.d.ts +71 -0
  484. package/dist/golden-matcher.d.ts.map +1 -0
  485. package/dist/governance/eu-ai-act.d.ts +37 -0
  486. package/dist/governance/eu-ai-act.d.ts.map +1 -0
  487. package/dist/governance/index.d.ts +5 -135
  488. package/dist/governance/index.d.ts.map +1 -0
  489. package/dist/governance/nist-ai-rmf.d.ts +15 -0
  490. package/dist/governance/nist-ai-rmf.d.ts.map +1 -0
  491. package/dist/governance/soc2.d.ts +12 -0
  492. package/dist/governance/soc2.d.ts.map +1 -0
  493. package/dist/governance/types.d.ts +66 -0
  494. package/dist/governance/types.d.ts.map +1 -0
  495. package/dist/harness-optimizer.d.ts +82 -0
  496. package/dist/harness-optimizer.d.ts.map +1 -0
  497. package/dist/held-out-gate.d.ts +135 -0
  498. package/dist/held-out-gate.d.ts.map +1 -0
  499. package/dist/hosted/client.d.ts +73 -0
  500. package/dist/hosted/client.d.ts.map +1 -0
  501. package/dist/hosted/from-env.test.d.ts +8 -0
  502. package/dist/hosted/from-env.test.d.ts.map +1 -0
  503. package/dist/hosted/index.d.ts +10 -238
  504. package/dist/hosted/index.d.ts.map +1 -0
  505. package/dist/hosted/types.d.ts +159 -0
  506. package/dist/hosted/types.d.ts.map +1 -0
  507. package/dist/index.d.ts +277 -5643
  508. package/dist/index.d.ts.map +1 -0
  509. package/dist/index.js +317 -108
  510. package/dist/index.js.map +1 -1
  511. package/dist/integrity/backend-integrity.d.ts +71 -0
  512. package/dist/integrity/backend-integrity.d.ts.map +1 -0
  513. package/dist/integrity/preflight.d.ts +72 -0
  514. package/dist/integrity/preflight.d.ts.map +1 -0
  515. package/dist/integrity/preflight.test.d.ts +2 -0
  516. package/dist/integrity/preflight.test.d.ts.map +1 -0
  517. package/dist/integrity/single-backend.d.ts +67 -0
  518. package/dist/integrity/single-backend.d.ts.map +1 -0
  519. package/dist/intent-match-judge.d.ts +69 -0
  520. package/dist/intent-match-judge.d.ts.map +1 -0
  521. package/dist/intent-match-judge.test.d.ts +2 -0
  522. package/dist/intent-match-judge.test.d.ts.map +1 -0
  523. package/dist/{judge-calibration-0p2QcWNE.d.ts → judge-calibration.d.ts} +16 -17
  524. package/dist/judge-calibration.d.ts.map +1 -0
  525. package/dist/judge-ensemble.d.ts +66 -0
  526. package/dist/judge-ensemble.d.ts.map +1 -0
  527. package/dist/judge-ensemble.test.d.ts +8 -0
  528. package/dist/judge-ensemble.test.d.ts.map +1 -0
  529. package/dist/judge-families.d.ts +38 -0
  530. package/dist/judge-families.d.ts.map +1 -0
  531. package/dist/judge-panel.d.ts +65 -0
  532. package/dist/judge-panel.d.ts.map +1 -0
  533. package/dist/judge-retry.d.ts +70 -0
  534. package/dist/judge-retry.d.ts.map +1 -0
  535. package/dist/judge-runner.d.ts +36 -0
  536. package/dist/judge-runner.d.ts.map +1 -0
  537. package/dist/judge-runner.test.d.ts +2 -0
  538. package/dist/judge-runner.test.d.ts.map +1 -0
  539. package/dist/judges.d.ts +74 -0
  540. package/dist/judges.d.ts.map +1 -0
  541. package/dist/keyword-coverage-judge.d.ts +89 -0
  542. package/dist/keyword-coverage-judge.d.ts.map +1 -0
  543. package/dist/keyword-coverage-judge.test.d.ts +2 -0
  544. package/dist/keyword-coverage-judge.test.d.ts.map +1 -0
  545. package/dist/knowledge/index.d.ts +3 -103
  546. package/dist/knowledge/index.d.ts.map +1 -0
  547. package/dist/knowledge/readiness.d.ts +26 -0
  548. package/dist/knowledge/readiness.d.ts.map +1 -0
  549. package/dist/knowledge/types.d.ts +75 -0
  550. package/dist/knowledge/types.d.ts.map +1 -0
  551. package/dist/live-proof.d.ts +62 -0
  552. package/dist/live-proof.d.ts.map +1 -0
  553. package/dist/{llm-client-BeEcAokY.d.ts → llm-client.d.ts} +52 -23
  554. package/dist/llm-client.d.ts.map +1 -0
  555. package/dist/llm-client.test.d.ts +2 -0
  556. package/dist/llm-client.test.d.ts.map +1 -0
  557. package/dist/locked-jsonl-appender.d.ts +19 -0
  558. package/dist/locked-jsonl-appender.d.ts.map +1 -0
  559. package/dist/matrix/aggregation.d.ts +16 -0
  560. package/dist/matrix/aggregation.d.ts.map +1 -0
  561. package/dist/matrix/index.d.ts +12 -30
  562. package/dist/matrix/index.d.ts.map +1 -0
  563. package/dist/matrix/runner.d.ts +15 -0
  564. package/dist/matrix/runner.d.ts.map +1 -0
  565. package/dist/{types-mn5Aqk7x.d.ts → matrix/types.d.ts} +11 -15
  566. package/dist/matrix/types.d.ts.map +1 -0
  567. package/dist/meta-eval/calibration.d.ts +47 -0
  568. package/dist/meta-eval/calibration.d.ts.map +1 -0
  569. package/dist/meta-eval/correlation-study.d.ts +53 -0
  570. package/dist/meta-eval/correlation-study.d.ts.map +1 -0
  571. package/dist/meta-eval/index.d.ts +6 -181
  572. package/dist/meta-eval/index.d.ts.map +1 -0
  573. package/dist/meta-eval/index.js +1 -1
  574. package/dist/{outcome-store-rnXLEqSn.d.ts → meta-eval/outcome-store.d.ts} +7 -8
  575. package/dist/meta-eval/outcome-store.d.ts.map +1 -0
  576. package/dist/{rubric-predictive-validity-Cy_W-hWZ.d.ts → meta-eval/rubric-predictive-validity.d.ts} +8 -11
  577. package/dist/meta-eval/rubric-predictive-validity.d.ts.map +1 -0
  578. package/dist/meta-eval/sentinel.d.ts +169 -0
  579. package/dist/meta-eval/sentinel.d.ts.map +1 -0
  580. package/dist/metrics.d.ts +63 -0
  581. package/dist/metrics.d.ts.map +1 -0
  582. package/dist/model-seats.d.ts +71 -0
  583. package/dist/model-seats.d.ts.map +1 -0
  584. package/dist/model-seats.test.d.ts +2 -0
  585. package/dist/model-seats.test.d.ts.map +1 -0
  586. package/dist/muffled-gate-scanner.d.ts +102 -0
  587. package/dist/muffled-gate-scanner.d.ts.map +1 -0
  588. package/dist/{multi-layer-verifier-DUZXrPDA.d.ts → multi-layer-verifier.d.ts} +12 -15
  589. package/dist/multi-layer-verifier.d.ts.map +1 -0
  590. package/dist/multi-layer-verifier.test.d.ts +2 -0
  591. package/dist/multi-layer-verifier.test.d.ts.map +1 -0
  592. package/dist/multi-toolchain-layer.d.ts +80 -0
  593. package/dist/multi-toolchain-layer.d.ts.map +1 -0
  594. package/dist/multi-toolchain-layer.test.d.ts +2 -0
  595. package/dist/multi-toolchain-layer.test.d.ts.map +1 -0
  596. package/dist/multishot/default-tools.d.ts +34 -0
  597. package/dist/multishot/default-tools.d.ts.map +1 -0
  598. package/dist/multishot/index.d.ts +7 -290
  599. package/dist/multishot/index.d.ts.map +1 -0
  600. package/dist/multishot/index.js.map +1 -1
  601. package/dist/multishot/judges.d.ts +32 -0
  602. package/dist/multishot/judges.d.ts.map +1 -0
  603. package/dist/multishot/matrix.d.ts +107 -0
  604. package/dist/multishot/matrix.d.ts.map +1 -0
  605. package/dist/multishot/multishot.d.ts +23 -0
  606. package/dist/multishot/multishot.d.ts.map +1 -0
  607. package/dist/multishot/router.d.ts +37 -0
  608. package/dist/multishot/router.d.ts.map +1 -0
  609. package/dist/multishot/types.d.ts +60 -0
  610. package/dist/multishot/types.d.ts.map +1 -0
  611. package/dist/observability.d.ts +71 -0
  612. package/dist/observability.d.ts.map +1 -0
  613. package/dist/openapi.json +1 -1
  614. package/dist/oracle.d.ts +55 -0
  615. package/dist/oracle.d.ts.map +1 -0
  616. package/dist/orthogonality.d.ts +35 -0
  617. package/dist/orthogonality.d.ts.map +1 -0
  618. package/dist/otel-pipeline.d.ts +31 -0
  619. package/dist/otel-pipeline.d.ts.map +1 -0
  620. package/dist/paraphrase.d.ts +107 -0
  621. package/dist/paraphrase.d.ts.map +1 -0
  622. package/dist/{pareto-E-pembql.d.ts → pareto.d.ts} +9 -10
  623. package/dist/pareto.d.ts.map +1 -0
  624. package/dist/partition-held-out.d.ts +70 -0
  625. package/dist/partition-held-out.d.ts.map +1 -0
  626. package/dist/partition-held-out.test.d.ts +2 -0
  627. package/dist/partition-held-out.test.d.ts.map +1 -0
  628. package/dist/perf/index.d.ts +13 -119
  629. package/dist/perf/index.d.ts.map +1 -0
  630. package/dist/perf/integrity.d.ts +30 -0
  631. package/dist/perf/integrity.d.ts.map +1 -0
  632. package/dist/perf/journey.d.ts +45 -0
  633. package/dist/perf/journey.d.ts.map +1 -0
  634. package/dist/perf/ratchet.d.ts +47 -0
  635. package/dist/perf/ratchet.d.ts.map +1 -0
  636. package/dist/pipelines/budget-breach.d.ts +31 -0
  637. package/dist/pipelines/budget-breach.d.ts.map +1 -0
  638. package/dist/pipelines/budget-breach.test.d.ts +2 -0
  639. package/dist/pipelines/budget-breach.test.d.ts.map +1 -0
  640. package/dist/pipelines/failure-cluster.d.ts +38 -0
  641. package/dist/pipelines/failure-cluster.d.ts.map +1 -0
  642. package/dist/pipelines/failure-cluster.test.d.ts +2 -0
  643. package/dist/pipelines/failure-cluster.test.d.ts.map +1 -0
  644. package/dist/pipelines/first-divergence.d.ts +26 -0
  645. package/dist/pipelines/first-divergence.d.ts.map +1 -0
  646. package/dist/pipelines/first-divergence.test.d.ts +2 -0
  647. package/dist/pipelines/first-divergence.test.d.ts.map +1 -0
  648. package/dist/pipelines/index.d.ts +8 -173
  649. package/dist/pipelines/index.d.ts.map +1 -0
  650. package/dist/pipelines/index.js +40 -15
  651. package/dist/pipelines/index.js.map +1 -1
  652. package/dist/pipelines/judge-agreement.d.ts +26 -0
  653. package/dist/pipelines/judge-agreement.d.ts.map +1 -0
  654. package/dist/pipelines/judge-agreement.test.d.ts +2 -0
  655. package/dist/pipelines/judge-agreement.test.d.ts.map +1 -0
  656. package/dist/pipelines/regression.d.ts +23 -0
  657. package/dist/pipelines/regression.d.ts.map +1 -0
  658. package/dist/pipelines/regression.test.d.ts +2 -0
  659. package/dist/pipelines/regression.test.d.ts.map +1 -0
  660. package/dist/pipelines/stuck-loop.d.ts +32 -0
  661. package/dist/pipelines/stuck-loop.d.ts.map +1 -0
  662. package/dist/pipelines/stuck-loop.test.d.ts +2 -0
  663. package/dist/pipelines/stuck-loop.test.d.ts.map +1 -0
  664. package/dist/pipelines/tool-waste.d.ts +34 -0
  665. package/dist/pipelines/tool-waste.d.ts.map +1 -0
  666. package/dist/pipelines/tool-waste.test.d.ts +2 -0
  667. package/dist/pipelines/tool-waste.test.d.ts.map +1 -0
  668. package/dist/playbook.d.ts +16 -0
  669. package/dist/playbook.d.ts.map +1 -0
  670. package/dist/pr-review-benchmark.d.ts +88 -0
  671. package/dist/pr-review-benchmark.d.ts.map +1 -0
  672. package/dist/pr-review-benchmark.test.d.ts +2 -0
  673. package/dist/pr-review-benchmark.test.d.ts.map +1 -0
  674. package/dist/pre-registration.d.ts +125 -0
  675. package/dist/pre-registration.d.ts.map +1 -0
  676. package/dist/prm/builtin-rubrics.d.ts +33 -0
  677. package/dist/prm/builtin-rubrics.d.ts.map +1 -0
  678. package/dist/prm/index.d.ts +5 -100
  679. package/dist/prm/index.d.ts.map +1 -0
  680. package/dist/prm/index.js +55 -12
  681. package/dist/prm/index.js.map +1 -1
  682. package/dist/prm/inference.d.ts +29 -0
  683. package/dist/prm/inference.d.ts.map +1 -0
  684. package/dist/prm/inference.test.d.ts +2 -0
  685. package/dist/prm/inference.test.d.ts.map +1 -0
  686. package/dist/{rubric-BOfxn4ja.d.ts → prm/rubric.d.ts} +10 -13
  687. package/dist/prm/rubric.d.ts.map +1 -0
  688. package/dist/prm/training-export.d.ts +38 -0
  689. package/dist/prm/training-export.d.ts.map +1 -0
  690. package/dist/produced-state.d.ts +63 -0
  691. package/dist/produced-state.d.ts.map +1 -0
  692. package/dist/produced-state.test.d.ts +8 -0
  693. package/dist/produced-state.test.d.ts.map +1 -0
  694. package/dist/profile/baselines.d.ts +37 -0
  695. package/dist/profile/baselines.d.ts.map +1 -0
  696. package/dist/profile/index.d.ts +105 -0
  697. package/dist/profile/index.d.ts.map +1 -0
  698. package/dist/promotion-gate.d.ts +93 -0
  699. package/dist/promotion-gate.d.ts.map +1 -0
  700. package/dist/prompt-registry.d.ts +41 -0
  701. package/dist/prompt-registry.d.ts.map +1 -0
  702. package/dist/propose-review-control.d.ts +49 -0
  703. package/dist/propose-review-control.d.ts.map +1 -0
  704. package/dist/propose-review-control.test.d.ts +2 -0
  705. package/dist/propose-review-control.test.d.ts.map +1 -0
  706. package/dist/propose-review.d.ts +155 -0
  707. package/dist/propose-review.d.ts.map +1 -0
  708. package/dist/{red-team-BXHil6c8.d.ts → red-team.d.ts} +14 -16
  709. package/dist/red-team.d.ts.map +1 -0
  710. package/dist/reference-replay-steering.d.ts +11 -0
  711. package/dist/reference-replay-steering.d.ts.map +1 -0
  712. package/dist/reference-replay.d.ts +176 -0
  713. package/dist/reference-replay.d.ts.map +1 -0
  714. package/dist/reflective-mutation.d.ts +79 -0
  715. package/dist/reflective-mutation.d.ts.map +1 -0
  716. package/dist/registry.d.ts +31 -0
  717. package/dist/registry.d.ts.map +1 -0
  718. package/dist/release-confidence.d.ts +128 -0
  719. package/dist/release-confidence.d.ts.map +1 -0
  720. package/dist/release-report.d.ts +11 -0
  721. package/dist/release-report.d.ts.map +1 -0
  722. package/dist/replay.d.ts +120 -0
  723. package/dist/replay.d.ts.map +1 -0
  724. package/dist/reporter.d.ts +14 -0
  725. package/dist/reporter.d.ts.map +1 -0
  726. package/dist/reporting.d.ts +15 -15
  727. package/dist/reporting.d.ts.map +1 -0
  728. package/dist/reporting.js +3 -3
  729. package/dist/researcher.d.ts +140 -0
  730. package/dist/researcher.d.ts.map +1 -0
  731. package/dist/reviewer.d.ts +118 -0
  732. package/dist/reviewer.d.ts.map +1 -0
  733. package/dist/reviewer.test.d.ts +2 -0
  734. package/dist/reviewer.test.d.ts.map +1 -0
  735. package/dist/reward-model-export.d.ts +60 -0
  736. package/dist/reward-model-export.d.ts.map +1 -0
  737. package/dist/rl/active-curriculum.d.ts +110 -0
  738. package/dist/rl/active-curriculum.d.ts.map +1 -0
  739. package/dist/rl/adaptation-eval.d.ts +109 -0
  740. package/dist/rl/adaptation-eval.d.ts.map +1 -0
  741. package/dist/{adversarial-DIVcDoI_.d.ts → rl/adversarial.d.ts} +6 -7
  742. package/dist/rl/adversarial.d.ts.map +1 -0
  743. package/dist/rl/compute-curves.d.ts +127 -0
  744. package/dist/rl/compute-curves.d.ts.map +1 -0
  745. package/dist/rl/contamination.d.ts +117 -0
  746. package/dist/rl/contamination.d.ts.map +1 -0
  747. package/dist/rl/corpus.d.ts +55 -0
  748. package/dist/rl/corpus.d.ts.map +1 -0
  749. package/dist/rl/corpus.test.d.ts +2 -0
  750. package/dist/rl/corpus.test.d.ts.map +1 -0
  751. package/dist/rl/dataset.d.ts +102 -0
  752. package/dist/rl/dataset.d.ts.map +1 -0
  753. package/dist/rl/dataset.test.d.ts +2 -0
  754. package/dist/rl/dataset.test.d.ts.map +1 -0
  755. package/dist/rl/exporters.d.ts +141 -0
  756. package/dist/rl/exporters.d.ts.map +1 -0
  757. package/dist/rl/index.d.ts +49 -0
  758. package/dist/rl/index.d.ts.map +1 -0
  759. package/dist/{off-policy-DiwuKKg7.d.ts → rl/off-policy.d.ts} +8 -9
  760. package/dist/rl/off-policy.d.ts.map +1 -0
  761. package/dist/rl/predictive-validity-researcher.d.ts +69 -0
  762. package/dist/rl/predictive-validity-researcher.d.ts.map +1 -0
  763. package/dist/rl/preferences.d.ts +141 -0
  764. package/dist/rl/preferences.d.ts.map +1 -0
  765. package/dist/rl/process-reward.d.ts +122 -0
  766. package/dist/rl/process-reward.d.ts.map +1 -0
  767. package/dist/rl/reward-hacking.d.ts +104 -0
  768. package/dist/rl/reward-hacking.d.ts.map +1 -0
  769. package/dist/rl/rl-campaign.d.ts +85 -0
  770. package/dist/rl/rl-campaign.d.ts.map +1 -0
  771. package/dist/rl/run-record-adapters.d.ts +56 -0
  772. package/dist/rl/run-record-adapters.d.ts.map +1 -0
  773. package/dist/rl/sim-fidelity.d.ts +166 -0
  774. package/dist/rl/sim-fidelity.d.ts.map +1 -0
  775. package/dist/rl/sim-fidelity.test.d.ts +2 -0
  776. package/dist/rl/sim-fidelity.test.d.ts.map +1 -0
  777. package/dist/rl/tournament.d.ts +115 -0
  778. package/dist/rl/tournament.d.ts.map +1 -0
  779. package/dist/rl/verifiable-reward.d.ts +124 -0
  780. package/dist/rl/verifiable-reward.d.ts.map +1 -0
  781. package/dist/rl.d.ts +1 -1192
  782. package/dist/rl.js +615 -615
  783. package/dist/rl.js.map +1 -1
  784. package/dist/{run-campaign-RDGAM5KJ.js → run-campaign-WXY7KI67.js} +3 -3
  785. package/dist/run-critic.d.ts +23 -0
  786. package/dist/run-critic.d.ts.map +1 -0
  787. package/dist/run-evidence.d.ts +32 -0
  788. package/dist/run-evidence.d.ts.map +1 -0
  789. package/dist/{run-record-e7vj1uZQ.d.ts → run-record.d.ts} +16 -122
  790. package/dist/run-record.d.ts.map +1 -0
  791. package/dist/run-record.test.d.ts +2 -0
  792. package/dist/run-record.test.d.ts.map +1 -0
  793. package/dist/run-score.d.ts +31 -0
  794. package/dist/run-score.d.ts.map +1 -0
  795. package/dist/runtime-trajectory.d.ts +47 -0
  796. package/dist/runtime-trajectory.d.ts.map +1 -0
  797. package/dist/{test-graded-scenario-BdVaPyHT.d.ts → sandbox-harness.d.ts} +34 -60
  798. package/dist/sandbox-harness.d.ts.map +1 -0
  799. package/dist/sandbox-harness.test.d.ts +2 -0
  800. package/dist/sandbox-harness.test.d.ts.map +1 -0
  801. package/dist/sandbox-pool.d.ts +74 -0
  802. package/dist/sandbox-pool.d.ts.map +1 -0
  803. package/dist/sandbox-pool.test.d.ts +2 -0
  804. package/dist/sandbox-pool.test.d.ts.map +1 -0
  805. package/dist/scorecard.d.ts +133 -0
  806. package/dist/scorecard.d.ts.map +1 -0
  807. package/dist/scorecard.test.d.ts +2 -0
  808. package/dist/scorecard.test.d.ts.map +1 -0
  809. package/dist/self-play.d.ts +69 -0
  810. package/dist/self-play.d.ts.map +1 -0
  811. package/dist/semantic-concept-judge.d.ts +135 -0
  812. package/dist/semantic-concept-judge.d.ts.map +1 -0
  813. package/dist/semantic-concept-judge.test.d.ts +2 -0
  814. package/dist/semantic-concept-judge.test.d.ts.map +1 -0
  815. package/dist/{sequential-5iSVfzl2.d.ts → sequential.d.ts} +9 -10
  816. package/dist/sequential.d.ts.map +1 -0
  817. package/dist/{series-convergence-D5OWMBg6.d.ts → series-convergence.d.ts} +4 -5
  818. package/dist/series-convergence.d.ts.map +1 -0
  819. package/dist/slo.d.ts +48 -0
  820. package/dist/slo.d.ts.map +1 -0
  821. package/dist/state-continuity.d.ts +47 -0
  822. package/dist/state-continuity.d.ts.map +1 -0
  823. package/dist/{statistics-C7PozGrZ.d.ts → statistics.d.ts} +152 -39
  824. package/dist/statistics.d.ts.map +1 -0
  825. package/dist/statistics.test.d.ts +2 -0
  826. package/dist/statistics.test.d.ts.map +1 -0
  827. package/dist/steering-optimizer.d.ts +58 -0
  828. package/dist/steering-optimizer.d.ts.map +1 -0
  829. package/dist/steering.d.ts +24 -0
  830. package/dist/steering.d.ts.map +1 -0
  831. package/dist/storyboard/code-edit.d.ts +64 -0
  832. package/dist/storyboard/code-edit.d.ts.map +1 -0
  833. package/dist/storyboard/code-edit.test.d.ts +2 -0
  834. package/dist/storyboard/code-edit.test.d.ts.map +1 -0
  835. package/dist/storyboard/index.d.ts +16 -81
  836. package/dist/storyboard/index.d.ts.map +1 -0
  837. package/dist/storyboard/index.test.d.ts +2 -0
  838. package/dist/storyboard/index.test.d.ts.map +1 -0
  839. package/dist/{summary-report-DGmUucwQ.d.ts → summary-report.d.ts} +23 -160
  840. package/dist/summary-report.d.ts.map +1 -0
  841. package/dist/telemetry/client.d.ts +35 -0
  842. package/dist/telemetry/client.d.ts.map +1 -0
  843. package/dist/telemetry/index.d.ts +17 -35
  844. package/dist/telemetry/index.d.ts.map +1 -0
  845. package/dist/telemetry/schema.d.ts +61 -0
  846. package/dist/telemetry/schema.d.ts.map +1 -0
  847. package/dist/telemetry/sink-fetch.d.ts +39 -0
  848. package/dist/telemetry/sink-fetch.d.ts.map +1 -0
  849. package/dist/telemetry/{file.d.ts → sink-file.d.ts} +5 -7
  850. package/dist/telemetry/sink-file.d.ts.map +1 -0
  851. package/dist/test-graded-scenario.d.ts +42 -0
  852. package/dist/test-graded-scenario.d.ts.map +1 -0
  853. package/dist/testing.d.ts +5 -0
  854. package/dist/testing.d.ts.map +1 -0
  855. package/dist/testing.js +8 -0
  856. package/dist/testing.js.map +1 -0
  857. package/dist/tool-use-metrics.d.ts +35 -0
  858. package/dist/tool-use-metrics.d.ts.map +1 -0
  859. package/dist/trace/capture-fetch.d.ts +48 -0
  860. package/dist/trace/capture-fetch.d.ts.map +1 -0
  861. package/dist/trace/capture-fetch.test.d.ts +2 -0
  862. package/dist/trace/capture-fetch.test.d.ts.map +1 -0
  863. package/dist/{emitter-DEZwY14K.d.ts → trace/emitter.d.ts} +9 -12
  864. package/dist/trace/emitter.d.ts.map +1 -0
  865. package/dist/trace/extract-usage.d.ts +46 -0
  866. package/dist/trace/extract-usage.d.ts.map +1 -0
  867. package/dist/trace/extract-usage.test.d.ts +2 -0
  868. package/dist/trace/extract-usage.test.d.ts.map +1 -0
  869. package/dist/trace/index.d.ts +15 -0
  870. package/dist/trace/index.d.ts.map +1 -0
  871. package/dist/{integrity-VJ9A7aST.d.ts → trace/integrity.d.ts} +11 -14
  872. package/dist/trace/integrity.d.ts.map +1 -0
  873. package/dist/trace/otel-bridge.d.ts +29 -0
  874. package/dist/trace/otel-bridge.d.ts.map +1 -0
  875. package/dist/trace/otel-export.d.ts +52 -0
  876. package/dist/trace/otel-export.d.ts.map +1 -0
  877. package/dist/trace/otel.d.ts +57 -0
  878. package/dist/trace/otel.d.ts.map +1 -0
  879. package/dist/trace/otlp-attributes.d.ts +17 -0
  880. package/dist/trace/otlp-attributes.d.ts.map +1 -0
  881. package/dist/trace/query.d.ts +29 -0
  882. package/dist/trace/query.d.ts.map +1 -0
  883. package/dist/trace/query.test.d.ts +2 -0
  884. package/dist/trace/query.test.d.ts.map +1 -0
  885. package/dist/{raw-provider-sink-C46HDghv.d.ts → trace/raw-provider-sink.d.ts} +13 -14
  886. package/dist/trace/raw-provider-sink.d.ts.map +1 -0
  887. package/dist/{redact-B40YG2M_.d.ts → trace/redact.d.ts} +7 -8
  888. package/dist/trace/redact.d.ts.map +1 -0
  889. package/dist/{schema-m0gsnbt3.d.ts → trace/schema.d.ts} +29 -30
  890. package/dist/trace/schema.d.ts.map +1 -0
  891. package/dist/trace/store-to-otlp.d.ts +72 -0
  892. package/dist/trace/store-to-otlp.d.ts.map +1 -0
  893. package/dist/trace/store-to-otlp.test.d.ts +2 -0
  894. package/dist/trace/store-to-otlp.test.d.ts.map +1 -0
  895. package/dist/{store-CKUAgsJz.d.ts → trace/store.d.ts} +37 -13
  896. package/dist/trace/store.d.ts.map +1 -0
  897. package/dist/trace/store.test.d.ts +2 -0
  898. package/dist/trace/store.test.d.ts.map +1 -0
  899. package/dist/{analyst-C8HHvfJp.d.ts → trace-analyst/analyst.d.ts} +12 -14
  900. package/dist/trace-analyst/analyst.d.ts.map +1 -0
  901. package/dist/trace-analyst/analyst.test.d.ts +2 -0
  902. package/dist/trace-analyst/analyst.test.d.ts.map +1 -0
  903. package/dist/trace-analyst/behavioral-metrics.d.ts +40 -0
  904. package/dist/trace-analyst/behavioral-metrics.d.ts.map +1 -0
  905. package/dist/trace-analyst/behavioral-metrics.test.d.ts +2 -0
  906. package/dist/trace-analyst/behavioral-metrics.test.d.ts.map +1 -0
  907. package/dist/trace-analyst/hook.d.ts +55 -0
  908. package/dist/trace-analyst/hook.d.ts.map +1 -0
  909. package/dist/trace-analyst/index.d.ts +18 -0
  910. package/dist/trace-analyst/index.d.ts.map +1 -0
  911. package/dist/trace-analyst/insights.d.ts +71 -0
  912. package/dist/trace-analyst/insights.d.ts.map +1 -0
  913. package/dist/trace-analyst/insights.test.d.ts +2 -0
  914. package/dist/trace-analyst/insights.test.d.ts.map +1 -0
  915. package/dist/trace-analyst/otlp-flatten.d.ts +42 -0
  916. package/dist/trace-analyst/otlp-flatten.d.ts.map +1 -0
  917. package/dist/trace-analyst/otlp-span.d.ts +85 -0
  918. package/dist/trace-analyst/otlp-span.d.ts.map +1 -0
  919. package/dist/trace-analyst/otlp-span.test.d.ts +2 -0
  920. package/dist/trace-analyst/otlp-span.test.d.ts.map +1 -0
  921. package/dist/trace-analyst/otlp-to-run-records.d.ts +115 -0
  922. package/dist/trace-analyst/otlp-to-run-records.d.ts.map +1 -0
  923. package/dist/trace-analyst/otlp-to-run-records.test.d.ts +2 -0
  924. package/dist/trace-analyst/otlp-to-run-records.test.d.ts.map +1 -0
  925. package/dist/trace-analyst/otlp-to-run-records.timestamps.test.d.ts +2 -0
  926. package/dist/trace-analyst/otlp-to-run-records.timestamps.test.d.ts.map +1 -0
  927. package/dist/trace-analyst/prompts.d.ts +6 -0
  928. package/dist/trace-analyst/prompts.d.ts.map +1 -0
  929. package/dist/trace-analyst/store-otlp.d.ts +126 -0
  930. package/dist/trace-analyst/store-otlp.d.ts.map +1 -0
  931. package/dist/trace-analyst/store-otlp.test.d.ts +8 -0
  932. package/dist/trace-analyst/store-otlp.test.d.ts.map +1 -0
  933. package/dist/trace-analyst/store-otlp.timestamps.test.d.ts +2 -0
  934. package/dist/trace-analyst/store-otlp.timestamps.test.d.ts.map +1 -0
  935. package/dist/trace-analyst/store.d.ts +63 -0
  936. package/dist/trace-analyst/store.d.ts.map +1 -0
  937. package/dist/trace-analyst/tools.d.ts +44 -0
  938. package/dist/trace-analyst/tools.d.ts.map +1 -0
  939. package/dist/trace-analyst/tools.test.d.ts +10 -0
  940. package/dist/trace-analyst/tools.test.d.ts.map +1 -0
  941. package/dist/{store-C1YxJDEK.d.ts → trace-analyst/types.d.ts} +18 -74
  942. package/dist/trace-analyst/types.d.ts.map +1 -0
  943. package/dist/trace-contracts.d.ts +180 -0
  944. package/dist/trace-contracts.d.ts.map +1 -0
  945. package/dist/traced-analyst.d.ts +26 -0
  946. package/dist/traced-analyst.d.ts.map +1 -0
  947. package/dist/traced-judges.d.ts +27 -0
  948. package/dist/traced-judges.d.ts.map +1 -0
  949. package/dist/traces.d.ts +4 -947
  950. package/dist/traces.d.ts.map +1 -0
  951. package/dist/traces.js +42 -12
  952. package/dist/{trajectory-GEdXJCL5.d.ts → trajectory.d.ts} +8 -9
  953. package/dist/trajectory.d.ts.map +1 -0
  954. package/dist/{types-Croy5h7V.d.ts → types.d.ts} +33 -33
  955. package/dist/types.d.ts.map +1 -0
  956. package/dist/ui-finding.d.ts +104 -0
  957. package/dist/ui-finding.d.ts.map +1 -0
  958. package/dist/verdict-cache.d.ts +78 -0
  959. package/dist/verdict-cache.d.ts.map +1 -0
  960. package/dist/verdict-cache.test.d.ts +2 -0
  961. package/dist/verdict-cache.test.d.ts.map +1 -0
  962. package/dist/{verdict-C9MlYujm.d.ts → verdict.d.ts} +2 -3
  963. package/dist/verdict.d.ts.map +1 -0
  964. package/dist/visual-diff.d.ts +32 -0
  965. package/dist/visual-diff.d.ts.map +1 -0
  966. package/dist/wire/handlers.d.ts +54 -0
  967. package/dist/wire/handlers.d.ts.map +1 -0
  968. package/dist/wire/index.d.ts +13 -570
  969. package/dist/wire/index.d.ts.map +1 -0
  970. package/dist/wire/index.js +2 -2
  971. package/dist/wire/openapi.d.ts +3 -0
  972. package/dist/wire/openapi.d.ts.map +1 -0
  973. package/dist/wire/rpc.d.ts +21 -0
  974. package/dist/wire/rpc.d.ts.map +1 -0
  975. package/dist/wire/rubrics.d.ts +34 -0
  976. package/dist/wire/rubrics.d.ts.map +1 -0
  977. package/dist/wire/schemas.d.ts +410 -0
  978. package/dist/wire/schemas.d.ts.map +1 -0
  979. package/dist/wire/server.d.ts +60 -0
  980. package/dist/wire/server.d.ts.map +1 -0
  981. package/dist/workflow/event-schema.d.ts +5 -0
  982. package/dist/workflow/event-schema.d.ts.map +1 -0
  983. package/dist/workflow/feedback-pack.d.ts +99 -0
  984. package/dist/workflow/feedback-pack.d.ts.map +1 -0
  985. package/dist/workflow/index.d.ts +22 -495
  986. package/dist/workflow/index.d.ts.map +1 -0
  987. package/dist/workflow/index.js +2 -2
  988. package/dist/workflow/intelligence-export.d.ts +62 -0
  989. package/dist/workflow/intelligence-export.d.ts.map +1 -0
  990. package/dist/workflow/partner-report.d.ts +49 -0
  991. package/dist/workflow/partner-report.d.ts.map +1 -0
  992. package/dist/workflow/phase-graph.d.ts +43 -0
  993. package/dist/workflow/phase-graph.d.ts.map +1 -0
  994. package/dist/workflow/promotion-gate.d.ts +61 -0
  995. package/dist/workflow/promotion-gate.d.ts.map +1 -0
  996. package/dist/workflow/run-record.d.ts +12 -0
  997. package/dist/workflow/run-record.d.ts.map +1 -0
  998. package/dist/workflow/runtime-adapter.d.ts +20 -0
  999. package/dist/workflow/runtime-adapter.d.ts.map +1 -0
  1000. package/dist/workflow/sanitize.d.ts +21 -0
  1001. package/dist/workflow/sanitize.d.ts.map +1 -0
  1002. package/dist/workflow/schema.d.ts +5 -0
  1003. package/dist/workflow/schema.d.ts.map +1 -0
  1004. package/dist/workflow/summary.d.ts +43 -0
  1005. package/dist/workflow/summary.d.ts.map +1 -0
  1006. package/dist/workflow/trace-event-fields.d.ts +6 -0
  1007. package/dist/workflow/trace-event-fields.d.ts.map +1 -0
  1008. package/dist/workflow/trajectory.d.ts +15 -0
  1009. package/dist/workflow/trajectory.d.ts.map +1 -0
  1010. package/dist/workflow/types.d.ts +68 -0
  1011. package/dist/workflow/types.d.ts.map +1 -0
  1012. package/dist/workspace-inspector.d.ts +67 -0
  1013. package/dist/workspace-inspector.d.ts.map +1 -0
  1014. package/dist/wrangler-deploy-runner.test.d.ts +2 -0
  1015. package/dist/wrangler-deploy-runner.test.d.ts.map +1 -0
  1016. package/docs/campaign-proposers.md +170 -0
  1017. package/docs/concepts.md +8 -4
  1018. package/docs/customer-journeys.md +15 -13
  1019. package/docs/design/loop-taxonomy.md +34 -66
  1020. package/docs/distributed-driver.md +14 -14
  1021. package/docs/feature-guide.md +1 -1
  1022. package/docs/hosted-ingest-spec.md +2 -3
  1023. package/docs/multi-shot-optimization.md +8 -8
  1024. package/docs/product-eval-adoption.md +1 -1
  1025. package/docs/self-improvement-map.md +33 -29
  1026. package/package.json +9 -15
  1027. package/dist/calibration-Cpr3WaX3.d.ts +0 -101
  1028. package/dist/chunk-47X6LRCE.js.map +0 -1
  1029. package/dist/chunk-6SOJM3VR.js.map +0 -1
  1030. package/dist/chunk-CVVHBFGN.js.map +0 -1
  1031. package/dist/chunk-D3V5B42D.js.map +0 -1
  1032. package/dist/chunk-E4GH6USR.js.map +0 -1
  1033. package/dist/chunk-GSH6QNNS.js.map +0 -1
  1034. package/dist/chunk-KWRRMR3J.js.map +0 -1
  1035. package/dist/chunk-LMZQ2Z4U.js.map +0 -1
  1036. package/dist/chunk-QAY5UIJO.js.map +0 -1
  1037. package/dist/chunk-QG2OVF2D.js.map +0 -1
  1038. package/dist/chunk-T375SUOZ.js.map +0 -1
  1039. package/dist/chunk-TWS7AZEY.js.map +0 -1
  1040. package/dist/chunk-UMMZHCPB.js.map +0 -1
  1041. package/dist/chunk-XY4DDNEG.js.map +0 -1
  1042. package/dist/chunk-ZFIBGEOL.js.map +0 -1
  1043. package/dist/control-_Qb7skHX.d.ts +0 -259
  1044. package/dist/corpus-BoR-041R.d.ts +0 -560
  1045. package/dist/failure-cluster-CL7IVgkJ.d.ts +0 -76
  1046. package/dist/harness-optimizer-EnEnQPsr.d.ts +0 -106
  1047. package/dist/index-Bx3gZ8xl.d.ts +0 -159
  1048. package/dist/pre-registration-mAnCugl9.d.ts +0 -523
  1049. package/dist/provenance-LnqRT0sS.d.ts +0 -441
  1050. package/dist/query-CqTxMwDw.d.ts +0 -31
  1051. package/dist/release-report-euXIV_Sk.d.ts +0 -233
  1052. package/dist/run-critic-BAIjX99r.d.ts +0 -56
  1053. package/dist/run-improvement-loop-5z_l5zDz.d.ts +0 -427
  1054. package/dist/runtime-trajectory-BDgfGZSr.d.ts +0 -49
  1055. package/dist/semantic-concept-judge-Dn8Z6KEG.d.ts +0 -624
  1056. package/dist/sink-fetch-B1Yg4Til.d.ts +0 -101
  1057. package/docs/design/external-agent-wedge.md +0 -89
  1058. package/docs/design/phase-d-rfc.md +0 -125
  1059. package/docs/design/phase4-consumer-migration.md +0 -70
  1060. package/docs/design/primitives-integration-spec.md +0 -393
  1061. package/docs/design/product-self-improvement-loop.md +0 -146
  1062. package/docs/design/self-improvement-engine.md +0 -140
  1063. package/docs/design/self-improvement-protocol.md +0 -223
  1064. package/docs/design/self-improvement-roadmap.md +0 -106
  1065. package/docs/design/substrate-gaps.md +0 -118
  1066. package/docs/phase-b-pairing-kit.md +0 -188
  1067. package/docs/phase-b-runbook.md +0 -176
  1068. package/docs/pilot/README.md +0 -62
  1069. package/docs/pilot/customer-checklist.md +0 -90
  1070. package/docs/pilot/integration-foreign-stack.md +0 -296
  1071. package/docs/pilot/integration-tangle-stack.md +0 -248
  1072. package/docs/pilot/one-pager.md +0 -161
  1073. package/docs/pilot/sample-insight-report.json +0 -172
  1074. package/docs/quickstart-external.md +0 -229
  1075. package/docs/research/belief-state-agent-eval-roadmap.md +0 -593
  1076. package/docs/research/research-roadmap.md +0 -205
  1077. package/docs/specs/driver-honest-spec.md +0 -251
  1078. package/docs/specs/hermes-self-improvement-audit.md +0 -93
  1079. package/docs/specs/profile-versioning.md +0 -291
  1080. package/docs/three-package-architecture.md +0 -168
  1081. /package/dist/{chunk-QS3RBQPI.js.map → chunk-D5KBVULY.js.map} +0 -0
  1082. /package/dist/{chunk-UHMJT4T7.js.map → chunk-IZCEK2HR.js.map} +0 -0
  1083. /package/dist/{chunk-L3JOU6XM.js.map → chunk-NACM5RS7.js.map} +0 -0
  1084. /package/dist/{chunk-4FBZZIYD.js.map → chunk-QTMYW64F.js.map} +0 -0
  1085. /package/dist/{chunk-CY6U5S3X.js.map → chunk-URWVKRCS.js.map} +0 -0
  1086. /package/dist/{chunk-Y47J2LJ3.js.map → chunk-Z6L6YSU6.js.map} +0 -0
  1087. /package/dist/{run-campaign-RDGAM5KJ.js.map → run-campaign-WXY7KI67.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/trace-analyst/behavioral-metrics.ts","../src/analyst/behavioral-analyst.ts","../src/analyst/default-registry.ts"],"sourcesContent":["/**\n * Deterministic behavioral metrics over OTLP spans — pure arithmetic, no LLM.\n *\n * These are the model-independent multiplier: the four trace-quality signals a\n * tolerant analyzer (e.g. HALO) re-derives per run inside the model — token\n * growth, output decay, tool monoculture, missing self-verification — computed\n * here once, in TypeScript, with zero model judgment. A finding that falls out\n * of arithmetic is trivially model-agnostic and cannot hallucinate the trend.\n *\n * General, not trace-specific: the detectors key off token trajectories and\n * tool usage present in any agentic OTLP trace, not any one benchmark.\n */\n\nimport {\n LLM_INPUT_TOKEN_ATTR_KEYS,\n LLM_OUTPUT_TOKEN_ATTR_KEYS,\n TOOL_NAME_ATTR_KEYS,\n} from '../trace/otlp-attributes'\nimport type { TraceAnalystSpan } from './types'\n\nexport type SuboptimalCode =\n | 'monotonic-input-growth'\n | 'output-length-decay'\n | 'single-tool-dependency'\n | 'no-self-verification'\n\nexport interface SuboptimalSignal {\n code: SuboptimalCode\n severity: 'high' | 'medium' | 'low'\n /** Human-readable claim, with the backing numbers inlined. */\n detail: string\n /** The exact figures the detector fired on — auditable, no model in the loop. */\n evidence: Record<string, number | string | boolean>\n}\n\nexport interface BehavioralMetrics {\n llmCallCount: number\n inputTokenTrajectory: number[]\n outputTokenTrajectory: number[]\n toolHistogram: Record<string, number>\n totalToolCalls: number\n distinctTools: number\n /** distinct/total tool calls; 1.0 when there are no tool calls. */\n toolDiversityRatio: number\n hasSelfVerification: boolean\n signals: SuboptimalSignal[]\n}\n\n/** ≥ this input-token growth ratio across a run, with no compression, fires. */\nconst INPUT_GROWTH_FACTOR = 3\n/** Tool-usage signals need at least this many calls to be meaningful. */\nconst MIN_TOOL_CALLS = 3\n/** Tool names matching this are self-verification, not state mutation. */\nconst VERIFY_RE = /verif|eval|inspect|check|assert|validat|review|confirm/i\n\nfunction num(v: unknown): number | null {\n return typeof v === 'number' && Number.isFinite(v) ? v : null\n}\nfunction numAttr(attrs: Record<string, unknown>, keys: readonly string[]): number | null {\n for (const key of keys) {\n const value = num(attrs[key])\n if (value !== null) return value\n }\n return null\n}\nfunction inputTokensOf(s: TraceAnalystSpan): number | null {\n return (\n numAttr(s.attributes, LLM_INPUT_TOKEN_ATTR_KEYS) ?? num(s.attributes['llm.usage.input_tokens'])\n )\n}\nfunction outputTokensOf(s: TraceAnalystSpan): number | null {\n return (\n numAttr(s.attributes, LLM_OUTPUT_TOKEN_ATTR_KEYS) ??\n num(s.attributes['llm.usage.output_tokens'])\n )\n}\nfunction stepOf(s: TraceAnalystSpan): number | null {\n return num(s.attributes.step)\n}\nfunction toolNameOf(s: TraceAnalystSpan): string | null {\n if (s.tool_name) return s.tool_name\n for (const key of TOOL_NAME_ATTR_KEYS) {\n const t = s.attributes[key]\n if (typeof t === 'string' && t.length > 0) return t\n }\n return null\n}\n\n/**\n * Reduce a span list to behavioral metrics + fired suboptimality signals.\n * Pure + deterministic: same spans → same output, on any machine, no model.\n */\nexport function computeTraceMetrics(spans: readonly TraceAnalystSpan[]): BehavioralMetrics {\n // Order by step (when present) then start_time so trajectories reflect run order.\n const ordered = [...spans].sort((a, b) => {\n const sa = stepOf(a)\n const sb = stepOf(b)\n if (sa !== null && sb !== null && sa !== sb) return sa - sb\n return a.start_time.localeCompare(b.start_time)\n })\n\n const inputTokenTrajectory: number[] = []\n const outputTokenTrajectory: number[] = []\n const toolHistogram: Record<string, number> = {}\n let hasSelfVerification = false\n\n for (const s of ordered) {\n const inT = inputTokensOf(s)\n if (inT !== null) inputTokenTrajectory.push(inT)\n const outT = outputTokensOf(s)\n if (outT !== null) outputTokenTrajectory.push(outT)\n const tool = toolNameOf(s)\n if (tool) {\n toolHistogram[tool] = (toolHistogram[tool] ?? 0) + 1\n if (VERIFY_RE.test(tool)) hasSelfVerification = true\n }\n }\n\n const totalToolCalls = Object.values(toolHistogram).reduce((a, b) => a + b, 0)\n const distinctTools = Object.keys(toolHistogram).length\n const toolDiversityRatio = totalToolCalls === 0 ? 1 : distinctTools / totalToolCalls\n\n const signals: SuboptimalSignal[] = []\n\n if (inputTokenTrajectory.length >= 3) {\n const first = inputTokenTrajectory[0]!\n const last = inputTokenTrajectory[inputTokenTrajectory.length - 1]!\n // first === 0 with later growth is an unbounded ratio (0→huge context blowup);\n // treat it as infinite so the signal fires, and report it as such instead of\n // dividing by zero for the displayed factor.\n const growthFromZero = first === 0 && last > 0\n const growth = growthFromZero ? Infinity : first > 0 ? last / first : 0\n if (last > first && growth >= INPUT_GROWTH_FACTOR) {\n const growthLabel = growthFromZero ? '0→nonzero (unbounded)' : `${growth.toFixed(1)}x`\n signals.push({\n code: 'monotonic-input-growth',\n severity: 'high',\n detail: `LLM input tokens grew ${growthLabel} (${first}→${last}) across ${inputTokenTrajectory.length} calls — full history re-sent each step with no compression.`,\n evidence: {\n first,\n last,\n growth_x: growthFromZero ? 'unbounded' : Number(growth.toFixed(2)),\n calls: inputTokenTrajectory.length,\n },\n })\n }\n }\n\n if (outputTokenTrajectory.length >= 3) {\n const first = outputTokenTrajectory[0]!\n const last = outputTokenTrajectory[outputTokenTrajectory.length - 1]!\n if (last < first) {\n signals.push({\n code: 'output-length-decay',\n severity: 'medium',\n detail: `LLM output tokens shrank ${first}→${last} over ${outputTokenTrajectory.length} calls — less planning/reasoning per step as context grows.`,\n evidence: { first, last, calls: outputTokenTrajectory.length },\n })\n }\n }\n\n if (totalToolCalls >= MIN_TOOL_CALLS && distinctTools === 1) {\n const only = Object.keys(toolHistogram)[0]!\n signals.push({\n code: 'single-tool-dependency',\n severity: 'medium',\n detail: `All ${totalToolCalls} tool calls are \\`${only}\\` — no tool diversity and no fallback path.`,\n evidence: { tool: only, calls: totalToolCalls, distinct_tools: 1 },\n })\n }\n\n if (totalToolCalls >= MIN_TOOL_CALLS && !hasSelfVerification) {\n signals.push({\n code: 'no-self-verification',\n severity: 'medium',\n detail: `${totalToolCalls} tool calls and none verify/inspect/check state — the agent never validates its own actions.`,\n evidence: { tool_calls: totalToolCalls, verification_calls: 0 },\n })\n }\n\n return {\n llmCallCount: inputTokenTrajectory.length,\n inputTokenTrajectory,\n outputTokenTrajectory,\n toolHistogram,\n totalToolCalls,\n distinctTools,\n toolDiversityRatio,\n hasSelfVerification,\n signals,\n }\n}\n","/**\n * `behavioralAnalyst` — a DETERMINISTIC analyst (cost.kind = 'deterministic',\n * never calls the LLM). It produces the efficiency/behavioral findings a\n * tolerant agentic analyzer (HALO) re-derives per run inside the model —\n * context bloat, output decay, tool monoculture, missing self-verification —\n * directly from arithmetic over spans (`computeTraceMetrics`).\n *\n * Why it matters: these findings are model-agnostic BY CONSTRUCTION (no model\n * in the loop), so they cannot return 0 on a weak model the way the Ax-RLM\n * does — and they are strictly more reliable than HALO, which spends tokens\n * re-deriving the same numbers and can hallucinate the trend. The agentic\n * RLM kinds remain for SEMANTIC findings that genuinely need a model; this\n * analyst owns the behavioral class.\n */\n\nimport {\n type BehavioralMetrics,\n computeTraceMetrics,\n type SuboptimalCode,\n} from '../trace-analyst/behavioral-metrics'\nimport type { TraceAnalysisStore } from '../trace-analyst/store'\nimport type { TraceAnalystSpan } from '../trace-analyst/types'\nimport { type Analyst, type AnalystFinding, makeFinding } from './types'\n\nconst RECOMMENDED_ACTION: Record<SuboptimalCode, string> = {\n 'monotonic-input-growth':\n 'Add a context-budget instruction: once prior context exceeds a threshold, summarize earlier steps into a short status line instead of re-sending full history.',\n 'output-length-decay':\n 'Require a minimum planning/reasoning budget per step so late steps do not degrade into terse, error-prone commands.',\n 'single-tool-dependency':\n 'Direct the agent to use the full toolset (verify / inspect / alternate actions), not a single execute call, and to plan a fallback when a call returns an unexpected result.',\n 'no-self-verification':\n 'After every state-mutating action, verify the result (eval / inspect / assert) before proceeding.',\n}\n\nconst ANALYST_ID = 'efficiency-behavioral'\n\n/**\n * Map computed signals → structured AnalystFindings. Pure: no LLM, no clock\n * dependence beyond `produced_at` (overridable for deterministic tests).\n */\nexport function deriveEfficiencyFindings(\n metrics: BehavioralMetrics,\n opts: { analystId?: string; producedAt?: string } = {},\n): AnalystFinding[] {\n const analystId = opts.analystId ?? ANALYST_ID\n return metrics.signals.map((sig) =>\n makeFinding({\n analyst_id: analystId,\n area: 'efficiency',\n subject: sig.code, // kebab — passes the cluster grammar; stable key for diffFindings\n claim: sig.detail,\n severity: sig.severity,\n // Deterministic arithmetic over spans, not a model judgment → certain.\n confidence: 1,\n evidence_refs: [\n {\n kind: 'metric',\n uri: `metric://efficiency/${sig.code}`,\n excerpt: JSON.stringify(sig.evidence),\n },\n ],\n recommended_action: RECOMMENDED_ACTION[sig.code],\n metadata: { deterministic: true, evidence: sig.evidence },\n ...(opts.producedAt ? { produced_at: opts.producedAt } : {}),\n }),\n )\n}\n\n/** The deterministic behavioral/efficiency analyst (no LLM, any-model). */\nexport function behavioralAnalyst(): Analyst<TraceAnalysisStore> {\n return {\n id: ANALYST_ID,\n description:\n 'Deterministic behavioral/efficiency findings over OTLP spans — token-growth, output-decay, tool-monoculture, missing self-verification. Zero LLM; model-agnostic by construction.',\n inputKind: 'trace-store',\n cost: { kind: 'deterministic' },\n version: '1.0.0',\n async analyze(store) {\n const overview = await store.getOverview()\n const spans: TraceAnalystSpan[] = []\n for (const traceId of overview.sample_trace_ids) {\n const viewed = await store.viewTrace({ trace_id: traceId })\n if (viewed.spans) spans.push(...viewed.spans)\n }\n return deriveEfficiencyFindings(computeTraceMetrics(spans))\n },\n }\n}\n","/**\n * `buildDefaultAnalystRegistry` — the canonical analyst suite, so consumers\n * stop hand-wiring `new AnalystRegistry()` + per-kind `createTraceAnalystKind`.\n *\n * The deterministic `behavioralAnalyst` is ALWAYS registered (it needs no\n * model and is model-agnostic by construction). The agentic RLM kinds are\n * registered only when an `ai` service is supplied — so a caller with no LLM\n * still gets the full behavioral/efficiency diagnosis, and the substrate's\n * \"any model (including no model)\" guarantee holds at the suite level.\n */\n\nimport type { AxAIService } from '@ax-llm/ax'\nimport { behavioralAnalyst } from './behavioral-analyst'\nimport { createTraceAnalystKind, type TraceAnalystKindSpec } from './kind-factory'\nimport { DEFAULT_TRACE_ANALYST_KINDS } from './kinds'\nimport { AnalystRegistry, type AnalystRegistryOptions } from './registry'\n\nexport interface DefaultAnalystRegistryOptions {\n /** Ax service for the agentic RLM kinds. Omit → only the deterministic analyst. */\n ai?: AxAIService\n /** Model for the agentic kinds (falls back to the ai service default). */\n model?: string\n /** Which agentic kinds to register when `ai` is present. Default = the shipped suite. */\n kinds?: readonly TraceAnalystKindSpec[]\n /** Set false to omit the deterministic behavioral analyst (default: include). */\n includeBehavioral?: boolean\n /** Forwarded to the AnalystRegistry constructor (signal, tags, priorFindings). */\n registry?: AnalystRegistryOptions\n}\n\nexport function buildDefaultAnalystRegistry(\n opts: DefaultAnalystRegistryOptions = {},\n): AnalystRegistry {\n const registry = new AnalystRegistry(opts.registry)\n if (opts.includeBehavioral !== false) {\n registry.register(behavioralAnalyst())\n }\n if (opts.ai) {\n const kinds = opts.kinds ?? DEFAULT_TRACE_ANALYST_KINDS\n for (const spec of kinds) {\n registry.register(createTraceAnalystKind(spec, { ai: opts.ai, model: opts.model }))\n }\n }\n return registry\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiDA,IAAM,sBAAsB;AAE5B,IAAM,iBAAiB;AAEvB,IAAM,YAAY;AAElB,SAAS,IAAI,GAA2B;AACtC,SAAO,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,IAAI,IAAI;AAC3D;AACA,SAAS,QAAQ,OAAgC,MAAwC;AACvF,aAAW,OAAO,MAAM;AACtB,UAAM,QAAQ,IAAI,MAAM,GAAG,CAAC;AAC5B,QAAI,UAAU,KAAM,QAAO;AAAA,EAC7B;AACA,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AAa,EAAE,aAAa,KAAK,WAAW,IAAI,CAAC;AAAA,IAC5D,CAAC;AAAA,EACH;AACF;AAGO,SAAS,oBAAiD;AAC/D,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,aACE;AAAA,IACF,WAAW;AAAA,IACX,MAAM,EAAE,MAAM,gBAAgB;AAAA,IAC9B,SAAS;AAAA,IACT,MAAM,QAAQ,OAAO;AACnB,YAAM,WAAW,MAAM,MAAM,YAAY;AACzC,YAAM,QAA4B,CAAC;AACnC,iBAAW,WAAW,SAAS,kBAAkB;AAC/C,cAAM,SAAS,MAAM,MAAM,UAAU,EAAE,UAAU,QAAQ,CAAC;AAC1D,YAAI,OAAO,MAAO,OAAM,KAAK,GAAG,OAAO,KAAK;AAAA,MAC9C;AACA,aAAO,yBAAyB,oBAAoB,KAAK,CAAC;AAAA,IAC5D;AAAA,EACF;AACF;;;AC1DO,SAAS,4BACd,OAAsC,CAAC,GACtB;AACjB,QAAM,WAAW,IAAI,gBAAgB,KAAK,QAAQ;AAClD,MAAI,KAAK,sBAAsB,OAAO;AACpC,aAAS,SAAS,kBAAkB,CAAC;AAAA,EACvC;AACA,MAAI,KAAK,IAAI;AACX,UAAM,QAAQ,KAAK,SAAS;AAC5B,eAAW,QAAQ,OAAO;AACxB,eAAS,SAAS,uBAAuB,MAAM,EAAE,IAAI,KAAK,IAAI,OAAO,KAAK,MAAM,CAAC,CAAC;AAAA,IACpF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -112,6 +112,21 @@ function usesMaxCompletionTokens(model) {
112
112
  async function sleep(ms) {
113
113
  return new Promise((resolve) => setTimeout(resolve, ms));
114
114
  }
115
+ function linkSignals(timeoutController, caller) {
116
+ if (!caller) return timeoutController.signal;
117
+ if (typeof AbortSignal.any === "function") {
118
+ return AbortSignal.any([timeoutController.signal, caller]);
119
+ }
120
+ if (caller.aborted) {
121
+ timeoutController.abort();
122
+ } else {
123
+ caller.addEventListener("abort", () => timeoutController.abort(), { once: true });
124
+ }
125
+ return timeoutController.signal;
126
+ }
127
+ function deadlineExceeded(start, deadlineMs) {
128
+ return deadlineMs != null && Date.now() - start >= deadlineMs;
129
+ }
115
130
  function stripFencedJson(raw) {
116
131
  const trimmed = raw.trim();
117
132
  const m = trimmed.match(/^```(?:json)?\s*\n?([\s\S]*?)\n?```\s*$/);
@@ -179,9 +194,19 @@ async function callLlm(req, opts = {}) {
179
194
  const sink = opts.rawSink;
180
195
  const redactor = opts.redactor ?? defaultProviderRedactor;
181
196
  const traceContext = opts.traceContext;
197
+ const callerSignal = opts.signal;
198
+ const deadlineMs = opts.deadlineMs;
199
+ const deadlineStart = Date.now();
182
200
  let lastErr;
183
201
  for (let attempt = 0; attempt < maxRetries; attempt++) {
202
+ if (callerSignal?.aborted) {
203
+ throw new DOMException("callLlm aborted by caller signal", "AbortError");
204
+ }
205
+ if (attempt > 0 && deadlineExceeded(deadlineStart, deadlineMs)) {
206
+ throw lastErr instanceof Error ? lastErr : new Error(String(lastErr));
207
+ }
184
208
  const controller = new AbortController();
209
+ const attemptSignal = linkSignals(controller, callerSignal);
185
210
  const timeoutHandle = setTimeout(() => controller.abort(), timeoutMs);
186
211
  const started = Date.now();
187
212
  const requestBody = buildBody(req, false);
@@ -208,7 +233,7 @@ async function callLlm(req, opts = {}) {
208
233
  method: "POST",
209
234
  headers,
210
235
  body: JSON.stringify(requestBody),
211
- signal: controller.signal
236
+ signal: attemptSignal
212
237
  });
213
238
  clearTimeout(timeoutHandle);
214
239
  const responseHeaders = sink ? headersToObject(res.headers) : void 0;
@@ -241,7 +266,7 @@ async function callLlm(req, opts = {}) {
241
266
  body,
242
267
  req.model
243
268
  );
244
- if (RETRYABLE_STATUS.has(res.status) && attempt < maxRetries - 1) {
269
+ if (RETRYABLE_STATUS.has(res.status) && attempt < maxRetries - 1 && !deadlineExceeded(deadlineStart, deadlineMs)) {
245
270
  lastErr = err;
246
271
  const retryAfter = parseRetryAfter(res.headers);
247
272
  await sleep(retryAfter ?? backoffMs(attempt));
@@ -299,8 +324,11 @@ async function callLlm(req, opts = {}) {
299
324
  const choice = json.choices?.[0];
300
325
  const usageRaw = json.usage ?? {};
301
326
  const costFromProxy = json._response_cost ?? json.cost_usd;
327
+ const content = choice?.message?.content ?? "";
302
328
  return {
303
- content: choice?.message?.content ?? "",
329
+ content,
330
+ finishReason: choice?.finish_reason ?? null,
331
+ contentEmpty: content.trim().length === 0,
304
332
  usage: {
305
333
  promptTokens: Number(usageRaw.prompt_tokens ?? 0),
306
334
  completionTokens: Number(usageRaw.completion_tokens ?? 0),
@@ -317,6 +345,26 @@ async function callLlm(req, opts = {}) {
317
345
  } catch (err) {
318
346
  clearTimeout(timeoutHandle);
319
347
  lastErr = err;
348
+ if (callerSignal?.aborted) {
349
+ if (sink && !attemptErrorRecorded) {
350
+ await recordRaw(sink, redactor, {
351
+ eventId: cryptoEventId(),
352
+ runId: traceContext?.runId,
353
+ spanId: traceContext?.spanId,
354
+ provider,
355
+ model: req.model,
356
+ endpoint,
357
+ baseUrl,
358
+ attemptIndex: attempt,
359
+ direction: "error",
360
+ timestamp: Date.now(),
361
+ durationMs: Date.now() - started,
362
+ errorMessage: err instanceof Error ? err.message : String(err),
363
+ redactedFields: []
364
+ });
365
+ }
366
+ throw err;
367
+ }
320
368
  if (sink && !attemptErrorRecorded) {
321
369
  await recordRaw(sink, redactor, {
322
370
  eventId: cryptoEventId(),
@@ -334,7 +382,7 @@ async function callLlm(req, opts = {}) {
334
382
  redactedFields: []
335
383
  });
336
384
  }
337
- if (attempt < maxRetries - 1 && isTransientLlmError(err)) {
385
+ if (attempt < maxRetries - 1 && isTransientLlmError(err) && !deadlineExceeded(deadlineStart, deadlineMs)) {
338
386
  await sleep(backoffMs(attempt));
339
387
  continue;
340
388
  }
@@ -494,4 +542,4 @@ export {
494
542
  probeLlm,
495
543
  LlmClient
496
544
  };
497
- //# sourceMappingURL=chunk-CVVHBFGN.js.map
545
+ //# sourceMappingURL=chunk-CWNP4DV4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/llm-client.ts"],"sourcesContent":["/**\n * LLM client with graceful degrade.\n *\n * OpenAI-compatible `/v1/chat/completions` client with:\n * - Exponential-backoff retry on 429 + 5xx gateway errors (502/503/504).\n * - Retry on transient network errors (fetch failed, AbortError, ECONNRESET).\n * - Graceful json_schema → json_object degrade on 400 with schema-reject body.\n * - Fenced-JSON stripping (```json ... ```) for models that wrap structured output.\n * - Configurable base URL + api key / bearer, works with LiteLLM proxies, OpenAI\n * directly, cli-bridge subscriptions, and any router that speaks the spec.\n *\n * Usage:\n * const { value, result } = await callLlmJson<MyType>(\n * { model: 'gpt-4o', messages: [...], jsonSchema: { name: 'x', schema: {...} } },\n * { baseUrl: 'https://router.tangle.tools/v1', apiKey: process.env.KEY },\n * )\n *\n * This is THE llm-calling seam for agent-eval primitives that need structured\n * output (semantic concept judge, reviewer directives, critic scores). Primitives\n * that need free-form text use `callLlm` and parse output themselves.\n */\n\nimport { AgentEvalError, CaptureIntegrityError } from './errors'\nimport {\n defaultProviderRedactor,\n type ProviderRedactor,\n providerFromBaseUrl,\n type RawProviderEvent,\n type RawProviderSink,\n} from './trace/raw-provider-sink'\n\n// ─── Types ──────────────────────────────────────────────────────────────\n\nexport interface LlmMessage {\n role: 'system' | 'user' | 'assistant'\n /**\n * Either a plain text content string OR a multimodal content array\n * (text + image_url parts) for vision-capable models.\n */\n content:\n | string\n | Array<\n | { type: 'text'; text: string }\n | { type: 'image_url'; image_url: { url: string; detail?: 'auto' | 'low' | 'high' } }\n >\n}\n\nexport interface LlmCallRequest {\n model: string\n messages: LlmMessage[]\n /** Optional JSON-mode response format (response_format: json_object). */\n jsonMode?: boolean\n /** Optional structured output via JSON Schema. Falls back to json_object on 400. */\n jsonSchema?: { name: string; schema: Record<string, unknown> }\n temperature?: number\n maxTokens?: number\n /** Per-call timeout, default 300s. */\n timeoutMs?: number\n}\n\nexport interface LlmUsage {\n promptTokens: number\n completionTokens: number\n totalTokens: number\n /** Proxies populate this when prompt caching is on. */\n cachedPromptTokens?: number\n}\n\nexport interface LlmCallResult {\n /** The text content of the first choice. Empty string if none. */\n content: string\n usage: LlmUsage\n /**\n * Cost in USD. Pulled from proxy's `_response_cost` field when present;\n * `null` when neither the proxy nor the caller can derive it.\n */\n costUsd: number | null\n /** Model name actually used (echoed from response). */\n model: string\n /** Wall-clock duration of the HTTP call (last attempt, if retried). */\n durationMs: number\n /**\n * `finish_reason` echoed from the first choice (`stop`, `length`,\n * `content_filter`, `tool_calls`, ...). `null` when the provider omits it.\n * Exposed so a free-form `callLlm` caller CAN detect a truncated answer\n * (`length`) instead of treating a cut-off completion as complete. Note:\n * `callLlm` does not itself reject on it — acting on this signal is the\n * caller's responsibility (in-repo free-form drivers do not yet enforce it).\n */\n finishReason?: string | null\n /**\n * True when `content.trim()` is empty. An empty completion is a silent zero\n * for free-form `callLlm` callers; this flag is the signal a caller can\n * inspect to fail loud rather than proceed on an empty string. `callLlm`\n * surfaces it but does not throw on it.\n */\n contentEmpty?: boolean\n /** Raw response body. */\n raw: Record<string, unknown>\n}\n\nexport class LlmCallError extends AgentEvalError {\n constructor(\n message: string,\n public readonly status: number,\n public readonly body: string,\n public readonly model: string,\n ) {\n super('judge', message)\n }\n}\n\nexport interface LlmClientOptions {\n /** Base URL (without trailing slash). Must end at the `/v1` prefix. */\n baseUrl?: string\n /** Bearer token — either `apiKey` or `bearer` populates `Authorization: Bearer ...`. */\n apiKey?: string\n bearer?: string\n /** Override for the `Authorization` header (e.g. `X-Auth: ...`). Takes precedence over apiKey/bearer. */\n authHeader?: { name: string; value: string }\n /** Default timeout in ms. Per-call can override. */\n defaultTimeoutMs?: number\n /**\n * Caller-supplied abort signal — e.g. a campaign-wide cancel. Linked to\n * each attempt's per-attempt timeout controller, so aborting it cancels\n * the in-flight fetch. A caller abort is FATAL: it is not retried even\n * though an AbortError otherwise matches the transient patterns.\n */\n signal?: AbortSignal\n /**\n * Cross-attempt wall-clock budget in ms, measured from the first attempt.\n * Before launching each attempt the loop checks the remaining budget and\n * stops retrying once it is exhausted, rather than waiting the full\n * per-attempt timeout on every retry. Bounds total time independent of\n * `maxRetries` × `timeoutMs`.\n */\n deadlineMs?: number\n /** Max retry attempts on retriable errors. Default 3 (1 initial + 2 retries). */\n maxRetries?: number\n /** Fetch implementation — defaults to global `fetch`. Override for custom transport (e.g. tests). */\n fetch?: typeof fetch\n /**\n * Optional raw HTTP capture sink. When provided, every request, response,\n * and error (across all retry attempts) is recorded to the sink, with auth\n * headers and credential-shaped body fields redacted by default. This is\n * the layer-1 forensics primitive: structured `LlmSpan`s record intent,\n * raw events record what actually crossed the wire.\n */\n rawSink?: RawProviderSink\n /**\n * Logical provider id attached to raw events. When omitted, derived from\n * `baseUrl` via `providerFromBaseUrl`.\n */\n provider?: string\n /** Trace context attached to raw events; populated by emitter-aware callers. */\n traceContext?: { runId?: string; spanId?: string }\n /** Override the redaction strategy for this call. Defaults to `defaultProviderRedactor`. */\n redactor?: ProviderRedactor\n}\n\n// ─── Internals ──────────────────────────────────────────────────────────\n\nconst DEFAULT_BASE_URL = 'https://router.tangle.tools/v1'\n// Flagship / reasoning models routinely take several minutes on large prompts (a\n// reflection over many failures, a long tool transcript). A tight cap aborts a\n// legitimately-slow but healthy call — and because every retry attempt re-uses\n// the same window, such a model aborts on ALL attempts and the loop throws. The\n// default is generous enough to let those complete, bounded enough that a truly\n// hung call still fails over after retries, and tunable per deployment via\n// TANGLE_LLM_TIMEOUT_MS. Per-call `req.timeoutMs` / `opts.defaultTimeoutMs`\n// still win for callers that know their model's latency.\nconst DEFAULT_TIMEOUT_MS = Number(process.env.TANGLE_LLM_TIMEOUT_MS) || 300_000\nconst DEFAULT_MAX_RETRIES = Number(process.env.TANGLE_LLM_MAX_RETRIES) || 3\n\nconst RETRYABLE_STATUS = new Set([429, 502, 503, 504])\n\n/**\n * Transient transport/network error signatures, matched against an error's\n * name, message, and `code`. Covers fetch/undici network failures, aborts\n * and timeouts, and — critically — HTTP/2 transport faults a keep-alive\n * connection raises mid-response: `terminated`, `NGHTTP2_INTERNAL_ERROR`,\n * `UND_ERR_*`, `other side closed`. Those last ones carry no clean HTTP\n * status; unrecognised, they escape the retry loop and surface as an\n * uncaught rejection.\n */\nconst TRANSIENT_ERROR_PATTERNS: readonly RegExp[] = [\n /AbortError/i,\n /TimeoutError/i,\n /this operation was aborted/i,\n /fetch failed/i,\n /ECONNRESET/i,\n /ETIMEDOUT/i,\n /EAI_AGAIN/i,\n /socket hang up/i,\n /stream.*ended.*unexpectedly/i,\n /terminated/i,\n /other side closed/i,\n /NGHTTP2/i,\n /UND_ERR/i,\n]\n\n/**\n * True when an error is a transient transport/network fault worth retrying,\n * as opposed to a deterministic failure (4xx schema reject, JSON parse) that\n * a retry cannot fix. Inspects `LlmCallError.status`, then the error's\n * name/message/code, then recurses into `error.cause` — undici nests the\n * real socket fault one or more levels under `.cause`.\n *\n * This is THE retry classifier for the package: `callLlm` and\n * `withJudgeRetry` both route through it, so a connection-class error is\n * treated identically whether it surfaces in the HTTP client or a\n * TCloud-backed judge.\n */\nexport function isTransientLlmError(err: unknown): boolean {\n return classifyTransient(err, 0)\n}\n\nfunction classifyTransient(err: unknown, depth: number): boolean {\n if (err instanceof LlmCallError) return RETRYABLE_STATUS.has(err.status)\n if (!(err instanceof Error)) return false\n // Foreign errors (e.g. a TCloud judge SDK error) can carry a numeric HTTP\n // status without being an LlmCallError — a retryable status is decisive.\n const status = (err as { status?: unknown }).status\n if (typeof status === 'number' && RETRYABLE_STATUS.has(status)) return true\n const code = (err as { code?: unknown }).code\n const haystack = `${err.name}\\n${err.message}\\n${typeof code === 'string' ? code : ''}`\n if (TRANSIENT_ERROR_PATTERNS.some((p) => p.test(haystack))) return true\n const cause = (err as { cause?: unknown }).cause\n if (depth < 4 && cause instanceof Error && cause !== err) {\n return classifyTransient(cause, depth + 1)\n }\n return false\n}\n\nfunction parseRetryAfter(headers: Headers): number | null {\n const h = headers.get('retry-after')\n if (!h) return null\n const asNumber = Number(h)\n if (Number.isFinite(asNumber) && asNumber > 0) return asNumber * 1000\n const asDate = Date.parse(h)\n if (Number.isFinite(asDate)) return Math.max(0, asDate - Date.now())\n return null\n}\n\n/** Exponential backoff: 500ms, 1s, 2s, 4s, ... capped at 16s. Attempt is 0-indexed. */\nexport function backoffMs(attempt: number): number {\n return Math.min(500 * 2 ** attempt, 16_000)\n}\n\nfunction buildHeaders(opts: LlmClientOptions): Record<string, string> {\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n }\n if (opts.authHeader) {\n headers[opts.authHeader.name] = opts.authHeader.value\n } else if (opts.bearer || opts.apiKey) {\n headers.Authorization = `Bearer ${opts.bearer ?? opts.apiKey}`\n }\n return headers\n}\n\nfunction isSchemaRejection(status: number, body: string): boolean {\n if (status !== 400) return false\n const lower = body.toLowerCase()\n return (\n lower.includes('response_format') ||\n lower.includes('json_schema') ||\n lower.includes('is unavailable') ||\n lower.includes('not supported')\n )\n}\n\nfunction buildBody(req: LlmCallRequest, forceJsonObject: boolean): Record<string, unknown> {\n const body: Record<string, unknown> = {\n model: req.model,\n messages: req.messages,\n temperature: req.temperature ?? 0,\n }\n if (req.maxTokens != null) {\n if (usesMaxCompletionTokens(req.model)) body.max_completion_tokens = req.maxTokens\n else body.max_tokens = req.maxTokens\n }\n\n if (req.jsonSchema && !forceJsonObject) {\n body.response_format = {\n type: 'json_schema',\n json_schema: { name: req.jsonSchema.name, schema: req.jsonSchema.schema, strict: true },\n }\n } else if (req.jsonMode || req.jsonSchema) {\n body.response_format = { type: 'json_object' }\n }\n\n return body\n}\n\nfunction usesMaxCompletionTokens(model: string): boolean {\n return /^gpt-5(?:[.-]|$)/i.test(model)\n}\n\nasync function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\n/**\n * Combine the per-attempt timeout signal with an optional caller signal into\n * one signal the fetch listens on. Prefers the native `AbortSignal.any`; falls\n * back to manual wiring on runtimes that predate it. The caller signal is also\n * propagated to the timeout controller so aborting it cancels the in-flight\n * fetch immediately.\n */\nfunction linkSignals(timeoutController: AbortController, caller?: AbortSignal): AbortSignal {\n if (!caller) return timeoutController.signal\n if (typeof (AbortSignal as { any?: unknown }).any === 'function') {\n return AbortSignal.any([timeoutController.signal, caller])\n }\n if (caller.aborted) {\n timeoutController.abort()\n } else {\n caller.addEventListener('abort', () => timeoutController.abort(), { once: true })\n }\n return timeoutController.signal\n}\n\n/** True once the cross-attempt wall-clock budget (if any) is exhausted. */\nfunction deadlineExceeded(start: number, deadlineMs: number | undefined): boolean {\n return deadlineMs != null && Date.now() - start >= deadlineMs\n}\n\n// ─── Public API ─────────────────────────────────────────────────────────\n\n/**\n * Strip a ```json / ``` code fence if the model emitted one.\n * Idempotent for naked JSON. Some models (claude-code via router, certain\n * deepseek models) wrap output even under json_object.\n */\nexport function stripFencedJson(raw: string): string {\n const trimmed = raw.trim()\n const m = trimmed.match(/^```(?:json)?\\s*\\n?([\\s\\S]*?)\\n?```\\s*$/)\n return m ? m[1]!.trim() : trimmed\n}\n\nexport function extractJsonPayload(raw: string): string {\n const stripped = stripFencedJson(raw)\n try {\n JSON.parse(stripped)\n return stripped\n } catch {\n // Continue with balanced extraction below.\n }\n\n const starts = [...stripped.matchAll(/[[{]/g)]\n .map((match) => match.index)\n .filter((index) => index != null)\n for (const start of starts) {\n const candidate = extractBalancedJson(stripped, start)\n if (!candidate) continue\n try {\n JSON.parse(candidate)\n return candidate\n } catch {\n // Keep scanning; earlier braces may belong to prose.\n }\n }\n\n return stripped\n}\n\nfunction extractBalancedJson(input: string, start: number): string | null {\n const opener = input[start]\n const closer = opener === '{' ? '}' : opener === '[' ? ']' : null\n if (!closer) return null\n\n const stack: string[] = [closer]\n let isInString = false\n let isEscaped = false\n\n for (let i = start + 1; i < input.length; i++) {\n const char = input[i]!\n if (isEscaped) {\n isEscaped = false\n continue\n }\n if (char === '\\\\') {\n isEscaped = isInString\n continue\n }\n if (char === '\"') {\n isInString = !isInString\n continue\n }\n if (isInString) continue\n\n if (char === '{') stack.push('}')\n else if (char === '[') stack.push(']')\n else if (char === stack[stack.length - 1]) {\n stack.pop()\n if (stack.length === 0) return input.slice(start, i + 1)\n }\n }\n\n return null\n}\n\n/**\n * Low-level call. Returns raw content + usage + cost. Retries on transient\n * failures; does NOT degrade schema here — callers that want graceful\n * degrade use `callLlmJson`.\n */\nexport async function callLlm(\n req: LlmCallRequest,\n opts: LlmClientOptions = {},\n): Promise<LlmCallResult> {\n const baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, '')\n const url = `${baseUrl}/chat/completions`\n const endpoint = '/chat/completions'\n const timeoutMs = req.timeoutMs ?? opts.defaultTimeoutMs ?? DEFAULT_TIMEOUT_MS\n const maxRetries = opts.maxRetries ?? DEFAULT_MAX_RETRIES\n const fetchFn = opts.fetch ?? globalThis.fetch\n const headers = buildHeaders(opts)\n const provider = opts.provider ?? providerFromBaseUrl(baseUrl)\n const sink = opts.rawSink\n const redactor = opts.redactor ?? defaultProviderRedactor\n const traceContext = opts.traceContext\n const callerSignal = opts.signal\n const deadlineMs = opts.deadlineMs\n const deadlineStart = Date.now()\n\n let lastErr: unknown\n for (let attempt = 0; attempt < maxRetries; attempt++) {\n // A caller cancel is fatal — never retried. Checking before each attempt\n // means an already-aborted signal short-circuits without firing fetch.\n if (callerSignal?.aborted) {\n throw new DOMException('callLlm aborted by caller signal', 'AbortError')\n }\n // Stop retrying once the cross-attempt budget is spent rather than burning\n // a full per-attempt timeout on each remaining retry.\n if (attempt > 0 && deadlineExceeded(deadlineStart, deadlineMs)) {\n throw lastErr instanceof Error ? lastErr : new Error(String(lastErr))\n }\n const controller = new AbortController()\n const attemptSignal = linkSignals(controller, callerSignal)\n const timeoutHandle = setTimeout(() => controller.abort(), timeoutMs)\n const started = Date.now()\n const requestBody = buildBody(req, false)\n let attemptErrorRecorded = false\n if (sink) {\n await recordRaw(sink, redactor, {\n eventId: cryptoEventId(),\n runId: traceContext?.runId,\n spanId: traceContext?.spanId,\n provider,\n model: req.model,\n endpoint,\n baseUrl,\n attemptIndex: attempt,\n direction: 'request',\n timestamp: started,\n requestHeaders: headers,\n requestBody,\n redactedFields: [],\n })\n }\n\n try {\n const res = await fetchFn(url, {\n method: 'POST',\n headers,\n body: JSON.stringify(requestBody),\n signal: attemptSignal,\n })\n clearTimeout(timeoutHandle)\n const responseHeaders = sink ? headersToObject(res.headers) : undefined\n\n if (!res.ok) {\n const body = await res.text()\n if (sink) {\n await recordRaw(sink, redactor, {\n eventId: cryptoEventId(),\n runId: traceContext?.runId,\n spanId: traceContext?.spanId,\n provider,\n model: req.model,\n endpoint,\n baseUrl,\n attemptIndex: attempt,\n direction: 'error',\n timestamp: Date.now(),\n durationMs: Date.now() - started,\n statusCode: res.status,\n responseHeaders,\n responseBody: body,\n errorMessage: `HTTP ${res.status}`,\n redactedFields: [],\n })\n attemptErrorRecorded = true\n }\n const err = new LlmCallError(\n `LLM call ${res.status}: ${body.slice(0, 300)}`,\n res.status,\n body,\n req.model,\n )\n if (\n RETRYABLE_STATUS.has(res.status) &&\n attempt < maxRetries - 1 &&\n !deadlineExceeded(deadlineStart, deadlineMs)\n ) {\n lastErr = err\n const retryAfter = parseRetryAfter(res.headers)\n await sleep(retryAfter ?? backoffMs(attempt))\n continue\n }\n throw err\n }\n\n const text = await res.text()\n let json: Record<string, unknown>\n try {\n json = JSON.parse(text) as Record<string, unknown>\n } catch (parseErr) {\n if (sink) {\n await recordRaw(sink, redactor, {\n eventId: cryptoEventId(),\n runId: traceContext?.runId,\n spanId: traceContext?.spanId,\n provider,\n model: req.model,\n endpoint,\n baseUrl,\n attemptIndex: attempt,\n direction: 'error',\n timestamp: Date.now(),\n durationMs: Date.now() - started,\n statusCode: res.status,\n responseHeaders,\n responseBody: text,\n errorMessage: `non-JSON response: ${parseErr instanceof Error ? parseErr.message : String(parseErr)}`,\n redactedFields: [],\n })\n attemptErrorRecorded = true\n }\n throw parseErr\n }\n if (sink) {\n await recordRaw(sink, redactor, {\n eventId: cryptoEventId(),\n runId: traceContext?.runId,\n spanId: traceContext?.spanId,\n provider,\n model: req.model,\n endpoint,\n baseUrl,\n attemptIndex: attempt,\n direction: 'response',\n timestamp: Date.now(),\n durationMs: Date.now() - started,\n statusCode: res.status,\n responseHeaders,\n responseBody: json,\n redactedFields: [],\n })\n }\n const choice = (\n json.choices as\n | Array<{ message?: { content?: string }; finish_reason?: string | null }>\n | undefined\n )?.[0]\n const usageRaw = (json.usage as Record<string, unknown> | undefined) ?? {}\n const costFromProxy = (json._response_cost ?? json.cost_usd) as number | undefined\n const content = choice?.message?.content ?? ''\n\n return {\n content,\n finishReason: choice?.finish_reason ?? null,\n contentEmpty: content.trim().length === 0,\n usage: {\n promptTokens: Number(usageRaw.prompt_tokens ?? 0),\n completionTokens: Number(usageRaw.completion_tokens ?? 0),\n totalTokens: Number(usageRaw.total_tokens ?? 0),\n cachedPromptTokens:\n usageRaw.prompt_tokens_details && typeof usageRaw.prompt_tokens_details === 'object'\n ? Number(\n (usageRaw.prompt_tokens_details as Record<string, unknown>).cached_tokens ?? 0,\n )\n : undefined,\n },\n costUsd: typeof costFromProxy === 'number' ? costFromProxy : null,\n model: (json.model as string) ?? req.model,\n durationMs: Date.now() - started,\n raw: json,\n }\n } catch (err) {\n clearTimeout(timeoutHandle)\n lastErr = err\n // A caller cancel is fatal even though an AbortError matches the\n // transient patterns — a cancelled call must surface immediately, not\n // be retried against the same dead intent.\n if (callerSignal?.aborted) {\n if (sink && !attemptErrorRecorded) {\n await recordRaw(sink, redactor, {\n eventId: cryptoEventId(),\n runId: traceContext?.runId,\n spanId: traceContext?.spanId,\n provider,\n model: req.model,\n endpoint,\n baseUrl,\n attemptIndex: attempt,\n direction: 'error',\n timestamp: Date.now(),\n durationMs: Date.now() - started,\n errorMessage: err instanceof Error ? err.message : String(err),\n redactedFields: [],\n })\n }\n throw err\n }\n if (sink && !attemptErrorRecorded) {\n // Record only if neither the !res.ok branch nor the JSON.parse catch\n // already produced an error event for this attempt. Covers network\n // failures, timeouts, and aborts.\n await recordRaw(sink, redactor, {\n eventId: cryptoEventId(),\n runId: traceContext?.runId,\n spanId: traceContext?.spanId,\n provider,\n model: req.model,\n endpoint,\n baseUrl,\n attemptIndex: attempt,\n direction: 'error',\n timestamp: Date.now(),\n durationMs: Date.now() - started,\n errorMessage: err instanceof Error ? err.message : String(err),\n redactedFields: [],\n })\n }\n if (\n attempt < maxRetries - 1 &&\n isTransientLlmError(err) &&\n !deadlineExceeded(deadlineStart, deadlineMs)\n ) {\n await sleep(backoffMs(attempt))\n continue\n }\n throw err\n }\n }\n throw lastErr instanceof Error ? lastErr : new Error(String(lastErr))\n}\n\nasync function recordRaw(\n sink: RawProviderSink,\n redactor: ProviderRedactor,\n event: RawProviderEvent,\n): Promise<void> {\n // Errors from sinks must not crash the LLM call. Forensic capture is\n // best-effort; the structured trace is the system of record.\n try {\n await sink.record(redactor(event))\n } catch {\n // Intentionally swallowed.\n }\n}\n\nfunction headersToObject(h: Headers): Record<string, string> {\n const out: Record<string, string> = {}\n h.forEach((value, key) => {\n out[key] = value\n })\n return out\n}\n\nfunction cryptoEventId(): string {\n if (typeof globalThis.crypto?.randomUUID === 'function') return globalThis.crypto.randomUUID()\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`\n}\n\n/**\n * Structured-output call. Returns parsed JSON plus the raw result envelope.\n * Degrades `jsonSchema` → `jsonMode` on a 400 that names the schema param —\n * critical for deepseek-v3/v4, kimi-k2.6, and other models that don't accept\n * the `response_format.json_schema` shape but DO accept `json_object`.\n */\nexport async function callLlmJson<T = unknown>(\n req: LlmCallRequest,\n opts: LlmClientOptions = {},\n): Promise<{ value: T; result: LlmCallResult }> {\n try {\n const result = await callLlm({ ...req, jsonMode: req.jsonMode ?? !req.jsonSchema }, opts)\n const value = parseJsonSafely<T>(result.content, result.model)\n return { value, result }\n } catch (err) {\n if (err instanceof LlmCallError && isSchemaRejection(err.status, err.body) && req.jsonSchema) {\n // Degrade to json_object + retry.\n const degradedReq: LlmCallRequest = { ...req, jsonMode: true, jsonSchema: undefined }\n const result = await callLlm(degradedReq, opts)\n const value = parseJsonSafely<T>(result.content, result.model)\n return { value, result }\n }\n throw err\n }\n}\n\nfunction parseJsonSafely<T>(content: string, model: string): T {\n const stripped = extractJsonPayload(content)\n try {\n return JSON.parse(stripped) as T\n } catch (err) {\n throw new Error(\n `LLM returned non-JSON content (model=${model}): ${\n err instanceof Error ? err.message : String(err)\n }\\n--- raw content ---\\n${content.slice(0, 800)}`,\n )\n }\n}\n\n// ─── Route assertion ────────────────────────────────────────────────────\n\nexport type LlmRouteAssertionReason =\n | 'no_explicit_base_url'\n | 'base_url_blocked'\n | 'base_url_not_allowed'\n | 'no_auth'\n | 'wrong_provider'\n\nexport class LlmRouteAssertionError extends CaptureIntegrityError {\n constructor(\n message: string,\n public readonly reason: LlmRouteAssertionReason,\n public readonly baseUrl: string,\n ) {\n super(message)\n }\n}\n\nexport interface LlmRouteRequirements {\n /**\n * Throw if `opts.baseUrl` is undefined, i.e. the call would fall back to\n * `DEFAULT_BASE_URL`. Set this for evaluation runs where silently using\n * the public/free-tier router is a defect — the launch reviewer needs to\n * know exactly which provider answered.\n */\n requireExplicitBaseUrl?: boolean\n /**\n * Allowlist of acceptable base URLs. Strings match by prefix\n * (case-insensitive); RegExps test against the full base URL.\n */\n allowedBaseUrls?: Array<string | RegExp>\n /** Blocklist that takes precedence over `allowedBaseUrls`. */\n blockedBaseUrls?: Array<string | RegExp>\n /** Throw if no auth header / api key is configured. */\n requireAuth?: boolean\n /**\n * Logical provider id the configured `baseUrl` is expected to match (via\n * `providerFromBaseUrl`). Mainly useful when paired with `requireExplicitBaseUrl`.\n */\n expectedProvider?: string\n}\n\n/**\n * Fail-loud assertion that the configured LLM client points at the route\n * the caller intends. Designed for the matrix-runner preflight: invoke\n * once before any LLM call to catch misconfiguration before a sweep burns\n * dollars on the wrong provider.\n *\n * Throws `LlmRouteAssertionError`. Pure — no I/O — so it's safe to call\n * from constructors and CI gates.\n */\nexport function assertLlmRoute(opts: LlmClientOptions, req: LlmRouteRequirements = {}): void {\n const baseUrlExplicit = opts.baseUrl !== undefined\n const baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, '')\n\n if (req.requireExplicitBaseUrl && !baseUrlExplicit) {\n throw new LlmRouteAssertionError(\n `assertLlmRoute: requireExplicitBaseUrl set but opts.baseUrl is undefined; would fall back to ${DEFAULT_BASE_URL}.`,\n 'no_explicit_base_url',\n baseUrl,\n )\n }\n\n if (req.blockedBaseUrls?.some((p) => matchUrl(baseUrl, p))) {\n throw new LlmRouteAssertionError(\n `assertLlmRoute: baseUrl ${baseUrl} matches a blocked pattern.`,\n 'base_url_blocked',\n baseUrl,\n )\n }\n\n if (req.allowedBaseUrls && req.allowedBaseUrls.length > 0) {\n const ok = req.allowedBaseUrls.some((p) => matchUrl(baseUrl, p))\n if (!ok) {\n throw new LlmRouteAssertionError(\n `assertLlmRoute: baseUrl ${baseUrl} is not in the allowed list (${req.allowedBaseUrls.map(describePattern).join(', ')}).`,\n 'base_url_not_allowed',\n baseUrl,\n )\n }\n }\n\n if (req.requireAuth && !opts.apiKey && !opts.bearer && !opts.authHeader) {\n throw new LlmRouteAssertionError(\n `assertLlmRoute: requireAuth set but no apiKey, bearer, or authHeader was supplied.`,\n 'no_auth',\n baseUrl,\n )\n }\n\n if (req.expectedProvider) {\n const actual = opts.provider ?? providerFromBaseUrl(baseUrl)\n if (actual !== req.expectedProvider) {\n throw new LlmRouteAssertionError(\n `assertLlmRoute: expected provider ${req.expectedProvider} but baseUrl ${baseUrl} resolves to ${actual}.`,\n 'wrong_provider',\n baseUrl,\n )\n }\n }\n}\n\nfunction matchUrl(url: string, pattern: string | RegExp): boolean {\n if (pattern instanceof RegExp) return pattern.test(url)\n return url.toLowerCase().startsWith(pattern.toLowerCase())\n}\n\nfunction describePattern(p: string | RegExp): string {\n return p instanceof RegExp ? p.source : p\n}\n\n/**\n * Probe whether a model is reachable. Returns latency + null error on\n * success; `ok=false` + error message on any failure (HTTP, timeout,\n * network, parse). Designed for sweep preflights — fail loud at the\n * boundary before burning a 30-leaf run on a misconfigured router.\n *\n * Sends a tiny `ping` message with `maxTokens=64`. Reasoning models\n * (glm-5.1, deepseek-v4) can burn the entire budget on internal reasoning\n * for short prompts, so don't tighten this further. We don't validate\n * content; HTTP 200 means reachable.\n */\nexport async function probeLlm(\n model: string,\n opts: LlmClientOptions & { timeoutMs?: number } = {},\n): Promise<{ ok: boolean; latencyMs: number; error: string | null }> {\n const start = Date.now()\n try {\n await callLlm(\n {\n model,\n messages: [{ role: 'user', content: 'ping' }],\n maxTokens: 64,\n timeoutMs: opts.timeoutMs ?? 30_000,\n },\n opts,\n )\n return { ok: true, latencyMs: Date.now() - start, error: null }\n } catch (err) {\n return {\n ok: false,\n latencyMs: Date.now() - start,\n error: err instanceof Error ? err.message : String(err),\n }\n }\n}\n\n/**\n * Stateful client — construct once with defaults, call many times.\n * Thin wrapper around the free functions; exists for callers that want\n * to inject a single configured instance into multiple primitives.\n */\nexport class LlmClient {\n constructor(private readonly opts: LlmClientOptions = {}) {}\n\n call(req: LlmCallRequest, per?: LlmClientOptions): Promise<LlmCallResult> {\n return callLlm(req, { ...this.opts, ...per })\n }\n\n callJson<T = unknown>(\n req: LlmCallRequest,\n per?: LlmClientOptions,\n ): Promise<{ value: T; result: LlmCallResult }> {\n return callLlmJson<T>(req, { ...this.opts, ...per })\n }\n}\n"],"mappings":";;;;;;;;;;AAqGO,IAAM,eAAN,cAA2B,eAAe;AAAA,EAC/C,YACE,SACgB,QACA,MACA,OAChB;AACA,UAAM,SAAS,OAAO;AAJN;AACA;AACA;AAAA,EAGlB;AAAA,EALkB;AAAA,EACA;AAAA,EACA;AAIpB;AAoDA,IAAM,mBAAmB;AASzB,IAAM,qBAAqB,OAAO,QAAQ,IAAI,qBAAqB,KAAK;AACxE,IAAM,sBAAsB,OAAO,QAAQ,IAAI,sBAAsB,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gB,GAA4B;AACnD,SAAO,aAAa,SAAS,EAAE,SAAS;AAC1C;AAaA,eAAsB,SACpB,OACA,OAAkD,CAAC,GACgB;AACnE,QAAM,QAAQ,KAAK,IAAI;AACvB,MAAI;AACF,UAAM;AAAA,MACJ;AAAA,QACE;AAAA,QACA,UAAU,CAAC,EAAE,MAAM,QAAQ,SAAS,OAAO,CAAC;AAAA,QAC5C,WAAW;AAAA,QACX,WAAW,KAAK,aAAa;AAAA,MAC/B;AAAA,MACA;AAAA,IACF;AACA,WAAO,EAAE,IAAI,MAAM,WAAW,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK;AAAA,EAChE,SAAS,KAAK;AACZ,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,WAAW,KAAK,IAAI,IAAI;AAAA,MACxB,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,IACxD;AAAA,EACF;AACF;AAOO,IAAM,YAAN,MAAgB;AAAA,EACrB,YAA6B,OAAyB,CAAC,GAAG;AAA7B;AAAA,EAA8B;AAAA,EAA9B;AAAA,EAE7B,KAAK,KAAqB,KAAgD;AACxE,WAAO,QAAQ,KAAK,EAAE,GAAG,KAAK,MAAM,GAAG,IAAI,CAAC;AAAA,EAC9C;AAAA,EAEA,SACE,KACA,KAC8C;AAC9C,WAAO,YAAe,KAAK,EAAE,GAAG,KAAK,MAAM,GAAG,IAAI,CAAC;AAAA,EACrD;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  callLlmJson
3
- } from "./chunk-CVVHBFGN.js";
3
+ } from "./chunk-CWNP4DV4.js";
4
4
 
5
5
  // src/wire/schemas.ts
6
6
  import { extendZodWithOpenApi } from "@asteasolutions/zod-to-openapi";
@@ -1002,4 +1002,4 @@ export {
1002
1002
  startServer,
1003
1003
  startServerAsync
1004
1004
  };
1005
- //# sourceMappingURL=chunk-QS3RBQPI.js.map
1005
+ //# sourceMappingURL=chunk-D5KBVULY.js.map
@@ -0,0 +1,81 @@
1
+ // src/concurrency.ts
2
+ var Mutex = class {
3
+ locked = false;
4
+ waiters = [];
5
+ async acquire() {
6
+ if (!this.locked) {
7
+ this.locked = true;
8
+ return () => this.release();
9
+ }
10
+ return new Promise((resolve) => {
11
+ this.waiters.push(() => {
12
+ resolve(() => this.release());
13
+ });
14
+ });
15
+ }
16
+ release() {
17
+ const next = this.waiters.shift();
18
+ if (next) {
19
+ next();
20
+ } else {
21
+ this.locked = false;
22
+ }
23
+ }
24
+ async runExclusive(fn) {
25
+ const release = await this.acquire();
26
+ try {
27
+ return await fn();
28
+ } finally {
29
+ release();
30
+ }
31
+ }
32
+ /** True iff someone holds the lock right now. Diagnostics only. */
33
+ get isLocked() {
34
+ return this.locked;
35
+ }
36
+ /** Pending waiter count. Diagnostics only. */
37
+ get pending() {
38
+ return this.waiters.length;
39
+ }
40
+ };
41
+
42
+ // src/locked-jsonl-appender.ts
43
+ import { appendFileSync, existsSync, mkdirSync } from "fs";
44
+ import { dirname } from "path";
45
+ var mutexes = /* @__PURE__ */ new Map();
46
+ function getMutex(path) {
47
+ let m = mutexes.get(path);
48
+ if (!m) {
49
+ m = new Mutex();
50
+ mutexes.set(path, m);
51
+ }
52
+ return m;
53
+ }
54
+ var LockedJsonlAppender = class {
55
+ constructor(path) {
56
+ this.path = path;
57
+ this.mutex = getMutex(path);
58
+ if (!existsSync(dirname(path))) {
59
+ mkdirSync(dirname(path), { recursive: true });
60
+ }
61
+ }
62
+ path;
63
+ mutex;
64
+ async append(entry) {
65
+ const line = `${JSON.stringify(entry)}
66
+ `;
67
+ await this.mutex.runExclusive(() => {
68
+ appendFileSync(this.path, line);
69
+ });
70
+ }
71
+ };
72
+ function resetLockedAppendersForTesting() {
73
+ mutexes.clear();
74
+ }
75
+
76
+ export {
77
+ Mutex,
78
+ LockedJsonlAppender,
79
+ resetLockedAppendersForTesting
80
+ };
81
+ //# sourceMappingURL=chunk-DJWX3GVS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/concurrency.ts","../src/locked-jsonl-appender.ts"],"sourcesContent":["/**\n * concurrency — small primitives the evolution loop needs.\n *\n * `Mutex` is a zero-dep async lock with FIFO fairness. The evolution loop\n * uses it to serialise checkout/build/commit sequences inside a single\n * pool slot, and to gate concurrent JSONL writers (see\n * `lockedJsonlReferenceReplayStore`).\n *\n * Deliberately minimal — no priority queue, no timeouts. If you need\n * those, swap to `async-mutex` at the call site.\n */\n\nexport class Mutex {\n private locked = false\n private readonly waiters: Array<() => void> = []\n\n async acquire(): Promise<() => void> {\n if (!this.locked) {\n this.locked = true\n return () => this.release()\n }\n return new Promise<() => void>((resolve) => {\n this.waiters.push(() => {\n resolve(() => this.release())\n })\n })\n }\n\n private release(): void {\n const next = this.waiters.shift()\n if (next) {\n next()\n } else {\n this.locked = false\n }\n }\n\n async runExclusive<T>(fn: () => Promise<T> | T): Promise<T> {\n const release = await this.acquire()\n try {\n return await fn()\n } finally {\n release()\n }\n }\n\n /** True iff someone holds the lock right now. Diagnostics only. */\n get isLocked(): boolean {\n return this.locked\n }\n\n /** Pending waiter count. Diagnostics only. */\n get pending(): number {\n return this.waiters.length\n }\n}\n","/**\n * LockedJsonlAppender — mutex-serialized JSONL append helper for arbitrary\n * payloads. The reference-replay store does the same thing for typed\n * `ReferenceReplayRun` rows; this is the generic version used by\n * `MutationTelemetry`, `TrialTelemetry`, and any other consumer that wants\n * append-only durable telemetry without rolling its own lock.\n *\n * Locks are per absolute file path (process-local). Cross-process\n * concurrency is NOT addressed — that's an fcntl/flock problem.\n */\n\nimport { appendFileSync, existsSync, mkdirSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { Mutex } from './concurrency'\n\nconst mutexes = new Map<string, Mutex>()\n\nfunction getMutex(path: string): Mutex {\n let m = mutexes.get(path)\n if (!m) {\n m = new Mutex()\n mutexes.set(path, m)\n }\n return m\n}\n\nexport class LockedJsonlAppender {\n private readonly mutex: Mutex\n constructor(public readonly path: string) {\n this.mutex = getMutex(path)\n if (!existsSync(dirname(path))) {\n mkdirSync(dirname(path), { recursive: true })\n }\n }\n\n async append(entry: unknown): Promise<void> {\n const line = `${JSON.stringify(entry)}\\n`\n await this.mutex.runExclusive(() => {\n appendFileSync(this.path, line)\n })\n }\n}\n\n/** Reset all internal mutex state — tests only. */\nexport function resetLockedAppendersForTesting(): void {\n mutexes.clear()\n}\n"],"mappings":";AAYO,IAAM,QAAN,MAAY;AAAA,EACT,SAAS;AAAA,EACA,UAA6B,CAAC;AAAA,EAE/C,MAAM,UAA+B;AACnC,QAAI,CAAC,KAAK,QAAQ;AAChB,WAAK,SAAS;AACd,aAAO,MAAM,KAAK,QAAQ;AAAA,IAC5B;AACA,WAAO,IAAI,QAAoB,CAAC,YAAY;AAC1C,WAAK,QAAQ,KAAK,MAAM;AACtB,gBAAQ,MAAM,KAAK,QAAQ,CAAC;AAAA,MAC9B,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEQ,UAAgB;AACtB,UAAM,OAAO,KAAK,QAAQ,MAAM;AAChC,QAAI,MAAM;AACR,WAAK;AAAA,IACP,OAAO;AACL,WAAK,SAAS;AAAA,IAChB;AAAA,EACF;AAAA,EAEA,MAAM,aAAgB,IAAsC;AAC1D,UAAM,UAAU,MAAM,KAAK,QAAQ;AACnC,QAAI;AACF,aAAO,MAAM,GAAG;AAAA,IAClB,UAAE;AACA,cAAQ;AAAA,IACV;AAAA,EACF;AAAA;AAAA,EAGA,IAAI,WAAoB;AACtB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,UAAkB;AACpB,WAAO,KAAK,QAAQ;AAAA,EACtB;AACF;;;AC5CA,SAAS,gBAAgB,YAAY,iBAAiB;AACtD,SAAS,eAAe;AAGxB,IAAM,UAAU,oBAAI,IAAmB;AAEvC,SAAS,SAAS,MAAqB;AACrC,MAAI,IAAI,QAAQ,IAAI,IAAI;AACxB,MAAI,CAAC,GAAG;AACN,QAAI,IAAI,MAAM;AACd,YAAQ,IAAI,MAAM,CAAC;AAAA,EACrB;AACA,SAAO;AACT;AAEO,IAAM,sBAAN,MAA0B;AAAA,EAE/B,YAA4B,MAAc;AAAd;AAC1B,SAAK,QAAQ,SAAS,IAAI;AAC1B,QAAI,CAAC,WAAW,QAAQ,IAAI,CAAC,GAAG;AAC9B,gBAAU,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;AAAA,IAC9C;AAAA,EACF;AAAA,EAL4B;AAAA,EADX;AAAA,EAQjB,MAAM,OAAO,OAA+B;AAC1C,UAAM,OAAO,GAAG,KAAK,UAAU,KAAK,CAAC;AAAA;AACrC,UAAM,KAAK,MAAM,aAAa,MAAM;AAClC,qBAAe,KAAK,MAAM,IAAI;AAAA,IAChC,CAAC;AAAA,EACH;AACF;AAGO,SAAS,iCAAuC;AACrD,UAAQ,MAAM;AAChB;","names":[]}
@@ -316,16 +316,42 @@ function extractProducedState(events) {
316
316
 
317
317
  // src/agent-profile.ts
318
318
  import { createHash } from "crypto";
319
- function agentProfileHash(profile) {
320
- if (typeof profile.model !== "string" || profile.model.trim().length === 0) {
321
- throw new ValidationError(`AgentProfile "${profile.id}" has no model \u2014 cannot hash`);
319
+ function agentProfileId(profile) {
320
+ const label = pathSafeProfileLabel(agentProfileDisplayLabel(profile)) ?? "profile";
321
+ return `${label}-${agentProfileHash(profile).slice(0, 16)}`;
322
+ }
323
+ function agentProfileModelId(profile) {
324
+ const model = profile.model?.default?.trim();
325
+ if (!model) {
326
+ const label = agentProfileDisplayLabel(profile) ?? "unnamed profile";
327
+ throw new ValidationError(
328
+ `AgentProfile "${label}" has no model.default \u2014 cannot record eval run`
329
+ );
330
+ }
331
+ return model;
332
+ }
333
+ function agentProfileDisplayLabel(profile) {
334
+ return profile.name?.trim() || profile.version?.trim() || void 0;
335
+ }
336
+ function pathSafeProfileLabel(label) {
337
+ const safe = label?.trim().replace(/[^A-Za-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
338
+ return safe || void 0;
339
+ }
340
+ function compact(input) {
341
+ const out = {};
342
+ for (const [key, value] of Object.entries(input)) {
343
+ if (value !== void 0) out[key] = value;
322
344
  }
345
+ return out;
346
+ }
347
+ function agentProfileHash(profile) {
348
+ const model = agentProfileModelId(profile);
323
349
  const behaviour = {
324
- model: profile.model.trim(),
325
- skills: [...profile.skills ?? []].sort(),
326
- promptVersion: profile.promptVersion ?? null,
327
- tools: [...profile.tools ?? []].sort(),
328
- metadata: profile.metadata ?? {}
350
+ ...profile,
351
+ name: void 0,
352
+ description: void 0,
353
+ tags: profile.tags ? [...profile.tags].sort() : void 0,
354
+ model: compact({ ...profile.model, default: model })
329
355
  };
330
356
  return createHash("sha256").update(JSON.stringify(canonicalize(behaviour))).digest("hex");
331
357
  }
@@ -337,6 +363,8 @@ export {
337
363
  createLlmCorrectnessChecker,
338
364
  createTokenRecallChecker,
339
365
  extractProducedState,
366
+ agentProfileId,
367
+ agentProfileModelId,
340
368
  agentProfileHash
341
369
  };
342
- //# sourceMappingURL=chunk-S6OZEZQK.js.map
370
+ //# sourceMappingURL=chunk-HMA63UEO.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/completion-verifier.ts","../src/produced-state.ts","../src/agent-profile.ts"],"sourcesContent":["/**\n * Completion verifier — the task-completion oracle.\n *\n * Answers the only eval question that is not a proxy: did the agent actually\n * COMPLETE the task — produce every required deliverable, persisted and\n * correct — rather than describe what should be done. A fluent transcript\n * that never produces the artifact scores zero here.\n *\n * Per requirement, a two-stage check:\n * 1. Structural — a produced item (vault artifact / approved proposal /\n * tool call) of the right kind is matched against the requirement and\n * carries non-empty content. Deterministic; no LLM.\n * 2. Correctness — only if structurally present AND the matched item\n * carries content, one targeted check decides whether that item\n * actually fulfils the requirement. A hallucinated artifact fails here;\n * an absent one already failed stage 1.\n *\n * `completionRate` is satisfied / total. Quality dimensions are meaningless\n * on an incomplete task — callers gate on `fullyComplete` / `completionRate`\n * before scoring quality.\n */\n\nimport type { TCloud } from '@tangle-network/tcloud'\nimport type { Artifact } from './artifact-validator'\nimport type { DefaultVerdict } from './verdict'\n\n/** What kind of produced state can satisfy a requirement structurally. */\nexport type SatisfiedBy = 'artifact' | 'proposal' | 'tool-call' | 'any'\n\nexport interface CompletionRequirement {\n /** Stable id from the task gold (e.g. a persona's `expected_requirements[].req_id`). */\n reqId: string\n /** Human-readable description of the required deliverable. */\n title: string\n /** Optional kind/category hint, matched against a produced item's kind. */\n category?: string\n /** What produced state satisfies this requirement. Defaults to 'any'. */\n satisfiedBy?: SatisfiedBy\n}\n\nexport interface TaskGold {\n taskId: string\n requirements: CompletionRequirement[]\n}\n\nexport interface ProducedProposal {\n id: string\n title: string\n status: 'pending' | 'approved' | 'rejected'\n /** Optional persisted body — when present, enables a correctness check. */\n content?: string\n}\n\n/** Everything observable about what a run actually produced. */\nexport interface ProducedState {\n /** Persisted vault artifacts. Reuses the shared `Artifact` shape. */\n artifacts: Artifact[]\n /** Proposals / filings the agent created. */\n proposals: ProducedProposal[]\n /** Names of tools the agent invoked. */\n toolCalls: string[]\n}\n\nexport interface RequirementCheck {\n reqId: string\n title: string\n /** A produced item of the right kind matched the requirement, non-empty. */\n structurallyPresent: boolean\n /**\n * Whether the matched item actually fulfils the requirement. `null` when\n * not structurally present, or when the matched item carries no content\n * to assess.\n */\n correct: boolean | null\n /** structurallyPresent && correct !== false. */\n satisfied: boolean\n /** Human-readable evidence for the verdict. */\n evidence: string[]\n}\n\n/** Extends the substrate verdict spine: `valid` = `fullyComplete` and\n * `score` = `completionRate` — derived in `completionVerdict()`, the one\n * place those equalities hold by construction. */\nexport interface CompletionVerdict extends DefaultVerdict {\n taskId: string\n requirements: RequirementCheck[]\n /** satisfied / total requirements. */\n completionRate: number\n /** Every requirement satisfied. */\n fullyComplete: boolean\n}\n\n/**\n * Construct a `CompletionVerdict` from the per-requirement checks, deriving\n * `completionRate` / `fullyComplete` and the spine fields (`valid` =\n * `fullyComplete`, `score` = `completionRate`) in one place. Throws on zero\n * requirements — a verdict over nothing is a misconfiguration, mirroring\n * `verifyCompletion`'s gold-spec guard.\n */\nexport function completionVerdict(input: {\n taskId: string\n requirements: RequirementCheck[]\n}): CompletionVerdict {\n if (input.requirements.length === 0) {\n throw new Error(\n `completionVerdict: task '${input.taskId}' has no requirement checks — nothing to derive a verdict from`,\n )\n }\n const satisfiedCount = input.requirements.filter((r) => r.satisfied).length\n const completionRate = satisfiedCount / input.requirements.length\n const fullyComplete = satisfiedCount === input.requirements.length\n return {\n taskId: input.taskId,\n requirements: input.requirements,\n completionRate,\n fullyComplete,\n valid: fullyComplete,\n score: completionRate,\n }\n}\n\n/**\n * Decides whether a produced item's content actually fulfils a requirement.\n * Injected so the structural verifier stays pure and unit-testable; the\n * production implementation is `createLlmCorrectnessChecker`.\n */\nexport type CorrectnessChecker = (\n requirement: CompletionRequirement,\n content: string,\n) => Promise<{ correct: boolean; reason: string }>\n\nconst STOPWORDS = new Set([\n 'the',\n 'a',\n 'an',\n 'of',\n 'for',\n 'and',\n 'or',\n 'to',\n 'in',\n 'on',\n 'with',\n 'by',\n])\n\n// Deliverable-FORM vocabulary — words that name the SHAPE of an output, not its\n// domain content. A correct \"swap-comparison view persisted as a ui/** artifact\"\n// is an OpenUI JSON whose body says nothing about \"artifact\" / \"persisted\" /\n// \"view\"; the discriminative tokens are the domain nouns (swap, comparison).\n// Stripped from the REQUIREMENT side of structural recall so a deliverable is\n// matched on what it IS about, not on the boilerplate describing its form. The\n// correctness checker strips the same class via TITLE_STOPWORDS. Anti-game holds:\n// the distinctive domain tokens remain, so an off-topic item still fails.\nconst REQUIREMENT_FORM_STOPWORDS = new Set([\n 'generated',\n 'generate',\n 'view',\n 'render',\n 'rendered',\n 'persisted',\n 'persist',\n 'artifact',\n 'file',\n 'document',\n 'note',\n 'proposal',\n 'deliverable',\n 'output',\n 'created',\n 'create',\n 'produce',\n 'produced',\n 'flag',\n])\n\nconst MATCH_THRESHOLD = 0.5\nconst MIN_CONTENT_CHARS = 50\n\nfunction tokens(s: string, extraStop?: Set<string>): Set<string> {\n return new Set(\n s\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter((t) => t.length > 1 && !STOPWORDS.has(t) && !extraStop?.has(t)),\n )\n}\n\n/**\n * Recall of the requirement's tokens within a candidate's identifying text.\n * Recall, not Jaccard — a candidate's path/id legitimately carries extra\n * tokens the requirement does not name. The requirement side drops\n * deliverable-FORM vocabulary so recall keys on the distinctive domain tokens.\n */\nfunction tokenRecall(requirementText: string, candidateText: string): number {\n const req = tokens(requirementText, REQUIREMENT_FORM_STOPWORDS)\n if (req.size === 0) return 0\n const cand = tokens(candidateText)\n let hit = 0\n for (const t of req) if (cand.has(t)) hit++\n return hit / req.size\n}\n\ninterface Candidate {\n reqIndex: number\n /** Unique key for a produced item — each item satisfies at most one requirement. */\n itemKey: string\n score: number\n evidence: string\n /** Content to correctness-check, or null when the matched item has none. */\n content: string | null\n}\n\nfunction artifactCandidates(\n req: CompletionRequirement,\n reqIndex: number,\n artifacts: Artifact[],\n): Candidate[] {\n const reqText = `${req.title} ${req.category ?? ''}`\n const out: Candidate[] = []\n artifacts.forEach((a, i) => {\n if ((a.content ?? '').trim().length < MIN_CONTENT_CHARS) return\n // Match against the artifact CONTENT too, not just its path + kind — a\n // generated view / note whose path is generic still satisfies a requirement\n // when its body covers it (e.g. an OpenUI comparison grounded in the on-file\n // figures). Bounded slice keeps the recall text cheap; MATCH_THRESHOLD holds.\n let score = tokenRecall(\n reqText,\n `${a.path ?? ''} ${a.kind} ${(a.content ?? '').slice(0, 4000)}`,\n )\n if (req.category && a.kind && req.category.toLowerCase() === a.kind.toLowerCase()) {\n score = Math.max(score, 1)\n }\n if (score < MATCH_THRESHOLD) return\n out.push({\n reqIndex,\n itemKey: `artifact:${i}`,\n score,\n evidence: `artifact '${a.path ?? a.kind}' matched (token recall ${score.toFixed(2)})`,\n content: a.content ?? null,\n })\n })\n return out\n}\n\nfunction proposalCandidates(\n req: CompletionRequirement,\n reqIndex: number,\n proposals: ProducedProposal[],\n): Candidate[] {\n const reqText = `${req.title} ${req.category ?? ''}`\n const out: Candidate[] = []\n for (const p of proposals) {\n // Pending or rejected work is not a completed deliverable.\n if (p.status !== 'approved') continue\n // A proposal needs an assessable BODY to be a deliverable. A bare title is\n // not completion: correctness cannot be judged on it, so a title-only match\n // would auto-pass the oracle (structurallyPresent && correct===null →\n // satisfied) with no verifiable content. Tool calls are the only\n // legitimately content-less deliverable (`toolCallCandidates`).\n const body = (p.content ?? '').trim()\n if (body.length < MIN_CONTENT_CHARS) continue\n // Match against the body as well as the (often short) title — a refusal /\n // flag / analysis proposal whose title is a label still satisfies a\n // descriptively-worded requirement when its content covers it. MATCH_THRESHOLD\n // + the requirement's distinctive tokens keep an off-topic proposal out;\n // correctness (a SEMANTIC checker, NOT this lexical pass) then judges\n // polarity/fulfilment, so a negation that merely contains the tokens fails.\n // Structural and correctness must use different evidence or the two-stage\n // check collapses to one lexical gate.\n const score = tokenRecall(reqText, `${p.title} ${body}`)\n if (score < MATCH_THRESHOLD) continue\n out.push({\n reqIndex,\n itemKey: `proposal:${p.id}`,\n score,\n evidence: `approved proposal '${p.title}' matched (token recall ${score.toFixed(2)})`,\n content: body,\n })\n }\n return out\n}\n\nfunction toolCallCandidates(\n req: CompletionRequirement,\n reqIndex: number,\n toolCalls: string[],\n): Candidate[] {\n const out: Candidate[] = []\n toolCalls.forEach((name, i) => {\n const score = tokenRecall(req.title, name)\n if (score < MATCH_THRESHOLD) return\n out.push({\n reqIndex,\n itemKey: `tool:${i}`,\n score,\n evidence: `tool call '${name}' matched (token recall ${score.toFixed(2)})`,\n content: null,\n })\n })\n return out\n}\n\n/**\n * Verify whether a run completed the task. `checkCorrectness` is injected —\n * `createLlmCorrectnessChecker` for production, a deterministic stub in tests.\n *\n * Throws on a gold spec with no requirements: an eval task that requires\n * nothing is a misconfiguration, not a vacuously-complete task.\n */\nexport async function verifyCompletion(\n gold: TaskGold,\n state: ProducedState,\n checkCorrectness: CorrectnessChecker,\n): Promise<CompletionVerdict> {\n if (gold.requirements.length === 0) {\n throw new Error(\n `verifyCompletion: task '${gold.taskId}' has no requirements — malformed gold spec`,\n )\n }\n\n // Collect every above-threshold (requirement, produced-item) candidate, then\n // assign greedily by descending score: each requirement and each produced\n // item is used at most once. One deliverable fulfils one requirement.\n const candidates: Candidate[] = []\n gold.requirements.forEach((req, i) => {\n const by = req.satisfiedBy ?? 'any'\n if (by === 'artifact' || by === 'any') {\n candidates.push(...artifactCandidates(req, i, state.artifacts))\n }\n if (by === 'proposal' || by === 'any') {\n candidates.push(...proposalCandidates(req, i, state.proposals))\n }\n if (by === 'tool-call' || by === 'any') {\n candidates.push(...toolCallCandidates(req, i, state.toolCalls))\n }\n })\n candidates.sort((a, b) => b.score - a.score)\n\n const assigned = new Map<number, Candidate>()\n const itemTaken = new Set<string>()\n for (const c of candidates) {\n if (assigned.has(c.reqIndex) || itemTaken.has(c.itemKey)) continue\n assigned.set(c.reqIndex, c)\n itemTaken.add(c.itemKey)\n }\n\n const requirements: RequirementCheck[] = []\n for (let i = 0; i < gold.requirements.length; i++) {\n const req = gold.requirements[i]!\n const match = assigned.get(i)\n const evidence: string[] = []\n let correct: boolean | null = null\n\n if (match) {\n evidence.push(match.evidence)\n if (match.content !== null) {\n const r = await checkCorrectness(req, match.content)\n correct = r.correct\n evidence.push(`correctness: ${r.correct ? 'pass' : 'fail'} — ${r.reason}`)\n } else {\n evidence.push('correctness: not assessed — matched item carries no content')\n }\n } else {\n const by = req.satisfiedBy ?? 'any'\n const kind = by === 'any' ? 'artifact/proposal/tool-call' : by\n evidence.push(`no produced ${kind} matched this requirement`)\n }\n\n const structurallyPresent = match !== undefined\n const satisfied = structurallyPresent && correct !== false\n requirements.push({\n reqId: req.reqId,\n title: req.title,\n structurallyPresent,\n correct,\n satisfied,\n evidence,\n })\n }\n\n return completionVerdict({ taskId: gold.taskId, requirements })\n}\n\nexport interface LlmCorrectnessCheckerOpts {\n model?: string\n /** Max chars of artifact content sent to the checker. */\n maxContentChars?: number\n}\n\n/** Parse the correctness checker's model response. Fails loud on a bad shape. */\nexport function parseCorrectnessResponse(raw: string): { correct: boolean; reason: string } {\n const match = raw.match(/\\{[\\s\\S]*\\}/)\n if (!match) {\n throw new Error(`correctness checker: no JSON object in model response: ${raw.slice(0, 200)}`)\n }\n const parsed = JSON.parse(match[0]) as { correct?: unknown; reason?: unknown }\n if (typeof parsed.correct !== 'boolean') {\n throw new Error(`correctness checker: 'correct' is not a boolean in: ${match[0].slice(0, 200)}`)\n }\n return { correct: parsed.correct, reason: typeof parsed.reason === 'string' ? parsed.reason : '' }\n}\n\n/**\n * Production `CorrectnessChecker` — one LLM call per matched artifact,\n * deterministic (temperature 0), structured JSON out. Judges fulfilment\n * only: a plan, a gesture, or a description of what should be done does not\n * fulfil a requirement — the artifact must BE the deliverable.\n */\nexport function createLlmCorrectnessChecker(\n tc: TCloud,\n opts: LlmCorrectnessCheckerOpts = {},\n): CorrectnessChecker {\n const model = opts.model ?? 'claude-sonnet-4-6'\n const maxContentChars = opts.maxContentChars ?? 8000\n return async (requirement, content) => {\n const resp = await tc.chat({\n model,\n messages: [\n {\n role: 'system',\n content:\n 'You verify whether a produced work artifact actually fulfils a stated requirement. Judge fulfilment only — is the deliverable substantively present and on-point — not polish. A plan to do it later, a vague gesture, or a description of what should be done does NOT fulfil a requirement; the artifact must BE the deliverable. Respond with a single JSON object: {\"correct\": boolean, \"reason\": string (<= 30 words)}.',\n },\n {\n role: 'user',\n content: `Requirement: ${requirement.title}\\n${\n requirement.category ? `Category: ${requirement.category}\\n` : ''\n }\\nProduced artifact:\\n${content.slice(0, maxContentChars)}`,\n },\n ],\n temperature: 0,\n maxTokens: 200,\n })\n const raw =\n (resp as { choices?: { message?: { content?: string } }[] }).choices?.[0]?.message?.content ??\n ''\n return parseCorrectnessResponse(raw)\n }\n}\n\n/** Stopwords for requirement-title tokenization — drops the imperative verbs\n * ('review', 'update', …) common to deliverable titles so recall keys on the\n * substantive nouns, not the boilerplate ask. */\nconst TITLE_STOPWORDS = new Set([\n 'the',\n 'a',\n 'an',\n 'and',\n 'or',\n 'for',\n 'to',\n 'of',\n 'in',\n 'on',\n 'with',\n 'review',\n 'update',\n 'new',\n 'proposed',\n])\n\n/**\n * Deterministic `CorrectnessChecker` — the no-LLM counterpart to\n * `createLlmCorrectnessChecker`. A produced item fulfils a requirement when its\n * content is substantive (≥ `minContentLength` chars) AND recalls ≥ `minRecall`\n * of the requirement title's significant tokens. No network.\n *\n * Polarity-blind: token recall credits a negation that contains the\n * requirement's tokens (\"I will NOT produce the comparison\" recalls every token\n * of \"produce the comparison\"). The structural match stage is ALSO lexical, so\n * pairing the two collapses to a single gameable gate. Use this only as an\n * opt-in structural pre-filter or for tasks whose requirements have no polarity\n * to invert; for produced-state grading the correctness checker MUST be semantic\n * (`createLlmCorrectnessChecker`). See the anti-game fixtures in the test suite.\n */\nexport function createTokenRecallChecker(\n opts: { minRecall?: number; minContentLength?: number } = {},\n): CorrectnessChecker {\n const minRecall = opts.minRecall ?? 0.5\n const minLen = opts.minContentLength ?? 120\n return async (requirement, content) => {\n const body = content.trim()\n if (body.length < minLen)\n return {\n correct: false,\n reason: `content too thin (${body.length} chars) to be the deliverable`,\n }\n const titleTokens = requirement.title\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter((t) => t.length > 2 && !TITLE_STOPWORDS.has(t))\n if (titleTokens.length === 0)\n return {\n correct: true,\n reason: 'requirement title has no significant tokens — structural match accepted',\n }\n const lower = body.toLowerCase()\n const hits = titleTokens.filter((t) => lower.includes(t)).length\n const recall = hits / titleTokens.length\n return recall >= minRecall\n ? {\n correct: true,\n reason: `content recalls ${hits}/${titleTokens.length} requirement tokens`,\n }\n : {\n correct: false,\n reason: `content recalls only ${hits}/${titleTokens.length} requirement tokens`,\n }\n }\n}\n","/**\n * Produced-state extraction — normalize a run's runtime event stream into the\n * typed `ProducedState` the completion oracle consumes.\n *\n * `ProducedState` answers \"what did the agent actually produce\" — vault\n * artifacts, proposals, tool calls. The runtime emits these as a stream of\n * events; this module is the single normalization point from that stream to\n * the shape `verifyCompletion` expects.\n *\n * Input is structurally typed (`RuntimeEventLike`) so this module does not\n * depend on agent-runtime — agent-runtime's `RuntimeStreamEvent` satisfies it\n * structurally. The `content` on `ArtifactEventLike` and the whole\n * `proposal_created` variant are the runtime-side enrichments this contract\n * requires; the runtime emits them, this module consumes them.\n */\n\nimport type { Artifact } from './artifact-validator'\nimport type { ProducedProposal, ProducedState } from './completion-verifier'\n\n/** A tool the agent invoked. */\nexport interface ToolCallEventLike {\n type: 'tool_call'\n toolName: string\n}\n\n/**\n * An artifact the agent produced. `content` is the enriched field — the\n * runtime's base `artifact` event carries only metadata; the completion\n * oracle needs the body to verify the deliverable, so the runtime emits it.\n */\nexport interface ArtifactEventLike {\n type: 'artifact'\n artifactId: string\n name?: string\n mimeType?: string\n uri?: string\n content?: string\n}\n\n/** A proposal / filing the agent created. */\nexport interface ProposalEventLike {\n type: 'proposal_created'\n proposalId: string\n title: string\n status?: 'pending' | 'approved' | 'rejected'\n // body of the proposal (e.g. a submit_proposal `description`). When present,\n // the completion oracle correctness-checks it like artifact content; absent,\n // the proposal is graded presence-only.\n content?: string\n}\n\n/**\n * The subset of runtime stream events `extractProducedState` consumes.\n * agent-runtime's full `RuntimeStreamEvent` union satisfies this structurally;\n * the `{ type: string }` catch-all keeps the input permissive so callers can\n * pass the whole unfiltered telemetry stream — unrecognized events are skipped.\n */\nexport type RuntimeEventLike =\n | ToolCallEventLike\n | ArtifactEventLike\n | ProposalEventLike\n | { type: string }\n\nfunction artifactKind(mimeType: string | undefined): string {\n if (!mimeType) return 'file'\n if (mimeType.includes('json')) return 'json'\n if (mimeType.startsWith('text/')) return 'text'\n return 'file'\n}\n\n/**\n * Normalize a run's runtime event stream into `ProducedState`.\n *\n * Pure and total — unrecognized event types are skipped. `toolCalls` is\n * deduplicated by name in first-seen order (completion cares about a tool's\n * presence, not its call count). An artifact with neither a name nor a uri\n * still yields an entry keyed by its `artifactId` so it is never silently\n * dropped; an artifact with no `content` yields empty content, which the\n * completion oracle's structural check then rejects on its own.\n */\nexport function extractProducedState(events: readonly RuntimeEventLike[]): ProducedState {\n const artifacts: Artifact[] = []\n const proposals: ProducedProposal[] = []\n const toolCalls: string[] = []\n const seenTools = new Set<string>()\n\n for (const ev of events) {\n if (ev.type === 'tool_call') {\n const name = (ev as ToolCallEventLike).toolName\n if (name && !seenTools.has(name)) {\n seenTools.add(name)\n toolCalls.push(name)\n }\n } else if (ev.type === 'artifact') {\n const a = ev as ArtifactEventLike\n artifacts.push({\n kind: artifactKind(a.mimeType),\n path: a.name ?? a.uri ?? a.artifactId,\n content: a.content ?? '',\n })\n } else if (ev.type === 'proposal_created') {\n const p = ev as ProposalEventLike\n proposals.push({\n id: p.proposalId,\n title: p.title,\n status: p.status ?? 'pending',\n ...(p.content !== undefined ? { content: p.content } : {}),\n })\n }\n }\n\n return { artifacts, proposals, toolCalls }\n}\n","/**\n * @stable\n *\n * AgentProfile — the eval harness's unit of variation.\n *\n * A profile pins everything that changes agent behaviour for a benchmark\n * cell: the model, the active skills, the prompt version, the available\n * tools. Vary the profile — swap a model, add a skill — and re-run the suite\n * to benchmark the change. The scorecard keys a cell on\n * `(scenarioId, profileHash)`, so the model is not a separate axis: it lives\n * inside the profile, and two profiles with the same model but different\n * skills are different cells.\n *\n * `agentProfileHash` is the profile's behaviour identity. Two profiles that\n * produce the same agent behaviour share a hash (and a scorecard cell);\n * reordering `skills` or `tools` does not change it; the human-facing `id`\n * label does not affect it.\n */\n\nimport { createHash } from 'node:crypto'\nimport { ValidationError } from './errors'\nimport { canonicalize } from './pre-registration'\n\nexport interface AgentProfile {\n /** Human-facing label, e.g. `sonnet-legal-skills-v3`. Not part of the hash. */\n id: string\n /** Model snapshot id this profile pins, e.g. `claude-sonnet-4-6@2025-04-15`. */\n model: string\n /** Skill ids/versions active in this profile — the primary behaviour lever. */\n skills?: string[]\n /** Prompt version identifier. */\n promptVersion?: string\n /** Tool ids available to the agent. */\n tools?: string[]\n /** Any other behaviour-bearing knobs that should fingerprint into the hash. */\n metadata?: Record<string, string | number | boolean>\n}\n\n/**\n * Deterministic behaviour identity of a profile — a sha256 over the\n * behaviour-bearing fields. `skills` and `tools` are order-insensitive; the\n * `id` label is excluded. Throws on a profile with no `model` — an unkeyable\n * profile must fail loud rather than collapse into a blank-model cell.\n */\nexport function agentProfileHash(profile: AgentProfile): string {\n if (typeof profile.model !== 'string' || profile.model.trim().length === 0) {\n throw new ValidationError(`AgentProfile \"${profile.id}\" has no model — cannot hash`)\n }\n const behaviour = {\n model: profile.model.trim(),\n skills: [...(profile.skills ?? [])].sort(),\n promptVersion: profile.promptVersion ?? null,\n tools: [...(profile.tools ?? [])].sort(),\n metadata: profile.metadata ?? {},\n }\n return createHash('sha256')\n .update(JSON.stringify(canonicalize(behaviour)))\n .digest('hex')\n}\n"],"mappings":";;;;;;;;AAmGO,SAAS,kBAAkB,OAGZ;AACpB,MAAI,MAAM,aAAa,WAAW,GAAG;AACnC,UAAM,IAAI;AAAA,MACR,4BAA4B,MAAM,MAAM;AAAA,IAC1C;AAAA,EACF;AACA,QAAM,iBAAiB,MAAM,aAAa,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE;AACrE,QAAM,iBAAiB,iBAAiB,MAAM,aAAa;AAC3D,QAAM,gBAAgB,mBAAmB,MAAM,aAAa;AAC5D,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,cAAc,MAAM;AAAA,IACpB;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AACF;AAYA,IAAM,YAAY,oBAAI,IAAI;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAUD,IAAM,6BAA6B,oBAAI,IAAI;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AA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AA,EACrF;AACA,QAAM,YAAY;AAAA,IAChB,OAAO,QAAQ,MAAM,KAAK;AAAA,IAC1B,QAAQ,CAAC,GAAI,QAAQ,UAAU,CAAC,CAAE,EAAE,KAAK;AAAA,IACzC,eAAe,QAAQ,iBAAiB;AAAA,IACxC,OAAO,CAAC,GAAI,QAAQ,SAAS,CAAC,CAAE,EAAE,KAAK;AAAA,IACvC,UAAU,QAAQ,YAAY,CAAC;AAAA,EACjC;AACA,SAAO,WAAW,QAAQ,EACvB,OAAO,KAAK,UAAU,aAAa,SAAS,CAAC,CAAC,EAC9C,OAAO,KAAK;AACjB;","names":[]}
1
+ {"version":3,"sources":["../src/completion-verifier.ts","../src/produced-state.ts","../src/agent-profile.ts"],"sourcesContent":["/**\n * Completion verifier — the task-completion oracle.\n *\n * Answers the only eval question that is not a proxy: did the agent actually\n * COMPLETE the task — produce every required deliverable, persisted and\n * correct — rather than describe what should be done. A fluent transcript\n * that never produces the artifact scores zero here.\n *\n * Per requirement, a two-stage check:\n * 1. Structural — a produced item (vault artifact / approved proposal /\n * tool call) of the right kind is matched against the requirement and\n * carries non-empty content. Deterministic; no LLM.\n * 2. Correctness — only if structurally present AND the matched item\n * carries content, one targeted check decides whether that item\n * actually fulfils the requirement. A hallucinated artifact fails here;\n * an absent one already failed stage 1.\n *\n * `completionRate` is satisfied / total. Quality dimensions are meaningless\n * on an incomplete task — callers gate on `fullyComplete` / `completionRate`\n * before scoring quality.\n */\n\nimport type { TCloud } from '@tangle-network/tcloud'\nimport type { Artifact } from './artifact-validator'\nimport type { DefaultVerdict } from './verdict'\n\n/** What kind of produced state can satisfy a requirement structurally. */\nexport type SatisfiedBy = 'artifact' | 'proposal' | 'tool-call' | 'any'\n\nexport interface CompletionRequirement {\n /** Stable id from the task gold (e.g. a persona's `expected_requirements[].req_id`). */\n reqId: string\n /** Human-readable description of the required deliverable. */\n title: string\n /** Optional kind/category hint, matched against a produced item's kind. */\n category?: string\n /** What produced state satisfies this requirement. Defaults to 'any'. */\n satisfiedBy?: SatisfiedBy\n}\n\nexport interface TaskGold {\n taskId: string\n requirements: CompletionRequirement[]\n}\n\nexport interface ProducedProposal {\n id: string\n title: string\n status: 'pending' | 'approved' | 'rejected'\n /** Optional persisted body — when present, enables a correctness check. */\n content?: string\n}\n\n/** Everything observable about what a run actually produced. */\nexport interface ProducedState {\n /** Persisted vault artifacts. Reuses the shared `Artifact` shape. */\n artifacts: Artifact[]\n /** Proposals / filings the agent created. */\n proposals: ProducedProposal[]\n /** Names of tools the agent invoked. */\n toolCalls: string[]\n}\n\nexport interface RequirementCheck {\n reqId: string\n title: string\n /** A produced item of the right kind matched the requirement, non-empty. */\n structurallyPresent: boolean\n /**\n * Whether the matched item actually fulfils the requirement. `null` when\n * not structurally present, or when the matched item carries no content\n * to assess.\n */\n correct: boolean | null\n /** structurallyPresent && correct !== false. */\n satisfied: boolean\n /** Human-readable evidence for the verdict. */\n evidence: string[]\n}\n\n/** Extends the substrate verdict spine: `valid` = `fullyComplete` and\n * `score` = `completionRate` — derived in `completionVerdict()`, the one\n * place those equalities hold by construction. */\nexport interface CompletionVerdict extends DefaultVerdict {\n taskId: string\n requirements: RequirementCheck[]\n /** satisfied / total requirements. */\n completionRate: number\n /** Every requirement satisfied. */\n fullyComplete: boolean\n}\n\n/**\n * Construct a `CompletionVerdict` from the per-requirement checks, deriving\n * `completionRate` / `fullyComplete` and the spine fields (`valid` =\n * `fullyComplete`, `score` = `completionRate`) in one place. Throws on zero\n * requirements — a verdict over nothing is a misconfiguration, mirroring\n * `verifyCompletion`'s gold-spec guard.\n */\nexport function completionVerdict(input: {\n taskId: string\n requirements: RequirementCheck[]\n}): CompletionVerdict {\n if (input.requirements.length === 0) {\n throw new Error(\n `completionVerdict: task '${input.taskId}' has no requirement checks — nothing to derive a verdict from`,\n )\n }\n const satisfiedCount = input.requirements.filter((r) => r.satisfied).length\n const completionRate = satisfiedCount / input.requirements.length\n const fullyComplete = satisfiedCount === input.requirements.length\n return {\n taskId: input.taskId,\n requirements: input.requirements,\n completionRate,\n fullyComplete,\n valid: fullyComplete,\n score: completionRate,\n }\n}\n\n/**\n * Decides whether a produced item's content actually fulfils a requirement.\n * Injected so the structural verifier stays pure and unit-testable; the\n * production implementation is `createLlmCorrectnessChecker`.\n */\nexport type CorrectnessChecker = (\n requirement: CompletionRequirement,\n content: string,\n) => Promise<{ correct: boolean; reason: string }>\n\nconst STOPWORDS = new Set([\n 'the',\n 'a',\n 'an',\n 'of',\n 'for',\n 'and',\n 'or',\n 'to',\n 'in',\n 'on',\n 'with',\n 'by',\n])\n\n// Deliverable-FORM vocabulary — words that name the SHAPE of an output, not its\n// domain content. A correct \"swap-comparison view persisted as a ui/** artifact\"\n// is an OpenUI JSON whose body says nothing about \"artifact\" / \"persisted\" /\n// \"view\"; the discriminative tokens are the domain nouns (swap, comparison).\n// Stripped from the REQUIREMENT side of structural recall so a deliverable is\n// matched on what it IS about, not on the boilerplate describing its form. The\n// correctness checker strips the same class via TITLE_STOPWORDS. Anti-game holds:\n// the distinctive domain tokens remain, so an off-topic item still fails.\nconst REQUIREMENT_FORM_STOPWORDS = new Set([\n 'generated',\n 'generate',\n 'view',\n 'render',\n 'rendered',\n 'persisted',\n 'persist',\n 'artifact',\n 'file',\n 'document',\n 'note',\n 'proposal',\n 'deliverable',\n 'output',\n 'created',\n 'create',\n 'produce',\n 'produced',\n 'flag',\n])\n\nconst MATCH_THRESHOLD = 0.5\nconst MIN_CONTENT_CHARS = 50\n\nfunction tokens(s: string, extraStop?: Set<string>): Set<string> {\n return new Set(\n s\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter((t) => t.length > 1 && !STOPWORDS.has(t) && !extraStop?.has(t)),\n )\n}\n\n/**\n * Recall of the requirement's tokens within a candidate's identifying text.\n * Recall, not Jaccard — a candidate's path/id legitimately carries extra\n * tokens the requirement does not name. The requirement side drops\n * deliverable-FORM vocabulary so recall keys on the distinctive domain tokens.\n */\nfunction tokenRecall(requirementText: string, candidateText: string): number {\n const req = tokens(requirementText, REQUIREMENT_FORM_STOPWORDS)\n if (req.size === 0) return 0\n const cand = tokens(candidateText)\n let hit = 0\n for (const t of req) if (cand.has(t)) hit++\n return hit / req.size\n}\n\ninterface Candidate {\n reqIndex: number\n /** Unique key for a produced item — each item satisfies at most one requirement. */\n itemKey: string\n score: number\n evidence: string\n /** Content to correctness-check, or null when the matched item has none. */\n content: string | null\n}\n\nfunction artifactCandidates(\n req: CompletionRequirement,\n reqIndex: number,\n artifacts: Artifact[],\n): Candidate[] {\n const reqText = `${req.title} ${req.category ?? ''}`\n const out: Candidate[] = []\n artifacts.forEach((a, i) => {\n if ((a.content ?? '').trim().length < MIN_CONTENT_CHARS) return\n // Match against the artifact CONTENT too, not just its path + kind — a\n // generated view / note whose path is generic still satisfies a requirement\n // when its body covers it (e.g. an OpenUI comparison grounded in the on-file\n // figures). Bounded slice keeps the recall text cheap; MATCH_THRESHOLD holds.\n let score = tokenRecall(\n reqText,\n `${a.path ?? ''} ${a.kind} ${(a.content ?? '').slice(0, 4000)}`,\n )\n if (req.category && a.kind && req.category.toLowerCase() === a.kind.toLowerCase()) {\n score = Math.max(score, 1)\n }\n if (score < MATCH_THRESHOLD) return\n out.push({\n reqIndex,\n itemKey: `artifact:${i}`,\n score,\n evidence: `artifact '${a.path ?? a.kind}' matched (token recall ${score.toFixed(2)})`,\n content: a.content ?? null,\n })\n })\n return out\n}\n\nfunction proposalCandidates(\n req: CompletionRequirement,\n reqIndex: number,\n proposals: ProducedProposal[],\n): Candidate[] {\n const reqText = `${req.title} ${req.category ?? ''}`\n const out: Candidate[] = []\n for (const p of proposals) {\n // Pending or rejected work is not a completed deliverable.\n if (p.status !== 'approved') continue\n // A proposal needs an assessable BODY to be a deliverable. A bare title is\n // not completion: correctness cannot be judged on it, so a title-only match\n // would auto-pass the oracle (structurallyPresent && correct===null →\n // satisfied) with no verifiable content. Tool calls are the only\n // legitimately content-less deliverable (`toolCallCandidates`).\n const body = (p.content ?? '').trim()\n if (body.length < MIN_CONTENT_CHARS) continue\n // Match against the body as well as the (often short) title — a refusal /\n // flag / analysis proposal whose title is a label still satisfies a\n // descriptively-worded requirement when its content covers it. MATCH_THRESHOLD\n // + the requirement's distinctive tokens keep an off-topic proposal out;\n // correctness (a SEMANTIC checker, NOT this lexical pass) then judges\n // polarity/fulfilment, so a negation that merely contains the tokens fails.\n // Structural and correctness must use different evidence or the two-stage\n // check collapses to one lexical gate.\n const score = tokenRecall(reqText, `${p.title} ${body}`)\n if (score < MATCH_THRESHOLD) continue\n out.push({\n reqIndex,\n itemKey: `proposal:${p.id}`,\n score,\n evidence: `approved proposal '${p.title}' matched (token recall ${score.toFixed(2)})`,\n content: body,\n })\n }\n return out\n}\n\nfunction toolCallCandidates(\n req: CompletionRequirement,\n reqIndex: number,\n toolCalls: string[],\n): Candidate[] {\n const out: Candidate[] = []\n toolCalls.forEach((name, i) => {\n const score = tokenRecall(req.title, name)\n if (score < MATCH_THRESHOLD) return\n out.push({\n reqIndex,\n itemKey: `tool:${i}`,\n score,\n evidence: `tool call '${name}' matched (token recall ${score.toFixed(2)})`,\n content: null,\n })\n })\n return out\n}\n\n/**\n * Verify whether a run completed the task. `checkCorrectness` is injected —\n * `createLlmCorrectnessChecker` for production, a deterministic stub in tests.\n *\n * Throws on a gold spec with no requirements: an eval task that requires\n * nothing is a misconfiguration, not a vacuously-complete task.\n */\nexport async function verifyCompletion(\n gold: TaskGold,\n state: ProducedState,\n checkCorrectness: CorrectnessChecker,\n): Promise<CompletionVerdict> {\n if (gold.requirements.length === 0) {\n throw new Error(\n `verifyCompletion: task '${gold.taskId}' has no requirements — malformed gold spec`,\n )\n }\n\n // Collect every above-threshold (requirement, produced-item) candidate, then\n // assign greedily by descending score: each requirement and each produced\n // item is used at most once. One deliverable fulfils one requirement.\n const candidates: Candidate[] = []\n gold.requirements.forEach((req, i) => {\n const by = req.satisfiedBy ?? 'any'\n if (by === 'artifact' || by === 'any') {\n candidates.push(...artifactCandidates(req, i, state.artifacts))\n }\n if (by === 'proposal' || by === 'any') {\n candidates.push(...proposalCandidates(req, i, state.proposals))\n }\n if (by === 'tool-call' || by === 'any') {\n candidates.push(...toolCallCandidates(req, i, state.toolCalls))\n }\n })\n candidates.sort((a, b) => b.score - a.score)\n\n const assigned = new Map<number, Candidate>()\n const itemTaken = new Set<string>()\n for (const c of candidates) {\n if (assigned.has(c.reqIndex) || itemTaken.has(c.itemKey)) continue\n assigned.set(c.reqIndex, c)\n itemTaken.add(c.itemKey)\n }\n\n const requirements: RequirementCheck[] = []\n for (let i = 0; i < gold.requirements.length; i++) {\n const req = gold.requirements[i]!\n const match = assigned.get(i)\n const evidence: string[] = []\n let correct: boolean | null = null\n\n if (match) {\n evidence.push(match.evidence)\n if (match.content !== null) {\n const r = await checkCorrectness(req, match.content)\n correct = r.correct\n evidence.push(`correctness: ${r.correct ? 'pass' : 'fail'} — ${r.reason}`)\n } else {\n evidence.push('correctness: not assessed — matched item carries no content')\n }\n } else {\n const by = req.satisfiedBy ?? 'any'\n const kind = by === 'any' ? 'artifact/proposal/tool-call' : by\n evidence.push(`no produced ${kind} matched this requirement`)\n }\n\n const structurallyPresent = match !== undefined\n const satisfied = structurallyPresent && correct !== false\n requirements.push({\n reqId: req.reqId,\n title: req.title,\n structurallyPresent,\n correct,\n satisfied,\n evidence,\n })\n }\n\n return completionVerdict({ taskId: gold.taskId, requirements })\n}\n\nexport interface LlmCorrectnessCheckerOpts {\n model?: string\n /** Max chars of artifact content sent to the checker. */\n maxContentChars?: number\n}\n\n/** Parse the correctness checker's model response. Fails loud on a bad shape. */\nexport function parseCorrectnessResponse(raw: string): { correct: boolean; reason: string } {\n const match = raw.match(/\\{[\\s\\S]*\\}/)\n if (!match) {\n throw new Error(`correctness checker: no JSON object in model response: ${raw.slice(0, 200)}`)\n }\n const parsed = JSON.parse(match[0]) as { correct?: unknown; reason?: unknown }\n if (typeof parsed.correct !== 'boolean') {\n throw new Error(`correctness checker: 'correct' is not a boolean in: ${match[0].slice(0, 200)}`)\n }\n return { correct: parsed.correct, reason: typeof parsed.reason === 'string' ? parsed.reason : '' }\n}\n\n/**\n * Production `CorrectnessChecker` — one LLM call per matched artifact,\n * deterministic (temperature 0), structured JSON out. Judges fulfilment\n * only: a plan, a gesture, or a description of what should be done does not\n * fulfil a requirement — the artifact must BE the deliverable.\n */\nexport function createLlmCorrectnessChecker(\n tc: TCloud,\n opts: LlmCorrectnessCheckerOpts = {},\n): CorrectnessChecker {\n const model = opts.model ?? 'claude-sonnet-4-6'\n const maxContentChars = opts.maxContentChars ?? 8000\n return async (requirement, content) => {\n const resp = await tc.chat({\n model,\n messages: [\n {\n role: 'system',\n content:\n 'You verify whether a produced work artifact actually fulfils a stated requirement. Judge fulfilment only — is the deliverable substantively present and on-point — not polish. A plan to do it later, a vague gesture, or a description of what should be done does NOT fulfil a requirement; the artifact must BE the deliverable. Respond with a single JSON object: {\"correct\": boolean, \"reason\": string (<= 30 words)}.',\n },\n {\n role: 'user',\n content: `Requirement: ${requirement.title}\\n${\n requirement.category ? `Category: ${requirement.category}\\n` : ''\n }\\nProduced artifact:\\n${content.slice(0, maxContentChars)}`,\n },\n ],\n temperature: 0,\n maxTokens: 200,\n })\n const raw =\n (resp as { choices?: { message?: { content?: string } }[] }).choices?.[0]?.message?.content ??\n ''\n return parseCorrectnessResponse(raw)\n }\n}\n\n/** Stopwords for requirement-title tokenization — drops the imperative verbs\n * ('review', 'update', …) common to deliverable titles so recall keys on the\n * substantive nouns, not the boilerplate ask. */\nconst TITLE_STOPWORDS = new Set([\n 'the',\n 'a',\n 'an',\n 'and',\n 'or',\n 'for',\n 'to',\n 'of',\n 'in',\n 'on',\n 'with',\n 'review',\n 'update',\n 'new',\n 'proposed',\n])\n\n/**\n * Deterministic `CorrectnessChecker` — the no-LLM counterpart to\n * `createLlmCorrectnessChecker`. A produced item fulfils a requirement when its\n * content is substantive (≥ `minContentLength` chars) AND recalls ≥ `minRecall`\n * of the requirement title's significant tokens. No network.\n *\n * Polarity-blind: token recall credits a negation that contains the\n * requirement's tokens (\"I will NOT produce the comparison\" recalls every token\n * of \"produce the comparison\"). The structural match stage is ALSO lexical, so\n * pairing the two collapses to a single gameable gate. Use this only as an\n * opt-in structural pre-filter or for tasks whose requirements have no polarity\n * to invert; for produced-state grading the correctness checker MUST be semantic\n * (`createLlmCorrectnessChecker`). See the anti-game fixtures in the test suite.\n */\nexport function createTokenRecallChecker(\n opts: { minRecall?: number; minContentLength?: number } = {},\n): CorrectnessChecker {\n const minRecall = opts.minRecall ?? 0.5\n const minLen = opts.minContentLength ?? 120\n return async (requirement, content) => {\n const body = content.trim()\n if (body.length < minLen)\n return {\n correct: false,\n reason: `content too thin (${body.length} chars) to be the deliverable`,\n }\n const titleTokens = requirement.title\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter((t) => t.length > 2 && !TITLE_STOPWORDS.has(t))\n if (titleTokens.length === 0)\n return {\n correct: true,\n reason: 'requirement title has no significant tokens — structural match accepted',\n }\n const lower = body.toLowerCase()\n const hits = titleTokens.filter((t) => lower.includes(t)).length\n const recall = hits / titleTokens.length\n return recall >= minRecall\n ? {\n correct: true,\n reason: `content recalls ${hits}/${titleTokens.length} requirement tokens`,\n }\n : {\n correct: false,\n reason: `content recalls only ${hits}/${titleTokens.length} requirement tokens`,\n }\n }\n}\n","/**\n * Produced-state extraction — normalize a run's runtime event stream into the\n * typed `ProducedState` the completion oracle consumes.\n *\n * `ProducedState` answers \"what did the agent actually produce\" — vault\n * artifacts, proposals, tool calls. The runtime emits these as a stream of\n * events; this module is the single normalization point from that stream to\n * the shape `verifyCompletion` expects.\n *\n * Input is structurally typed (`RuntimeEventLike`) so this module does not\n * depend on agent-runtime — agent-runtime's `RuntimeStreamEvent` satisfies it\n * structurally. The `content` on `ArtifactEventLike` and the whole\n * `proposal_created` variant are the runtime-side enrichments this contract\n * requires; the runtime emits them, this module consumes them.\n */\n\nimport type { Artifact } from './artifact-validator'\nimport type { ProducedProposal, ProducedState } from './completion-verifier'\n\n/** A tool the agent invoked. */\nexport interface ToolCallEventLike {\n type: 'tool_call'\n toolName: string\n}\n\n/**\n * An artifact the agent produced. `content` is the enriched field — the\n * runtime's base `artifact` event carries only metadata; the completion\n * oracle needs the body to verify the deliverable, so the runtime emits it.\n */\nexport interface ArtifactEventLike {\n type: 'artifact'\n artifactId: string\n name?: string\n mimeType?: string\n uri?: string\n content?: string\n}\n\n/** A proposal / filing the agent created. */\nexport interface ProposalEventLike {\n type: 'proposal_created'\n proposalId: string\n title: string\n status?: 'pending' | 'approved' | 'rejected'\n // body of the proposal (e.g. a submit_proposal `description`). When present,\n // the completion oracle correctness-checks it like artifact content; absent,\n // the proposal is graded presence-only.\n content?: string\n}\n\n/**\n * The subset of runtime stream events `extractProducedState` consumes.\n * agent-runtime's full `RuntimeStreamEvent` union satisfies this structurally;\n * the `{ type: string }` catch-all keeps the input permissive so callers can\n * pass the whole unfiltered telemetry stream — unrecognized events are skipped.\n */\nexport type RuntimeEventLike =\n | ToolCallEventLike\n | ArtifactEventLike\n | ProposalEventLike\n | { type: string }\n\nfunction artifactKind(mimeType: string | undefined): string {\n if (!mimeType) return 'file'\n if (mimeType.includes('json')) return 'json'\n if (mimeType.startsWith('text/')) return 'text'\n return 'file'\n}\n\n/**\n * Normalize a run's runtime event stream into `ProducedState`.\n *\n * Pure and total — unrecognized event types are skipped. `toolCalls` is\n * deduplicated by name in first-seen order (completion cares about a tool's\n * presence, not its call count). An artifact with neither a name nor a uri\n * still yields an entry keyed by its `artifactId` so it is never silently\n * dropped; an artifact with no `content` yields empty content, which the\n * completion oracle's structural check then rejects on its own.\n */\nexport function extractProducedState(events: readonly RuntimeEventLike[]): ProducedState {\n const artifacts: Artifact[] = []\n const proposals: ProducedProposal[] = []\n const toolCalls: string[] = []\n const seenTools = new Set<string>()\n\n for (const ev of events) {\n if (ev.type === 'tool_call') {\n const name = (ev as ToolCallEventLike).toolName\n if (name && !seenTools.has(name)) {\n seenTools.add(name)\n toolCalls.push(name)\n }\n } else if (ev.type === 'artifact') {\n const a = ev as ArtifactEventLike\n artifacts.push({\n kind: artifactKind(a.mimeType),\n path: a.name ?? a.uri ?? a.artifactId,\n content: a.content ?? '',\n })\n } else if (ev.type === 'proposal_created') {\n const p = ev as ProposalEventLike\n proposals.push({\n id: p.proposalId,\n title: p.title,\n status: p.status ?? 'pending',\n ...(p.content !== undefined ? { content: p.content } : {}),\n })\n }\n }\n\n return { artifacts, proposals, toolCalls }\n}\n","import { createHash } from 'node:crypto'\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport { ValidationError } from './errors'\nimport { canonicalize } from './pre-registration'\n\nexport type { AgentProfile } from '@tangle-network/agent-interface'\n\n/**\n * Collision-resistant, path-safe, human-readable profile id for eval artifacts.\n * Scorecard joins still use `agentProfileHash`; this id is for run ids, matrix\n * keys, and directory names where two profiles must not collapse onto one row.\n * The suffix is the first 64 bits of the behaviour hash, enough for ordinary\n * eval matrices while keeping filenames readable.\n */\nexport function agentProfileId(profile: AgentProfile): string {\n const label = pathSafeProfileLabel(agentProfileDisplayLabel(profile)) ?? 'profile'\n return `${label}-${agentProfileHash(profile).slice(0, 16)}`\n}\n\n/**\n * Model snapshot used for `RunRecord.model`. Eval surfaces require a concrete\n * model id because run records reject bare/missing model aliases.\n */\nexport function agentProfileModelId(profile: AgentProfile): string {\n const model = profile.model?.default?.trim()\n if (!model) {\n const label = agentProfileDisplayLabel(profile) ?? 'unnamed profile'\n throw new ValidationError(\n `AgentProfile \"${label}\" has no model.default — cannot record eval run`,\n )\n }\n return model\n}\n\nfunction agentProfileDisplayLabel(profile: AgentProfile): string | undefined {\n return profile.name?.trim() || profile.version?.trim() || undefined\n}\n\nfunction pathSafeProfileLabel(label: string | undefined): string | undefined {\n const safe = label\n ?.trim()\n .replace(/[^A-Za-z0-9._-]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n return safe || undefined\n}\n\nfunction compact<T extends Record<string, unknown>>(input: T): Partial<T> {\n const out: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(input)) {\n if (value !== undefined) out[key] = value\n }\n return out as Partial<T>\n}\n\n/**\n * Deterministic behaviour identity for the canonical\n * `@tangle-network/agent-interface` AgentProfile.\n *\n * `name` and `description` are labels and do not affect the hash. Profile\n * `version`, prompt, model hints, tools, resources, hooks, modes, permissions,\n * and extensions do affect the hash. Resource array order is hash-bearing\n * because mount order can change agent behaviour. Undefined fields are treated\n * as absent; explicit `null` fields remain hash-bearing.\n */\nexport function agentProfileHash(profile: AgentProfile): string {\n const model = agentProfileModelId(profile)\n const behaviour = {\n ...profile,\n name: undefined,\n description: undefined,\n tags: profile.tags ? [...profile.tags].sort() : undefined,\n model: compact({ ...profile.model, default: model }),\n }\n return createHash('sha256')\n .update(JSON.stringify(canonicalize(behaviour)))\n .digest('hex')\n}\n"],"mappings":";;;;;;;;AAmGO,SAAS,kBAAkB,OAGZ;AACpB,MAAI,MAAM,aAAa,WAAW,GAAG;AACnC,UAAM,IAAI;AAAA,MACR,4BAA4B,MAAM,MAAM;AAAA,IAC1C;AAAA,EACF;AACA,QAAM,iBAAiB,MAAM,aAAa,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE;AACrE,QAAM,iBAAiB,iBAAiB,MAAM,aAAa;AAC3D,QAAM,gBAAgB,mBAAmB,MAAM,aAAa;AAC5D,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,cAAc,MAAM;AAAA,IACpB;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AACF;AAYA,IAAM,YAAY,oBAAI,IAAI;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAUD,IAAM,6BAA6B,oBAAI,IAAI;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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+B;AACjE,QAAM,QAAQ,QAAQ,OAAO,SAAS,KAAK;AAC3C,MAAI,CAAC,OAAO;AACV,UAAM,QAAQ,yBAAyB,OAAO,KAAK;AACnD,UAAM,IAAI;AAAA,MACR,iBAAiB,KAAK;AAAA,IACxB;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,yBAAyB,SAA2C;AAC3E,SAAO,QAAQ,MAAM,KAAK,KAAK,QAAQ,SAAS,KAAK,KAAK;AAC5D;AAEA,SAAS,qBAAqB,OAA+C;AAC3E,QAAM,OAAO,OACT,KAAK,EACN,QAAQ,qBAAqB,GAAG,EAChC,QAAQ,OAAO,GAAG,EAClB,QAAQ,UAAU,EAAE;AACvB,SAAO,QAAQ;AACjB;AAEA,SAAS,QAA2C,OAAsB;AACxE,QAAM,MAA+B,CAAC;AACtC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,QAAI,UAAU,OAAW,KAAI,GAAG,IAAI;AAAA,EACtC;AACA,SAAO;AACT;AAYO,SAAS,iBAAiB,SAA+B;AAC9D,QAAM,QAAQ,oBAAoB,OAAO;AACzC,QAAM,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM,QAAQ,OAAO,CAAC,GAAG,QAAQ,IAAI,EAAE,KAAK,IAAI;AAAA,IAChD,OAAO,QAAQ,EAAE,GAAG,QAAQ,OAAO,SAAS,MAAM,CAAC;AAAA,EACrD;AACA,SAAO,WAAW,QAAQ,EACvB,OAAO,KAAK,UAAU,aAAa,SAAS,CAAC,CAAC,EAC9C,OAAO,KAAK;AACjB;","names":[]}
@@ -2,7 +2,7 @@ import {
2
2
  OtlpFileTraceStore,
3
3
  TraceFileMissingError,
4
4
  buildTraceAnalystTools
5
- } from "./chunk-QAY5UIJO.js";
5
+ } from "./chunk-YBIGNSCZ.js";
6
6
 
7
7
  // src/trace-analyst/prompts.ts
8
8
  var TRACE_ANALYST_ACTOR_DESCRIPTION = `You answer questions about an OTLP-shaped JSONL trace dataset using the trace tools provided in the \`traces\` namespace.
@@ -197,4 +197,4 @@ export {
197
197
  TRACE_ANALYST_SUBAGENT_DESCRIPTION,
198
198
  analyzeTraces
199
199
  };
200
- //# sourceMappingURL=chunk-UHMJT4T7.js.map
200
+ //# sourceMappingURL=chunk-IZCEK2HR.js.map