@tangle-network/agent-eval 0.180.0 → 0.182.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 (247) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +119 -159
  3. package/dist/adapters/http.d.ts +2 -2
  4. package/dist/{agent-profile-B7yErX0q.d.ts → agent-profile-CivaSsSy.d.ts} +4 -4
  5. package/dist/{agent-profile-B7yErX0q.d.ts.map → agent-profile-CivaSsSy.d.ts.map} +1 -1
  6. package/dist/{agent-profile-cell-0gSi5ffD.js → agent-profile-cell-Cv6UA-W_.js} +20 -57
  7. package/dist/agent-profile-cell-Cv6UA-W_.js.map +1 -0
  8. package/dist/{agent-profile-cell-CTOZJUuE.d.ts → agent-profile-cell-s__adRnK.d.ts} +3 -3
  9. package/dist/agent-profile-cell-s__adRnK.d.ts.map +1 -0
  10. package/dist/analyst/index.d.ts +11 -11
  11. package/dist/analyst/index.js +4 -4
  12. package/dist/ast-CP9ae9B0.js +557 -0
  13. package/dist/ast-CP9ae9B0.js.map +1 -0
  14. package/dist/ast-hI-vjW6J.d.ts +457 -0
  15. package/dist/ast-hI-vjW6J.d.ts.map +1 -0
  16. package/dist/{benchmark-command-D4vpnAdO.js → benchmark-command-7X7HPNHh.js} +8 -7
  17. package/dist/{benchmark-command-D4vpnAdO.js.map → benchmark-command-7X7HPNHh.js.map} +1 -1
  18. package/dist/benchmarks/index.d.ts +4 -4
  19. package/dist/benchmarks/index.js +3 -3
  20. package/dist/campaign/index.d.ts +6 -6
  21. package/dist/campaign/index.js +8 -8
  22. package/dist/{campaign-BGEurASO.js → campaign-B2U7WcFz.js} +13 -13
  23. package/dist/{campaign-BGEurASO.js.map → campaign-B2U7WcFz.js.map} +1 -1
  24. package/dist/{campaign-evidence-D8DBLqLI.js → campaign-evidence-PYPUftRy.js} +515 -471
  25. package/dist/campaign-evidence-PYPUftRy.js.map +1 -0
  26. package/dist/cli.js +5 -8
  27. package/dist/cli.js.map +1 -1
  28. package/dist/{client-BlLY6o2w.js → client-CXE-U1SA.js} +3 -1
  29. package/dist/client-CXE-U1SA.js.map +1 -0
  30. package/dist/{client-CuQgX33c.d.ts → client-kh2jOjTK.d.ts} +4 -4
  31. package/dist/{client-CuQgX33c.d.ts.map → client-kh2jOjTK.d.ts.map} +1 -1
  32. package/dist/contract/index.d.ts +13 -13
  33. package/dist/contract/index.js +11 -10
  34. package/dist/contract/index.js.map +1 -1
  35. package/dist/{default-registry-IGDE9XIC.d.ts → default-registry-BwDSWVzg.d.ts} +6 -6
  36. package/dist/{default-registry-IGDE9XIC.d.ts.map → default-registry-BwDSWVzg.d.ts.map} +1 -1
  37. package/dist/{default-registry-aL7xUrUz.js → default-registry-DHWwIwa8.js} +2 -2
  38. package/dist/{default-registry-aL7xUrUz.js.map → default-registry-DHWwIwa8.js.map} +1 -1
  39. package/dist/{define-agent-eval-Cx4Ls9ta.d.ts → define-agent-eval-CwOWWQt_.d.ts} +33 -12
  40. package/dist/define-agent-eval-CwOWWQt_.d.ts.map +1 -0
  41. package/dist/{define-agent-eval-Dzidv34q.js → define-agent-eval-DSIPB4hi.js} +136 -69
  42. package/dist/define-agent-eval-DSIPB4hi.js.map +1 -0
  43. package/dist/{dspy-rlm-engine-xKiWmj_G.js → dspy-rlm-engine-S53V0HhE.js} +2 -2
  44. package/dist/{dspy-rlm-engine-xKiWmj_G.js.map → dspy-rlm-engine-S53V0HhE.js.map} +1 -1
  45. package/dist/{engine-CX8ReXkn.d.ts → engine-DS1cysJy.d.ts} +10 -7
  46. package/dist/engine-DS1cysJy.d.ts.map +1 -0
  47. package/dist/{eval-campaign-Cs-7MiCs.js → eval-campaign-CCEkwzoH.js} +4 -4
  48. package/dist/{eval-campaign-Cs-7MiCs.js.map → eval-campaign-CCEkwzoH.js.map} +1 -1
  49. package/dist/{exact-types-B7LC1EyX.d.ts → exact-types-BZDe0W2D.d.ts} +2 -2
  50. package/dist/{exact-types-B7LC1EyX.d.ts.map → exact-types-BZDe0W2D.d.ts.map} +1 -1
  51. package/dist/experiment/index.d.ts +27 -477
  52. package/dist/experiment/index.d.ts.map +1 -1
  53. package/dist/experiment/index.js +97 -561
  54. package/dist/experiment/index.js.map +1 -1
  55. package/dist/{experiment-tracker-B3TiF5-u.d.ts → experiment-tracker-C7PfnF4b.d.ts} +2 -2
  56. package/dist/{experiment-tracker-B3TiF5-u.d.ts.map → experiment-tracker-C7PfnF4b.d.ts.map} +1 -1
  57. package/dist/{external-optimizer-process-Dlz8YxrT.js → external-optimizer-process-QDRURJAM.js} +3 -3
  58. package/dist/{external-optimizer-process-Dlz8YxrT.js.map → external-optimizer-process-QDRURJAM.js.map} +1 -1
  59. package/dist/{external-optimizer-subprocess-q3VzlGAO.js → external-optimizer-subprocess-D4dzUBZI.js} +3 -2
  60. package/dist/{external-optimizer-subprocess-q3VzlGAO.js.map → external-optimizer-subprocess-D4dzUBZI.js.map} +1 -1
  61. package/dist/{feedback-trajectory-eHWNv5Aj.d.ts → feedback-trajectory-CXmtITBo.d.ts} +3 -3
  62. package/dist/{feedback-trajectory-eHWNv5Aj.d.ts.map → feedback-trajectory-CXmtITBo.d.ts.map} +1 -1
  63. package/dist/hosted/index.d.ts +2 -2
  64. package/dist/hosted/index.d.ts.map +1 -1
  65. package/dist/hosted/index.js +1 -1
  66. package/dist/{index-BxWvILU8.d.ts → index-Bp_6sj3x.d.ts} +109 -56
  67. package/dist/index-Bp_6sj3x.d.ts.map +1 -0
  68. package/dist/{index-e7LXeRVa.d.ts → index-CJ3LhKIX.d.ts} +2 -2
  69. package/dist/{index-e7LXeRVa.d.ts.map → index-CJ3LhKIX.d.ts.map} +1 -1
  70. package/dist/{index-CiUjjEIa.d.ts → index-DbG8QbH9.d.ts} +8 -8
  71. package/dist/{index-CiUjjEIa.d.ts.map → index-DbG8QbH9.d.ts.map} +1 -1
  72. package/dist/{index-DxNYmx4a.d.ts → index-DoykkxW0.d.ts} +11 -11
  73. package/dist/{index-DxNYmx4a.d.ts.map → index-DoykkxW0.d.ts.map} +1 -1
  74. package/dist/index.d.ts +28 -28
  75. package/dist/index.js +27 -18
  76. package/dist/index.js.map +1 -1
  77. package/dist/{insight-report-DETqPc_A.d.ts → insight-report-D1qa0HWs.d.ts} +9 -5
  78. package/dist/{insight-report-DETqPc_A.d.ts.map → insight-report-D1qa0HWs.d.ts.map} +1 -1
  79. package/dist/{integrity-DH5ng72x.js → integrity-CgQce0FV.js} +2 -2
  80. package/dist/{integrity-DH5ng72x.js.map → integrity-CgQce0FV.js.map} +1 -1
  81. package/dist/{integrity-BKTcA-HP.d.ts → integrity-rGOfSUle.d.ts} +2 -2
  82. package/dist/{integrity-BKTcA-HP.d.ts.map → integrity-rGOfSUle.d.ts.map} +1 -1
  83. package/dist/{ledger-core-Cs9f7385.js → journal-Cs9f7385.js} +1 -1
  84. package/dist/journal-Cs9f7385.js.map +1 -0
  85. package/dist/{judge-calibration-C5CbMYce.d.ts → judge-calibration-DFtEMlde.d.ts} +31 -2
  86. package/dist/judge-calibration-DFtEMlde.d.ts.map +1 -0
  87. package/dist/{judge-calibration-BnpVKtnb.js → judge-calibration-DYmaBtJr.js} +48 -2
  88. package/dist/{judge-calibration-BnpVKtnb.js.map → judge-calibration-DYmaBtJr.js.map} +1 -1
  89. package/dist/ledger-core/index.d.ts +1 -1
  90. package/dist/ledger-core/index.js +1 -1
  91. package/dist/{llm-judge-v80Kmu9g.js → llm-judge-BPFR12VJ.js} +645 -456
  92. package/dist/llm-judge-BPFR12VJ.js.map +1 -0
  93. package/dist/{matrix-DeMmnWrP.d.ts → matrix-CyhW-vgJ.d.ts} +2 -2
  94. package/dist/{matrix-DeMmnWrP.d.ts.map → matrix-CyhW-vgJ.d.ts.map} +1 -1
  95. package/dist/meta-eval/index.d.ts +138 -7
  96. package/dist/meta-eval/index.d.ts.map +1 -1
  97. package/dist/meta-eval/index.js +245 -97
  98. package/dist/meta-eval/index.js.map +1 -1
  99. package/dist/{mint-Cc1_zwRQ.js → mint-ySIIkKlV.js} +2 -2
  100. package/dist/{mint-Cc1_zwRQ.js.map → mint-ySIIkKlV.js.map} +1 -1
  101. package/dist/multishot/golden/index.d.ts +1 -1
  102. package/dist/multishot/index.d.ts +2 -2
  103. package/dist/openapi.json +1 -1
  104. package/dist/outcome-store-BXlkwMPR.js +131 -0
  105. package/dist/outcome-store-BXlkwMPR.js.map +1 -0
  106. package/dist/{outcome-store-BYHIuO0e.d.ts → outcome-store-CNt4iZ67.d.ts} +18 -25
  107. package/dist/outcome-store-CNt4iZ67.d.ts.map +1 -0
  108. package/dist/{paired-arms-D4aeIHUy.js → paired-arms-JSDcs2zx.js} +16 -3
  109. package/dist/paired-arms-JSDcs2zx.js.map +1 -0
  110. package/dist/{paired-promotion-decision-CGzg0cI_.d.ts → paired-promotion-decision-DPsMQm-0.d.ts} +13 -7
  111. package/dist/{paired-promotion-decision-CGzg0cI_.d.ts.map → paired-promotion-decision-DPsMQm-0.d.ts.map} +1 -1
  112. package/dist/pipelines/index.js +1 -1
  113. package/dist/{power-and-mde-B8F2RdcD.js → power-and-mde-BJOpt6pq.js} +2 -2
  114. package/dist/{power-and-mde-B8F2RdcD.js.map → power-and-mde-BJOpt6pq.js.map} +1 -1
  115. package/dist/{produced-state-Cv0kJJuP.js → produced-state-CkoG43gI.js} +3 -3
  116. package/dist/{produced-state-Cv0kJJuP.js.map → produced-state-CkoG43gI.js.map} +1 -1
  117. package/dist/profile-cell.d.ts +1 -1
  118. package/dist/profile-cell.js +1 -1
  119. package/dist/{promotion-policy-DWOm70gx.js → promotion-policy-BKFrl7CC.js} +28 -40
  120. package/dist/promotion-policy-BKFrl7CC.js.map +1 -0
  121. package/dist/{registry-ByVld1-5.d.ts → registry-BRbB6Y0v.d.ts} +4 -4
  122. package/dist/{registry-ByVld1-5.d.ts.map → registry-BRbB6Y0v.d.ts.map} +1 -1
  123. package/dist/{release-confidence-BAcNYOf1.d.ts → release-confidence-BcqeQTHW.d.ts} +3 -3
  124. package/dist/{release-confidence-BAcNYOf1.d.ts.map → release-confidence-BcqeQTHW.d.ts.map} +1 -1
  125. package/dist/{release-confidence-BcGCclTB.js → release-confidence-DMg8n18l.js} +2 -2
  126. package/dist/{release-confidence-BcGCclTB.js.map → release-confidence-DMg8n18l.js.map} +1 -1
  127. package/dist/{report-command-V1ecVgAv.js → report-command-BvqaxlVG.js} +32 -201
  128. package/dist/report-command-BvqaxlVG.js.map +1 -0
  129. package/dist/reporting.d.ts +4 -4
  130. package/dist/reporting.js +5 -5
  131. package/dist/{researcher-jsW1X94L.d.ts → researcher-64T49THL.d.ts} +6 -6
  132. package/dist/{researcher-jsW1X94L.d.ts.map → researcher-64T49THL.d.ts.map} +1 -1
  133. package/dist/{reward-hacking-ZXEi9VCq.d.ts → reward-hacking-uzO_ihep.d.ts} +2 -2
  134. package/dist/{reward-hacking-ZXEi9VCq.d.ts.map → reward-hacking-uzO_ihep.d.ts.map} +1 -1
  135. package/dist/rl.d.ts +53 -99
  136. package/dist/rl.d.ts.map +1 -1
  137. package/dist/rl.js +183 -170
  138. package/dist/rl.js.map +1 -1
  139. package/dist/rollout/index.d.ts +1 -1
  140. package/dist/rollout/index.js +2 -3
  141. package/dist/{rollout-DmoJVqrF.js → rollout-BsN6pOU7.js} +154 -13
  142. package/dist/rollout-BsN6pOU7.js.map +1 -0
  143. package/dist/rubric-predictive-validity-Bmj2_cll.d.ts +79 -0
  144. package/dist/rubric-predictive-validity-Bmj2_cll.d.ts.map +1 -0
  145. package/dist/rubric-predictive-validity-CCK-1B7w.js +178 -0
  146. package/dist/rubric-predictive-validity-CCK-1B7w.js.map +1 -0
  147. package/dist/{run-record-DTv1MdjK.d.ts → run-record-BiTWauyO.d.ts} +2 -2
  148. package/dist/{run-record-DTv1MdjK.d.ts.map → run-record-BiTWauyO.d.ts.map} +1 -1
  149. package/dist/run-record-DPa2PeHx.js +464 -0
  150. package/dist/run-record-DPa2PeHx.js.map +1 -0
  151. package/dist/{run-record-DQpSf7t-.js → run-record-DualPTn2.js} +2 -2
  152. package/dist/{run-record-DQpSf7t-.js.map → run-record-DualPTn2.js.map} +1 -1
  153. package/dist/{semantic-concept-judge-Bi6_iGqg.js → semantic-concept-judge-Bm5JDEKO.js} +3 -3
  154. package/dist/{semantic-concept-judge-Bi6_iGqg.js.map → semantic-concept-judge-Bm5JDEKO.js.map} +1 -1
  155. package/dist/{sequential-B5gXgcyp.js → sequential-D_xHrBZe.js} +42 -25
  156. package/dist/sequential-D_xHrBZe.js.map +1 -0
  157. package/dist/{series-convergence-DeG33RpC.d.ts → series-convergence-BnMs_uAr.d.ts} +3 -3
  158. package/dist/{series-convergence-DeG33RpC.d.ts.map → series-convergence-BnMs_uAr.d.ts.map} +1 -1
  159. package/dist/{skillopt-optimization-method-C3oYul8v.js → skillopt-optimization-method-B2IEaCeF.js} +5 -5
  160. package/dist/{skillopt-optimization-method-C3oYul8v.js.map → skillopt-optimization-method-B2IEaCeF.js.map} +1 -1
  161. package/dist/{statistical-heldout-0La5ZTlv.d.ts → statistical-heldout-CpVd6FmY.d.ts} +207 -144
  162. package/dist/statistical-heldout-CpVd6FmY.d.ts.map +1 -0
  163. package/dist/{store-tool-spans-4J1EDElP.d.ts → store-tool-spans-Dt-YdAuE.d.ts} +6 -6
  164. package/dist/{store-tool-spans-4J1EDElP.d.ts.map → store-tool-spans-Dt-YdAuE.d.ts.map} +1 -1
  165. package/dist/{summary-report-gMrbYawB.d.ts → summary-report-D1h4dlrK.d.ts} +3 -3
  166. package/dist/{summary-report-gMrbYawB.d.ts.map → summary-report-D1h4dlrK.d.ts.map} +1 -1
  167. package/dist/{summary-report-B16xy9Kd.js → summary-report-IGAOtgPd.js} +4 -4
  168. package/dist/{summary-report-B16xy9Kd.js.map → summary-report-IGAOtgPd.js.map} +1 -1
  169. package/dist/supervisor-run/index.d.ts +20 -44
  170. package/dist/supervisor-run/index.d.ts.map +1 -1
  171. package/dist/supervisor-run/index.js +8 -8
  172. package/dist/supervisor-run/index.js.map +1 -1
  173. package/dist/{terminal-record-BtPwKTSr.js → terminal-record-BHocwFw1.js} +5 -22
  174. package/dist/terminal-record-BHocwFw1.js.map +1 -0
  175. package/dist/{tool-groups-2QA0S7dK.d.ts → tool-groups-B2bSNaJB.d.ts} +3 -3
  176. package/dist/tool-groups-B2bSNaJB.d.ts.map +1 -0
  177. package/dist/{tool-waste-B9tdWV6g.js → tool-waste-C7MU9u1e.js} +2 -2
  178. package/dist/{tool-waste-B9tdWV6g.js.map → tool-waste-C7MU9u1e.js.map} +1 -1
  179. package/dist/trace-repair/index.d.ts +2 -2
  180. package/dist/traces.d.ts +6 -6
  181. package/dist/traces.js +1 -1
  182. package/dist/{types-lPkDQNqJ.d.ts → types-BlIJ5URG.d.ts} +17 -26
  183. package/dist/types-BlIJ5URG.d.ts.map +1 -0
  184. package/dist/{types-BmlkCrg0.d.ts → types-BvZoPTGa.d.ts} +3 -3
  185. package/dist/{types-BmlkCrg0.d.ts.map → types-BvZoPTGa.d.ts.map} +1 -1
  186. package/dist/{types-gvRsyJLh.d.ts → types-CBbLtr2J.d.ts} +38 -3
  187. package/dist/{types-gvRsyJLh.d.ts.map → types-CBbLtr2J.d.ts.map} +1 -1
  188. package/dist/{types-C34V4Vto.d.ts → types-CS0qk_Yp.d.ts} +4 -4
  189. package/dist/{types-C34V4Vto.d.ts.map → types-CS0qk_Yp.d.ts.map} +1 -1
  190. package/dist/{types-DzuaM493.d.ts → types-D7gEdPoQ.d.ts} +3 -3
  191. package/dist/{types-DzuaM493.d.ts.map → types-D7gEdPoQ.d.ts.map} +1 -1
  192. package/dist/wire/index.d.ts +2 -2
  193. package/docs/adapters-observability.md +14 -0
  194. package/docs/campaign-proposers.md +86 -128
  195. package/docs/charter.md +108 -112
  196. package/docs/concepts.md +157 -69
  197. package/docs/design/mlbenchmarks-book-review.md +440 -0
  198. package/docs/design/mlbenchmarks-review/observations.json +713 -0
  199. package/docs/design/mlbenchmarks-review/probes.mts +476 -0
  200. package/docs/design/mlbenchmarks-review/sources.json +200 -0
  201. package/docs/design/self-improvement-evidence-audit.md +263 -0
  202. package/docs/design.md +2 -1
  203. package/docs/eval-surface-map.md +95 -42
  204. package/docs/evaluation-integrity.md +220 -0
  205. package/docs/experiment.md +111 -55
  206. package/docs/feature-guide.md +5 -6
  207. package/docs/hosted-ingest-spec.md +4 -11
  208. package/docs/insight-report.md +187 -455
  209. package/docs/outcome-validity.md +182 -0
  210. package/docs/product-eval-adoption.md +1 -2
  211. package/docs/public-api.md +5 -8
  212. package/docs/research-report-methodology.md +7 -7
  213. package/docs/search-history-receipts.md +8 -0
  214. package/docs/statistical-evidence.md +129 -0
  215. package/docs/verdicts.md +76 -49
  216. package/package.json +1 -1
  217. package/dist/agent-profile-cell-0gSi5ffD.js.map +0 -1
  218. package/dist/agent-profile-cell-CTOZJUuE.d.ts.map +0 -1
  219. package/dist/campaign-evidence-D8DBLqLI.js.map +0 -1
  220. package/dist/client-BlLY6o2w.js.map +0 -1
  221. package/dist/define-agent-eval-Cx4Ls9ta.d.ts.map +0 -1
  222. package/dist/define-agent-eval-Dzidv34q.js.map +0 -1
  223. package/dist/engine-CX8ReXkn.d.ts.map +0 -1
  224. package/dist/index-BxWvILU8.d.ts.map +0 -1
  225. package/dist/judge-calibration-C5CbMYce.d.ts.map +0 -1
  226. package/dist/ledger-core-Cs9f7385.js.map +0 -1
  227. package/dist/llm-judge-v80Kmu9g.js.map +0 -1
  228. package/dist/opencode-sqlite-CNw3vubS.js +0 -145
  229. package/dist/opencode-sqlite-CNw3vubS.js.map +0 -1
  230. package/dist/outcome-store-BYHIuO0e.d.ts.map +0 -1
  231. package/dist/outcome-store-ChBKlTd_.js +0 -75
  232. package/dist/outcome-store-ChBKlTd_.js.map +0 -1
  233. package/dist/paired-arms-D4aeIHUy.js.map +0 -1
  234. package/dist/promotion-policy-DWOm70gx.js.map +0 -1
  235. package/dist/report-command-V1ecVgAv.js.map +0 -1
  236. package/dist/rollout-DmoJVqrF.js.map +0 -1
  237. package/dist/rubric-predictive-validity-2D5Gw9z9.js +0 -131
  238. package/dist/rubric-predictive-validity-2D5Gw9z9.js.map +0 -1
  239. package/dist/rubric-predictive-validity-Dl1dvKCv.d.ts +0 -75
  240. package/dist/rubric-predictive-validity-Dl1dvKCv.d.ts.map +0 -1
  241. package/dist/run-record-CR63CpHK.js +0 -216
  242. package/dist/run-record-CR63CpHK.js.map +0 -1
  243. package/dist/sequential-B5gXgcyp.js.map +0 -1
  244. package/dist/statistical-heldout-0La5ZTlv.d.ts.map +0 -1
  245. package/dist/terminal-record-BtPwKTSr.js.map +0 -1
  246. package/dist/tool-groups-2QA0S7dK.d.ts.map +0 -1
  247. package/dist/types-lPkDQNqJ.d.ts.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { y as RolloutSplit } from "../schema-BzWDXhOR.js";
