@tangle-network/agent-eval 0.129.0 → 0.130.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.
- package/CHANGELOG.md +14 -0
- package/README.md +1 -0
- package/dist/active-curriculum-C4mk67HP.js +214 -0
- package/dist/active-curriculum-C4mk67HP.js.map +1 -0
- package/dist/adversarial-smnADNFS.d.ts +21 -0
- package/dist/adversarial-smnADNFS.d.ts.map +1 -0
- package/dist/analyst/index.d.ts +81 -2872
- package/dist/analyst/index.d.ts.map +1 -0
- package/dist/analyst/index.js +319 -360
- package/dist/analyst/index.js.map +1 -1
- package/dist/analyst-BkTS3C58.d.ts +89 -0
- package/dist/analyst-BkTS3C58.d.ts.map +1 -0
- package/dist/analyst-LsnNpSkm.js +152 -0
- package/dist/analyst-LsnNpSkm.js.map +1 -0
- package/dist/analyze-runs-C1CavBMk.js +1067 -0
- package/dist/analyze-runs-C1CavBMk.js.map +1 -0
- package/dist/analyze-runs-FsgYCinh.d.ts +72 -0
- package/dist/analyze-runs-FsgYCinh.d.ts.map +1 -0
- package/dist/attribute-vocabulary-DLJ6303h.d.ts +54 -0
- package/dist/attribute-vocabulary-DLJ6303h.d.ts.map +1 -0
- package/dist/authenticity/index.d.ts +81 -79
- package/dist/authenticity/index.d.ts.map +1 -0
- package/dist/authenticity/index.js +209 -193
- package/dist/authenticity/index.js.map +1 -1
- package/dist/baseline-HsBvw_dk.js +550 -0
- package/dist/baseline-HsBvw_dk.js.map +1 -0
- package/dist/baseline-hG3K85h4.d.ts +125 -0
- package/dist/baseline-hG3K85h4.d.ts.map +1 -0
- package/dist/belief-state/index.d.ts +448 -1188
- package/dist/belief-state/index.d.ts.map +1 -0
- package/dist/belief-state/index.js +1617 -1709
- package/dist/belief-state/index.js.map +1 -1
- package/dist/benchmarks/index.d.ts +2 -891
- package/dist/benchmarks/index.js +2 -60
- package/dist/benchmarks-DviOvUNr.js +754 -0
- package/dist/benchmarks-DviOvUNr.js.map +1 -0
- package/dist/builder-eval/index.d.ts +150 -662
- package/dist/builder-eval/index.d.ts.map +1 -0
- package/dist/builder-eval/index.js +356 -345
- package/dist/builder-eval/index.js.map +1 -1
- package/dist/calibration-CNWWA6K8.js +94 -0
- package/dist/calibration-CNWWA6K8.js.map +1 -0
- package/dist/campaign/index.d.ts +5 -6381
- package/dist/campaign/index.js +3 -213
- package/dist/campaign-CBKZvQ1H.js +3885 -0
- package/dist/campaign-CBKZvQ1H.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +164 -175
- package/dist/cli.js.map +1 -1
- package/dist/client-C97NMzqi.d.ts +581 -0
- package/dist/client-C97NMzqi.d.ts.map +1 -0
- package/dist/client-CYzbdJOZ.js +637 -0
- package/dist/client-CYzbdJOZ.js.map +1 -0
- package/dist/code-agent-session-BjkMTQ7H.js +1390 -0
- package/dist/code-agent-session-BjkMTQ7H.js.map +1 -0
- package/dist/code-agent-session-DqqgOJaz.d.ts +143 -0
- package/dist/code-agent-session-DqqgOJaz.d.ts.map +1 -0
- package/dist/concurrency-DIxRZF_J.js +85 -0
- package/dist/concurrency-DIxRZF_J.js.map +1 -0
- package/dist/contract/index.d.ts +645 -5565
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +1730 -1938
- package/dist/contract/index.js.map +1 -1
- package/dist/control.d.ts +3 -1030
- package/dist/control.js +2 -33
- package/dist/cost-ledger-DIgQUFZZ.js +801 -0
- package/dist/cost-ledger-DIgQUFZZ.js.map +1 -0
- package/dist/cost-ledger-Dye6jCgg.d.ts +236 -0
- package/dist/cost-ledger-Dye6jCgg.d.ts.map +1 -0
- package/dist/dataset-BvtnC8Dc.d.ts +115 -0
- package/dist/dataset-BvtnC8Dc.d.ts.map +1 -0
- package/dist/default-registry-C-vFCSEc.js +2579 -0
- package/dist/default-registry-C-vFCSEc.js.map +1 -0
- package/dist/default-registry-CNPo-Vsb.d.ts +540 -0
- package/dist/default-registry-CNPo-Vsb.d.ts.map +1 -0
- package/dist/emitter-CPBAhxum.js +266 -0
- package/dist/emitter-CPBAhxum.js.map +1 -0
- package/dist/emitter-DGQGoLyj.d.ts +113 -0
- package/dist/emitter-DGQGoLyj.d.ts.map +1 -0
- package/dist/errors-8YnH8WlF.js +64 -0
- package/dist/errors-8YnH8WlF.js.map +1 -0
- package/dist/errors-CEk209JS.d.ts +76 -0
- package/dist/errors-CEk209JS.d.ts.map +1 -0
- package/dist/eval-campaign-DEm6c8ru.js +349 -0
- package/dist/eval-campaign-DEm6c8ru.js.map +1 -0
- package/dist/execution-tracks-CpgFPpS5.js +93 -0
- package/dist/execution-tracks-CpgFPpS5.js.map +1 -0
- package/dist/exporters-q9iL-2Jf.js +148 -0
- package/dist/exporters-q9iL-2Jf.js.map +1 -0
- package/dist/extract-usage-BrQ8mCLX.js +155 -0
- package/dist/extract-usage-BrQ8mCLX.js.map +1 -0
- package/dist/failure-cluster-CqcvCcdR.d.ts +59 -0
- package/dist/failure-cluster-CqcvCcdR.d.ts.map +1 -0
- package/dist/feedback-trajectory-CVaeREXV.d.ts +340 -0
- package/dist/feedback-trajectory-CVaeREXV.d.ts.map +1 -0
- package/dist/fuzz.d.ts +320 -646
- package/dist/fuzz.d.ts.map +1 -0
- package/dist/fuzz.js +670 -618
- package/dist/fuzz.js.map +1 -1
- package/dist/hf-dataset-DBJXXoY1.js +763 -0
- package/dist/hf-dataset-DBJXXoY1.js.map +1 -0
- package/dist/hosted/index.d.ts +11 -831
- package/dist/hosted/index.d.ts.map +1 -0
- package/dist/hosted/index.js +2 -37
- package/dist/index-2JJSA6-r2.d.ts +926 -0
- package/dist/index-2JJSA6-r2.d.ts.map +1 -0
- package/dist/index-6N0aYmpW.d.ts +217 -0
- package/dist/index-6N0aYmpW.d.ts.map +1 -0
- package/dist/index-BAvgST_9.d.ts +131 -0
- package/dist/index-BAvgST_9.d.ts.map +1 -0
- package/dist/index-BvnJuTGD.d.ts +68 -0
- package/dist/index-BvnJuTGD.d.ts.map +1 -0
- package/dist/index-C61Wi7yg.d.ts +547 -0
- package/dist/index-C61Wi7yg.d.ts.map +1 -0
- package/dist/index-CAPUUKaM.d.ts +335 -0
- package/dist/index-CAPUUKaM.d.ts.map +1 -0
- package/dist/index-DE5fb3EC.d.ts +2244 -0
- package/dist/index-DE5fb3EC.d.ts.map +1 -0
- package/dist/index-DSC51roc.d.ts +102 -0
- package/dist/index-DSC51roc.d.ts.map +1 -0
- package/dist/index.d.ts +3755 -15555
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11182 -11216
- package/dist/index.js.map +1 -1
- package/dist/integrity-BzRbCHzi.js +424 -0
- package/dist/integrity-BzRbCHzi.js.map +1 -0
- package/dist/integrity-rmVhXWA7.d.ts +61 -0
- package/dist/integrity-rmVhXWA7.d.ts.map +1 -0
- package/dist/judge-calibration-DFtEMlde.d.ts +146 -0
- package/dist/judge-calibration-DFtEMlde.d.ts.map +1 -0
- package/dist/ledger-core/index.d.ts +2 -0
- package/dist/ledger-core/index.js +2 -0
- package/dist/ledger-core-DtZz1RG0.js +388 -0
- package/dist/ledger-core-DtZz1RG0.js.map +1 -0
- package/dist/llm-client--GR4JbZE.js +687 -0
- package/dist/llm-client--GR4JbZE.js.map +1 -0
- package/dist/llm-client-B_nIBlYo.d.ts +290 -0
- package/dist/llm-client-B_nIBlYo.d.ts.map +1 -0
- package/dist/matrix/index.d.ts +3 -155
- package/dist/matrix/index.js +2 -8
- package/dist/matrix-BzQnu2S6.js +270 -0
- package/dist/matrix-BzQnu2S6.js.map +1 -0
- package/dist/meta-eval/index.d.ts +4 -1027
- package/dist/meta-eval/index.js +393 -390
- package/dist/meta-eval/index.js.map +1 -1
- package/dist/metrics-C9YY1OcL.js +239 -0
- package/dist/metrics-C9YY1OcL.js.map +1 -0
- package/dist/mint-yN2M2eh0.js +201 -0
- package/dist/mint-yN2M2eh0.js.map +1 -0
- package/dist/multi-layer-verifier-BHY1gWAc.d.ts +138 -0
- package/dist/multi-layer-verifier-BHY1gWAc.d.ts.map +1 -0
- package/dist/multishot/index.d.ts +273 -480
- package/dist/multishot/index.d.ts.map +1 -0
- package/dist/multishot/index.js +595 -548
- package/dist/multishot/index.js.map +1 -1
- package/dist/off-policy-DvgzvtIx.js +220 -0
- package/dist/off-policy-DvgzvtIx.js.map +1 -0
- package/dist/off-policy-mskQw8Mb.d.ts +153 -0
- package/dist/off-policy-mskQw8Mb.d.ts.map +1 -0
- package/dist/openapi.json +1 -1
- package/dist/opencode-sqlite-BGrHeDu3.js +318 -0
- package/dist/opencode-sqlite-BGrHeDu3.js.map +1 -0
- package/dist/outcome-store-BYHIuO0e.d.ts +65 -0
- package/dist/outcome-store-BYHIuO0e.d.ts.map +1 -0
- package/dist/outcome-store-ChBKlTd_.js +75 -0
- package/dist/outcome-store-ChBKlTd_.js.map +1 -0
- package/dist/paired-arms-D9D0wXj2.js +260 -0
- package/dist/paired-arms-D9D0wXj2.js.map +1 -0
- package/dist/pipelines/index.d.ts +95 -532
- package/dist/pipelines/index.d.ts.map +1 -0
- package/dist/pipelines/index.js +497 -478
- package/dist/pipelines/index.js.map +1 -1
- package/dist/pre-registration-DakwTRXk.js +96 -0
- package/dist/pre-registration-DakwTRXk.js.map +1 -0
- package/dist/propose-review-control-LhIWGzHl.js +1458 -0
- package/dist/propose-review-control-LhIWGzHl.js.map +1 -0
- package/dist/query-CJ_DX8vl.d.ts +28 -0
- package/dist/query-CJ_DX8vl.d.ts.map +1 -0
- package/dist/query-Di7eEQ79.js +83 -0
- package/dist/query-Di7eEQ79.js.map +1 -0
- package/dist/raw-provider-sink-BQd7mzyT.js +201 -0
- package/dist/raw-provider-sink-BQd7mzyT.js.map +1 -0
- package/dist/raw-provider-sink-BU29Sh8h.d.ts +134 -0
- package/dist/raw-provider-sink-BU29Sh8h.d.ts.map +1 -0
- package/dist/redact-7Aq1ukl-.js +107 -0
- package/dist/redact-7Aq1ukl-.js.map +1 -0
- package/dist/release-report-Cz9NKH39.js +603 -0
- package/dist/release-report-Cz9NKH39.js.map +1 -0
- package/dist/release-report-mvB2G4_J.d.ts +244 -0
- package/dist/release-report-mvB2G4_J.d.ts.map +1 -0
- package/dist/replay-GnyotH0J.js +1741 -0
- package/dist/replay-GnyotH0J.js.map +1 -0
- package/dist/replay-OoidtG1E.d.ts +749 -0
- package/dist/replay-OoidtG1E.d.ts.map +1 -0
- package/dist/reporting.d.ts +6 -1312
- package/dist/reporting.js +6 -51
- package/dist/researcher-CwTdwXG1.d.ts +314 -0
- package/dist/researcher-CwTdwXG1.d.ts.map +1 -0
- package/dist/reward-hacking-eAnOsynk.d.ts +224 -0
- package/dist/reward-hacking-eAnOsynk.d.ts.map +1 -0
- package/dist/reward-hacking-qipEpKvY.js +596 -0
- package/dist/reward-hacking-qipEpKvY.js.map +1 -0
- package/dist/reward-nw2xZGZG.js +137 -0
- package/dist/reward-nw2xZGZG.js.map +1 -0
- package/dist/rl.d.ts +760 -4010
- package/dist/rl.d.ts.map +1 -0
- package/dist/rl.js +2325 -1958
- package/dist/rl.js.map +1 -1
- package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
- package/dist/rollout/index.d.ts +3 -2087
- package/dist/rollout/index.js +8 -168
- package/dist/rollout-BOYjemfR.js +624 -0
- package/dist/rollout-BOYjemfR.js.map +1 -0
- package/dist/rubric-predictive-validity-B3xmbmS1.js +141 -0
- package/dist/rubric-predictive-validity-B3xmbmS1.js.map +1 -0
- package/dist/rubric-predictive-validity-Ku_clp_1.d.ts +74 -0
- package/dist/rubric-predictive-validity-Ku_clp_1.d.ts.map +1 -0
- package/dist/run-evidence-ClRX_8A9.d.ts +225 -0
- package/dist/run-evidence-ClRX_8A9.d.ts.map +1 -0
- package/dist/run-record-BuoE80Dq.js +467 -0
- package/dist/{chunk-56TAVBOK.js.map → run-record-BuoE80Dq.js.map} +1 -1
- package/dist/run-record-CnZu_gjl.d.ts +357 -0
- package/dist/run-record-CnZu_gjl.d.ts.map +1 -0
- package/dist/run-score-iEEAWiBY.js +41 -0
- package/dist/run-score-iEEAWiBY.js.map +1 -0
- package/dist/runtime-trajectory-1gyaTOoC.js +93 -0
- package/dist/runtime-trajectory-1gyaTOoC.js.map +1 -0
- package/dist/runtime-trajectory-BvSZcCHD.d.ts +50 -0
- package/dist/runtime-trajectory-BvSZcCHD.d.ts.map +1 -0
- package/dist/schema-BtVldJ3T.d.ts +206 -0
- package/dist/schema-BtVldJ3T.d.ts.map +1 -0
- package/dist/schema-C6DW4ZHR.js +821 -0
- package/dist/schema-C6DW4ZHR.js.map +1 -0
- package/dist/schema-CRhEY1SO.js +69 -0
- package/dist/schema-CRhEY1SO.js.map +1 -0
- package/dist/schema-Cef2cFmb.d.ts +408 -0
- package/dist/schema-Cef2cFmb.d.ts.map +1 -0
- package/dist/semantic-concept-judge-B6cWNJ2K.js +725 -0
- package/dist/semantic-concept-judge-B6cWNJ2K.js.map +1 -0
- package/dist/sequential-Br0mAPHA.js +148 -0
- package/dist/sequential-Br0mAPHA.js.map +1 -0
- package/dist/sequential-CYwq6Ff_.d.ts +141 -0
- package/dist/sequential-CYwq6Ff_.d.ts.map +1 -0
- package/dist/series-convergence-CjO2QdRW.js +43 -0
- package/dist/series-convergence-CjO2QdRW.js.map +1 -0
- package/dist/series-convergence-ofsqPWhs.d.ts +35 -0
- package/dist/series-convergence-ofsqPWhs.d.ts.map +1 -0
- package/dist/server-m5D9cvnG.js +1040 -0
- package/dist/server-m5D9cvnG.js.map +1 -0
- package/dist/skill-usage-C_pXm7lP.d.ts +534 -0
- package/dist/skill-usage-C_pXm7lP.d.ts.map +1 -0
- package/dist/skillopt-optimization-method-B7wX7XkF.d.ts +1739 -0
- package/dist/skillopt-optimization-method-B7wX7XkF.d.ts.map +1 -0
- package/dist/skillopt-optimization-method-D4ODwFVV.js +7712 -0
- package/dist/skillopt-optimization-method-D4ODwFVV.js.map +1 -0
- package/dist/statistics-Cmj6nynr.d.ts +514 -0
- package/dist/statistics-Cmj6nynr.d.ts.map +1 -0
- package/dist/statistics-CnnxdpOg.js +1437 -0
- package/dist/statistics-CnnxdpOg.js.map +1 -0
- package/dist/store-CT9YIIve.d.ts +117 -0
- package/dist/store-CT9YIIve.d.ts.map +1 -0
- package/dist/store-CxJry_cs.d.ts +229 -0
- package/dist/store-CxJry_cs.d.ts.map +1 -0
- package/dist/storyboard/index.d.ts +84 -203
- package/dist/storyboard/index.d.ts.map +1 -0
- package/dist/storyboard/index.js +609 -542
- package/dist/storyboard/index.js.map +1 -1
- package/dist/summary-report-BNs5nmXI.js +862 -0
- package/dist/summary-report-BNs5nmXI.js.map +1 -0
- package/dist/summary-report-Cj9gdw4i.d.ts +407 -0
- package/dist/summary-report-Cj9gdw4i.d.ts.map +1 -0
- package/dist/supervisor-run/index.d.ts +2 -959
- package/dist/supervisor-run/index.js +2 -65
- package/dist/supervisor-run-_lnTLM3z.js +1679 -0
- package/dist/supervisor-run-_lnTLM3z.js.map +1 -0
- package/dist/task-failure-attributes-CQZlB3et.js +311 -0
- package/dist/task-failure-attributes-CQZlB3et.js.map +1 -0
- package/dist/test-graded-scenario-BsqWLmPt.js +318 -0
- package/dist/test-graded-scenario-BsqWLmPt.js.map +1 -0
- package/dist/test-graded-scenario-D1TaI2va.d.ts +141 -0
- package/dist/test-graded-scenario-D1TaI2va.d.ts.map +1 -0
- package/dist/tools-BmuN627J.js +1085 -0
- package/dist/tools-BmuN627J.js.map +1 -0
- package/dist/trace-attributes.d.ts +2 -52
- package/dist/trace-attributes.js +131 -61
- package/dist/trace-attributes.js.map +1 -1
- package/dist/traces.d.ts +12 -2365
- package/dist/traces.js +12 -252
- package/dist/trajectory-D_7rLrvE.js +56 -0
- package/dist/trajectory-D_7rLrvE.js.map +1 -0
- package/dist/types-DGsxbAEd.d.ts +387 -0
- package/dist/types-DGsxbAEd.d.ts.map +1 -0
- package/dist/types-k9tZGKUg.d.ts +640 -0
- package/dist/types-k9tZGKUg.d.ts.map +1 -0
- package/dist/verdict-Dps8_okt.d.ts +37 -0
- package/dist/verdict-Dps8_okt.d.ts.map +1 -0
- package/dist/wire/index.d.ts +702 -1173
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/wire/index.js +2 -81
- package/package.json +17 -9
- package/dist/benchmarks/index.js.map +0 -1
- package/dist/campaign/index.js.map +0 -1
- package/dist/chunk-2QU3YOPR.js +0 -7374
- package/dist/chunk-2QU3YOPR.js.map +0 -1
- package/dist/chunk-3OCR4R5I.js +0 -728
- package/dist/chunk-3OCR4R5I.js.map +0 -1
- package/dist/chunk-3RF76KTD.js +0 -84
- package/dist/chunk-3RF76KTD.js.map +0 -1
- package/dist/chunk-56TAVBOK.js +0 -698
- package/dist/chunk-5DTSBUL2.js +0 -159
- package/dist/chunk-5DTSBUL2.js.map +0 -1
- package/dist/chunk-7FO3TNPI.js +0 -232
- package/dist/chunk-7FO3TNPI.js.map +0 -1
- package/dist/chunk-7ZZMD7UK.js +0 -386
- package/dist/chunk-7ZZMD7UK.js.map +0 -1
- package/dist/chunk-BOD4O7OF.js +0 -40
- package/dist/chunk-BOD4O7OF.js.map +0 -1
- package/dist/chunk-BSO5JDQH.js +0 -2335
- package/dist/chunk-BSO5JDQH.js.map +0 -1
- package/dist/chunk-C6LXANRU.js +0 -1550
- package/dist/chunk-C6LXANRU.js.map +0 -1
- package/dist/chunk-DODXQREJ.js +0 -752
- package/dist/chunk-DODXQREJ.js.map +0 -1
- package/dist/chunk-DRYIUNWY.js +0 -622
- package/dist/chunk-DRYIUNWY.js.map +0 -1
- package/dist/chunk-E7QXT7SX.js +0 -183
- package/dist/chunk-E7QXT7SX.js.map +0 -1
- package/dist/chunk-EG66UGL4.js +0 -341
- package/dist/chunk-EG66UGL4.js.map +0 -1
- package/dist/chunk-FXTVJPYD.js +0 -576
- package/dist/chunk-FXTVJPYD.js.map +0 -1
- package/dist/chunk-G7MGMCZD.js +0 -153
- package/dist/chunk-G7MGMCZD.js.map +0 -1
- package/dist/chunk-GGE4NNQT.js +0 -65
- package/dist/chunk-GGE4NNQT.js.map +0 -1
- package/dist/chunk-H23X7XKK.js +0 -181
- package/dist/chunk-H23X7XKK.js.map +0 -1
- package/dist/chunk-HHWE3POT.js +0 -94
- package/dist/chunk-HHWE3POT.js.map +0 -1
- package/dist/chunk-HPWUNB47.js +0 -289
- package/dist/chunk-HPWUNB47.js.map +0 -1
- package/dist/chunk-IYCLP2N2.js +0 -766
- package/dist/chunk-IYCLP2N2.js.map +0 -1
- package/dist/chunk-JHCHEVET.js +0 -274
- package/dist/chunk-JHCHEVET.js.map +0 -1
- package/dist/chunk-JQSF5DQT.js +0 -701
- package/dist/chunk-JQSF5DQT.js.map +0 -1
- package/dist/chunk-K4DBDHLK.js +0 -158
- package/dist/chunk-K4DBDHLK.js.map +0 -1
- package/dist/chunk-K6N6XJJX.js +0 -306
- package/dist/chunk-K6N6XJJX.js.map +0 -1
- package/dist/chunk-M4YBQKIJ.js +0 -1040
- package/dist/chunk-M4YBQKIJ.js.map +0 -1
- package/dist/chunk-MA6HLL3S.js +0 -65
- package/dist/chunk-MA6HLL3S.js.map +0 -1
- package/dist/chunk-MAZ26DC7.js +0 -99
- package/dist/chunk-MAZ26DC7.js.map +0 -1
- package/dist/chunk-NPCTHQIO.js +0 -91
- package/dist/chunk-NPCTHQIO.js.map +0 -1
- package/dist/chunk-NY44NC4A.js +0 -1056
- package/dist/chunk-NY44NC4A.js.map +0 -1
- package/dist/chunk-OIUOT4QD.js +0 -44
- package/dist/chunk-OIUOT4QD.js.map +0 -1
- package/dist/chunk-ONWEPEDO.js +0 -57
- package/dist/chunk-ONWEPEDO.js.map +0 -1
- package/dist/chunk-OWN5NPMC.js +0 -152
- package/dist/chunk-OWN5NPMC.js.map +0 -1
- package/dist/chunk-P6FYH6K4.js +0 -1161
- package/dist/chunk-P6FYH6K4.js.map +0 -1
- package/dist/chunk-PC4UYEBM.js +0 -166
- package/dist/chunk-PC4UYEBM.js.map +0 -1
- package/dist/chunk-PC5DOSM7.js +0 -579
- package/dist/chunk-PC5DOSM7.js.map +0 -1
- package/dist/chunk-PXE2VKMX.js +0 -140
- package/dist/chunk-PXE2VKMX.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-QB6BDBP2.js +0 -4464
- package/dist/chunk-QB6BDBP2.js.map +0 -1
- package/dist/chunk-RXHCETDZ.js +0 -536
- package/dist/chunk-RXHCETDZ.js.map +0 -1
- package/dist/chunk-RZTMDUO7.js +0 -49
- package/dist/chunk-RZTMDUO7.js.map +0 -1
- package/dist/chunk-SFLLL76A.js +0 -669
- package/dist/chunk-SFLLL76A.js.map +0 -1
- package/dist/chunk-SZLVEKMJ.js +0 -1446
- package/dist/chunk-SZLVEKMJ.js.map +0 -1
- package/dist/chunk-T4SQEITX.js +0 -95
- package/dist/chunk-T4SQEITX.js.map +0 -1
- package/dist/chunk-T6RLYGAD.js +0 -158
- package/dist/chunk-T6RLYGAD.js.map +0 -1
- package/dist/chunk-TJVT4QFF.js +0 -911
- package/dist/chunk-TJVT4QFF.js.map +0 -1
- package/dist/chunk-TQ7LNKZ3.js +0 -136
- package/dist/chunk-TQ7LNKZ3.js.map +0 -1
- package/dist/chunk-U4L7JRPZ.js +0 -1706
- package/dist/chunk-U4L7JRPZ.js.map +0 -1
- package/dist/chunk-U4PHLT2N.js +0 -419
- package/dist/chunk-U4PHLT2N.js.map +0 -1
- package/dist/chunk-VCZ5FQYW.js +0 -928
- package/dist/chunk-VCZ5FQYW.js.map +0 -1
- package/dist/chunk-VI2UW6B6.js +0 -162
- package/dist/chunk-VI2UW6B6.js.map +0 -1
- package/dist/chunk-VQMK5FMP.js +0 -247
- package/dist/chunk-VQMK5FMP.js.map +0 -1
- package/dist/chunk-WGXIEX7P.js +0 -116
- package/dist/chunk-WGXIEX7P.js.map +0 -1
- package/dist/chunk-WVATSFCP.js +0 -1553
- package/dist/chunk-WVATSFCP.js.map +0 -1
- package/dist/chunk-X4YIBDER.js +0 -1662
- package/dist/chunk-X4YIBDER.js.map +0 -1
- package/dist/chunk-YQN4ICPP.js +0 -355
- package/dist/chunk-YQN4ICPP.js.map +0 -1
- package/dist/chunk-ZET2UAYW.js +0 -89
- package/dist/chunk-ZET2UAYW.js.map +0 -1
- package/dist/chunk-ZHTZ4EYI.js +0 -1212
- package/dist/chunk-ZHTZ4EYI.js.map +0 -1
- package/dist/control.js.map +0 -1
- package/dist/hosted/index.js.map +0 -1
- package/dist/matrix/index.js.map +0 -1
- package/dist/reporting.js.map +0 -1
- package/dist/rollout/index.js.map +0 -1
- package/dist/run-campaign-OJJ7CZF4.js +0 -18
- package/dist/run-campaign-OJJ7CZF4.js.map +0 -1
- package/dist/supervisor-run/index.js.map +0 -1
- package/dist/traces.js.map +0 -1
- package/dist/wire/index.js.map +0 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
//#region src/rl/off-policy.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Off-policy evaluation primitives.
|
|
4
|
+
*
|
|
5
|
+
* Standard inverse-probability-weighted (IPS), self-normalized
|
|
6
|
+
* importance-weighted (SNIPS), and doubly-robust (DR) estimators for the
|
|
7
|
+
* value of a *target* policy given trajectories collected under a
|
|
8
|
+
* *behavior* policy. This is the canonical RL eval task: "we have last
|
|
9
|
+
* week's runs, we changed the policy — how would the new one do without
|
|
10
|
+
* re-running?"
|
|
11
|
+
*
|
|
12
|
+
* The math here is textbook (Dudík, Langford, Li 2011 for DR; Swaminathan
|
|
13
|
+
* & Joachims 2015 for SNIPS) but the *application* to LLM-agent
|
|
14
|
+
* evaluation needs care:
|
|
15
|
+
*
|
|
16
|
+
* - The "policy" is the (prompt, tool config, model snapshot) triple.
|
|
17
|
+
* Two policies have the same probability over an action *iff* their
|
|
18
|
+
* LLM call would emit the same token with the same probability —
|
|
19
|
+
* which is generally unknowable without the model log-probs.
|
|
20
|
+
* - For LLM agents, propensity scores must be supplied by the caller
|
|
21
|
+
* (logged in the trace, recovered from token log-probs, or estimated
|
|
22
|
+
* via a learned propensity model). We do NOT estimate propensity here.
|
|
23
|
+
* - Doubly-robust requires two outputs from a Q-function: its prediction
|
|
24
|
+
* for the logged action and its expectation under the target policy.
|
|
25
|
+
* Consumers compute these with a tabular estimate, regression fit, or
|
|
26
|
+
* learned reward model before constructing the trajectories.
|
|
27
|
+
*
|
|
28
|
+
* Bias / variance tradeoffs:
|
|
29
|
+
* - IPS: unbiased; high variance for small overlap, infinite variance
|
|
30
|
+
* when target has support outside behavior.
|
|
31
|
+
* - SNIPS: lower variance, slight bias; usually preferred in practice.
|
|
32
|
+
* - DR: doubly-robust — unbiased if either propensity OR Q-function is
|
|
33
|
+
* correct. Lowest practical variance when Q is decent. Use this.
|
|
34
|
+
*
|
|
35
|
+
* Caveat the panel will land: on the LLM-agent setting, propensity scores
|
|
36
|
+
* recovered from token log-probs are noisy, the action space is enormous,
|
|
37
|
+
* and overlap is often poor. These estimators are useful but not magic;
|
|
38
|
+
* complement with `replayCampaign` (exact replay where the request hashes
|
|
39
|
+
* match) for high-confidence answers and OPE for the gap.
|
|
40
|
+
*/
|
|
41
|
+
interface OffPolicyTrajectory {
|
|
42
|
+
/** Stable id, for traceability through the dataset. */
|
|
43
|
+
runId: string;
|
|
44
|
+
/** Reward observed under the behavior policy (the realized outcome). */
|
|
45
|
+
reward: number;
|
|
46
|
+
/**
|
|
47
|
+
* Behavior-policy probability of the action that was taken. For LLM
|
|
48
|
+
* agents this is typically `exp(sum(token_log_probs))` over the chosen
|
|
49
|
+
* trajectory. Must be in (0, 1].
|
|
50
|
+
*/
|
|
51
|
+
behaviorProb: number;
|
|
52
|
+
/**
|
|
53
|
+
* Target-policy probability of the same action. For replay-style
|
|
54
|
+
* counterfactual evaluation this is what the *new* policy would have
|
|
55
|
+
* assigned to the *old* trajectory. Must be in [0, 1].
|
|
56
|
+
*/
|
|
57
|
+
targetProb: number;
|
|
58
|
+
/**
|
|
59
|
+
* Model-based reward prediction for the action selected by the behavior
|
|
60
|
+
* policy: `Q_hat(context, loggedAction)`. Supply this together with
|
|
61
|
+
* `vHatTarget` for contextual-bandit doubly-robust estimation.
|
|
62
|
+
*/
|
|
63
|
+
qHatChosen?: number | null;
|
|
64
|
+
/**
|
|
65
|
+
* Expected model-based reward under the target policy:
|
|
66
|
+
* `sum_action targetPolicy(action | context) * Q_hat(context, action)`.
|
|
67
|
+
* Supply this together with `qHatChosen`. For an honest evaluation, both
|
|
68
|
+
* values must come from a model cross-fitted or trained outside this row.
|
|
69
|
+
*/
|
|
70
|
+
vHatTarget?: number | null;
|
|
71
|
+
}
|
|
72
|
+
interface OffPolicyContributionCounts {
|
|
73
|
+
/** Contributions using the contextual-bandit doubly-robust formula. */
|
|
74
|
+
dr: number;
|
|
75
|
+
/** Contributions using exact IPS because no reward-model estimate was supplied. */
|
|
76
|
+
ipsFallback: number;
|
|
77
|
+
}
|
|
78
|
+
interface OffPolicyEstimate {
|
|
79
|
+
/** Estimated value of the target policy. */
|
|
80
|
+
value: number;
|
|
81
|
+
/** Standard error of the estimate. */
|
|
82
|
+
standardError: number;
|
|
83
|
+
/** Effective sample size (Kong 1992). Lower = more reliance on a few high-weight samples. */
|
|
84
|
+
effectiveSampleSize: number;
|
|
85
|
+
/** Number of trajectories used. */
|
|
86
|
+
n: number;
|
|
87
|
+
/**
|
|
88
|
+
* Diagnostic: maximum importance weight observed. Large values (>>10x
|
|
89
|
+
* mean) are a red flag — variance is dominated by a few outliers.
|
|
90
|
+
*/
|
|
91
|
+
maxImportanceWeight: number;
|
|
92
|
+
/** Populated by `doublyRobust` to expose which formula each row used. */
|
|
93
|
+
contributionCounts?: OffPolicyContributionCounts;
|
|
94
|
+
}
|
|
95
|
+
interface OffPolicyOptions {
|
|
96
|
+
/**
|
|
97
|
+
* Cap importance weights at this value (Ionides 2008 truncated IS) to
|
|
98
|
+
* trade unbiasedness for variance reduction. Default `Infinity` (no cap).
|
|
99
|
+
* Set e.g. `10` for stable estimates when the policies are close.
|
|
100
|
+
*/
|
|
101
|
+
weightCap?: number;
|
|
102
|
+
/** Reward clipping range. Default `[0, 1]`. */
|
|
103
|
+
rewardClip?: {
|
|
104
|
+
low: number;
|
|
105
|
+
high: number;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Inverse Probability Weighting (Horvitz-Thompson). Unbiased estimator
|
|
110
|
+
* of E[reward under target policy]. Variance scales with the spread of
|
|
111
|
+
* target/behavior ratios.
|
|
112
|
+
*/
|
|
113
|
+
declare function inverseProbabilityWeighting(trajectories: OffPolicyTrajectory[], opts?: OffPolicyOptions): OffPolicyEstimate;
|
|
114
|
+
/**
|
|
115
|
+
* Self-Normalized Importance Sampling. Lower variance than vanilla IPS at
|
|
116
|
+
* the cost of small bias (vanishing as N grows). The right default for
|
|
117
|
+
* LLM-agent evaluation where overlap is often poor.
|
|
118
|
+
*/
|
|
119
|
+
declare function selfNormalizedImportanceWeighting(trajectories: OffPolicyTrajectory[], opts?: OffPolicyOptions): OffPolicyEstimate;
|
|
120
|
+
/**
|
|
121
|
+
* Doubly-robust off-policy estimator (Dudík, Langford, Li 2011).
|
|
122
|
+
*
|
|
123
|
+
* V_DR = (1/N) * sum_i [ v_hat_target_i
|
|
124
|
+
* + (target_prob_i / behavior_prob_i) * (r_i - q_hat_chosen_i) ]
|
|
125
|
+
*
|
|
126
|
+
* Unbiased if EITHER:
|
|
127
|
+
* - the importance ratios are correct (IPS-style validity), OR
|
|
128
|
+
* - the Q-hat function is correct (model-based validity).
|
|
129
|
+
*
|
|
130
|
+
* In practice both are imperfect, but the residual bias is the *product*
|
|
131
|
+
* of both errors — much smaller than either alone. This is why DR is the
|
|
132
|
+
* default in production OPE pipelines.
|
|
133
|
+
*
|
|
134
|
+
* `qHatChosen` and `vHatTarget` must be supplied together. Rows with neither
|
|
135
|
+
* use the exact IPS contribution. `contributionCounts` makes the mix explicit
|
|
136
|
+
* in the result.
|
|
137
|
+
* Callers must cross-fit the Q-function or train it on independent rows;
|
|
138
|
+
* fitting and evaluating Q on the same outcomes leaks the answer.
|
|
139
|
+
*/
|
|
140
|
+
declare function doublyRobust(trajectories: OffPolicyTrajectory[], opts?: OffPolicyOptions): OffPolicyEstimate;
|
|
141
|
+
/**
|
|
142
|
+
* Convenience: run all three estimators and return them side-by-side.
|
|
143
|
+
* The recommended diagnostic — agreement across estimators is a much
|
|
144
|
+
* stronger signal than any single one.
|
|
145
|
+
*/
|
|
146
|
+
declare function offPolicyEstimateAll(trajectories: OffPolicyTrajectory[], opts?: OffPolicyOptions): {
|
|
147
|
+
ips: OffPolicyEstimate;
|
|
148
|
+
snips: OffPolicyEstimate;
|
|
149
|
+
dr: OffPolicyEstimate;
|
|
150
|
+
};
|
|
151
|
+
//#endregion
|
|
152
|
+
export { doublyRobust as a, selfNormalizedImportanceWeighting as c, OffPolicyTrajectory as i, OffPolicyEstimate as n, inverseProbabilityWeighting as o, OffPolicyOptions as r, offPolicyEstimateAll as s, OffPolicyContributionCounts as t };
|
|
153
|
+
//# sourceMappingURL=off-policy-mskQw8Mb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"off-policy-mskQw8Mb.d.ts","names":[],"sources":["../src/rl/off-policy.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA0CiB;;EAEf;;EAEA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;;EAOA;;UAGe;;EAEf;;EAEA;;UAGe;;EAEf;;EAEA;;EAEA;;EAEA;;;;;EAKA;;EAEA,qBAAqB;;UAGN;;;;;;EAMf;;EAEA;IAAe;IAAa;;;;;;;;iBAQd,4BACd,cAAc,uBACd,OAAM,mBACL;;;;;;iBA4Ca,kCACd,cAAc,uBACd,OAAM,mBACL;;;;;;;;;;;;;;;;;;;;;iBAwDa,aACd,cAAc,uBACd,OAAM,mBACL;;;;;;iBAuEa,qBACd,cAAc,uBACd,OAAM;EACH,KAAK;EAAmB,OAAO;EAAmB,IAAI"}
|
package/dist/openapi.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"openapi": "3.1.0",
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "@tangle-network/agent-eval — wire protocol",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.130.0",
|
|
6
6
|
"description": "HTTP and stdio RPC interface to agent-eval. The TypeScript runtime is the source of truth; this spec is the contract that cross-language clients (Python, Rust, Go) generate from.\n\nWire-protocol version: 1.0.0. Bumps on breaking changes to request/response schemas.",
|
|
7
7
|
"contact": {
|
|
8
8
|
"name": "Tangle Network",
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
//#region src/rollout/readers/claude-jsonl.ts
|
|
6
|
+
/**
|
|
7
|
+
* Backfill reader over Claude Code project transcripts
|
|
8
|
+
* (~/.claude/projects/<cwd-slug>/<sessionId>.jsonl) → canonical
|
|
9
|
+
* chat-with-tools messages plus per-session token usage.
|
|
10
|
+
*
|
|
11
|
+
* Transcript lines consumed: type:"user" (string content or content blocks —
|
|
12
|
+
* text + tool_result) and type:"assistant" (content blocks — thinking, text,
|
|
13
|
+
* tool_use; message.usage carries tokens). Sidechain lines (isSidechain=true,
|
|
14
|
+
* subagent threads) are separate invocations and are excluded from the main
|
|
15
|
+
* transcript. Everything else (queue-operation, attachment, last-prompt…) is
|
|
16
|
+
* transport metadata, not conversation.
|
|
17
|
+
*/
|
|
18
|
+
const DEFAULT_CLAUDE_PROJECTS_DIR = join(homedir(), ".claude", "projects");
|
|
19
|
+
/** Claude Code's project-directory slug for a working directory. */
|
|
20
|
+
function claudeProjectSlug(cwd) {
|
|
21
|
+
return cwd.replace(/[^a-zA-Z0-9-]/g, "-");
|
|
22
|
+
}
|
|
23
|
+
/** Transcript files recorded for sessions launched from `cwd`. */
|
|
24
|
+
async function findClaudeTranscripts(cwd, projectsDir = DEFAULT_CLAUDE_PROJECTS_DIR) {
|
|
25
|
+
const dir = join(projectsDir, claudeProjectSlug(cwd));
|
|
26
|
+
return (await readdir(dir).catch(() => [])).filter((n) => n.endsWith(".jsonl")).sort().map((n) => ({
|
|
27
|
+
sessionId: n.replace(/\.jsonl$/, ""),
|
|
28
|
+
path: join(dir, n)
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
const isRecord$1 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
32
|
+
/** Parse transcript jsonl text into conversation lines. Non-conversation lines are dropped. */
|
|
33
|
+
function parseClaudeEntries(raw) {
|
|
34
|
+
const out = [];
|
|
35
|
+
for (const line of raw.split("\n")) {
|
|
36
|
+
if (!line.trim()) continue;
|
|
37
|
+
let entry;
|
|
38
|
+
try {
|
|
39
|
+
const parsed = JSON.parse(line);
|
|
40
|
+
if (!isRecord$1(parsed)) continue;
|
|
41
|
+
entry = parsed;
|
|
42
|
+
} catch {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (entry.type !== "user" && entry.type !== "assistant") continue;
|
|
46
|
+
const message = entry.message;
|
|
47
|
+
if (!isRecord$1(message)) continue;
|
|
48
|
+
out.push({
|
|
49
|
+
type: entry.type,
|
|
50
|
+
timestamp: typeof entry.timestamp === "string" ? entry.timestamp : null,
|
|
51
|
+
message,
|
|
52
|
+
toolUseResult: entry.toolUseResult,
|
|
53
|
+
isSidechain: entry.isSidechain === true,
|
|
54
|
+
agentId: typeof entry.agentId === "string" ? entry.agentId : null
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
function blockText(content) {
|
|
60
|
+
if (typeof content === "string") return content;
|
|
61
|
+
if (!Array.isArray(content)) return "";
|
|
62
|
+
return content.filter((b) => isRecord$1(b) && b.type === "text" && typeof b.text === "string").map((b) => b.text).join("\n");
|
|
63
|
+
}
|
|
64
|
+
/** Parse one transcript jsonl into canonical messages + usage totals. */
|
|
65
|
+
async function readClaudeTranscript(path, options = {}) {
|
|
66
|
+
return transcriptFromEntries(parseClaudeEntries(await readFile(path, "utf8")), options);
|
|
67
|
+
}
|
|
68
|
+
/** The messages+usage projection of already-parsed entries. */
|
|
69
|
+
function transcriptFromEntries(entries, options = {}) {
|
|
70
|
+
const wantSidechain = options.includeSidechain === true;
|
|
71
|
+
const messages = [];
|
|
72
|
+
const usage = {
|
|
73
|
+
tokensIn: 0,
|
|
74
|
+
tokensOut: 0,
|
|
75
|
+
cacheRead: 0,
|
|
76
|
+
cacheWrite: 0
|
|
77
|
+
};
|
|
78
|
+
let startedAt = null;
|
|
79
|
+
let endedAt = null;
|
|
80
|
+
let model = null;
|
|
81
|
+
let lastAssistantApiId = null;
|
|
82
|
+
let lastAssistantIndex = -1;
|
|
83
|
+
for (const entry of entries) {
|
|
84
|
+
if (entry.isSidechain !== wantSidechain) continue;
|
|
85
|
+
const message = entry.message;
|
|
86
|
+
if (entry.timestamp !== null) {
|
|
87
|
+
if (startedAt === null) startedAt = entry.timestamp;
|
|
88
|
+
endedAt = entry.timestamp;
|
|
89
|
+
}
|
|
90
|
+
if (entry.type === "user") {
|
|
91
|
+
lastAssistantApiId = null;
|
|
92
|
+
lastAssistantIndex = -1;
|
|
93
|
+
const content = message.content;
|
|
94
|
+
if (typeof content === "string") {
|
|
95
|
+
messages.push({
|
|
96
|
+
role: "user",
|
|
97
|
+
content
|
|
98
|
+
});
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (!Array.isArray(content)) continue;
|
|
102
|
+
let userText = "";
|
|
103
|
+
for (const block of content) {
|
|
104
|
+
if (!isRecord$1(block)) continue;
|
|
105
|
+
if (block.type === "tool_result" && typeof block.tool_use_id === "string") messages.push({
|
|
106
|
+
role: "tool",
|
|
107
|
+
tool_call_id: block.tool_use_id,
|
|
108
|
+
content: blockText(block.content) || (typeof block.content === "string" ? block.content : "")
|
|
109
|
+
});
|
|
110
|
+
else if (block.type === "text" && typeof block.text === "string") userText += (userText.length > 0 ? "\n" : "") + block.text;
|
|
111
|
+
}
|
|
112
|
+
if (userText.length > 0) messages.push({
|
|
113
|
+
role: "user",
|
|
114
|
+
content: userText
|
|
115
|
+
});
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (typeof message.model === "string") model = message.model;
|
|
119
|
+
const apiId = typeof message.id === "string" ? message.id : null;
|
|
120
|
+
const continuesTurn = apiId !== null && apiId === lastAssistantApiId && lastAssistantIndex >= 0;
|
|
121
|
+
const msgUsage = message.usage;
|
|
122
|
+
if (isRecord$1(msgUsage) && !continuesTurn) {
|
|
123
|
+
usage.tokensIn += typeof msgUsage.input_tokens === "number" ? msgUsage.input_tokens : 0;
|
|
124
|
+
usage.tokensOut += typeof msgUsage.output_tokens === "number" ? msgUsage.output_tokens : 0;
|
|
125
|
+
usage.cacheRead += typeof msgUsage.cache_read_input_tokens === "number" ? msgUsage.cache_read_input_tokens : 0;
|
|
126
|
+
usage.cacheWrite += typeof msgUsage.cache_creation_input_tokens === "number" ? msgUsage.cache_creation_input_tokens : 0;
|
|
127
|
+
}
|
|
128
|
+
const content = message.content;
|
|
129
|
+
if (!Array.isArray(content)) continue;
|
|
130
|
+
let reasoning = "";
|
|
131
|
+
let text = "";
|
|
132
|
+
const toolCalls = [];
|
|
133
|
+
for (const block of content) {
|
|
134
|
+
if (!isRecord$1(block)) continue;
|
|
135
|
+
if (block.type === "thinking" && typeof block.thinking === "string" && block.thinking.length > 0) reasoning += (reasoning.length > 0 ? "\n" : "") + block.thinking;
|
|
136
|
+
else if (block.type === "text" && typeof block.text === "string") text += (text.length > 0 ? "\n" : "") + block.text;
|
|
137
|
+
else if (block.type === "tool_use" && typeof block.id === "string") toolCalls.push({
|
|
138
|
+
id: block.id,
|
|
139
|
+
type: "function",
|
|
140
|
+
function: {
|
|
141
|
+
name: typeof block.name === "string" ? block.name : "unknown",
|
|
142
|
+
arguments: JSON.stringify(block.input ?? {})
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if (reasoning.length === 0 && text.length === 0 && toolCalls.length === 0) continue;
|
|
147
|
+
if (continuesTurn) {
|
|
148
|
+
const prev = messages[lastAssistantIndex];
|
|
149
|
+
if (text.length > 0) prev.content = prev.content === null ? text : `${prev.content}\n${text}`;
|
|
150
|
+
if (reasoning.length > 0) prev.reasoning_content = prev.reasoning_content === void 0 ? reasoning : `${prev.reasoning_content}\n${reasoning}`;
|
|
151
|
+
if (toolCalls.length > 0) prev.tool_calls = [...prev.tool_calls ?? [], ...toolCalls];
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
messages.push({
|
|
155
|
+
role: "assistant",
|
|
156
|
+
content: text.length > 0 ? text : null,
|
|
157
|
+
...reasoning.length > 0 ? { reasoning_content: reasoning } : {},
|
|
158
|
+
...toolCalls.length > 0 ? { tool_calls: toolCalls } : {}
|
|
159
|
+
});
|
|
160
|
+
lastAssistantApiId = apiId;
|
|
161
|
+
lastAssistantIndex = messages.length - 1;
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
messages,
|
|
165
|
+
usage,
|
|
166
|
+
startedAt,
|
|
167
|
+
endedAt,
|
|
168
|
+
model
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/rollout/readers/opencode-sqlite.ts
|
|
173
|
+
/**
|
|
174
|
+
* Read-only backfill reader over the opencode sqlite store
|
|
175
|
+
* (~/.local/share/opencode/opencode.db) → canonical chat-with-tools messages.
|
|
176
|
+
*
|
|
177
|
+
* Schema consumed (observed, 2026-07): `session` rows carry directory /
|
|
178
|
+
* parent_id / agent / model / cost / tokens_*; `message` rows carry a JSON
|
|
179
|
+
* `data` blob ({role, modelID, providerID, tokens, cost, finish}); `part`
|
|
180
|
+
* rows carry the actual content ({type: text|reasoning|tool|step-start|
|
|
181
|
+
* step-finish|snapshot…}). Tool parts hold {callID, state:{input, output,
|
|
182
|
+
* status}} — both the call and its result, which we split into an assistant
|
|
183
|
+
* tool_call plus a role:"tool" result message.
|
|
184
|
+
*
|
|
185
|
+
* The store is mutable and can be corrupt (a `.corrupt-bak` sibling ships
|
|
186
|
+
* next to it in the wild), so `openOpencodeDb` returns null instead of
|
|
187
|
+
* throwing — callers record a gap line, never crash the backfill.
|
|
188
|
+
*/
|
|
189
|
+
const DEFAULT_OPENCODE_DB = join(homedir(), ".local", "share", "opencode", "opencode.db");
|
|
190
|
+
const nodeRequire = createRequire(import.meta.url);
|
|
191
|
+
/** Open the store read-only; null = unavailable/corrupt (caller records a gap). */
|
|
192
|
+
async function openOpencodeDb(path = DEFAULT_OPENCODE_DB) {
|
|
193
|
+
try {
|
|
194
|
+
const { DatabaseSync } = nodeRequire("node:sqlite");
|
|
195
|
+
const db = new DatabaseSync(path, { readOnly: true });
|
|
196
|
+
db.prepare("SELECT id FROM session LIMIT 1").get();
|
|
197
|
+
return db;
|
|
198
|
+
} catch {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
203
|
+
function parseSessionRow(row) {
|
|
204
|
+
let model = null;
|
|
205
|
+
if (typeof row.model === "string" && row.model.length > 0) try {
|
|
206
|
+
const parsed = JSON.parse(row.model);
|
|
207
|
+
if (isRecord(parsed)) model = parsed;
|
|
208
|
+
} catch {
|
|
209
|
+
model = null;
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
id: String(row.id),
|
|
213
|
+
parentId: row.parent_id === null || row.parent_id === void 0 ? null : String(row.parent_id),
|
|
214
|
+
directory: String(row.directory),
|
|
215
|
+
agent: row.agent === null || row.agent === void 0 ? null : String(row.agent),
|
|
216
|
+
model,
|
|
217
|
+
costUsd: Number(row.cost ?? 0),
|
|
218
|
+
tokensInput: Number(row.tokens_input ?? 0),
|
|
219
|
+
tokensOutput: Number(row.tokens_output ?? 0),
|
|
220
|
+
tokensReasoning: Number(row.tokens_reasoning ?? 0),
|
|
221
|
+
tokensCacheRead: Number(row.tokens_cache_read ?? 0),
|
|
222
|
+
tokensCacheWrite: Number(row.tokens_cache_write ?? 0),
|
|
223
|
+
timeCreated: Number(row.time_created ?? 0),
|
|
224
|
+
timeUpdated: Number(row.time_updated ?? 0)
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
const SESSION_COLUMNS = "id, parent_id, directory, agent, model, cost, tokens_input, tokens_output, tokens_reasoning, tokens_cache_read, tokens_cache_write, time_created, time_updated";
|
|
228
|
+
/** Sessions whose cwd is `directory` (the worker-clone join key). */
|
|
229
|
+
function findOpencodeSessionsByDirectory(db, directory) {
|
|
230
|
+
return db.prepare(`SELECT ${SESSION_COLUMNS} FROM session WHERE directory = ? ORDER BY time_created`).all(directory).map(parseSessionRow);
|
|
231
|
+
}
|
|
232
|
+
function findOpencodeSessionById(db, sessionId) {
|
|
233
|
+
const row = db.prepare(`SELECT ${SESSION_COLUMNS} FROM session WHERE id = ?`).get(sessionId);
|
|
234
|
+
return row === void 0 ? null : parseSessionRow(row);
|
|
235
|
+
}
|
|
236
|
+
function toolResultContent(output) {
|
|
237
|
+
if (typeof output === "string") return output;
|
|
238
|
+
if (output === null || output === void 0) return "";
|
|
239
|
+
return JSON.stringify(output);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Convert one session's message+part rows into canonical messages.
|
|
243
|
+
* An opencode assistant message row spans several model steps; each step's
|
|
244
|
+
* parts (reasoning → text → tool …) become one assistant message followed by
|
|
245
|
+
* the role:"tool" results of its calls, preserving order.
|
|
246
|
+
*/
|
|
247
|
+
function readOpencodeSessionMessages(db, sessionId) {
|
|
248
|
+
const messageRows = db.prepare("SELECT id, data FROM message WHERE session_id = ? ORDER BY time_created, id").all(sessionId);
|
|
249
|
+
const partsStmt = db.prepare("SELECT data FROM part WHERE message_id = ? ORDER BY id");
|
|
250
|
+
const messages = [];
|
|
251
|
+
for (const messageRow of messageRows) {
|
|
252
|
+
let data;
|
|
253
|
+
try {
|
|
254
|
+
const parsed = JSON.parse(messageRow.data);
|
|
255
|
+
if (!isRecord(parsed)) continue;
|
|
256
|
+
data = parsed;
|
|
257
|
+
} catch {
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
const parts = [];
|
|
261
|
+
for (const row of partsStmt.all(messageRow.id)) try {
|
|
262
|
+
const parsed = JSON.parse(row.data);
|
|
263
|
+
if (isRecord(parsed)) parts.push(parsed);
|
|
264
|
+
} catch {}
|
|
265
|
+
if (data.role === "user") {
|
|
266
|
+
const text = parts.filter((p) => p.type === "text" && typeof p.text === "string").map((p) => p.text).join("\n");
|
|
267
|
+
messages.push({
|
|
268
|
+
role: "user",
|
|
269
|
+
content: text
|
|
270
|
+
});
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (data.role !== "assistant") continue;
|
|
274
|
+
const steps = [];
|
|
275
|
+
let current = [];
|
|
276
|
+
for (const part of parts) {
|
|
277
|
+
if (part.type === "step-start") {
|
|
278
|
+
if (current.length > 0) steps.push(current);
|
|
279
|
+
current = [];
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (part.type === "step-finish" || part.type === "snapshot" || part.type === "patch") continue;
|
|
283
|
+
current.push(part);
|
|
284
|
+
}
|
|
285
|
+
if (current.length > 0) steps.push(current);
|
|
286
|
+
for (const step of steps) {
|
|
287
|
+
const reasoning = step.filter((p) => p.type === "reasoning" && typeof p.text === "string" && p.text.length > 0).map((p) => p.text).join("\n");
|
|
288
|
+
const text = step.filter((p) => p.type === "text" && typeof p.text === "string").map((p) => p.text).join("\n");
|
|
289
|
+
const toolParts = step.filter((p) => p.type === "tool" && typeof p.callID === "string");
|
|
290
|
+
const toolCalls = toolParts.map((p) => ({
|
|
291
|
+
id: p.callID,
|
|
292
|
+
type: "function",
|
|
293
|
+
function: {
|
|
294
|
+
name: p.tool ?? "unknown",
|
|
295
|
+
arguments: JSON.stringify(p.state?.input ?? {})
|
|
296
|
+
}
|
|
297
|
+
}));
|
|
298
|
+
if (reasoning.length === 0 && text.length === 0 && toolCalls.length === 0) continue;
|
|
299
|
+
messages.push({
|
|
300
|
+
role: "assistant",
|
|
301
|
+
content: text.length > 0 ? text : null,
|
|
302
|
+
...reasoning.length > 0 ? { reasoning_content: reasoning } : {},
|
|
303
|
+
...toolCalls.length > 0 ? { tool_calls: toolCalls } : {}
|
|
304
|
+
});
|
|
305
|
+
for (const p of toolParts) messages.push({
|
|
306
|
+
role: "tool",
|
|
307
|
+
tool_call_id: p.callID,
|
|
308
|
+
name: p.tool ?? "unknown",
|
|
309
|
+
content: toolResultContent(p.state?.output)
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return messages;
|
|
314
|
+
}
|
|
315
|
+
//#endregion
|
|
316
|
+
export { readOpencodeSessionMessages as a, findClaudeTranscripts as c, transcriptFromEntries as d, openOpencodeDb as i, parseClaudeEntries as l, findOpencodeSessionById as n, DEFAULT_CLAUDE_PROJECTS_DIR as o, findOpencodeSessionsByDirectory as r, claudeProjectSlug as s, DEFAULT_OPENCODE_DB as t, readClaudeTranscript as u };
|
|
317
|
+
|
|
318
|
+
//# sourceMappingURL=opencode-sqlite-BGrHeDu3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode-sqlite-BGrHeDu3.js","names":["isRecord"],"sources":["../src/rollout/readers/claude-jsonl.ts","../src/rollout/readers/opencode-sqlite.ts"],"sourcesContent":["/**\n * Backfill reader over Claude Code project transcripts\n * (~/.claude/projects/<cwd-slug>/<sessionId>.jsonl) → canonical\n * chat-with-tools messages plus per-session token usage.\n *\n * Transcript lines consumed: type:\"user\" (string content or content blocks —\n * text + tool_result) and type:\"assistant\" (content blocks — thinking, text,\n * tool_use; message.usage carries tokens). Sidechain lines (isSidechain=true,\n * subagent threads) are separate invocations and are excluded from the main\n * transcript. Everything else (queue-operation, attachment, last-prompt…) is\n * transport metadata, not conversation.\n */\n\nimport { readdir, readFile } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nimport type { ChatMessage, ChatToolCall } from '../schema'\n\nexport const DEFAULT_CLAUDE_PROJECTS_DIR = join(homedir(), '.claude', 'projects')\n\n/** Claude Code's project-directory slug for a working directory. */\nexport function claudeProjectSlug(cwd: string): string {\n return cwd.replace(/[^a-zA-Z0-9-]/g, '-')\n}\n\nexport interface ClaudeTranscriptRef {\n sessionId: string\n path: string\n}\n\n/** Transcript files recorded for sessions launched from `cwd`. */\nexport async function findClaudeTranscripts(\n cwd: string,\n projectsDir: string = DEFAULT_CLAUDE_PROJECTS_DIR,\n): Promise<ClaudeTranscriptRef[]> {\n const dir = join(projectsDir, claudeProjectSlug(cwd))\n const names = await readdir(dir).catch(() => [])\n return names\n .filter((n) => n.endsWith('.jsonl'))\n .sort()\n .map((n) => ({ sessionId: n.replace(/\\.jsonl$/, ''), path: join(dir, n) }))\n}\n\nexport interface ClaudeUsageTotals {\n tokensIn: number\n tokensOut: number\n cacheRead: number\n cacheWrite: number\n}\n\nexport interface ClaudeTranscript {\n messages: ChatMessage[]\n usage: ClaudeUsageTotals\n /** Timestamp of the first conversation line; null = empty transcript. */\n startedAt: string | null\n endedAt: string | null\n model: string | null\n}\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === 'object' && v !== null && !Array.isArray(v)\n\n/**\n * One conversation line of a transcript, still in Claude Code's own shape.\n *\n * This is the single line-level parse of the format. `readClaudeTranscript`\n * projects it to canonical messages + usage; the supervision-tree reader\n * (`src/supervisor-run/claude-code-reader.ts`) projects the SAME entries to\n * spawn/settle/steer instants. Two projections, one parser — a second\n * transcript parser is how the two views silently disagree.\n */\nexport interface ClaudeEntry {\n readonly type: 'user' | 'assistant'\n /** ISO instant of the line; null when the line carried none. */\n readonly timestamp: string | null\n /** The Anthropic message body (`role`, `content`, `model`, `usage`). */\n readonly message: Record<string, unknown>\n /** Claude Code's structured tool result, when the line carries one. */\n readonly toolUseResult: unknown\n /** True on subagent threads — a separate invocation, not this transcript's turn. */\n readonly isSidechain: boolean\n /** Subagent id Claude Code stamps on sidechain lines; null on main-thread lines. */\n readonly agentId: string | null\n}\n\n/** Parse transcript jsonl text into conversation lines. Non-conversation lines are dropped. */\nexport function parseClaudeEntries(raw: string): ClaudeEntry[] {\n const out: ClaudeEntry[] = []\n for (const line of raw.split('\\n')) {\n if (!line.trim()) continue\n let entry: Record<string, unknown>\n try {\n const parsed: unknown = JSON.parse(line)\n if (!isRecord(parsed)) continue\n entry = parsed\n } catch {\n continue\n }\n if (entry.type !== 'user' && entry.type !== 'assistant') continue\n const message = entry.message\n if (!isRecord(message)) continue\n out.push({\n type: entry.type,\n timestamp: typeof entry.timestamp === 'string' ? entry.timestamp : null,\n message,\n toolUseResult: entry.toolUseResult,\n isSidechain: entry.isSidechain === true,\n agentId: typeof entry.agentId === 'string' ? entry.agentId : null,\n })\n }\n return out\n}\n\nexport interface ReadClaudeTranscriptOptions {\n /**\n * Read the sidechain (subagent) thread instead of skipping it. Subagent\n * transcripts under `<session>/subagents/agent-<id>.jsonl` are sidechain\n * lines end to end, so their usage is invisible without this.\n */\n readonly includeSidechain?: boolean\n}\n\nfunction blockText(content: unknown): string {\n if (typeof content === 'string') return content\n if (!Array.isArray(content)) return ''\n return content\n .filter(\n (b): b is Record<string, unknown> =>\n isRecord(b) && b.type === 'text' && typeof b.text === 'string',\n )\n .map((b) => b.text as string)\n .join('\\n')\n}\n\n/** Parse one transcript jsonl into canonical messages + usage totals. */\nexport async function readClaudeTranscript(\n path: string,\n options: ReadClaudeTranscriptOptions = {},\n): Promise<ClaudeTranscript> {\n return transcriptFromEntries(parseClaudeEntries(await readFile(path, 'utf8')), options)\n}\n\n/** The messages+usage projection of already-parsed entries. */\nexport function transcriptFromEntries(\n entries: readonly ClaudeEntry[],\n options: ReadClaudeTranscriptOptions = {},\n): ClaudeTranscript {\n const wantSidechain = options.includeSidechain === true\n const messages: ChatMessage[] = []\n const usage: ClaudeUsageTotals = { tokensIn: 0, tokensOut: 0, cacheRead: 0, cacheWrite: 0 }\n let startedAt: string | null = null\n let endedAt: string | null = null\n let model: string | null = null\n // Claude Code writes one jsonl line PER CONTENT BLOCK of an API message,\n // repeating message.id and usage on each — merge blocks into one canonical\n // assistant turn and count usage once per API message id.\n let lastAssistantApiId: string | null = null\n let lastAssistantIndex = -1\n\n for (const entry of entries) {\n if (entry.isSidechain !== wantSidechain) continue\n const message = entry.message\n if (entry.timestamp !== null) {\n if (startedAt === null) startedAt = entry.timestamp\n endedAt = entry.timestamp\n }\n\n if (entry.type === 'user') {\n lastAssistantApiId = null\n lastAssistantIndex = -1\n const content = message.content\n if (typeof content === 'string') {\n messages.push({ role: 'user', content })\n continue\n }\n if (!Array.isArray(content)) continue\n // A user line may interleave tool_result blocks (answers to the prior\n // assistant tool_use) with plain text; preserve order.\n let userText = ''\n for (const block of content) {\n if (!isRecord(block)) continue\n if (block.type === 'tool_result' && typeof block.tool_use_id === 'string') {\n messages.push({\n role: 'tool',\n tool_call_id: block.tool_use_id,\n content:\n blockText(block.content) || (typeof block.content === 'string' ? block.content : ''),\n })\n } else if (block.type === 'text' && typeof block.text === 'string') {\n userText += (userText.length > 0 ? '\\n' : '') + block.text\n }\n }\n if (userText.length > 0) messages.push({ role: 'user', content: userText })\n continue\n }\n\n // assistant\n if (typeof message.model === 'string') model = message.model\n const apiId = typeof message.id === 'string' ? message.id : null\n const continuesTurn = apiId !== null && apiId === lastAssistantApiId && lastAssistantIndex >= 0\n const msgUsage = message.usage\n if (isRecord(msgUsage) && !continuesTurn) {\n usage.tokensIn += typeof msgUsage.input_tokens === 'number' ? msgUsage.input_tokens : 0\n usage.tokensOut += typeof msgUsage.output_tokens === 'number' ? msgUsage.output_tokens : 0\n usage.cacheRead +=\n typeof msgUsage.cache_read_input_tokens === 'number' ? msgUsage.cache_read_input_tokens : 0\n usage.cacheWrite +=\n typeof msgUsage.cache_creation_input_tokens === 'number'\n ? msgUsage.cache_creation_input_tokens\n : 0\n }\n const content = message.content\n if (!Array.isArray(content)) continue\n let reasoning = ''\n let text = ''\n const toolCalls: ChatToolCall[] = []\n for (const block of content) {\n if (!isRecord(block)) continue\n if (\n block.type === 'thinking' &&\n typeof block.thinking === 'string' &&\n block.thinking.length > 0\n ) {\n reasoning += (reasoning.length > 0 ? '\\n' : '') + block.thinking\n } else if (block.type === 'text' && typeof block.text === 'string') {\n text += (text.length > 0 ? '\\n' : '') + block.text\n } else if (block.type === 'tool_use' && typeof block.id === 'string') {\n toolCalls.push({\n id: block.id,\n type: 'function',\n function: {\n name: typeof block.name === 'string' ? block.name : 'unknown',\n arguments: JSON.stringify(block.input ?? {}),\n },\n })\n }\n }\n if (reasoning.length === 0 && text.length === 0 && toolCalls.length === 0) continue\n if (continuesTurn) {\n const prev = messages[lastAssistantIndex]!\n if (text.length > 0) prev.content = prev.content === null ? text : `${prev.content}\\n${text}`\n if (reasoning.length > 0) {\n prev.reasoning_content =\n prev.reasoning_content === undefined\n ? reasoning\n : `${prev.reasoning_content}\\n${reasoning}`\n }\n if (toolCalls.length > 0) prev.tool_calls = [...(prev.tool_calls ?? []), ...toolCalls]\n continue\n }\n messages.push({\n role: 'assistant',\n content: text.length > 0 ? text : null,\n ...(reasoning.length > 0 ? { reasoning_content: reasoning } : {}),\n ...(toolCalls.length > 0 ? { tool_calls: toolCalls } : {}),\n })\n lastAssistantApiId = apiId\n lastAssistantIndex = messages.length - 1\n }\n\n return { messages, usage, startedAt, endedAt, model }\n}\n","/**\n * Read-only backfill reader over the opencode sqlite store\n * (~/.local/share/opencode/opencode.db) → canonical chat-with-tools messages.\n *\n * Schema consumed (observed, 2026-07): `session` rows carry directory /\n * parent_id / agent / model / cost / tokens_*; `message` rows carry a JSON\n * `data` blob ({role, modelID, providerID, tokens, cost, finish}); `part`\n * rows carry the actual content ({type: text|reasoning|tool|step-start|\n * step-finish|snapshot…}). Tool parts hold {callID, state:{input, output,\n * status}} — both the call and its result, which we split into an assistant\n * tool_call plus a role:\"tool\" result message.\n *\n * The store is mutable and can be corrupt (a `.corrupt-bak` sibling ships\n * next to it in the wild), so `openOpencodeDb` returns null instead of\n * throwing — callers record a gap line, never crash the backfill.\n */\n\nimport { createRequire } from 'node:module'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nimport type { DatabaseSync } from 'node:sqlite'\nimport type { ChatMessage, ChatToolCall } from '../schema'\n\nexport const DEFAULT_OPENCODE_DB = join(homedir(), '.local', 'share', 'opencode', 'opencode.db')\n\nexport interface OpencodeSessionRow {\n id: string\n parentId: string | null\n directory: string\n agent: string | null\n /** Raw session.model JSON: {id, providerID, variant} where present. */\n model: { id?: string; providerID?: string } | null\n costUsd: number\n tokensInput: number\n tokensOutput: number\n tokensReasoning: number\n tokensCacheRead: number\n tokensCacheWrite: number\n timeCreated: number\n timeUpdated: number\n}\n\n// `node:sqlite` is loaded through CommonJS `require`, not `import()`. esbuild\n// (bundling) and Vite (tests) both rewrite a dynamic import and strip the\n// `node:` prefix under an es20xx target, turning this builtin into a bogus\n// \"sqlite\" package lookup; composing the specifier at runtime does not reliably\n// defeat that (it still resolved through Vite's transform in some workers, so\n// the failure moved around as test files were added). A require obtained from\n// `createRequire` is not an analyzable module reference in either tool, so\n// neither can rewrite it.\nconst nodeRequire = createRequire(import.meta.url)\n\n/** Open the store read-only; null = unavailable/corrupt (caller records a gap). */\nexport async function openOpencodeDb(\n path: string = DEFAULT_OPENCODE_DB,\n): Promise<DatabaseSync | null> {\n try {\n const { DatabaseSync } = nodeRequire('node:sqlite') as typeof import('node:sqlite')\n const db = new DatabaseSync(path, { readOnly: true })\n // Probe: a corrupt store can open() fine and fail on first page read.\n db.prepare('SELECT id FROM session LIMIT 1').get()\n return db\n } catch {\n return null\n }\n}\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === 'object' && v !== null && !Array.isArray(v)\n\nfunction parseSessionRow(row: Record<string, unknown>): OpencodeSessionRow {\n let model: OpencodeSessionRow['model'] = null\n if (typeof row.model === 'string' && row.model.length > 0) {\n try {\n const parsed: unknown = JSON.parse(row.model)\n if (isRecord(parsed)) model = parsed as { id?: string; providerID?: string }\n } catch {\n model = null\n }\n }\n return {\n id: String(row.id),\n parentId: row.parent_id === null || row.parent_id === undefined ? null : String(row.parent_id),\n directory: String(row.directory),\n agent: row.agent === null || row.agent === undefined ? null : String(row.agent),\n model,\n costUsd: Number(row.cost ?? 0),\n tokensInput: Number(row.tokens_input ?? 0),\n tokensOutput: Number(row.tokens_output ?? 0),\n tokensReasoning: Number(row.tokens_reasoning ?? 0),\n tokensCacheRead: Number(row.tokens_cache_read ?? 0),\n tokensCacheWrite: Number(row.tokens_cache_write ?? 0),\n timeCreated: Number(row.time_created ?? 0),\n timeUpdated: Number(row.time_updated ?? 0),\n }\n}\n\nconst SESSION_COLUMNS =\n 'id, parent_id, directory, agent, model, cost, tokens_input, tokens_output, tokens_reasoning, tokens_cache_read, tokens_cache_write, time_created, time_updated'\n\n/** Sessions whose cwd is `directory` (the worker-clone join key). */\nexport function findOpencodeSessionsByDirectory(\n db: DatabaseSync,\n directory: string,\n): OpencodeSessionRow[] {\n const rows = db\n .prepare(`SELECT ${SESSION_COLUMNS} FROM session WHERE directory = ? ORDER BY time_created`)\n .all(directory) as Array<Record<string, unknown>>\n return rows.map(parseSessionRow)\n}\n\nexport function findOpencodeSessionById(\n db: DatabaseSync,\n sessionId: string,\n): OpencodeSessionRow | null {\n const row = db.prepare(`SELECT ${SESSION_COLUMNS} FROM session WHERE id = ?`).get(sessionId) as\n | Record<string, unknown>\n | undefined\n return row === undefined ? null : parseSessionRow(row)\n}\n\ninterface OpencodePart {\n type?: string\n text?: string\n tool?: string\n callID?: string\n state?: { status?: string; input?: unknown; output?: unknown }\n}\n\nfunction toolResultContent(output: unknown): string {\n if (typeof output === 'string') return output\n if (output === null || output === undefined) return ''\n return JSON.stringify(output)\n}\n\n/**\n * Convert one session's message+part rows into canonical messages.\n * An opencode assistant message row spans several model steps; each step's\n * parts (reasoning → text → tool …) become one assistant message followed by\n * the role:\"tool\" results of its calls, preserving order.\n */\nexport function readOpencodeSessionMessages(db: DatabaseSync, sessionId: string): ChatMessage[] {\n const messageRows = db\n .prepare('SELECT id, data FROM message WHERE session_id = ? ORDER BY time_created, id')\n .all(sessionId) as Array<{ id: string; data: string }>\n const partsStmt = db.prepare('SELECT data FROM part WHERE message_id = ? ORDER BY id')\n\n const messages: ChatMessage[] = []\n for (const messageRow of messageRows) {\n let data: Record<string, unknown>\n try {\n const parsed: unknown = JSON.parse(messageRow.data)\n if (!isRecord(parsed)) continue\n data = parsed\n } catch {\n continue\n }\n const parts: OpencodePart[] = []\n for (const row of partsStmt.all(messageRow.id) as Array<{ data: string }>) {\n try {\n const parsed: unknown = JSON.parse(row.data)\n if (isRecord(parsed)) parts.push(parsed as OpencodePart)\n } catch {\n // Malformed part payload: skip the part, keep the message.\n }\n }\n\n if (data.role === 'user') {\n const text = parts\n .filter((p) => p.type === 'text' && typeof p.text === 'string')\n .map((p) => p.text as string)\n .join('\\n')\n messages.push({ role: 'user', content: text })\n continue\n }\n if (data.role !== 'assistant') continue\n\n // Split the row into steps at step-start boundaries; parts before the\n // first step-start (none observed, but tolerated) form an implicit step.\n const steps: OpencodePart[][] = []\n let current: OpencodePart[] = []\n for (const part of parts) {\n if (part.type === 'step-start') {\n if (current.length > 0) steps.push(current)\n current = []\n continue\n }\n if (part.type === 'step-finish' || part.type === 'snapshot' || part.type === 'patch') continue\n current.push(part)\n }\n if (current.length > 0) steps.push(current)\n\n for (const step of steps) {\n const reasoning = step\n .filter((p) => p.type === 'reasoning' && typeof p.text === 'string' && p.text.length > 0)\n .map((p) => p.text as string)\n .join('\\n')\n const text = step\n .filter((p) => p.type === 'text' && typeof p.text === 'string')\n .map((p) => p.text as string)\n .join('\\n')\n const toolParts = step.filter((p) => p.type === 'tool' && typeof p.callID === 'string')\n const toolCalls: ChatToolCall[] = toolParts.map((p) => ({\n id: p.callID as string,\n type: 'function',\n function: {\n name: p.tool ?? 'unknown',\n arguments: JSON.stringify(p.state?.input ?? {}),\n },\n }))\n if (reasoning.length === 0 && text.length === 0 && toolCalls.length === 0) continue\n messages.push({\n role: 'assistant',\n content: text.length > 0 ? text : null,\n ...(reasoning.length > 0 ? { reasoning_content: reasoning } : {}),\n ...(toolCalls.length > 0 ? { tool_calls: toolCalls } : {}),\n })\n for (const p of toolParts) {\n messages.push({\n role: 'tool',\n tool_call_id: p.callID as string,\n name: p.tool ?? 'unknown',\n content: toolResultContent(p.state?.output),\n })\n }\n }\n }\n return messages\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAa,8BAA8B,KAAK,QAAQ,GAAG,WAAW,UAAU;;AAGhF,SAAgB,kBAAkB,KAAqB;CACrD,OAAO,IAAI,QAAQ,kBAAkB,GAAG;AAC1C;;AAQA,eAAsB,sBACpB,KACA,cAAsB,6BACU;CAChC,MAAM,MAAM,KAAK,aAAa,kBAAkB,GAAG,CAAC;CAEpD,QAAO,MADa,QAAQ,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,EAAA,CAE5C,QAAQ,MAAM,EAAE,SAAS,QAAQ,CAAC,CAAC,CACnC,KAAK,CAAC,CACN,KAAK,OAAO;EAAE,WAAW,EAAE,QAAQ,YAAY,EAAE;EAAG,MAAM,KAAK,KAAK,CAAC;CAAE,EAAE;AAC9E;AAkBA,MAAMA,cAAY,MAChB,OAAO,MAAM,YAAY,MAAM,QAAQ,CAAC,MAAM,QAAQ,CAAC;;AA0BzD,SAAgB,mBAAmB,KAA4B;CAC7D,MAAM,MAAqB,CAAC;CAC5B,KAAK,MAAM,QAAQ,IAAI,MAAM,IAAI,GAAG;EAClC,IAAI,CAAC,KAAK,KAAK,GAAG;EAClB,IAAI;EACJ,IAAI;GACF,MAAM,SAAkB,KAAK,MAAM,IAAI;GACvC,IAAI,CAACA,WAAS,MAAM,GAAG;GACvB,QAAQ;EACV,QAAQ;GACN;EACF;EACA,IAAI,MAAM,SAAS,UAAU,MAAM,SAAS,aAAa;EACzD,MAAM,UAAU,MAA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ChB,MAAM,EAAE,QAAQ;IAChB,SAAS,kBAAkB,EAAE,OAAO,MAAM;GAC5C,CAAC;EAEL;CACF;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region src/meta-eval/outcome-store.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* OutcomeStore — deployment outcomes attached to Run IDs.
|
|
4
|
+
*
|
|
5
|
+
* Outcomes arrive asynchronously from production telemetry after the
|
|
6
|
+
* eval run completed: user ratings, retention flags, conversion events,
|
|
7
|
+
* revenue, support-ticket rate, anything a product team can measure.
|
|
8
|
+
* The store is a peer to TraceStore — separate lifecycle, same runId
|
|
9
|
+
* foreign key.
|
|
10
|
+
*
|
|
11
|
+
* The whole point of this module is to make the meta-eval correlation
|
|
12
|
+
* question computable: `correlate(evalMetric, outcomeMetric) → r, ρ, n, CI`.
|
|
13
|
+
*/
|
|
14
|
+
interface DeploymentOutcome {
|
|
15
|
+
runId: string;
|
|
16
|
+
capturedAt: number;
|
|
17
|
+
/** Numeric outcomes keyed by name — retention_7d, csat, revenue_usd, etc. */
|
|
18
|
+
metrics: Record<string, number>;
|
|
19
|
+
/** Dimensions for stratified analysis — cohort, region, user_segment. */
|
|
20
|
+
labels?: Record<string, string>;
|
|
21
|
+
/** Free-form provenance (source system, pipeline version). */
|
|
22
|
+
source?: string;
|
|
23
|
+
}
|
|
24
|
+
interface OutcomeFilter {
|
|
25
|
+
runIds?: string[];
|
|
26
|
+
since?: number;
|
|
27
|
+
until?: number;
|
|
28
|
+
label?: {
|
|
29
|
+
key: string;
|
|
30
|
+
value: string;
|
|
31
|
+
};
|
|
32
|
+
source?: string;
|
|
33
|
+
}
|
|
34
|
+
interface OutcomeStore {
|
|
35
|
+
append(outcome: DeploymentOutcome): Promise<void>;
|
|
36
|
+
/** All outcomes attached to this run (a single run can have many — multiple
|
|
37
|
+
* capture windows over deployment time). */
|
|
38
|
+
forRun(runId: string): Promise<DeploymentOutcome[]>;
|
|
39
|
+
list(filter?: OutcomeFilter): Promise<DeploymentOutcome[]>;
|
|
40
|
+
}
|
|
41
|
+
declare class InMemoryOutcomeStore implements OutcomeStore {
|
|
42
|
+
private items;
|
|
43
|
+
append(outcome: DeploymentOutcome): Promise<void>;
|
|
44
|
+
forRun(runId: string): Promise<DeploymentOutcome[]>;
|
|
45
|
+
list(filter?: OutcomeFilter): Promise<DeploymentOutcome[]>;
|
|
46
|
+
}
|
|
47
|
+
interface FileSystemOutcomeStoreOptions {
|
|
48
|
+
dir: string;
|
|
49
|
+
maxBytes?: number;
|
|
50
|
+
}
|
|
51
|
+
declare class FileSystemOutcomeStore implements OutcomeStore {
|
|
52
|
+
private dir;
|
|
53
|
+
private maxBytes;
|
|
54
|
+
private memo?;
|
|
55
|
+
private loaded;
|
|
56
|
+
constructor(options: FileSystemOutcomeStoreOptions);
|
|
57
|
+
private ensureDir;
|
|
58
|
+
append(outcome: DeploymentOutcome): Promise<void>;
|
|
59
|
+
private load;
|
|
60
|
+
forRun(runId: string): Promise<DeploymentOutcome[]>;
|
|
61
|
+
list(filter?: OutcomeFilter): Promise<DeploymentOutcome[]>;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { OutcomeFilter as a, InMemoryOutcomeStore as i, FileSystemOutcomeStore as n, OutcomeStore as o, FileSystemOutcomeStoreOptions as r, DeploymentOutcome as t };
|
|
65
|
+
//# sourceMappingURL=outcome-store-BYHIuO0e.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome-store-BYHIuO0e.d.ts","names":[],"sources":["../src/meta-eval/outcome-store.ts"],"mappings":";;;;;;;;;;;;;UAaiB;EACf;EACA;;EAEA,SAAS;;EAET,SAAS;;EAET;;UAGe;EACf;EACA;EACA;EACA;IAAU;IAAa;;EACvB;;UAGe;EACf,OAAO,SAAS,oBAAoB;;;EAGpC,OAAO,gBAAgB,QAAQ;EAC/B,KAAK,SAAS,gBAAgB,QAAQ;;cAG3B,gCAAgC;UACnC;EAEF,OAAO,SAAS,oBAAoB;EAIpC,OAAO,gBAAgB,QAAQ;EAI/B,KAAK,SAAQ,gBAAqB,QAAQ;;UAKjC;EACf;EACA;;cAGW,kCAAkC;UACrC;UACA;UACA;UACA;EAER,YAAY,SAAS;UAKP;EAKR,OAAO,SAAS,oBAAoB;UAiB5B;EAuBR,OAAO,gBAAgB,QAAQ;EAI/B,KAAK,SAAS,gBAAgB,QAAQ"}
|