@tangle-network/agent-eval 0.144.11 → 0.144.13
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 +11 -0
- package/dist/agent-profile-B9_GGsG8.d.ts +84 -0
- package/dist/agent-profile-B9_GGsG8.d.ts.map +1 -0
- package/dist/{agent-profile-cell-BOP-iA9Q.d.ts → agent-profile-cell-BkcRDikH.d.ts} +2 -2
- package/dist/{agent-profile-cell-BOP-iA9Q.d.ts.map → agent-profile-cell-BkcRDikH.d.ts.map} +1 -1
- package/dist/analyst/index.d.ts +134 -16
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +364 -10
- package/dist/analyst/index.js.map +1 -1
- package/dist/backend-integrity-CsVin_Wb.d.ts +280 -0
- package/dist/backend-integrity-CsVin_Wb.d.ts.map +1 -0
- package/dist/{baseline-C-GocmIW.js → baseline-BhPRQBVn.js} +3 -2
- package/dist/{baseline-C-GocmIW.js.map → baseline-BhPRQBVn.js.map} +1 -1
- package/dist/{benchmark-CWeqGl7x.js → benchmark-BhT16ep9.js} +2 -2
- package/dist/{benchmark-CWeqGl7x.js.map → benchmark-BhT16ep9.js.map} +1 -1
- package/dist/{agent-profile-DPi7IZg7.d.ts → benchmark-Ceoan7vk.d.ts} +4 -91
- package/dist/benchmark-Ceoan7vk.d.ts.map +1 -0
- package/dist/{benchmark-command-BteMFN62.js → benchmark-command-CY6cbhOB.js} +36 -79
- package/dist/benchmark-command-CY6cbhOB.js.map +1 -0
- package/dist/benchmarks/index.d.ts +244 -2
- package/dist/benchmarks/index.d.ts.map +1 -0
- package/dist/benchmarks/index.js +733 -1
- package/dist/benchmarks/index.js.map +1 -0
- package/dist/builder-eval/index.d.ts +23 -2
- package/dist/builder-eval/index.d.ts.map +1 -1
- package/dist/builder-eval/index.js +227 -3
- package/dist/builder-eval/index.js.map +1 -1
- package/dist/campaign/index.d.ts +10 -8
- package/dist/campaign/index.js +9 -6
- package/dist/{campaign-C2TTzQII.js → campaign-BYjBAypg.js} +21 -634
- package/dist/campaign-BYjBAypg.js.map +1 -0
- package/dist/{canonical-D011XM8r.js → canonical-D-XsTQ6_.js} +2 -2
- package/dist/{canonical-D011XM8r.js.map → canonical-D-XsTQ6_.js.map} +1 -1
- package/dist/{index-CQTZ-4XN.d.ts → capture-fetch-DDvpjVRU.d.ts} +3 -3
- package/dist/capture-fetch-DDvpjVRU.d.ts.map +1 -0
- package/dist/{default-registry-BmktKy8r.js → chat-client-Bp4Ebuuc.js} +1276 -1276
- package/dist/chat-client-Bp4Ebuuc.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/{client-C9gzZE59.d.ts → client-KUbGulm_.d.ts} +4 -4
- package/dist/{client-C9gzZE59.d.ts.map → client-KUbGulm_.d.ts.map} +1 -1
- package/dist/contract/index.d.ts +13 -390
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +18 -542
- package/dist/contract/index.js.map +1 -1
- package/dist/{cost-ledger-DMFxsLKr.js → cost-ledger-BSe92yAV.js} +3 -3
- package/dist/{cost-ledger-DMFxsLKr.js.map → cost-ledger-BSe92yAV.js.map} +1 -1
- package/dist/{cost-ledger-Bv_e8XHY.d.ts → cost-ledger-DbQdN3nO.d.ts} +2 -2
- package/dist/{cost-ledger-Bv_e8XHY.d.ts.map → cost-ledger-DbQdN3nO.d.ts.map} +1 -1
- package/dist/{counterfactual-CxmxAONP.d.ts → counterfactual--bpysZF0.d.ts} +2 -14
- package/dist/{counterfactual-CxmxAONP.d.ts.map → counterfactual--bpysZF0.d.ts.map} +1 -1
- package/dist/{counterfactual-CWPTrMH7.js → counterfactual-lDfCx0Uz.js} +3 -31
- package/dist/{counterfactual-CWPTrMH7.js.map → counterfactual-lDfCx0Uz.js.map} +1 -1
- package/dist/{dataset-C8xaLXdY.d.ts → dataset-CJjKqQfA.d.ts} +2 -8
- package/dist/dataset-CJjKqQfA.d.ts.map +1 -0
- package/dist/{default-registry-Bf8Woqmq.d.ts → default-registry-Di6HP6pG.d.ts} +7 -12
- package/dist/default-registry-Di6HP6pG.d.ts.map +1 -0
- package/dist/{analyze-runs-C30yljDJ.js → define-agent-eval-iqjT--ZZ.js} +542 -130
- package/dist/define-agent-eval-iqjT--ZZ.js.map +1 -0
- package/dist/define-agent-eval-sH24zBfM.d.ts +388 -0
- package/dist/define-agent-eval-sH24zBfM.d.ts.map +1 -0
- package/dist/descriptive-B5MwKfbf.js +144 -0
- package/dist/descriptive-B5MwKfbf.js.map +1 -0
- package/dist/{dspy-rlm-engine-DbTk4JdR.js → dspy-rlm-engine-B_qhSc21.js} +4 -4
- package/dist/{dspy-rlm-engine-DbTk4JdR.js.map → dspy-rlm-engine-B_qhSc21.js.map} +1 -1
- package/dist/effect-sizes-DiH8MGOH.js +82 -0
- package/dist/effect-sizes-DiH8MGOH.js.map +1 -0
- package/dist/{engine-3hL-XqwJ.d.ts → engine-otFpE2gF.d.ts} +10 -38
- package/dist/engine-otFpE2gF.d.ts.map +1 -0
- package/dist/{errors-CKPfb2aH.d.ts → errors-DEE6u6ot.d.ts} +2 -14
- package/dist/{errors-CKPfb2aH.d.ts.map → errors-DEE6u6ot.d.ts.map} +1 -1
- package/dist/{errors-D-LKuDhb.js → errors-Dngq5h35.js} +2 -8
- package/dist/{errors-D-LKuDhb.js.map → errors-Dngq5h35.js.map} +1 -1
- package/dist/{eval-campaign-B_7wcnav.js → eval-campaign-UB-usSQ2.js} +6 -6
- package/dist/{eval-campaign-B_7wcnav.js.map → eval-campaign-UB-usSQ2.js.map} +1 -1
- package/dist/{exact-types-DSFFpLLI.d.ts → exact-types-BH1twmAJ.d.ts} +2 -2
- package/dist/{exact-types-DSFFpLLI.d.ts.map → exact-types-BH1twmAJ.d.ts.map} +1 -1
- package/dist/experiment/index.d.ts +9 -6
- package/dist/experiment/index.d.ts.map +1 -1
- package/dist/experiment/index.js +11 -7
- package/dist/experiment/index.js.map +1 -1
- package/dist/experiment-tracker-C29gXM4B.js +269 -0
- package/dist/experiment-tracker-C29gXM4B.js.map +1 -0
- package/dist/{experiment-tracker-IMntXr6J.d.ts → experiment-tracker-DWHZBAYL.d.ts} +77 -121
- package/dist/experiment-tracker-DWHZBAYL.d.ts.map +1 -0
- package/dist/{external-optimizer-contracts-CZuJNcT5.d.ts → external-optimizer-contracts-lixrOZdX.d.ts} +3 -3
- package/dist/{external-optimizer-contracts-CZuJNcT5.d.ts.map → external-optimizer-contracts-lixrOZdX.d.ts.map} +1 -1
- package/dist/external-optimizer-process-BTiNB-RH.js +301 -0
- package/dist/external-optimizer-process-BTiNB-RH.js.map +1 -0
- package/dist/{single-run-lock-DFWHEB09.js → external-optimizer-subprocess-DrJ9hR8u.js} +144 -438
- package/dist/external-optimizer-subprocess-DrJ9hR8u.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 → failure-cluster-BLURuWG4.d.ts} +2 -3
- package/dist/failure-cluster-BLURuWG4.d.ts.map +1 -0
- package/dist/{feedback-trajectory-CacHpxsp.d.ts → feedback-trajectory-juOozjAc.d.ts} +5 -36
- package/dist/feedback-trajectory-juOozjAc.d.ts.map +1 -0
- package/dist/fuzz.d.ts +2 -2
- package/dist/fuzz.js +2 -2
- package/dist/hosted/index.d.ts +3 -3
- package/dist/{index-CvSN3IG1.d.ts → index-B8Ui1mr1.d.ts} +2 -2
- package/dist/{index-CvSN3IG1.d.ts.map → index-B8Ui1mr1.d.ts.map} +1 -1
- package/dist/{skill-usage-CO9OLRBx.d.ts → index-BWDrSVfw.d.ts} +11 -136
- package/dist/index-BWDrSVfw.d.ts.map +1 -0
- package/dist/index-Ba3YrbAL.d.ts +1 -0
- package/dist/{index-BnEuDAK2.d.ts → index-COQYtuRF.d.ts} +3 -3
- package/dist/{index-BnEuDAK2.d.ts.map → index-COQYtuRF.d.ts.map} +1 -1
- package/dist/{index-C3ssXVLv.d.ts → index-CvjYbU0D.d.ts} +2 -2
- package/dist/{index-C3ssXVLv.d.ts.map → index-CvjYbU0D.d.ts.map} +1 -1
- package/dist/{index-DPPGNJ_R.d.ts → index-DSmEylT9.d.ts} +17 -115
- package/dist/index-DSmEylT9.d.ts.map +1 -0
- package/dist/index.d.ts +2397 -5308
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5914 -10496
- package/dist/index.js.map +1 -1
- package/dist/{insight-report-CgX_s0Ez.d.ts → insight-report-CRi-Ufrj.d.ts} +4 -4
- package/dist/{insight-report-CgX_s0Ez.d.ts.map → insight-report-CRi-Ufrj.d.ts.map} +1 -1
- package/dist/{integrity-MLzHOfV9.js → integrity-Cy9WHAtb.js} +2 -2
- package/dist/{integrity-MLzHOfV9.js.map → integrity-Cy9WHAtb.js.map} +1 -1
- package/dist/{integrity-DY6tIbl0.js → integrity-DysDBWDu.js} +2 -2
- package/dist/{integrity-DY6tIbl0.js.map → integrity-DysDBWDu.js.map} +1 -1
- package/dist/{integrity-BuqEKu-x.d.ts → integrity-OrcI9Nau.d.ts} +3 -3
- package/dist/{integrity-BuqEKu-x.d.ts.map → integrity-OrcI9Nau.d.ts.map} +1 -1
- package/dist/internal-BDHPCnjk.js +230 -0
- package/dist/internal-BDHPCnjk.js.map +1 -0
- package/dist/judge-calibration-C5CbMYce.d.ts +117 -0
- package/dist/judge-calibration-C5CbMYce.d.ts.map +1 -0
- package/dist/judge-calibration-DZkWrm5H.js +317 -0
- package/dist/judge-calibration-DZkWrm5H.js.map +1 -0
- package/dist/{kind-factory-B8-r8-y8.js → kind-factory-CPmSd58s.js} +208 -208
- package/dist/{kind-factory-B8-r8-y8.js.map → kind-factory-CPmSd58s.js.map} +1 -1
- package/dist/ledger-core/index.d.ts +1 -1
- package/dist/ledger-core/index.js +2 -2
- package/dist/{ledger-core-DXZIqu17.js → ledger-core-BmZt19oQ.js} +110 -110
- package/dist/{ledger-core-DXZIqu17.js.map → ledger-core-BmZt19oQ.js.map} +1 -1
- package/dist/{llm-client-DzvMUsS_.js → llm-client-d0-2TT1g.js} +4 -64
- package/dist/{llm-client-DzvMUsS_.js.map → llm-client-d0-2TT1g.js.map} +1 -1
- package/dist/{skillopt-optimization-method-CQdVeM8k.js → llm-judge-dZ8P6nGI.js} +3349 -5401
- package/dist/llm-judge-dZ8P6nGI.js.map +1 -0
- package/dist/matrix/index.d.ts +2 -2
- package/dist/meta-eval/index.d.ts +3 -3
- package/dist/meta-eval/index.js +3 -3
- package/dist/{metrics-C9YY1OcL.js → metrics-Cl0L1KUy.js} +2 -108
- package/dist/{metrics-C9YY1OcL.js.map → metrics-Cl0L1KUy.js.map} +1 -1
- package/dist/{mint-B2O60ACG.js → mint-Dj9Ww_3I.js} +4 -4
- package/dist/{mint-B2O60ACG.js.map → mint-Dj9Ww_3I.js.map} +1 -1
- package/dist/{multi-layer-verifier-DnAqwl0h.d.ts → multi-layer-verifier-DIguZc8Z.d.ts} +3 -3
- package/dist/{multi-layer-verifier-DnAqwl0h.d.ts.map → multi-layer-verifier-DIguZc8Z.d.ts.map} +1 -1
- package/dist/multiplicity-DIWHvysC.d.ts +43 -0
- package/dist/multiplicity-DIWHvysC.d.ts.map +1 -0
- package/dist/multishot/index.d.ts +3 -3
- package/dist/multishot/index.js +1 -1
- package/dist/openapi.json +1 -1
- package/dist/{opencode-sqlite-8r6WUfHc.js → opencode-sqlite-DJWAXLms.js} +2 -2
- package/dist/{opencode-sqlite-8r6WUfHc.js.map → opencode-sqlite-DJWAXLms.js.map} +1 -1
- package/dist/package-version-D7lQHt_-.js +34 -0
- package/dist/package-version-D7lQHt_-.js.map +1 -0
- package/dist/paired-arms-D-XRF_fy.js +1045 -0
- package/dist/paired-arms-D-XRF_fy.js.map +1 -0
- package/dist/paired-promotion-decision-CGzg0cI_.d.ts +251 -0
- package/dist/paired-promotion-decision-CGzg0cI_.d.ts.map +1 -0
- package/dist/paired-tests-BHIhYVdu.js +213 -0
- package/dist/paired-tests-BHIhYVdu.js.map +1 -0
- package/dist/pareto-BqNW3LJR.d.ts +117 -0
- package/dist/pareto-BqNW3LJR.d.ts.map +1 -0
- package/dist/pipelines/index.d.ts +3 -64
- package/dist/pipelines/index.d.ts.map +1 -1
- package/dist/pipelines/index.js +4 -284
- package/dist/pipelines/index.js.map +1 -1
- package/dist/power-and-mde-CHIrXJll.js +195 -0
- package/dist/power-and-mde-CHIrXJll.js.map +1 -0
- package/dist/{promotion-policy-CrLrmys8.js → power-preflight-DEw-uC7q.js} +4 -184
- package/dist/power-preflight-DEw-uC7q.js.map +1 -0
- package/dist/pre-registration-CZwSFQS4.d.ts +577 -0
- package/dist/pre-registration-CZwSFQS4.d.ts.map +1 -0
- package/dist/{prime-protocol-BfSalTfR.js → prime-protocol-6tZTVsWm.js} +72 -21
- package/dist/prime-protocol-6tZTVsWm.js.map +1 -0
- package/dist/produced-state-DU79a81m.js +586 -0
- package/dist/produced-state-DU79a81m.js.map +1 -0
- package/dist/profile-cell.d.ts +1 -1
- package/dist/profile-cell.js +1 -1
- package/dist/promotion-policy-D0nPhkSy.d.ts +134 -0
- package/dist/promotion-policy-D0nPhkSy.d.ts.map +1 -0
- package/dist/promotion-policy-xzA40Evo.js +186 -0
- package/dist/promotion-policy-xzA40Evo.js.map +1 -0
- package/dist/{skillopt-optimization-method-USDKhxSA.d.ts → provenance-CCdxgLDT.d.ts} +57 -478
- package/dist/provenance-CCdxgLDT.d.ts.map +1 -0
- package/dist/registry-oJeeI4-a.d.ts +178 -0
- package/dist/registry-oJeeI4-a.d.ts.map +1 -0
- package/dist/{release-report-DA2BCu5a.d.ts → release-confidence-BFRE5WSp.d.ts} +180 -112
- package/dist/release-confidence-BFRE5WSp.d.ts.map +1 -0
- package/dist/{release-report-BUYmoKo2.js → release-confidence-CxDuiAev.js} +125 -217
- package/dist/release-confidence-CxDuiAev.js.map +1 -0
- package/dist/reporting.d.ts +6 -5
- package/dist/reporting.js +7 -5
- package/dist/{researcher-BchpD55R.d.ts → researcher-DaN4GST-.d.ts} +7 -40
- package/dist/{researcher-BchpD55R.d.ts.map → researcher-DaN4GST-.d.ts.map} +1 -1
- package/dist/{reward-hacking-BDToousL.js → reward-hacking-DNgjilrV.js} +3 -3
- package/dist/reward-hacking-DNgjilrV.js.map +1 -0
- package/dist/{reward-hacking-BI0OMAlo.d.ts → reward-hacking-DSSTuI9r.d.ts} +5 -5
- package/dist/{reward-hacking-BI0OMAlo.d.ts.map → reward-hacking-DSSTuI9r.d.ts.map} +1 -1
- package/dist/rl.d.ts +7 -7
- package/dist/rl.js +11 -10
- package/dist/rl.js.map +1 -1
- package/dist/rollout/index.d.ts +2 -2
- package/dist/rollout/index.js +4 -4
- package/dist/{rollout-DRrksrcV.js → rollout-BWtw0I_6.js} +3 -3
- package/dist/{rollout-DRrksrcV.js.map → rollout-BWtw0I_6.js.map} +1 -1
- package/dist/{rubric-predictive-validity-DvkjPYCe.d.ts → rubric-predictive-validity-BgxtKe4G.d.ts} +2 -2
- package/dist/{rubric-predictive-validity-DvkjPYCe.d.ts.map → rubric-predictive-validity-BgxtKe4G.d.ts.map} +1 -1
- package/dist/{rubric-predictive-validity-BRR632r1.js → rubric-predictive-validity-Cwwyd7ah.js} +2 -2
- package/dist/{rubric-predictive-validity-BRR632r1.js.map → rubric-predictive-validity-Cwwyd7ah.js.map} +1 -1
- package/dist/{run-record-BmSPWXJR.js → run-record-BvHPVS-i.js} +3 -3
- package/dist/{run-record-BmSPWXJR.js.map → run-record-BvHPVS-i.js.map} +1 -1
- package/dist/{run-record-CF4Dwpxr.d.ts → run-record-CKiihE6f.d.ts} +4 -4
- package/dist/{run-record-CF4Dwpxr.d.ts.map → run-record-CKiihE6f.d.ts.map} +1 -1
- package/dist/{proposal-findings-2GIUo1et.js → run-score-lDzV0X8j.js} +31 -31
- package/dist/run-score-lDzV0X8j.js.map +1 -0
- package/dist/sandbox-harness-BlSOu4LX.d.ts +70 -0
- package/dist/sandbox-harness-BlSOu4LX.d.ts.map +1 -0
- package/dist/{schema-Cef2cFmb2.d.ts → schema-Cef2cFmb.d.ts} +1 -1
- package/dist/schema-Cef2cFmb.d.ts.map +1 -0
- package/dist/semantic-concept-judge-BiJxScqe.js +406 -0
- package/dist/semantic-concept-judge-BiJxScqe.js.map +1 -0
- package/dist/{sequential-D-BLJBKU.js → sequential-C458DXNf.js} +4 -3
- package/dist/{sequential-D-BLJBKU.js.map → sequential-C458DXNf.js.map} +1 -1
- package/dist/sequential-eprocess-CbUt2htw.js +83 -0
- package/dist/sequential-eprocess-CbUt2htw.js.map +1 -0
- package/dist/series-convergence-D1cL1f-4.d.ts +129 -0
- package/dist/series-convergence-D1cL1f-4.d.ts.map +1 -0
- package/dist/{server-iu0ede49.js → server-ulsOdrTI.js} +5 -21
- package/dist/server-ulsOdrTI.js.map +1 -0
- package/dist/skillopt-optimization-method-C5cotF4E.d.ts +427 -0
- package/dist/skillopt-optimization-method-C5cotF4E.d.ts.map +1 -0
- package/dist/skillopt-optimization-method-jjdnc3YK.js +1999 -0
- package/dist/skillopt-optimization-method-jjdnc3YK.js.map +1 -0
- package/dist/{statistical-heldout-TQ-4CYiN.d.ts → statistical-heldout-DoFF5KJX.d.ts} +5 -278
- package/dist/statistical-heldout-DoFF5KJX.d.ts.map +1 -0
- package/dist/{store-otlp-Dw8PPIlL.js → store-otlp-CsptLYpN.js} +3 -3
- package/dist/{store-otlp-Dw8PPIlL.js.map → store-otlp-CsptLYpN.js.map} +1 -1
- package/dist/store-tool-spans-Cq9mFd-q.js +667 -0
- package/dist/store-tool-spans-Cq9mFd-q.js.map +1 -0
- package/dist/store-tool-spans-DbDLOBOb.d.ts +342 -0
- package/dist/store-tool-spans-DbDLOBOb.d.ts.map +1 -0
- package/dist/student-t-CvBq2mve.js +38 -0
- package/dist/student-t-CvBq2mve.js.map +1 -0
- package/dist/{summary-report-Lf-5I7xh.js → summary-report-Blysd6Z2.js} +6 -3
- package/dist/{summary-report-Lf-5I7xh.js.map → summary-report-Blysd6Z2.js.map} +1 -1
- package/dist/{summary-report-BNR7DWTj.d.ts → summary-report-CaL-Hnxt.d.ts} +5 -5
- package/dist/{summary-report-BNR7DWTj.d.ts.map → summary-report-CaL-Hnxt.d.ts.map} +1 -1
- package/dist/supervisor-run/index.d.ts +391 -3
- package/dist/supervisor-run/index.d.ts.map +1 -0
- package/dist/supervisor-run/index.js +1689 -2
- package/dist/{supervisor-run-D_sokXcO.js.map → supervisor-run/index.js.map} +1 -1
- package/dist/{extract-usage-CdZdoj1s.js → task-failure-attributes-CpQ4y5RD.js} +5 -157
- package/dist/task-failure-attributes-CpQ4y5RD.js.map +1 -0
- package/dist/{tool-groups-CZPGGlHf.d.ts → tool-groups-Cteb03Ps.d.ts} +3 -3
- package/dist/tool-groups-Cteb03Ps.d.ts.map +1 -0
- package/dist/tool-waste-BDdBZG1F.js +803 -0
- package/dist/tool-waste-BDdBZG1F.js.map +1 -0
- package/dist/tool-waste-DjRDEsuI.d.ts +128 -0
- package/dist/tool-waste-DjRDEsuI.d.ts.map +1 -0
- package/dist/trace-repair/index.d.ts +14 -5
- package/dist/trace-repair/index.d.ts.map +1 -1
- package/dist/trace-repair/index.js +35 -7
- package/dist/trace-repair/index.js.map +1 -1
- package/dist/traces.d.ts +406 -7
- package/dist/traces.d.ts.map +1 -0
- package/dist/traces.js +1011 -10
- package/dist/traces.js.map +1 -0
- package/dist/trajectory-replay/index.d.ts +16 -3
- package/dist/trajectory-replay/index.d.ts.map +1 -1
- package/dist/trajectory-replay/index.js +52 -5
- package/dist/trajectory-replay/index.js.map +1 -1
- package/dist/types-BEPZc6eo.d.ts +93 -0
- package/dist/types-BEPZc6eo.d.ts.map +1 -0
- package/dist/{usage-receipt-t7vAzCRQ.js → types-BI4fT3HN.js} +67 -67
- package/dist/types-BI4fT3HN.js.map +1 -0
- package/dist/{types-BnjdJ70P.d.ts → types-BZ59Ahr8.d.ts} +5 -5
- package/dist/{types-BnjdJ70P.d.ts.map → types-BZ59Ahr8.d.ts.map} +1 -1
- package/dist/{types-D216SgwM.d.ts → types-Cx3YUh2r.d.ts} +4 -241
- package/dist/types-Cx3YUh2r.d.ts.map +1 -0
- package/dist/{types-BvDKaULh.d.ts → types-DLQx4mKU.d.ts} +4 -4
- package/dist/{types-BvDKaULh.d.ts.map → types-DLQx4mKU.d.ts.map} +1 -1
- package/dist/{types-D4mog56g.d.ts → types-yLK8gXE9.d.ts} +2 -2
- package/dist/{types-D4mog56g.d.ts.map → types-yLK8gXE9.d.ts.map} +1 -1
- package/dist/verdict-BndeTAh_.js +61 -0
- package/dist/verdict-BndeTAh_.js.map +1 -0
- package/dist/verdict-E4eRNf7-.d.ts +392 -0
- package/dist/verdict-E4eRNf7-.d.ts.map +1 -0
- package/dist/{verdict-cache-BCcOh0kF.js → verdict-cache-mZf5FEiY.js} +3 -55
- package/dist/{verdict-cache-BCcOh0kF.js.map → verdict-cache-mZf5FEiY.js.map} +1 -1
- package/dist/wire/index.d.ts +3 -3
- package/dist/wire/index.d.ts.map +1 -1
- package/dist/wire/index.js +1 -1
- package/docs/charter.md +3 -3
- package/docs/control-runtime.md +3 -42
- package/docs/experiment.md +0 -1
- package/docs/feature-guide.md +2 -2
- package/docs/trace-repair-grader.md +1 -0
- package/docs/trajectory-replay.md +1 -0
- package/docs/verdicts.md +43 -0
- package/docs/verification-strategies.md +3 -2
- package/package.json +6 -11
- package/dist/agent-profile-DPi7IZg7.d.ts.map +0 -1
- package/dist/analyze-runs-C30yljDJ.js.map +0 -1
- package/dist/baseline-CavEbRyH.d.ts +0 -136
- package/dist/baseline-CavEbRyH.d.ts.map +0 -1
- package/dist/benchmark-command-BteMFN62.js.map +0 -1
- package/dist/benchmarks-Dzs8CKb1.js +0 -755
- package/dist/benchmarks-Dzs8CKb1.js.map +0 -1
- package/dist/campaign-C2TTzQII.js.map +0 -1
- package/dist/completion-verifier-DJA5BhPb.d.ts +0 -414
- package/dist/completion-verifier-DJA5BhPb.d.ts.map +0 -1
- package/dist/control.d.ts +0 -3
- package/dist/control.js +0 -2
- package/dist/dataset-C8xaLXdY.d.ts.map +0 -1
- package/dist/default-registry-Bf8Woqmq.d.ts.map +0 -1
- package/dist/default-registry-BmktKy8r.js.map +0 -1
- package/dist/engine-3hL-XqwJ.d.ts.map +0 -1
- package/dist/experiment-tracker-CnRICnMl.js +0 -500
- package/dist/experiment-tracker-CnRICnMl.js.map +0 -1
- package/dist/experiment-tracker-IMntXr6J.d.ts.map +0 -1
- package/dist/extract-usage-CdZdoj1s.js.map +0 -1
- package/dist/failure-cluster-CqcvCcdR.d.ts.map +0 -1
- package/dist/feedback-trajectory-CacHpxsp.d.ts.map +0 -1
- package/dist/index-BZ3-y4YL.d.ts +0 -391
- package/dist/index-BZ3-y4YL.d.ts.map +0 -1
- package/dist/index-CQTZ-4XN.d.ts.map +0 -1
- package/dist/index-DPPGNJ_R.d.ts.map +0 -1
- package/dist/index-YE4KdKbO2.d.ts +0 -335
- package/dist/index-YE4KdKbO2.d.ts.map +0 -1
- package/dist/paired-arms-iZ08VFMN.js +0 -260
- package/dist/paired-arms-iZ08VFMN.js.map +0 -1
- package/dist/paired-promotion-decision-B6zJ3gYM.d.ts +0 -114
- package/dist/paired-promotion-decision-B6zJ3gYM.d.ts.map +0 -1
- package/dist/prime-protocol-BfSalTfR.js.map +0 -1
- package/dist/promotion-policy-Ckjhzg_4.d.ts +0 -289
- package/dist/promotion-policy-Ckjhzg_4.d.ts.map +0 -1
- package/dist/promotion-policy-CrLrmys8.js.map +0 -1
- package/dist/proposal-findings-2GIUo1et.js.map +0 -1
- package/dist/propose-review-control-dSNPjFUH.js +0 -1458
- package/dist/propose-review-control-dSNPjFUH.js.map +0 -1
- package/dist/release-report-BUYmoKo2.js.map +0 -1
- package/dist/release-report-DA2BCu5a.d.ts.map +0 -1
- package/dist/replay-CohS93nE.js +0 -1859
- package/dist/replay-CohS93nE.js.map +0 -1
- package/dist/replay-DbhZ4Ked.d.ts +0 -834
- package/dist/replay-DbhZ4Ked.d.ts.map +0 -1
- package/dist/reward-hacking-BDToousL.js.map +0 -1
- package/dist/run-evidence-Dhi3C81V.d.ts +0 -225
- package/dist/run-evidence-Dhi3C81V.d.ts.map +0 -1
- package/dist/schema-Cef2cFmb2.d.ts.map +0 -1
- package/dist/semantic-concept-judge-D1z-KepS.js +0 -767
- package/dist/semantic-concept-judge-D1z-KepS.js.map +0 -1
- package/dist/series-convergence-ofsqPWhs.d.ts +0 -35
- package/dist/series-convergence-ofsqPWhs.d.ts.map +0 -1
- package/dist/server-iu0ede49.js.map +0 -1
- package/dist/single-run-lock-DFWHEB09.js.map +0 -1
- package/dist/skill-usage-CO9OLRBx.d.ts.map +0 -1
- package/dist/skillopt-optimization-method-CQdVeM8k.js.map +0 -1
- package/dist/skillopt-optimization-method-USDKhxSA.d.ts.map +0 -1
- package/dist/statistical-heldout-TQ-4CYiN.d.ts.map +0 -1
- package/dist/statistics-ByxzSiOM.js +0 -2212
- package/dist/statistics-ByxzSiOM.js.map +0 -1
- package/dist/statistics-D6Uebe_4.d.ts +0 -968
- package/dist/statistics-D6Uebe_4.d.ts.map +0 -1
- package/dist/supervisor-run-D_sokXcO.js +0 -1690
- package/dist/test-graded-scenario-D1TaI2va.d.ts +0 -141
- package/dist/test-graded-scenario-D1TaI2va.d.ts.map +0 -1
- package/dist/test-graded-scenario-JHcKQNpq.js +0 -318
- package/dist/test-graded-scenario-JHcKQNpq.js.map +0 -1
- package/dist/tool-groups-CZPGGlHf.d.ts.map +0 -1
- package/dist/tool-use-metrics-DEGMKycK.js +0 -370
- package/dist/tool-use-metrics-DEGMKycK.js.map +0 -1
- package/dist/types-D216SgwM.d.ts.map +0 -1
- package/dist/usage-receipt-t7vAzCRQ.js.map +0 -1
- package/dist/verdict-DExhxfgR.d.ts +0 -201
- package/dist/verdict-DExhxfgR.d.ts.map +0 -1
package/dist/traces.js
CHANGED
|
@@ -1,13 +1,1014 @@
|
|
|
1
|
-
import { a as providerFromBaseUrl, i as defaultProviderRedactor, n as InMemoryRawProviderSink, r as NoopRawProviderSink, t as FileSystemRawProviderSink } from "./raw-provider-sink-BQd7mzyT.js";
|
|
2
|
-
import { INPUT_VALUE, LLM_CACHED_TOKENS, LLM_CACHED_TOKEN_ATTR_KEYS, LLM_CACHE_WRITE_TOKENS, LLM_CACHE_WRITE_TOKEN_ATTR_KEYS, LLM_CONTEXT_TOKENS, LLM_COST_ATTR_KEYS, LLM_COST_USD, LLM_INPUT_TOKENS, LLM_INPUT_TOKEN_ATTR_KEYS, LLM_MODEL_ATTR_KEYS, LLM_MODEL_NAME, LLM_OUTPUT_TOKENS, LLM_OUTPUT_TOKEN_ATTR_KEYS, LLM_REASONING_TOKENS, LLM_REASONING_TOKEN_ATTR_KEYS, OPENINFERENCE_SPAN_KIND, OUTPUT_VALUE, RUN_COST_ATTR_KEYS, SPAN_KIND_ATTR_KEYS, TOOL_ARGS_CAPTURED, TOOL_LATENCY_MS, TOOL_NAME, TOOL_NAME_ATTR_KEYS, applyLlmSpanOtlpAttributes, asNumber, contextInputTokens, firstNumberAttr } from "./trace-attributes.js";
|
|
3
|
-
import { $ as stringField, C as TraceNotFoundError, G as asString, J as firstStringAttr, S as TraceFileTooLargeError, X as projectOtlpFlatLine, Y as inferOtlpKind, Z as readOtlpStatus, _ as TraceAnalysisLimitError, b as TraceFileMalformedError, c as traceAnalystFunctionGroup, et as applyToolSpanOtlpAttributes, g as SpanNotFoundError, h as TRACE_ANALYSIS_LIMITS, l as createBoundedTraceAnalysisStore, m as TRACE_ANALYST_TRUNCATION_MARKER_PREFIX, nt as isOtlpModelCall, o as TRACE_ANALYST_TOOL_NAMESPACE, p as DEFAULT_TRACE_ANALYST_BUDGETS, q as extractOtlpAttributes, rt as traceSpanKindToOpenInferenceKind, s as buildTraceAnalysisToolDescriptors, tt as classifyOtlpSpanRole, v as TraceAnalysisStoreContractError, x as TraceFileMissingError, y as TraceAnalysisValidationError } from "./kind-factory-B8-r8-y8.js";
|
|
4
|
-
import { n as llmSpanFromProvider, t as TraceEmitter } from "./emitter-CPBAhxum.js";
|
|
5
1
|
import { a as isRetrievalSpan, i as isLlmSpan, n as TRACE_SCHEMA_VERSION, o as isSandboxSpan, r as isJudgeSpan, s as isToolSpan, t as FAILURE_CLASSES } from "./schema-CRhEY1SO.js";
|
|
6
|
-
import { A as TRACE_ANALYST_ACTOR_DESCRIPTION, C as domainEvidencePattern, D as tokenizeDomainWords, E as scoreTraceInsightReadiness, O as traceAnalystOnRunComplete, S as describeTraceInsightScope, T as planTraceInsightQuestions, _ as otlpToTraceRunRecords, a as convertTraceStoresToOtlp, b as buildTraceInsightPrompt, c as otelRunCompleteHook, d as captureFetchToRawSink, f as ToolTraceMissingError, g as otlpToRunRecords, h as otlpRowsToTraceRunRecords, i as iterateRawCalls, j as TRACE_ANALYST_ACTOR_DESCRIPTION_VERSION, k as analyzeTraces, l as OTEL_AGENT_EVAL_SCOPE, m as otlpRowsToRunRecords, n as ReplayCacheMissError, o as createOtelExporter, p as toolSpansToTraceAnalysisStore, r as createReplayFetch, s as createOtelTracingStore, t as ReplayCache, u as exportRunAsOtlp, v as flattenOtlpExportToNdjson, w as inferDomainKeywords, x as defaultTraceInsightPanel, y as buildTraceInsightContext } from "./replay-CohS93nE.js";
|
|
7
|
-
import { i as otlpTextToTraceAnalysisStore, n as OtlpFileTraceStore } from "./store-otlp-Dw8PPIlL.js";
|
|
8
|
-
import { n as extractUsageFromResponse, r as extractUsageFromSse, t as extractUsage } from "./extract-usage-CdZdoj1s.js";
|
|
9
2
|
import { a as judgeSpans, c as runsForScenario, i as hasCapturedToolArgs, l as toolSpans, n as argHash, o as llmSpans, r as groupBy, s as runFailureClass, t as aggregateLlm } from "./query-Di7eEQ79.js";
|
|
10
|
-
import {
|
|
11
|
-
import { n as assertRunCaptured, r as throwIfRunIncomplete, t as RunIntegrityError } from "./integrity-MLzHOfV9.js";
|
|
3
|
+
import { r as modelHasSnapshot, s as validateRunRecord } from "./run-record-BvHPVS-i.js";
|
|
12
4
|
import { i as redactValue, n as REDACTION_VERSION, r as redactString, t as DEFAULT_REDACTION_RULES } from "./redact-7Aq1ukl-.js";
|
|
13
|
-
|
|
5
|
+
import { n as llmSpanFromProvider, t as TraceEmitter } from "./emitter-CPBAhxum.js";
|
|
6
|
+
import { $ as classifyOtlpSpanRole, C as TraceNotFoundError, G as extractOtlpAttributes, J as projectOtlpFlatLine, K as firstStringAttr, Q as applyToolSpanOtlpAttributes, S as TraceFileTooLargeError, U as asString, W as compareSpanTime, X as spanEpochMillis, Y as readOtlpStatus, Z as stringField, _ as TraceAnalysisLimitError, b as TraceFileMalformedError, c as traceAnalystFunctionGroup, et as isOtlpModelCall, g as SpanNotFoundError, h as TRACE_ANALYSIS_LIMITS, l as createBoundedTraceAnalysisStore, m as TRACE_ANALYST_TRUNCATION_MARKER_PREFIX, o as TRACE_ANALYST_TOOL_NAMESPACE, p as DEFAULT_TRACE_ANALYST_BUDGETS, q as inferOtlpKind, s as buildTraceAnalysisToolDescriptors, tt as traceSpanKindToOpenInferenceKind, v as TraceAnalysisStoreContractError, x as TraceFileMissingError, y as TraceAnalysisValidationError } from "./kind-factory-CPmSd58s.js";
|
|
7
|
+
import { INPUT_VALUE, LLM_CACHED_TOKENS, LLM_CACHED_TOKEN_ATTR_KEYS, LLM_CACHE_WRITE_TOKENS, LLM_CACHE_WRITE_TOKEN_ATTR_KEYS, LLM_CONTEXT_TOKENS, LLM_COST_ATTR_KEYS, LLM_COST_USD, LLM_INPUT_TOKENS, LLM_INPUT_TOKEN_ATTR_KEYS, LLM_MODEL_ATTR_KEYS, LLM_MODEL_NAME, LLM_OUTPUT_TOKENS, LLM_OUTPUT_TOKEN_ATTR_KEYS, LLM_REASONING_TOKENS, LLM_REASONING_TOKEN_ATTR_KEYS, OPENINFERENCE_SPAN_KIND, OUTPUT_VALUE, RUN_COST_ATTR_KEYS, SPAN_KIND_ATTR_KEYS, TOOL_ARGS_CAPTURED, TOOL_LATENCY_MS, TOOL_NAME, TOOL_NAME_ATTR_KEYS, applyLlmSpanOtlpAttributes, asNumber, contextInputTokens, firstNumberAttr } from "./trace-attributes.js";
|
|
8
|
+
import { n as extractUsageFromResponse, r as extractUsageFromSse, t as extractUsage } from "./extract-usage-BrQ8mCLX.js";
|
|
9
|
+
import { a as providerFromBaseUrl, i as defaultProviderRedactor, n as InMemoryRawProviderSink, r as NoopRawProviderSink, t as FileSystemRawProviderSink } from "./raw-provider-sink-BQd7mzyT.js";
|
|
10
|
+
import { S as captureFetchToRawSink, _ as TRACE_ANALYST_ACTOR_DESCRIPTION_VERSION, a as spanStatusToOtlp, b as spanIdForWire, c as defaultTraceInsightPanel, d as inferDomainKeywords, f as planTraceInsightQuestions, g as TRACE_ANALYST_ACTOR_DESCRIPTION, h as analyzeTraces, i as epochMillisToIso, l as describeTraceInsightScope, m as tokenizeDomainWords, n as toolSpansToTraceAnalysisStore, o as buildTraceInsightContext, p as scoreTraceInsightReadiness, r as createOtlpFlatLine, s as buildTraceInsightPrompt, t as ToolTraceMissingError, u as domainEvidencePattern, v as OTEL_AGENT_EVAL_SCOPE, x as traceIdForWire, y as exportRunAsOtlp } from "./store-tool-spans-Cq9mFd-q.js";
|
|
11
|
+
import { n as assertRunCaptured, r as throwIfRunIncomplete, t as RunIntegrityError } from "./integrity-Cy9WHAtb.js";
|
|
12
|
+
import { n as InMemoryTraceStore, t as FileSystemTraceStore } from "./store-DNe_Uv1Q.js";
|
|
13
|
+
import { i as otlpTextToTraceAnalysisStore, n as OtlpFileTraceStore } from "./store-otlp-CsptLYpN.js";
|
|
14
|
+
import { i as summarizeTraceErrors, n as recordAggregateMeasurements, r as summarizeExecutionMeasurements, t as readTaskFailureLabels } from "./task-failure-attributes-CpQ4y5RD.js";
|
|
15
|
+
import { readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
//#region src/trace/otel-bridge.ts
|
|
18
|
+
/**
|
|
19
|
+
* Create a RunCompleteHook that exports all spans from the completed run
|
|
20
|
+
* to the OTEL exporter, then flushes.
|
|
21
|
+
*/
|
|
22
|
+
function otelRunCompleteHook(exporter) {
|
|
23
|
+
return async (ctx) => {
|
|
24
|
+
const spans = await ctx.store.spans({ runId: ctx.runId });
|
|
25
|
+
for (const span of spans) if (span.endedAt) exporter.exportSpan(storeSpanToExportable(span, ctx.runId));
|
|
26
|
+
await exporter.flush();
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create an auto-exporting TraceStore wrapper that intercepts updateSpan
|
|
31
|
+
* calls. When a span gets an endedAt, it's exported immediately. This
|
|
32
|
+
* gives real-time streaming instead of batch-at-end.
|
|
33
|
+
*
|
|
34
|
+
* This is the preferred integration path: wrap the store before
|
|
35
|
+
* constructing the TraceEmitter.
|
|
36
|
+
*/
|
|
37
|
+
function createOtelTracingStore(inner, exporter, traceId) {
|
|
38
|
+
return {
|
|
39
|
+
async appendRun(run) {
|
|
40
|
+
return inner.appendRun(run);
|
|
41
|
+
},
|
|
42
|
+
async updateRun(runId, patch) {
|
|
43
|
+
return inner.updateRun(runId, patch);
|
|
44
|
+
},
|
|
45
|
+
async appendSpan(span) {
|
|
46
|
+
if (span.endedAt) exporter.exportSpan(storeSpanToExportable(span, traceId));
|
|
47
|
+
return inner.appendSpan(span);
|
|
48
|
+
},
|
|
49
|
+
async updateSpan(spanId, patch) {
|
|
50
|
+
await inner.updateSpan(spanId, patch);
|
|
51
|
+
if (patch.endedAt) {
|
|
52
|
+
const found = (await inner.spans({ runId: traceId })).find((s) => s.spanId === spanId);
|
|
53
|
+
if (found) exporter.exportSpan(storeSpanToExportable(found, traceId));
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
async appendEvent(event) {
|
|
57
|
+
return inner.appendEvent(event);
|
|
58
|
+
},
|
|
59
|
+
async appendBudgetEntry(entry) {
|
|
60
|
+
return inner.appendBudgetEntry(entry);
|
|
61
|
+
},
|
|
62
|
+
async appendArtifact(artifact) {
|
|
63
|
+
return inner.appendArtifact(artifact);
|
|
64
|
+
},
|
|
65
|
+
getRun: inner.getRun.bind(inner),
|
|
66
|
+
listRuns: inner.listRuns.bind(inner),
|
|
67
|
+
spans: inner.spans.bind(inner),
|
|
68
|
+
events: inner.events.bind(inner),
|
|
69
|
+
budget: inner.budget.bind(inner),
|
|
70
|
+
artifacts: inner.artifacts.bind(inner)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function storeSpanToExportable(span, traceId) {
|
|
74
|
+
const llm = span.kind === "llm" ? span : void 0;
|
|
75
|
+
const tool = span.kind === "tool" ? span : void 0;
|
|
76
|
+
return {
|
|
77
|
+
traceId,
|
|
78
|
+
spanId: span.spanId,
|
|
79
|
+
parentSpanId: span.parentSpanId,
|
|
80
|
+
name: span.name,
|
|
81
|
+
kind: span.kind,
|
|
82
|
+
startedAt: span.startedAt,
|
|
83
|
+
endedAt: span.endedAt,
|
|
84
|
+
status: span.status,
|
|
85
|
+
error: span.error,
|
|
86
|
+
model: llm?.model,
|
|
87
|
+
inputTokens: llm?.inputTokens,
|
|
88
|
+
outputTokens: llm?.outputTokens,
|
|
89
|
+
reasoningTokens: llm?.reasoningTokens,
|
|
90
|
+
cachedTokens: llm?.cachedTokens,
|
|
91
|
+
cacheWriteTokens: llm?.cacheWriteTokens,
|
|
92
|
+
costUsd: llm?.costUsd,
|
|
93
|
+
tool: tool ? {
|
|
94
|
+
toolName: tool.toolName,
|
|
95
|
+
args: tool.args,
|
|
96
|
+
argsCaptured: tool.argsCaptured,
|
|
97
|
+
result: tool.result,
|
|
98
|
+
latencyMs: tool.latencyMs
|
|
99
|
+
} : void 0,
|
|
100
|
+
attributes: span.attributes
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/trace/otel-export.ts
|
|
105
|
+
/**
|
|
106
|
+
* OTEL span exporter — streams spans to an OTLP/HTTP collector.
|
|
107
|
+
*
|
|
108
|
+
* Reads OTEL_EXPORTER_OTLP_ENDPOINT + OTEL_EXPORTER_OTLP_HEADERS from env
|
|
109
|
+
* when no explicit config is given. Batches spans and flushes periodically
|
|
110
|
+
* or when the batch fills. No @opentelemetry SDK dependency — minimal
|
|
111
|
+
* OTLP/JSON serializer (~120 LOC) using the existing otel.ts helpers.
|
|
112
|
+
*/
|
|
113
|
+
/**
|
|
114
|
+
* Create an OTEL exporter. Returns undefined when no endpoint is configured
|
|
115
|
+
* (neither via config nor env) — callers should check before attaching.
|
|
116
|
+
*/
|
|
117
|
+
function createOtelExporter(config) {
|
|
118
|
+
const resolvedEndpoint = config?.endpoint ?? (typeof process !== "undefined" ? process.env.OTEL_EXPORTER_OTLP_ENDPOINT : void 0);
|
|
119
|
+
if (!resolvedEndpoint) return void 0;
|
|
120
|
+
const endpoint = resolvedEndpoint;
|
|
121
|
+
const headers = config?.headers ?? parseHeadersFromEnv();
|
|
122
|
+
const batchSize = config?.batchSize ?? 64;
|
|
123
|
+
const flushIntervalMs = config?.flushIntervalMs ?? 5e3;
|
|
124
|
+
const serviceName = config?.serviceName ?? "agent-eval";
|
|
125
|
+
const resourceAttrs = config?.resourceAttributes ?? {};
|
|
126
|
+
const pending = [];
|
|
127
|
+
let timer;
|
|
128
|
+
let stopped = false;
|
|
129
|
+
const exporter = {
|
|
130
|
+
exportSpan(span) {
|
|
131
|
+
if (stopped) return;
|
|
132
|
+
pending.push(toOtlpSpan(span));
|
|
133
|
+
if (pending.length >= batchSize) doFlush();
|
|
134
|
+
},
|
|
135
|
+
async flush() {
|
|
136
|
+
await doFlush();
|
|
137
|
+
},
|
|
138
|
+
async shutdown() {
|
|
139
|
+
stopped = true;
|
|
140
|
+
if (timer !== void 0) {
|
|
141
|
+
clearInterval(timer);
|
|
142
|
+
timer = void 0;
|
|
143
|
+
}
|
|
144
|
+
await doFlush();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
timer = setInterval(() => {
|
|
148
|
+
if (pending.length > 0) doFlush();
|
|
149
|
+
}, flushIntervalMs);
|
|
150
|
+
if (typeof timer === "object" && "unref" in timer) timer.unref();
|
|
151
|
+
async function doFlush() {
|
|
152
|
+
if (pending.length === 0) return;
|
|
153
|
+
const batch = pending.splice(0);
|
|
154
|
+
const body = { resourceSpans: [{
|
|
155
|
+
resource: { attributes: toAttributes({
|
|
156
|
+
"service.name": serviceName,
|
|
157
|
+
...resourceAttrs
|
|
158
|
+
}) },
|
|
159
|
+
scopeSpans: [{
|
|
160
|
+
scope: OTEL_AGENT_EVAL_SCOPE,
|
|
161
|
+
spans: batch
|
|
162
|
+
}]
|
|
163
|
+
}] };
|
|
164
|
+
const url = `${endpoint.replace(/\/+$/, "")}/v1/traces`;
|
|
165
|
+
try {
|
|
166
|
+
await fetch(url, {
|
|
167
|
+
method: "POST",
|
|
168
|
+
headers: {
|
|
169
|
+
"content-type": "application/json",
|
|
170
|
+
...headers
|
|
171
|
+
},
|
|
172
|
+
body: JSON.stringify(body)
|
|
173
|
+
});
|
|
174
|
+
} catch {}
|
|
175
|
+
}
|
|
176
|
+
return exporter;
|
|
177
|
+
}
|
|
178
|
+
function parseHeadersFromEnv() {
|
|
179
|
+
if (typeof process === "undefined") return {};
|
|
180
|
+
const raw = process.env.OTEL_EXPORTER_OTLP_HEADERS;
|
|
181
|
+
if (!raw) return {};
|
|
182
|
+
const out = {};
|
|
183
|
+
for (const pair of raw.split(",")) {
|
|
184
|
+
const eq = pair.indexOf("=");
|
|
185
|
+
if (eq < 0) continue;
|
|
186
|
+
const key = pair.slice(0, eq).trim();
|
|
187
|
+
const value = pair.slice(eq + 1).trim();
|
|
188
|
+
if (key) out[key] = value;
|
|
189
|
+
}
|
|
190
|
+
return out;
|
|
191
|
+
}
|
|
192
|
+
function toOtlpSpan(span) {
|
|
193
|
+
const endedAt = span.endedAt ?? span.startedAt;
|
|
194
|
+
const attrs = {};
|
|
195
|
+
if (span.attributes) {
|
|
196
|
+
for (const [k, v] of Object.entries(span.attributes)) if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") attrs[k] = v;
|
|
197
|
+
}
|
|
198
|
+
attrs[OPENINFERENCE_SPAN_KIND] = traceSpanKindToOpenInferenceKind(span.kind);
|
|
199
|
+
applyLlmSpanOtlpAttributes(attrs, span);
|
|
200
|
+
if (span.tool) applyToolSpanOtlpAttributes(attrs, span.tool);
|
|
201
|
+
return {
|
|
202
|
+
traceId: traceIdForWire(span.traceId),
|
|
203
|
+
spanId: spanIdForWire(span.spanId),
|
|
204
|
+
parentSpanId: span.parentSpanId ? spanIdForWire(span.parentSpanId) : void 0,
|
|
205
|
+
name: span.name,
|
|
206
|
+
kind: 1,
|
|
207
|
+
startTimeUnixNano: msToNs(span.startedAt),
|
|
208
|
+
endTimeUnixNano: msToNs(endedAt),
|
|
209
|
+
attributes: toAttributes(attrs),
|
|
210
|
+
status: span.status === "error" ? {
|
|
211
|
+
code: 2,
|
|
212
|
+
message: span.error
|
|
213
|
+
} : { code: 1 }
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function toAttributes(record) {
|
|
217
|
+
return Object.entries(record).map(([key, value]) => ({
|
|
218
|
+
key,
|
|
219
|
+
value: typeof value === "number" ? Number.isInteger(value) ? { intValue: value.toString() } : { doubleValue: value } : typeof value === "boolean" ? { boolValue: value } : { stringValue: value }
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
function msToNs(ms) {
|
|
223
|
+
return (BigInt(Math.floor(ms)) * 1000000n).toString();
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region src/trace/store-to-otlp.ts
|
|
227
|
+
/**
|
|
228
|
+
* Convert agent-eval's internal trace shape (`FileSystemTraceStore` → `Run`,
|
|
229
|
+
* `Span`, `TraceEvent`) into the OTLP-flat JSONL the trace analyst
|
|
230
|
+
* (`analyzeTraces` + `OtlpFileTraceStore`) reads.
|
|
231
|
+
*
|
|
232
|
+
* Eval harnesses shard a `FileSystemTraceStore` per cell (persona / variant)
|
|
233
|
+
* under a run directory. The analyst consumes a single OTLP-NDJSON file keyed
|
|
234
|
+
* on `trace_id` + `span_id` with `start_time`/`end_time` in ISO-8601 and
|
|
235
|
+
* resource + `attributes` rolled up per-span. This module walks every shard,
|
|
236
|
+
* projects each `Span` (plus events pinned to it) into the flat OTLP shape,
|
|
237
|
+
* and emits one NDJSON file.
|
|
238
|
+
*
|
|
239
|
+
* Generic OTLP/OpenInference fields are always emitted (`service.name`,
|
|
240
|
+
* `agent.name`, `run.id`/`run.status`, `openinference.span.kind`,
|
|
241
|
+
* `llm.model_name`, …). Domain attributes (`legal.*`, `tax.*`, …) are injected
|
|
242
|
+
* per-run via {@link TraceStoreToOtlpOptions.resourceAttributes} /
|
|
243
|
+
* {@link TraceStoreToOtlpOptions.runAttributes} so consumers don't re-roll the
|
|
244
|
+
* walker.
|
|
245
|
+
*/
|
|
246
|
+
/**
|
|
247
|
+
* Read every per-cell shard under each source root and write a flat OTLP-JSONL
|
|
248
|
+
* view of the corpus to `outPath`. Each cell directory is a
|
|
249
|
+
* `FileSystemTraceStore` — NDJSON append-only with size-based rotation;
|
|
250
|
+
* `updateRun`/`updateSpan` append `{ id, ...patch, _update: true }` rows
|
|
251
|
+
* rather than rewriting, so readers must merge those patches in (done here).
|
|
252
|
+
*
|
|
253
|
+
* A `string` source is treated as a celled root.
|
|
254
|
+
*/
|
|
255
|
+
function convertTraceStoresToOtlp(source, outPath, opts = {}) {
|
|
256
|
+
const sources = Array.isArray(source) ? [...source] : typeof source === "string" ? [{
|
|
257
|
+
root: source,
|
|
258
|
+
layout: "celled"
|
|
259
|
+
}] : [source];
|
|
260
|
+
const defaultServiceName = opts.serviceName ?? "agent-eval";
|
|
261
|
+
const resourceAttributes = opts.resourceAttributes ?? (() => ({}));
|
|
262
|
+
const runAttributes = opts.runAttributes ?? (() => ({}));
|
|
263
|
+
const lines = [];
|
|
264
|
+
let spanCount = 0;
|
|
265
|
+
let runCount = 0;
|
|
266
|
+
let cellCount = 0;
|
|
267
|
+
let cellErrorCount = 0;
|
|
268
|
+
for (const src of sources) {
|
|
269
|
+
const serviceName = src.serviceName ?? defaultServiceName;
|
|
270
|
+
const cellDirs = src.layout === "flat" ? [{
|
|
271
|
+
label: "<root>",
|
|
272
|
+
dir: src.root
|
|
273
|
+
}] : listCells(src.root).map((name) => ({
|
|
274
|
+
label: name,
|
|
275
|
+
dir: join(src.root, name)
|
|
276
|
+
}));
|
|
277
|
+
for (const cell of cellDirs) try {
|
|
278
|
+
const result = projectCell({
|
|
279
|
+
cellDir: cell.dir,
|
|
280
|
+
serviceName,
|
|
281
|
+
resourceAttributes,
|
|
282
|
+
runAttributes
|
|
283
|
+
});
|
|
284
|
+
for (const line of result.lines) lines.push(line);
|
|
285
|
+
spanCount += result.spanCount;
|
|
286
|
+
runCount += result.runCount;
|
|
287
|
+
cellCount += 1;
|
|
288
|
+
} catch (err) {
|
|
289
|
+
console.warn(`[traces-to-otlp] cell ${cell.label} (${cell.dir}) skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
290
|
+
cellErrorCount += 1;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
writeFileSync(outPath, lines.join("\n") + (lines.length > 0 ? "\n" : ""));
|
|
294
|
+
return {
|
|
295
|
+
spanCount,
|
|
296
|
+
runCount,
|
|
297
|
+
cellCount,
|
|
298
|
+
cellErrorCount
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
function projectCell(args) {
|
|
302
|
+
const { cellDir, serviceName, resourceAttributes, runAttributes } = args;
|
|
303
|
+
const lines = [];
|
|
304
|
+
let runCount = 0;
|
|
305
|
+
let spanCount = 0;
|
|
306
|
+
const runs = readMergedShards(cellDir, "runs", "runId");
|
|
307
|
+
const spans = readMergedShards(cellDir, "spans", "spanId");
|
|
308
|
+
const events = readShards(cellDir, "events");
|
|
309
|
+
const runByRunId = /* @__PURE__ */ new Map();
|
|
310
|
+
for (const r of runs) runByRunId.set(r.runId, r);
|
|
311
|
+
const spanBySpanId = /* @__PURE__ */ new Map();
|
|
312
|
+
for (const s of spans) spanBySpanId.set(s.spanId, s);
|
|
313
|
+
const eventsBySpanId = /* @__PURE__ */ new Map();
|
|
314
|
+
for (const e of events) {
|
|
315
|
+
if (e.kind === "state_mutation" && e.payload && typeof e.payload === "object") {
|
|
316
|
+
const entity = e.payload.entity;
|
|
317
|
+
if (entity === "run") {
|
|
318
|
+
const run = e.payload.run;
|
|
319
|
+
if (run?.runId) runByRunId.set(run.runId, run);
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
if (entity === "run.update") {
|
|
323
|
+
const patch = e.payload.patch;
|
|
324
|
+
if (patch && e.runId) {
|
|
325
|
+
const prior = runByRunId.get(e.runId);
|
|
326
|
+
if (prior) runByRunId.set(e.runId, {
|
|
327
|
+
...prior,
|
|
328
|
+
...patch
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
if (entity === "span") {
|
|
334
|
+
const span = e.payload.span;
|
|
335
|
+
if (span?.spanId) spanBySpanId.set(span.spanId, span);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
if (entity === "span.update") {
|
|
339
|
+
const spanId = e.payload.spanId;
|
|
340
|
+
const patch = e.payload.patch;
|
|
341
|
+
if (spanId && patch) {
|
|
342
|
+
const prior = spanBySpanId.get(spanId);
|
|
343
|
+
if (prior) spanBySpanId.set(spanId, {
|
|
344
|
+
...prior,
|
|
345
|
+
...patch
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (!e.spanId) continue;
|
|
352
|
+
const arr = eventsBySpanId.get(e.spanId) ?? [];
|
|
353
|
+
arr.push(e);
|
|
354
|
+
eventsBySpanId.set(e.spanId, arr);
|
|
355
|
+
}
|
|
356
|
+
for (const run of runByRunId.values()) {
|
|
357
|
+
const traceId = traceIdForWire(run.runId);
|
|
358
|
+
const agentName = run.variantId ?? run.scenarioId;
|
|
359
|
+
const sharedResource = { attributes: {
|
|
360
|
+
"service.name": serviceName,
|
|
361
|
+
"agent.name": agentName,
|
|
362
|
+
"run.id": run.runId,
|
|
363
|
+
"run.status": run.status,
|
|
364
|
+
...resourceAttributes(run)
|
|
365
|
+
} };
|
|
366
|
+
const runSpanId = spanIdForWire(`run-${run.runId}`);
|
|
367
|
+
const runStart = msToIso(run.startedAt);
|
|
368
|
+
const runEnd = msToIso(run.endedAt ?? run.startedAt);
|
|
369
|
+
const runStatus = run.outcome?.failureClass && run.outcome.failureClass !== "success" ? "STATUS_CODE_ERROR" : "STATUS_CODE_OK";
|
|
370
|
+
const runAttrs = {
|
|
371
|
+
[OPENINFERENCE_SPAN_KIND]: "AGENT",
|
|
372
|
+
"agent.name": agentName,
|
|
373
|
+
"agent.workflow.name": serviceName,
|
|
374
|
+
...runAttributes(run)
|
|
375
|
+
};
|
|
376
|
+
lines.push(JSON.stringify(toLine({
|
|
377
|
+
traceId,
|
|
378
|
+
spanId: runSpanId,
|
|
379
|
+
parentSpanId: "",
|
|
380
|
+
name: `run.${agentName}`,
|
|
381
|
+
kind: "SPAN_KIND_INTERNAL",
|
|
382
|
+
startTime: runStart,
|
|
383
|
+
endTime: runEnd,
|
|
384
|
+
statusCode: runStatus,
|
|
385
|
+
statusMessage: run.outcome?.notes ?? "",
|
|
386
|
+
resource: sharedResource,
|
|
387
|
+
attributes: runAttrs
|
|
388
|
+
})));
|
|
389
|
+
runCount += 1;
|
|
390
|
+
for (const span of spanBySpanId.values()) {
|
|
391
|
+
if (span.runId !== run.runId) continue;
|
|
392
|
+
const spanAttrs = spanToAttributes(span, eventsBySpanId.get(span.spanId) ?? []);
|
|
393
|
+
const statusCode = spanStatusToOtlp(span.status, span.error, "STATUS_CODE_OK");
|
|
394
|
+
lines.push(JSON.stringify(toLine({
|
|
395
|
+
traceId,
|
|
396
|
+
spanId: spanIdForWire(span.spanId),
|
|
397
|
+
parentSpanId: span.parentSpanId ? spanIdForWire(span.parentSpanId) : runSpanId,
|
|
398
|
+
name: span.name,
|
|
399
|
+
kind: spanKindToOtlpKind(span.kind),
|
|
400
|
+
startTime: msToIso(span.startedAt),
|
|
401
|
+
endTime: msToIso(span.endedAt ?? span.startedAt),
|
|
402
|
+
statusCode,
|
|
403
|
+
statusMessage: span.error ?? "",
|
|
404
|
+
resource: sharedResource,
|
|
405
|
+
attributes: spanAttrs
|
|
406
|
+
})));
|
|
407
|
+
spanCount += 1;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
lines,
|
|
412
|
+
runCount,
|
|
413
|
+
spanCount
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
function listCells(root) {
|
|
417
|
+
try {
|
|
418
|
+
return readdirSync(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
|
|
419
|
+
} catch {
|
|
420
|
+
return [];
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Read every NDJSON shard for `name` under `cellDir`, ordered by mtime so
|
|
425
|
+
* rotated files apply before the active one. Yields raw rows including any
|
|
426
|
+
* `_update: true` patches.
|
|
427
|
+
*/
|
|
428
|
+
function readShards(cellDir, name) {
|
|
429
|
+
let entries;
|
|
430
|
+
try {
|
|
431
|
+
entries = readdirSync(cellDir);
|
|
432
|
+
} catch {
|
|
433
|
+
return [];
|
|
434
|
+
}
|
|
435
|
+
const shards = entries.filter((f) => (f === `${name}.ndjson` || f.startsWith(`${name}.`)) && f.endsWith(".ndjson")).map((f) => ({
|
|
436
|
+
file: f,
|
|
437
|
+
path: join(cellDir, f)
|
|
438
|
+
})).map((s) => {
|
|
439
|
+
let mtime = 0;
|
|
440
|
+
try {
|
|
441
|
+
mtime = statSync(s.path).mtimeMs;
|
|
442
|
+
} catch {}
|
|
443
|
+
return {
|
|
444
|
+
...s,
|
|
445
|
+
mtime
|
|
446
|
+
};
|
|
447
|
+
}).sort((a, b) => a.mtime - b.mtime || a.file.localeCompare(b.file));
|
|
448
|
+
const rows = [];
|
|
449
|
+
for (const shard of shards) {
|
|
450
|
+
let text;
|
|
451
|
+
try {
|
|
452
|
+
text = readFileSync(shard.path, "utf-8");
|
|
453
|
+
} catch {
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
for (const line of text.split("\n")) {
|
|
457
|
+
const trimmed = line.trim();
|
|
458
|
+
if (!trimmed) continue;
|
|
459
|
+
try {
|
|
460
|
+
rows.push(JSON.parse(trimmed));
|
|
461
|
+
} catch {}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return rows;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Read NDJSON shards and merge `{ ...patch, _update: true }` rows into the
|
|
468
|
+
* prior record keyed on `idKey` — mirrors the in-memory merge
|
|
469
|
+
* `FileSystemTraceStore` keeps but doesn't replay on cross-process load.
|
|
470
|
+
*/
|
|
471
|
+
function readMergedShards(cellDir, name, idKey) {
|
|
472
|
+
const rows = readShards(cellDir, name);
|
|
473
|
+
const byId = /* @__PURE__ */ new Map();
|
|
474
|
+
for (const row of rows) {
|
|
475
|
+
const id = row[idKey];
|
|
476
|
+
if (!id) continue;
|
|
477
|
+
const prior = byId.get(id);
|
|
478
|
+
if (prior && row._update) byId.set(id, {
|
|
479
|
+
...prior,
|
|
480
|
+
...row,
|
|
481
|
+
_update: void 0
|
|
482
|
+
});
|
|
483
|
+
else byId.set(id, row);
|
|
484
|
+
}
|
|
485
|
+
return [...byId.values()];
|
|
486
|
+
}
|
|
487
|
+
function spanToAttributes(span, events) {
|
|
488
|
+
const attrs = { [OPENINFERENCE_SPAN_KIND]: traceSpanKindToOpenInferenceKind(span.kind) };
|
|
489
|
+
if (span.kind === "llm") {
|
|
490
|
+
applyLlmSpanOtlpAttributes(attrs, span);
|
|
491
|
+
if (Array.isArray(span.messages)) attrs["llm.input_messages"] = JSON.stringify(span.messages.slice(-6));
|
|
492
|
+
if (typeof span.output === "string") attrs["llm.output_messages"] = JSON.stringify([{
|
|
493
|
+
role: "assistant",
|
|
494
|
+
content: span.output
|
|
495
|
+
}]);
|
|
496
|
+
} else if (span.kind === "tool") applyToolSpanOtlpAttributes(attrs, span);
|
|
497
|
+
else if (span.kind === "judge") {
|
|
498
|
+
attrs["judge.id"] = span.judgeId;
|
|
499
|
+
attrs["judge.dimension"] = span.dimension;
|
|
500
|
+
attrs["judge.score"] = span.score;
|
|
501
|
+
attrs["judge.target_span_id"] = span.targetSpanId;
|
|
502
|
+
}
|
|
503
|
+
if (span.attributes) for (const [k, v] of Object.entries(span.attributes)) attrs[`agent_eval.${k}`] = v;
|
|
504
|
+
if (events.length > 0) {
|
|
505
|
+
attrs["agent_eval.event_count"] = events.length;
|
|
506
|
+
attrs["agent_eval.event_kinds"] = JSON.stringify(events.map((e) => e.kind));
|
|
507
|
+
}
|
|
508
|
+
return attrs;
|
|
509
|
+
}
|
|
510
|
+
function spanKindToOtlpKind(kind) {
|
|
511
|
+
switch (kind) {
|
|
512
|
+
case "llm": return "SPAN_KIND_CLIENT";
|
|
513
|
+
case "retrieval": return "SPAN_KIND_CLIENT";
|
|
514
|
+
default: return "SPAN_KIND_INTERNAL";
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
const toLine = createOtlpFlatLine;
|
|
518
|
+
function msToIso(ms) {
|
|
519
|
+
if (ms <= 0) return (/* @__PURE__ */ new Date(0)).toISOString();
|
|
520
|
+
return epochMillisToIso(ms) ?? (/* @__PURE__ */ new Date(0)).toISOString();
|
|
521
|
+
}
|
|
522
|
+
//#endregion
|
|
523
|
+
//#region src/trace-analyst/hook.ts
|
|
524
|
+
const DEFAULT_QUESTION = "Summarise what happened in this run. Surface any failure modes, surprising findings, or evidence that the run's verdict is wrong.";
|
|
525
|
+
function traceAnalystOnRunComplete(opts) {
|
|
526
|
+
return async (ctx) => {
|
|
527
|
+
if (opts.shouldRun && !opts.shouldRun(ctx)) return;
|
|
528
|
+
const source = opts.analyze.source;
|
|
529
|
+
if (source === void 0) {
|
|
530
|
+
await ctx.store.appendEvent({
|
|
531
|
+
eventId: `analyst-skip-${ctx.runId}`,
|
|
532
|
+
runId: ctx.runId,
|
|
533
|
+
kind: "log",
|
|
534
|
+
timestamp: Date.now(),
|
|
535
|
+
payload: {
|
|
536
|
+
source: "trace_analyst_hook",
|
|
537
|
+
reason: "no source configured"
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
const result = await analyzeTraces({ question: opts.question ?? DEFAULT_QUESTION }, {
|
|
543
|
+
...opts.analyze,
|
|
544
|
+
source
|
|
545
|
+
});
|
|
546
|
+
if (opts.save) await opts.save(result, ctx);
|
|
547
|
+
if (opts.gateOn && !opts.gateOn(result, ctx)) await ctx.store.appendEvent({
|
|
548
|
+
eventId: `analyst-gate-${ctx.runId}`,
|
|
549
|
+
runId: ctx.runId,
|
|
550
|
+
kind: "log",
|
|
551
|
+
timestamp: Date.now(),
|
|
552
|
+
payload: {
|
|
553
|
+
source: "trace_analyst_hook",
|
|
554
|
+
reason: "analyst_gate_failed",
|
|
555
|
+
findings: result.findings
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
//#endregion
|
|
561
|
+
//#region src/trace-analyst/otlp-flatten.ts
|
|
562
|
+
const DEFAULT_KIND_MAP = {
|
|
563
|
+
0: "SPAN_KIND_UNSPECIFIED",
|
|
564
|
+
1: "SPAN_KIND_INTERNAL",
|
|
565
|
+
2: "SPAN_KIND_SERVER",
|
|
566
|
+
3: "SPAN_KIND_CLIENT",
|
|
567
|
+
4: "SPAN_KIND_PRODUCER",
|
|
568
|
+
5: "SPAN_KIND_CONSUMER"
|
|
569
|
+
};
|
|
570
|
+
const STATUS_MAP = {
|
|
571
|
+
0: "STATUS_CODE_UNSET",
|
|
572
|
+
1: "STATUS_CODE_OK",
|
|
573
|
+
2: "STATUS_CODE_ERROR"
|
|
574
|
+
};
|
|
575
|
+
/** Unwrap an OTLP attribute-value union to a scalar. */
|
|
576
|
+
function attrValue(v) {
|
|
577
|
+
if (v.stringValue !== void 0) return v.stringValue;
|
|
578
|
+
if (v.intValue !== void 0) return Number(v.intValue);
|
|
579
|
+
if (v.doubleValue !== void 0) return v.doubleValue;
|
|
580
|
+
if (v.boolValue !== void 0) return v.boolValue;
|
|
581
|
+
return "";
|
|
582
|
+
}
|
|
583
|
+
function attrsToRecord(attrs) {
|
|
584
|
+
const out = {};
|
|
585
|
+
for (const a of attrs) out[a.key] = attrValue(a.value);
|
|
586
|
+
return out;
|
|
587
|
+
}
|
|
588
|
+
function nanoToIso(nano) {
|
|
589
|
+
const ms = Number(nano) / 1e6;
|
|
590
|
+
return Number.isFinite(ms) ? new Date(ms).toISOString() : (/* @__PURE__ */ new Date(0)).toISOString();
|
|
591
|
+
}
|
|
592
|
+
/** Mirror selected attributes into the OpenInference vocabulary in place. */
|
|
593
|
+
function applyOpenInference(attrs) {
|
|
594
|
+
if ("llm.model" in attrs && !("llm.model_name" in attrs)) attrs[LLM_MODEL_NAME] = attrs["llm.model"];
|
|
595
|
+
if ("llm.input_tokens" in attrs && !("llm.token_count.prompt" in attrs)) attrs[LLM_INPUT_TOKENS] = attrs["llm.input_tokens"];
|
|
596
|
+
if ("inference.llm.input_tokens" in attrs && !("llm.token_count.prompt" in attrs)) attrs[LLM_INPUT_TOKENS] = attrs["inference.llm.input_tokens"];
|
|
597
|
+
if ("llm.output_tokens" in attrs && !("llm.token_count.completion" in attrs)) attrs[LLM_OUTPUT_TOKENS] = attrs["llm.output_tokens"];
|
|
598
|
+
if ("inference.llm.output_tokens" in attrs && !("llm.token_count.completion" in attrs)) attrs[LLM_OUTPUT_TOKENS] = attrs["inference.llm.output_tokens"];
|
|
599
|
+
if ("tool.name" in attrs && !("inference.tool.name" in attrs)) attrs["inference.tool.name"] = attrs[TOOL_NAME];
|
|
600
|
+
if ("span.kind" in attrs && !("openinference.span.kind" in attrs)) attrs[OPENINFERENCE_SPAN_KIND] = String(attrs["span.kind"]).toUpperCase();
|
|
601
|
+
}
|
|
602
|
+
function flattenOtlpExportToNdjson(otlpExport, opts = {}) {
|
|
603
|
+
const vocab = opts.attributeVocabulary ?? "openinference";
|
|
604
|
+
const kindMap = {
|
|
605
|
+
...DEFAULT_KIND_MAP,
|
|
606
|
+
...opts.kindMap
|
|
607
|
+
};
|
|
608
|
+
const lines = [];
|
|
609
|
+
for (const rs of otlpExport.resourceSpans ?? []) {
|
|
610
|
+
const resource = { attributes: attrsToRecord(rs.resource?.attributes ?? []) };
|
|
611
|
+
for (const scope of rs.scopeSpans ?? []) for (const span of scope.spans ?? []) {
|
|
612
|
+
const attributes = attrsToRecord(span.attributes ?? []);
|
|
613
|
+
if (vocab === "openinference") applyOpenInference(attributes);
|
|
614
|
+
const line = createOtlpFlatLine({
|
|
615
|
+
traceId: span.traceId,
|
|
616
|
+
spanId: span.spanId,
|
|
617
|
+
parentSpanId: span.parentSpanId ?? null,
|
|
618
|
+
name: span.name,
|
|
619
|
+
kind: kindMap[span.kind] ?? "SPAN_KIND_UNSPECIFIED",
|
|
620
|
+
startTime: nanoToIso(span.startTimeUnixNano),
|
|
621
|
+
endTime: nanoToIso(span.endTimeUnixNano),
|
|
622
|
+
statusCode: STATUS_MAP[span.status?.code ?? 0] ?? "STATUS_CODE_UNSET",
|
|
623
|
+
statusMessage: span.status?.message,
|
|
624
|
+
resource,
|
|
625
|
+
attributes,
|
|
626
|
+
events: span.events?.map((e) => ({
|
|
627
|
+
name: e.name,
|
|
628
|
+
timeUnixNano: e.timeUnixNano,
|
|
629
|
+
...e.attributes ? { attributes: attrsToRecord(e.attributes) } : {}
|
|
630
|
+
}))
|
|
631
|
+
});
|
|
632
|
+
lines.push(line);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return lines;
|
|
636
|
+
}
|
|
637
|
+
//#endregion
|
|
638
|
+
//#region src/trace-analyst/otlp-to-run-records.ts
|
|
639
|
+
/**
|
|
640
|
+
* `otlpToRunRecords` — fold an OTLP traces.jsonl (one OTLP span per line;
|
|
641
|
+
* the form AppWorld / HALO emit via their OpenInference OTLP exporter, the
|
|
642
|
+
* same shape `flattenOtlpExportToNdjson` produces) into validated
|
|
643
|
+
* `RunRecord[]` — one record per `trace_id` by default, or per caller-defined
|
|
644
|
+
* logical run when one task is fragmented across multiple OTLP traces.
|
|
645
|
+
*
|
|
646
|
+
* This is the offline ingestion primitive the AppWorld proposer bench and the
|
|
647
|
+
* hosted Intelligence product both stand on: traces in, paper-grade rows
|
|
648
|
+
* out, ready for `compareOptimizationMethods` / `analyzeRuns` / the promotion gate.
|
|
649
|
+
*
|
|
650
|
+
* Aggregation per trace:
|
|
651
|
+
* - tokenUsage: reconcile input, output, cache-read, and cache-write across
|
|
652
|
+
* nested model-call wrappers without double-counting parent aggregates.
|
|
653
|
+
* - costUsd: reconcile complete observed model-call cost when present; else priced via
|
|
654
|
+
* `opts.priceUsdPerToken` from the aggregated tokens; else `null` with a
|
|
655
|
+
* loud `raw.cost_unpriced = 1` marker.
|
|
656
|
+
* - task failure class and detail: read from process-root
|
|
657
|
+
* `tangle.task.failure_*` attributes; malformed or conflicting values throw.
|
|
658
|
+
* - terminalFailureReason: the failed root's normalized status message,
|
|
659
|
+
* when one unambiguous root supplies terminal failure evidence.
|
|
660
|
+
* - terminalOutcome: reduced from root-span status only. Child tool errors
|
|
661
|
+
* remain visible in `error_span_count` and `execution_error_count` without
|
|
662
|
+
* changing the run outcome. Root, guardrail, evaluator, propagated, and
|
|
663
|
+
* unknown errors retain separate counters.
|
|
664
|
+
* - model: the dominant LLM model in the trace (snapshot-padded to satisfy
|
|
665
|
+
* `validateRunRecord` when the trace's model is a bare alias).
|
|
666
|
+
* - outcome score: `opts.scoreForTrace` (AppWorld `world.evaluate()` →
|
|
667
|
+
* TGC/SGC) when supplied. Traces without an external task-quality signal
|
|
668
|
+
* remain unlabeled; execution errors never become a task score.
|
|
669
|
+
* - prompt / completion: carried into `raw` as token-count signals and,
|
|
670
|
+
* when the first/last LLM span exposes `input.value` / `output.value`,
|
|
671
|
+
* the verbatim text is preserved on the optional `promptText` /
|
|
672
|
+
* `completionText` of the returned `OtlpTraceRunRecord`.
|
|
673
|
+
*
|
|
674
|
+
* Fail-loud: an OTLP file with zero valid spans throws. A trace with no
|
|
675
|
+
* spans is impossible (a trace exists only because a span referenced it).
|
|
676
|
+
* `validateRunRecord` runs on every row — a malformed projection throws
|
|
677
|
+
* rather than silently producing a half-record.
|
|
678
|
+
*/
|
|
679
|
+
/**
|
|
680
|
+
* Parse + aggregate an OTLP traces.jsonl string into validated
|
|
681
|
+
* `RunRecord[]` (one per trace). Use {@link otlpToTraceRunRecords} when you
|
|
682
|
+
* also want the verbatim prompt/completion text alongside each record.
|
|
683
|
+
*/
|
|
684
|
+
function otlpToRunRecords(otlpJsonl, opts) {
|
|
685
|
+
return otlpToTraceRunRecords(otlpJsonl, opts).map((r) => r.record);
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Aggregate already-parsed OTLP flat rows without serializing them back to
|
|
689
|
+
* JSONL. This is the in-memory counterpart to {@link otlpToRunRecords}; both
|
|
690
|
+
* paths share projection, reconciliation, validation, and ordering.
|
|
691
|
+
*/
|
|
692
|
+
function otlpRowsToRunRecords(rows, opts) {
|
|
693
|
+
return otlpRowsToTraceRunRecords(rows, opts).map((row) => row.record);
|
|
694
|
+
}
|
|
695
|
+
/** As {@link otlpToRunRecords} but returns the prompt/completion text too. */
|
|
696
|
+
function otlpToTraceRunRecords(otlpJsonl, opts) {
|
|
697
|
+
return traceRunRecordsFromSpans(groupSpansByLogicalRun(groupJsonlSpansByTrace(otlpJsonl), opts.logicalRunIdForTrace), opts);
|
|
698
|
+
}
|
|
699
|
+
/** Parsed-row counterpart to {@link otlpToTraceRunRecords}. */
|
|
700
|
+
function otlpRowsToTraceRunRecords(rows, opts) {
|
|
701
|
+
return traceRunRecordsFromSpans(groupSpansByLogicalRun(groupRowsByTrace(rows), opts.logicalRunIdForTrace), opts);
|
|
702
|
+
}
|
|
703
|
+
function traceRunRecordsFromSpans(byTrace, opts) {
|
|
704
|
+
const splitTag = opts.splitTag ?? "holdout";
|
|
705
|
+
const commitSha = opts.commitSha ?? "unknown";
|
|
706
|
+
const promptHash = opts.promptHash ?? "unknown";
|
|
707
|
+
const configHash = opts.configHash ?? "unknown";
|
|
708
|
+
const seed = opts.seed ?? 0;
|
|
709
|
+
const fallbackModel = opts.fallbackModel ?? "unknown@otlp";
|
|
710
|
+
if (byTrace.size === 0) throw new Error("otlpToRunRecords: OTLP input produced zero valid spans — every row was empty, malformed, or missing trace_id/span_id");
|
|
711
|
+
const traceIds = [...byTrace.keys()].sort();
|
|
712
|
+
const out = [];
|
|
713
|
+
for (const traceId of traceIds) {
|
|
714
|
+
const spans = byTrace.get(traceId);
|
|
715
|
+
const agg = aggregateTrace(traceId, spans, fallbackModel);
|
|
716
|
+
const score = resolveScore(opts, traceId, agg);
|
|
717
|
+
const { costUsd, costProvenance } = resolveCost(opts, agg);
|
|
718
|
+
const raw = {
|
|
719
|
+
source_trace_count: agg.sourceTraceCount,
|
|
720
|
+
span_count: agg.spanCount,
|
|
721
|
+
llm_span_count: agg.llmSpanCount,
|
|
722
|
+
tool_span_count: agg.toolSpanCount,
|
|
723
|
+
agent_span_count: agg.agentSpanCount,
|
|
724
|
+
error_span_count: agg.errorSpanCount,
|
|
725
|
+
execution_error_count: agg.executionErrorCount,
|
|
726
|
+
process_error_count: agg.processErrorCount,
|
|
727
|
+
guardrail_error_count: agg.guardrailErrorCount,
|
|
728
|
+
judge_error_count: agg.judgeErrorCount,
|
|
729
|
+
propagated_error_count: agg.propagatedErrorCount,
|
|
730
|
+
unclassified_error_count: agg.unclassifiedErrorCount,
|
|
731
|
+
prompt_tokens: agg.tokenUsage.input,
|
|
732
|
+
completion_tokens: agg.tokenUsage.output
|
|
733
|
+
};
|
|
734
|
+
if (agg.tokenUsage.reasoning !== void 0) raw.reasoning_tokens = agg.tokenUsage.reasoning;
|
|
735
|
+
if (agg.tokenUsage.cached !== void 0) raw.cached_tokens = agg.tokenUsage.cached;
|
|
736
|
+
if (agg.tokenUsage.cacheWrite !== void 0) raw.cache_write_tokens = agg.tokenUsage.cacheWrite;
|
|
737
|
+
if (agg.costMeasurement.value !== void 0 && !agg.costMeasurement.complete) raw.partial_observed_cost_usd = agg.costMeasurement.value;
|
|
738
|
+
recordAggregateMeasurements(raw, agg.aggregateMeasurement);
|
|
739
|
+
if (costProvenance.kind === "uncaptured") raw.cost_unpriced = 1;
|
|
740
|
+
const outcome = { raw };
|
|
741
|
+
if (score !== void 0) if (splitTag === "holdout") outcome.holdoutScore = score;
|
|
742
|
+
else outcome.searchScore = score;
|
|
743
|
+
const { promptText, completionText } = extractPromptCompletion(spans, agg.callSpanIds);
|
|
744
|
+
const judgeMetadata = opts.judgeMetadataForTrace?.(traceId);
|
|
745
|
+
const taskFailure = readTaskFailureLabels(spans.filter((span) => span.parent_span_id === null && isTerminalRootCandidate(span)), `otlpToRunRecords: run '${traceId}'`);
|
|
746
|
+
const record = validateRunRecord({
|
|
747
|
+
runId: `otlp:${opts.experimentId}:${opts.candidateId}:${traceId}`,
|
|
748
|
+
experimentId: opts.experimentId,
|
|
749
|
+
candidateId: opts.candidateId,
|
|
750
|
+
seed,
|
|
751
|
+
model: ensureSnapshot(agg.model, fallbackModel),
|
|
752
|
+
promptHash,
|
|
753
|
+
configHash,
|
|
754
|
+
commitSha,
|
|
755
|
+
wallMs: agg.wallMs,
|
|
756
|
+
costUsd,
|
|
757
|
+
costProvenance,
|
|
758
|
+
tokenUsage: agg.tokenUsage,
|
|
759
|
+
terminalOutcome: agg.terminalOutcome,
|
|
760
|
+
...agg.terminalFailureMessage ? { terminalFailureReason: agg.terminalFailureMessage } : {},
|
|
761
|
+
...judgeMetadata ? { judgeMetadata } : {},
|
|
762
|
+
outcome,
|
|
763
|
+
...taskFailure,
|
|
764
|
+
splitTag,
|
|
765
|
+
scenarioId: traceId
|
|
766
|
+
});
|
|
767
|
+
out.push({
|
|
768
|
+
record,
|
|
769
|
+
...promptText !== void 0 ? { promptText } : {},
|
|
770
|
+
...completionText !== void 0 ? { completionText } : {}
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
return out;
|
|
774
|
+
}
|
|
775
|
+
function* yieldJsonlRows(otlpJsonl) {
|
|
776
|
+
for (const line of otlpJsonl.split("\n")) {
|
|
777
|
+
const trimmed = line.trim();
|
|
778
|
+
if (trimmed.length === 0) continue;
|
|
779
|
+
let parsed;
|
|
780
|
+
try {
|
|
781
|
+
parsed = JSON.parse(trimmed);
|
|
782
|
+
} catch {
|
|
783
|
+
continue;
|
|
784
|
+
}
|
|
785
|
+
if (parsed && typeof parsed === "object") yield parsed;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
function groupJsonlSpansByTrace(otlpJsonl) {
|
|
789
|
+
return groupRowsByTrace(yieldJsonlRows(otlpJsonl));
|
|
790
|
+
}
|
|
791
|
+
function groupRowsByTrace(rows) {
|
|
792
|
+
const byTrace = /* @__PURE__ */ new Map();
|
|
793
|
+
for (const row of rows) {
|
|
794
|
+
if (!row || typeof row !== "object") continue;
|
|
795
|
+
const span = projectOtlpFlatLine(row);
|
|
796
|
+
if (!span) continue;
|
|
797
|
+
const arr = byTrace.get(span.trace_id);
|
|
798
|
+
if (arr) arr.push(span);
|
|
799
|
+
else byTrace.set(span.trace_id, [span]);
|
|
800
|
+
}
|
|
801
|
+
return byTrace;
|
|
802
|
+
}
|
|
803
|
+
function groupSpansByLogicalRun(byTrace, logicalRunIdForTrace) {
|
|
804
|
+
if (!logicalRunIdForTrace) return byTrace;
|
|
805
|
+
const byRun = /* @__PURE__ */ new Map();
|
|
806
|
+
for (const [traceId, spans] of byTrace) {
|
|
807
|
+
const suppliedRunId = logicalRunIdForTrace(traceId);
|
|
808
|
+
if (typeof suppliedRunId !== "string" || suppliedRunId.trim().length === 0) throw new Error(`otlpToRunRecords: logicalRunIdForTrace('${traceId}') returned an empty run id`);
|
|
809
|
+
const runId = suppliedRunId.trim();
|
|
810
|
+
const target = byRun.get(runId) ?? [];
|
|
811
|
+
for (const span of spans) target.push({
|
|
812
|
+
...span,
|
|
813
|
+
span_id: qualifySpanId(traceId, span.span_id),
|
|
814
|
+
parent_span_id: span.parent_span_id ? qualifySpanId(traceId, span.parent_span_id) : null
|
|
815
|
+
});
|
|
816
|
+
byRun.set(runId, target);
|
|
817
|
+
}
|
|
818
|
+
return byRun;
|
|
819
|
+
}
|
|
820
|
+
function qualifySpanId(traceId, spanId) {
|
|
821
|
+
const prefix = `${traceId}:`;
|
|
822
|
+
return spanId.startsWith(prefix) ? spanId : `${prefix}${spanId}`;
|
|
823
|
+
}
|
|
824
|
+
function aggregateTrace(traceId, spans, fallbackModel) {
|
|
825
|
+
const ordered = [...spans].sort((a, b) => compareSpanTime(a.start_time, b.start_time) || a.span_id.localeCompare(b.span_id));
|
|
826
|
+
const measurements = summarizeExecutionMeasurements(ordered.map((span) => ({
|
|
827
|
+
id: span.span_id,
|
|
828
|
+
...span.parent_span_id ? { parentId: span.parent_span_id } : {},
|
|
829
|
+
attributes: span.attributes,
|
|
830
|
+
modelCall: isOtlpModelCall({
|
|
831
|
+
kind: span.kind,
|
|
832
|
+
name: span.name,
|
|
833
|
+
attributes: span.attributes
|
|
834
|
+
}),
|
|
835
|
+
aggregate: span.kind !== "LLM" && span.kind !== "UNKNOWN"
|
|
836
|
+
})));
|
|
837
|
+
let toolSpanCount = 0;
|
|
838
|
+
let agentSpanCount = 0;
|
|
839
|
+
let firstErrorMessage;
|
|
840
|
+
const modelVotes = /* @__PURE__ */ new Map();
|
|
841
|
+
let earliest = ordered[0]?.start_time ?? "";
|
|
842
|
+
let latest = ordered[0]?.end_time ?? "";
|
|
843
|
+
for (const s of ordered) {
|
|
844
|
+
if (s.start_time && (!earliest || compareSpanTime(s.start_time, earliest) < 0)) earliest = s.start_time;
|
|
845
|
+
if (s.end_time && (!latest || compareSpanTime(s.end_time, latest) > 0)) latest = s.end_time;
|
|
846
|
+
if (s.kind === "TOOL") toolSpanCount += 1;
|
|
847
|
+
else if (s.kind === "AGENT") agentSpanCount += 1;
|
|
848
|
+
if (s.status === "ERROR") {
|
|
849
|
+
if (firstErrorMessage === void 0) firstErrorMessage = (s.status_message ?? `${s.name} — STATUS_CODE_ERROR`).slice(0, 500);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
const callSpanIds = new Set(measurements.callSpanIds);
|
|
853
|
+
for (const span of ordered) {
|
|
854
|
+
if (!callSpanIds.has(span.span_id)) continue;
|
|
855
|
+
const model = firstStringAttr(span.attributes, LLM_MODEL_ATTR_KEYS) ?? span.model_name;
|
|
856
|
+
if (model) modelVotes.set(model, (modelVotes.get(model) ?? 0) + 1);
|
|
857
|
+
}
|
|
858
|
+
const model = topVote(modelVotes) ?? firstModelAttr(ordered) ?? fallbackModel;
|
|
859
|
+
let wallMs = 0;
|
|
860
|
+
const a = spanEpochMillis(earliest);
|
|
861
|
+
const b = spanEpochMillis(latest);
|
|
862
|
+
if (a !== null && b !== null) wallMs = Math.max(0, b - a);
|
|
863
|
+
const sourceTraceIds = [...new Set(spans.map((span) => span.trace_id))].sort();
|
|
864
|
+
const terminal = terminalEvidenceFromRoots(ordered);
|
|
865
|
+
const errorSummary = summarizeTraceErrors(ordered.map((span) => ({
|
|
866
|
+
id: span.span_id,
|
|
867
|
+
...span.parent_span_id ? { parentId: span.parent_span_id } : {},
|
|
868
|
+
role: errorRoleForProjectedSpan(span),
|
|
869
|
+
error: span.status === "ERROR",
|
|
870
|
+
processRoot: span.parent_span_id === null && isTerminalRootCandidate(span)
|
|
871
|
+
})));
|
|
872
|
+
return {
|
|
873
|
+
traceId,
|
|
874
|
+
sourceTraceCount: sourceTraceIds.length,
|
|
875
|
+
sourceTraceIds,
|
|
876
|
+
spanCount: spans.length,
|
|
877
|
+
llmSpanCount: measurements.modelCallCount,
|
|
878
|
+
toolSpanCount,
|
|
879
|
+
agentSpanCount,
|
|
880
|
+
errorSpanCount: errorSummary.total,
|
|
881
|
+
executionErrorCount: errorSummary.execution,
|
|
882
|
+
processErrorCount: errorSummary.process,
|
|
883
|
+
guardrailErrorCount: errorSummary.guardrail,
|
|
884
|
+
judgeErrorCount: errorSummary.evaluation,
|
|
885
|
+
propagatedErrorCount: errorSummary.propagated,
|
|
886
|
+
unclassifiedErrorCount: errorSummary.unclassified,
|
|
887
|
+
tokenUsage: measurements.tokenUsage,
|
|
888
|
+
firstErrorMessage,
|
|
889
|
+
model,
|
|
890
|
+
startTime: earliest,
|
|
891
|
+
endTime: latest,
|
|
892
|
+
wallMs,
|
|
893
|
+
terminalOutcome: terminal.outcome,
|
|
894
|
+
...terminal.failureMessage ? { terminalFailureMessage: terminal.failureMessage } : {},
|
|
895
|
+
callSpanIds: measurements.callSpanIds,
|
|
896
|
+
costMeasurement: measurements.cost,
|
|
897
|
+
...measurements.aggregate ? { aggregateMeasurement: measurements.aggregate } : {}
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
function terminalEvidenceFromRoots(spans) {
|
|
901
|
+
const roots = spans.filter((span) => span.parent_span_id === null && isTerminalRootCandidate(span));
|
|
902
|
+
if (roots.length !== 1) return { outcome: "unknown" };
|
|
903
|
+
const root = roots[0];
|
|
904
|
+
if (root.status === "ERROR") return {
|
|
905
|
+
outcome: "failed",
|
|
906
|
+
failureMessage: (root.status_message ?? `${root.name} — STATUS_CODE_ERROR`).slice(0, 500)
|
|
907
|
+
};
|
|
908
|
+
if (root.status === "OK") return { outcome: "succeeded" };
|
|
909
|
+
return { outcome: "unknown" };
|
|
910
|
+
}
|
|
911
|
+
function isTerminalRootCandidate(span) {
|
|
912
|
+
const role = errorRoleForProjectedSpan(span);
|
|
913
|
+
return role !== "LLM" && role !== "TOOL" && role !== "EVALUATOR" && role !== "GUARDRAIL";
|
|
914
|
+
}
|
|
915
|
+
function errorRoleForProjectedSpan(span) {
|
|
916
|
+
return classifyOtlpSpanRole({
|
|
917
|
+
kind: span.kind,
|
|
918
|
+
name: span.name,
|
|
919
|
+
attributes: span.attributes
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
function resolveScore(opts, traceId, agg) {
|
|
923
|
+
const supplied = opts.scoreForTrace?.(traceId, agg);
|
|
924
|
+
if (supplied !== void 0) {
|
|
925
|
+
if (!Number.isFinite(supplied)) throw new Error(`otlpToRunRecords: scoreForTrace('${traceId}') returned non-finite ${supplied}`);
|
|
926
|
+
return supplied;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
function resolveCost(opts, agg) {
|
|
930
|
+
const observedCost = agg.costMeasurement;
|
|
931
|
+
if (observedCost.complete && observedCost.value !== void 0) return {
|
|
932
|
+
costUsd: observedCost.value,
|
|
933
|
+
costProvenance: {
|
|
934
|
+
kind: "observed",
|
|
935
|
+
usd: observedCost.value
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
if (agg.aggregateMeasurement?.costUsd !== void 0) return {
|
|
939
|
+
costUsd: agg.aggregateMeasurement.costUsd,
|
|
940
|
+
costProvenance: {
|
|
941
|
+
kind: "observed",
|
|
942
|
+
usd: agg.aggregateMeasurement.costUsd
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
if (opts.priceUsdPerToken !== void 0) {
|
|
946
|
+
const costUsd = (agg.tokenUsage.input + agg.tokenUsage.output) * opts.priceUsdPerToken;
|
|
947
|
+
return {
|
|
948
|
+
costUsd,
|
|
949
|
+
costProvenance: {
|
|
950
|
+
kind: "estimated",
|
|
951
|
+
usd: costUsd
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
return {
|
|
956
|
+
costUsd: null,
|
|
957
|
+
costProvenance: {
|
|
958
|
+
kind: "uncaptured",
|
|
959
|
+
usd: null
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
function extractPromptCompletion(spans, callSpanIds) {
|
|
964
|
+
const callIds = new Set(callSpanIds);
|
|
965
|
+
const measuredCalls = spans.filter((span) => callIds.has(span.span_id));
|
|
966
|
+
const llm = (measuredCalls.length > 0 ? measuredCalls : spans.filter((s) => s.kind === "LLM")).sort((a, b) => compareSpanTime(a.start_time, b.start_time) || a.span_id.localeCompare(b.span_id));
|
|
967
|
+
if (llm.length === 0) return {};
|
|
968
|
+
const promptText = firstStringAttr(llm[0].attributes, [
|
|
969
|
+
"input.value",
|
|
970
|
+
"llm.input_messages",
|
|
971
|
+
"gen_ai.prompt"
|
|
972
|
+
]) ?? void 0;
|
|
973
|
+
const last = llm[llm.length - 1];
|
|
974
|
+
const completionText = firstStringAttr(last.attributes, [
|
|
975
|
+
"output.value",
|
|
976
|
+
"llm.output_messages",
|
|
977
|
+
"gen_ai.completion"
|
|
978
|
+
]) ?? void 0;
|
|
979
|
+
return {
|
|
980
|
+
...promptText !== void 0 ? { promptText } : {},
|
|
981
|
+
...completionText !== void 0 ? { completionText } : {}
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
function topVote(votes) {
|
|
985
|
+
let best = null;
|
|
986
|
+
let bestN = 0;
|
|
987
|
+
for (const [k, n] of votes) if (n > bestN || n === bestN && best !== null && k < best) {
|
|
988
|
+
best = k;
|
|
989
|
+
bestN = n;
|
|
990
|
+
}
|
|
991
|
+
return best;
|
|
992
|
+
}
|
|
993
|
+
function firstModelAttr(spans) {
|
|
994
|
+
for (const s of spans) {
|
|
995
|
+
const m = firstStringAttr(s.attributes, LLM_MODEL_ATTR_KEYS) ?? s.model_name;
|
|
996
|
+
if (m) return m;
|
|
997
|
+
}
|
|
998
|
+
return null;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* `validateRunRecord` rejects bare model aliases (`gpt-4o`) that remap
|
|
1002
|
+
* silently. AppWorld/HALO traces frequently carry such bare ids (or a null
|
|
1003
|
+
* model). When the model already encodes a snapshot we keep it; otherwise we
|
|
1004
|
+
* append the fallback snapshot token so the row is admissible without lying
|
|
1005
|
+
* about the model — the bare base name is preserved verbatim before `@`.
|
|
1006
|
+
*/
|
|
1007
|
+
function ensureSnapshot(model, fallbackModel) {
|
|
1008
|
+
if (modelHasSnapshot(model)) return model;
|
|
1009
|
+
return `${model}${fallbackModel.includes("@") ? fallbackModel.slice(fallbackModel.indexOf("@")) : "@otlp"}`;
|
|
1010
|
+
}
|
|
1011
|
+
//#endregion
|
|
1012
|
+
export { DEFAULT_REDACTION_RULES, DEFAULT_TRACE_ANALYST_BUDGETS, FAILURE_CLASSES, FileSystemRawProviderSink, FileSystemTraceStore, INPUT_VALUE, InMemoryRawProviderSink, InMemoryTraceStore, LLM_CACHED_TOKENS, LLM_CACHED_TOKEN_ATTR_KEYS, LLM_CACHE_WRITE_TOKENS, LLM_CACHE_WRITE_TOKEN_ATTR_KEYS, LLM_CONTEXT_TOKENS, LLM_COST_ATTR_KEYS, LLM_COST_USD, LLM_INPUT_TOKENS, LLM_INPUT_TOKEN_ATTR_KEYS, LLM_MODEL_ATTR_KEYS, LLM_MODEL_NAME, LLM_OUTPUT_TOKENS, LLM_OUTPUT_TOKEN_ATTR_KEYS, LLM_REASONING_TOKENS, LLM_REASONING_TOKEN_ATTR_KEYS, NoopRawProviderSink, OPENINFERENCE_SPAN_KIND, OTEL_AGENT_EVAL_SCOPE, OUTPUT_VALUE, OtlpFileTraceStore, REDACTION_VERSION, RUN_COST_ATTR_KEYS, RunIntegrityError, SPAN_KIND_ATTR_KEYS, SpanNotFoundError, TOOL_ARGS_CAPTURED, TOOL_LATENCY_MS, TOOL_NAME, TOOL_NAME_ATTR_KEYS, TRACE_ANALYSIS_LIMITS, TRACE_ANALYST_ACTOR_DESCRIPTION, TRACE_ANALYST_ACTOR_DESCRIPTION_VERSION, TRACE_ANALYST_TOOL_NAMESPACE, TRACE_ANALYST_TRUNCATION_MARKER_PREFIX, TRACE_SCHEMA_VERSION, ToolTraceMissingError, TraceAnalysisLimitError, TraceAnalysisStoreContractError, TraceAnalysisValidationError, TraceEmitter, TraceFileMalformedError, TraceFileMissingError, TraceFileTooLargeError, TraceNotFoundError, aggregateLlm, analyzeTraces, applyLlmSpanOtlpAttributes, applyToolSpanOtlpAttributes, argHash, asNumber, asString, assertRunCaptured, buildTraceAnalysisToolDescriptors, buildTraceInsightContext, buildTraceInsightPrompt, captureFetchToRawSink, classifyOtlpSpanRole, contextInputTokens, convertTraceStoresToOtlp, createBoundedTraceAnalysisStore, createOtelExporter, createOtelTracingStore, defaultProviderRedactor, defaultTraceInsightPanel, describeTraceInsightScope, domainEvidencePattern, exportRunAsOtlp, extractOtlpAttributes, extractUsage, extractUsageFromResponse, extractUsageFromSse, firstNumberAttr, firstStringAttr, flattenOtlpExportToNdjson, groupBy, hasCapturedToolArgs, inferDomainKeywords, inferOtlpKind, isJudgeSpan, isLlmSpan, isOtlpModelCall, isRetrievalSpan, isSandboxSpan, isToolSpan, judgeSpans, llmSpanFromProvider, llmSpans, otelRunCompleteHook, otlpRowsToRunRecords, otlpRowsToTraceRunRecords, otlpTextToTraceAnalysisStore, otlpToRunRecords, otlpToTraceRunRecords, planTraceInsightQuestions, projectOtlpFlatLine, providerFromBaseUrl, readOtlpStatus, redactString, redactValue, runFailureClass, runsForScenario, scoreTraceInsightReadiness, stringField, throwIfRunIncomplete, tokenizeDomainWords, toolSpans, toolSpansToTraceAnalysisStore, traceAnalystFunctionGroup, traceAnalystOnRunComplete, traceSpanKindToOpenInferenceKind };
|
|
1013
|
+
|
|
1014
|
+
//# sourceMappingURL=traces.js.map
|