2
- import { A as WallDistribution, C as SupervisorRunSources, D as SupervisorStatusSource, E as SupervisorRunTreeGapCode, M as isUnavailable, N as showMeasured, O as TerminalFailure, P as unavailable, S as SupervisorRunRollup, T as SupervisorRunTreeGap, _ as SpendMeasurements, a as NamedResourceReceipt, b as SupervisorRunReader, c as PatchStats, d as RoleSpend, f as RollupCellRow, g as SpendMeasurement, h as SourceLimits, i as NO_SOURCE_LIMITS, j as WorkerLogSource, k as Unavailable, l as PerWorkerRow, m as SUPERVISOR_RUN_SCHEMA, n as EconomicsMetrics, o as OrchestrationMetrics, p as SUPERVISOR_RUN_ROLLUP_SCHEMA, r as Measured, s as OutcomeMetrics, t as DecisionMetrics, u as ResourceSpendRecord, v as SteerBreakdown, w as SupervisorRunTree, x as SupervisorRunReport, y as SupervisorRunNodeRole } from "../types-lPkDQNqJ.js";
2
+ import { A as WallDistribution, C as SupervisorRunSources, D as SupervisorStatusSource, E as SupervisorRunTreeGapCode, M as isUnavailable, N as showMeasured, O as TerminalFailure, P as unavailable, S as SupervisorRunRollup, T as SupervisorRunTreeGap, _ as SpendMeasurements, a as NamedResourceReceipt, b as SupervisorRunReader, c as PatchStats, d as RoleSpend, f as RollupCellRow, g as SpendMeasurement, h as SourceLimits, i as NO_SOURCE_LIMITS, j as WorkerLogSource, k as Unavailable, l as PerWorkerRow, m as SUPERVISOR_RUN_SCHEMA, n as EconomicsMetrics, o as OrchestrationMetrics, p as SUPERVISOR_RUN_ROLLUP_SCHEMA, r as Measured, s as OutcomeMetrics, t as DecisionMetrics, u as ResourceSpendRecord, v as SteerBreakdown, w as SupervisorRunTree, x as SupervisorRunReport, y as SupervisorRunNodeRole } from "../types-BlIJ5URG.js";
3
3
  //#region src/supervisor-run/source-facts.d.ts
