@tangle-network/agent-eval 0.145.22 → 0.146.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { o as runRolloutReleaseCli } from "./hf-dataset-XggBupCr.js";
3
- import { n as runAnalystBenchmarkCommand } from "./benchmark-command-CDB_yKqS.js";
3
+ import { n as runAnalystBenchmarkCommand } from "./benchmark-command-CxLJljS1.js";
4
4
  import { a as runRpcBatch, o as runRpcOnce, p as handleVersion, r as startServerAsync, s as buildOpenApi } from "./server-cQXve8i4.js";
5
5
  import { writeFileSync } from "node:fs";
6
6
  //#region src/cli-config.ts
@@ -0,0 +1,383 @@
1
+ import { p as CostProvenance } from "./cost-ledger-DbQdN3nO.js";
2
+ import { w as JudgeScore } from "./types-DABZgDGV.js";
3
+ import { o as MatrixResult } from "./index-D_P7Ye43.js";
4
+ import { AgentProfile } from "@tangle-network/agent-interface";
5
+ //#region src/multishot/judges.d.ts
6
+ declare const DEFAULT_JUDGE_MODEL = "openai/gpt-4o-mini";
7
+ interface JudgeDimension {
8
+ /** JSON field name + score key. */
9
+ key: string;
10
+ /** Description shown in the judge's user prompt. */
11
+ description: string;
12
+ }
13
+ interface JudgeConfig<TInput> {
14
+ /** Display name (for trace + log). */
15
+ name: string;
16
+ /** Model used for this judge. */
17
+ model?: string;
18
+ /** 0-10 scored dimensions. */
19
+ dimensions: JudgeDimension[];
20
+ /** Judge system prompt — sets persona + JSON-only constraint. */
21
+ systemPrompt: string;
22
+ /** Build the user prompt from the typed input. Must include "Respond with
23
+ * ONLY this JSON: { ... }" listing each dimension key. */
24
+ buildPrompt: (input: TInput) => string;
25
+ /** Optional model + api overrides. */
26
+ apiKey?: string;
27
+ baseUrl?: string;
28
+ /** Maximum output tokens for the judge response. Defaults to 1500. */
29
+ maxTokens?: number;
30
+ }
31
+ interface JudgeRunResult {
32
+ /** Semantic result; failed scores remain non-throwing so matrix aggregation can exclude them. */
33
+ score: JudgeScore;
34
+ /** Cost of the completed call, separate from diagnostic provider metadata. */
35
+ cost: CostProvenance;
36
+ }
37
+ declare function runJudge<TInput>(judge: JudgeConfig<TInput>, input: TInput): Promise<JudgeRunResult>;
38
+ /** Convenience: stringified dimension list for inclusion in a judge prompt.
39
+ * Returns lines like `- audience_fit: Does this match what the audience cares about? (0-10)`. */
40
+ declare function renderDimensions(dims: readonly JudgeDimension[]): string;
41
+ /** Convenience: build the "Respond with ONLY this JSON" footer for a judge prompt. */
42
+ declare function renderJsonFooter(dims: readonly JudgeDimension[]): string;
43
+ //#endregion
44
+ //#region src/multishot/types.d.ts
45
+ interface MultishotMessage {
46
+ role: 'user' | 'assistant' | 'tool';
47
+ content: string;
48
+ toolCallId?: string;
49
+ toolCalls?: Array<{
50
+ id: string;
51
+ name: string;
52
+ args: Record<string, unknown>;
53
+ }>;
54
+ }
55
+ interface MultishotArtifact {
56
+ type: string;
57
+ turn: number;
58
+ invocation: {
59
+ name: string;
60
+ args: Record<string, unknown>;
61
+ };
62
+ content: string;
63
+ }
64
+ interface MultishotResult {
65
+ transcript: MultishotMessage[];
66
+ artifacts: MultishotArtifact[];
67
+ toolCalls: number;
68
+ durationMs: number;
69
+ /** Known spend. A subtotal, not a total, when `costProvenance.kind` is
70
+ * `uncaptured`. */
71
+ costUsd: number;
72
+ /** Origin of `costUsd`. A shot that priced every call reports `estimated`
73
+ * or `observed`; a shot with a call the router priced at nothing reports
74
+ * `uncaptured`, and the matrix records the cell as under-counted instead of
75
+ * presenting the subtotal as a complete estimate.
76
+ *
77
+ * Optional so an engine written before this field keeps working; the matrix
78
+ * then judges the cell on judge receipts alone, as it did before. */
79
+ costProvenance?: CostProvenance;
80
+ }
81
+ interface MultishotToolDefinition {
82
+ type: 'function';
83
+ function: {
84
+ name: string;
85
+ description: string;
86
+ parameters: Record<string, unknown>;
87
+ };
88
+ }
89
+ /** One chat-completion request the multishot loop issues for a single agent
90
+ * (or driver) inference step. Mirrors the OpenAI-compat body the loop would
91
+ * otherwise POST to the Tangle router. */
92
+ interface MultishotTransportRequest {
93
+ model: string;
94
+ messages: Array<Record<string, unknown>>;
95
+ tools?: MultishotToolDefinition[];
96
+ temperature?: number;
97
+ maxTokens?: number;
98
+ signal?: AbortSignal;
99
+ }
100
+ interface MultishotTransportToolCall {
101
+ id: string;
102
+ type: 'function';
103
+ function: {
104
+ name: string;
105
+ arguments: string;
106
+ };
107
+ }
108
+ interface MultishotTransportResponse {
109
+ message: {
110
+ content?: string | null;
111
+ tool_calls?: MultishotTransportToolCall[];
112
+ };
113
+ usage?: {
114
+ prompt_tokens?: number;
115
+ completion_tokens?: number;
116
+ };
117
+ /** Actual spend for this call. When omitted, the loop meters cost from
118
+ * `usage` via the per-model router estimator (estimateRouterCost). */
119
+ costUsd?: number;
120
+ }
121
+ /** Execution seam for one leg of the multishot loop. When provided, it
122
+ * replaces the internal router HTTP call for that leg — the loop still owns
123
+ * turn scheduling, tool dispatch, transcript capture, and cost metering.
124
+ * agent-eval has no dependency on agent-runtime; adapt agent-runtime's
125
+ * resolveAgentBackend (or any sandbox/cli-bridge/router client) into this
126
+ * signature product-side. */
127
+ type MultishotTransport = (req: MultishotTransportRequest) => Promise<MultishotTransportResponse>;
128
+ type MultishotToolExecutor = (args: Record<string, unknown>, ctx: {
129
+ apiKey: string;
130
+ baseUrl: string;
131
+ signal?: AbortSignal;
132
+ }) => Promise<{
133
+ content: string;
134
+ costUsd: number;
135
+ }>;
136
+ interface MultishotPersona {
137
+ /** Stable identifier — used for per-cell artifact paths + matrix axis keys. */
138
+ id: string;
139
+ /** Per-domain payload (income/profile/voice/etc.) shaped by the consumer. */
140
+ [k: string]: unknown;
141
+ }
142
+ /**
143
+ * Persona-shaping callbacks. Both are OPTIONAL: when omitted, the loop derives
144
+ * them from the `AgentProfile` + persona payload (see `defaultShapeFromProfile`)
145
+ * so a pure-profile call — `runMultishot({ profile, persona })` — works with no
146
+ * role-builder functions. Provide callbacks only to override the derived shape.
147
+ */
148
+ interface MultishotShape<TPersona extends MultishotPersona> {
149
+ /** Opening user message (turn 0) — the persona's first ask. */
150
+ buildOpener?: (persona: TPersona) => string;
151
+ /** System prompt the driver LLM uses to roleplay the persona. Should set
152
+ * voice, goals, constraints, time-pressure, and the "never go silent" rule. */
153
+ buildDriverSystemPrompt?: (persona: TPersona) => string;
154
+ }
155
+ declare class MultishotDriverEmptyError extends Error {
156
+ readonly turn: number;
157
+ constructor(turn: number);
158
+ }
159
+ declare class MultishotFatalToolError extends Error {
160
+ constructor(message: string);
161
+ }
162
+ declare class MultishotShotResultError extends Error {
163
+ constructor(reason: string);
164
+ }
165
+ /** Contract guard for the value a caller-supplied shot resolves with. The
166
+ * matrix writes per-cell artifacts, builds judge inputs, and meters cost from
167
+ * this value, so a malformed result must stop the cell instead of scoring a
168
+ * degraded one. Two silent degradations this closes: an artifact with no
169
+ * `type` matches neither the code nor the content artifact set, so the cell
170
+ * scores as though the artifact was never produced; a non-finite `costUsd`
171
+ * reaches `summary.totalCostUsd` and makes every cost number NaN.
172
+ *
173
+ * A rejected cell is still billed: the matrix cell reads the shot's own
174
+ * `costUsd` when it is a usable amount and declares that spend on the throw,
175
+ * so money the shot spent before returning a malformed result stays in the
176
+ * cumulative sum the cost ceiling reads. A result whose `costUsd` is itself
177
+ * malformed carries no usable amount, and the cell records as `uncaptured`.
178
+ *
179
+ * Every required field of `MultishotMessage` and `MultishotArtifact` is
180
+ * checked, including `toolCalls` elements and `invocation.args`. Optional
181
+ * fields are checked only when present. */
182
+ declare function assertMultishotShotResult(value: unknown): asserts value is MultishotResult;
183
+ //#endregion
184
+ //#region src/multishot/multishot.d.ts
185
+ interface RunMultishotOptions<TPersona extends MultishotPersona> {
186
+ profile: AgentProfile;
187
+ persona: TPersona;
188
+ /** Persona-shaping callbacks. Optional — omitted callbacks are derived from
189
+ * the profile + persona payload, so a pure-profile call works. */
190
+ shape?: MultishotShape<TPersona>;
191
+ /** Tool definitions advertised to the agent. Defaults to delegate_research + delegate_code. */
192
+ tools?: MultishotToolDefinition[];
193
+ /** Map from tool name → executor invoked inline when the agent emits a tool_call. */
194
+ toolExecutors?: Record<string, MultishotToolExecutor>;
195
+ /** Map from tool name → artifact type label written into MultishotArtifact.type.
196
+ * Tools without a mapping still execute, but their results aren't surfaced as
197
+ * typed artifacts (only as tool messages in the transcript). */
198
+ artifactTypeFor?: (toolName: string) => string | undefined;
199
+ maxTurns?: number;
200
+ agentModel?: string;
201
+ driverModel?: string;
202
+ /** Fallback driver models tried when the primary simulated-user model returns empty twice. */
203
+ driverFallbackModels?: string[];
204
+ /** Maximum output tokens for the first agent call in each assistant turn. */
205
+ agentMaxTokens?: number;
206
+ /** Maximum output tokens for agent follow-up calls after tool results. */
207
+ toolFollowupMaxTokens?: number;
208
+ /** Maximum output tokens for each simulated-user driver response. */
209
+ driverMaxTokens?: number;
210
+ /** Maximum tool calls the agent may dispatch inside one assistant turn. */
211
+ maxToolDispatches?: number;
212
+ /** Execution seam for the agent leg. When provided, every agent inference
213
+ * step goes through this function instead of the router HTTP call; the
214
+ * string levers (agentModel, apiKey, baseUrl) stop applying to that leg.
215
+ * apiKey/baseUrl are still resolved for tool executors and any leg
216
+ * without an injected transport. */
217
+ agentTransport?: MultishotTransport;
218
+ /** Execution seam for the simulated-user driver leg (symmetric to
219
+ * agentTransport). Driver model fallback rotation still applies — the
220
+ * transport receives each candidate model in turn. */
221
+ driverTransport?: MultishotTransport;
222
+ apiKey?: string;
223
+ baseUrl?: string;
224
+ signal?: AbortSignal;
225
+ }
226
+ /** One multishot shot — the conversation engine `runMultishotMatrix` invokes
227
+ * once per cell. `runMultishot` is the default implementation.
228
+ *
229
+ * An alternative engine (a graph-backed conversation, a replay of a recorded
230
+ * transcript, a sandbox-hosted agent) implements this exact signature and
231
+ * reaches the matrix through `RunMultishotMatrixOptions.runShot`. The matrix
232
+ * keeps every other cell mechanic — cell fan-out, concurrency, the cost
233
+ * ceiling, the judge slots, the cell composite, and the per-cell writers — so
234
+ * swapping the engine needs no copy of the cell body. */
235
+ type MultishotShot<TPersona extends MultishotPersona> = (opts: RunMultishotOptions<TPersona>) => Promise<MultishotResult>;
236
+ declare function runMultishot<TPersona extends MultishotPersona>(opts: RunMultishotOptions<TPersona>): Promise<MultishotResult>;
237
+ //#endregion
238
+ //#region src/multishot/matrix.d.ts
239
+ interface ConversationJudgeInput<TPersona extends MultishotPersona> {
240
+ transcript: MultishotMessage[];
241
+ persona: TPersona;
242
+ }
243
+ interface ArtifactJudgeInput<TPersona extends MultishotPersona> {
244
+ artifact: MultishotArtifact;
245
+ persona: TPersona;
246
+ }
247
+ interface MultishotJudges<TPersona extends MultishotPersona> {
248
+ /** Scores the full transcript end-to-end (always runs). */
249
+ conversation: JudgeConfig<ConversationJudgeInput<TPersona>>;
250
+ /** Scores each code-type artifact. Optional — omit when domain has no code artifacts. */
251
+ codeReview?: JudgeConfig<ArtifactJudgeInput<TPersona>>;
252
+ /** Scores each non-code (research/content/template) artifact. Optional. */
253
+ contentQuality?: JudgeConfig<ArtifactJudgeInput<TPersona>>;
254
+ /** Which artifact types route to codeReview. Defaults to ['code']. */
255
+ codeArtifactTypes?: string[];
256
+ /** Which artifact types route to contentQuality. Defaults to ['research']. */
257
+ contentArtifactTypes?: string[];
258
+ }
259
+ interface CellCompositeScore {
260
+ composite: number;
261
+ conversation: JudgeScore;
262
+ codeReview?: {
263
+ perArtifact: Array<JudgeScore & {
264
+ turn: number;
265
+ type: string;
266
+ }>;
267
+ composite: number;
268
+ };
269
+ contentQuality?: {
270
+ perArtifact: Array<JudgeScore & {
271
+ turn: number;
272
+ type: string;
273
+ }>;
274
+ composite: number;
275
+ };
276
+ }
277
+ interface RunMultishotMatrixOptions<TPersona extends MultishotPersona> {
278
+ /** AgentProfile axis (matrix primary). */
279
+ profiles: Array<{
280
+ id: string;
281
+ value: AgentProfile;
282
+ }>;
283
+ /** Persona axis. */
284
+ personas: TPersona[];
285
+ /** Persona-shaping callbacks. Optional — omitted callbacks are derived per
286
+ * cell from that cell's profile + persona payload (pure-profile path). */
287
+ shape?: MultishotShape<TPersona>;
288
+ /** Judge configurations. */
289
+ judges: MultishotJudges<TPersona>;
290
+ /** Tool definitions advertised to the agent. Defaults to delegate_research + delegate_code. */
291
+ tools?: MultishotToolDefinition[];
292
+ /** Map from tool name → inline executor. Must align with `tools`. */
293
+ toolExecutors?: Record<string, MultishotToolExecutor>;
294
+ /** Tool name → artifact type label. Defaults to research/code mapping. */
295
+ artifactTypeFor?: (toolName: string) => string | undefined;
296
+ /** Where per-cell artifacts land. Cells write to `<runDir>/<profileId>/<personaId>/rep-N/`. */
297
+ runDir: string;
298
+ /** Replicates per (profile, persona) cell. */
299
+ reps?: number;
300
+ /** Max conversation turns per cell. */
301
+ maxTurns?: number;
302
+ /** Maximum tool calls the agent may dispatch inside one assistant turn. */
303
+ maxToolDispatches?: number;
304
+ /** Max concurrent cells. */
305
+ maxConcurrency?: number;
306
+ /** Total $ ceiling across the matrix; cells aborted past this. */
307
+ costCeiling?: number;
308
+ /** Upper bound on what one cell can spend. A cell whose cost is a subtotal
309
+ * is charged this bound against `costCeiling` instead of its known amount,
310
+ * so hidden spend cannot walk the run past its budget. */
311
+ maxCellCostUsd?: number;
312
+ /** Agent model. */
313
+ agentModel?: string;
314
+ /** Driver model. */
315
+ driverModel?: string;
316
+ /** Fallback driver models tried when the primary simulated-user model returns empty twice. */
317
+ driverFallbackModels?: string[];
318
+ /** Maximum output tokens for the first agent call in each assistant turn. */
319
+ agentMaxTokens?: number;
320
+ /** Maximum output tokens for agent follow-up calls after tool results. */
321
+ toolFollowupMaxTokens?: number;
322
+ /** Maximum output tokens for each simulated-user driver response. */
323
+ driverMaxTokens?: number;
324
+ /** Maximum output tokens for each judge response. */
325
+ judgeMaxTokens?: number;
326
+ /** Execution seam for the agent leg of every cell — replaces the router
327
+ * HTTP call when provided (see RunMultishotOptions.agentTransport).
328
+ * Judges are unaffected; configure those via MultishotJudges. */
329
+ agentTransport?: MultishotTransport;
330
+ /** Execution seam for the simulated-user driver leg of every cell. */
331
+ driverTransport?: MultishotTransport;
332
+ /** Conversation engine for every cell. Defaults to `runMultishot`.
333
+ *
334
+ * The matrix owns everything around the shot — cell fan-out, concurrency,
335
+ * the cost ceiling, the judge slots, the cell composite, the per-cell
336
+ * artifact writers and the run summary — and forwards the whole cell input
337
+ * to this function, so an alternative engine replaces ONLY the
338
+ * conversation. Every option on this interface that `runMultishot` accepts
339
+ * reaches the shot unchanged. `RunMultishotOptions.signal` has no
340
+ * matrix-level counterpart and is not forwarded; a shot owns its own
341
+ * cancellation.
342
+ *
343
+ * A shot that resolves with a value outside `MultishotResult` throws
344
+ * `MultishotShotResultError` for that cell. The default engine is never
345
+ * used as a fallback. */
346
+ runShot?: MultishotShot<TPersona>;
347
+ /** Pass-thru fields. */
348
+ apiKey?: string;
349
+ baseUrl?: string;
350
+ }
351
+ /** Per-cell output the multishot matrix records in `MatrixResult.cells`.
352
+ * A consumer that supplies its own `runShot` reads the matrix through this
353
+ * type instead of declaring a structural copy. */
354
+ interface MultishotCellOutput {
355
+ turns: number;
356
+ toolCalls: number;
357
+ artifactCount: number;
358
+ }
359
+ interface CellCompositeInput {
360
+ conversation: JudgeScore;
361
+ /** Present iff the codeReview judge is configured. */
362
+ codeReviews?: ReadonlyArray<JudgeScore>;
363
+ /** Present iff the contentQuality judge is configured. */
364
+ contentReviews?: ReadonlyArray<JudgeScore>;
365
+ }
366
+ /** Cell composite = mean over configured judge slots, excluding failed
367
+ * scores: a failed conversation judge or an all-failed artifact slot carries
368
+ * no signal and is dropped from the mean. `composite` is 0 only when EVERY
369
+ * configured slot failed (`allJudgesFailed` distinguishes that from a real
370
+ * zero). Pure — exported for deterministic testing. */
371
+ declare function computeCellComposite(input: CellCompositeInput): {
372
+ composite: number;
373
+ codeComposite: number;
374
+ contentComposite: number;
375
+ allJudgesFailed: boolean;
376
+ };
377
+ interface RunMultishotMatrixResult {
378
+ matrix: MatrixResult<MultishotCellOutput>;
379
+ }
380
+ declare function runMultishotMatrix<TPersona extends MultishotPersona>(opts: RunMultishotMatrixOptions<TPersona>): Promise<RunMultishotMatrixResult>;
381
+ //#endregion
382
+ export { JudgeConfig as A, MultishotToolExecutor as C, MultishotTransportToolCall as D, MultishotTransportResponse as E, runJudge as F, JudgeRunResult as M, renderDimensions as N, assertMultishotShotResult as O, renderJsonFooter as P, MultishotToolDefinition as S, MultishotTransportRequest as T, MultishotMessage as _, MultishotCellOutput as a, MultishotShape as b, RunMultishotMatrixResult as c, MultishotShot as d, RunMultishotOptions as f, MultishotFatalToolError as g, MultishotDriverEmptyError as h, ConversationJudgeInput as i, JudgeDimension as j, DEFAULT_JUDGE_MODEL as k, computeCellComposite as l, MultishotArtifact as m, CellCompositeInput as n, MultishotJudges as o, runMultishot as p, CellCompositeScore as r, RunMultishotMatrixOptions as s, ArtifactJudgeInput as t, runMultishotMatrix as u, MultishotPersona as v, MultishotTransport as w, MultishotShotResultError as x, MultishotResult as y };
383
+ //# sourceMappingURL=matrix-su7mIfbB.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrix-su7mIfbB.d.ts","names":[],"sources":["../src/multishot/judges.ts","../src/multishot/types.ts","../src/multishot/multishot.ts","../src/multishot/matrix.ts"],"mappings":";;;;;cAyBa;UAEI;;EAEf;;EAEA;;UAGe,YAAY;;EAE3B;;EAEA;;EAEA,YAAY;;EAEZ;;;EAGA,cAAc,OAAO;;EAErB;EACA;;EAEA;;UAGe;;EAEf,OAAO;;EAEP,MAAM;;iBAGc,SAAS,QAC7B,OAAO,YAAY,SACnB,OAAO,SACN,QAAQ;;;iBAkIK,iBAAiB,eAAe;;iBAKhC,iBAAiB,eAAe;;;UClM/B;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;;;;;;;;KASU,sBACV,KAAK,8BACF,QAAQ;KAED,yBACV,MAAM,yBACN;EAAO;EAAgB;EAAiB,SAAS;MAC9C;EAAU;EAAiB;;UAEf;;EAEf;;GAEC;;;;;;;;UASc,eAAe,iBAAiB;;EAE/C,eAAe,SAAS;;;EAGxB,2BAA2B,SAAS;;cAGzB,kCAAkC;WACjB;EAA5B,YAA4B;;cAMjB,gCAAgC;EAC3C,YAAY;;cAMD,iCAAiC;EAC5C,YAAY;;;;;;;;;;;;;;;;;;;iBAyBE,0BAA0B,yBAAyB,SAAS;;;UCpH3D,oBAAoB,iBAAiB;EACpD,SAAS;EACT,SAAS;;;EAGT,QAAQ,eAAe;;EAEvB,QAAQ;;EAER,gBAAgB,eAAe;;;;EAI/B,mBAAmB;EACnB;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;EAMA,iBAAiB;;;;EAIjB,kBAAkB;EAClB;EACA;EACA,SAAS;;;;;;;;;;;KAYC,cAAc,iBAAiB,qBACzC,MAAM,oBAAoB,cACvB,QAAQ;iBAWS,aAAa,iBAAiB,kBAClD,MAAM,oBAAoB,YACzB,QAAQ;;;UCtEM,uBAAuB,iBAAiB;EACvD,YAAY;EACZ,SAAS;;UAGM,mBAAmB,iBAAiB;EACnD,UAAU;EACV,SAAS;;UAGM,gBAAgB,iBAAiB;;EAEhD,cAAc,YAAY,uBAAuB;;EAEjD,aAAa,YAAY,mBAAmB;;EAE5C,iBAAiB,YAAY,mBAAmB;;EAEhD;;EAEA;;UAGe;EACf;EACA,cAAc;EACd;IACE,aAAa,MAAM;MAAe;MAAc;;IAChD;;EAEF;IACE,aAAa,MAAM;MAAe;MAAc;;IAChD;;;UAIa,0BAA0B,iBAAiB;;EAE1D,UAAU;IAAQ;IAAY,OAAO;;;EAErC,UAAU;;;EAGV,QAAQ,eAAe;;EAEvB,QAAQ,gBAAgB;;EAExB,QAAQ;;EAER,gBAAgB,eAAe;;EAE/B,mBAAmB;;EAEnB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;EAIA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;EAIA,iBAAiB;;EAEjB,kBAAkB;;;;;;;;;;;;;;;EAelB,UAAU,cAAc;;EAExB;EACA;;;;;UAMe;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"}
@@ -0,0 +1,230 @@
1
+ import { S as MultishotToolDefinition, T as MultishotTransportRequest, c as RunMultishotMatrixResult, f as RunMultishotOptions, s as RunMultishotMatrixOptions, v as MultishotPersona, y as MultishotResult } from "../../matrix-su7mIfbB.js";
2
+ //#region src/multishot/golden/compare.d.ts
3
+ interface CompareOptions {
4
+ /** Stop after this many mismatches. A structural divergence high in the
5
+ * tree would otherwise report every leaf below it. */
6
+ limit?: number;
7
+ }
8
+ declare function compareJson(expected: unknown, actual: unknown, path: string, options?: CompareOptions): string[];
9
+ //#endregion
10
+ //#region src/multishot/golden/engine.d.ts
11
+ /** A conversation engine: one profile, one persona, one transcript. */
12
+ type MultishotGoldenEngine = (opts: RunMultishotOptions<MultishotPersona>) => Promise<MultishotResult>;
13
+ /** A matrix engine: profile x persona fan-out, judge slots, per-cell files. */
14
+ type MultishotMatrixGoldenEngine = (opts: RunMultishotMatrixOptions<MultishotPersona>) => Promise<RunMultishotMatrixResult>;
15
+ //#endregion
16
+ //#region src/multishot/golden/types.d.ts
17
+ /** One chat message as it reached a transport, normalized to the fields that
18
+ * decide behaviour. `content` is `null` when the message carried none. */
19
+ interface MultishotRecordedMessage {
20
+ role: string;
21
+ content: string | null;
22
+ /** Present on a tool result message. */
23
+ toolCallId?: string;
24
+ /** Present on an assistant message that dispatched tools. */
25
+ toolCalls?: Array<{
26
+ id: string;
27
+ name: string;
28
+ arguments: string;
29
+ }>;
30
+ }
31
+ /** One transport call, recorded in issue order. The ledger pins the sampling
32
+ * contract (per-leg temperature and token budget), the model rotation order,
33
+ * the tool advertisement, and the exact message log each leg saw — the four
34
+ * places two orchestrators diverge without the returned result changing. */
35
+ interface MultishotRecordedRequest {
36
+ leg: 'agent' | 'driver';
37
+ model: string;
38
+ temperature: number | null;
39
+ maxTokens: number | null;
40
+ /** The tool definitions advertised, in order, compared by value. `null` when
41
+ * the request carried no tools. An engine that rebuilds the array is free to
42
+ * do so; an engine that changes a name, a description or a parameter schema
43
+ * changes what the agent is offered, and that is the divergence. */
44
+ tools: MultishotToolDefinition[] | null;
45
+ messages: MultishotRecordedMessage[];
46
+ }
47
+ /** `MultishotResult` without wall-clock `durationMs`, which no two runs share. */
48
+ type RecordedMultishotResult = Omit<MultishotResult, 'durationMs'>;
49
+ /** A throw, reduced to what a caller can observe: the constructor name, the
50
+ * message, and the cell spend the throw declares. */
51
+ interface RecordedMultishotError {
52
+ name: string;
53
+ message: string;
54
+ /** Spend the throw carries for the matrix cost ceiling, or `null` when it
55
+ * carries none. `durationMs` is wall clock and is not recorded. */
56
+ cellSpend: {
57
+ costUsd: number;
58
+ kind: 'observed' | 'estimated' | 'uncaptured';
59
+ } | null;
60
+ }
61
+ type MultishotGoldenOutcome = {
62
+ kind: 'result';
63
+ result: RecordedMultishotResult;
64
+ } | {
65
+ kind: 'error';
66
+ error: RecordedMultishotError;
67
+ };
68
+ interface MultishotGoldenRecord {
69
+ id: string;
70
+ description: string;
71
+ requests: MultishotRecordedRequest[];
72
+ outcome: MultishotGoldenOutcome;
73
+ }
74
+ /** One judge call the matrix issued, recorded from the request body. */
75
+ interface RecordedJudgeRequest {
76
+ model: string;
77
+ temperature: number | null;
78
+ maxTokens: number | null;
79
+ messages: MultishotRecordedMessage[];
80
+ }
81
+ interface MultishotMatrixGoldenRecord {
82
+ id: string;
83
+ description: string;
84
+ requests: MultishotRecordedRequest[];
85
+ judgeRequests: RecordedJudgeRequest[];
86
+ /** The returned `MatrixResult`, with wall-clock and run-identity keys removed. */
87
+ matrix: unknown;
88
+ /** Every file the run persisted under its run directory, keyed by
89
+ * slash-separated relative path. JSON files are parsed and stripped of
90
+ * wall-clock keys; Markdown is kept as text with wall-clock tokens masked. */
91
+ files: Record<string, unknown>;
92
+ }
93
+ /** A frozen fixture version. Records are append-only: a behaviour change mints
94
+ * a NEW version file, never an edit to a released one. */
95
+ interface MultishotGoldenRecordSet {
96
+ version: string;
97
+ /** Engine the records were captured from, as `<module>#<export>`. */
98
+ recordedFrom: string;
99
+ /** Package version that captured them. */
100
+ recordedFromPackageVersion: string;
101
+ recordedAt: string;
102
+ scenarios: MultishotGoldenRecord[];
103
+ matrixScenarios: MultishotMatrixGoldenRecord[];
104
+ }
105
+ //#endregion
106
+ //#region src/multishot/golden/matrix-scenarios.d.ts
107
+ interface MultishotMatrixGoldenCase {
108
+ options: RunMultishotMatrixOptions<MultishotPersona>;
109
+ requests: MultishotRecordedRequest[];
110
+ /** Judge calls, filled while the case runs. Sorted before comparison. */
111
+ judgeRequests: RecordedJudgeRequest[];
112
+ /** Installs the deterministic judge wire on `globalThis.fetch` and returns
113
+ * the function that restores the previous one. */
114
+ installJudgeWire: () => () => void;
115
+ }
116
+ interface MultishotMatrixGoldenScenario {
117
+ readonly id: string;
118
+ readonly description: string;
119
+ readonly build: (runDir: string) => MultishotMatrixGoldenCase;
120
+ }
121
+ declare function multishotMatrixGoldenScenarios(): MultishotMatrixGoldenScenario[];
122
+ //#endregion
123
+ //#region src/multishot/golden/scenarios.d.ts
124
+ /** Options plus the ledger the scenario's transports fill while it runs. */
125
+ interface MultishotGoldenCase {
126
+ options: RunMultishotOptions<MultishotPersona>;
127
+ /** Every transport call, in issue order. Populated by running the case. */
128
+ requests: MultishotRecordedRequest[];
129
+ }
130
+ interface MultishotGoldenScenario {
131
+ readonly id: string;
132
+ readonly description: string;
133
+ /** Fresh options and a fresh ledger. Scripted transports carry per-run
134
+ * state, so an engine run and a re-run must never share a case. */
135
+ readonly build: () => MultishotGoldenCase;
136
+ }
137
+ /** Every recorded shot scenario, in record order. */
138
+ declare function multishotGoldenScenarios(): MultishotGoldenScenario[];
139
+ //#endregion
140
+ //#region src/multishot/golden/harness.d.ts
141
+ interface MultishotGoldenScenarioReport {
142
+ id: string;
143
+ description: string;
144
+ ok: boolean;
145
+ mismatches: string[];
146
+ }
147
+ interface MultishotGoldenReport {
148
+ version: string;
149
+ recordedFrom: string;
150
+ ok: boolean;
151
+ scenarios: MultishotGoldenScenarioReport[];
152
+ }
153
+ declare class MultishotGoldenMismatchError extends Error {
154
+ readonly scenarioId: string;
155
+ readonly mismatches: string[];
156
+ readonly version: string;
157
+ constructor(scenarioId: string, mismatches: string[], version: string);
158
+ }
159
+ /** Run one scenario and report every field that diverged from the record. */
160
+ declare function checkMultishotGoldenScenario(opts: {
161
+ engine: MultishotGoldenEngine;
162
+ scenario: MultishotGoldenScenario;
163
+ records?: MultishotGoldenRecordSet;
164
+ }): Promise<MultishotGoldenScenarioReport>;
165
+ /** Same as `checkMultishotGoldenScenario`, but throws on divergence. */
166
+ declare function assertMultishotGoldenScenario(opts: {
167
+ engine: MultishotGoldenEngine;
168
+ scenario: MultishotGoldenScenario;
169
+ records?: MultishotGoldenRecordSet;
170
+ }): Promise<void>;
171
+ /** Run every shot scenario. Never throws on divergence — read `ok`. */
172
+ declare function checkMultishotGolden(opts: {
173
+ engine: MultishotGoldenEngine;
174
+ records?: MultishotGoldenRecordSet;
175
+ only?: string[];
176
+ }): Promise<MultishotGoldenReport>;
177
+ /** Run one matrix scenario against `runDir` and report every divergence. */
178
+ declare function checkMultishotMatrixGoldenScenario(opts: {
179
+ engine: MultishotMatrixGoldenEngine;
180
+ scenario: MultishotMatrixGoldenScenario;
181
+ /** An empty directory the engine may write its per-cell files into. */
182
+ runDir: string;
183
+ records?: MultishotGoldenRecordSet;
184
+ }): Promise<MultishotGoldenScenarioReport>;
185
+ declare function assertMultishotMatrixGoldenScenario(opts: {
186
+ engine: MultishotMatrixGoldenEngine;
187
+ scenario: MultishotMatrixGoldenScenario;
188
+ runDir: string;
189
+ records?: MultishotGoldenRecordSet;
190
+ }): Promise<void>;
191
+ //#endregion
192
+ //#region src/multishot/golden/recording.d.ts
193
+ /** Keys whose value is wall clock or run identity. Two runs never agree on
194
+ * them, so they are removed before comparison instead of being compared. */
195
+ declare const VOLATILE_KEYS: ReadonlySet<string>;
196
+ declare function recordMessage(raw: unknown): MultishotRecordedMessage;
197
+ declare function recordRequest(leg: 'agent' | 'driver', req: MultishotTransportRequest): MultishotRecordedRequest;
198
+ /** Judge calls reach the wire as an OpenAI-compat body, not through a
199
+ * transport, so they are recorded from the request body the stub receives. */
200
+ declare function recordJudgeRequest(body: Record<string, unknown>): RecordedJudgeRequest;
201
+ declare function recordResult(result: MultishotResult): RecordedMultishotResult;
202
+ declare function recordError(err: unknown): RecordedMultishotError;
203
+ /** Deep copy with every wall-clock and run-identity key removed. */
204
+ declare function stripVolatile(value: unknown): unknown;
205
+ /** The matrix summary Markdown carries a rendered duration. Mask it so the rest
206
+ * of the document — cell counts, pass rate, mean, cost, the uncaptured warning
207
+ * — stays under comparison.
208
+ *
209
+ * A duration the mask does not recognise would stay in the comparison and make
210
+ * every run mismatch on a definitionally irreproducible field, so an
211
+ * unmaskable duration line fails loud instead. */
212
+ declare function maskVolatileMarkdown(text: string): string;
213
+ /** Judge calls fan out through `Promise.all` across three slots, so their
214
+ * issue order is an implementation detail of the cell body, not behaviour a
215
+ * caller can observe. Their CONTENT is behaviour, so they are compared as a
216
+ * set with a stable order. */
217
+ declare function sortJudgeRequests(requests: readonly RecordedJudgeRequest[]): RecordedJudgeRequest[];
218
+ /** Every file under `dir`, keyed by slash-separated relative path. JSON is
219
+ * parsed and stripped of wall-clock keys; Markdown keeps its text with the
220
+ * rendered duration masked; anything else is kept verbatim. */
221
+ declare function readRunDir(dir: string): Record<string, unknown>;
222
+ //#endregion
223
+ //#region src/multishot/golden/records/index.d.ts
224
+ /** Version a check uses when the caller names none. */
225
+ declare const CURRENT_MULTISHOT_GOLDEN_VERSION = "v1";
226
+ declare function multishotGoldenVersions(): string[];
227
+ declare function goldenRecords(version?: string): MultishotGoldenRecordSet;
228
+ //#endregion
229
+ export { CURRENT_MULTISHOT_GOLDEN_VERSION, type CompareOptions, type MultishotGoldenCase, type MultishotGoldenEngine, MultishotGoldenMismatchError, type MultishotGoldenOutcome, type MultishotGoldenRecord, type MultishotGoldenRecordSet, type MultishotGoldenReport, type MultishotGoldenScenario, type MultishotGoldenScenarioReport, type MultishotMatrixGoldenCase, type MultishotMatrixGoldenEngine, type MultishotMatrixGoldenRecord, type MultishotMatrixGoldenScenario, type MultishotRecordedMessage, type MultishotRecordedRequest, type RecordedJudgeRequest, type RecordedMultishotError, type RecordedMultishotResult, VOLATILE_KEYS, assertMultishotGoldenScenario, assertMultishotMatrixGoldenScenario, checkMultishotGolden, checkMultishotGoldenScenario, checkMultishotMatrixGoldenScenario, compareJson, goldenRecords, maskVolatileMarkdown, multishotGoldenScenarios, multishotGoldenVersions, multishotMatrixGoldenScenarios, readRunDir, recordError, recordJudgeRequest, recordMessage, recordRequest, recordResult, sortJudgeRequests, stripVolatile };
230
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/multishot/golden/compare.ts","../../../src/multishot/golden/engine.ts","../../../src/multishot/golden/types.ts","../../../src/multishot/golden/matrix-scenarios.ts","../../../src/multishot/golden/scenarios.ts","../../../src/multishot/golden/harness.ts","../../../src/multishot/golden/recording.ts","../../../src/multishot/golden/records/index.ts"],"mappings":";;UAQiB;;;EAGf;;iBAGc,YACd,mBACA,iBACA,cACA,UAAS;;;;KCPC,yBACV,MAAM,oBAAoB,sBACvB,QAAQ;;KAGD,+BACV,MAAM,0BAA0B,sBAC7B,QAAQ;;;;;UCRI;EACf;EACA;;EAEA;;EAEA,YAAY;IAAQ;IAAY;IAAc;;;;;;;UAO/B;EACf;EACA;EACA;EACA;;;;;EAKA,OAAO;EACP,UAAU;;;KAIA,0BAA0B,KAAK;;;UAI1B;EACf;EACA;;;EAGA;IAAa;IAAiB;;;KAGpB;EACN;EAAgB,QAAQ;;EACxB;EAAe,OAAO;;UAEX;EACf;EACA;EACA,UAAU;EACV,SAAS;;;UAIM;EACf;EACA;EACA;EACA,UAAU;;UAGK;EACf;EACA;EACA,UAAU;EACV,eAAe;;EAEf;;;;EAIA,OAAO;;;;UAKQ;EACf;;EAEA;;EAEA;EACA;EACA,WAAW;EACX,iBAAiB;;;;UCpEF;EACf,SAAS,0BAA0B;EACnC,UAAU;;EAEV,eAAe;;;EAGf;;UAGe;WACN;WACA;WACA,QAAQ,mBAAmB;;iBAqJtB,kCAAkC;;;;UCzJjC;EACf,SAAS,oBAAoB;;EAE7B,UAAU;;UAGK;WACN;WACA;;;WAGA,aAAa;;;iBA4WR,4BAA4B;;;UCzX3B;EACf;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,WAAW;;cAGA,qCAAqC;WAErC;WACA;WACA;EAHX,YACW,oBACA,sBACA;;;iBAoCS,6BAA6B;EACjD,QAAQ;EACR,UAAU;EACV,UAAU;IACR,QAAQ;;iBAoCU,8BAA8B;EAClD,QAAQ;EACR,UAAU;EACV,UAAU;IACR;;iBASkB,qBAAqB;EACzC,QAAQ;EACR,UAAU;EACV;IACE,QAAQ;;iBA6BU,mCAAmC;EACvD,QAAQ;EACR,UAAU;;EAEV;EACA,UAAU;IACR,QAAQ;iBA0BU,oCAAoC;EACxD,QAAQ;EACR,UAAU;EACV;EACA,UAAU;IACR;;;;;cC1LS,eAAe;iBAOZ,cAAc,eAAe;iBA0B7B,cACd,yBACA,KAAK,4BACJ;;;iBAaa,mBAAmB,MAAM,0BAA0B;iBASnD,aAAa,QAAQ,kBAAkB;iBAKvC,YAAY,eAAe;;iBAU3B,cAAc;;;;;;;;iBAoBd,qBAAqB;;;;;iBAgBrB,kBACd,mBAAmB,yBAClB;;;;iBAWa,WAAW,cAAc;;;;cCpI5B;iBAoDG;iBAIA,cACd,mBACC"}