@tangle-network/agent-eval 1.0.23 → 1.0.25
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 +84 -0
- package/dist/adapters/http.d.ts +2 -2
- package/dist/{agent-profile-C80hNPYb.d.ts → agent-profile-BF1WLMco.d.ts} +3 -3
- package/dist/{agent-profile-C80hNPYb.d.ts.map → agent-profile-BF1WLMco.d.ts.map} +1 -1
- package/dist/analyst/index.d.ts +14 -14
- package/dist/analyst/index.js +9 -9
- package/dist/{analyze-runs-DbHQHvDC.d.ts → analyze-runs-BaziIw93.d.ts} +4 -4
- package/dist/{analyze-runs-DbHQHvDC.d.ts.map → analyze-runs-BaziIw93.d.ts.map} +1 -1
- package/dist/app-grade/index.d.ts +4 -4
- package/dist/app-grade/index.js +3 -3
- package/dist/{benchmark-command-DkUpd9Q6.js → benchmark-command-DRAHkn4D.js} +8 -9
- package/dist/{benchmark-command-DkUpd9Q6.js.map → benchmark-command-DRAHkn4D.js.map} +1 -1
- package/dist/benchmarks/index.d.ts +4 -4
- package/dist/benchmarks/index.js +3 -3
- package/dist/campaign/index.d.ts +7 -7
- package/dist/campaign/index.js +4 -4
- package/dist/{campaign-D00Tbey-.js → campaign-Cqz2vk2p.js} +6 -6
- package/dist/{campaign-D00Tbey-.js.map → campaign-Cqz2vk2p.js.map} +1 -1
- package/dist/{chat-client-Zz97O3NB.js → chat-client-PJEzoot9.js} +5 -3
- package/dist/chat-client-PJEzoot9.js.map +1 -0
- package/dist/{chat-json-call-Dgi7-RH-.js → chat-json-call-CaNO3k0A.js} +2 -2
- package/dist/{chat-json-call-Dgi7-RH-.js.map → chat-json-call-CaNO3k0A.js.map} +1 -1
- package/dist/cli.js +3 -3
- package/dist/{cluster-Cd0MRbr9.d.ts → cluster-CSd0LE_M.d.ts} +4 -2
- package/dist/{cluster-Cd0MRbr9.d.ts.map → cluster-CSd0LE_M.d.ts.map} +1 -1
- package/dist/{completion-verifier-DFyYFezn.js → completion-verifier-DVZx0x6x.js} +5 -4
- package/dist/completion-verifier-DVZx0x6x.js.map +1 -0
- package/dist/{completion-verifier-BEpsr3N4.d.ts → completion-verifier-oAgSwdFe.d.ts} +3 -2
- package/dist/{completion-verifier-BEpsr3N4.d.ts.map → completion-verifier-oAgSwdFe.d.ts.map} +1 -1
- package/dist/contract/index.d.ts +10 -10
- package/dist/contract/index.js +7 -8
- package/dist/contract/index.js.map +1 -1
- package/dist/{cost-ledger-DfhStGcZ.js → cost-ledger-1CwUnVOd.js} +145 -3
- package/dist/cost-ledger-1CwUnVOd.js.map +1 -0
- package/dist/{decision-point-Di2LATNH.js → decision-point-CQOczIIH.js} +2 -2
- package/dist/{decision-point-Di2LATNH.js.map → decision-point-CQOczIIH.js.map} +1 -1
- package/dist/{default-registry-CdFbxPnr.js → default-registry-D-xd7KxV.js} +5 -5
- package/dist/{default-registry-CdFbxPnr.js.map → default-registry-D-xd7KxV.js.map} +1 -1
- package/dist/{default-registry-CjgRr-l7.d.ts → default-registry-DoIBhuS-.d.ts} +7 -7
- package/dist/{default-registry-CjgRr-l7.d.ts.map → default-registry-DoIBhuS-.d.ts.map} +1 -1
- package/dist/{define-agent-eval-BV16x8C0.js → define-agent-eval-BLVewqJm.js} +3 -3
- package/dist/{define-agent-eval-BV16x8C0.js.map → define-agent-eval-BLVewqJm.js.map} +1 -1
- package/dist/{define-agent-eval-BQBwKHwF.d.ts → define-agent-eval-Be2Ser8j.d.ts} +7 -7
- package/dist/{define-agent-eval-BQBwKHwF.d.ts.map → define-agent-eval-Be2Ser8j.d.ts.map} +1 -1
- package/dist/diagnosis/index.d.ts +2 -2
- package/dist/{dspy-rlm-engine-cWyn8G1a.js → dspy-rlm-engine-BS_jxE0P.js} +4 -4
- package/dist/{dspy-rlm-engine-cWyn8G1a.js.map → dspy-rlm-engine-BS_jxE0P.js.map} +1 -1
- package/dist/{engine-s3t6uYH9.d.ts → engine-CPBhCLJR.d.ts} +2 -2
- package/dist/{engine-s3t6uYH9.d.ts.map → engine-CPBhCLJR.d.ts.map} +1 -1
- package/dist/{evaluation-DRgHKEVV.d.ts → evaluation-BjRgUyst.d.ts} +4 -4
- package/dist/{evaluation-DRgHKEVV.d.ts.map → evaluation-BjRgUyst.d.ts.map} +1 -1
- package/dist/{evaluation-bU_bhlv-.js → evaluation-C_GJvEEG.js} +2 -2
- package/dist/{evaluation-bU_bhlv-.js.map → evaluation-C_GJvEEG.js.map} +1 -1
- package/dist/evaluation.d.ts +1 -1
- package/dist/evaluation.js +1 -1
- package/dist/{exact-types-DTlZSygs.d.ts → exact-types-DEnrf7NX.d.ts} +2 -2
- package/dist/{exact-types-DTlZSygs.d.ts.map → exact-types-DEnrf7NX.d.ts.map} +1 -1
- package/dist/experiment/index.d.ts +3 -3
- package/dist/{external-optimizer-process-2ImGH_LR.js → external-optimizer-process-m9xln7zN.js} +2 -2
- package/dist/{external-optimizer-process-2ImGH_LR.js.map → external-optimizer-process-m9xln7zN.js.map} +1 -1
- package/dist/{external-optimizer-subprocess-_C_2yriN.js → external-optimizer-subprocess-GO6s84Ov.js} +3 -3
- package/dist/{external-optimizer-subprocess-_C_2yriN.js.map → external-optimizer-subprocess-GO6s84Ov.js.map} +1 -1
- package/dist/{feedback-trajectory-DrKk79NU.d.ts → feedback-trajectory-DxkG5EPi.d.ts} +3 -3
- package/dist/{feedback-trajectory-DrKk79NU.d.ts.map → feedback-trajectory-DxkG5EPi.d.ts.map} +1 -1
- package/dist/{findings-store-BSuaV3dN.js → findings-store-CTy71Lnr.js} +5 -5
- package/dist/{findings-store-BSuaV3dN.js.map → findings-store-CTy71Lnr.js.map} +1 -1
- package/dist/fuzz.js +1 -1
- package/dist/{index-DtX456kD.d.ts → index-AjfEHHA8.d.ts} +9 -9
- package/dist/{index-DtX456kD.d.ts.map → index-AjfEHHA8.d.ts.map} +1 -1
- package/dist/{index-DLZp90hM.d.ts → index-BI9ecONy.d.ts} +10 -10
- package/dist/{index-DLZp90hM.d.ts.map → index-BI9ecONy.d.ts.map} +1 -1
- package/dist/{index-DAnkXnwF.d.ts → index-BriU7rfL.d.ts} +3 -3
- package/dist/{index-DAnkXnwF.d.ts.map → index-BriU7rfL.d.ts.map} +1 -1
- package/dist/{index-DjrXBogW.d.ts → index-D-0mg-eu.d.ts} +8 -8
- package/dist/{index-DjrXBogW.d.ts.map → index-D-0mg-eu.d.ts.map} +1 -1
- package/dist/{index-DNXFzSpc.d.ts → index-DHWFYUVW.d.ts} +2 -2
- package/dist/{index-DNXFzSpc.d.ts.map → index-DHWFYUVW.d.ts.map} +1 -1
- package/dist/{index-DZ_aqB7v.d.ts → index-JPI2spOx.d.ts} +23 -23
- package/dist/{index-DZ_aqB7v.d.ts.map → index-JPI2spOx.d.ts.map} +1 -1
- package/dist/{index-DwscLCQX.d.ts → index-VSN1IZQp.d.ts} +3 -3
- package/dist/{index-DwscLCQX.d.ts.map → index-VSN1IZQp.d.ts.map} +1 -1
- package/dist/index.d.ts +27 -27
- package/dist/index.js +62 -21
- package/dist/index.js.map +1 -1
- package/dist/{integrity-CrmnGB2T.d.ts → integrity-BMyCpnZ8.d.ts} +2 -2
- package/dist/{integrity-CrmnGB2T.d.ts.map → integrity-BMyCpnZ8.d.ts.map} +1 -1
- package/dist/{judge-gate-CrN0PaAL.js → judge-gate-DsoI5tx7.js} +2 -2
- package/dist/{judge-gate-CrN0PaAL.js.map → judge-gate-DsoI5tx7.js.map} +1 -1
- package/dist/{kind-factory-CV0FNCMM.js → kind-factory-CJXaE1oF.js} +2 -2
- package/dist/{kind-factory-CV0FNCMM.js.map → kind-factory-CJXaE1oF.js.map} +1 -1
- package/dist/{llm-client-DMMSg-Ro.js → llm-client-Bj-TooRS.js} +11 -11
- package/dist/{llm-client-DMMSg-Ro.js.map → llm-client-Bj-TooRS.js.map} +1 -1
- package/dist/{llm-judge-Cbh7OHaO.js → llm-judge-DzAT7Wka.js} +5 -5
- package/dist/{llm-judge-Cbh7OHaO.js.map → llm-judge-DzAT7Wka.js.map} +1 -1
- package/dist/{matrix-8NhGDcmi.d.ts → matrix-DdniPG_M.d.ts} +3 -4
- package/dist/matrix-DdniPG_M.d.ts.map +1 -0
- package/dist/meta-eval/index.d.ts +2 -2
- package/dist/meta-eval/index.js +2 -2
- package/dist/multishot/golden/index.d.ts +1 -1
- package/dist/multishot/index.d.ts +3 -2
- package/dist/multishot/index.d.ts.map +1 -1
- package/dist/multishot/index.js +3 -3
- package/dist/multishot/index.js.map +1 -1
- package/dist/openapi.json +1 -1
- package/dist/{paired-promotion-decision-DJU3fZxH.d.ts → paired-promotion-decision-DawN2o0G.d.ts} +2 -2
- package/dist/{paired-promotion-decision-DJU3fZxH.d.ts.map → paired-promotion-decision-DawN2o0G.d.ts.map} +1 -1
- package/dist/{prime-protocol-CKxq_-cx.d.ts → prime-protocol-RUPtoYiI.d.ts} +2 -2
- package/dist/{prime-protocol-CKxq_-cx.d.ts.map → prime-protocol-RUPtoYiI.d.ts.map} +1 -1
- package/dist/{promotion-gate-HDtliGsh.d.ts → promotion-gate-DG_PSJx_.d.ts} +2 -2
- package/dist/{promotion-gate-HDtliGsh.d.ts.map → promotion-gate-DG_PSJx_.d.ts.map} +1 -1
- package/dist/{proposal-findings-DWs94yT8.js → proposal-findings-CS6LoGGp.js} +2 -2
- package/dist/{proposal-findings-DWs94yT8.js.map → proposal-findings-CS6LoGGp.js.map} +1 -1
- package/dist/{registry-BnenKvxM.d.ts → registry-BqoX13FD.d.ts} +4 -4
- package/dist/{registry-BnenKvxM.d.ts.map → registry-BqoX13FD.d.ts.map} +1 -1
- package/dist/reporting.d.ts +4 -4
- package/dist/{researcher-DEpedkOZ.d.ts → researcher-BuojS14L.d.ts} +4 -4
- package/dist/{researcher-DEpedkOZ.d.ts.map → researcher-BuojS14L.d.ts.map} +1 -1
- package/dist/rl.d.ts +8 -8
- package/dist/rl.js.map +1 -1
- package/dist/rollout/index.d.ts +2 -2
- package/dist/rollout/index.js +1 -1
- package/dist/{rollout-DWl3Gg6A.js → rollout-B86tqluQ.js} +2 -2
- package/dist/{rollout-DWl3Gg6A.js.map → rollout-B86tqluQ.js.map} +1 -1
- package/dist/search/index.d.ts +2 -2
- package/dist/{search-kernel-CoDJ21q9.d.ts → search-kernel-C4XnLKIW.d.ts} +3 -3
- package/dist/{search-kernel-CoDJ21q9.d.ts.map → search-kernel-C4XnLKIW.d.ts.map} +1 -1
- package/dist/{sequential-BCzXKQab.d.ts → sequential-1-T2oi1_.d.ts} +2 -2
- package/dist/{sequential-BCzXKQab.d.ts.map → sequential-1-T2oi1_.d.ts.map} +1 -1
- package/dist/{server-DFVwfoZq.js → server-BQbd__Hr.js} +16 -5
- package/dist/server-BQbd__Hr.js.map +1 -0
- package/dist/{skillopt-optimization-method-B1Hkfexf.js → skillopt-optimization-method-BtX7xXDd.js} +5 -5
- package/dist/{skillopt-optimization-method-B1Hkfexf.js.map → skillopt-optimization-method-BtX7xXDd.js.map} +1 -1
- package/dist/{statistical-heldout-e2hbqDui.d.ts → statistical-heldout-Bx1QUDNy.d.ts} +5 -5
- package/dist/{statistical-heldout-e2hbqDui.d.ts.map → statistical-heldout-Bx1QUDNy.d.ts.map} +1 -1
- package/dist/statistics.d.ts +2 -2
- package/dist/{store-otlp-C-jyj3WX.js → store-otlp-CmgKDr0O.js} +2 -2
- package/dist/{store-otlp-C-jyj3WX.js.map → store-otlp-CmgKDr0O.js.map} +1 -1
- package/dist/{store-tool-spans-DalWlKY8.js → store-tool-spans-CW24axM0.js} +3 -3
- package/dist/{store-tool-spans-DalWlKY8.js.map → store-tool-spans-CW24axM0.js.map} +1 -1
- package/dist/{store-tool-spans-mlmGj6n3.d.ts → store-tool-spans-kCDPEwjL.d.ts} +5 -5
- package/dist/{store-tool-spans-mlmGj6n3.d.ts.map → store-tool-spans-kCDPEwjL.d.ts.map} +1 -1
- package/dist/{summary-report-DsiORzPc.d.ts → summary-report-9kwI6jFQ.d.ts} +2 -2
- package/dist/{summary-report-DsiORzPc.d.ts.map → summary-report-9kwI6jFQ.d.ts.map} +1 -1
- package/dist/supervisor-run/index.d.ts +1 -1
- package/dist/{systemone-B93onE_a.d.ts → systemone-CSwi1hp-.d.ts} +7 -7
- package/dist/{systemone-B93onE_a.d.ts.map → systemone-CSwi1hp-.d.ts.map} +1 -1
- package/dist/{systemone-review-BIggseLt.d.ts → systemone-review-WpWosn3a.d.ts} +2 -2
- package/dist/{systemone-review-BIggseLt.d.ts.map → systemone-review-WpWosn3a.d.ts.map} +1 -1
- package/dist/systemone.d.ts +3 -3
- package/dist/systemone.js +2 -2
- package/dist/{tool-groups-CCiATVZw.d.ts → tool-groups-Bcasvncd.d.ts} +3 -3
- package/dist/tool-groups-Bcasvncd.d.ts.map +1 -0
- package/dist/{trace-questions-B7lkyOlo.d.ts → trace-questions-DI42jXPj.d.ts} +3 -3
- package/dist/{trace-questions-B7lkyOlo.d.ts.map → trace-questions-DI42jXPj.d.ts.map} +1 -1
- package/dist/trace-repair/index.d.ts +1 -1
- package/dist/traces.d.ts +5 -5
- package/dist/traces.js +3 -3
- package/dist/{types-efIQ03Uo.d.ts → types-ByrbgALT.d.ts} +4 -4
- package/dist/{types-efIQ03Uo.d.ts.map → types-ByrbgALT.d.ts.map} +1 -1
- package/dist/{types-DUVhW5V1.d.ts → types-CLGrB4Sv.d.ts} +2 -2
- package/dist/{types-DUVhW5V1.d.ts.map → types-CLGrB4Sv.d.ts.map} +1 -1
- package/dist/{types-3uX8odDK.d.ts → types-D7g2XFTc.d.ts} +2 -2
- package/dist/{types-3uX8odDK.d.ts.map → types-D7g2XFTc.d.ts.map} +1 -1
- package/dist/{types-Ob1blgI2.d.ts → types-DbGSC2No.d.ts} +2 -2
- package/dist/{types-Ob1blgI2.d.ts.map → types-DbGSC2No.d.ts.map} +1 -1
- package/dist/wire/index.d.ts +2 -2
- package/dist/wire/index.d.ts.map +1 -1
- package/dist/wire/index.js +1 -1
- package/docs/wire-protocol.md +1 -1
- package/package.json +1 -1
- package/dist/chat-client-Zz97O3NB.js.map +0 -1
- package/dist/completion-verifier-DFyYFezn.js.map +0 -1
- package/dist/cost-ledger-DfhStGcZ.js.map +0 -1
- package/dist/matrix-8NhGDcmi.d.ts.map +0 -1
- package/dist/metrics-zALlR17s.js +0 -146
- package/dist/metrics-zALlR17s.js.map +0 -1
- package/dist/server-DFVwfoZq.js.map +0 -1
- package/dist/tool-groups-CCiATVZw.d.ts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { u as CostProvenance } from "./cost-ledger-Czro9wmo.js";
|
|
2
|
-
import { C as JudgeDimension, w as JudgeScore } from "./types-
|
|
2
|
+
import { C as JudgeDimension, w as JudgeScore } from "./types-ByrbgALT.js";
|
|
3
3
|
import { o as MatrixResult } from "./index-DwUGehqX.js";
|
|
4
4
|
import { AgentProfile } from "@tangle-network/agent-interface";
|
|
5
5
|
interface MultishotMessage {
|
|
@@ -141,7 +141,6 @@ declare class MultishotFatalToolError extends Error {
|
|
|
141
141
|
* checked, including `toolCalls` elements and `invocation.args`. Optional
|
|
142
142
|
* fields are checked only when present. */
|
|
143
143
|
declare function assertMultishotShotResult(value: unknown): asserts value is MultishotResult;
|
|
144
|
-
declare const DEFAULT_JUDGE_MODEL = "openai/gpt-4o-mini";
|
|
145
144
|
interface MultishotJudgeConfig<TInput> {
|
|
146
145
|
/** Display name (for trace + log). */
|
|
147
146
|
name: string;
|
|
@@ -380,5 +379,5 @@ interface RunMultishotMatrixResult {
|
|
|
380
379
|
matrix: MatrixResult<MultishotCellOutput>;
|
|
381
380
|
}
|
|
382
381
|
declare function runMultishotMatrix<TPersona extends MultishotPersona>(opts: RunMultishotMatrixOptions<TPersona>): Promise<RunMultishotMatrixResult>;
|
|
383
|
-
export {
|
|
384
|
-
//# sourceMappingURL=matrix-
|
|
382
|
+
export { MultishotTransportResponse as A, MultishotPersona as C, MultishotToolExecutor as D, MultishotToolDefinition as E, assertMultishotShotResult as M, MultishotTransport as O, MultishotMessage as S, MultishotShape as T, renderJsonFooter as _, MultishotCellOutput as a, MultishotDriverEmptyError as b, RunMultishotMatrixResult as c, MultishotShot as d, RunMultishotOptions as f, renderDimensions as g, MultishotJudgeConfig as h, ConversationJudgeInput as i, MultishotTransportToolCall as j, MultishotTransportRequest as k, computeCellComposite as l, JudgeRunResult as m, CellCompositeInput as n, MultishotJudges as o, runMultishot as p, CellCompositeScore as r, RunMultishotMatrixOptions as s, ArtifactJudgeInput as t, runMultishotMatrix as u, runJudge as v, MultishotResult as w, MultishotFatalToolError as x, MultishotArtifact as y };
|
|
383
|
+
//# sourceMappingURL=matrix-DdniPG_M.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matrix-DdniPG_M.d.ts","names":[],"sources":["../src/multishot/types.ts","../src/multishot/judges.ts","../src/multishot/multishot.ts","../src/multishot/matrix.ts"],"mappings":";;;;UAIiB;EACf;EACA;EACA;EACA,YAAY;IAAQ;IAAY;IAAc,MAAM;;;UAGrC;EACf;EACA;EACA;IAAc;IAAc,MAAM;;EAClC;;UAGe;EACf,YAAY;EACZ,WAAW;EACX;EACA;;;EAGA;;;;;;;;EAQA,iBAAiB;;UAGF;EACf;EACA;IACE;IACA;IACA,YAAY;;;;;;UAOC;EACf;EACA,UAAU,MAAM;EAChB,QAAQ;EACR;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;IAAY;IAAc;;;UAGX;EACf;IAAW;IAAyB,aAAa;;EACjD;IAAU;IAAwB;;;;EAGlC;;;;EAIA;;;;;;;;KASU,sBACV,KAAK,8BACF,QAAQ;KAED,yBACV,MAAM,yBACN;;EAEE,WAAW;EACX,SAAS;MAER;EAAU;EAAiB;;UAEf;;EAEf;;GAEC;;;;;;;;UASc,eAAe,iBAAiB;;EAE/C,eAAe,SAAS;;;EAGxB,2BAA2B,SAAS;;cAGzB,kCAAkC;WACjB;EAAA,YAAA;;cAMjB,gCAAgC;EAC/B,YAAA;;;;;;;;;;;;;;;;;;;iBAgCE,0BAA0B,yBAAyB,SAAS;UCtI3D,q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;EAIA,gBAAgB;;EAEhB,iBAAiB;;;EAGjB,gBAAgB;;;;;;;;;;;;;;;EAehB,UAAU,cAAc;;;;;UAMT;EACf;EACA;EACA;;UAoBe;EACf,cAAc;;EAEd,cAAc,cAAc;;EAE5B,iBAAiB,cAAc;;;;;;;iBAQjB,qBAAqB,OAAO;EAC1C;EACA;EACA;EACA;;UAuBe;EACf,QAAQ,aAAa;;iBAGD,mBAAmB,iBAAiB,kBACxD,MAAM,0BAA0B,YAC/B,QAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as selfPreference, Bt as CalibrationResult, Gt as GoldenItem, Ht as ContinuousAgreement, Jt as VerbosityBiasResult, Kt as PositionalBiasResult, Qt as positionalBias, Ut as ContinuousAgreementOptions, Vt as CandidateScore, Wt as ContinuousCalibrationResult, Xt as calibrateJudgeContinuous, Yt as calibrateJudge, Zt as continuousAgreement, en as verbosityBias, qt as SelfPreferenceResult } from "../index-
|
|
1
|
+
import { $t as selfPreference, Bt as CalibrationResult, Gt as GoldenItem, Ht as ContinuousAgreement, Jt as VerbosityBiasResult, Kt as PositionalBiasResult, Qt as positionalBias, Ut as ContinuousAgreementOptions, Vt as CandidateScore, Wt as ContinuousCalibrationResult, Xt as calibrateJudgeContinuous, Yt as calibrateJudge, Zt as continuousAgreement, en as verbosityBias, qt as SelfPreferenceResult } from "../index-DHWFYUVW.js";
|
|
2
2
|
import { a as RubricPredictiveValidityReport, c as CorrelationInterval, d as FileSystemOutcomeStore, f as FileSystemOutcomeStoreOptions, g as OutcomeStoreError, h as OutcomeStore, i as RubricPredictiveValidityInput, l as OutcomeReduction, m as OutcomeFilter, n as RubricOutcomeExclusion, o as RubricRanking, p as InMemoryOutcomeStore, r as RubricOutcomePair, s as rubricPredictiveValidity, t as OutcomeMetricSpec, u as DeploymentOutcome } from "../rubric-predictive-validity-Bbi88Aut.js";
|
|
3
|
-
import { $ as measureJudgeAgreement, $t as CorrelationStudyOptions, A as JudgePanelOutput, At as ProbabilityPolicyAuditInput, B as JudgeConfusion, Bt as clusterBootstrapMean, C as JudgeCalibrationCellVerdict, Ct as EvaluatorAdmissionPolicy, D as JudgeCalibrationGoldItem, Dt as EvaluatorAuditPlan, E as JudgeCalibrationGateConfig, Et as EvaluatorAuditObservation, F as CalibrationExample, Ft as evaluatorAuditObservationSchema, G as JudgeGateRefusedError, Gt as CategoricalForecast, H as JudgeGateDecision, Ht as CalibrationOptions, I as CalibrationMerge, It as planEvaluatorAudit, J as JudgeRunMeta, Jt as calibrationCurve, K as JudgeGateStatus, Kt as OrdinalForecast, L as DEFAULT_JUDGE_GATE_POLICY, Lt as ClusterBootstrapOptions, M as RubricDimensionGuide, Mt as auditEvaluator, N as calibrateJudgePanel, Nt as auditProbabilityPolicy, O as JudgeDimensionCalibration, Ot as EvaluatorAuditPlanInput, P as gateJudgeCalibration, Pt as evaluatorAdmissionPolicySchema, Q as judgeGateDecision, Qt as CorrelationResult, R as JudgeAgreement, Rt as ClusterBootstrapResult, S as CalibrateJudgePanelInput, T as JudgeCalibrationGateCell, Tt as EvaluatorAuditInput, U as JudgeGateInput, Ut as CalibrationPair, V as JudgeExampleAgreement, Vt as CalibrationBin, W as JudgeGatePolicy, Wt as CalibrationReport, X as addCalibrationVerdicts, Xt as multiclassBrierScore, Y as OwnerVerdict, Yt as calibrationFromPairs, Z as assertJudgeMayGate, Zt as rankedProbabilityScore, _ as catchRate, _t as snapshotFromCalibration, a as PerturbedField, at as SentinelMetrics, b as plantByPerturbation, c as PlantEvidence, ct as SentinelSnapshot, d as PlantKindCounts, dt as SentinelTrend, en as CorrelationStudyResult, et as registerCalibrationSet, f as PlantManifest, ft as SnapshotMeta, g as UnseededRejection, gt as snapshotFromAgreement, h as SeededGradingSet, ht as judgeSentinelReport, i as PerturbationKind, it as SentinelMetricName, j as JudgePanelPrompt, jt as ProbabilityPolicyAuditReport, k as JudgePanelCalibration, kt as EvaluatorErrorRate, l as PlantExpectation, lt as SentinelStore, m as SeedPlantsOptions, mt as fileSentinelStore, n as CatchRateStatus, nn as OutcomePair, nt as EvalHealthStamp, o as PerturbedPlant, ot as SentinelReport, p as PlantOutcome, pt as evalHealthStamp, q as JudgeRun, qt as brierScore, r as EvidencePerturbation, rn as correlationStudy, rt as JudgeSentinelOptions, s as Plant, st as SentinelSetOptions, t as CatchRateReport, tn as EvalMetricSpec, tt as snapshotFromJudgeAgreement, u as PlantKind, ut as SentinelThresholds, v as definePlant, vt as snapshotFromSentinelSet, w as JudgeCalibrationGate, wt as EvaluatorAdmissionReport, x as seedPlants, y as perturbEvidence, yt as validateSentinelSnapshot, z as JudgeCalibrationSet, zt as ClusteredObservation } from "../index-
|
|
3
|
+
import { $ as measureJudgeAgreement, $t as CorrelationStudyOptions, A as JudgePanelOutput, At as ProbabilityPolicyAuditInput, B as JudgeConfusion, Bt as clusterBootstrapMean, C as JudgeCalibrationCellVerdict, Ct as EvaluatorAdmissionPolicy, D as JudgeCalibrationGoldItem, Dt as EvaluatorAuditPlan, E as JudgeCalibrationGateConfig, Et as EvaluatorAuditObservation, F as CalibrationExample, Ft as evaluatorAuditObservationSchema, G as JudgeGateRefusedError, Gt as CategoricalForecast, H as JudgeGateDecision, Ht as CalibrationOptions, I as CalibrationMerge, It as planEvaluatorAudit, J as JudgeRunMeta, Jt as calibrationCurve, K as JudgeGateStatus, Kt as OrdinalForecast, L as DEFAULT_JUDGE_GATE_POLICY, Lt as ClusterBootstrapOptions, M as RubricDimensionGuide, Mt as auditEvaluator, N as calibrateJudgePanel, Nt as auditProbabilityPolicy, O as JudgeDimensionCalibration, Ot as EvaluatorAuditPlanInput, P as gateJudgeCalibration, Pt as evaluatorAdmissionPolicySchema, Q as judgeGateDecision, Qt as CorrelationResult, R as JudgeAgreement, Rt as ClusterBootstrapResult, S as CalibrateJudgePanelInput, T as JudgeCalibrationGateCell, Tt as EvaluatorAuditInput, U as JudgeGateInput, Ut as CalibrationPair, V as JudgeExampleAgreement, Vt as CalibrationBin, W as JudgeGatePolicy, Wt as CalibrationReport, X as addCalibrationVerdicts, Xt as multiclassBrierScore, Y as OwnerVerdict, Yt as calibrationFromPairs, Z as assertJudgeMayGate, Zt as rankedProbabilityScore, _ as catchRate, _t as snapshotFromCalibration, a as PerturbedField, at as SentinelMetrics, b as plantByPerturbation, c as PlantEvidence, ct as SentinelSnapshot, d as PlantKindCounts, dt as SentinelTrend, en as CorrelationStudyResult, et as registerCalibrationSet, f as PlantManifest, ft as SnapshotMeta, g as UnseededRejection, gt as snapshotFromAgreement, h as SeededGradingSet, ht as judgeSentinelReport, i as PerturbationKind, it as SentinelMetricName, j as JudgePanelPrompt, jt as ProbabilityPolicyAuditReport, k as JudgePanelCalibration, kt as EvaluatorErrorRate, l as PlantExpectation, lt as SentinelStore, m as SeedPlantsOptions, mt as fileSentinelStore, n as CatchRateStatus, nn as OutcomePair, nt as EvalHealthStamp, o as PerturbedPlant, ot as SentinelReport, p as PlantOutcome, pt as evalHealthStamp, q as JudgeRun, qt as brierScore, r as EvidencePerturbation, rn as correlationStudy, rt as JudgeSentinelOptions, s as Plant, st as SentinelSetOptions, t as CatchRateReport, tn as EvalMetricSpec, tt as snapshotFromJudgeAgreement, u as PlantKind, ut as SentinelThresholds, v as definePlant, vt as snapshotFromSentinelSet, w as JudgeCalibrationGate, wt as EvaluatorAdmissionReport, x as seedPlants, y as perturbEvidence, yt as validateSentinelSnapshot, z as JudgeCalibrationSet, zt as ClusteredObservation } from "../index-VSN1IZQp.js";
|
|
4
4
|
export { type CalibrateJudgePanelInput, CalibrationBin, CalibrationExample, CalibrationMerge, CalibrationOptions, CalibrationPair, CalibrationReport, type CalibrationResult, type CandidateScore, CatchRateReport, CatchRateStatus, CategoricalForecast, ClusterBootstrapOptions, ClusterBootstrapResult, ClusteredObservation, type ContinuousAgreement, type ContinuousAgreementOptions, type ContinuousCalibrationResult, type CorrelationInterval, CorrelationResult, CorrelationStudyOptions, CorrelationStudyResult, DEFAULT_JUDGE_GATE_POLICY, DeploymentOutcome, type EvalHealthStamp, EvalMetricSpec, type EvaluatorAdmissionPolicy, type EvaluatorAdmissionReport, type EvaluatorAuditInput, type EvaluatorAuditObservation, type EvaluatorAuditPlan, type EvaluatorAuditPlanInput, type EvaluatorErrorRate, EvidencePerturbation, FileSystemOutcomeStore, FileSystemOutcomeStoreOptions, type GoldenItem, InMemoryOutcomeStore, JudgeAgreement, type JudgeCalibrationCellVerdict, type JudgeCalibrationGate, type JudgeCalibrationGateCell, type JudgeCalibrationGateConfig, type JudgeCalibrationGoldItem, JudgeCalibrationSet, JudgeConfusion, type JudgeDimensionCalibration, JudgeExampleAgreement, JudgeGateDecision, JudgeGateInput, JudgeGatePolicy, JudgeGateRefusedError, JudgeGateStatus, type JudgePanelCalibration, type JudgePanelOutput, type JudgePanelPrompt, JudgeRun, JudgeRunMeta, type JudgeSentinelOptions, OrdinalForecast, OutcomeFilter, OutcomeMetricSpec, OutcomePair, type OutcomeReduction, OutcomeStore, OutcomeStoreError, OwnerVerdict, PerturbationKind, PerturbedField, PerturbedPlant, Plant, PlantEvidence, PlantExpectation, PlantKind, PlantKindCounts, PlantManifest, PlantOutcome, type PositionalBiasResult, type ProbabilityPolicyAuditInput, type ProbabilityPolicyAuditReport, type RubricDimensionGuide, RubricOutcomeExclusion, RubricOutcomePair, RubricPredictiveValidityInput, RubricPredictiveValidityReport, RubricRanking, SeedPlantsOptions, SeededGradingSet, type SelfPreferenceResult, type SentinelMetricName, type SentinelMetrics, type SentinelReport, type SentinelSetOptions, type SentinelSnapshot, type SentinelStore, type SentinelThresholds, type SentinelTrend, type SnapshotMeta, UnseededRejection, type VerbosityBiasResult, addCalibrationVerdicts, assertJudgeMayGate, auditEvaluator, auditProbabilityPolicy, brierScore, calibrateJudge, calibrateJudgeContinuous, calibrateJudgePanel, calibrationCurve, calibrationFromPairs, catchRate, clusterBootstrapMean, continuousAgreement, correlationStudy, definePlant, evalHealthStamp, evaluatorAdmissionPolicySchema, evaluatorAuditObservationSchema, fileSentinelStore, gateJudgeCalibration, judgeGateDecision, judgeSentinelReport, measureJudgeAgreement, multiclassBrierScore, perturbEvidence, planEvaluatorAudit, plantByPerturbation, positionalBias, rankedProbabilityScore, registerCalibrationSet, rubricPredictiveValidity, seedPlants, selfPreference, snapshotFromAgreement, snapshotFromCalibration, snapshotFromJudgeAgreement, snapshotFromSentinelSet, validateSentinelSnapshot, verbosityBias };
|
package/dist/meta-eval/index.js
CHANGED
|
@@ -3,10 +3,10 @@ import { a as hashCanonical, i as compareCodeUnits } from "../canonical-CicJlINA
|
|
|
3
3
|
import { J as continuousAgreement, K as calibrateJudge, X as selfPreference, Y as positionalBias, Z as verbosityBias, q as calibrateJudgeContinuous } from "../statistics-CvvC-MPv.js";
|
|
4
4
|
import { t as mulberry32 } from "../random-DrzcgC7F.js";
|
|
5
5
|
import { s as runMetricExtractor } from "../query-CGXzO9d4.js";
|
|
6
|
-
import { n as callLlmJson } from "../llm-client-
|
|
6
|
+
import { n as callLlmJson } from "../llm-client-Bj-TooRS.js";
|
|
7
7
|
import { a as validateObservationOptions, i as reduceOutcomeMetric, n as correlationSummary, r as hasVariation, t as assertUniqueObservationIds } from "../outcome-observations-DPkH-LHQ.js";
|
|
8
8
|
import { a as rankedProbabilityScore, i as multiclassBrierScore, n as calibrationCurve, r as calibrationFromPairs, t as brierScore } from "../calibration-Cf-wpqqO.js";
|
|
9
|
-
import { a as judgeGateDecision, c as snapshotFromJudgeAgreement, d as judgeSentinelReport, f as snapshotFromAgreement, g as withJudgeRetry, h as validateSentinelSnapshot, i as assertJudgeMayGate, l as evalHealthStamp, m as snapshotFromSentinelSet, n as JudgeGateRefusedError, o as measureJudgeAgreement, p as snapshotFromCalibration, r as addCalibrationVerdicts, s as registerCalibrationSet, t as DEFAULT_JUDGE_GATE_POLICY, u as fileSentinelStore } from "../judge-gate-
|
|
9
|
+
import { a as judgeGateDecision, c as snapshotFromJudgeAgreement, d as judgeSentinelReport, f as snapshotFromAgreement, g as withJudgeRetry, h as validateSentinelSnapshot, i as assertJudgeMayGate, l as evalHealthStamp, m as snapshotFromSentinelSet, n as JudgeGateRefusedError, o as measureJudgeAgreement, p as snapshotFromCalibration, r as addCalibrationVerdicts, s as registerCalibrationSet, t as DEFAULT_JUDGE_GATE_POLICY, u as fileSentinelStore } from "../judge-gate-DsoI5tx7.js";
|
|
10
10
|
import { t as computeInterval } from "../interval-Bd2f4CRT.js";
|
|
11
11
|
import { t as clusterBootstrapMean } from "../cluster-bootstrap-B0MTOBRU.js";
|
|
12
12
|
import { t as rubricPredictiveValidity } from "../rubric-predictive-validity-DL7gJ51F.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as MultishotPersona, E as MultishotToolDefinition, c as RunMultishotMatrixResult, f as RunMultishotOptions, k as MultishotTransportRequest, s as RunMultishotMatrixOptions, w as MultishotResult } from "../../matrix-DdniPG_M.js";
|
|
2
2
|
interface CompareOptions {
|
|
3
3
|
/** Stop after this many mismatches. A structural divergence high in the
|
|
4
4
|
* tree would otherwise report every leaf below it. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { P as DEFAULT_JUDGE_MODEL } from "../cluster-CSd0LE_M.js";
|
|
2
|
+
import { C as JudgeDimension, w as JudgeScore } from "../types-ByrbgALT.js";
|
|
3
|
+
import { A as MultishotTransportResponse, C as MultishotPersona, D as MultishotToolExecutor, E as MultishotToolDefinition, M as assertMultishotShotResult, O as MultishotTransport, S as MultishotMessage, T as MultishotShape, _ as renderJsonFooter, a as MultishotCellOutput, b as MultishotDriverEmptyError, c as RunMultishotMatrixResult, d as MultishotShot, f as RunMultishotOptions, g as renderDimensions, h as MultishotJudgeConfig, i as ConversationJudgeInput, j as MultishotTransportToolCall, k as MultishotTransportRequest, l as computeCellComposite, m as JudgeRunResult, n as CellCompositeInput, o as MultishotJudges, p as runMultishot, r as CellCompositeScore, s as RunMultishotMatrixOptions, t as ArtifactJudgeInput, u as runMultishotMatrix, v as runJudge, w as MultishotResult, x as MultishotFatalToolError, y as MultishotArtifact } from "../matrix-DdniPG_M.js";
|
|
3
4
|
import { AgentProfile } from "@tangle-network/agent-interface";
|
|
4
5
|
/** Prompt and completion tokens one leg reported. */
|
|
5
6
|
interface MultishotLegTokens {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/multishot/conversation.ts","../../src/multishot/cost.ts","../../src/multishot/default-tools.ts","../../src/multishot/shape-defaults.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/multishot/conversation.ts","../../src/multishot/cost.ts","../../src/multishot/default-tools.ts","../../src/multishot/shape-defaults.ts"],"mappings":";;;;;UA2BiB;EACf;EACA;;;;;UAMe;EACf,QAAQ;EACR;;;;UAKe;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;;EAIT,UAAU,eAAe,QAAQ;;;;EAIjC,WAAW,eAAe,QAAQ;IAAsB;;;;KAI9C,+BAA+B,cAAc,0BAA0B;;;;;;;;wBAiB7D,yBAAyB,iBAAiB,kBAC9D,MAAM,oBAAoB,WAC1B,OAAO,8BACN,QAAQ;;;;;;;wBC3EK,sBACd,eACA;EAAU;EAAwB;;qBCAvB;UAEI;;;EAGf;EACA;;UAGe;;;EAGf;EACA;;UA+Fe;EACf,WAAW;EACX,OAAO;;;EAGP;;UAGe;EACf,OAAO;EACP,WAAW,eAAe;EAC1B,kBAAkB;;wBAGJ,uBAAuB,SAAQ,qBAA0B;;;wBCpEzD,wBAAwB,iBAAiB,kBACvD,SAAS,cACT,QAAQ,eAAe,YACtB,SAAS,eAAe"}
|
package/dist/multishot/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as estimateCost, p as isModelPriced } from "../cost-ledger-1CwUnVOd.js";
|
|
2
|
+
import { t as DEFAULT_JUDGE_MODEL } from "../chat-client-PJEzoot9.js";
|
|
2
3
|
import { n as withCellSpend } from "../cell-spend-zxmzg4GH.js";
|
|
3
4
|
import { t as runAgentMatrix } from "../matrix-CgpX8wdm.js";
|
|
4
5
|
import { n as MultishotFatalToolError, r as assertMultishotShotResult, t as MultishotDriverEmptyError } from "../types-DK4vNv5q.js";
|
|
@@ -431,9 +432,8 @@ function driverVisibleContent(msg) {
|
|
|
431
432
|
return `Agent called ${toolNames.length === 1 ? "tool" : "tools"}: ${toolNames.join(", ")}.`;
|
|
432
433
|
}
|
|
433
434
|
// src/multishot/judges.ts
|
|
434
|
-
const DEFAULT_JUDGE_MODEL = "openai/gpt-4o-mini";
|
|
435
435
|
async function runJudge(judge, input) {
|
|
436
|
-
const model = judge.model ?? "
|
|
436
|
+
const model = judge.model ?? "zai/glm-5.3";
|
|
437
437
|
const prompt = judge.buildPrompt(input);
|
|
438
438
|
let raw = "";
|
|
439
439
|
let llmCall;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/multishot/cost.ts","../../src/multishot/default-tools.ts","../../src/multishot/shape-defaults.ts","../../src/multishot/conversation.ts","../../src/multishot/judges.ts","../../src/multishot/multishot.ts","../../src/multishot/matrix.ts"],"sourcesContent":["// Per-model cost estimator for multishot legs whose transport reported token\n// usage but no billed amount.\n\n/**\n * Rough per-model cost estimate from token counts. Underestimates Anthropic,\n * overestimates open-weight models — accurate enough for a cost ceiling, and\n * never presented as a billed amount: a leg metered from this table is\n * recorded with `estimated` provenance.\n */\nexport function estimateMultishotCost(\n model: string,\n usage?: { prompt_tokens?: number; completion_tokens?: number },\n): number {\n if (!usage) return 0\n const inputTok = usage.prompt_tokens ?? 0\n const outputTok = usage.completion_tokens ?? 0\n let inPer1k = 0.003\n let outPer1k = 0.015\n if (model.includes('gpt-4o-mini')) {\n inPer1k = 0.00015\n outPer1k = 0.0006\n } else if (model.includes('gpt-5.4') || model.includes('claude-sonnet')) {\n inPer1k = 0.003\n outPer1k = 0.015\n } else if (model.includes('kimi') || model.includes('glm') || model.includes('deepseek')) {\n inPer1k = 0.0005\n outPer1k = 0.002\n }\n return (inputTok * inPer1k + outputTok * outPer1k) / 1000\n}\n","// Default delegate_research + delegate_code tools and their inline executors.\n//\n// Consumers can override either by passing their own tools + executors to\n// runMultishot. The defaults are sufficient for most domains — point the\n// researcher system prompt at your domain's citation style and the coder\n// at your preferred language.\n\nimport { estimateMultishotCost } from './cost'\nimport type { MultishotToolDefinition, MultishotToolExecutor } from './types'\n\nconst DEFAULT_RESEARCHER_MODEL = 'openai/gpt-4o-mini'\nexport const DEFAULT_CODER_MODEL = 'openai/gpt-4o-mini'\n\nexport interface DefaultResearcherConfig {\n /** Replace the system prompt to bias the researcher toward a domain's\n * citation style. Defaults to a generic \"cite sources by name\" prompt. */\n systemPrompt?: string\n model?: string\n}\n\nexport interface DefaultCoderConfig {\n /** Replace the system prompt to bias the coder toward a language /\n * framework / artifact style. */\n systemPrompt?: string\n model?: string\n}\n\nconst GENERIC_RESEARCHER_SYSTEM =\n 'You are a research specialist. Return a markdown brief with 3-5 findings. Each finding cites a specific source by name. Add a confidence level (high/medium/low) per finding. No fluff, no preamble.'\n\nconst GENERIC_CODER_SYSTEM =\n 'You are an expert engineer. Output ONE fenced code block containing the complete solution. Inline-comment non-obvious decisions. No explanation outside the block.'\n\nconst DEFAULT_DELEGATE_RESEARCH_TOOL: MultishotToolDefinition = {\n type: 'function',\n function: {\n name: 'delegate_research',\n description:\n 'Research a topic deeply via specialist. Returns evidence-bearing items with citations. Use for audience research, competitive intel, regulatory landscape, market data, citation-grounded analysis.',\n parameters: {\n type: 'object',\n properties: {\n question: { type: 'string', description: 'Specific question to research' },\n scope: {\n type: 'string',\n description: 'Optional scope: time window, geography, jurisdiction, segment',\n },\n },\n required: ['question'],\n },\n },\n}\n\nconst DEFAULT_DELEGATE_CODE_TOOL: MultishotToolDefinition = {\n type: 'function',\n function: {\n name: 'delegate_code',\n description:\n 'Generate a runnable script, template, pipeline, or tool via specialist. Returns complete working code or structured markdown. Use for content pipelines, calc snippets, dashboards, compliance checklists, deadline trackers.',\n parameters: {\n type: 'object',\n properties: {\n goal: { type: 'string', description: 'What the code must accomplish' },\n language: {\n type: 'string',\n description: 'Optional language preference (default: TypeScript)',\n },\n },\n required: ['goal'],\n },\n },\n}\n\nfunction createResearchExecutor(config: DefaultResearcherConfig = {}): MultishotToolExecutor {\n const systemPrompt = config.systemPrompt ?? GENERIC_RESEARCHER_SYSTEM\n const model = config.model ?? DEFAULT_RESEARCHER_MODEL\n return async (args, ctx) => {\n const question = String(args.question ?? '')\n const scope = args.scope ? String(args.scope) : undefined\n const { message, usage, costUsd } = await ctx.transport({\n model,\n temperature: 0.3,\n maxTokens: 1800,\n messages: [\n { role: 'system', content: systemPrompt },\n { role: 'user', content: `Research: ${question}${scope ? `\\nScope: ${scope}` : ''}` },\n ],\n signal: ctx.signal,\n })\n return {\n content: message.content ?? '',\n costUsd: costUsd ?? estimateMultishotCost(model, usage),\n }\n }\n}\n\nfunction createCodeExecutor(config: DefaultCoderConfig = {}): MultishotToolExecutor {\n const systemPrompt = config.systemPrompt ?? GENERIC_CODER_SYSTEM\n const model = config.model ?? DEFAULT_CODER_MODEL\n return async (args, ctx) => {\n const goal = String(args.goal ?? '')\n const language = args.language ? String(args.language) : 'TypeScript'\n const { message, usage, costUsd } = await ctx.transport({\n model,\n temperature: 0.2,\n maxTokens: 2000,\n messages: [\n { role: 'system', content: `${systemPrompt}\\n\\nLanguage: ${language}` },\n { role: 'user', content: `Produce: ${goal}` },\n ],\n signal: ctx.signal,\n })\n return {\n content: message.content ?? '',\n costUsd: costUsd ?? estimateMultishotCost(model, usage),\n }\n }\n}\n\nexport interface DefaultToolsConfig {\n research?: DefaultResearcherConfig\n code?: DefaultCoderConfig\n /** When true (default), each tool result is recorded as a typed artifact:\n * research → type='research', code → type='code'. */\n recordArtifacts?: boolean\n}\n\nexport interface DefaultToolsBundle {\n tools: MultishotToolDefinition[]\n executors: Record<string, MultishotToolExecutor>\n artifactTypeFor: (toolName: string) => string | undefined\n}\n\nexport function defaultDelegationTools(config: DefaultToolsConfig = {}): DefaultToolsBundle {\n return {\n tools: [DEFAULT_DELEGATE_RESEARCH_TOOL, DEFAULT_DELEGATE_CODE_TOOL],\n executors: {\n delegate_research: createResearchExecutor(config.research),\n delegate_code: createCodeExecutor(config.code),\n },\n artifactTypeFor: (name) =>\n name === 'delegate_research' ? 'research' : name === 'delegate_code' ? 'code' : undefined,\n }\n}\n","// Profile-derived defaults for MultishotShape — the pure-profile path.\n//\n// `MultishotShape`'s callbacks were REQUIRED beside `profile: AgentProfile`,\n// which mixed the abstractions: the node under test was a profile, but the\n// simulated user's role could only be expressed as code. These defaults make\n// the callbacks optional — a pure-profile call works, and the derived prompts\n// are plain data (a pure function of profile + persona payload), so an\n// optimizer can sweep them (tangle-network/agent-runtime#694).\n\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport type { MultishotPersona, MultishotShape } from './types'\n\n/** Persona payload rendered as stable `- key: value` lines. `id` is identity,\n * not voice, and structured values are serialized so nothing is dropped. */\nfunction renderPersonaFacts(persona: MultishotPersona): string {\n const lines: string[] = []\n for (const [key, value] of Object.entries(persona)) {\n if (key === 'id' || value === undefined) continue\n const rendered =\n typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'\n ? String(value)\n : JSON.stringify(value)\n lines.push(`- ${key}: ${rendered}`)\n }\n return lines.join('\\n')\n}\n\n/** Default opening user message: the persona introduces itself with its whole\n * payload and asks the agent (as described by the profile) to take over. */\nfunction defaultMultishotOpener(profile: AgentProfile, persona: MultishotPersona): string {\n const facts = renderPersonaFacts(persona)\n const agentDescription = profile.description ?? profile.name ?? 'the agent'\n return [\n `Hi — I'm reaching out to ${agentDescription} for help. My situation:`,\n facts.length > 0 ? facts : `- (no details provided beyond id: ${persona.id})`,\n '',\n 'Tell me what you need from me, and get started on my case.',\n ].join('\\n')\n}\n\n/** Default driver system prompt: roleplay the persona from its payload, stay\n * in character, push back on vague answers, and never go silent. */\nfunction defaultMultishotDriverSystemPrompt(\n profile: AgentProfile,\n persona: MultishotPersona,\n): string {\n const facts = renderPersonaFacts(persona)\n const agentDescription = profile.description ?? profile.name ?? 'an AI agent'\n return [\n `You are role-playing a real person (persona \"${persona.id}\") talking to ${agentDescription}.`,\n facts.length > 0 ? `Who you are:\\n${facts}` : '',\n '',\n 'How to behave:',\n '- Stay in character: first person, realistic voice, concrete details from your situation.',\n '- Judge every reply by whether it actually moves YOUR case forward. Push back on vague, hedged, or generic answers and demand specifics.',\n \"- Answer the agent's questions with information consistent with who you are; invent plausible details rather than stalling.\",\n '- Never go silent: always produce a substantive next message.',\n '- Output ONLY your next message to the agent — no meta-commentary, no stage directions.',\n ]\n .filter((block) => block.length > 0)\n .join('\\n')\n}\n\n/** The fully-resolved shape for a profile: caller overrides win, the\n * profile-derived defaults fill the rest. */\nexport function defaultShapeFromProfile<TPersona extends MultishotPersona>(\n profile: AgentProfile,\n shape?: MultishotShape<TPersona>,\n): Required<MultishotShape<TPersona>> {\n return {\n buildOpener: shape?.buildOpener ?? ((persona) => defaultMultishotOpener(profile, persona)),\n buildDriverSystemPrompt:\n shape?.buildDriverSystemPrompt ??\n ((persona) => defaultMultishotDriverSystemPrompt(profile, persona)),\n }\n}\n","// The multishot conversation's two legs, separable from the loop that orders\n// them.\n//\n// `runMultishot` orders the legs as a plain turn loop. A caller that orders\n// them another way — a Runtime flow graph, a scheduler, a replay harness —\n// drives the same legs through `runMultishotConversation`, so the transcript,\n// artifacts, tool-call count, driver point of view and cost accounting stay\n// this package's single implementation.\n//\n// agent-eval owns no model transport: every leg runs on a MultishotTransport\n// the caller supplies, so no provider credential enters this package.\n\nimport { withCellSpend } from '../matrix'\nimport { estimateMultishotCost } from './cost'\nimport { defaultDelegationTools } from './default-tools'\nimport type { RunMultishotOptions } from './multishot'\nimport { defaultShapeFromProfile } from './shape-defaults'\nimport {\n type MultishotArtifact,\n MultishotDriverEmptyError,\n MultishotFatalToolError,\n type MultishotMessage,\n type MultishotPersona,\n type MultishotResult,\n} from './types'\n\n/** Prompt and completion tokens one leg reported. */\nexport interface MultishotLegTokens {\n input: number\n output: number\n}\n\n/** What one leg spent: its tokens and the USD it added to the conversation's\n * cost (provider-reported, else estimated from usage; tool executor spend\n * included). */\nexport interface MultishotLegSpend {\n tokens: MultishotLegTokens\n usd: number\n}\n\n/** One conversation's state and legs. Each leg appends to the shared\n * transcript; the caller decides the order in which legs run. */\nexport interface MultishotConversation {\n /** Agent turns the conversation is configured for (`opts.maxTurns ?? 10`). */\n readonly maxTurns: number\n /** The model the agent leg runs on. */\n readonly agentModel: string\n /** The primary simulated-user model. */\n readonly driverModel: string\n /** The persona's first message, already in the transcript. */\n readonly opener: string\n /** The simulated user's system prompt. */\n readonly driverSystemPrompt: string\n /** One agent turn: inference, inline tool execution and follow-up inference,\n * until the agent answers without tools. Throws on abort, on a fatal tool\n * error and on the per-turn tool dispatch cap. */\n agentTurn(turn: number): Promise<MultishotLegSpend>\n /** The simulated user's reply to the transcript so far, appended for the\n * next agent turn. Retries an empty reply once per model, rotates through\n * the fallback models, then throws `MultishotDriverEmptyError`. */\n driverTurn(turn: number): Promise<MultishotLegSpend & { content: string }>\n}\n\n/** Orders the legs of one conversation. Resolves when the conversation is done. */\nexport type MultishotConversationDriver = (conversation: MultishotConversation) => Promise<void>\n\ninterface ConversationMeter {\n costUsd: number\n startedAt: number\n /** True once a call contributed a fabricated `0` — no provider cost and no\n * usage to price. `costUsd` is a subtotal from that point on. */\n uncaptured: boolean\n}\n\n/**\n * Run one multishot conversation whose leg order `drive` decides.\n *\n * Returns the conversation's `MultishotResult`. When any leg or `drive` throws,\n * the error is rethrown carrying the spend so far (`withCellSpend`), so a\n * matrix bills the failed cell for the turns it already paid for.\n */\nexport async function runMultishotConversation<TPersona extends MultishotPersona>(\n opts: RunMultishotOptions<TPersona>,\n drive: MultishotConversationDriver,\n): Promise<MultishotResult> {\n const meter: ConversationMeter = { costUsd: 0, startedAt: Date.now(), uncaptured: false }\n try {\n const state = openConversation(opts, meter)\n await drive(state.conversation)\n return {\n transcript: state.transcript,\n artifacts: state.artifacts,\n toolCalls: state.toolCalls(),\n durationMs: Date.now() - meter.startedAt,\n costUsd: meter.costUsd,\n // A shot that priced every call reports a complete estimate. One that had\n // a call the router priced at nothing reports a subtotal, so the cell is\n // recorded as under-counted rather than as a complete estimate.\n costProvenance: meter.uncaptured\n ? { kind: 'uncaptured', usd: null }\n : { kind: 'estimated', usd: meter.costUsd },\n }\n } catch (err) {\n throw withCellSpend(err, {\n costUsd: meter.costUsd,\n durationMs: Date.now() - meter.startedAt,\n kind: meter.uncaptured ? 'uncaptured' : 'estimated',\n })\n }\n}\n\nfunction openConversation<TPersona extends MultishotPersona>(\n opts: RunMultishotOptions<TPersona>,\n meter: ConversationMeter,\n): {\n conversation: MultishotConversation\n transcript: MultishotMessage[]\n artifacts: MultishotArtifact[]\n toolCalls: () => number\n} {\n const maxTurns = opts.maxTurns ?? 10\n const maxToolDispatches = opts.maxToolDispatches ?? 4\n const agentModel = opts.agentModel ?? 'openai/gpt-5.4'\n const driverModel = opts.driverModel ?? 'openai/gpt-4o-mini'\n const driverModels = [driverModel, ...(opts.driverFallbackModels ?? [])]\n const agentMaxTokens = opts.agentMaxTokens ?? 2500\n const toolFollowupMaxTokens = opts.toolFollowupMaxTokens ?? 2000\n const driverMaxTokens = opts.driverMaxTokens ?? 600\n\n const bundle =\n opts.tools && opts.toolExecutors\n ? {\n tools: opts.tools,\n executors: opts.toolExecutors,\n artifactTypeFor: opts.artifactTypeFor ?? (() => undefined),\n }\n : defaultDelegationTools()\n const tools = opts.tools ?? bundle.tools\n const executors = opts.toolExecutors ?? bundle.executors\n const artifactTypeFor = opts.artifactTypeFor ?? bundle.artifactTypeFor\n\n const agentTransport = opts.agentTransport\n const driverTransport = opts.driverTransport\n const toolTransport = opts.toolTransport ?? agentTransport\n\n const shape = defaultShapeFromProfile(opts.profile, opts.shape)\n\n const transcript: MultishotMessage[] = []\n const artifacts: MultishotArtifact[] = []\n let toolCalls = 0\n\n const opener = shape.buildOpener(opts.persona)\n transcript.push({ role: 'user', content: opener })\n\n const systemPrompt = [opts.profile.prompt?.systemPrompt, opts.profile.prompt?.appendSystemPrompt]\n .filter((value): value is string => Boolean(value))\n .join('\\n\\n')\n const agentMessages: Array<Record<string, unknown>> = [\n { role: 'system', content: systemPrompt },\n { role: 'user', content: opener },\n ]\n const driverSystemPrompt = shape.buildDriverSystemPrompt(opts.persona)\n\n async function agentTurn(turn: number): Promise<MultishotLegSpend> {\n if (opts.signal?.aborted) throw new Error('multishot aborted')\n const usdBefore = meter.costUsd\n const tokens = { input: 0, output: 0 }\n let dispatchesThisTurn = 0\n while (true) {\n const {\n message: agentMsg,\n usage: agentUsage,\n costUsd: agentCostUsd,\n } = await agentTransport({\n model: agentModel,\n messages: agentMessages,\n tools,\n temperature: 0.7,\n maxTokens: dispatchesThisTurn === 0 ? agentMaxTokens : toolFollowupMaxTokens,\n signal: opts.signal,\n })\n meter.costUsd += agentCostUsd ?? estimateMultishotCost(agentModel, agentUsage)\n if (agentCostUsd === undefined && agentUsage === undefined) meter.uncaptured = true\n tokens.input += agentUsage?.prompt_tokens ?? 0\n tokens.output += agentUsage?.completion_tokens ?? 0\n\n const agentText = (agentMsg.content ?? '').trim()\n const agentToolCalls = (agentMsg.tool_calls ?? []).map((tc) => ({\n id: tc.id,\n name: tc.function.name,\n args: (() => {\n try {\n return JSON.parse(tc.function.arguments) as Record<string, unknown>\n } catch {\n return {} as Record<string, unknown>\n }\n })(),\n }))\n\n agentMessages.push({\n role: 'assistant',\n content: agentText || null,\n ...(agentMsg.tool_calls?.length ? { tool_calls: agentMsg.tool_calls } : {}),\n })\n transcript.push({\n role: 'assistant',\n content: agentText,\n toolCalls: agentToolCalls.length > 0 ? agentToolCalls : undefined,\n })\n\n if (agentToolCalls.length === 0) break\n dispatchesThisTurn += agentToolCalls.length\n if (dispatchesThisTurn > maxToolDispatches) {\n throw new Error(\n `multishot: tool dispatch cap exceeded (${dispatchesThisTurn}/${maxToolDispatches}) on turn ${turn}`,\n )\n }\n\n for (const tc of agentToolCalls) {\n toolCalls++\n let toolResult = ''\n try {\n const executor = executors[tc.name]\n if (!executor) {\n toolResult = JSON.stringify({ error: `unknown tool ${tc.name}` })\n } else {\n const r = await executor(tc.args, { transport: toolTransport, signal: opts.signal })\n toolResult = r.content\n meter.costUsd += r.costUsd\n const artifactType = artifactTypeFor(tc.name)\n if (artifactType) {\n artifacts.push({\n type: artifactType,\n turn,\n invocation: { name: tc.name, args: tc.args },\n content: toolResult,\n })\n }\n }\n } catch (err) {\n if (err instanceof MultishotFatalToolError) throw err\n toolResult = JSON.stringify({ error: err instanceof Error ? err.message : String(err) })\n }\n agentMessages.push({ role: 'tool', tool_call_id: tc.id, content: toolResult || 'done' })\n transcript.push({ role: 'tool', content: toolResult || 'done', toolCallId: tc.id })\n }\n }\n return { tokens, usd: meter.costUsd - usdBefore }\n }\n\n // Every driver attempt is charged, including the empty ones that force a\n // retry and the ones that precede `MultishotDriverEmptyError`: those calls\n // billed the provider whether or not their content was usable.\n async function driverTurn(turn: number): Promise<MultishotLegSpend & { content: string }> {\n const usdBefore = meter.costUsd\n // Driver point of view: the agent's `assistant` messages become `user`\n // (the agent talking TO the driver); the driver's prior `user` messages\n // become `assistant` (the driver's prior responses).\n const driverMessages: Array<Record<string, unknown>> = [\n { role: 'system', content: driverSystemPrompt },\n ]\n for (const msg of transcript) {\n if (msg.role === 'tool') continue\n const content = driverVisibleContent(msg)\n if (!content) continue\n if (msg.role === 'assistant') driverMessages.push({ role: 'user', content })\n else if (msg.role === 'user') driverMessages.push({ role: 'assistant', content })\n }\n\n // The driver must never go silent. Retry once on empty content; then fail loud.\n const tokens = { input: 0, output: 0 }\n for (const model of driverModels) {\n for (let attempt = 0; attempt < 2; attempt++) {\n const { message, usage, costUsd } = await driverTransport({\n model,\n messages: driverMessages,\n temperature: 0.9,\n maxTokens: driverMaxTokens,\n signal: opts.signal,\n })\n meter.costUsd += costUsd ?? estimateMultishotCost(model, usage)\n if (costUsd === undefined && usage === undefined) meter.uncaptured = true\n tokens.input += usage?.prompt_tokens ?? 0\n tokens.output += usage?.completion_tokens ?? 0\n const content = (message.content ?? '').trim()\n if (content.length > 0) {\n agentMessages.push({ role: 'user', content })\n transcript.push({ role: 'user', content })\n return { content, tokens, usd: meter.costUsd - usdBefore }\n }\n }\n }\n throw new MultishotDriverEmptyError(turn)\n }\n\n return {\n conversation: {\n maxTurns,\n agentModel,\n driverModel,\n opener,\n driverSystemPrompt,\n agentTurn,\n driverTurn,\n },\n transcript,\n artifacts,\n toolCalls: () => toolCalls,\n }\n}\n\n/** Silent tool-calling agent turns surface to the driver as\n * \"Agent called tools: …\" so the simulated user can react to them. */\nfunction driverVisibleContent(msg: MultishotMessage): string | null {\n const text = msg.content.trim()\n if (text.length > 0) return text\n if (msg.role !== 'assistant' || !msg.toolCalls?.length) return null\n\n const toolNames = msg.toolCalls.map((call) => call.name.trim()).filter(Boolean)\n if (toolNames.length === 0) return 'Agent called tools.'\n return `Agent called ${toolNames.length === 1 ? 'tool' : 'tools'}: ${toolNames.join(', ')}.`\n}\n","// Generic judge runner — domain consumers configure dimensions + prompts.\n//\n// Three judge slots are conventional for multishot eval:\n// - conversation (scores the full transcript)\n// - codeReview (scores each code artifact)\n// - contentQuality (scores each non-code artifact)\n//\n// But the runJudge primitive is fully generic: any input maps to a score plus\n// explicit observed, estimated, or uncaptured cost.\n\nimport type { JudgeDimension, JudgeScore } from '../campaign/types'\nimport type { CostProvenance } from '../cost-ledger'\nimport type { LlmCallMetadata, LlmUsage } from '../llm-client'\nimport { estimateCost, isModelPriced } from '../metrics'\nimport type { MultishotTransport, MultishotTransportResponse } from './types'\n\n// Canonical declaration lives in campaign/types.ts. Multishot emits the same\n// shape on its producer-defined 0-10 scale.\nexport type { JudgeDimension, JudgeScore } from '../campaign/types'\n\nexport const DEFAULT_JUDGE_MODEL = 'openai/gpt-4o-mini'\n\nexport interface MultishotJudgeConfig<TInput> {\n /** Display name (for trace + log). */\n name: string\n /** Caller-owned execution for this judge's call. agent-eval issues no\n * provider request and holds no credential. */\n transport: MultishotTransport\n /** Model used for this judge. */\n model?: string\n /** 0-10 scored dimensions. */\n dimensions: JudgeDimension[]\n /** Judge system prompt — sets persona + JSON-only constraint. */\n systemPrompt: string\n /** Build the user prompt from the typed input. Must include \"Respond with\n * ONLY this JSON: { ... }\" listing each dimension key. */\n buildPrompt: (input: TInput) => string\n /** Maximum output tokens for the judge response. Defaults to 1500. */\n maxTokens?: number\n}\n\nexport interface JudgeRunResult {\n /** Semantic result; failed scores remain non-throwing so matrix aggregation can exclude them. */\n score: JudgeScore\n /** Cost of the completed call, separate from diagnostic provider metadata. */\n cost: CostProvenance\n}\n\nexport async function runJudge<TInput>(\n judge: MultishotJudgeConfig<TInput>,\n input: TInput,\n): Promise<JudgeRunResult> {\n const model = judge.model ?? DEFAULT_JUDGE_MODEL\n const prompt = judge.buildPrompt(input)\n let raw = ''\n let llmCall: LlmCallMetadata\n let cost: CostProvenance\n const startedAt = Date.now()\n try {\n const response = await judge.transport({\n model,\n temperature: 0,\n maxTokens: judge.maxTokens ?? 1500,\n messages: [\n { role: 'system', content: judge.systemPrompt },\n { role: 'user', content: prompt },\n ],\n })\n const call = judgeCallMetadata(response, model, Date.now() - startedAt)\n llmCall = call.llmCall\n cost = call.cost\n raw = (response.message.content ?? '').trim()\n } catch (err) {\n // failed:true lets consumers reading `.composite` keep working while\n // aggregators exclude this score from means instead of averaging a zero.\n return {\n score: {\n dimensions: {},\n composite: 0,\n failed: true,\n notes: `judge ${judge.name} call failed: ${err instanceof Error ? err.message : String(err)}`,\n llmCall: unknownJudgeCall(model, Date.now() - startedAt),\n },\n cost: { kind: 'uncaptured', usd: null },\n }\n }\n\n let parsed: Record<string, unknown> | null = null\n try {\n const cleaned = raw\n .replace(/^```json\\s*/i, '')\n .replace(/```\\s*$/, '')\n .trim()\n parsed = JSON.parse(cleaned) as Record<string, unknown>\n } catch {\n return {\n score: {\n dimensions: {},\n composite: 0,\n failed: true,\n notes: `judge ${judge.name} returned non-JSON: ${raw.slice(0, 200)}`,\n llmCall,\n },\n cost,\n }\n }\n\n const dimensions: Record<string, number> = {}\n let sum = 0\n for (const dim of judge.dimensions) {\n const v = Number(parsed[dim.key] ?? 0)\n const clamped = Number.isFinite(v) ? Math.max(0, Math.min(10, v)) : 0\n dimensions[dim.key] = clamped\n sum += clamped\n }\n return {\n score: {\n dimensions,\n composite: judge.dimensions.length === 0 ? 0 : sum / judge.dimensions.length,\n notes: typeof parsed.notes === 'string' ? parsed.notes : '',\n llmCall,\n },\n cost,\n }\n}\n\nfunction judgeCallMetadata(\n response: MultishotTransportResponse,\n requestedModel: string,\n durationMs: number,\n): {\n llmCall: LlmCallMetadata\n cost: CostProvenance\n} {\n const usage = canonicalUsage(response.usage)\n // The transport reports the served identity when it observed one. Falling\n // back to the requested id keeps attribution honest for a transport that\n // reported none; it is not proof that model answered.\n const model = response.model ?? requestedModel\n return {\n llmCall: {\n usage,\n costUsd: response.costUsd ?? null,\n model,\n durationMs,\n },\n cost:\n response.costUsd !== undefined\n ? { kind: 'observed', usd: response.costUsd }\n : usage.captured === false || !isModelPriced(model)\n ? { kind: 'uncaptured', usd: null }\n : {\n kind: 'estimated',\n usd: estimateCost(usage.promptTokens, usage.completionTokens, model),\n },\n }\n}\n\nfunction canonicalUsage(usage: MultishotTransportResponse['usage']): LlmUsage {\n const promptTokens = tokenCount(usage?.prompt_tokens)\n const completionTokens = tokenCount(usage?.completion_tokens)\n const captured = promptTokens !== undefined && completionTokens !== undefined\n return {\n promptTokens: promptTokens ?? 0,\n completionTokens: completionTokens ?? 0,\n totalTokens: (promptTokens ?? 0) + (completionTokens ?? 0),\n captured,\n }\n}\n\nfunction unknownJudgeCall(model: string, durationMs: number): LlmCallMetadata {\n return {\n usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0, captured: false },\n costUsd: null,\n model,\n durationMs,\n }\n}\n\nfunction tokenCount(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : undefined\n}\n\n/** Convenience: stringified dimension list for inclusion in a judge prompt.\n * Returns lines like `- audience_fit: Does this match what the audience cares about? (0-10)`. */\nexport function renderDimensions(dims: readonly JudgeDimension[]): string {\n return dims.map((d) => `- ${d.key}: ${d.description}`).join('\\n')\n}\n\n/** Convenience: build the \"Respond with ONLY this JSON\" footer for a judge prompt. */\nexport function renderJsonFooter(dims: readonly JudgeDimension[]): string {\n const fields = dims.map((d) => `\"${d.key}\":N`).join(',')\n return `Respond with ONLY this JSON (no markdown, no preamble):\\n{${fields},\"notes\":\"1-2 sentence critique\"}`\n}\n","// Multi-turn driver-agent simulation with inline tool execution.\n//\n// The driver = LLM acting as the persona (reactive, non-deterministic).\n// The agent = the product agent under test, executed by the caller-supplied\n// transport with the profile's systemPrompt + the configured tools.\n// Tool calls execute inline via the configured executors and feed back\n// into the agent's message log so the agent integrates the result.\n//\n// agent-eval owns no model transport: every leg runs on a MultishotTransport\n// the caller supplies, so no provider credential enters this package.\n\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport { runMultishotConversation } from './conversation'\nimport type {\n MultishotPersona,\n MultishotResult,\n MultishotShape,\n MultishotToolDefinition,\n MultishotToolExecutor,\n MultishotTransport,\n} from './types'\n\nexport interface RunMultishotOptions<TPersona extends MultishotPersona> {\n profile: AgentProfile\n persona: TPersona\n /** Persona-shaping callbacks. Optional — omitted callbacks are derived from\n * the profile + persona payload, so a pure-profile call works. */\n shape?: MultishotShape<TPersona>\n /** Tool definitions advertised to the agent. Defaults to delegate_research + delegate_code. */\n tools?: MultishotToolDefinition[]\n /** Map from tool name → executor invoked inline when the agent emits a tool_call. */\n toolExecutors?: Record<string, MultishotToolExecutor>\n /** Map from tool name → artifact type label written into MultishotArtifact.type.\n * Tools without a mapping still execute, but their results aren't surfaced as\n * typed artifacts (only as tool messages in the transcript). */\n artifactTypeFor?: (toolName: string) => string | undefined\n maxTurns?: number\n agentModel?: string\n driverModel?: string\n /** Fallback driver models tried when the primary simulated-user model returns empty twice. */\n driverFallbackModels?: string[]\n /** Maximum output tokens for the first agent call in each assistant turn. */\n agentMaxTokens?: number\n /** Maximum output tokens for agent follow-up calls after tool results. */\n toolFollowupMaxTokens?: number\n /** Maximum output tokens for each simulated-user driver response. */\n driverMaxTokens?: number\n /** Maximum tool calls the agent may dispatch inside one assistant turn. */\n maxToolDispatches?: number\n /** Caller-owned execution for the agent leg. Every agent inference step\n * runs through this function; `agentModel` names the model it receives. */\n agentTransport: MultishotTransport\n /** Caller-owned execution for the simulated-user driver leg. Driver model\n * fallback rotation still applies — the transport receives each candidate\n * model in turn. */\n driverTransport: MultishotTransport\n /** Caller-owned execution for the specialist leg the tool executors run.\n * Defaults to `agentTransport`. */\n toolTransport?: MultishotTransport\n signal?: AbortSignal\n}\n\n/** One multishot shot — the conversation engine `runMultishotMatrix` invokes\n * once per cell. `runMultishot` is the default implementation.\n *\n * An alternative engine (a graph-backed conversation, a replay of a recorded\n * transcript, a sandbox-hosted agent) implements this exact signature and\n * reaches the matrix through `RunMultishotMatrixOptions.runShot`. The matrix\n * keeps every other cell mechanic — cell fan-out, concurrency, the cost\n * ceiling, the judge slots, the cell composite, and the per-cell writers — so\n * swapping the engine needs no copy of the cell body. */\nexport type MultishotShot<TPersona extends MultishotPersona> = (\n opts: RunMultishotOptions<TPersona>,\n) => Promise<MultishotResult>\n\n/** The package's reference conversation engine, and the referent of three\n * things that stop working without it.\n *\n * 1. `runMultishotMatrix` runs it as the per-cell engine when the caller names\n * no `runShot`, so the matrix always has an engine to run.\n * 2. `golden.test.ts` proves the frozen records against it on every run, and\n * perturbs it to prove the records detect a change. Records checked only\n * against a replay of themselves prove nothing.\n * 3. The repo's recording command names it as `--engine`. The script defaults\n * no engine, so a version records whichever one the caller names — and a\n * record set minted from a consumer's engine would let a product's wiring\n * define this package's frozen contract.\n *\n * An alternative engine reaches the matrix through `runShot` and reaches the\n * records through `assertMultishotGoldenScenario`. Neither seam removes the\n * three roles above. */\nexport async function runMultishot<TPersona extends MultishotPersona>(\n opts: RunMultishotOptions<TPersona>,\n): Promise<MultishotResult> {\n return runMultishotConversation(opts, async (conversation) => {\n for (let turn = 0; turn < conversation.maxTurns; turn++) {\n await conversation.agentTurn(turn)\n if (turn < conversation.maxTurns - 1) await conversation.driverTurn(turn)\n }\n })\n}\n","// Multishot matrix wrapper — sweeps profiles × personas × reps, runs\n// the driver-agent loop per cell, applies up to three configured judges,\n// persists per-cell artifacts, and aggregates by axis.\n//\n// Uses runAgentMatrix from @tangle-network/agent-eval/matrix under the\n// hood so cell scheduling + concurrency + cost ceiling are unified with\n// other matrix consumers.\n\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport type { CostProvenance } from '../cost-ledger'\nimport type { MatrixResult } from '../matrix'\nimport { runAgentMatrix, withCellSpend } from '../matrix'\nimport { type MultishotJudgeConfig, type JudgeScore, runJudge } from './judges'\nimport { type MultishotShot, runMultishot } from './multishot'\nimport {\n assertMultishotShotResult,\n type MultishotArtifact,\n type MultishotMessage,\n type MultishotPersona,\n type MultishotShape,\n type MultishotToolDefinition,\n type MultishotToolExecutor,\n type MultishotTransport,\n} from './types'\n\nexport interface ConversationJudgeInput<TPersona extends MultishotPersona> {\n transcript: MultishotMessage[]\n persona: TPersona\n}\n\nexport interface ArtifactJudgeInput<TPersona extends MultishotPersona> {\n artifact: MultishotArtifact\n persona: TPersona\n}\n\nexport interface MultishotJudges<TPersona extends MultishotPersona> {\n /** Scores the full transcript end-to-end (always runs). */\n conversation: MultishotJudgeConfig<ConversationJudgeInput<TPersona>>\n /** Scores each code-type artifact. Optional — omit when domain has no code artifacts. */\n codeReview?: MultishotJudgeConfig<ArtifactJudgeInput<TPersona>>\n /** Scores each non-code (research/content/template) artifact. Optional. */\n contentQuality?: MultishotJudgeConfig<ArtifactJudgeInput<TPersona>>\n /** Which artifact types route to codeReview. Defaults to ['code']. */\n codeArtifactTypes?: string[]\n /** Which artifact types route to contentQuality. Defaults to ['research']. */\n contentArtifactTypes?: string[]\n}\n\nexport interface CellCompositeScore {\n composite: number\n conversation: JudgeScore\n codeReview?: {\n perArtifact: Array<JudgeScore & { turn: number; type: string }>\n composite: number\n }\n contentQuality?: {\n perArtifact: Array<JudgeScore & { turn: number; type: string }>\n composite: number\n }\n}\n\nexport interface RunMultishotMatrixOptions<TPersona extends MultishotPersona> {\n /** AgentProfile axis (matrix primary). */\n profiles: Array<{ id: string; value: AgentProfile }>\n /** Persona axis. */\n personas: TPersona[]\n /** Persona-shaping callbacks. Optional — omitted callbacks are derived per\n * cell from that cell's profile + persona payload (pure-profile path). */\n shape?: MultishotShape<TPersona>\n /** Judge configurations. */\n judges: MultishotJudges<TPersona>\n /** Tool definitions advertised to the agent. Defaults to delegate_research + delegate_code. */\n tools?: MultishotToolDefinition[]\n /** Map from tool name → inline executor. Must align with `tools`. */\n toolExecutors?: Record<string, MultishotToolExecutor>\n /** Tool name → artifact type label. Defaults to research/code mapping. */\n artifactTypeFor?: (toolName: string) => string | undefined\n /** Where per-cell artifacts land. Cells write to `<runDir>/<profileId>/<personaId>/rep-N/`. */\n runDir: string\n /** Replicates per (profile, persona) cell. */\n reps?: number\n /** Max conversation turns per cell. */\n maxTurns?: number\n /** Maximum tool calls the agent may dispatch inside one assistant turn. */\n maxToolDispatches?: number\n /** Max concurrent cells. */\n maxConcurrency?: number\n /** Total $ ceiling across the matrix; cells aborted past this. */\n costCeiling?: number\n /** Upper bound on what one cell can spend. A cell whose cost is a subtotal\n * is charged this bound against `costCeiling` instead of its known amount,\n * so hidden spend cannot walk the run past its budget. */\n maxCellCostUsd?: number\n /** Agent model. */\n agentModel?: string\n /** Driver model. */\n driverModel?: string\n /** Fallback driver models tried when the primary simulated-user model returns empty twice. */\n driverFallbackModels?: string[]\n /** Maximum output tokens for the first agent call in each assistant turn. */\n agentMaxTokens?: number\n /** Maximum output tokens for agent follow-up calls after tool results. */\n toolFollowupMaxTokens?: number\n /** Maximum output tokens for each simulated-user driver response. */\n driverMaxTokens?: number\n /** Maximum output tokens for each judge response. */\n judgeMaxTokens?: number\n /** Caller-owned execution for the agent leg of every cell (see\n * RunMultishotOptions.agentTransport). Judges are unaffected; each judge\n * carries its own transport in MultishotJudges. */\n agentTransport: MultishotTransport\n /** Caller-owned execution for the simulated-user driver leg of every cell. */\n driverTransport: MultishotTransport\n /** Caller-owned execution for the specialist leg the tool executors run in\n * every cell. Defaults to `agentTransport`. */\n toolTransport?: MultishotTransport\n /** Conversation engine for every cell. Defaults to `runMultishot`.\n *\n * The matrix owns everything around the shot — cell fan-out, concurrency,\n * the cost ceiling, the judge slots, the cell composite, the per-cell\n * artifact writers and the run summary — and forwards the whole cell input\n * to this function, so an alternative engine replaces ONLY the\n * conversation. Every option on this interface that `runMultishot` accepts\n * reaches the shot unchanged. `RunMultishotOptions.signal` has no\n * matrix-level counterpart and is not forwarded; a shot owns its own\n * cancellation.\n *\n * A shot that resolves with a value outside `MultishotResult` throws\n * `MultishotShotResultError` for that cell. The default engine is never\n * used as a fallback. */\n runShot?: MultishotShot<TPersona>\n}\n\n/** Per-cell output the multishot matrix records in `MatrixResult.cells`.\n * A consumer that supplies its own `runShot` reads the matrix through this\n * type instead of declaring a structural copy. */\nexport interface MultishotCellOutput {\n turns: number\n toolCalls: number\n artifactCount: number\n}\n\ninterface ArtifactJudgeRun {\n score: JudgeScore & { turn: number; type: string }\n cost: CostProvenance\n}\n\n/** Mean composite over non-failed scores. `0` when the list is empty (a\n * configured judge with nothing to score contributes 0, matching the cell\n * composite's long-standing semantics); `null` when scores exist but every\n * one failed — no signal, so the slot must be EXCLUDED from the cell mean\n * rather than dragging it to zero. */\nfunction meanCompositeExcludingFailed(scores: ReadonlyArray<JudgeScore>): number | null {\n if (scores.length === 0) return 0\n const live = scores.filter((s) => !s.failed)\n if (live.length === 0) return null\n return live.reduce((sum, s) => sum + s.composite, 0) / live.length\n}\n\nexport interface CellCompositeInput {\n conversation: JudgeScore\n /** Present iff the codeReview judge is configured. */\n codeReviews?: ReadonlyArray<JudgeScore>\n /** Present iff the contentQuality judge is configured. */\n contentReviews?: ReadonlyArray<JudgeScore>\n}\n\n/** Cell composite = mean over configured judge slots, excluding failed\n * scores: a failed conversation judge or an all-failed artifact slot carries\n * no signal and is dropped from the mean. `composite` is 0 only when EVERY\n * configured slot failed (`allJudgesFailed` distinguishes that from a real\n * zero). Pure — exported for deterministic testing. */\nexport function computeCellComposite(input: CellCompositeInput): {\n composite: number\n codeComposite: number\n contentComposite: number\n allJudgesFailed: boolean\n} {\n const contributions: number[] = []\n if (!input.conversation.failed) contributions.push(input.conversation.composite)\n\n const codeMean = input.codeReviews ? meanCompositeExcludingFailed(input.codeReviews) : undefined\n if (typeof codeMean === 'number') contributions.push(codeMean)\n const contentMean = input.contentReviews\n ? meanCompositeExcludingFailed(input.contentReviews)\n : undefined\n if (typeof contentMean === 'number') contributions.push(contentMean)\n\n return {\n composite:\n contributions.length === 0\n ? 0\n : contributions.reduce((s, v) => s + v, 0) / contributions.length,\n codeComposite: codeMean ?? 0,\n contentComposite: contentMean ?? 0,\n allJudgesFailed: contributions.length === 0,\n }\n}\n\nexport interface RunMultishotMatrixResult {\n matrix: MatrixResult<MultishotCellOutput>\n}\n\nexport async function runMultishotMatrix<TPersona extends MultishotPersona>(\n opts: RunMultishotMatrixOptions<TPersona>,\n): Promise<RunMultishotMatrixResult> {\n const codeTypes = new Set(opts.judges.codeArtifactTypes ?? ['code'])\n const contentTypes = new Set(opts.judges.contentArtifactTypes ?? ['research'])\n const runShot: MultishotShot<TPersona> = opts.runShot ?? runMultishot\n mkdirSync(opts.runDir, { recursive: true })\n\n const matrix = await runAgentMatrix<MultishotCellOutput>({\n axes: [\n { name: 'profile', values: opts.profiles },\n { name: 'persona', values: opts.personas.map((p) => ({ id: p.id, value: p })) },\n ],\n reps: opts.reps ?? 1,\n maxConcurrency: opts.maxConcurrency ?? 2,\n costCeiling: opts.costCeiling,\n maxCellCostUsd: opts.maxCellCostUsd,\n async runCell(cell) {\n const cellStartedAt = Date.now()\n const profile = cell.axes.profile?.value as AgentProfile\n const persona = cell.axes.persona?.value as TPersona\n const profileId = String(cell.axes.profile?.id ?? 'unknown')\n const personaId = String(cell.axes.persona?.id ?? 'unknown')\n\n // A shot that throws declares its own spend (see `runMultishot`). Rethrow\n // it untouched: a shot that declared nothing spent an unknown amount, and\n // claiming a number here would report a fabricated total.\n const sim = await runShot({\n profile,\n persona,\n shape: opts.shape,\n tools: opts.tools,\n toolExecutors: opts.toolExecutors,\n artifactTypeFor: opts.artifactTypeFor,\n maxTurns: opts.maxTurns,\n maxToolDispatches: opts.maxToolDispatches,\n agentModel: opts.agentModel,\n driverModel: opts.driverModel,\n driverFallbackModels: opts.driverFallbackModels,\n agentMaxTokens: opts.agentMaxTokens,\n toolFollowupMaxTokens: opts.toolFollowupMaxTokens,\n driverMaxTokens: opts.driverMaxTokens,\n agentTransport: opts.agentTransport,\n driverTransport: opts.driverTransport,\n toolTransport: opts.toolTransport,\n })\n // Everything from here on runs with the shot's spend already committed.\n // A throw past this line must carry it, or the money leaves the matrix's\n // cumulative sum and the cost ceiling under-counts the run.\n const shotCostUsd = shotCostSubtotal(sim)\n // A shot that says nothing about provenance is taken at its word, which\n // is how every engine written before the field behaved.\n const shotCostComplete = sim?.costProvenance?.kind !== 'uncaptured'\n let judgeCostUsd = 0\n let judgeCostComplete = false\n // Where the cell is, so a throw declares the right completeness: before\n // the judges only the shot has spent, while they are in flight their\n // spend is unknown, and after they settle their receipts decide.\n let phase: 'validate' | 'judging' | 'scoring' = 'validate'\n try {\n assertMultishotShotResult(sim)\n\n const codeArtifacts = sim.artifacts.filter((a) => codeTypes.has(a.type))\n const contentArtifacts = sim.artifacts.filter((a) => contentTypes.has(a.type))\n\n phase = 'judging'\n const [conversationRun, codeReviewRuns, contentReviewRuns] = await Promise.all([\n runJudge(withJudgeMaxTokens(opts.judges.conversation, opts.judgeMaxTokens), {\n transcript: sim.transcript,\n persona,\n }),\n opts.judges.codeReview\n ? Promise.all(\n codeArtifacts.map((artifact) =>\n runJudge(withJudgeMaxTokens(opts.judges.codeReview!, opts.judgeMaxTokens), {\n artifact,\n persona,\n }).then((result) => ({\n score: {\n ...result.score,\n turn: artifact.turn,\n type: artifact.type,\n },\n cost: result.cost,\n })),\n ),\n )\n : Promise.resolve([] as ArtifactJudgeRun[]),\n opts.judges.contentQuality\n ? Promise.all(\n contentArtifacts.map((artifact) =>\n runJudge(withJudgeMaxTokens(opts.judges.contentQuality!, opts.judgeMaxTokens), {\n artifact,\n persona,\n }).then((result) => ({\n score: {\n ...result.score,\n turn: artifact.turn,\n type: artifact.type,\n },\n cost: result.cost,\n })),\n ),\n )\n : Promise.resolve([] as ArtifactJudgeRun[]),\n ])\n const judgeRuns = [conversationRun, ...codeReviewRuns, ...contentReviewRuns]\n judgeCostUsd = judgeRuns.reduce((sum, run) => sum + (run.cost.usd ?? 0), 0)\n judgeCostComplete = judgeRuns.every((run) => run.cost.kind !== 'uncaptured')\n phase = 'scoring'\n\n const conversation = conversationRun.score\n const codeReviews = codeReviewRuns.map((run) => run.score)\n const contentReviews = contentReviewRuns.map((run) => run.score)\n\n const { composite, codeComposite, contentComposite, allJudgesFailed } =\n computeCellComposite({\n conversation,\n codeReviews: opts.judges.codeReview ? codeReviews : undefined,\n contentReviews: opts.judges.contentQuality ? contentReviews : undefined,\n })\n\n const cellScore: CellCompositeScore = { composite, conversation }\n if (opts.judges.codeReview)\n cellScore.codeReview = { perArtifact: codeReviews, composite: codeComposite }\n if (opts.judges.contentQuality)\n cellScore.contentQuality = { perArtifact: contentReviews, composite: contentComposite }\n\n const cellDir = join(opts.runDir, profileId, personaId, `rep-${cell.rep}`)\n mkdirSync(cellDir, { recursive: true })\n writeFileSync(join(cellDir, 'transcript.json'), JSON.stringify(sim.transcript, null, 2))\n writeFileSync(join(cellDir, 'artifacts.json'), JSON.stringify(sim.artifacts, null, 2))\n writeFileSync(join(cellDir, 'scores.json'), JSON.stringify(cellScore, null, 2))\n\n const notes = [`convo=${conversation.composite.toFixed(1)}`]\n if (opts.judges.codeReview) notes.push(`code=${codeComposite.toFixed(1)}`)\n if (opts.judges.contentQuality) notes.push(`content=${contentComposite.toFixed(1)}`)\n if (allJudgesFailed) notes.push('all-judges-failed')\n if (!judgeCostComplete) notes.push('judge-cost-incomplete')\n\n return {\n output: {\n turns: sim.transcript.length,\n toolCalls: sim.toolCalls,\n artifactCount: sim.artifacts.length,\n },\n verdict: { valid: composite >= 5, score: composite, notes: notes.join(' ') },\n costUsd: sim.costUsd + judgeCostUsd,\n // Either leg can leave the cell total a subtotal: a judge whose cost\n // the router never reported, or a shot that declared its own spend\n // uncaptured. The matrix counts the known part toward the ceiling and\n // reports the cell as under-counted rather than presenting the sum as\n // complete.\n costProvenance:\n judgeCostComplete && shotCostComplete\n ? { kind: 'estimated', usd: sim.costUsd + judgeCostUsd }\n : { kind: 'uncaptured', usd: null },\n durationMs: sim.durationMs,\n }\n } catch (err) {\n // No usable shot subtotal means the cell's spend is genuinely unknown;\n // rethrow untouched so the matrix records it as uncaptured instead of\n // billing a number this frame cannot support.\n if (shotCostUsd === undefined) throw err\n throw withCellSpend(err, {\n costUsd: shotCostUsd + judgeCostUsd,\n durationMs: Date.now() - cellStartedAt,\n // The judges bill before they settle, so a throw among them leaves a\n // subtotal. Before they start, and after they settle with every\n // receipt captured, the amount is the cell's whole spend — unless the\n // shot already declared its own part incomplete.\n kind:\n shotCostComplete && (phase === 'validate' || (phase === 'scoring' && judgeCostComplete))\n ? 'estimated'\n : 'uncaptured',\n })\n }\n },\n })\n\n // Persist top-level summary.\n const summary = {\n cells: matrix.summary.totalCells,\n passRate: matrix.summary.overallPassRate,\n meanScore: matrix.summary.overallMeanScore,\n totalCostUsd: matrix.summary.totalCostUsd,\n costUncapturedCells: matrix.summary.costUncapturedCells,\n ceilingChargedUsd: matrix.summary.ceilingChargedUsd,\n durationMs: matrix.summary.durationMs,\n runsExecuted: matrix.summary.runsExecuted,\n cellsSkipped: matrix.summary.cellsSkipped,\n byProfile: matrix.byAxis.profile,\n byPersona: matrix.byAxis.persona,\n }\n writeFileSync(join(opts.runDir, 'summary.json'), JSON.stringify(summary, null, 2))\n\n // A reader of the on-disk summary must not take the cost line as the run's\n // whole spend when some cells reported only a subtotal.\n const uncaptured = matrix.summary.costUncapturedCells\n const costLabel = uncaptured > 0 ? 'Cost (at least)' : 'Cost'\n\n const md: string[] = [\n `# Multishot matrix`,\n ``,\n `**Cells**: ${matrix.summary.totalCells} | **Pass rate**: ${(matrix.summary.overallPassRate * 100).toFixed(0)}% | **Mean**: ${matrix.summary.overallMeanScore.toFixed(2)} | **${costLabel}**: $${matrix.summary.totalCostUsd.toFixed(2)} | **Duration**: ${(matrix.summary.durationMs / 1000).toFixed(0)}s`,\n ``,\n ...(uncaptured > 0\n ? [\n `> ${uncaptured} of ${matrix.summary.runsExecuted} cells reported a cost subtotal, not a total. Real spend is higher than every cost figure below.`,\n ``,\n ]\n : []),\n `## By profile`,\n ``,\n '| profile | pass | mean | cost |',\n '|---|---|---|---|',\n ...Object.entries(matrix.byAxis.profile ?? {}).map(\n ([id, s]) =>\n `| ${id} | ${(s.passRate * 100).toFixed(0)}% | ${s.meanScore.toFixed(2)} | $${s.totalCostUsd.toFixed(2)} |`,\n ),\n ``,\n `## By persona`,\n ``,\n '| persona | pass | mean | cost |',\n '|---|---|---|---|',\n ...Object.entries(matrix.byAxis.persona ?? {}).map(\n ([id, s]) =>\n `| ${id} | ${(s.passRate * 100).toFixed(0)}% | ${s.meanScore.toFixed(2)} | $${s.totalCostUsd.toFixed(2)} |`,\n ),\n ``,\n ]\n writeFileSync(join(opts.runDir, 'summary.md'), md.join('\\n'))\n\n return { matrix }\n}\n\n/** The shot's own spend, when the value it resolved with reports a usable\n * amount. `undefined` when it does not — a malformed shot result is exactly\n * the case where the number cannot be trusted, and billing a wrong figure is\n * worse than recording the cell as uncaptured. */\nfunction shotCostSubtotal(\n sim: { costUsd?: unknown; costProvenance?: CostProvenance } | null | undefined,\n): number | undefined {\n const value = sim?.costUsd\n return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined\n}\n\nfunction withJudgeMaxTokens<TInput>(\n judge: MultishotJudgeConfig<TInput>,\n maxTokens: number | undefined,\n): MultishotJudgeConfig<TInput> {\n if (maxTokens === undefined || judge.maxTokens !== undefined) return judge\n return { ...judge, maxTokens }\n}\n"],"mappings":";;;;;;;;;;;;;AASA,SAAgB,sBACd,OACA,OACQ;CACR,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,WAAW,MAAM,iBAAiB;CACxC,MAAM,YAAY,MAAM,qBAAqB;CAC7C,IAAI,UAAU;CACd,IAAI,WAAW;CACf,IAAI,MAAM,SAAS,aAAa,GAAG;EACjC,UAAU;EACV,WAAW;CACb,OAAO,IAAI,MAAM,SAAS,SAAS,KAAK,MAAM,SAAS,eAAe,GAAG;EACvE,UAAU;EACV,WAAW;CACb,OAAO,IAAI,MAAM,SAAS,MAAM,KAAK,MAAM,SAAS,KAAK,KAAK,MAAM,SAAS,UAAU,GAAG;EACxF,UAAU;EACV,WAAW;CACb;CACA,QAAQ,WAAW,UAAU,YAAY,YAAY;AACvD;;ACnBA,MAAM,2BAA2B;AACjC,MAAa,sBAAsB;AAgBnC,MAAM,4BACJ;AAEF,MAAM,uBACJ;AAEF,MAAM,iCAA0D;CAC9D,MAAM;CACN,UAAU;EACR,MAAM;EACN,aACE;EACF,YAAY;GACV,MAAM;GACN,YAAY;IACV,UAAU;KAAE,MAAM;KAAU,aAAa;IAAgC;IACzE,OAAO;KACL,MAAM;KACN,aAAa;IACf;GACF;GACA,UAAU,CAAC,UAAU;EACvB;CACF;AACF;AAEA,MAAM,6BAAsD;CAC1D,MAAM;CACN,UAAU;EACR,MAAM;EACN,aACE;EACF,YAAY;GACV,MAAM;GACN,YAAY;IACV,MAAM;KAAE,MAAM;KAAU,aAAa;IAAgC;IACrE,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,YAAY,OAAO,SAAS,KAAK,KAAK,SAAS,IAAI,QAAQ,KAAA;AACrF;AAEA,SAAS,mBACP,OACA,WAC8B;CAC9B,IAAI,cAAc,KAAA,KAAa,MAAM,cAAc,KAAA,GAAW,OAAO;CACrE,OAAO;EAAE,GAAG;EAAO;CAAU;AAC/B"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/multishot/cost.ts","../../src/multishot/default-tools.ts","../../src/multishot/shape-defaults.ts","../../src/multishot/conversation.ts","../../src/multishot/judges.ts","../../src/multishot/multishot.ts","../../src/multishot/matrix.ts"],"sourcesContent":["// Per-model cost estimator for multishot legs whose transport reported token\n// usage but no billed amount.\n\n/**\n * Rough per-model cost estimate from token counts. Underestimates Anthropic,\n * overestimates open-weight models — accurate enough for a cost ceiling, and\n * never presented as a billed amount: a leg metered from this table is\n * recorded with `estimated` provenance.\n */\nexport function estimateMultishotCost(\n model: string,\n usage?: { prompt_tokens?: number; completion_tokens?: number },\n): number {\n if (!usage) return 0\n const inputTok = usage.prompt_tokens ?? 0\n const outputTok = usage.completion_tokens ?? 0\n let inPer1k = 0.003\n let outPer1k = 0.015\n if (model.includes('gpt-4o-mini')) {\n inPer1k = 0.00015\n outPer1k = 0.0006\n } else if (model.includes('gpt-5.4') || model.includes('claude-sonnet')) {\n inPer1k = 0.003\n outPer1k = 0.015\n } else if (model.includes('kimi') || model.includes('glm') || model.includes('deepseek')) {\n inPer1k = 0.0005\n outPer1k = 0.002\n }\n return (inputTok * inPer1k + outputTok * outPer1k) / 1000\n}\n","// Default delegate_research + delegate_code tools and their inline executors.\n//\n// Consumers can override either by passing their own tools + executors to\n// runMultishot. The defaults are sufficient for most domains — point the\n// researcher system prompt at your domain's citation style and the coder\n// at your preferred language.\n\nimport { estimateMultishotCost } from './cost'\nimport type { MultishotToolDefinition, MultishotToolExecutor } from './types'\n\nconst DEFAULT_RESEARCHER_MODEL = 'openai/gpt-4o-mini'\nexport const DEFAULT_CODER_MODEL = 'openai/gpt-4o-mini'\n\nexport interface DefaultResearcherConfig {\n /** Replace the system prompt to bias the researcher toward a domain's\n * citation style. Defaults to a generic \"cite sources by name\" prompt. */\n systemPrompt?: string\n model?: string\n}\n\nexport interface DefaultCoderConfig {\n /** Replace the system prompt to bias the coder toward a language /\n * framework / artifact style. */\n systemPrompt?: string\n model?: string\n}\n\nconst GENERIC_RESEARCHER_SYSTEM =\n 'You are a research specialist. Return a markdown brief with 3-5 findings. Each finding cites a specific source by name. Add a confidence level (high/medium/low) per finding. No fluff, no preamble.'\n\nconst GENERIC_CODER_SYSTEM =\n 'You are an expert engineer. Output ONE fenced code block containing the complete solution. Inline-comment non-obvious decisions. No explanation outside the block.'\n\nconst DEFAULT_DELEGATE_RESEARCH_TOOL: MultishotToolDefinition = {\n type: 'function',\n function: {\n name: 'delegate_research',\n description:\n 'Research a topic deeply via specialist. Returns evidence-bearing items with citations. Use for audience research, competitive intel, regulatory landscape, market data, citation-grounded analysis.',\n parameters: {\n type: 'object',\n properties: {\n question: { type: 'string', description: 'Specific question to research' },\n scope: {\n type: 'string',\n description: 'Optional scope: time window, geography, jurisdiction, segment',\n },\n },\n required: ['question'],\n },\n },\n}\n\nconst DEFAULT_DELEGATE_CODE_TOOL: MultishotToolDefinition = {\n type: 'function',\n function: {\n name: 'delegate_code',\n description:\n 'Generate a runnable script, template, pipeline, or tool via specialist. Returns complete working code or structured markdown. Use for content pipelines, calc snippets, dashboards, compliance checklists, deadline trackers.',\n parameters: {\n type: 'object',\n properties: {\n goal: { type: 'string', description: 'What the code must accomplish' },\n language: {\n type: 'string',\n description: 'Optional language preference (default: TypeScript)',\n },\n },\n required: ['goal'],\n },\n },\n}\n\nfunction createResearchExecutor(config: DefaultResearcherConfig = {}): MultishotToolExecutor {\n const systemPrompt = config.systemPrompt ?? GENERIC_RESEARCHER_SYSTEM\n const model = config.model ?? DEFAULT_RESEARCHER_MODEL\n return async (args, ctx) => {\n const question = String(args.question ?? '')\n const scope = args.scope ? String(args.scope) : undefined\n const { message, usage, costUsd } = await ctx.transport({\n model,\n temperature: 0.3,\n maxTokens: 1800,\n messages: [\n { role: 'system', content: systemPrompt },\n { role: 'user', content: `Research: ${question}${scope ? `\\nScope: ${scope}` : ''}` },\n ],\n signal: ctx.signal,\n })\n return {\n content: message.content ?? '',\n costUsd: costUsd ?? estimateMultishotCost(model, usage),\n }\n }\n}\n\nfunction createCodeExecutor(config: DefaultCoderConfig = {}): MultishotToolExecutor {\n const systemPrompt = config.systemPrompt ?? GENERIC_CODER_SYSTEM\n const model = config.model ?? DEFAULT_CODER_MODEL\n return async (args, ctx) => {\n const goal = String(args.goal ?? '')\n const language = args.language ? String(args.language) : 'TypeScript'\n const { message, usage, costUsd } = await ctx.transport({\n model,\n temperature: 0.2,\n maxTokens: 2000,\n messages: [\n { role: 'system', content: `${systemPrompt}\\n\\nLanguage: ${language}` },\n { role: 'user', content: `Produce: ${goal}` },\n ],\n signal: ctx.signal,\n })\n return {\n content: message.content ?? '',\n costUsd: costUsd ?? estimateMultishotCost(model, usage),\n }\n }\n}\n\nexport interface DefaultToolsConfig {\n research?: DefaultResearcherConfig\n code?: DefaultCoderConfig\n /** When true (default), each tool result is recorded as a typed artifact:\n * research → type='research', code → type='code'. */\n recordArtifacts?: boolean\n}\n\nexport interface DefaultToolsBundle {\n tools: MultishotToolDefinition[]\n executors: Record<string, MultishotToolExecutor>\n artifactTypeFor: (toolName: string) => string | undefined\n}\n\nexport function defaultDelegationTools(config: DefaultToolsConfig = {}): DefaultToolsBundle {\n return {\n tools: [DEFAULT_DELEGATE_RESEARCH_TOOL, DEFAULT_DELEGATE_CODE_TOOL],\n executors: {\n delegate_research: createResearchExecutor(config.research),\n delegate_code: createCodeExecutor(config.code),\n },\n artifactTypeFor: (name) =>\n name === 'delegate_research' ? 'research' : name === 'delegate_code' ? 'code' : undefined,\n }\n}\n","// Profile-derived defaults for MultishotShape — the pure-profile path.\n//\n// `MultishotShape`'s callbacks were REQUIRED beside `profile: AgentProfile`,\n// which mixed the abstractions: the node under test was a profile, but the\n// simulated user's role could only be expressed as code. These defaults make\n// the callbacks optional — a pure-profile call works, and the derived prompts\n// are plain data (a pure function of profile + persona payload), so an\n// optimizer can sweep them (tangle-network/agent-runtime#694).\n\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport type { MultishotPersona, MultishotShape } from './types'\n\n/** Persona payload rendered as stable `- key: value` lines. `id` is identity,\n * not voice, and structured values are serialized so nothing is dropped. */\nfunction renderPersonaFacts(persona: MultishotPersona): string {\n const lines: string[] = []\n for (const [key, value] of Object.entries(persona)) {\n if (key === 'id' || value === undefined) continue\n const rendered =\n typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'\n ? String(value)\n : JSON.stringify(value)\n lines.push(`- ${key}: ${rendered}`)\n }\n return lines.join('\\n')\n}\n\n/** Default opening user message: the persona introduces itself with its whole\n * payload and asks the agent (as described by the profile) to take over. */\nfunction defaultMultishotOpener(profile: AgentProfile, persona: MultishotPersona): string {\n const facts = renderPersonaFacts(persona)\n const agentDescription = profile.description ?? profile.name ?? 'the agent'\n return [\n `Hi — I'm reaching out to ${agentDescription} for help. My situation:`,\n facts.length > 0 ? facts : `- (no details provided beyond id: ${persona.id})`,\n '',\n 'Tell me what you need from me, and get started on my case.',\n ].join('\\n')\n}\n\n/** Default driver system prompt: roleplay the persona from its payload, stay\n * in character, push back on vague answers, and never go silent. */\nfunction defaultMultishotDriverSystemPrompt(\n profile: AgentProfile,\n persona: MultishotPersona,\n): string {\n const facts = renderPersonaFacts(persona)\n const agentDescription = profile.description ?? profile.name ?? 'an AI agent'\n return [\n `You are role-playing a real person (persona \"${persona.id}\") talking to ${agentDescription}.`,\n facts.length > 0 ? `Who you are:\\n${facts}` : '',\n '',\n 'How to behave:',\n '- Stay in character: first person, realistic voice, concrete details from your situation.',\n '- Judge every reply by whether it actually moves YOUR case forward. Push back on vague, hedged, or generic answers and demand specifics.',\n \"- Answer the agent's questions with information consistent with who you are; invent plausible details rather than stalling.\",\n '- Never go silent: always produce a substantive next message.',\n '- Output ONLY your next message to the agent — no meta-commentary, no stage directions.',\n ]\n .filter((block) => block.length > 0)\n .join('\\n')\n}\n\n/** The fully-resolved shape for a profile: caller overrides win, the\n * profile-derived defaults fill the rest. */\nexport function defaultShapeFromProfile<TPersona extends MultishotPersona>(\n profile: AgentProfile,\n shape?: MultishotShape<TPersona>,\n): Required<MultishotShape<TPersona>> {\n return {\n buildOpener: shape?.buildOpener ?? ((persona) => defaultMultishotOpener(profile, persona)),\n buildDriverSystemPrompt:\n shape?.buildDriverSystemPrompt ??\n ((persona) => defaultMultishotDriverSystemPrompt(profile, persona)),\n }\n}\n","// The multishot conversation's two legs, separable from the loop that orders\n// them.\n//\n// `runMultishot` orders the legs as a plain turn loop. A caller that orders\n// them another way — a Runtime flow graph, a scheduler, a replay harness —\n// drives the same legs through `runMultishotConversation`, so the transcript,\n// artifacts, tool-call count, driver point of view and cost accounting stay\n// this package's single implementation.\n//\n// agent-eval owns no model transport: every leg runs on a MultishotTransport\n// the caller supplies, so no provider credential enters this package.\n\nimport { withCellSpend } from '../matrix'\nimport { estimateMultishotCost } from './cost'\nimport { defaultDelegationTools } from './default-tools'\nimport type { RunMultishotOptions } from './multishot'\nimport { defaultShapeFromProfile } from './shape-defaults'\nimport {\n type MultishotArtifact,\n MultishotDriverEmptyError,\n MultishotFatalToolError,\n type MultishotMessage,\n type MultishotPersona,\n type MultishotResult,\n} from './types'\n\n/** Prompt and completion tokens one leg reported. */\nexport interface MultishotLegTokens {\n input: number\n output: number\n}\n\n/** What one leg spent: its tokens and the USD it added to the conversation's\n * cost (provider-reported, else estimated from usage; tool executor spend\n * included). */\nexport interface MultishotLegSpend {\n tokens: MultishotLegTokens\n usd: number\n}\n\n/** One conversation's state and legs. Each leg appends to the shared\n * transcript; the caller decides the order in which legs run. */\nexport interface MultishotConversation {\n /** Agent turns the conversation is configured for (`opts.maxTurns ?? 10`). */\n readonly maxTurns: number\n /** The model the agent leg runs on. */\n readonly agentModel: string\n /** The primary simulated-user model. */\n readonly driverModel: string\n /** The persona's first message, already in the transcript. */\n readonly opener: string\n /** The simulated user's system prompt. */\n readonly driverSystemPrompt: string\n /** One agent turn: inference, inline tool execution and follow-up inference,\n * until the agent answers without tools. Throws on abort, on a fatal tool\n * error and on the per-turn tool dispatch cap. */\n agentTurn(turn: number): Promise<MultishotLegSpend>\n /** The simulated user's reply to the transcript so far, appended for the\n * next agent turn. Retries an empty reply once per model, rotates through\n * the fallback models, then throws `MultishotDriverEmptyError`. */\n driverTurn(turn: number): Promise<MultishotLegSpend & { content: string }>\n}\n\n/** Orders the legs of one conversation. Resolves when the conversation is done. */\nexport type MultishotConversationDriver = (conversation: MultishotConversation) => Promise<void>\n\ninterface ConversationMeter {\n costUsd: number\n startedAt: number\n /** True once a call contributed a fabricated `0` — no provider cost and no\n * usage to price. `costUsd` is a subtotal from that point on. */\n uncaptured: boolean\n}\n\n/**\n * Run one multishot conversation whose leg order `drive` decides.\n *\n * Returns the conversation's `MultishotResult`. When any leg or `drive` throws,\n * the error is rethrown carrying the spend so far (`withCellSpend`), so a\n * matrix bills the failed cell for the turns it already paid for.\n */\nexport async function runMultishotConversation<TPersona extends MultishotPersona>(\n opts: RunMultishotOptions<TPersona>,\n drive: MultishotConversationDriver,\n): Promise<MultishotResult> {\n const meter: ConversationMeter = { costUsd: 0, startedAt: Date.now(), uncaptured: false }\n try {\n const state = openConversation(opts, meter)\n await drive(state.conversation)\n return {\n transcript: state.transcript,\n artifacts: state.artifacts,\n toolCalls: state.toolCalls(),\n durationMs: Date.now() - meter.startedAt,\n costUsd: meter.costUsd,\n // A shot that priced every call reports a complete estimate. One that had\n // a call the router priced at nothing reports a subtotal, so the cell is\n // recorded as under-counted rather than as a complete estimate.\n costProvenance: meter.uncaptured\n ? { kind: 'uncaptured', usd: null }\n : { kind: 'estimated', usd: meter.costUsd },\n }\n } catch (err) {\n throw withCellSpend(err, {\n costUsd: meter.costUsd,\n durationMs: Date.now() - meter.startedAt,\n kind: meter.uncaptured ? 'uncaptured' : 'estimated',\n })\n }\n}\n\nfunction openConversation<TPersona extends MultishotPersona>(\n opts: RunMultishotOptions<TPersona>,\n meter: ConversationMeter,\n): {\n conversation: MultishotConversation\n transcript: MultishotMessage[]\n artifacts: MultishotArtifact[]\n toolCalls: () => number\n} {\n const maxTurns = opts.maxTurns ?? 10\n const maxToolDispatches = opts.maxToolDispatches ?? 4\n const agentModel = opts.agentModel ?? 'openai/gpt-5.4'\n const driverModel = opts.driverModel ?? 'openai/gpt-4o-mini'\n const driverModels = [driverModel, ...(opts.driverFallbackModels ?? [])]\n const agentMaxTokens = opts.agentMaxTokens ?? 2500\n const toolFollowupMaxTokens = opts.toolFollowupMaxTokens ?? 2000\n const driverMaxTokens = opts.driverMaxTokens ?? 600\n\n const bundle =\n opts.tools && opts.toolExecutors\n ? {\n tools: opts.tools,\n executors: opts.toolExecutors,\n artifactTypeFor: opts.artifactTypeFor ?? (() => undefined),\n }\n : defaultDelegationTools()\n const tools = opts.tools ?? bundle.tools\n const executors = opts.toolExecutors ?? bundle.executors\n const artifactTypeFor = opts.artifactTypeFor ?? bundle.artifactTypeFor\n\n const agentTransport = opts.agentTransport\n const driverTransport = opts.driverTransport\n const toolTransport = opts.toolTransport ?? agentTransport\n\n const shape = defaultShapeFromProfile(opts.profile, opts.shape)\n\n const transcript: MultishotMessage[] = []\n const artifacts: MultishotArtifact[] = []\n let toolCalls = 0\n\n const opener = shape.buildOpener(opts.persona)\n transcript.push({ role: 'user', content: opener })\n\n const systemPrompt = [opts.profile.prompt?.systemPrompt, opts.profile.prompt?.appendSystemPrompt]\n .filter((value): value is string => Boolean(value))\n .join('\\n\\n')\n const agentMessages: Array<Record<string, unknown>> = [\n { role: 'system', content: systemPrompt },\n { role: 'user', content: opener },\n ]\n const driverSystemPrompt = shape.buildDriverSystemPrompt(opts.persona)\n\n async function agentTurn(turn: number): Promise<MultishotLegSpend> {\n if (opts.signal?.aborted) throw new Error('multishot aborted')\n const usdBefore = meter.costUsd\n const tokens = { input: 0, output: 0 }\n let dispatchesThisTurn = 0\n while (true) {\n const {\n message: agentMsg,\n usage: agentUsage,\n costUsd: agentCostUsd,\n } = await agentTransport({\n model: agentModel,\n messages: agentMessages,\n tools,\n temperature: 0.7,\n maxTokens: dispatchesThisTurn === 0 ? agentMaxTokens : toolFollowupMaxTokens,\n signal: opts.signal,\n })\n meter.costUsd += agentCostUsd ?? estimateMultishotCost(agentModel, agentUsage)\n if (agentCostUsd === undefined && agentUsage === undefined) meter.uncaptured = true\n tokens.input += agentUsage?.prompt_tokens ?? 0\n tokens.output += agentUsage?.completion_tokens ?? 0\n\n const agentText = (agentMsg.content ?? '').trim()\n const agentToolCalls = (agentMsg.tool_calls ?? []).map((tc) => ({\n id: tc.id,\n name: tc.function.name,\n args: (() => {\n try {\n return JSON.parse(tc.function.arguments) as Record<string, unknown>\n } catch {\n return {} as Record<string, unknown>\n }\n })(),\n }))\n\n agentMessages.push({\n role: 'assistant',\n content: agentText || null,\n ...(agentMsg.tool_calls?.length ? { tool_calls: agentMsg.tool_calls } : {}),\n })\n transcript.push({\n role: 'assistant',\n content: agentText,\n toolCalls: agentToolCalls.length > 0 ? agentToolCalls : undefined,\n })\n\n if (agentToolCalls.length === 0) break\n dispatchesThisTurn += agentToolCalls.length\n if (dispatchesThisTurn > maxToolDispatches) {\n throw new Error(\n `multishot: tool dispatch cap exceeded (${dispatchesThisTurn}/${maxToolDispatches}) on turn ${turn}`,\n )\n }\n\n for (const tc of agentToolCalls) {\n toolCalls++\n let toolResult = ''\n try {\n const executor = executors[tc.name]\n if (!executor) {\n toolResult = JSON.stringify({ error: `unknown tool ${tc.name}` })\n } else {\n const r = await executor(tc.args, { transport: toolTransport, signal: opts.signal })\n toolResult = r.content\n meter.costUsd += r.costUsd\n const artifactType = artifactTypeFor(tc.name)\n if (artifactType) {\n artifacts.push({\n type: artifactType,\n turn,\n invocation: { name: tc.name, args: tc.args },\n content: toolResult,\n })\n }\n }\n } catch (err) {\n if (err instanceof MultishotFatalToolError) throw err\n toolResult = JSON.stringify({ error: err instanceof Error ? err.message : String(err) })\n }\n agentMessages.push({ role: 'tool', tool_call_id: tc.id, content: toolResult || 'done' })\n transcript.push({ role: 'tool', content: toolResult || 'done', toolCallId: tc.id })\n }\n }\n return { tokens, usd: meter.costUsd - usdBefore }\n }\n\n // Every driver attempt is charged, including the empty ones that force a\n // retry and the ones that precede `MultishotDriverEmptyError`: those calls\n // billed the provider whether or not their content was usable.\n async function driverTurn(turn: number): Promise<MultishotLegSpend & { content: string }> {\n const usdBefore = meter.costUsd\n // Driver point of view: the agent's `assistant` messages become `user`\n // (the agent talking TO the driver); the driver's prior `user` messages\n // become `assistant` (the driver's prior responses).\n const driverMessages: Array<Record<string, unknown>> = [\n { role: 'system', content: driverSystemPrompt },\n ]\n for (const msg of transcript) {\n if (msg.role === 'tool') continue\n const content = driverVisibleContent(msg)\n if (!content) continue\n if (msg.role === 'assistant') driverMessages.push({ role: 'user', content })\n else if (msg.role === 'user') driverMessages.push({ role: 'assistant', content })\n }\n\n // The driver must never go silent. Retry once on empty content; then fail loud.\n const tokens = { input: 0, output: 0 }\n for (const model of driverModels) {\n for (let attempt = 0; attempt < 2; attempt++) {\n const { message, usage, costUsd } = await driverTransport({\n model,\n messages: driverMessages,\n temperature: 0.9,\n maxTokens: driverMaxTokens,\n signal: opts.signal,\n })\n meter.costUsd += costUsd ?? estimateMultishotCost(model, usage)\n if (costUsd === undefined && usage === undefined) meter.uncaptured = true\n tokens.input += usage?.prompt_tokens ?? 0\n tokens.output += usage?.completion_tokens ?? 0\n const content = (message.content ?? '').trim()\n if (content.length > 0) {\n agentMessages.push({ role: 'user', content })\n transcript.push({ role: 'user', content })\n return { content, tokens, usd: meter.costUsd - usdBefore }\n }\n }\n }\n throw new MultishotDriverEmptyError(turn)\n }\n\n return {\n conversation: {\n maxTurns,\n agentModel,\n driverModel,\n opener,\n driverSystemPrompt,\n agentTurn,\n driverTurn,\n },\n transcript,\n artifacts,\n toolCalls: () => toolCalls,\n }\n}\n\n/** Silent tool-calling agent turns surface to the driver as\n * \"Agent called tools: …\" so the simulated user can react to them. */\nfunction driverVisibleContent(msg: MultishotMessage): string | null {\n const text = msg.content.trim()\n if (text.length > 0) return text\n if (msg.role !== 'assistant' || !msg.toolCalls?.length) return null\n\n const toolNames = msg.toolCalls.map((call) => call.name.trim()).filter(Boolean)\n if (toolNames.length === 0) return 'Agent called tools.'\n return `Agent called ${toolNames.length === 1 ? 'tool' : 'tools'}: ${toolNames.join(', ')}.`\n}\n","// Generic judge runner — domain consumers configure dimensions + prompts.\n//\n// Three judge slots are conventional for multishot eval:\n// - conversation (scores the full transcript)\n// - codeReview (scores each code artifact)\n// - contentQuality (scores each non-code artifact)\n//\n// But the runJudge primitive is fully generic: any input maps to a score plus\n// explicit observed, estimated, or uncaptured cost.\n\nimport { DEFAULT_JUDGE_MODEL } from '../analyst/chat-client'\nimport type { JudgeDimension, JudgeScore } from '../campaign/types'\nimport type { CostProvenance } from '../cost-ledger'\nimport type { LlmCallMetadata, LlmUsage } from '../llm-client'\nimport { estimateCost, isModelPriced } from '../metrics'\nimport type { MultishotTransport, MultishotTransportResponse } from './types'\n\n// Canonical declaration lives in campaign/types.ts. Multishot emits the same\n// shape on its producer-defined 0-10 scale.\nexport type { JudgeDimension, JudgeScore } from '../campaign/types'\n\nexport interface MultishotJudgeConfig<TInput> {\n /** Display name (for trace + log). */\n name: string\n /** Caller-owned execution for this judge's call. agent-eval issues no\n * provider request and holds no credential. */\n transport: MultishotTransport\n /** Model used for this judge. */\n model?: string\n /** 0-10 scored dimensions. */\n dimensions: JudgeDimension[]\n /** Judge system prompt — sets persona + JSON-only constraint. */\n systemPrompt: string\n /** Build the user prompt from the typed input. Must include \"Respond with\n * ONLY this JSON: { ... }\" listing each dimension key. */\n buildPrompt: (input: TInput) => string\n /** Maximum output tokens for the judge response. Defaults to 1500. */\n maxTokens?: number\n}\n\nexport interface JudgeRunResult {\n /** Semantic result; failed scores remain non-throwing so matrix aggregation can exclude them. */\n score: JudgeScore\n /** Cost of the completed call, separate from diagnostic provider metadata. */\n cost: CostProvenance\n}\n\nexport async function runJudge<TInput>(\n judge: MultishotJudgeConfig<TInput>,\n input: TInput,\n): Promise<JudgeRunResult> {\n const model = judge.model ?? DEFAULT_JUDGE_MODEL\n const prompt = judge.buildPrompt(input)\n let raw = ''\n let llmCall: LlmCallMetadata\n let cost: CostProvenance\n const startedAt = Date.now()\n try {\n const response = await judge.transport({\n model,\n temperature: 0,\n maxTokens: judge.maxTokens ?? 1500,\n messages: [\n { role: 'system', content: judge.systemPrompt },\n { role: 'user', content: prompt },\n ],\n })\n const call = judgeCallMetadata(response, model, Date.now() - startedAt)\n llmCall = call.llmCall\n cost = call.cost\n raw = (response.message.content ?? '').trim()\n } catch (err) {\n // failed:true lets consumers reading `.composite` keep working while\n // aggregators exclude this score from means instead of averaging a zero.\n return {\n score: {\n dimensions: {},\n composite: 0,\n failed: true,\n notes: `judge ${judge.name} call failed: ${err instanceof Error ? err.message : String(err)}`,\n llmCall: unknownJudgeCall(model, Date.now() - startedAt),\n },\n cost: { kind: 'uncaptured', usd: null },\n }\n }\n\n let parsed: Record<string, unknown> | null = null\n try {\n const cleaned = raw\n .replace(/^```json\\s*/i, '')\n .replace(/```\\s*$/, '')\n .trim()\n parsed = JSON.parse(cleaned) as Record<string, unknown>\n } catch {\n return {\n score: {\n dimensions: {},\n composite: 0,\n failed: true,\n notes: `judge ${judge.name} returned non-JSON: ${raw.slice(0, 200)}`,\n llmCall,\n },\n cost,\n }\n }\n\n const dimensions: Record<string, number> = {}\n let sum = 0\n for (const dim of judge.dimensions) {\n const v = Number(parsed[dim.key] ?? 0)\n const clamped = Number.isFinite(v) ? Math.max(0, Math.min(10, v)) : 0\n dimensions[dim.key] = clamped\n sum += clamped\n }\n return {\n score: {\n dimensions,\n composite: judge.dimensions.length === 0 ? 0 : sum / judge.dimensions.length,\n notes: typeof parsed.notes === 'string' ? parsed.notes : '',\n llmCall,\n },\n cost,\n }\n}\n\nfunction judgeCallMetadata(\n response: MultishotTransportResponse,\n requestedModel: string,\n durationMs: number,\n): {\n llmCall: LlmCallMetadata\n cost: CostProvenance\n} {\n const usage = canonicalUsage(response.usage)\n // The transport reports the served identity when it observed one. Falling\n // back to the requested id keeps attribution honest for a transport that\n // reported none; it is not proof that model answered.\n const model = response.model ?? requestedModel\n return {\n llmCall: {\n usage,\n costUsd: response.costUsd ?? null,\n model,\n durationMs,\n },\n cost:\n response.costUsd !== undefined\n ? { kind: 'observed', usd: response.costUsd }\n : usage.captured === false || !isModelPriced(model)\n ? { kind: 'uncaptured', usd: null }\n : {\n kind: 'estimated',\n usd: estimateCost(usage.promptTokens, usage.completionTokens, model),\n },\n }\n}\n\nfunction canonicalUsage(usage: MultishotTransportResponse['usage']): LlmUsage {\n const promptTokens = tokenCount(usage?.prompt_tokens)\n const completionTokens = tokenCount(usage?.completion_tokens)\n const captured = promptTokens !== undefined && completionTokens !== undefined\n return {\n promptTokens: promptTokens ?? 0,\n completionTokens: completionTokens ?? 0,\n totalTokens: (promptTokens ?? 0) + (completionTokens ?? 0),\n captured,\n }\n}\n\nfunction unknownJudgeCall(model: string, durationMs: number): LlmCallMetadata {\n return {\n usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0, captured: false },\n costUsd: null,\n model,\n durationMs,\n }\n}\n\nfunction tokenCount(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : undefined\n}\n\n/** Convenience: stringified dimension list for inclusion in a judge prompt.\n * Returns lines like `- audience_fit: Does this match what the audience cares about? (0-10)`. */\nexport function renderDimensions(dims: readonly JudgeDimension[]): string {\n return dims.map((d) => `- ${d.key}: ${d.description}`).join('\\n')\n}\n\n/** Convenience: build the \"Respond with ONLY this JSON\" footer for a judge prompt. */\nexport function renderJsonFooter(dims: readonly JudgeDimension[]): string {\n const fields = dims.map((d) => `\"${d.key}\":N`).join(',')\n return `Respond with ONLY this JSON (no markdown, no preamble):\\n{${fields},\"notes\":\"1-2 sentence critique\"}`\n}\n","// Multi-turn driver-agent simulation with inline tool execution.\n//\n// The driver = LLM acting as the persona (reactive, non-deterministic).\n// The agent = the product agent under test, executed by the caller-supplied\n// transport with the profile's systemPrompt + the configured tools.\n// Tool calls execute inline via the configured executors and feed back\n// into the agent's message log so the agent integrates the result.\n//\n// agent-eval owns no model transport: every leg runs on a MultishotTransport\n// the caller supplies, so no provider credential enters this package.\n\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport { runMultishotConversation } from './conversation'\nimport type {\n MultishotPersona,\n MultishotResult,\n MultishotShape,\n MultishotToolDefinition,\n MultishotToolExecutor,\n MultishotTransport,\n} from './types'\n\nexport interface RunMultishotOptions<TPersona extends MultishotPersona> {\n profile: AgentProfile\n persona: TPersona\n /** Persona-shaping callbacks. Optional — omitted callbacks are derived from\n * the profile + persona payload, so a pure-profile call works. */\n shape?: MultishotShape<TPersona>\n /** Tool definitions advertised to the agent. Defaults to delegate_research + delegate_code. */\n tools?: MultishotToolDefinition[]\n /** Map from tool name → executor invoked inline when the agent emits a tool_call. */\n toolExecutors?: Record<string, MultishotToolExecutor>\n /** Map from tool name → artifact type label written into MultishotArtifact.type.\n * Tools without a mapping still execute, but their results aren't surfaced as\n * typed artifacts (only as tool messages in the transcript). */\n artifactTypeFor?: (toolName: string) => string | undefined\n maxTurns?: number\n agentModel?: string\n driverModel?: string\n /** Fallback driver models tried when the primary simulated-user model returns empty twice. */\n driverFallbackModels?: string[]\n /** Maximum output tokens for the first agent call in each assistant turn. */\n agentMaxTokens?: number\n /** Maximum output tokens for agent follow-up calls after tool results. */\n toolFollowupMaxTokens?: number\n /** Maximum output tokens for each simulated-user driver response. */\n driverMaxTokens?: number\n /** Maximum tool calls the agent may dispatch inside one assistant turn. */\n maxToolDispatches?: number\n /** Caller-owned execution for the agent leg. Every agent inference step\n * runs through this function; `agentModel` names the model it receives. */\n agentTransport: MultishotTransport\n /** Caller-owned execution for the simulated-user driver leg. Driver model\n * fallback rotation still applies — the transport receives each candidate\n * model in turn. */\n driverTransport: MultishotTransport\n /** Caller-owned execution for the specialist leg the tool executors run.\n * Defaults to `agentTransport`. */\n toolTransport?: MultishotTransport\n signal?: AbortSignal\n}\n\n/** One multishot shot — the conversation engine `runMultishotMatrix` invokes\n * once per cell. `runMultishot` is the default implementation.\n *\n * An alternative engine (a graph-backed conversation, a replay of a recorded\n * transcript, a sandbox-hosted agent) implements this exact signature and\n * reaches the matrix through `RunMultishotMatrixOptions.runShot`. The matrix\n * keeps every other cell mechanic — cell fan-out, concurrency, the cost\n * ceiling, the judge slots, the cell composite, and the per-cell writers — so\n * swapping the engine needs no copy of the cell body. */\nexport type MultishotShot<TPersona extends MultishotPersona> = (\n opts: RunMultishotOptions<TPersona>,\n) => Promise<MultishotResult>\n\n/** The package's reference conversation engine, and the referent of three\n * things that stop working without it.\n *\n * 1. `runMultishotMatrix` runs it as the per-cell engine when the caller names\n * no `runShot`, so the matrix always has an engine to run.\n * 2. `golden.test.ts` proves the frozen records against it on every run, and\n * perturbs it to prove the records detect a change. Records checked only\n * against a replay of themselves prove nothing.\n * 3. The repo's recording command names it as `--engine`. The script defaults\n * no engine, so a version records whichever one the caller names — and a\n * record set minted from a consumer's engine would let a product's wiring\n * define this package's frozen contract.\n *\n * An alternative engine reaches the matrix through `runShot` and reaches the\n * records through `assertMultishotGoldenScenario`. Neither seam removes the\n * three roles above. */\nexport async function runMultishot<TPersona extends MultishotPersona>(\n opts: RunMultishotOptions<TPersona>,\n): Promise<MultishotResult> {\n return runMultishotConversation(opts, async (conversation) => {\n for (let turn = 0; turn < conversation.maxTurns; turn++) {\n await conversation.agentTurn(turn)\n if (turn < conversation.maxTurns - 1) await conversation.driverTurn(turn)\n }\n })\n}\n","// Multishot matrix wrapper — sweeps profiles × personas × reps, runs\n// the driver-agent loop per cell, applies up to three configured judges,\n// persists per-cell artifacts, and aggregates by axis.\n//\n// Uses runAgentMatrix from @tangle-network/agent-eval/matrix under the\n// hood so cell scheduling + concurrency + cost ceiling are unified with\n// other matrix consumers.\n\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport type { CostProvenance } from '../cost-ledger'\nimport type { MatrixResult } from '../matrix'\nimport { runAgentMatrix, withCellSpend } from '../matrix'\nimport { type MultishotJudgeConfig, type JudgeScore, runJudge } from './judges'\nimport { type MultishotShot, runMultishot } from './multishot'\nimport {\n assertMultishotShotResult,\n type MultishotArtifact,\n type MultishotMessage,\n type MultishotPersona,\n type MultishotShape,\n type MultishotToolDefinition,\n type MultishotToolExecutor,\n type MultishotTransport,\n} from './types'\n\nexport interface ConversationJudgeInput<TPersona extends MultishotPersona> {\n transcript: MultishotMessage[]\n persona: TPersona\n}\n\nexport interface ArtifactJudgeInput<TPersona extends MultishotPersona> {\n artifact: MultishotArtifact\n persona: TPersona\n}\n\nexport interface MultishotJudges<TPersona extends MultishotPersona> {\n /** Scores the full transcript end-to-end (always runs). */\n conversation: MultishotJudgeConfig<ConversationJudgeInput<TPersona>>\n /** Scores each code-type artifact. Optional — omit when domain has no code artifacts. */\n codeReview?: MultishotJudgeConfig<ArtifactJudgeInput<TPersona>>\n /** Scores each non-code (research/content/template) artifact. Optional. */\n contentQuality?: MultishotJudgeConfig<ArtifactJudgeInput<TPersona>>\n /** Which artifact types route to codeReview. Defaults to ['code']. */\n codeArtifactTypes?: string[]\n /** Which artifact types route to contentQuality. Defaults to ['research']. */\n contentArtifactTypes?: string[]\n}\n\nexport interface CellCompositeScore {\n composite: number\n conversation: JudgeScore\n codeReview?: {\n perArtifact: Array<JudgeScore & { turn: number; type: string }>\n composite: number\n }\n contentQuality?: {\n perArtifact: Array<JudgeScore & { turn: number; type: string }>\n composite: number\n }\n}\n\nexport interface RunMultishotMatrixOptions<TPersona extends MultishotPersona> {\n /** AgentProfile axis (matrix primary). */\n profiles: Array<{ id: string; value: AgentProfile }>\n /** Persona axis. */\n personas: TPersona[]\n /** Persona-shaping callbacks. Optional — omitted callbacks are derived per\n * cell from that cell's profile + persona payload (pure-profile path). */\n shape?: MultishotShape<TPersona>\n /** Judge configurations. */\n judges: MultishotJudges<TPersona>\n /** Tool definitions advertised to the agent. Defaults to delegate_research + delegate_code. */\n tools?: MultishotToolDefinition[]\n /** Map from tool name → inline executor. Must align with `tools`. */\n toolExecutors?: Record<string, MultishotToolExecutor>\n /** Tool name → artifact type label. Defaults to research/code mapping. */\n artifactTypeFor?: (toolName: string) => string | undefined\n /** Where per-cell artifacts land. Cells write to `<runDir>/<profileId>/<personaId>/rep-N/`. */\n runDir: string\n /** Replicates per (profile, persona) cell. */\n reps?: number\n /** Max conversation turns per cell. */\n maxTurns?: number\n /** Maximum tool calls the agent may dispatch inside one assistant turn. */\n maxToolDispatches?: number\n /** Max concurrent cells. */\n maxConcurrency?: number\n /** Total $ ceiling across the matrix; cells aborted past this. */\n costCeiling?: number\n /** Upper bound on what one cell can spend. A cell whose cost is a subtotal\n * is charged this bound against `costCeiling` instead of its known amount,\n * so hidden spend cannot walk the run past its budget. */\n maxCellCostUsd?: number\n /** Agent model. */\n agentModel?: string\n /** Driver model. */\n driverModel?: string\n /** Fallback driver models tried when the primary simulated-user model returns empty twice. */\n driverFallbackModels?: string[]\n /** Maximum output tokens for the first agent call in each assistant turn. */\n agentMaxTokens?: number\n /** Maximum output tokens for agent follow-up calls after tool results. */\n toolFollowupMaxTokens?: number\n /** Maximum output tokens for each simulated-user driver response. */\n driverMaxTokens?: number\n /** Maximum output tokens for each judge response. */\n judgeMaxTokens?: number\n /** Caller-owned execution for the agent leg of every cell (see\n * RunMultishotOptions.agentTransport). Judges are unaffected; each judge\n * carries its own transport in MultishotJudges. */\n agentTransport: MultishotTransport\n /** Caller-owned execution for the simulated-user driver leg of every cell. */\n driverTransport: MultishotTransport\n /** Caller-owned execution for the specialist leg the tool executors run in\n * every cell. Defaults to `agentTransport`. */\n toolTransport?: MultishotTransport\n /** Conversation engine for every cell. Defaults to `runMultishot`.\n *\n * The matrix owns everything around the shot — cell fan-out, concurrency,\n * the cost ceiling, the judge slots, the cell composite, the per-cell\n * artifact writers and the run summary — and forwards the whole cell input\n * to this function, so an alternative engine replaces ONLY the\n * conversation. Every option on this interface that `runMultishot` accepts\n * reaches the shot unchanged. `RunMultishotOptions.signal` has no\n * matrix-level counterpart and is not forwarded; a shot owns its own\n * cancellation.\n *\n * A shot that resolves with a value outside `MultishotResult` throws\n * `MultishotShotResultError` for that cell. The default engine is never\n * used as a fallback. */\n runShot?: MultishotShot<TPersona>\n}\n\n/** Per-cell output the multishot matrix records in `MatrixResult.cells`.\n * A consumer that supplies its own `runShot` reads the matrix through this\n * type instead of declaring a structural copy. */\nexport interface MultishotCellOutput {\n turns: number\n toolCalls: number\n artifactCount: number\n}\n\ninterface ArtifactJudgeRun {\n score: JudgeScore & { turn: number; type: string }\n cost: CostProvenance\n}\n\n/** Mean composite over non-failed scores. `0` when the list is empty (a\n * configured judge with nothing to score contributes 0, matching the cell\n * composite's long-standing semantics); `null` when scores exist but every\n * one failed — no signal, so the slot must be EXCLUDED from the cell mean\n * rather than dragging it to zero. */\nfunction meanCompositeExcludingFailed(scores: ReadonlyArray<JudgeScore>): number | null {\n if (scores.length === 0) return 0\n const live = scores.filter((s) => !s.failed)\n if (live.length === 0) return null\n return live.reduce((sum, s) => sum + s.composite, 0) / live.length\n}\n\nexport interface CellCompositeInput {\n conversation: JudgeScore\n /** Present iff the codeReview judge is configured. */\n codeReviews?: ReadonlyArray<JudgeScore>\n /** Present iff the contentQuality judge is configured. */\n contentReviews?: ReadonlyArray<JudgeScore>\n}\n\n/** Cell composite = mean over configured judge slots, excluding failed\n * scores: a failed conversation judge or an all-failed artifact slot carries\n * no signal and is dropped from the mean. `composite` is 0 only when EVERY\n * configured slot failed (`allJudgesFailed` distinguishes that from a real\n * zero). Pure — exported for deterministic testing. */\nexport function computeCellComposite(input: CellCompositeInput): {\n composite: number\n codeComposite: number\n contentComposite: number\n allJudgesFailed: boolean\n} {\n const contributions: number[] = []\n if (!input.conversation.failed) contributions.push(input.conversation.composite)\n\n const codeMean = input.codeReviews ? meanCompositeExcludingFailed(input.codeReviews) : undefined\n if (typeof codeMean === 'number') contributions.push(codeMean)\n const contentMean = input.contentReviews\n ? meanCompositeExcludingFailed(input.contentReviews)\n : undefined\n if (typeof contentMean === 'number') contributions.push(contentMean)\n\n return {\n composite:\n contributions.length === 0\n ? 0\n : contributions.reduce((s, v) => s + v, 0) / contributions.length,\n codeComposite: codeMean ?? 0,\n contentComposite: contentMean ?? 0,\n allJudgesFailed: contributions.length === 0,\n }\n}\n\nexport interface RunMultishotMatrixResult {\n matrix: MatrixResult<MultishotCellOutput>\n}\n\nexport async function runMultishotMatrix<TPersona extends MultishotPersona>(\n opts: RunMultishotMatrixOptions<TPersona>,\n): Promise<RunMultishotMatrixResult> {\n const codeTypes = new Set(opts.judges.codeArtifactTypes ?? ['code'])\n const contentTypes = new Set(opts.judges.contentArtifactTypes ?? ['research'])\n const runShot: MultishotShot<TPersona> = opts.runShot ?? runMultishot\n mkdirSync(opts.runDir, { recursive: true })\n\n const matrix = await runAgentMatrix<MultishotCellOutput>({\n axes: [\n { name: 'profile', values: opts.profiles },\n { name: 'persona', values: opts.personas.map((p) => ({ id: p.id, value: p })) },\n ],\n reps: opts.reps ?? 1,\n maxConcurrency: opts.maxConcurrency ?? 2,\n costCeiling: opts.costCeiling,\n maxCellCostUsd: opts.maxCellCostUsd,\n async runCell(cell) {\n const cellStartedAt = Date.now()\n const profile = cell.axes.profile?.value as AgentProfile\n const persona = cell.axes.persona?.value as TPersona\n const profileId = String(cell.axes.profile?.id ?? 'unknown')\n const personaId = String(cell.axes.persona?.id ?? 'unknown')\n\n // A shot that throws declares its own spend (see `runMultishot`). Rethrow\n // it untouched: a shot that declared nothing spent an unknown amount, and\n // claiming a number here would report a fabricated total.\n const sim = await runShot({\n profile,\n persona,\n shape: opts.shape,\n tools: opts.tools,\n toolExecutors: opts.toolExecutors,\n artifactTypeFor: opts.artifactTypeFor,\n maxTurns: opts.maxTurns,\n maxToolDispatches: opts.maxToolDispatches,\n agentModel: opts.agentModel,\n driverModel: opts.driverModel,\n driverFallbackModels: opts.driverFallbackModels,\n agentMaxTokens: opts.agentMaxTokens,\n toolFollowupMaxTokens: opts.toolFollowupMaxTokens,\n driverMaxTokens: opts.driverMaxTokens,\n agentTransport: opts.agentTransport,\n driverTransport: opts.driverTransport,\n toolTransport: opts.toolTransport,\n })\n // Everything from here on runs with the shot's spend already committed.\n // A throw past this line must carry it, or the money leaves the matrix's\n // cumulative sum and the cost ceiling under-counts the run.\n const shotCostUsd = shotCostSubtotal(sim)\n // A shot that says nothing about provenance is taken at its word, which\n // is how every engine written before the field behaved.\n const shotCostComplete = sim?.costProvenance?.kind !== 'uncaptured'\n let judgeCostUsd = 0\n let judgeCostComplete = false\n // Where the cell is, so a throw declares the right completeness: before\n // the judges only the shot has spent, while they are in flight their\n // spend is unknown, and after they settle their receipts decide.\n let phase: 'validate' | 'judging' | 'scoring' = 'validate'\n try {\n assertMultishotShotResult(sim)\n\n const codeArtifacts = sim.artifacts.filter((a) => codeTypes.has(a.type))\n const contentArtifacts = sim.artifacts.filter((a) => contentTypes.has(a.type))\n\n phase = 'judging'\n const [conversationRun, codeReviewRuns, contentReviewRuns] = await Promise.all([\n runJudge(withJudgeMaxTokens(opts.judges.conversation, opts.judgeMaxTokens), {\n transcript: sim.transcript,\n persona,\n }),\n opts.judges.codeReview\n ? Promise.all(\n codeArtifacts.map((artifact) =>\n runJudge(withJudgeMaxTokens(opts.judges.codeReview!, opts.judgeMaxTokens), {\n artifact,\n persona,\n }).then((result) => ({\n score: {\n ...result.score,\n turn: artifact.turn,\n type: artifact.type,\n },\n cost: result.cost,\n })),\n ),\n )\n : Promise.resolve([] as ArtifactJudgeRun[]),\n opts.judges.contentQuality\n ? Promise.all(\n contentArtifacts.map((artifact) =>\n runJudge(withJudgeMaxTokens(opts.judges.contentQuality!, opts.judgeMaxTokens), {\n artifact,\n persona,\n }).then((result) => ({\n score: {\n ...result.score,\n turn: artifact.turn,\n type: artifact.type,\n },\n cost: result.cost,\n })),\n ),\n )\n : Promise.resolve([] as ArtifactJudgeRun[]),\n ])\n const judgeRuns = [conversationRun, ...codeReviewRuns, ...contentReviewRuns]\n judgeCostUsd = judgeRuns.reduce((sum, run) => sum + (run.cost.usd ?? 0), 0)\n judgeCostComplete = judgeRuns.every((run) => run.cost.kind !== 'uncaptured')\n phase = 'scoring'\n\n const conversation = conversationRun.score\n const codeReviews = codeReviewRuns.map((run) => run.score)\n const contentReviews = contentReviewRuns.map((run) => run.score)\n\n const { composite, codeComposite, contentComposite, allJudgesFailed } =\n computeCellComposite({\n conversation,\n codeReviews: opts.judges.codeReview ? codeReviews : undefined,\n contentReviews: opts.judges.contentQuality ? contentReviews : undefined,\n })\n\n const cellScore: CellCompositeScore = { composite, conversation }\n if (opts.judges.codeReview)\n cellScore.codeReview = { perArtifact: codeReviews, composite: codeComposite }\n if (opts.judges.contentQuality)\n cellScore.contentQuality = { perArtifact: contentReviews, composite: contentComposite }\n\n const cellDir = join(opts.runDir, profileId, personaId, `rep-${cell.rep}`)\n mkdirSync(cellDir, { recursive: true })\n writeFileSync(join(cellDir, 'transcript.json'), JSON.stringify(sim.transcript, null, 2))\n writeFileSync(join(cellDir, 'artifacts.json'), JSON.stringify(sim.artifacts, null, 2))\n writeFileSync(join(cellDir, 'scores.json'), JSON.stringify(cellScore, null, 2))\n\n const notes = [`convo=${conversation.composite.toFixed(1)}`]\n if (opts.judges.codeReview) notes.push(`code=${codeComposite.toFixed(1)}`)\n if (opts.judges.contentQuality) notes.push(`content=${contentComposite.toFixed(1)}`)\n if (allJudgesFailed) notes.push('all-judges-failed')\n if (!judgeCostComplete) notes.push('judge-cost-incomplete')\n\n return {\n output: {\n turns: sim.transcript.length,\n toolCalls: sim.toolCalls,\n artifactCount: sim.artifacts.length,\n },\n verdict: { valid: composite >= 5, score: composite, notes: notes.join(' ') },\n costUsd: sim.costUsd + judgeCostUsd,\n // Either leg can leave the cell total a subtotal: a judge whose cost\n // the router never reported, or a shot that declared its own spend\n // uncaptured. The matrix counts the known part toward the ceiling and\n // reports the cell as under-counted rather than presenting the sum as\n // complete.\n costProvenance:\n judgeCostComplete && shotCostComplete\n ? { kind: 'estimated', usd: sim.costUsd + judgeCostUsd }\n : { kind: 'uncaptured', usd: null },\n durationMs: sim.durationMs,\n }\n } catch (err) {\n // No usable shot subtotal means the cell's spend is genuinely unknown;\n // rethrow untouched so the matrix records it as uncaptured instead of\n // billing a number this frame cannot support.\n if (shotCostUsd === undefined) throw err\n throw withCellSpend(err, {\n costUsd: shotCostUsd + judgeCostUsd,\n durationMs: Date.now() - cellStartedAt,\n // The judges bill before they settle, so a throw among them leaves a\n // subtotal. Before they start, and after they settle with every\n // receipt captured, the amount is the cell's whole spend — unless the\n // shot already declared its own part incomplete.\n kind:\n shotCostComplete && (phase === 'validate' || (phase === 'scoring' && judgeCostComplete))\n ? 'estimated'\n : 'uncaptured',\n })\n }\n },\n })\n\n // Persist top-level summary.\n const summary = {\n cells: matrix.summary.totalCells,\n passRate: matrix.summary.overallPassRate,\n meanScore: matrix.summary.overallMeanScore,\n totalCostUsd: matrix.summary.totalCostUsd,\n costUncapturedCells: matrix.summary.costUncapturedCells,\n ceilingChargedUsd: matrix.summary.ceilingChargedUsd,\n durationMs: matrix.summary.durationMs,\n runsExecuted: matrix.summary.runsExecuted,\n cellsSkipped: matrix.summary.cellsSkipped,\n byProfile: matrix.byAxis.profile,\n byPersona: matrix.byAxis.persona,\n }\n writeFileSync(join(opts.runDir, 'summary.json'), JSON.stringify(summary, null, 2))\n\n // A reader of the on-disk summary must not take the cost line as the run's\n // whole spend when some cells reported only a subtotal.\n const uncaptured = matrix.summary.costUncapturedCells\n const costLabel = uncaptured > 0 ? 'Cost (at least)' : 'Cost'\n\n const md: string[] = [\n `# Multishot matrix`,\n ``,\n `**Cells**: ${matrix.summary.totalCells} | **Pass rate**: ${(matrix.summary.overallPassRate * 100).toFixed(0)}% | **Mean**: ${matrix.summary.overallMeanScore.toFixed(2)} | **${costLabel}**: $${matrix.summary.totalCostUsd.toFixed(2)} | **Duration**: ${(matrix.summary.durationMs / 1000).toFixed(0)}s`,\n ``,\n ...(uncaptured > 0\n ? [\n `> ${uncaptured} of ${matrix.summary.runsExecuted} cells reported a cost subtotal, not a total. Real spend is higher than every cost figure below.`,\n ``,\n ]\n : []),\n `## By profile`,\n ``,\n '| profile | pass | mean | cost |',\n '|---|---|---|---|',\n ...Object.entries(matrix.byAxis.profile ?? {}).map(\n ([id, s]) =>\n `| ${id} | ${(s.passRate * 100).toFixed(0)}% | ${s.meanScore.toFixed(2)} | $${s.totalCostUsd.toFixed(2)} |`,\n ),\n ``,\n `## By persona`,\n ``,\n '| persona | pass | mean | cost |',\n '|---|---|---|---|',\n ...Object.entries(matrix.byAxis.persona ?? {}).map(\n ([id, s]) =>\n `| ${id} | ${(s.passRate * 100).toFixed(0)}% | ${s.meanScore.toFixed(2)} | $${s.totalCostUsd.toFixed(2)} |`,\n ),\n ``,\n ]\n writeFileSync(join(opts.runDir, 'summary.md'), md.join('\\n'))\n\n return { matrix }\n}\n\n/** The shot's own spend, when the value it resolved with reports a usable\n * amount. `undefined` when it does not — a malformed shot result is exactly\n * the case where the number cannot be trusted, and billing a wrong figure is\n * worse than recording the cell as uncaptured. */\nfunction shotCostSubtotal(\n sim: { costUsd?: unknown; costProvenance?: CostProvenance } | null | undefined,\n): number | undefined {\n const value = sim?.costUsd\n return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined\n}\n\nfunction withJudgeMaxTokens<TInput>(\n judge: MultishotJudgeConfig<TInput>,\n maxTokens: number | undefined,\n): MultishotJudgeConfig<TInput> {\n if (maxTokens === undefined || judge.maxTokens !== undefined) return judge\n return { ...judge, maxTokens }\n}\n"],"mappings":";;;;;;;;;;;;;;AASA,SAAgB,sBACd,OACA,OACQ;CACR,IAAI,CAAC,OAAO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
"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.1.0. Bumps on breaking changes to request/response schemas.",
|
|
7
7
|
"contact": {
|
|
8
8
|
"name": "Tangle Network",
|
package/dist/{paired-promotion-decision-DJU3fZxH.d.ts → paired-promotion-decision-DawN2o0G.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as PairedBootstrapResult } from "./index-
|
|
1
|
+
import { E as PairedBootstrapResult } from "./index-DHWFYUVW.js";
|
|
2
2
|
/** Which paired estimator produced the deciding interval. */
|
|
3
3
|
type PairedDecisionStatistic = 'paired_risk_difference' | 'mean_bootstrap' | 'median_bootstrap';
|
|
4
4
|
/** Which test carried the decision, given the estimator and the sample size. */
|
|
@@ -120,4 +120,4 @@ interface PairedDecisionShape {
|
|
|
120
120
|
*/
|
|
121
121
|
declare function decidePairedPromotion(before: number[], after: number[], options?: PairedPromotionDecisionOptions): PairedPromotionDecision;
|
|
122
122
|
export { PairedPromotionDecision as a, PairedMcNemarEvidence as i, PairedDecisionShape as n, PairedPromotionDecisionOptions as o, PairedDecisionStatistic as r, decidePairedPromotion as s, PairedDecisionMethod as t };
|
|
123
|
-
//# sourceMappingURL=paired-promotion-decision-
|
|
123
|
+
//# sourceMappingURL=paired-promotion-decision-DawN2o0G.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paired-promotion-decision-
|
|
1
|
+
{"version":3,"file":"paired-promotion-decision-DawN2o0G.d.ts","names":[],"sources":["../src/paired-promotion-decision.ts"],"mappings":";;KA2DY;;KAMA;;UAGK;;EAEf;;EAEA;;EAEA;;EAEA;;UAGe;;;EAGf;;EAEA;;EAEA;;EAEA;;;;EAIA;;;;;;;;EAQA;;;;;EAKA;;;;;;;;;;;;EAYA;;UAGe;;EAEf;;EAEA;EACA;EACA,WAAW;EACX,QAAQ;;;;;EAKR;;EAEA;;EAEA;;EAEA;;EAEA;;;;EAIA,WAAW;;EAEX,SAAS;;;EAGT;;EAEA;;EAEA;;;EAGA;;EAEA;;EAEA;;;EAGA;;EAEA;;EAEA;;EAEA;;;UAIe;EACf,WAAW;;EAEX;;EAEA;;;;;;;iBA2Dc,sBACd,kBACA,iBACA,UAAS,iCACR"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as CustomTokenPricing } from "./cost-ledger-Czro9wmo.js";
|
|
2
|
-
import { p as AnalystUsageReceipt } from "./types-
|
|
2
|
+
import { p as AnalystUsageReceipt } from "./types-DbGSC2No.js";
|
|
3
3
|
import { t as PrimeBridgeTransport } from "./prime-bridge-transport-Cfqir_Im.js";
|
|
4
4
|
/**
|
|
5
5
|
* The reply grammar an analyst arm holds a model to, independent of transport.
|
|
@@ -306,4 +306,4 @@ interface PrimeProtocolIdentity {
|
|
|
306
306
|
*/
|
|
307
307
|
declare function primeProtocolSha256(identity: PrimeProtocolIdentity): string;
|
|
308
308
|
export { runPrimeExchange as C, ReplyRowDecoded as D, ReplyEnvelope as E, ReplyRowRejection as O, projectPrimeTrajectory as S, ReplyContract as T, buildPrimePrompt as _, PrimeProjectionOutcome as a, normalizePrimeUsage as b, PrimeProtocolIdentity as c, PrimeRepairPromptSpec as d, PrimeRepairState as f, analystUsageReceiptFromPrimeUsage as g, PrimeTurnRecord as h, PrimeProjectionDelivery as i, PrimeRawUsage as l, PrimeRowDecoded as m, PrimeExchangeOutcome as n, PrimeProjectionSource as o, PrimeReplyContract as p, PrimeFailure as r, PrimePromptSpec as s, PrimeExchangeOptions as t, PrimeRejectedRow as u, buildPrimeRepairPrompt as v, DecodedReply as w, primeProtocolSha256 as x, mergePrimeRawUsage as y };
|
|
309
|
-
//# sourceMappingURL=prime-protocol-
|
|
309
|
+
//# sourceMappingURL=prime-protocol-RUPtoYiI.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prime-protocol-
|
|
1
|
+
{"version":3,"file":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7B,QAAQ,qBAAqB;;;;;;UAyLf,sBAAsB;;EAErC,QAAQ,iBAAiB;;EAEzB,UAAU,iBAAiB;;EAE3B;;UAGe;EACf;EACA;EACA;;KAGU,uBAAuB;EAE7B;EACA,gBAAgB;EAChB;EACA,UAAU;;EAEV;EAAW;EAAgB;;;;;;;;;iBASX,uBAAuB,OAC3C,QAAQ,sBAAsB,QAC9B;EAAU;IACT,QAAQ,uBAAuB;UA8BjB;EACf;EACA;EACA;EACA;;EAEA,QAAQ,SAAS;;;;;;;;;;;;iBAaH,oBAAoB,UAAU"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { o as FailureClass } from "./schema-CkIvnmLU.js";
|
|
2
2
|
import { a as RunRecord, c as RunSplitTag } from "./run-record-pBlhZizT.js";
|
|
3
3
|
import { i as DatasetSplit, n as DatasetManifest, r as DatasetScenario } from "./dataset-DThC1S6G.js";
|
|
4
|
-
import { S as HeldOutGateDecision } from "./summary-report-
|
|
4
|
+
import { S as HeldOutGateDecision } from "./summary-report-9kwI6jFQ.js";
|
|
5
5
|
/** Severity of an actionable finding attached to a run/trace. */
|
|
6
6
|
type AsiSeverity = 'info' | 'warning' | 'error' | 'critical';
|
|
7
7
|
/** Actionable side-info — a diagnosed finding the loop can act on. */
|
|
@@ -227,4 +227,4 @@ declare function judgeReplayGate<TOutput>(args: JudgeReplayGateArgs<TOutput>): P
|
|
|
227
227
|
candidateSamples: number;
|
|
228
228
|
}>;
|
|
229
229
|
export { evaluateReleaseConfidence as _, bootstrapCi as a, ReleaseConfidenceAxis as c, ReleaseConfidenceIssue as d, ReleaseConfidenceMetrics as f, ReleaseTraceEvidence as g, ReleaseConfidenceThresholds as h, Verdict as i, ReleaseConfidenceAxisName as l, ReleaseConfidenceStatus as m, BootstrapResult as n, judgeReplayGate as o, ReleaseConfidenceScorecard as p, JudgeReplayGateArgs as r, ActionableSideInfo as s, BootstrapOptions as t, ReleaseConfidenceInput as u };
|
|
230
|
-
//# sourceMappingURL=promotion-gate-
|
|
230
|
+
//# sourceMappingURL=promotion-gate-DG_PSJx_.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promotion-gate-
|
|
1
|
+
{"version":3,"file":"promotion-gate-DG_PSJx_.d.ts","names":[],"sources":["../src/release-confidence.ts","../src/promotion-gate.ts"],"mappings":";;;;;KAuBK;;UAGY;;EAEf;;EAEA;EACA,WAAW;;EAEX;;EAEA;;EAEA;;EAEA;EACA,WAAW;;KAGD;KACA;UAQK;EACf;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;;EAEA,eAAe;EACf,MAAM;EACN,WAAW;;UAGI;;EAEf;EACA;EACA;EACA;;EAEA;EACA;EACA;;EAEA;EACA;EACA;;EAEA;;EAEA;;UAGe;EACf;EACA;EACA;EACA,UAAU;EACV,qBAAqB;EACrB,gBAAgB;EAChB,kBAAkB;EAClB,eAAe;EACf,aAAa;;UAGE;EACf,MAAM;EACN,QAAQ;EACR;EACA;;UAGe;EACf,MAAM;EACN;EACA;EACA;;UAGe;EACf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa,OAAO;EACpB,cAAc;EACd,oBAAoB,QAAQ,OAAO;EACnC,0BAA0B;;;;;;;EAO1B;;UAGe;EACf;EACA;EACA;EACA,QAAQ;EACR;EACA,MAAM;EACN,QAAQ;EACR,SAAS;EACT,SAAS;EACT,cAAc;EACd;;iBAkBc,0BACd,OAAO,yBACN;;;;;;;;;;;;;;;;;;;;;;;;;KC3JS;UAEK;EACf;EACA;;EAEA;;EAEA;;EAEA;;EAEA;EACA;EACA,SAAS;;UAGM;;EAEf;;EAEA;;;;;;EAMA;;;EAGA;;;;;;;;;iBAUc,YACd,oBACA,qBACA,UAAS,mBACR;;;;;;;;;;;;;;;;UA0Gc,oBAAoB;EACnC,iBAAiB;EACjB,kBAAkB;;EAElB,QAAQ,QAAQ,YAAY;EAC5B;EACA;;EAEA;;EAEA;;;;;iBAMoB,gBAAgB,SACpC,MAAM,oBAAoB,WACzB,QAAQ;EAAoB;EAAyB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as ProposalFindingSchema } from "./external-optimizer-subprocess-
|
|
1
|
+
import { S as ProposalFindingSchema } from "./external-optimizer-subprocess-GO6s84Ov.js";
|
|
2
2
|
// src/analyst/proposal-findings.ts
|
|
3
3
|
/** True when a finding names a source candidate generation may learn from. */
|
|
4
4
|
function isProposalFinding(finding) {
|
|
@@ -22,4 +22,4 @@ function findingLabel(finding, index) {
|
|
|
22
22
|
}
|
|
23
23
|
export { assertProposalFindings as t };
|
|
24
24
|
|
|
25
|
-
//# sourceMappingURL=proposal-findings-
|
|
25
|
+
//# sourceMappingURL=proposal-findings-CS6LoGGp.js.map
|