4
4
  interface Tokens {
5
5
  input: number;
@@ -53,7 +53,7 @@ interface CloseRow {
53
53
  id: string;
54
54
  kind: 'settled' | 'cancelled';
55
55
  status: string | null;
56
- /** String verdict from legacy journals, or valid/invalid for a structured verdict. */
56
+ /** String verdict from flat journals, or valid/invalid for a structured verdict. */
57
57
  verdict: string | null;
58
58
  /** Structured verdict validity, when recorded. */
59
59
  valid: boolean | null;
@@ -195,8 +195,8 @@ interface SupervisorTreeFacts {
195
195
  /**
196
196
  * How a journal's rows were shaped on disk.
197
197
  *
198
- * `flat` — one event object per line (`{kind:'spawned', id, ...}`). The loops
199
- * supervisor writes this, and `readClaudeCodeSupervisorRun` synthesizes it.
198
+ * `flat` — one event object per line (`{kind:'spawned', id, ...}`). Claude Code
199
+ * and other adapters may synthesize this shape for the pure analyzer.
200
200
  *
201
201
  * `runtime-envelope` — the records `agent-runtime`'s `FileSpawnJournal` writes:
202
202
  * a `{kind:'begin', root, at}` header followed by `{kind:'event', root, event}`
@@ -247,7 +247,7 @@ interface ClaudeCodeReaderOptions {
247
247
  * source bytes. Never throws on a missing artifact.
248
248
  */
249
249
  declare function readClaudeCodeSupervisorRun(opts: ClaudeCodeReaderOptions): Promise<SupervisorRunSources>;
250
- /** A `SupervisorRunReader` over a Claude Code session — the same contract loops implements. */
250
+ /** A `SupervisorRunReader` over a Claude Code session — the same contract Runtime implements. */
251
251
  declare function claudeCodeSupervisorRunReader(opts: ClaudeCodeReaderOptions): SupervisorRunReader;
252
252
  //#endregion
253
253
  //#region src/supervisor-run/integrity-types.d.ts
@@ -289,37 +289,14 @@ interface SupervisorRunIntegrityOptions {
289
289
  */
290
290
  declare function analyzeSupervisorRunIntegrity(input: SupervisorRunSources | SupervisorRunTree, options?: SupervisorRunIntegrityOptions): SupervisorRunIntegrityReport;
291
291
  //#endregion
292
- //#region src/supervisor-run/loops-reader.d.ts
292
+ //#region src/supervisor-run/reader.d.ts
293
293
  /**
294
- * Locate the (single) supervisor run dir under `<ws>/.agent/supervisor`, falling back to the
295
- * pre-rename `<ws>/.loops/supervisor` so runs written by older supervisors stay analyzable.
296
- */
297
- declare function findSupervisorRunDirIn(ws: string): Promise<string | null>;
298
- interface LoopsReaderOptions {
299
- /** Override the workspace dir (default `<runDir>/ws`). */
300
- readonly ws?: string;
301
- /** Delivered patch path (default: `patchPath` from result.json). */
302
- readonly patchPath?: string;
303
- /** opencode sqlite store; set to `null` to skip the worker-token join entirely. */
304
- readonly opencodeDb?: string | null;
305
- /** Ledger to fall back to when the run has no `judge.json` (matched on iid + arm + runDir). */
306
- readonly ledgerPath?: string;
307
- }
308
- /**
309
- * Read a loops supervisor run directory into source bytes. Never throws on a
310
- * missing artifact — an absent file becomes a `null` field, which is what makes
311
- * the dependent metric `unavailable` instead of 0.
312
- */
313
- declare function readLoopsSupervisorRun(runDir: string, opts?: LoopsReaderOptions): Promise<SupervisorRunSources>;
314
- /** The loops on-disk layout, as a `SupervisorRunReader`. */
315
- declare function loopsSupervisorRunReader(runDir: string, opts?: LoopsReaderOptions): SupervisorRunReader;
316
- /**
317
- * Analyze a supervisor run. Accepts a run directory (read through the loops
318
- * reader), any `SupervisorRunReader`, or already-read source bytes — so a
294
+ * Analyze a supervisor run. Accepts a Runtime run directory, any
295
+ * `SupervisorRunReader`, or already-read source bytes — so a
319
296
  * caller with its own store never has to touch the filesystem layout.
320
297
  */
321
- declare function analyzeSupervisorRun(input: string | SupervisorRunReader | SupervisorRunSources, opts?: LoopsReaderOptions): Promise<SupervisorRunReport>;
322
- interface WriteSupervisorRunOptions extends LoopsReaderOptions {
298
+ declare function analyzeSupervisorRun(input: string | SupervisorRunReader | SupervisorRunSources): Promise<SupervisorRunReport>;
299
+ interface WriteSupervisorRunOptions {
323
300
  /** Append the headline block here (the experiment's run log). */
324
301
  readonly appendHeadlineTo?: string;
325
302
  /** Also console.log the headline (default true). */
@@ -352,7 +329,7 @@ declare function reportSupervisorRound(outDir: string, opts?: WriteSupervisorRun
352
329
  title?: string;
353
330
  }): Promise<SupervisorRunRollup>;
354
331
  /**
355
- * Every loops or Runtime supervisor run below `root`.
332
+ * Every Runtime supervisor run below `root`.
356
333
  *
357
334
  * When `root` itself is one run, return no children so callers can distinguish
358
335
  * a single report from a parent-directory rollup.
@@ -372,7 +349,7 @@ declare function renderSupervisorRollupMarkdown(rollup: SupervisorRunRollup, tit
372
349
  /**
373
350
  * `agent-eval supervisor-run report <runDir>` takes one run directory and
374
351
  * prints the report the module already renders. The command reads through
375
- * `analyzeSupervisorRun`, so a Runtime run dir and a loops run dir take the
352
+ * `analyzeSupervisorRun`, so a Runtime run directory takes the
376
353
  * same path and the status comes from the record `terminal-record.ts` names.
377
354
  *
378
355
  * Exit codes follow the other self-parsing subcommands: 2 for a usage error,
@@ -438,7 +415,7 @@ interface RuntimeReaderOptions {
438
415
  * Read one agent-runtime `createFileRunContext(dir)` directory.
439
416
  *
440
417
  * A run dir without `spawn-journal.jsonl` returns the same absent-shaped
441
- * sources `readLoopsSupervisorRun` returns for a missing store: `journal` and
418
+ * sources the reader returns for a missing store: `journal` and
442
419
  * `workers` null, each with its reason, so every dependent metric reads
443
420
  * `unavailable` — never 0 and never a throw. Its `result.json` and
444
421
  * `failure.json` are still read, so a run that died before its first spawn
@@ -463,13 +440,13 @@ declare function isRuntimeSupervisorRunDir(runDir: string): Promise<boolean>;
463
440
  //#endregion
464
441
  //#region src/supervisor-run/terminal-record.d.ts
465
442
  /** The reason every terminal field reads `unavailable` when no store wrote one. */
466
- declare const NO_TERMINAL_RECORD = "no terminal record: Runtime result.json kind, Runtime failure.json, or legacy state.json / result.json status";
443
+ declare const NO_TERMINAL_RECORD = "no terminal record: Runtime result.json kind or Runtime failure.json";
467
444
  /** The status reported for a run whose directory holds Runtime's failure record and no result. */
468
445
  declare const RUNTIME_FAILED_STATUS = "failed";
469
446
  interface TerminalRecordInput {
470
- /** Legacy loops `state.json`, parsed; null when absent. */
447
+ /** Runtime state document, parsed; null when absent. */
471
448
  readonly state: Record<string, unknown> | null;
472
- /** `result.json`, parsed; Runtime's `SupervisedResult` or the legacy loops result. */
449
+ /** Runtime `result.json`, parsed; null when absent. */
473
450
  readonly result: Record<string, unknown> | null;
474
451
  /**
475
452
  * Runtime's `failure.json`, parsed. `null` when the store was read and holds
@@ -482,19 +459,18 @@ interface TerminalRecord {
482
459
  readonly supStatusSource: Measured<SupervisorStatusSource>;
483
460
  /**
484
461
  * Runtime's `reason` on a `no-winner` result. `null` when the record carries
485
- * none (a winner, a failure record, or a legacy document).
462
+ * none (a winner or a failure record).
486
463
  */
487
464
  readonly supReason: Measured<string | null>;
488
465
  /** The recorded error. `null` when the run recorded a result and no error. */
489
466
  readonly failure: Measured<TerminalFailure | null>;
490
467
  /**
491
- * True when the run recorded a delivered result (Runtime `winner`, legacy
492
- * `completed`); false on every other recorded terminal state; null when no
493
- * terminal record exists.
468
+ * True when the run recorded a delivered Runtime `winner`; false on every
469
+ * other recorded terminal state; null when no terminal record exists.
494
470
  */
495
471
  readonly completed: boolean | null;
496
472
  }
497
473
  declare function readTerminalRecord(input: TerminalRecordInput): TerminalRecord;
498
474
  //#endregion
499
- export { type ClaudeCodeReaderOptions, type CloseRow, type DecisionMetrics, type EconomicsMetrics, type LoopsReaderOptions, type Measured, NO_SOURCE_LIMITS, NO_TERMINAL_RECORD, type NamedResourceReceipt, type OrchestrationMetrics, type OutcomeMetrics, type PatchStats, type PerWorkerRow, RUNTIME_FAILED_STATUS, type ResourceSpendRecord, type RoleSpend, type RollupCellRow, type RuntimeReaderOptions, SUPERVISOR_RUN_INTEGRITY_SCHEMA, SUPERVISOR_RUN_ROLLUP_SCHEMA, SUPERVISOR_RUN_SCHEMA, type SourceLimits, type SpawnRow, type SpendMeasurement, type SpendMeasurements, type SteerAcknowledgementFact, type SteerBreakdown, type SteerRequestFact, type SupervisorJournalDialect, type SupervisorRolloutOptions, type SupervisorRunCommandIo, type SupervisorRunIntegrityEvidence, type SupervisorRunIntegrityIssue, type SupervisorRunIntegrityIssueCode, type SupervisorRunIntegrityOptions, type SupervisorRunIntegrityReport, type SupervisorRunIntegritySeverity, type SupervisorRunNodeRole, type SupervisorRunReader, type SupervisorRunReport, type SupervisorRunReportFormat, type SupervisorRunRollup, type SupervisorRunSourceOnlyCheckCode, type SupervisorRunSources, type SupervisorRunTree, type SupervisorRunTreeGap, type SupervisorRunTreeGapCode, type SupervisorStatusSource, type SupervisorTreeFacts, type TerminalFailure, type TerminalRecord, type TerminalRecordInput, type Unavailable, type WallDistribution, type WorkerLogFacts, type WorkerLogSource, type WriteSupervisorRunOptions, analyzeSupervisorRun, analyzeSupervisorRunIntegrity, analyzeSupervisorRunSources, claudeCodeSupervisorRunReader, findSupervisorRunDirIn, findSupervisorRunDirs, isRuntimeSupervisorRunDir, isUnavailable, loopsSupervisorRunReader, parsePatch, parseSupervisorTree, readClaudeCodeSupervisorRun, readLoopsSupervisorRun, readRuntimeSupervisorRun, readTerminalRecord, renderSupervisorRollupMarkdown, renderSupervisorRunHeadline, renderSupervisorRunMarkdown, reportSupervisorRound, rollupSupervisorRuns, runSupervisorRunCommand, runtimeSupervisorRunReader, showMeasured, supervisorRunRolloutLines, unavailable, writeSupervisorRunReport, writeSupervisorRunReportSafe };
475
+ export { type ClaudeCodeReaderOptions, type CloseRow, type DecisionMetrics, type EconomicsMetrics, type Measured, NO_SOURCE_LIMITS, NO_TERMINAL_RECORD, type NamedResourceReceipt, type OrchestrationMetrics, type OutcomeMetrics, type PatchStats, type PerWorkerRow, RUNTIME_FAILED_STATUS, type ResourceSpendRecord, type RoleSpend, type RollupCellRow, type RuntimeReaderOptions, SUPERVISOR_RUN_INTEGRITY_SCHEMA, SUPERVISOR_RUN_ROLLUP_SCHEMA, SUPERVISOR_RUN_SCHEMA, type SourceLimits, type SpawnRow, type SpendMeasurement, type SpendMeasurements, type SteerAcknowledgementFact, type SteerBreakdown, type SteerRequestFact, type SupervisorJournalDialect, type SupervisorRolloutOptions, type SupervisorRunCommandIo, type SupervisorRunIntegrityEvidence, type SupervisorRunIntegrityIssue, type SupervisorRunIntegrityIssueCode, type SupervisorRunIntegrityOptions, type SupervisorRunIntegrityReport, type SupervisorRunIntegritySeverity, type SupervisorRunNodeRole, type SupervisorRunReader, type SupervisorRunReport, type SupervisorRunReportFormat, type SupervisorRunRollup, type SupervisorRunSourceOnlyCheckCode, type SupervisorRunSources, type SupervisorRunTree, type SupervisorRunTreeGap, type SupervisorRunTreeGapCode, type SupervisorStatusSource, type SupervisorTreeFacts, type TerminalFailure, type TerminalRecord, type TerminalRecordInput, type Unavailable, type WallDistribution, type WorkerLogFacts, type WorkerLogSource, type WriteSupervisorRunOptions, analyzeSupervisorRun, analyzeSupervisorRunIntegrity, analyzeSupervisorRunSources, claudeCodeSupervisorRunReader, findSupervisorRunDirs, isRuntimeSupervisorRunDir, isUnavailable, parsePatch, parseSupervisorTree, readClaudeCodeSupervisorRun, readRuntimeSupervisorRun, readTerminalRecord, renderSupervisorRollupMarkdown, renderSupervisorRunHeadline, renderSupervisorRunMarkdown, reportSupervisorRound, rollupSupervisorRuns, runSupervisorRunCommand, runtimeSupervisorRunReader, showMeasured, supervisorRunRolloutLines, unavailable, writeSupervisorRunReport, writeSupervisorRunReportSafe };
500
476
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/supervisor-run/source-facts.ts","../../src/supervisor-run/analyze.ts","../../src/supervisor-run/claude-code-reader.ts","../../src/supervisor-run/integrity-types.ts","../../src/supervisor-run/integrity.ts","../../src/supervisor-run/loops-reader.ts","../../src/supervisor-run/render.ts","../../src/supervisor-run/report-command.ts","../../src/supervisor-run/rollout-nodes.ts","../../src/supervisor-run/runtime-reader.ts","../../src/supervisor-run/terminal-record.ts"],"mappings":";;;UA+BU;EACR;EACA;EACA;EACA;;EAEA;;;;;;EAMA;;UAGe;WACN,YAAY,kBAAkB;EACvC,QAAQ;;;;;;EAMR;EACA;;;;;;EAMA;;UA6Ge;;EAEf;EACA;EACA;EACA;;EAEA,MAAM;;EAEN;;EAEA;EACA;;EAEA;EACA;;UAGe;EACf;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;EACA,OAAO;;EAEP;;UAGe;;EAEf;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;;EAEA;;EAEA;EACA;;EAEA;;EAEA;EACA;EACA;EACA;EACA,eAAe;EACf,uBAAuB;;UAGR;;EAEf;EACA;;UAGe;;EAEf;;EAEA;EACA;;;;;;UAOe;WACN,2BAA2B;WAC3B;WACA,iBAAiB;WACjB,iBAAiB;WACjB,uBAAuB;WACvB,uBAAuB;WACvB;;;;;;;IAOP;IACA;IACA;IACA;;IAEA;;IAEA;;IAEA;IACA;;IAEA;;IAEA;IACA;;IAEA;;WAEO,YAAY,oBAAoB;;WAEhC,wBAAwB;;WAExB;;;;;;;;;WASA;;WAEA;;;;;;WAMA,0BAA0B,SAAS;;;;;;;WAOnC;;WAEA,gBAAgB;;WAEhB,OAAO;WACP;WACA;;;;;;WAMA;WACA;;;;;;;;;;;;;;;;;;KAmDC;iBAiFI,oBAAoB,KAAK,uBAAuB;;;;;;;iBChZhD,4BACd,KAAK,sBACL,qBACC;;iBAi3Ba,WAAW,eAAe;;;;;;iBA+C1B,qBAAqB,kBAAkB,wBAAwB;;;UCl5B9D;;WAEN;;;;;WAKA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;iBAmOW,4BACpB,MA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AEI;;WAEN,OAAO;;WAEP,QAAQ;;;;;WAKR,SAAS;;UAGH;WACN,WAAW;WACX,iBAAiB,SAAS;;;;;WAK1B,WAAW;;WAEX,SAAS,SAAS;;;;;;WAMlB;;iBAuBK,mBAAmB,OAAO,sBAAsB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/supervisor-run/source-facts.ts","../../src/supervisor-run/analyze.ts","../../src/supervisor-run/claude-code-reader.ts","../../src/supervisor-run/integrity-types.ts","../../src/supervisor-run/integrity.ts","../../src/supervisor-run/reader.ts","../../src/supervisor-run/render.ts","../../src/supervisor-run/report-command.ts","../../src/supervisor-run/rollout-nodes.ts","../../src/supervisor-run/runtime-reader.ts","../../src/supervisor-run/terminal-record.ts"],"mappings":";;;UA+BU;EACR;EACA;EACA;EACA;;EAEA;;;;;;EAMA;;UAGe;WACN,YAAY,kBAAkB;EACvC,QAAQ;;;;;;EAMR;EACA;;;;;;EAMA;;UA6Ge;;EAEf;EACA;EACA;EACA;;EAEA,MAAM;;EAEN;;EAEA;EACA;;EAEA;EACA;;UAGe;EACf;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;EACA,OAAO;;EAEP;;UAGe;;EAEf;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;;EAEA;;EAEA;EACA;;EAEA;;EAEA;EACA;EACA;EACA;EACA,eAAe;EACf,uBAAuB;;UAGR;;EAEf;EACA;;UAGe;;EAEf;;EAEA;EACA;;;;;;UAOe;WACN,2BAA2B;WAC3B;WACA,iBAAiB;WACjB,iBAAiB;WACjB,uBAAuB;WACvB,uBAAuB;WACvB;;;;;;;IAOP;IACA;IACA;IACA;;IAEA;;IAEA;;IAEA;IACA;;IAEA;;IAEA;IACA;;IAEA;;WAEO,YAAY,oBAAoB;;WAEhC,wBAAwB;;WAExB;;;;;;;;;WASA;;WAEA;;;;;;WAMA,0BAA0B,SAAS;;;;;;;WAOnC;;WAEA,gBAA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AyEW,yBACpB,gBACA,OAAM,uBACL,QAAQ;;iBAmEK,2BACd,gBACA,OAAM,uBACL;;;;;;iBASmB,0BAA0B,iBAAiB;;;;cCpnBpD;;cAIA;UAEI;;WAEN,OAAO;;WAEP,QAAQ;;;;;WAKR,SAAS;;UAGH;WACN,WAAW;WACX,iBAAiB,SAAS;;;;;WAK1B,WAAW;;WAEX,SAAS,SAAS;;;;;WAKlB;;iBAuBK,mBAAmB,OAAO,sBAAsB"}
@@ -1,14 +1,14 @@
1
1
  import { i as parseClaudeEntries, o as transcriptFromEntries } from "../claude-jsonl-CxZZrDJ3.js";
2
- import { n as supervisorRunRolloutLines, r as SUPERVISOR_RUN_INTEGRITY_SCHEMA, t as analyzeSupervisorRunIntegrity } from "../integrity-DH5ng72x.js";
3
- import { d as SUPERVISOR_RUN_SCHEMA, f as isUnavailable, l as NO_SOURCE_LIMITS, m as unavailable, n as RUNTIME_FAILED_STATUS, p as showMeasured, r as readTerminalRecord, s as parseSupervisorTree, t as NO_TERMINAL_RECORD, u as SUPERVISOR_RUN_ROLLUP_SCHEMA } from "../terminal-record-BtPwKTSr.js";
4
- import { _ as parsePatch, a as loopsSupervisorRunReader, c as writeSupervisorRunReport, d as readRuntimeSupervisorRun, f as runtimeSupervisorRunReader, g as analyzeSupervisorRunSources, h as renderSupervisorRunMarkdown, i as findSupervisorRunDirs, l as writeSupervisorRunReportSafe, m as renderSupervisorRunHeadline, n as analyzeSupervisorRun, o as readLoopsSupervisorRun, p as renderSupervisorRollupMarkdown, r as findSupervisorRunDirIn, s as reportSupervisorRound, t as runSupervisorRunCommand, u as isRuntimeSupervisorRunDir, v as rollupSupervisorRuns } from "../report-command-V1ecVgAv.js";
2
+ import { n as supervisorRunRolloutLines, r as SUPERVISOR_RUN_INTEGRITY_SCHEMA, t as analyzeSupervisorRunIntegrity } from "../integrity-CgQce0FV.js";
3
+ import { d as SUPERVISOR_RUN_SCHEMA, f as isUnavailable, l as NO_SOURCE_LIMITS, m as unavailable, n as RUNTIME_FAILED_STATUS, p as showMeasured, r as readTerminalRecord, s as parseSupervisorTree, t as NO_TERMINAL_RECORD, u as SUPERVISOR_RUN_ROLLUP_SCHEMA } from "../terminal-record-BHocwFw1.js";
4
+ import { a as writeSupervisorRunReport, c as readRuntimeSupervisorRun, d as renderSupervisorRunHeadline, f as renderSupervisorRunMarkdown, h as rollupSupervisorRuns, i as reportSupervisorRound, l as runtimeSupervisorRunReader, m as parsePatch, n as analyzeSupervisorRun, o as writeSupervisorRunReportSafe, p as analyzeSupervisorRunSources, r as findSupervisorRunDirs, s as isRuntimeSupervisorRunDir, t as runSupervisorRunCommand, u as renderSupervisorRollupMarkdown } from "../report-command-BvqaxlVG.js";
5
5
  import { basename, dirname, join } from "node:path";
6
6
  import { readFile, readdir } from "node:fs/promises";
7
7
  //#region src/supervisor-run/claude-code-reader.ts
8
8
  /**
9
9
  * Supervision-tree reader over a THIRD-PARTY harness: Claude Code.
10
10
  *
11
- * `loops-reader.ts` reads a supervisor we wrote, whose journal was designed
11
+ * The Runtime reader reads a supervisor journal designed for this analysis.
12
12
  * for this analysis. This reader reads a harness we do not control, whose
13
13
  * transcript was designed for replaying a chat — and recovers the same tree
14
14
  * from it. If both produce a `SupervisorRunSources`, the tree model is a
@@ -38,12 +38,12 @@ import { readFile, readdir } from "node:fs/promises";
38
38
  * reports `unavailable — <reason>` instead of the $0 / 0-accepted that summing
39
39
  * an empty field would produce. See `SourceLimits`.
40
40
  *
41
- * ## Metric coverage vs the loops journal
41
+ * ## Metric coverage vs the Runtime journal
42
42
  *
43
43
  * Measured on a real 52-agent session (fixture:
44
44
  * `tests/fixtures/supervisor-run/claude-code-session-*`).
45
45
  *
46
- * | Metric | loops | Claude Code | Why |
46
+ * | Metric | Runtime | Claude Code | Why |
47
47
  * |---|---|---|---|
48
48
  * | workersSpawned / Settled / Cancelled | full | full | spawn tool_use + task-notification + TaskStop |
49
49
  * | steers / steersDelivered / steersByWorker | full | full | `SendMessage`; delivery from its tool_result |
@@ -474,7 +474,7 @@ async function readClaudeCodeSupervisorRun(opts) {
474
474
  traceCommand
475
475
  };
476
476
  }
477
- /** A `SupervisorRunReader` over a Claude Code session — the same contract loops implements. */
477
+ /** A `SupervisorRunReader` over a Claude Code session — the same contract Runtime implements. */
478
478
  function claudeCodeSupervisorRunReader(opts) {
479
479
  return {
480
480
  runRef: opts.runRef ?? opts.transcriptPath,
@@ -482,6 +482,6 @@ function claudeCodeSupervisorRunReader(opts) {
482
482
  };
483
483
  }
484
484
  //#endregion
485
- export { NO_SOURCE_LIMITS, NO_TERMINAL_RECORD, RUNTIME_FAILED_STATUS, SUPERVISOR_RUN_INTEGRITY_SCHEMA, SUPERVISOR_RUN_ROLLUP_SCHEMA, SUPERVISOR_RUN_SCHEMA, analyzeSupervisorRun, analyzeSupervisorRunIntegrity, analyzeSupervisorRunSources, claudeCodeSupervisorRunReader, findSupervisorRunDirIn, findSupervisorRunDirs, isRuntimeSupervisorRunDir, isUnavailable, loopsSupervisorRunReader, parsePatch, parseSupervisorTree, readClaudeCodeSupervisorRun, readLoopsSupervisorRun, readRuntimeSupervisorRun, readTerminalRecord, renderSupervisorRollupMarkdown, renderSupervisorRunHeadline, renderSupervisorRunMarkdown, reportSupervisorRound, rollupSupervisorRuns, runSupervisorRunCommand, runtimeSupervisorRunReader, showMeasured, supervisorRunRolloutLines, unavailable, writeSupervisorRunReport, writeSupervisorRunReportSafe };
485
+ export { NO_SOURCE_LIMITS, NO_TERMINAL_RECORD, RUNTIME_FAILED_STATUS, SUPERVISOR_RUN_INTEGRITY_SCHEMA, SUPERVISOR_RUN_ROLLUP_SCHEMA, SUPERVISOR_RUN_SCHEMA, analyzeSupervisorRun, analyzeSupervisorRunIntegrity, analyzeSupervisorRunSources, claudeCodeSupervisorRunReader, findSupervisorRunDirs, isRuntimeSupervisorRunDir, isUnavailable, parsePatch, parseSupervisorTree, readClaudeCodeSupervisorRun, readRuntimeSupervisorRun, readTerminalRecord, renderSupervisorRollupMarkdown, renderSupervisorRunHeadline, renderSupervisorRunMarkdown, reportSupervisorRound, rollupSupervisorRuns, runSupervisorRunCommand, runtimeSupervisorRunReader, showMeasured, supervisorRunRolloutLines, unavailable, writeSupervisorRunReport, writeSupervisorRunReportSafe };
486
486
 
487
487
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/supervisor-run/claude-code-reader.ts"],"sourcesContent":["/**\n * Supervision-tree reader over a THIRD-PARTY harness: Claude Code.\n *\n * `loops-reader.ts` reads a supervisor we wrote, whose journal was designed\n * for this analysis. This reader reads a harness we do not control, whose\n * transcript was designed for replaying a chat — and recovers the same tree\n * from it. If both produce a `SupervisorRunSources`, the tree model is a\n * property of multi-agent runs, not of our journal format.\n *\n * ## Where the tree hides in a Claude Code transcript\n *\n * | Tree fact | Claude Code evidence |\n * |---|---|\n * | spawn | assistant `tool_use` (`Agent` / `Task`), answered by a `tool_result` whose `toolUseResult.agentId` names the child |\n * | settle | a `<task-notification>` block in a later user line: `<task-id>` = agentId, `<status>` |\n * | steer | assistant `tool_use` (`SendMessage`) with `input.to` = agentId — mid-task, to a LIVE child |\n * | delivered | that steer's `tool_result` carrying `success` / `resumedAgentId` |\n * | cancel | assistant `tool_use` (`TaskStop`) targeting an agentId |\n * | brain spend| `message.usage` on the main thread's assistant lines |\n * | worker spend| `message.usage` inside `<session>/subagents/agent-<id>.jsonl` |\n * | depth | a child transcript that itself contains `Agent` tool_use lines |\n *\n * Every one of those is read through `parseClaudeEntries` — the SAME line\n * parser `src/rollout/readers/claude-jsonl.ts` uses for solo rollouts. There\n * is no second transcript parser.\n *\n * ## What Claude Code cannot say\n *\n * It records tokens but never a price, runs no per-worker verify, and keeps no\n * per-worker patch. Those are declared once in `limits`, so the analyzer\n * reports `unavailable — <reason>` instead of the $0 / 0-accepted that summing\n * an empty field would produce. See `SourceLimits`.\n *\n * ## Metric coverage vs the loops journal\n *\n * Measured on a real 52-agent session (fixture:\n * `tests/fixtures/supervisor-run/claude-code-session-*`).\n *\n * | Metric | loops | Claude Code | Why |\n * |---|---|---|---|\n * | workersSpawned / Settled / Cancelled | full | full | spawn tool_use + task-notification + TaskStop |\n * | steers / steersDelivered / steersByWorker | full | full | `SendMessage`; delivery from its tool_result |\n * | waves / waveSizes / maxConcurrency | full | full | derived from spawn/settle instants |\n * | respawns / repeatedLabels | full | full | same derivation |\n * | delegationDepth | full | full | a child transcript's own spawn calls |\n * | timeToFirstSpawn / supervisorWall | full | full | transcript instants |\n * | idleMs / idlePct / workerUtilization | full | PARTIAL | an agent that never notifies is counted live to the end of the transcript |\n * | observeThenRespawn / respawnWithoutEvidence | full | full | ordering of spawn vs settle instants |\n * | workerEvidenceBytes | full | PARTIAL | the child's closing message; 0 for pruned transcripts |\n * | brain tokens in/out + cache | full | full | main-thread `message.usage` |\n * | worker tokens in/out + cache | via harness join | full or unavailable | totals are refused if any spawned transcript was pruned; retained per-worker rows remain available |\n * | perWorker wall | full | full | spawn → settle instants |\n * | accepted / rejected / emptyPass / settledVerdicts | full | NONE | no per-worker verify step exists |\n * | brain/worker/total usd, costPerAcceptedPatch | full | NONE | transcripts carry no price |\n * | patch stats, delivered, verifyPass/Rc | full | NONE | no diff is handed back |\n * | judgeResolved / Score / Passed / Total | full | NONE | no judge in the loop |\n * | driverSteerCalls, brainTruncations | full | NONE | no outer driver log, no per-call finish_reason tap |\n */\n\nimport { readdir, readFile } from 'node:fs/promises'\nimport { basename, dirname, join } from 'node:path'\nimport {\n type ClaudeEntry,\n parseClaudeEntries,\n transcriptFromEntries,\n} from '../rollout/readers/claude-jsonl'\nimport type { SupervisorRunReader, SupervisorRunSources, WorkerLogSource } from './types'\n\n/** Tool names that spawn a child agent. `Task` is the older name for `Agent`. */\nconst DEFAULT_SPAWN_TOOLS = ['Agent', 'Task'] as const\n/** Tool names that deliver a message to an ALREADY-RUNNING child agent. */\nconst DEFAULT_STEER_TOOLS = ['SendMessage'] as const\n/** Tool names that stop a running child agent. */\nconst DEFAULT_CANCEL_TOOLS = ['TaskStop', 'KillAgent'] as const\n\nconst SPEND_UNPRICED =\n 'Claude Code transcripts record token usage but never a price — usd is not in the store'\nconst NO_VERDICTS =\n 'Claude Code runs no per-worker verify step — a subagent reports prose, not pass/fail'\nconst NO_DELIVERABLES =\n 'Claude Code retains no per-worker patch — subagents commit to git, they do not hand back a diff'\n\nexport interface ClaudeCodeReaderOptions {\n /** The main session transcript: `~/.claude/projects/<slug>/<sessionId>.jsonl`. */\n readonly transcriptPath: string\n /**\n * Directory of child transcripts. Defaults to `<transcript-dir>/<sessionId>/subagents`.\n * `null` skips the join, and every per-worker token count becomes unavailable.\n */\n readonly subagentsDir?: string | null\n readonly runRef?: string\n readonly instanceId?: string | null\n readonly arm?: string | null\n readonly spawnTools?: readonly string[]\n readonly steerTools?: readonly string[]\n readonly cancelTools?: readonly string[]\n}\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === 'object' && v !== null && !Array.isArray(v)\n\nconst str = (v: unknown): string | null => (typeof v === 'string' ? v : null)\n\ninterface ToolUse {\n readonly id: string\n readonly name: string\n readonly input: Record<string, unknown>\n readonly at: string | null\n}\n\ninterface ToolResult {\n readonly id: string\n readonly at: string | null\n readonly structured: unknown\n readonly text: string\n}\n\n/** Every tool call and tool result on one thread, in order, with instants. */\ninterface ThreadCalls {\n readonly uses: ToolUse[]\n readonly results: Map<string, ToolResult>\n readonly notifications: TaskNotification[]\n readonly firstAt: string | null\n readonly lastAt: string | null\n}\n\ninterface TaskNotification {\n readonly taskId: string\n readonly toolUseId: string | null\n readonly status: string\n readonly summary: string | null\n readonly at: string | null\n}\n\nfunction blockText(content: unknown): string {\n if (typeof content === 'string') return content\n if (!Array.isArray(content)) return ''\n const parts: string[] = []\n for (const b of content) {\n if (isRecord(b) && b.type === 'text' && typeof b.text === 'string') parts.push(b.text)\n }\n return parts.join('\\n')\n}\n\nconst tag = (xml: string, name: string): string | null => {\n const m = xml.match(new RegExp(`<${name}>([\\\\s\\\\S]*?)</${name}>`))\n return m === null ? null : (m[1] as string)\n}\n\n/**\n * Task notifications are the settle instants. A notification fires each time an\n * agent stops, so a resumed agent produces several — they are kept in order and\n * the LAST one is the settle the analyzer sees, with the earlier ones acting as\n * the intermediate stops they actually were.\n */\nfunction parseNotifications(text: string, at: string | null): TaskNotification[] {\n const out: TaskNotification[] = []\n for (const m of text.matchAll(/<task-notification>[\\s\\S]*?<\\/task-notification>/g)) {\n const xml = m[0]\n const taskId = tag(xml, 'task-id')\n if (taskId === null) continue\n out.push({\n taskId: taskId.trim(),\n toolUseId: tag(xml, 'tool-use-id')?.trim() ?? null,\n status: tag(xml, 'status')?.trim() ?? 'unknown',\n summary: tag(xml, 'summary')?.trim() ?? null,\n at,\n })\n }\n return out\n}\n\n/** Project entries of ONE thread (main or a single sidechain) into tool traffic. */\nfunction threadCalls(entries: readonly ClaudeEntry[]): ThreadCalls {\n const uses: ToolUse[] = []\n const results = new Map<string, ToolResult>()\n const notifications: TaskNotification[] = []\n let firstAt: string | null = null\n let lastAt: string | null = null\n\n for (const entry of entries) {\n if (entry.timestamp !== null) {\n if (firstAt === null) firstAt = entry.timestamp\n lastAt = entry.timestamp\n }\n const content = entry.message.content\n if (entry.type === 'assistant') {\n if (!Array.isArray(content)) continue\n for (const block of content) {\n if (!isRecord(block) || block.type !== 'tool_use') continue\n const id = str(block.id)\n const name = str(block.name)\n if (id === null || name === null) continue\n uses.push({\n id,\n name,\n input: isRecord(block.input) ? block.input : {},\n at: entry.timestamp,\n })\n }\n continue\n }\n if (typeof content === 'string') {\n notifications.push(...parseNotifications(content, entry.timestamp))\n continue\n }\n if (!Array.isArray(content)) continue\n for (const block of content) {\n if (!isRecord(block)) continue\n if (block.type === 'tool_result' && typeof block.tool_use_id === 'string') {\n results.set(block.tool_use_id, {\n id: block.tool_use_id,\n at: entry.timestamp,\n structured: entry.toolUseResult,\n text: blockText(block.content),\n })\n } else if (block.type === 'text' && typeof block.text === 'string') {\n notifications.push(...parseNotifications(block.text, entry.timestamp))\n }\n }\n }\n return { uses, results, notifications, firstAt, lastAt }\n}\n\n/**\n * The agent id a spawn produced. Claude Code puts it in the structured\n * `toolUseResult`; the same id is echoed in the result text for transcripts\n * written before that field existed, so both are tried before giving up.\n */\nfunction spawnedAgentId(result: ToolResult | undefined): string | null {\n if (result === undefined) return null\n if (isRecord(result.structured)) {\n const id = str(result.structured.agentId)\n if (id !== null) return id\n }\n return result.text.match(/agentId:\\s*([A-Za-z0-9_-]+)/)?.[1] ?? null\n}\n\ninterface ChildTranscript {\n readonly agentId: string\n readonly path: string\n readonly description: string | null\n readonly spawnToolUseId: string | null\n readonly spawnDepth: number | null\n readonly entries: ClaudeEntry[]\n readonly tokensIn: number\n readonly tokensOut: number\n readonly cacheRead: number\n readonly cacheWrite: number\n readonly firstAt: string | null\n readonly lastAt: string | null\n readonly model: string | null\n /**\n * The child's closing assistant message — what it actually handed back. This\n * is the Claude Code analogue of a worker's `evidence` blob.\n */\n readonly finalReport: string | null\n}\n\nasync function readChildren(dir: string): Promise<ChildTranscript[]> {\n const names = await readdir(dir).catch(() => null)\n if (names === null) return []\n const out: ChildTranscript[] = []\n for (const name of names.filter((n) => n.endsWith('.jsonl')).sort()) {\n const path = join(dir, name)\n const raw = await readFile(path, 'utf8').catch(() => null)\n if (raw === null) continue\n const entries = parseClaudeEntries(raw)\n // A subagent transcript is sidechain end to end — that flag is what marks it\n // a separate invocation rather than a turn of the parent.\n const projected = transcriptFromEntries(entries, { includeSidechain: true })\n const metaRaw = await readFile(path.replace(/\\.jsonl$/, '.meta.json'), 'utf8').catch(() => null)\n let meta: Record<string, unknown> = {}\n if (metaRaw !== null) {\n try {\n const parsed: unknown = JSON.parse(metaRaw)\n if (isRecord(parsed)) meta = parsed\n } catch {\n meta = {}\n }\n }\n const agentId =\n entries.find((e) => e.agentId !== null)?.agentId ??\n name.replace(/^agent-/, '').replace(/\\.jsonl$/, '')\n out.push({\n agentId,\n path,\n description: str(meta.description),\n spawnToolUseId: str(meta.toolUseId),\n spawnDepth: typeof meta.spawnDepth === 'number' ? meta.spawnDepth : null,\n entries,\n tokensIn: projected.usage.tokensIn,\n tokensOut: projected.usage.tokensOut,\n cacheRead: projected.usage.cacheRead,\n cacheWrite: projected.usage.cacheWrite,\n firstAt: projected.startedAt,\n lastAt: projected.endedAt,\n model: projected.model,\n finalReport:\n [...projected.messages]\n .reverse()\n .find((m) => m.role === 'assistant' && typeof m.content === 'string')?.content ?? null,\n })\n }\n return out\n}\n\ninterface SpawnFact {\n readonly agentId: string\n readonly parentId: string\n readonly label: string\n readonly at: string | null\n readonly model: string | null\n}\n\n/** A journal line in the dialect `parseSupervisorTree` reads. */\nconst line = (obj: Record<string, unknown>): string => JSON.stringify(obj)\n\n/**\n * Read a Claude Code session (plus its subagent transcripts) as supervision-tree\n * source bytes. Never throws on a missing artifact.\n */\nexport async function readClaudeCodeSupervisorRun(\n opts: ClaudeCodeReaderOptions,\n): Promise<SupervisorRunSources> {\n const spawnTools = new Set(opts.spawnTools ?? DEFAULT_SPAWN_TOOLS)\n const steerTools = new Set(opts.steerTools ?? DEFAULT_STEER_TOOLS)\n const cancelTools = new Set(opts.cancelTools ?? DEFAULT_CANCEL_TOOLS)\n\n const raw = await readFile(opts.transcriptPath, 'utf8').catch(() => null)\n const sessionId = basename(opts.transcriptPath).replace(/\\.jsonl$/, '')\n const runRef = opts.runRef ?? opts.transcriptPath\n const limits = {\n managerTokens: null,\n workerTokens: null,\n spendUsd: SPEND_UNPRICED,\n workerVerdicts: NO_VERDICTS,\n deliverables: null,\n }\n const traceCommand = `npx --yes @tangle-network/traces@latest analyze --harness claude-code --session ${sessionId}`\n\n if (raw === null) {\n return {\n runRef,\n instanceId: opts.instanceId ?? sessionId,\n arm: opts.arm ?? null,\n supRunDir: null,\n journal: null,\n brainLog: null,\n state: null,\n progress: null,\n workers: null,\n workersMissingReason: `session transcript unreadable at ${opts.transcriptPath}`,\n result: null,\n judge: null,\n judgeSource: null,\n patch: null,\n driverLog: null,\n harnessWorkerTokens: null,\n harnessMissingReason: `session transcript unreadable at ${opts.transcriptPath}`,\n limits: {\n ...limits,\n managerTokens: `session transcript unreadable at ${opts.transcriptPath}`,\n workerTokens: `session transcript unreadable at ${opts.transcriptPath}`,\n deliverables: NO_DELIVERABLES,\n },\n traceCommand,\n }\n }\n\n const allEntries = parseClaudeEntries(raw)\n const main = threadCalls(allEntries.filter((e) => !e.isSidechain))\n const mainTranscript = transcriptFromEntries(allEntries)\n\n const subagentsDir =\n opts.subagentsDir === undefined\n ? join(dirname(opts.transcriptPath), sessionId, 'subagents')\n : opts.subagentsDir\n const children = subagentsDir === null ? [] : await readChildren(subagentsDir)\n const childByAgentId = new Map(children.map((c) => [c.agentId, c]))\n const childBySpawnToolUseId = new Map(\n children.filter((c) => c.spawnToolUseId !== null).map((c) => [c.spawnToolUseId as string, c]),\n )\n\n // Every thread that can spawn: the session itself, plus each child transcript\n // (a child that calls the spawn tool is a second delegation level).\n const threads: Array<{ id: string; calls: ThreadCalls }> = [{ id: sessionId, calls: main }]\n for (const child of children) {\n threads.push({ id: child.agentId, calls: threadCalls(child.entries) })\n }\n\n const spawns: SpawnFact[] = []\n const steersByTarget = new Map<\n string,\n Array<{ requestId: string; at: string | null; delivered: boolean }>\n >()\n const cancels: Array<{ agentId: string; at: string | null }> = []\n const settles: TaskNotification[] = []\n\n for (const thread of threads) {\n for (const use of thread.calls.uses) {\n if (spawnTools.has(use.name)) {\n const result = thread.calls.results.get(use.id)\n const agentId = spawnedAgentId(result) ?? childBySpawnToolUseId.get(use.id)?.agentId ?? null\n if (agentId === null) continue\n const label =\n str(use.input.description) ?? childByAgentId.get(agentId)?.description ?? agentId\n spawns.push({\n agentId,\n parentId: thread.id,\n label,\n // The spawn is complete when the launch call is answered; the tool_use\n // instant is the fallback for a call that never got a result line.\n at: result?.at ?? use.at,\n model: isRecord(result?.structured) ? str(result.structured.resolvedModel) : null,\n })\n continue\n }\n if (steerTools.has(use.name)) {\n const target = str(use.input.to) ?? str(use.input.recipient)\n if (target === null) continue\n const result = thread.calls.results.get(use.id)\n const structured = isRecord(result?.structured) ? result.structured : null\n // `success` is the harness confirming the message reached a live agent;\n // absent, the steer is counted queued but not delivered.\n const delivered = structured?.success === true || str(structured?.resumedAgentId) === target\n const rows = steersByTarget.get(target) ?? []\n rows.push({ requestId: use.id, at: use.at, delivered })\n steersByTarget.set(target, rows)\n continue\n }\n if (cancelTools.has(use.name)) {\n const target = str(use.input.agentId) ?? str(use.input.to) ?? str(use.input.taskId)\n if (target !== null) cancels.push({ agentId: target, at: use.at })\n }\n }\n settles.push(...thread.calls.notifications)\n }\n\n const spawnedIds = new Set(spawns.map((s) => s.agentId))\n const cancelledIds = new Set(\n cancels.filter((c) => spawnedIds.has(c.agentId)).map((c) => c.agentId),\n )\n const startedAt = main.firstAt\n const completedAt = main.lastAt\n\n const journalLines: string[] = [\n line({\n kind: 'spawned',\n id: sessionId,\n parent: null,\n label: `session:${sessionId}`,\n role: 'supervisor',\n at: startedAt,\n }),\n ]\n for (const s of spawns) {\n journalLines.push(\n line({\n kind: 'spawned',\n id: s.agentId,\n parent: s.parentId,\n label: s.label,\n role: 'worker',\n at: s.at,\n }),\n )\n }\n\n // Only the LAST notification per agent is its settle; an earlier one is a stop\n // the supervisor resumed from, which the steer count already records.\n const lastNotification = new Map<string, TaskNotification>()\n for (const n of settles) {\n if (!spawnedIds.has(n.taskId)) continue\n lastNotification.set(n.taskId, n)\n }\n for (const [agentId, n] of lastNotification) {\n if (cancelledIds.has(agentId)) continue\n journalLines.push(\n line({\n kind: 'settled',\n id: agentId,\n status: n.status,\n verdict: n.summary,\n at: n.at,\n // No `spent` key: Claude Code prices nothing, and a zeroed spend object\n // would read as a $0 worker. `limits.spendUsd` carries the reason.\n }),\n )\n }\n // One cancel per agent: Claude Code can emit a stop then a retry-stop for the\n // same agentId, and each raw entry would otherwise mint a duplicate `cancelled`\n // line that double-counts in `workersCancelled`. Keep the last, mirroring the\n // last-notification dedup the settle path already does.\n const lastCancel = new Map<string, { agentId: string; at: string | null }>()\n for (const c of cancels) {\n if (!spawnedIds.has(c.agentId)) continue\n lastCancel.set(c.agentId, c)\n }\n for (const c of lastCancel.values()) {\n journalLines.push(\n line({ kind: 'cancelled', id: c.agentId, reason: 'stopped by supervisor', at: c.at }),\n )\n }\n // `metered` carries the brain's own inference. The token counts are real; the\n // usd stays absent and `limits.spendUsd` explains why.\n journalLines.push(\n line({\n kind: 'metered',\n id: sessionId,\n spend: {\n tokens: {\n input: mainTranscript.usage.tokensIn,\n output: mainTranscript.usage.tokensOut,\n cacheRead: mainTranscript.usage.cacheRead,\n cacheWrite: mainTranscript.usage.cacheWrite,\n },\n },\n at: completedAt,\n }),\n )\n\n const settleAtByAgent = new Map(\n [...lastNotification.entries()].map(([id, n]) => [id, n.at] as const),\n )\n const spawnAtByAgent = new Map(spawns.map((s) => [s.agentId, s.at] as const))\n\n const workers: WorkerLogSource[] = []\n for (const spawn of spawns) {\n const { agentId, label } = spawn\n const events: string[] = []\n const inbox: string[] = []\n const child = childByAgentId.get(agentId) ?? null\n const startAt = child?.firstAt ?? spawnAtByAgent.get(agentId) ?? null\n const endAt = settleAtByAgent.get(agentId) ?? child?.lastAt ?? null\n if (startAt !== null) events.push(line({ kind: 'started', label, at: startAt, agentId }))\n for (const steer of steersByTarget.get(agentId) ?? []) {\n inbox.push(line({ id: steer.requestId, at: steer.at, worker: label, message: 'steer' }))\n events.push(\n line({\n kind: 'message',\n label,\n direction: 'down',\n at: steer.at,\n requestId: steer.requestId,\n delivered: steer.delivered,\n }),\n )\n }\n if (endAt !== null) {\n events.push(\n line({\n kind: 'finished',\n label,\n at: endAt,\n agentId,\n // No `passed` / `patchBytes`: this harness has neither. Emitting\n // `passed: false` here would invent a failed worker.\n // `evidence` is the child's closing message — what it handed back.\n ...(child?.finalReport === null || child?.finalReport === undefined\n ? {}\n : { evidence: child.finalReport }),\n }),\n )\n }\n workers.push({\n workerId: agentId,\n label,\n events: events.length === 0 ? '' : `${events.join('\\n')}\\n`,\n inbox: inbox.length === 0 ? '' : `${inbox.join('\\n')}\\n`,\n patchBytes: null,\n transcriptRef: child?.path ?? null,\n patchPath: null,\n tokensIn: child?.tokensIn ?? null,\n tokensOut: child?.tokensOut ?? null,\n cacheRead: child?.cacheRead ?? null,\n cacheWrite: child?.cacheWrite ?? null,\n })\n }\n\n const joined = children.length\n const harnessWorkerTokens =\n joined === 0\n ? null\n : {\n store: 'claude-code subagent transcripts',\n sessions: joined,\n input: children.reduce((a, c) => a + c.tokensIn, 0),\n output: children.reduce((a, c) => a + c.tokensOut, 0),\n cacheRead: children.reduce((a, c) => a + c.cacheRead, 0),\n cacheWrite: children.reduce((a, c) => a + c.cacheWrite, 0),\n }\n\n const missingChildren = spawns.filter((s) => !childByAgentId.has(s.agentId)).length\n const harnessMissingReason =\n subagentsDir === null\n ? 'subagent transcript join disabled'\n : joined === 0\n ? `no subagent transcripts under ${subagentsDir}`\n : missingChildren === 0\n ? null\n : `${missingChildren}/${spawns.length} spawned agents have no retained transcript under ${subagentsDir} (Claude Code prunes them; their tokens are unrecoverable)`\n\n const liveWorkers = spawns.filter(\n (s) => !lastNotification.has(s.agentId) && !cancelledIds.has(s.agentId),\n ).length\n const state = JSON.stringify({\n id: sessionId,\n // Derived, not asserted: a spawned agent with no notification and no stop\n // is still running, which is exactly what a live transcript looks like.\n status: liveWorkers > 0 ? 'running' : 'idle',\n startedAt,\n completedAt,\n result: { delivered: null },\n })\n\n return {\n runRef,\n instanceId: opts.instanceId ?? sessionId,\n arm: opts.arm ?? null,\n supRunDir: subagentsDir,\n journal: `${journalLines.join('\\n')}\\n`,\n brainLog: null,\n state,\n progress: null,\n workers,\n workersMissingReason: null,\n result: null,\n judge: null,\n judgeSource: null,\n patch: null,\n driverLog: null,\n harnessWorkerTokens,\n harnessMissingReason,\n limits: {\n ...limits,\n workerTokens: spawns.length === 0 ? null : harnessMissingReason,\n deliverables: NO_DELIVERABLES,\n },\n rootTranscriptRef: opts.transcriptPath,\n traceCommand,\n }\n}\n\n/** A `SupervisorRunReader` over a Claude Code session — the same contract loops implements. */\nexport function claudeCodeSupervisorRunReader(opts: ClaudeCodeReaderOptions): SupervisorRunReader {\n return {\n runRef: opts.runRef ?? opts.transcriptPath,\n read: () => readClaudeCodeSupervisorRun(opts),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,MAAM,sBAAsB,CAAC,SAAS,MAAM;;AAE5C,MAAM,sBAAsB,CAAC,aAAa;;AAE1C,MAAM,uBAAuB,CAAC,YAAY,WAAW;AAErD,MAAM,iBACJ;AACF,MAAM,cACJ;AACF,MAAM,kBACJ;AAkBF,MAAM,YAAY,MAChB,OAAO,MAAM,YAAY,MAAM,QAAQ,CAAC,MAAM,QAAQ,CAAC;AAEzD,MAAM,OAAO,MAA+B,OAAO,MAAM,WAAW,IAAI;AAiCxE,SAAS,UAAU,SAA0B;CAC3C,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,IAAI,CAAC,MAAM,QAAQ,OAAO,GAAG,OAAO;CACpC,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,KAAK,SACd,IAAI,SAAS,CAAC,KAAK,EAAE,SAAS,UAAU,OAAO,EAAE,SAAS,UAAU,MAAM,KAAK,EAAE,IAAI;CAEvF,OAAO,MAAM,KAAK,IAAI;AACxB;AAEA,MAAM,OAAO,KAAa,SAAgC;CACxD,MAAM,IAAI,IAAI,MAAM,IAAI,OAAO,IAAI,KAAK,iBAAiB,KAAK,EAAE,CAAC;CACjE,OAAO,MAAM,OAAO,OAAQ,EAAE;AAChC;;;;;;;AAQA,SAAS,mBAAmB,MAAc,IAAuC;CAC/E,MAAM,MAA0B,CAAC;CACjC,KAAK,MAAM,KAAK,KAAK,SAAS,mDAAmD,GAAG;EAClF,MAAM,MAAM,EAAE;EACd,MAAM,SAAS,IAAI,KAAK,SAAS;EACjC,IAAI,W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AAsB;EACtB,QAAQ;EACR,OAAO;EACP,aAAa;EACb,OAAO;EACP,WAAW;EACX;EACA;EACA,QAAQ;GACN,GAAG;GACH,cAAc,OAAO,WAAW,IAAI,OAAO;GAC3C,cAAc;EAChB;EACA,mBAAmB,KAAK;EACxB;CACF;AACF;;AAGA,SAAgB,8BAA8B,MAAoD;CAChG,OAAO;EACL,QAAQ,KAAK,UAAU,KAAK;EAC5B,YAAY,4BAA4B,IAAI;CAC9C;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/supervisor-run/claude-code-reader.ts"],"sourcesContent":["/**\n * Supervision-tree reader over a THIRD-PARTY harness: Claude Code.\n *\n * The Runtime reader reads a supervisor journal designed for this analysis.\n * for this analysis. This reader reads a harness we do not control, whose\n * transcript was designed for replaying a chat — and recovers the same tree\n * from it. If both produce a `SupervisorRunSources`, the tree model is a\n * property of multi-agent runs, not of our journal format.\n *\n * ## Where the tree hides in a Claude Code transcript\n *\n * | Tree fact | Claude Code evidence |\n * |---|---|\n * | spawn | assistant `tool_use` (`Agent` / `Task`), answered by a `tool_result` whose `toolUseResult.agentId` names the child |\n * | settle | a `<task-notification>` block in a later user line: `<task-id>` = agentId, `<status>` |\n * | steer | assistant `tool_use` (`SendMessage`) with `input.to` = agentId — mid-task, to a LIVE child |\n * | delivered | that steer's `tool_result` carrying `success` / `resumedAgentId` |\n * | cancel | assistant `tool_use` (`TaskStop`) targeting an agentId |\n * | brain spend| `message.usage` on the main thread's assistant lines |\n * | worker spend| `message.usage` inside `<session>/subagents/agent-<id>.jsonl` |\n * | depth | a child transcript that itself contains `Agent` tool_use lines |\n *\n * Every one of those is read through `parseClaudeEntries` — the SAME line\n * parser `src/rollout/readers/claude-jsonl.ts` uses for solo rollouts. There\n * is no second transcript parser.\n *\n * ## What Claude Code cannot say\n *\n * It records tokens but never a price, runs no per-worker verify, and keeps no\n * per-worker patch. Those are declared once in `limits`, so the analyzer\n * reports `unavailable — <reason>` instead of the $0 / 0-accepted that summing\n * an empty field would produce. See `SourceLimits`.\n *\n * ## Metric coverage vs the Runtime journal\n *\n * Measured on a real 52-agent session (fixture:\n * `tests/fixtures/supervisor-run/claude-code-session-*`).\n *\n * | Metric | Runtime | Claude Code | Why |\n * |---|---|---|---|\n * | workersSpawned / Settled / Cancelled | full | full | spawn tool_use + task-notification + TaskStop |\n * | steers / steersDelivered / steersByWorker | full | full | `SendMessage`; delivery from its tool_result |\n * | waves / waveSizes / maxConcurrency | full | full | derived from spawn/settle instants |\n * | respawns / repeatedLabels | full | full | same derivation |\n * | delegationDepth | full | full | a child transcript's own spawn calls |\n * | timeToFirstSpawn / supervisorWall | full | full | transcript instants |\n * | idleMs / idlePct / workerUtilization | full | PARTIAL | an agent that never notifies is counted live to the end of the transcript |\n * | observeThenRespawn / respawnWithoutEvidence | full | full | ordering of spawn vs settle instants |\n * | workerEvidenceBytes | full | PARTIAL | the child's closing message; 0 for pruned transcripts |\n * | brain tokens in/out + cache | full | full | main-thread `message.usage` |\n * | worker tokens in/out + cache | via harness join | full or unavailable | totals are refused if any spawned transcript was pruned; retained per-worker rows remain available |\n * | perWorker wall | full | full | spawn → settle instants |\n * | accepted / rejected / emptyPass / settledVerdicts | full | NONE | no per-worker verify step exists |\n * | brain/worker/total usd, costPerAcceptedPatch | full | NONE | transcripts carry no price |\n * | patch stats, delivered, verifyPass/Rc | full | NONE | no diff is handed back |\n * | judgeResolved / Score / Passed / Total | full | NONE | no judge in the loop |\n * | driverSteerCalls, brainTruncations | full | NONE | no outer driver log, no per-call finish_reason tap |\n */\n\nimport { readdir, readFile } from 'node:fs/promises'\nimport { basename, dirname, join } from 'node:path'\nimport {\n type ClaudeEntry,\n parseClaudeEntries,\n transcriptFromEntries,\n} from '../rollout/readers/claude-jsonl'\nimport type { SupervisorRunReader, SupervisorRunSources, WorkerLogSource } from './types'\n\n/** Tool names that spawn a child agent. `Task` is the older name for `Agent`. */\nconst DEFAULT_SPAWN_TOOLS = ['Agent', 'Task'] as const\n/** Tool names that deliver a message to an ALREADY-RUNNING child agent. */\nconst DEFAULT_STEER_TOOLS = ['SendMessage'] as const\n/** Tool names that stop a running child agent. */\nconst DEFAULT_CANCEL_TOOLS = ['TaskStop', 'KillAgent'] as const\n\nconst SPEND_UNPRICED =\n 'Claude Code transcripts record token usage but never a price — usd is not in the store'\nconst NO_VERDICTS =\n 'Claude Code runs no per-worker verify step — a subagent reports prose, not pass/fail'\nconst NO_DELIVERABLES =\n 'Claude Code retains no per-worker patch — subagents commit to git, they do not hand back a diff'\n\nexport interface ClaudeCodeReaderOptions {\n /** The main session transcript: `~/.claude/projects/<slug>/<sessionId>.jsonl`. */\n readonly transcriptPath: string\n /**\n * Directory of child transcripts. Defaults to `<transcript-dir>/<sessionId>/subagents`.\n * `null` skips the join, and every per-worker token count becomes unavailable.\n */\n readonly subagentsDir?: string | null\n readonly runRef?: string\n readonly instanceId?: string | null\n readonly arm?: string | null\n readonly spawnTools?: readonly string[]\n readonly steerTools?: readonly string[]\n readonly cancelTools?: readonly string[]\n}\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === 'object' && v !== null && !Array.isArray(v)\n\nconst str = (v: unknown): string | null => (typeof v === 'string' ? v : null)\n\ninterface ToolUse {\n readonly id: string\n readonly name: string\n readonly input: Record<string, unknown>\n readonly at: string | null\n}\n\ninterface ToolResult {\n readonly id: string\n readonly at: string | null\n readonly structured: unknown\n readonly text: string\n}\n\n/** Every tool call and tool result on one thread, in order, with instants. */\ninterface ThreadCalls {\n readonly uses: ToolUse[]\n readonly results: Map<string, ToolResult>\n readonly notifications: TaskNotification[]\n readonly firstAt: string | null\n readonly lastAt: string | null\n}\n\ninterface TaskNotification {\n readonly taskId: string\n readonly toolUseId: string | null\n readonly status: string\n readonly summary: string | null\n readonly at: string | null\n}\n\nfunction blockText(content: unknown): string {\n if (typeof content === 'string') return content\n if (!Array.isArray(content)) return ''\n const parts: string[] = []\n for (const b of content) {\n if (isRecord(b) && b.type === 'text' && typeof b.text === 'string') parts.push(b.text)\n }\n return parts.join('\\n')\n}\n\nconst tag = (xml: string, name: string): string | null => {\n const m = xml.match(new RegExp(`<${name}>([\\\\s\\\\S]*?)</${name}>`))\n return m === null ? null : (m[1] as string)\n}\n\n/**\n * Task notifications are the settle instants. A notification fires each time an\n * agent stops, so a resumed agent produces several — they are kept in order and\n * the LAST one is the settle the analyzer sees, with the earlier ones acting as\n * the intermediate stops they actually were.\n */\nfunction parseNotifications(text: string, at: string | null): TaskNotification[] {\n const out: TaskNotification[] = []\n for (const m of text.matchAll(/<task-notification>[\\s\\S]*?<\\/task-notification>/g)) {\n const xml = m[0]\n const taskId = tag(xml, 'task-id')\n if (taskId === null) continue\n out.push({\n taskId: taskId.trim(),\n toolUseId: tag(xml, 'tool-use-id')?.trim() ?? null,\n status: tag(xml, 'status')?.trim() ?? 'unknown',\n summary: tag(xml, 'summary')?.trim() ?? null,\n at,\n })\n }\n return out\n}\n\n/** Project entries of ONE thread (main or a single sidechain) into tool traffic. */\nfunction threadCalls(entries: readonly ClaudeEntry[]): ThreadCalls {\n const uses: ToolUse[] = []\n const results = new Map<string, ToolResult>()\n const notifications: TaskNotification[] = []\n let firstAt: string | null = null\n let lastAt: string | null = null\n\n for (const entry of entries) {\n if (entry.timestamp !== null) {\n if (firstAt === null) firstAt = entry.timestamp\n lastAt = entry.timestamp\n }\n const content = entry.message.content\n if (entry.type === 'assistant') {\n if (!Array.isArray(content)) continue\n for (const block of content) {\n if (!isRecord(block) || block.type !== 'tool_use') continue\n const id = str(block.id)\n const name = str(block.name)\n if (id === null || name === null) continue\n uses.push({\n id,\n name,\n input: isRecord(block.input) ? block.input : {},\n at: entry.timestamp,\n })\n }\n continue\n }\n if (typeof content === 'string') {\n notifications.push(...parseNotifications(content, entry.timestamp))\n continue\n }\n if (!Array.isArray(content)) continue\n for (const block of content) {\n if (!isRecord(block)) continue\n if (block.type === 'tool_result' && typeof block.tool_use_id === 'string') {\n results.set(block.tool_use_id, {\n id: block.tool_use_id,\n at: entry.timestamp,\n structured: entry.toolUseResult,\n text: blockText(block.content),\n })\n } else if (block.type === 'text' && typeof block.text === 'string') {\n notifications.push(...parseNotifications(block.text, entry.timestamp))\n }\n }\n }\n return { uses, results, notifications, firstAt, lastAt }\n}\n\n/**\n * The agent id a spawn produced. Claude Code puts it in the structured\n * `toolUseResult`; the same id is echoed in the result text for transcripts\n * written before that field existed, so both are tried before giving up.\n */\nfunction spawnedAgentId(result: ToolResult | undefined): string | null {\n if (result === undefined) return null\n if (isRecord(result.structured)) {\n const id = str(result.structured.agentId)\n if (id !== null) return id\n }\n return result.text.match(/agentId:\\s*([A-Za-z0-9_-]+)/)?.[1] ?? null\n}\n\ninterface ChildTranscript {\n readonly agentId: string\n readonly path: string\n readonly description: string | null\n readonly spawnToolUseId: string | null\n readonly spawnDepth: number | null\n readonly entries: ClaudeEntry[]\n readonly tokensIn: number\n readonly tokensOut: number\n readonly cacheRead: number\n readonly cacheWrite: number\n readonly firstAt: string | null\n readonly lastAt: string | null\n readonly model: string | null\n /**\n * The child's closing assistant message — what it actually handed back. This\n * is the Claude Code analogue of a worker's `evidence` blob.\n */\n readonly finalReport: string | null\n}\n\nasync function readChildren(dir: string): Promise<ChildTranscript[]> {\n const names = await readdir(dir).catch(() => null)\n if (names === null) return []\n const out: ChildTranscript[] = []\n for (const name of names.filter((n) => n.endsWith('.jsonl')).sort()) {\n const path = join(dir, name)\n const raw = await readFile(path, 'utf8').catch(() => null)\n if (raw === null) continue\n const entries = parseClaudeEntries(raw)\n // A subagent transcript is sidechain end to end — that flag is what marks it\n // a separate invocation rather than a turn of the parent.\n const projected = transcriptFromEntries(entries, { includeSidechain: true })\n const metaRaw = await readFile(path.replace(/\\.jsonl$/, '.meta.json'), 'utf8').catch(() => null)\n let meta: Record<string, unknown> = {}\n if (metaRaw !== null) {\n try {\n const parsed: unknown = JSON.parse(metaRaw)\n if (isRecord(parsed)) meta = parsed\n } catch {\n meta = {}\n }\n }\n const agentId =\n entries.find((e) => e.agentId !== null)?.agentId ??\n name.replace(/^agent-/, '').replace(/\\.jsonl$/, '')\n out.push({\n agentId,\n path,\n description: str(meta.description),\n spawnToolUseId: str(meta.toolUseId),\n spawnDepth: typeof meta.spawnDepth === 'number' ? meta.spawnDepth : null,\n entries,\n tokensIn: projected.usage.tokensIn,\n tokensOut: projected.usage.tokensOut,\n cacheRead: projected.usage.cacheRead,\n cacheWrite: projected.usage.cacheWrite,\n firstAt: projected.startedAt,\n lastAt: projected.endedAt,\n model: projected.model,\n finalReport:\n [...projected.messages]\n .reverse()\n .find((m) => m.role === 'assistant' && typeof m.content === 'string')?.content ?? null,\n })\n }\n return out\n}\n\ninterface SpawnFact {\n readonly agentId: string\n readonly parentId: string\n readonly label: string\n readonly at: string | null\n readonly model: string | null\n}\n\n/** A journal line in the dialect `parseSupervisorTree` reads. */\nconst line = (obj: Record<string, unknown>): string => JSON.stringify(obj)\n\n/**\n * Read a Claude Code session (plus its subagent transcripts) as supervision-tree\n * source bytes. Never throws on a missing artifact.\n */\nexport async function readClaudeCodeSupervisorRun(\n opts: ClaudeCodeReaderOptions,\n): Promise<SupervisorRunSources> {\n const spawnTools = new Set(opts.spawnTools ?? DEFAULT_SPAWN_TOOLS)\n const steerTools = new Set(opts.steerTools ?? DEFAULT_STEER_TOOLS)\n const cancelTools = new Set(opts.cancelTools ?? DEFAULT_CANCEL_TOOLS)\n\n const raw = await readFile(opts.transcriptPath, 'utf8').catch(() => null)\n const sessionId = basename(opts.transcriptPath).replace(/\\.jsonl$/, '')\n const runRef = opts.runRef ?? opts.transcriptPath\n const limits = {\n managerTokens: null,\n workerTokens: null,\n spendUsd: SPEND_UNPRICED,\n workerVerdicts: NO_VERDICTS,\n deliverables: null,\n }\n const traceCommand = `npx --yes @tangle-network/traces@latest analyze --harness claude-code --session ${sessionId}`\n\n if (raw === null) {\n return {\n runRef,\n instanceId: opts.instanceId ?? sessionId,\n arm: opts.arm ?? null,\n supRunDir: null,\n journal: null,\n brainLog: null,\n state: null,\n progress: null,\n workers: null,\n workersMissingReason: `session transcript unreadable at ${opts.transcriptPath}`,\n result: null,\n judge: null,\n judgeSource: null,\n patch: null,\n driverLog: null,\n harnessWorkerTokens: null,\n harnessMissingReason: `session transcript unreadable at ${opts.transcriptPath}`,\n limits: {\n ...limits,\n managerTokens: `session transcript unreadable at ${opts.transcriptPath}`,\n workerTokens: `session transcript unreadable at ${opts.transcriptPath}`,\n deliverables: NO_DELIVERABLES,\n },\n traceCommand,\n }\n }\n\n const allEntries = parseClaudeEntries(raw)\n const main = threadCalls(allEntries.filter((e) => !e.isSidechain))\n const mainTranscript = transcriptFromEntries(allEntries)\n\n const subagentsDir =\n opts.subagentsDir === undefined\n ? join(dirname(opts.transcriptPath), sessionId, 'subagents')\n : opts.subagentsDir\n const children = subagentsDir === null ? [] : await readChildren(subagentsDir)\n const childByAgentId = new Map(children.map((c) => [c.agentId, c]))\n const childBySpawnToolUseId = new Map(\n children.filter((c) => c.spawnToolUseId !== null).map((c) => [c.spawnToolUseId as string, c]),\n )\n\n // Every thread that can spawn: the session itself, plus each child transcript\n // (a child that calls the spawn tool is a second delegation level).\n const threads: Array<{ id: string; calls: ThreadCalls }> = [{ id: sessionId, calls: main }]\n for (const child of children) {\n threads.push({ id: child.agentId, calls: threadCalls(child.entries) })\n }\n\n const spawns: SpawnFact[] = []\n const steersByTarget = new Map<\n string,\n Array<{ requestId: string; at: string | null; delivered: boolean }>\n >()\n const cancels: Array<{ agentId: string; at: string | null }> = []\n const settles: TaskNotification[] = []\n\n for (const thread of threads) {\n for (const use of thread.calls.uses) {\n if (spawnTools.has(use.name)) {\n const result = thread.calls.results.get(use.id)\n const agentId = spawnedAgentId(result) ?? childBySpawnToolUseId.get(use.id)?.agentId ?? null\n if (agentId === null) continue\n const label =\n str(use.input.description) ?? childByAgentId.get(agentId)?.description ?? agentId\n spawns.push({\n agentId,\n parentId: thread.id,\n label,\n // The spawn is complete when the launch call is answered; the tool_use\n // instant is the fallback for a call that never got a result line.\n at: result?.at ?? use.at,\n model: isRecord(result?.structured) ? str(result.structured.resolvedModel) : null,\n })\n continue\n }\n if (steerTools.has(use.name)) {\n const target = str(use.input.to) ?? str(use.input.recipient)\n if (target === null) continue\n const result = thread.calls.results.get(use.id)\n const structured = isRecord(result?.structured) ? result.structured : null\n // `success` is the harness confirming the message reached a live agent;\n // absent, the steer is counted queued but not delivered.\n const delivered = structured?.success === true || str(structured?.resumedAgentId) === target\n const rows = steersByTarget.get(target) ?? []\n rows.push({ requestId: use.id, at: use.at, delivered })\n steersByTarget.set(target, rows)\n continue\n }\n if (cancelTools.has(use.name)) {\n const target = str(use.input.agentId) ?? str(use.input.to) ?? str(use.input.taskId)\n if (target !== null) cancels.push({ agentId: target, at: use.at })\n }\n }\n settles.push(...thread.calls.notifications)\n }\n\n const spawnedIds = new Set(spawns.map((s) => s.agentId))\n const cancelledIds = new Set(\n cancels.filter((c) => spawnedIds.has(c.agentId)).map((c) => c.agentId),\n )\n const startedAt = main.firstAt\n const completedAt = main.lastAt\n\n const journalLines: string[] = [\n line({\n kind: 'spawned',\n id: sessionId,\n parent: null,\n label: `session:${sessionId}`,\n role: 'supervisor',\n at: startedAt,\n }),\n ]\n for (const s of spawns) {\n journalLines.push(\n line({\n kind: 'spawned',\n id: s.agentId,\n parent: s.parentId,\n label: s.label,\n role: 'worker',\n at: s.at,\n }),\n )\n }\n\n // Only the LAST notification per agent is its settle; an earlier one is a stop\n // the supervisor resumed from, which the steer count already records.\n const lastNotification = new Map<string, TaskNotification>()\n for (const n of settles) {\n if (!spawnedIds.has(n.taskId)) continue\n lastNotification.set(n.taskId, n)\n }\n for (const [agentId, n] of lastNotification) {\n if (cancelledIds.has(agentId)) continue\n journalLines.push(\n line({\n kind: 'settled',\n id: agentId,\n status: n.status,\n verdict: n.summary,\n at: n.at,\n // No `spent` key: Claude Code prices nothing, and a zeroed spend object\n // would read as a $0 worker. `limits.spendUsd` carries the reason.\n }),\n )\n }\n // One cancel per agent: Claude Code can emit a stop then a retry-stop for the\n // same agentId, and each raw entry would otherwise mint a duplicate `cancelled`\n // line that double-counts in `workersCancelled`. Keep the last, mirroring the\n // last-notification dedup the settle path already does.\n const lastCancel = new Map<string, { agentId: string; at: string | null }>()\n for (const c of cancels) {\n if (!spawnedIds.has(c.agentId)) continue\n lastCancel.set(c.agentId, c)\n }\n for (const c of lastCancel.values()) {\n journalLines.push(\n line({ kind: 'cancelled', id: c.agentId, reason: 'stopped by supervisor', at: c.at }),\n )\n }\n // `metered` carries the brain's own inference. The token counts are real; the\n // usd stays absent and `limits.spendUsd` explains why.\n journalLines.push(\n line({\n kind: 'metered',\n id: sessionId,\n spend: {\n tokens: {\n input: mainTranscript.usage.tokensIn,\n output: mainTranscript.usage.tokensOut,\n cacheRead: mainTranscript.usage.cacheRead,\n cacheWrite: mainTranscript.usage.cacheWrite,\n },\n },\n at: completedAt,\n }),\n )\n\n const settleAtByAgent = new Map(\n [...lastNotification.entries()].map(([id, n]) => [id, n.at] as const),\n )\n const spawnAtByAgent = new Map(spawns.map((s) => [s.agentId, s.at] as const))\n\n const workers: WorkerLogSource[] = []\n for (const spawn of spawns) {\n const { agentId, label } = spawn\n const events: string[] = []\n const inbox: string[] = []\n const child = childByAgentId.get(agentId) ?? null\n const startAt = child?.firstAt ?? spawnAtByAgent.get(agentId) ?? null\n const endAt = settleAtByAgent.get(agentId) ?? child?.lastAt ?? null\n if (startAt !== null) events.push(line({ kind: 'started', label, at: startAt, agentId }))\n for (const steer of steersByTarget.get(agentId) ?? []) {\n inbox.push(line({ id: steer.requestId, at: steer.at, worker: label, message: 'steer' }))\n events.push(\n line({\n kind: 'message',\n label,\n direction: 'down',\n at: steer.at,\n requestId: steer.requestId,\n delivered: steer.delivered,\n }),\n )\n }\n if (endAt !== null) {\n events.push(\n line({\n kind: 'finished',\n label,\n at: endAt,\n agentId,\n // No `passed` / `patchBytes`: this harness has neither. Emitting\n // `passed: false` here would invent a failed worker.\n // `evidence` is the child's closing message — what it handed back.\n ...(child?.finalReport === null || child?.finalReport === undefined\n ? {}\n : { evidence: child.finalReport }),\n }),\n )\n }\n workers.push({\n workerId: agentId,\n label,\n events: events.length === 0 ? '' : `${events.join('\\n')}\\n`,\n inbox: inbox.length === 0 ? '' : `${inbox.join('\\n')}\\n`,\n patchBytes: null,\n transcriptRef: child?.path ?? null,\n patchPath: null,\n tokensIn: child?.tokensIn ?? null,\n tokensOut: child?.tokensOut ?? null,\n cacheRead: child?.cacheRead ?? null,\n cacheWrite: child?.cacheWrite ?? null,\n })\n }\n\n const joined = children.length\n const harnessWorkerTokens =\n joined === 0\n ? null\n : {\n store: 'claude-code subagent transcripts',\n sessions: joined,\n input: children.reduce((a, c) => a + c.tokensIn, 0),\n output: children.reduce((a, c) => a + c.tokensOut, 0),\n cacheRead: children.reduce((a, c) => a + c.cacheRead, 0),\n cacheWrite: children.reduce((a, c) => a + c.cacheWrite, 0),\n }\n\n const missingChildren = spawns.filter((s) => !childByAgentId.has(s.agentId)).length\n const harnessMissingReason =\n subagentsDir === null\n ? 'subagent transcript join disabled'\n : joined === 0\n ? `no subagent transcripts under ${subagentsDir}`\n : missingChildren === 0\n ? null\n : `${missingChildren}/${spawns.length} spawned agents have no retained transcript under ${subagentsDir} (Claude Code prunes them; their tokens are unrecoverable)`\n\n const liveWorkers = spawns.filter(\n (s) => !lastNotification.has(s.agentId) && !cancelledIds.has(s.agentId),\n ).length\n const state = JSON.stringify({\n id: sessionId,\n // Derived, not asserted: a spawned agent with no notification and no stop\n // is still running, which is exactly what a live transcript looks like.\n status: liveWorkers > 0 ? 'running' : 'idle',\n startedAt,\n completedAt,\n result: { delivered: null },\n })\n\n return {\n runRef,\n instanceId: opts.instanceId ?? sessionId,\n arm: opts.arm ?? null,\n supRunDir: subagentsDir,\n journal: `${journalLines.join('\\n')}\\n`,\n brainLog: null,\n state,\n progress: null,\n workers,\n workersMissingReason: null,\n result: null,\n judge: null,\n judgeSource: null,\n patch: null,\n driverLog: null,\n harnessWorkerTokens,\n harnessMissingReason,\n limits: {\n ...limits,\n workerTokens: spawns.length === 0 ? null : harnessMissingReason,\n deliverables: NO_DELIVERABLES,\n },\n rootTranscriptRef: opts.transcriptPath,\n traceCommand,\n }\n}\n\n/** A `SupervisorRunReader` over a Claude Code session — the same contract Runtime implements. */\nexport function claudeCodeSupervisorRunReader(opts: ClaudeCodeReaderOptions): SupervisorRunReader {\n return {\n runRef: opts.runRef ?? opts.transcriptPath,\n read: () => readClaudeCodeSupervisorRun(opts),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,MAAM,sBAAsB,CAAC,SAAS,MAAM;;AAE5C,MAAM,sBAAsB,CAAC,aAAa;;AAE1C,MAAM,uBAAuB,CAAC,YAAY,WAAW;AAErD,MAAM,iBACJ;AACF,MAAM,cACJ;AACF,MAAM,kBACJ;AAkBF,MAAM,YAAY,MAChB,OAAO,MAAM,YAAY,MAAM,QAAQ,CAAC,MAAM,QAAQ,CAAC;AAEzD,MAAM,OAAO,MAA+B,OAAO,MAAM,WAAW,IAAI;AAiCxE,SAAS,UAAU,SAA0B;CAC3C,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,IAAI,CAAC,MAAM,QAAQ,OAAO,GAAG,OAAO;CACpC,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,KAAK,SACd,IAAI,SAAS,CAAC,KAAK,EAAE,SAAS,UAAU,OAAO,EAAE,SAAS,UAAU,MAAM,KAAK,EAAE,IAAI;CAEvF,OAAO,MAAM,KAAK,IAAI;AACxB;AAEA,MAAM,OAAO,KAAa,SAAgC;CACxD,MAAM,IAAI,IAAI,MAAM,IAAI,OAAO,IAAI,KAAK,iBAAiB,KAAK,EAAE,CAAC;CACjE,OAAO,MAAM,OAAO,OAAQ,EAAE;AAChC;;;;;;;AAQA,SAAS,mBAAmB,MAAc,IAAuC;CAC/E,MAAM,MAA0B,CAAC;CACjC,KAAK,MAAM,KAA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K,OAAO;EACjB,WAAW;EACX,SAAS,GAAG,aAAa,KAAK,IAAI,EAAE;EACpC,UAAU;EACV;EACA,UAAU;EACV;EACA,sBAAsB;EACtB,QAAQ;EACR,OAAO;EACP,aAAa;EACb,OAAO;EACP,WAAW;EACX;EACA;EACA,QAAQ;GACN,GAAG;GACH,cAAc,OAAO,WAAW,IAAI,OAAO;GAC3C,cAAc;EAChB;EACA,mBAAmB,KAAK;EACxB;CACF;AACF;;AAGA,SAAgB,8BAA8B,MAAoD;CAChG,OAAO;EACL,QAAQ,KAAK,UAAU,KAAK;EAC5B,YAAY,4BAA4B,IAAI;CAC9C;AACF"}
@@ -490,15 +490,14 @@ function parseSupervisorTree(src) {
490
490
  * run ended. Runtime's own record outranks every other source: `result.json` is
491
491
  * the `SupervisedResult` that `supervise()` returned, verbatim, and its `kind`
492
492
  * is the run's status. `failure.json` is the record Runtime writes when
493
- * `supervise()` threw before a result landed. The control-plane-era loops
494
- * documents (`state.json` `status`, `result.json` `sup_status`) stay readable
495
- * as named legacy sources, so a report always says which record it read.
493
+ * `supervise()` threw before a result landed. Runtime's result and failure
494
+ * records are the only terminal status contract; state is timing metadata.
496
495
  *
497
496
  * Pure: takes already-parsed documents and returns `Measured` values. The
498
497
  * analyzer and the rollout minter share it so a run never has two statuses.
499
498
  */
500
499
  /** The reason every terminal field reads `unavailable` when no store wrote one. */
501
- const NO_TERMINAL_RECORD = "no terminal record: Runtime result.json kind, Runtime failure.json, or legacy state.json / result.json status";
500
+ const NO_TERMINAL_RECORD = "no terminal record: Runtime result.json kind or Runtime failure.json";
502
501
  /** The status reported for a run whose directory holds Runtime's failure record and no result. */
503
502
  const RUNTIME_FAILED_STATUS = "failed";
504
503
  function str(value) {
@@ -516,7 +515,7 @@ function errorRecord(doc, source, earlierAttempt) {
516
515
  };
517
516
  }
518
517
  function readTerminalRecord(input) {
519
- const { state, result } = input;
518
+ const { result } = input;
520
519
  const resultKind = str(result?.kind);
521
520
  const settled = resultKind !== null && result !== null;
522
521
  const failureRecord = input.failure === null || input.failure === void 0 ? null : errorRecord(input.failure, "runtime-failure", settled);
@@ -541,22 +540,6 @@ function readTerminalRecord(input) {
541
540
  failure: unavailable("Runtime failure.json carries no error record"),
542
541
  completed: false
543
542
  };
544
- const legacyStateStatus = str(state?.status);
545
- if (legacyStateStatus !== null) return {
546
- supStatus: legacyStateStatus,
547
- supStatusSource: "legacy-state",
548
- supReason: null,
549
- failure: unavailable("legacy state.json records no failure document"),
550
- completed: legacyStateStatus === "completed"
551
- };
552
- const legacyResultStatus = str(result?.sup_status);
553
- if (legacyResultStatus !== null) return {
554
- supStatus: legacyResultStatus,
555
- supStatusSource: "legacy-result",
556
- supReason: null,
557
- failure: unavailable("legacy result.json records no failure document"),
558
- completed: legacyResultStatus === "completed"
559
- };
560
543
  return {
561
544
  supStatus: unavailable(NO_TERMINAL_RECORD),
562
545
  supStatusSource: unavailable(NO_TERMINAL_RECORD),
@@ -568,4 +551,4 @@ function readTerminalRecord(input) {
568
551
  //#endregion
569
552
  export { parseJson as a, workerSourceKey as c, SUPERVISOR_RUN_SCHEMA as d, isUnavailable as f, asRecord as i, NO_SOURCE_LIMITS as l, unavailable as m, RUNTIME_FAILED_STATUS as n, parseJsonl as o, showMeasured as p, readTerminalRecord as r, parseSupervisorTree as s, NO_TERMINAL_RECORD as t, SUPERVISOR_RUN_ROLLUP_SCHEMA as u };
570
553
 
571
- //# sourceMappingURL=terminal-record-BtPwKTSr.js.map
554
+ //# sourceMappingURL=terminal-record-BHocwFw1.js.map