@tangle-network/agent-eval 0.145.18 → 0.145.19

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-CyqmP3uA.js";
3
+ import { n as runAnalystBenchmarkCommand } from "./benchmark-command-Cq7sAba4.js";
4
4
  import { a as runRpcBatch, o as runRpcOnce, p as handleVersion, r as startServerAsync, s as buildOpenApi } from "./server-ulsOdrTI.js";
5
5
  import { writeFileSync } from "node:fs";
6
6
  //#region src/cli-config.ts
@@ -110,6 +110,26 @@ declare class MultishotDriverEmptyError extends Error {
110
110
  declare class MultishotFatalToolError extends Error {
111
111
  constructor(message: string);
112
112
  }
113
+ declare class MultishotShotResultError extends Error {
114
+ constructor(reason: string);
115
+ }
116
+ /** Contract guard for the value a caller-supplied shot resolves with. The
117
+ * matrix writes per-cell artifacts, builds judge inputs, and meters cost from
118
+ * this value, so a malformed result must stop the cell instead of scoring a
119
+ * degraded one. Two silent degradations this closes: an artifact with no
120
+ * `type` matches neither the code nor the content artifact set, so the cell
121
+ * scores as though the artifact was never produced; a non-finite `costUsd`
122
+ * reaches `summary.totalCostUsd` and makes every cost number NaN.
123
+ *
124
+ * It does NOT protect spend. A rejected cell records `costUsd: 0`, so a shot
125
+ * that spends before it returns a malformed result leaves that spend out of
126
+ * the cumulative sum the cost ceiling reads. That is how the matrix records
127
+ * every failed cell, not something this guard changes.
128
+ *
129
+ * Every required field of `MultishotMessage` and `MultishotArtifact` is
130
+ * checked, including `toolCalls` elements and `invocation.args`. Optional
131
+ * fields are checked only when present. */
132
+ declare function assertMultishotShotResult(value: unknown): asserts value is MultishotResult;
113
133
  //#endregion
114
134
  //#region src/multishot/router.d.ts
115
135
  interface RouterCompletionRequest {
@@ -225,6 +245,60 @@ declare function renderDimensions(dims: readonly JudgeDimension[]): string;
225
245
  /** Convenience: build the "Respond with ONLY this JSON" footer for a judge prompt. */
226
246
  declare function renderJsonFooter(dims: readonly JudgeDimension[]): string;
227
247
  //#endregion
248
+ //#region src/multishot/multishot.d.ts
249
+ interface RunMultishotOptions<TPersona extends MultishotPersona> {
250
+ profile: AgentProfile;
251
+ persona: TPersona;
252
+ /** Persona-shaping callbacks. Optional — omitted callbacks are derived from
253
+ * the profile + persona payload, so a pure-profile call works. */
254
+ shape?: MultishotShape<TPersona>;
255
+ /** Tool definitions advertised to the agent. Defaults to delegate_research + delegate_code. */
256
+ tools?: MultishotToolDefinition[];
257
+ /** Map from tool name → executor invoked inline when the agent emits a tool_call. */
258
+ toolExecutors?: Record<string, MultishotToolExecutor>;
259
+ /** Map from tool name → artifact type label written into MultishotArtifact.type.
260
+ * Tools without a mapping still execute, but their results aren't surfaced as
261
+ * typed artifacts (only as tool messages in the transcript). */
262
+ artifactTypeFor?: (toolName: string) => string | undefined;
263
+ maxTurns?: number;
264
+ agentModel?: string;
265
+ driverModel?: string;
266
+ /** Fallback driver models tried when the primary simulated-user model returns empty twice. */
267
+ driverFallbackModels?: string[];
268
+ /** Maximum output tokens for the first agent call in each assistant turn. */
269
+ agentMaxTokens?: number;
270
+ /** Maximum output tokens for agent follow-up calls after tool results. */
271
+ toolFollowupMaxTokens?: number;
272
+ /** Maximum output tokens for each simulated-user driver response. */
273
+ driverMaxTokens?: number;
274
+ /** Maximum tool calls the agent may dispatch inside one assistant turn. */
275
+ maxToolDispatches?: number;
276
+ /** Execution seam for the agent leg. When provided, every agent inference
277
+ * step goes through this function instead of the router HTTP call; the
278
+ * string levers (agentModel, apiKey, baseUrl) stop applying to that leg.
279
+ * apiKey/baseUrl are still resolved for tool executors and any leg
280
+ * without an injected transport. */
281
+ agentTransport?: MultishotTransport;
282
+ /** Execution seam for the simulated-user driver leg (symmetric to
283
+ * agentTransport). Driver model fallback rotation still applies — the
284
+ * transport receives each candidate model in turn. */
285
+ driverTransport?: MultishotTransport;
286
+ apiKey?: string;
287
+ baseUrl?: string;
288
+ signal?: AbortSignal;
289
+ }
290
+ /** One multishot shot — the conversation engine `runMultishotMatrix` invokes
291
+ * once per cell. `runMultishot` is the default implementation.
292
+ *
293
+ * An alternative engine (a graph-backed conversation, a replay of a recorded
294
+ * transcript, a sandbox-hosted agent) implements this exact signature and
295
+ * reaches the matrix through `RunMultishotMatrixOptions.runShot`. The matrix
296
+ * keeps every other cell mechanic — cell fan-out, concurrency, the cost
297
+ * ceiling, the judge slots, the cell composite, and the per-cell writers — so
298
+ * swapping the engine needs no copy of the cell body. */
299
+ type MultishotShot<TPersona extends MultishotPersona> = (opts: RunMultishotOptions<TPersona>) => Promise<MultishotResult>;
300
+ declare function runMultishot<TPersona extends MultishotPersona>(opts: RunMultishotOptions<TPersona>): Promise<MultishotResult>;
301
+ //#endregion
228
302
  //#region src/multishot/matrix.d.ts
229
303
  interface ConversationJudgeInput<TPersona extends MultishotPersona> {
230
304
  transcript: MultishotMessage[];
@@ -315,11 +389,29 @@ interface RunMultishotMatrixOptions<TPersona extends MultishotPersona> {
315
389
  agentTransport?: MultishotTransport;
316
390
  /** Execution seam for the simulated-user driver leg of every cell. */
317
391
  driverTransport?: MultishotTransport;
392
+ /** Conversation engine for every cell. Defaults to `runMultishot`.
393
+ *
394
+ * The matrix owns everything around the shot — cell fan-out, concurrency,
395
+ * the cost ceiling, the judge slots, the cell composite, the per-cell
396
+ * artifact writers and the run summary — and forwards the whole cell input
397
+ * to this function, so an alternative engine replaces ONLY the
398
+ * conversation. Every option on this interface that `runMultishot` accepts
399
+ * reaches the shot unchanged. `RunMultishotOptions.signal` has no
400
+ * matrix-level counterpart and is not forwarded; a shot owns its own
401
+ * cancellation.
402
+ *
403
+ * A shot that resolves with a value outside `MultishotResult` throws
404
+ * `MultishotShotResultError` for that cell. The default engine is never
405
+ * used as a fallback. */
406
+ runShot?: MultishotShot<TPersona>;
318
407
  /** Pass-thru fields. */
319
408
  apiKey?: string;
320
409
  baseUrl?: string;
321
410
  }
322
- interface CellOutput {
411
+ /** Per-cell output the multishot matrix records in `MatrixResult.cells`.
412
+ * A consumer that supplies its own `runShot` reads the matrix through this
413
+ * type instead of declaring a structural copy. */
414
+ interface MultishotCellOutput {
323
415
  turns: number;
324
416
  toolCalls: number;
325
417
  artifactCount: number;
@@ -343,54 +435,10 @@ declare function computeCellComposite(input: CellCompositeInput): {
343
435
  allJudgesFailed: boolean;
344
436
  };
345
437
  interface RunMultishotMatrixResult {
346
- matrix: MatrixResult<CellOutput>;
438
+ matrix: MatrixResult<MultishotCellOutput>;
347
439
  }
348
440
  declare function runMultishotMatrix<TPersona extends MultishotPersona>(opts: RunMultishotMatrixOptions<TPersona>): Promise<RunMultishotMatrixResult>;
349
441
  //#endregion
350
- //#region src/multishot/multishot.d.ts
351
- interface RunMultishotOptions<TPersona extends MultishotPersona> {
352
- profile: AgentProfile;
353
- persona: TPersona;
354
- /** Persona-shaping callbacks. Optional — omitted callbacks are derived from
355
- * the profile + persona payload, so a pure-profile call works. */
356
- shape?: MultishotShape<TPersona>;
357
- /** Tool definitions advertised to the agent. Defaults to delegate_research + delegate_code. */
358
- tools?: MultishotToolDefinition[];
359
- /** Map from tool name → executor invoked inline when the agent emits a tool_call. */
360
- toolExecutors?: Record<string, MultishotToolExecutor>;
361
- /** Map from tool name → artifact type label written into MultishotArtifact.type.
362
- * Tools without a mapping still execute, but their results aren't surfaced as
363
- * typed artifacts (only as tool messages in the transcript). */
364
- artifactTypeFor?: (toolName: string) => string | undefined;
365
- maxTurns?: number;
366
- agentModel?: string;
367
- driverModel?: string;
368
- /** Fallback driver models tried when the primary simulated-user model returns empty twice. */
369
- driverFallbackModels?: string[];
370
- /** Maximum output tokens for the first agent call in each assistant turn. */
371
- agentMaxTokens?: number;
372
- /** Maximum output tokens for agent follow-up calls after tool results. */
373
- toolFollowupMaxTokens?: number;
374
- /** Maximum output tokens for each simulated-user driver response. */
375
- driverMaxTokens?: number;
376
- /** Maximum tool calls the agent may dispatch inside one assistant turn. */
377
- maxToolDispatches?: number;
378
- /** Execution seam for the agent leg. When provided, every agent inference
379
- * step goes through this function instead of the router HTTP call; the
380
- * string levers (agentModel, apiKey, baseUrl) stop applying to that leg.
381
- * apiKey/baseUrl are still resolved for tool executors and any leg
382
- * without an injected transport. */
383
- agentTransport?: MultishotTransport;
384
- /** Execution seam for the simulated-user driver leg (symmetric to
385
- * agentTransport). Driver model fallback rotation still applies — the
386
- * transport receives each candidate model in turn. */
387
- driverTransport?: MultishotTransport;
388
- apiKey?: string;
389
- baseUrl?: string;
390
- signal?: AbortSignal;
391
- }
392
- declare function runMultishot<TPersona extends MultishotPersona>(opts: RunMultishotOptions<TPersona>): Promise<MultishotResult>;
393
- //#endregion
394
442
  //#region src/multishot/shape-defaults.d.ts
395
443
  /** Persona payload rendered as stable `- key: value` lines. `id` is identity,
396
444
  * not voice, and structured values are serialized so nothing is dropped. */
@@ -405,5 +453,5 @@ declare function defaultMultishotDriverSystemPrompt(profile: AgentProfile, perso
405
453
  * profile-derived defaults fill the rest. */
406
454
  declare function defaultShapeFromProfile<TPersona extends MultishotPersona>(profile: AgentProfile, shape?: MultishotShape<TPersona>): Required<MultishotShape<TPersona>>;
407
455
  //#endregion
408
- export { type ArtifactJudgeInput, type CellCompositeInput, type CellCompositeScore, type ConversationJudgeInput, DEFAULT_CODER_MODEL, DEFAULT_DELEGATE_CODE_TOOL, DEFAULT_DELEGATE_RESEARCH_TOOL, DEFAULT_JUDGE_MODEL, DEFAULT_RESEARCHER_MODEL, type DefaultCoderConfig, type DefaultResearcherConfig, type DefaultToolsBundle, type DefaultToolsConfig, type JudgeConfig, type JudgeDimension, type JudgeRunResult, type JudgeScore, type MultishotArtifact, MultishotDriverEmptyError, MultishotFatalToolError, type MultishotJudges, type MultishotMessage, type MultishotPersona, type MultishotResult, type MultishotShape, type MultishotToolDefinition, type MultishotToolExecutor, type MultishotTransport, type MultishotTransportRequest, type MultishotTransportResponse, type MultishotTransportToolCall, type RouterCompletionRequest, type RouterCompletionResponse, type RouterToolCall, type RunMultishotMatrixOptions, type RunMultishotMatrixResult, type RunMultishotOptions, computeCellComposite, createCodeExecutor, createResearchExecutor, defaultDelegationTools, defaultMultishotDriverSystemPrompt, defaultMultishotOpener, defaultRouterBaseUrl, defaultShapeFromProfile, estimateRouterCost, renderDimensions, renderJsonFooter, renderPersonaFacts, requireRouterApiKey, routerCompletion, runJudge, runMultishot, runMultishotMatrix };
456
+ export { type ArtifactJudgeInput, type CellCompositeInput, type CellCompositeScore, type ConversationJudgeInput, DEFAULT_CODER_MODEL, DEFAULT_DELEGATE_CODE_TOOL, DEFAULT_DELEGATE_RESEARCH_TOOL, DEFAULT_JUDGE_MODEL, DEFAULT_RESEARCHER_MODEL, type DefaultCoderConfig, type DefaultResearcherConfig, type DefaultToolsBundle, type DefaultToolsConfig, type JudgeConfig, type JudgeDimension, type JudgeRunResult, type JudgeScore, type MultishotArtifact, type MultishotCellOutput, MultishotDriverEmptyError, MultishotFatalToolError, type MultishotJudges, type MultishotMessage, type MultishotPersona, type MultishotResult, type MultishotShape, type MultishotShot, MultishotShotResultError, type MultishotToolDefinition, type MultishotToolExecutor, type MultishotTransport, type MultishotTransportRequest, type MultishotTransportResponse, type MultishotTransportToolCall, type RouterCompletionRequest, type RouterCompletionResponse, type RouterToolCall, type RunMultishotMatrixOptions, type RunMultishotMatrixResult, type RunMultishotOptions, assertMultishotShotResult, computeCellComposite, createCodeExecutor, createResearchExecutor, defaultDelegationTools, defaultMultishotDriverSystemPrompt, defaultMultishotOpener, defaultRouterBaseUrl, defaultShapeFromProfile, estimateRouterCost, renderDimensions, renderJsonFooter, renderPersonaFacts, requireRouterApiKey, routerCompletion, runJudge, runMultishot, runMultishotMatrix };
409
457
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/multishot/types.ts","../../src/multishot/router.ts","../../src/multishot/default-tools.ts","../../src/multishot/judges.ts","../../src/multishot/matrix.ts","../../src/multishot/multishot.ts","../../src/multishot/shape-defaults.ts"],"mappings":";;;;;UAEiB;EACf;EACA;EACA;EACA,YAAY;IAAQ;IAAY;IAAc,MAAM;;;UAGrC;EACf;EACA;EACA;IAAc;IAAc,MAAM;;EAClC;;UAGe;EACf,YAAY;EACZ,WAAW;EACX;EACA;EACA;;UAGe;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;;;;UCjGG;EACf;EACA;EACA;EACA,UAAU,MAAM;EAChB,QAAQ;EACR;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;IAAY;IAAc;;;UAGX;EACf;IAAW;IAAyB,aAAa;;EACjD;IAAU;IAAwB;;;EAElC;;EAEA;EACA;;iBAGoB,iBACpB,KAAK,0BACJ,QAAQ;iBA2CK,mBACd,eACA;EAAU;EAAwB;;iBAoBpB;iBAOA;;;cCjGH;cACA;UAEI;;;EAGf;EACA;;UAGe;;;EAGf;EACA;;cASW,gCAAgC;cAoBhC,4BAA4B;iBAoBzB,uBACd,SAAQ,0BACP;iBAsBa,mBAAmB,SAAQ,qBAA0B;UAsBpD;EACf,WAAW;EACX,OAAO;;;EAGP;;UAGe;EACf,OAAO;EACP,WAAW,eAAe;EAC1B,kBAAkB;;iBAG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;EAEvB,QAAQ;;EAER,gBAAgB,eAAe;;;;EAI/B,mBAAmB;EACnB;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;EAMA,iBAAiB;;;;EAIjB,kBAAkB;EAClB;EACA;EACA,SAAS;;iBAGW,aAAa,iBAAiB,kBAClD,MAAM,oBAAoB,YACzB,QAAQ;;;;;iBC5DK,mBAAmB,SAAS;;;iBAe5B,uBAAuB,SAAS,cAAc,SAAS;;;iBAavD,mCACd,SAAS,cACT,SAAS;;;iBAqBK,wBAAwB,iBAAiB,kBACvD,SAAS,cACT,QAAQ,eAAe,YACtB,SAAS,eAAe"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/multishot/types.ts","../../src/multishot/router.ts","../../src/multishot/default-tools.ts","../../src/multishot/judges.ts","../../src/multishot/multishot.ts","../../src/multishot/matrix.ts","../../src/multishot/shape-defaults.ts"],"mappings":";;;;;UAEiB;EACf;EACA;EACA;EACA,YAAY;IAAQ;IAAY;IAAc,MAAM;;;UAGrC;EACf;EACA;EACA;IAAc;IAAc,MAAM;;EAClC;;UAGe;EACf,YAAY;EACZ,WAAW;EACX;EACA;EACA;;UAGe;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;;;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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;;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;;;;;iBC7LK,mBAAmB,SAAS;;;iBAe5B,uBAAuB,SAAS,cAAc,SAAS;;;iBAavD,mCACd,SAAS,cACT,SAAS;;;iBAqBK,wBAAwB,iBAAiB,kBACvD,SAAS,cACT,QAAQ,eAAe,YACtB,SAAS,eAAe"}
@@ -379,6 +379,84 @@ var MultishotFatalToolError = class extends Error {
379
379
  this.name = "MultishotFatalToolError";
380
380
  }
381
381
  };
382
+ var MultishotShotResultError = class extends Error {
383
+ constructor(reason) {
384
+ super(`multishot: shot returned an invalid MultishotResult — ${reason}`);
385
+ this.name = "MultishotShotResultError";
386
+ }
387
+ };
388
+ const MULTISHOT_ROLES = /* @__PURE__ */ new Set([
389
+ "user",
390
+ "assistant",
391
+ "tool"
392
+ ]);
393
+ /** Contract guard for the value a caller-supplied shot resolves with. The
394
+ * matrix writes per-cell artifacts, builds judge inputs, and meters cost from
395
+ * this value, so a malformed result must stop the cell instead of scoring a
396
+ * degraded one. Two silent degradations this closes: an artifact with no
397
+ * `type` matches neither the code nor the content artifact set, so the cell
398
+ * scores as though the artifact was never produced; a non-finite `costUsd`
399
+ * reaches `summary.totalCostUsd` and makes every cost number NaN.
400
+ *
401
+ * It does NOT protect spend. A rejected cell records `costUsd: 0`, so a shot
402
+ * that spends before it returns a malformed result leaves that spend out of
403
+ * the cumulative sum the cost ceiling reads. That is how the matrix records
404
+ * every failed cell, not something this guard changes.
405
+ *
406
+ * Every required field of `MultishotMessage` and `MultishotArtifact` is
407
+ * checked, including `toolCalls` elements and `invocation.args`. Optional
408
+ * fields are checked only when present. */
409
+ function assertMultishotShotResult(value) {
410
+ if (typeof value !== "object" || value === null) throw new MultishotShotResultError(`expected an object, received ${describeValue(value)}`);
411
+ const result = value;
412
+ if (!Array.isArray(result.transcript)) throw new MultishotShotResultError(`transcript must be an array, received ${describeValue(result.transcript)}`);
413
+ if (!Array.isArray(result.artifacts)) throw new MultishotShotResultError(`artifacts must be an array, received ${describeValue(result.artifacts)}`);
414
+ result.transcript.forEach(assertMessage);
415
+ result.artifacts.forEach(assertArtifact);
416
+ assertFiniteCount(result.toolCalls, "toolCalls");
417
+ assertFiniteCount(result.durationMs, "durationMs");
418
+ assertFiniteCount(result.costUsd, "costUsd");
419
+ }
420
+ function assertMessage(value, index) {
421
+ const row = requireRow(value, `transcript[${index}]`);
422
+ if (typeof row.role !== "string" || !MULTISHOT_ROLES.has(row.role)) throw new MultishotShotResultError(`transcript[${index}].role must be user, assistant or tool, received ${describeValue(row.role)}`);
423
+ assertString(row.content, `transcript[${index}].content`);
424
+ if (row.toolCallId !== void 0) assertString(row.toolCallId, `transcript[${index}].toolCallId`);
425
+ if (row.toolCalls === void 0) return;
426
+ if (!Array.isArray(row.toolCalls)) throw new MultishotShotResultError(`transcript[${index}].toolCalls must be an array when present, received ${describeValue(row.toolCalls)}`);
427
+ row.toolCalls.forEach((call, callIndex) => {
428
+ const field = `transcript[${index}].toolCalls[${callIndex}]`;
429
+ const row = requireRow(call, field);
430
+ assertString(row.id, `${field}.id`);
431
+ assertString(row.name, `${field}.name`);
432
+ requireRow(row.args, `${field}.args`);
433
+ });
434
+ }
435
+ function assertArtifact(value, index) {
436
+ const row = requireRow(value, `artifacts[${index}]`);
437
+ assertString(row.type, `artifacts[${index}].type`);
438
+ assertString(row.content, `artifacts[${index}].content`);
439
+ assertFiniteCount(row.turn, `artifacts[${index}].turn`);
440
+ const invocation = requireRow(row.invocation, `artifacts[${index}].invocation`);
441
+ assertString(invocation.name, `artifacts[${index}].invocation.name`);
442
+ requireRow(invocation.args, `artifacts[${index}].invocation.args`);
443
+ }
444
+ function requireRow(value, field) {
445
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new MultishotShotResultError(`${field} must be an object, received ${describeValue(value)}`);
446
+ return value;
447
+ }
448
+ function assertString(value, field) {
449
+ if (typeof value !== "string") throw new MultishotShotResultError(`${field} must be a string, received ${describeValue(value)}`);
450
+ }
451
+ function assertFiniteCount(value, field) {
452
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) throw new MultishotShotResultError(`${field} must be a finite number >= 0, received ${describeValue(value)}`);
453
+ }
454
+ function describeValue(value) {
455
+ if (value === null) return "null";
456
+ if (Array.isArray(value)) return "an array";
457
+ if (typeof value === "object") return "an object";
458
+ return `${typeof value} ${String(value)}`;
459
+ }
382
460
  //#endregion
383
461
  //#region src/multishot/multishot.ts
384
462
  async function runMultishot(opts) {
@@ -610,6 +688,7 @@ function computeCellComposite(input) {
610
688
  async function runMultishotMatrix(opts) {
611
689
  const codeTypes = new Set(opts.judges.codeArtifactTypes ?? ["code"]);
612
690
  const contentTypes = new Set(opts.judges.contentArtifactTypes ?? ["research"]);
691
+ const runShot = opts.runShot ?? runMultishot;
613
692
  mkdirSync(opts.runDir, { recursive: true });
614
693
  const matrix = await runAgentMatrix({
615
694
  axes: [{
@@ -630,7 +709,7 @@ async function runMultishotMatrix(opts) {
630
709
  const persona = cell.axes.persona?.value;
631
710
  const profileId = String(cell.axes.profile?.id ?? "unknown");
632
711
  const personaId = String(cell.axes.persona?.id ?? "unknown");
633
- const sim = await runMultishot({
712
+ const sim = await runShot({
634
713
  profile,
635
714
  persona,
636
715
  shape: opts.shape,
@@ -650,6 +729,7 @@ async function runMultishotMatrix(opts) {
650
729
  apiKey: opts.apiKey,
651
730
  baseUrl: opts.baseUrl
652
731
  });
732
+ assertMultishotShotResult(sim);
653
733
  const codeArtifacts = sim.artifacts.filter((a) => codeTypes.has(a.type));
654
734
  const contentArtifacts = sim.artifacts.filter((a) => contentTypes.has(a.type));
655
735
  const [conversationRun, codeReviewRuns, contentReviewRuns] = await Promise.all([
@@ -773,6 +853,6 @@ function withJudgeMaxTokens(judge, maxTokens) {
773
853
  };
774
854
  }
775
855
  //#endregion
776
- export { DEFAULT_CODER_MODEL, DEFAULT_DELEGATE_CODE_TOOL, DEFAULT_DELEGATE_RESEARCH_TOOL, DEFAULT_JUDGE_MODEL, DEFAULT_RESEARCHER_MODEL, MultishotDriverEmptyError, MultishotFatalToolError, computeCellComposite, createCodeExecutor, createResearchExecutor, defaultDelegationTools, defaultMultishotDriverSystemPrompt, defaultMultishotOpener, defaultRouterBaseUrl, defaultShapeFromProfile, estimateRouterCost, renderDimensions, renderJsonFooter, renderPersonaFacts, requireRouterApiKey, routerCompletion, runJudge, runMultishot, runMultishotMatrix };
856
+ export { DEFAULT_CODER_MODEL, DEFAULT_DELEGATE_CODE_TOOL, DEFAULT_DELEGATE_RESEARCH_TOOL, DEFAULT_JUDGE_MODEL, DEFAULT_RESEARCHER_MODEL, MultishotDriverEmptyError, MultishotFatalToolError, MultishotShotResultError, assertMultishotShotResult, computeCellComposite, createCodeExecutor, createResearchExecutor, defaultDelegationTools, defaultMultishotDriverSystemPrompt, defaultMultishotOpener, defaultRouterBaseUrl, defaultShapeFromProfile, estimateRouterCost, renderDimensions, renderJsonFooter, renderPersonaFacts, requireRouterApiKey, routerCompletion, runJudge, runMultishot, runMultishotMatrix };
777
857
 
778
858
  //# sourceMappingURL=index.js.map