@ouispec/agent-evals 0.25.0 → 0.26.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.
Files changed (59) hide show
  1. package/README.md +21 -0
  2. package/dist/aggregate.d.ts +178 -0
  3. package/dist/aggregate.d.ts.map +1 -0
  4. package/dist/aggregate.js +122 -0
  5. package/dist/aggregate.js.map +1 -0
  6. package/dist/cassettes.d.ts +18 -2
  7. package/dist/cassettes.d.ts.map +1 -1
  8. package/dist/cassettes.js +19 -7
  9. package/dist/cassettes.js.map +1 -1
  10. package/dist/cli.js +125 -6
  11. package/dist/cli.js.map +1 -1
  12. package/dist/config.d.ts +61 -3
  13. package/dist/config.d.ts.map +1 -1
  14. package/dist/config.js.map +1 -1
  15. package/dist/expectations.d.ts +8 -0
  16. package/dist/expectations.d.ts.map +1 -0
  17. package/dist/expectations.js +16 -0
  18. package/dist/expectations.js.map +1 -0
  19. package/dist/index.d.ts +27 -9
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +17 -3
  22. package/dist/index.js.map +1 -1
  23. package/dist/judge.d.ts +8 -2
  24. package/dist/judge.d.ts.map +1 -1
  25. package/dist/judge.js +5 -2
  26. package/dist/judge.js.map +1 -1
  27. package/dist/leaderboard.d.ts +34 -0
  28. package/dist/leaderboard.d.ts.map +1 -0
  29. package/dist/leaderboard.js +341 -0
  30. package/dist/leaderboard.js.map +1 -0
  31. package/dist/matrix.d.ts +100 -0
  32. package/dist/matrix.d.ts.map +1 -0
  33. package/dist/matrix.js +169 -0
  34. package/dist/matrix.js.map +1 -0
  35. package/dist/models.d.ts +77 -0
  36. package/dist/models.d.ts.map +1 -0
  37. package/dist/models.js +163 -0
  38. package/dist/models.js.map +1 -0
  39. package/dist/report.d.ts +2 -2
  40. package/dist/report.d.ts.map +1 -1
  41. package/dist/report.js +12 -4
  42. package/dist/report.js.map +1 -1
  43. package/dist/run.d.ts +56 -10
  44. package/dist/run.d.ts.map +1 -1
  45. package/dist/run.js +145 -55
  46. package/dist/run.js.map +1 -1
  47. package/dist/spend.d.ts +113 -0
  48. package/dist/spend.d.ts.map +1 -0
  49. package/dist/spend.js +170 -0
  50. package/dist/spend.js.map +1 -0
  51. package/dist/suite.d.ts +3 -1
  52. package/dist/suite.d.ts.map +1 -1
  53. package/dist/suite.js +2 -1
  54. package/dist/suite.js.map +1 -1
  55. package/dist/usage.d.ts +45 -4
  56. package/dist/usage.d.ts.map +1 -1
  57. package/dist/usage.js +57 -14
  58. package/dist/usage.js.map +1 -1
  59. package/package.json +5 -5
package/dist/matrix.js ADDED
@@ -0,0 +1,169 @@
1
+ import { leadersOf, summarizeModel } from './aggregate.js';
2
+ import { checkCandidates, checkJudge } from './models.js';
3
+ import { evalTargets, runEvalCase } from './run.js';
4
+ import { EvalBudgetError, SpendGuard, estimateMatrix } from './spend.js';
5
+ import { rubricsOf } from './suite.js';
6
+ /** The results file's format, and its version: a reader checks both. */
7
+ export const MATRIX_FORMAT = 'agent-evals-matrix';
8
+ export const MATRIX_VERSION = 1;
9
+ /** By default a model within this many percentage points of the best pass rate may be picked for being cheaper. */
10
+ export const DEFAULT_WITHIN_POINTS = 2;
11
+ /** A scenario's categories: its suite's, then its own. */
12
+ export const tagsOf = (target) => [...new Set([...(target.suite.tags ?? []), ...(target.scenario.tags ?? [])])];
13
+ /** The candidates and the judge, checked together: the judge is never a candidate. */
14
+ function checkedModels(config, models) {
15
+ const judge = config.judgeModel ? checkJudge(config.judgeModel, 'the configuration') : undefined;
16
+ return { models: checkCandidates(models, 'the models', judge), judge };
17
+ }
18
+ function checkedRuns(runs) {
19
+ const n = runs ?? 1;
20
+ if (!Number.isInteger(n) || n < 1)
21
+ throw new Error(`[agent-evals] runs is a whole number, 1 or more, not ${String(runs)}`);
22
+ return n;
23
+ }
24
+ /**
25
+ * What a matrix will cost, without calling a model: its cases, from the
26
+ * configuration's suites narrowed as the options say, at each model's prices.
27
+ * Throws an `EvalBudgetError` naming every turn the suites give no budget for.
28
+ */
29
+ export function estimateRun(config, options) {
30
+ const { models, judge } = checkedModels(config, options.models);
31
+ const { targets } = evalTargets(config, options);
32
+ return estimateMatrix(targets, models, checkedRuns(options.runs), {
33
+ ...(config.budgets ? { budgets: config.budgets } : {}),
34
+ ...(judge ? { judgeModel: judge } : {}),
35
+ ...(config.judgeOptions?.maxOutputTokens !== undefined ? { judgeMaxOutputTokens: config.judgeOptions.maxOutputTokens } : {}),
36
+ });
37
+ }
38
+ /** One case's result, as the matrix keeps it. */
39
+ function matrixCaseOf(result, target, model, run) {
40
+ return {
41
+ suite: result.suite,
42
+ scenario: result.scenario,
43
+ title: result.title,
44
+ channel: result.channel,
45
+ tags: tagsOf(target),
46
+ model,
47
+ run,
48
+ status: result.stoppedBy ? 'stopped' : result.status,
49
+ failures: result.failures,
50
+ turns: result.turns.map((t) => ({
51
+ turn: t.turn,
52
+ kind: t.kind,
53
+ customer: t.customer,
54
+ reply: t.reply,
55
+ toolCalls: t.toolCalls,
56
+ held: t.held,
57
+ usage: t.usage,
58
+ invalidToolCalls: t.invalidToolCalls,
59
+ refusal: t.refusal,
60
+ costUsd: t.costUsd ?? 0,
61
+ outcome: t.outcome,
62
+ ...(t.stopReason ? { stopReason: t.stopReason } : {}),
63
+ })),
64
+ costUsd: result.costUsd ?? 0,
65
+ judgeCostUsd: result.judgeCostUsd,
66
+ modelRequests: result.modelRequests,
67
+ durationMs: result.durationMs,
68
+ cassette: result.cassette,
69
+ };
70
+ }
71
+ /** Run `tasks`, `concurrency` at a time, starting each only while `go()` says so; a task never started has no result. */
72
+ async function inPool(tasks, concurrency, go) {
73
+ const results = new Array(tasks.length).fill(undefined);
74
+ let next = 0;
75
+ const worker = async () => {
76
+ while (next < tasks.length && go()) {
77
+ const index = next++;
78
+ results[index] = await tasks[index]();
79
+ }
80
+ };
81
+ await Promise.all(Array.from({ length: Math.max(1, Math.min(concurrency, tasks.length)) }, worker));
82
+ return results;
83
+ }
84
+ /** Runs the matrix, and reports every case, each model's summary and the picks. */
85
+ export async function runMatrix(config, options) {
86
+ const startedMs = Date.now();
87
+ const startedAt = new Date(startedMs).toISOString();
88
+ const mode = options.mode ?? 'replay';
89
+ const { models, judge } = checkedModels(config, options.models);
90
+ const runs = checkedRuns(options.runs);
91
+ const concurrency = options.concurrency ?? 1;
92
+ if (!Number.isInteger(concurrency) || concurrency < 1)
93
+ throw new Error(`[agent-evals] concurrency is a whole number, 1 or more, not ${String(options.concurrency)}`);
94
+ const withinPoints = options.withinPoints ?? DEFAULT_WITHIN_POINTS;
95
+ if (!Number.isFinite(withinPoints) || withinPoints < 0)
96
+ throw new Error(`[agent-evals] withinPoints is 0 or more, not ${String(options.withinPoints)}`);
97
+ const maxCostUsd = options.maxCostUsd;
98
+ if (maxCostUsd !== undefined && (!Number.isFinite(maxCostUsd) || maxCostUsd <= 0))
99
+ throw new Error(`[agent-evals] the cost limit is more than $0, not ${String(maxCostUsd)}`);
100
+ const { targets, cassettes } = evalTargets(config, options);
101
+ if (!judge && targets.some((t) => rubricsOf(t.scenario).length > 0)) {
102
+ throw new Error('[agent-evals] the suites have rubrics, and a matrix judges them with one fixed model: give the configuration `judgeModel`');
103
+ }
104
+ let estimate = null;
105
+ let estimateProblems = [];
106
+ try {
107
+ estimate = estimateRun(config, options);
108
+ }
109
+ catch (err) {
110
+ // With a limit, a run whose cost cannot be estimated does not start.
111
+ if (!(err instanceof EvalBudgetError) || maxCostUsd !== undefined)
112
+ throw err;
113
+ estimateProblems = [...err.problems];
114
+ }
115
+ const total = targets.length * models.length * runs;
116
+ const guard = new SpendGuard(maxCostUsd);
117
+ const finish = (cases, stopped) => {
118
+ const summaries = models.map((model) => summarizeModel(model, cases.filter((c) => c.model === model.id), runs, targets.length));
119
+ return {
120
+ format: MATRIX_FORMAT,
121
+ version: MATRIX_VERSION,
122
+ mode,
123
+ runs,
124
+ startedAt,
125
+ durationMs: Date.now() - startedMs,
126
+ withinPoints,
127
+ judge: judge ? { id: judge.id, label: judge.label ?? judge.id, prices: judge.prices ?? null } : null,
128
+ models,
129
+ scenarios: [...new Map(targets.map((t) => [`${t.suite.name}\u0000${t.scenario.id}`, t])).values()].map((t) => ({
130
+ suite: t.suite.name,
131
+ id: t.scenario.id,
132
+ title: t.scenario.title,
133
+ tags: tagsOf(t),
134
+ channels: targets.filter((o) => o.suite === t.suite && o.scenario === t.scenario).map((o) => o.channel),
135
+ })),
136
+ cases,
137
+ summaries,
138
+ leaders: leadersOf(summaries, withinPoints),
139
+ spend: {
140
+ estimate,
141
+ estimateProblems,
142
+ maxCostUsd: maxCostUsd ?? null,
143
+ spentUsd: guard.spentUsd,
144
+ agentUsd: guard.agentUsd,
145
+ judgeUsd: guard.judgeUsd,
146
+ stopped,
147
+ },
148
+ };
149
+ };
150
+ if (maxCostUsd !== undefined && estimate && estimate.totalUsd > maxCostUsd)
151
+ return finish([], { reason: 'estimate', casesNotRun: total });
152
+ const tasks = [];
153
+ for (let run = 1; run <= runs; run++) {
154
+ for (const target of targets) {
155
+ for (const candidate of models) {
156
+ tasks.push(async () => {
157
+ const result = await runEvalCase(config, { ...target, mode, cassettes, candidate, run, guard });
158
+ options.onCase?.(result);
159
+ return matrixCaseOf(result, target, candidate.id, run);
160
+ });
161
+ }
162
+ }
163
+ }
164
+ const ran = (await inPool(tasks, concurrency, () => !guard.exceeded)).filter((c) => c !== undefined);
165
+ const unfinished = total - ran.filter((c) => c.status !== 'stopped').length;
166
+ // Every case ran to its end, though the last may have reached the limit: the run was not stopped.
167
+ return finish(ran, unfinished > 0 ? { reason: 'max-cost', casesNotRun: unfinished } : null);
168
+ }
169
+ //# sourceMappingURL=matrix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrix.js","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAyD,MAAM,gBAAgB,CAAC;AAClH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAiE,MAAM,aAAa,CAAC;AACzH,OAAO,E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,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAmB,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IACtH,MAAM,UAAU,GAAG,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC;IAC5E,kGAAkG;IAClG,OAAO,MAAM,CAAC,GAAG,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC9F,CAAC"}
@@ -0,0 +1,77 @@
1
+ import type { ProviderOptions } from '@ouispec/agent-worker';
2
+ import type { EvalModelCall } from './usage.js';
3
+ /** What a model costs, in US dollars per million tokens. */
4
+ export interface EvalModelPrices {
5
+ /** Input not read from or written to the prompt cache. */
6
+ input: number;
7
+ output: number;
8
+ /** Input read from the prompt cache. */
9
+ cacheRead: number;
10
+ /** Input written to the prompt cache. */
11
+ cacheWrite: number;
12
+ }
13
+ /** What a model can be asked for: the matrix sends each turn only what the model takes. */
14
+ export interface EvalModelCapabilities {
15
+ /** It reads a prompt cache: the run sends the configuration's cache breakpoint. Without it, none is sent. */
16
+ promptCache: boolean;
17
+ /** It takes a forced tool choice: without it, the agent's `forcedToolChoice` is off. */
18
+ forcedToolChoice: boolean;
19
+ /** It takes a temperature: without it, none is sent (`temperature: null`). */
20
+ temperature: boolean;
21
+ /** It reads images. Reported with its results; a scenario that sends one runs either way. */
22
+ vision: boolean;
23
+ /** Its context window, in tokens. Reported with its results, beside the largest call's input. */
24
+ contextWindow?: number;
25
+ }
26
+ /** One model of a matrix: what the product's registry declares for it. */
27
+ export interface EvalCandidate {
28
+ /** The provider's id for it, which the configuration's model factory builds. Unique in the matrix. */
29
+ id: string;
30
+ /** Its name in reports. */
31
+ label: string;
32
+ /** What every one of its turns sends the provider, in place of the agent's own `modelProviderOptions`. */
33
+ providerOptions?: ProviderOptions;
34
+ capabilities: EvalModelCapabilities;
35
+ prices: EvalModelPrices;
36
+ }
37
+ /** The judge of rubrics: one model for the whole run, never one of its candidates. */
38
+ export interface EvalJudgeModel {
39
+ /** The provider's id for it, which the judge's factory (or the model factory, with `purpose: 'judge'`) builds. */
40
+ id: string;
41
+ /** Its name in reports. Default: its id. */
42
+ label?: string;
43
+ /** What every verdict's request sends the provider. */
44
+ providerOptions?: ProviderOptions;
45
+ /** What its verdicts cost: counted toward the run's spend, never toward a candidate's. Required for a matrix whose suites have rubrics. */
46
+ prices?: EvalModelPrices;
47
+ }
48
+ /** A list of models that cannot be run, with every reason. */
49
+ export declare class EvalModelsError extends Error {
50
+ readonly source: string;
51
+ readonly problems: readonly string[];
52
+ constructor(source: string, problems: readonly string[]);
53
+ }
54
+ /** A file-system-safe form of a name: what a suite's and a model's recordings are filed under. */
55
+ export declare const slug: (name: string, fallback?: string) => string;
56
+ /** Every problem with a model's prices, each with where it is. */
57
+ export declare function pricesProblems(value: unknown, at: string): string[];
58
+ /**
59
+ * The candidates, checked: each one's id, label, capabilities and prices; no
60
+ * two with one id, or with ids filed under one name; and none that is the
61
+ * judge.
62
+ */
63
+ export declare function checkCandidates(value: unknown, source: string, judge?: EvalJudgeModel): EvalCandidate[];
64
+ /** The judge, checked: an id, and prices when given. */
65
+ export declare function checkJudge(judge: EvalJudgeModel, source: string): EvalJudgeModel;
66
+ /** Read a file of candidates: `.json`, `.yaml`/`.yml`, or a module (`.mjs`, `.js`) whose default export is the list. */
67
+ export declare function readModelsFile(path: string): Promise<unknown>;
68
+ /**
69
+ * The candidates `--models` names: a file of them; `all`, the configuration's
70
+ * every one; or ids, comma-separated, of the configuration's.
71
+ */
72
+ export declare function selectModels(spec: string, configured: readonly EvalCandidate[] | undefined, judge?: EvalJudgeModel): Promise<EvalCandidate[]>;
73
+ /** What one model call cost at `prices`, in US dollars: its uncached input, cache reads, cache writes and output, each at its price. */
74
+ export declare function callCost(call: Pick<EvalModelCall, 'noCacheTokens' | 'cacheReadTokens' | 'cacheWriteTokens' | 'outputTokens'>, prices: EvalModelPrices): number;
75
+ /** What calls cost together; 0 with no prices. */
76
+ export declare function callsCost(calls: readonly EvalModelCall[], prices: EvalModelPrices | undefined): number;
77
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,4DAA4D;AAC5D,MAAM,WAAW,eAAe;IAC9B,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,2FAA2F;AAC3F,MAAM,WAAW,qBAAqB;IACpC,6GAA6G;IAC7G,WAAW,EAAE,OAAO,CAAC;IACrB,wFAAwF;IACxF,gBAAgB,EAAE,OAAO,CAAC;IAC1B,8EAA8E;IAC9E,WAAW,EAAE,OAAO,CAAC;IACrB,6FAA6F;IAC7F,MAAM,EAAE,OAAO,CAAC;IAChB,iGAAiG;IACjG,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,sGAAsG;IACtG,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,0GAA0G;IAC1G,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,YAAY,EAAE,qBAAqB,CAAC;IACpC,M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AAI,EAAE,IAAI,CAAC,aAAa,EAAE,eAAe,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,cAAc,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,MAAM,CAI9J;AAED,kDAAkD;AAClD,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,SAAS,GAAG,MAAM,CAGtG"}
package/dist/models.js ADDED
@@ -0,0 +1,163 @@
1
+ /**
2
+ * The models a matrix runs: each candidate's id, label, provider options,
3
+ * capabilities and prices, as the product's own model registry declares them;
4
+ * and the judge of rubrics, which is fixed for a run and is never a candidate.
5
+ *
6
+ * Nothing here names a model. A product hands its candidates to the
7
+ * configuration (`models`), or in a file (`agent-evals --models <file>`), and
8
+ * its model factory builds whichever one it is handed.
9
+ */
10
+ import { existsSync, readFileSync } from 'node:fs';
11
+ import { extname, resolve } from 'node:path';
12
+ import { pathToFileURL } from 'node:url';
13
+ import { parse as parseYaml } from 'yaml';
14
+ /** A list of models that cannot be run, with every reason. */
15
+ export class EvalModelsError extends Error {
16
+ source;
17
+ problems;
18
+ constructor(source, problems) {
19
+ super(`${source} is not a list of models agent-evals can run:\n${problems.map((p) => ` - ${p}`).join('\n')}`);
20
+ this.source = source;
21
+ this.problems = problems;
22
+ this.name = 'EvalModelsError';
23
+ }
24
+ }
25
+ /** A file-system-safe form of a name: what a suite's and a model's recordings are filed under. */
26
+ export const slug = (name, fallback = 'suite') => name
27
+ .toLowerCase()
28
+ .replace(/[^a-z0-9_-]+/g, '-')
29
+ .replace(/^-+|-+$/g, '') || fallback;
30
+ const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
31
+ const PRICE_KEYS = ['input', 'output', 'cacheRead', 'cacheWrite'];
32
+ const CAPABILITY_FLAGS = ['promptCache', 'forcedToolChoice', 'temperature', 'vision'];
33
+ /** Every problem with a model's prices, each with where it is. */
34
+ export function pricesProblems(value, at) {
35
+ if (!isObject(value))
36
+ return [`${at}: give its prices per million tokens ({ ${PRICE_KEYS.join(', ')} })`];
37
+ const problems = [];
38
+ for (const key of PRICE_KEYS) {
39
+ const price = value[key];
40
+ if (typeof price !== 'number' || !Number.isFinite(price) || price < 0)
41
+ problems.push(`${at}.${key}: a price is a number of dollars per million tokens, 0 or more`);
42
+ }
43
+ for (const key of Object.keys(value))
44
+ if (!PRICE_KEYS.includes(key))
45
+ problems.push(`${at}.${key}: not a price (${PRICE_KEYS.join(', ')})`);
46
+ return problems;
47
+ }
48
+ /**
49
+ * The candidates, checked: each one's id, label, capabilities and prices; no
50
+ * two with one id, or with ids filed under one name; and none that is the
51
+ * judge.
52
+ */
53
+ export function checkCandidates(value, source, judge) {
54
+ if (!Array.isArray(value) || value.length === 0)
55
+ throw new EvalModelsError(source, ['it must be a list of one model or more']);
56
+ const problems = [];
57
+ const ids = new Map();
58
+ value.forEach((entry, i) => {
59
+ const at = `[${i}]`;
60
+ if (!isObject(entry)) {
61
+ problems.push(`${at}: a model is an object ({ id, label, capabilities, prices })`);
62
+ return;
63
+ }
64
+ const id = entry.id;
65
+ if (typeof id !== 'string' || !id.trim())
66
+ problems.push(`${at}.id: give the provider's id for the model`);
67
+ else {
68
+ const filed = slug(id, '');
69
+ if (!filed)
70
+ problems.push(`${at}.id: "${id}" has no letter or digit to file its recordings under`);
71
+ const twin = ids.get(filed);
72
+ if (twin !== undefined)
73
+ problems.push(`${at}.id: "${id}" ${twin === id ? 'is listed twice' : `and "${twin}" are filed under one name (${filed})`}`);
74
+ ids.set(filed, id);
75
+ if (judge && id === judge.id)
76
+ problems.push(`${at}.id: "${id}" is the judge, and the judge is never a candidate`);
77
+ }
78
+ if (typeof entry.label !== 'string' || !entry.label.trim())
79
+ problems.push(`${at}.label: give the model's name in reports`);
80
+ if (entry.providerOptions !== undefined && !isObject(entry.providerOptions))
81
+ problems.push(`${at}.providerOptions: an object by provider, as the provider takes it`);
82
+ const capabilities = entry.capabilities;
83
+ if (!isObject(capabilities))
84
+ problems.push(`${at}.capabilities: give what it can be asked for ({ ${CAPABILITY_FLAGS.join(', ')}, contextWindow })`);
85
+ else {
86
+ for (const flag of CAPABILITY_FLAGS)
87
+ if (typeof capabilities[flag] !== 'boolean')
88
+ problems.push(`${at}.capabilities.${flag}: true or false`);
89
+ const window = capabilities.contextWindow;
90
+ if (window !== undefined && (typeof window !== 'number' || !Number.isInteger(window) || window <= 0))
91
+ problems.push(`${at}.capabilities.contextWindow: a number of tokens`);
92
+ }
93
+ problems.push(...pricesProblems(entry.prices, `${at}.prices`));
94
+ });
95
+ if (problems.length > 0)
96
+ throw new EvalModelsError(source, problems);
97
+ return value;
98
+ }
99
+ /** The judge, checked: an id, and prices when given. */
100
+ export function checkJudge(judge, source) {
101
+ const problems = [];
102
+ if (typeof judge.id !== 'string' || !judge.id.trim())
103
+ problems.push('judgeModel.id: give the provider\'s id for the judge');
104
+ if (judge.prices !== undefined)
105
+ problems.push(...pricesProblems(judge.prices, 'judgeModel.prices'));
106
+ if (problems.length > 0)
107
+ throw new EvalModelsError(source, problems);
108
+ return judge;
109
+ }
110
+ /** Read a file of candidates: `.json`, `.yaml`/`.yml`, or a module (`.mjs`, `.js`) whose default export is the list. */
111
+ export async function readModelsFile(path) {
112
+ const ext = extname(path).toLowerCase();
113
+ if (ext === '.json')
114
+ return JSON.parse(readFileSync(path, 'utf8'));
115
+ if (ext === '.yaml' || ext === '.yml')
116
+ return parseYaml(readFileSync(path, 'utf8'));
117
+ if (ext === '.mjs' || ext === '.js') {
118
+ const loaded = (await import(pathToFileURL(path).href));
119
+ return loaded.default ?? loaded.models;
120
+ }
121
+ throw new EvalModelsError(path, [`a list of models is a .json, .yaml, .yml, .mjs or .js file, not ${ext || 'a file with no extension'}`]);
122
+ }
123
+ /**
124
+ * The candidates `--models` names: a file of them; `all`, the configuration's
125
+ * every one; or ids, comma-separated, of the configuration's.
126
+ */
127
+ export async function selectModels(spec, configured, judge) {
128
+ const path = resolve(spec);
129
+ if (existsSync(path))
130
+ return checkCandidates(await readModelsFile(path), path, judge);
131
+ if (!configured || configured.length === 0) {
132
+ throw new EvalModelsError('--models', [`there is no file ${path}, and the configuration lists no models (\`models\`) to choose "${spec}" from`]);
133
+ }
134
+ const all = checkCandidates(configured, 'the configuration\'s models', judge);
135
+ if (spec === 'all')
136
+ return all;
137
+ const ids = spec
138
+ .split(',')
139
+ .map((id) => id.trim())
140
+ .filter(Boolean);
141
+ const unknown = ids.filter((id) => !all.some((m) => m.id === id));
142
+ if (ids.length === 0 || unknown.length > 0) {
143
+ throw new EvalModelsError('--models', [
144
+ `${unknown.length ? `no model ${unknown.map((id) => `"${id}"`).join(', ')}` : 'no model named'} in the configuration (${all.map((m) => m.id).join(', ')})`,
145
+ ]);
146
+ }
147
+ if (new Set(ids).size !== ids.length)
148
+ throw new EvalModelsError('--models', ['a model is named twice']);
149
+ return ids.map((id) => all.find((m) => m.id === id));
150
+ }
151
+ /** One million. */
152
+ const PER = 1_000_000;
153
+ /** What one model call cost at `prices`, in US dollars: its uncached input, cache reads, cache writes and output, each at its price. */
154
+ export function callCost(call, prices) {
155
+ return ((call.noCacheTokens * prices.input + call.cacheReadTokens * prices.cacheRead + call.cacheWriteTokens * prices.cacheWrite + call.outputTokens * prices.output) / PER);
156
+ }
157
+ /** What calls cost together; 0 with no prices. */
158
+ export function callsCost(calls, prices) {
159
+ if (!prices)
160
+ return 0;
161
+ return calls.reduce((sum, call) => sum + callCost(call, prices), 0);
162
+ }
163
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,IAAI,SAAS,EA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,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAE,CAAC,CAAC;AACxD,CAAC;AAED,mBAAmB;AACnB,MAAM,GAAG,GAAG,SAAS,CAAC;AAEtB,wIAAwI;AACxI,MAAM,UAAU,QAAQ,CAAC,IAAoG,EAAE,MAAuB;IACpJ,OAAO,CACL,CAAC,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,CACpK,CAAC;AACJ,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,SAAS,CAAC,KAA+B,EAAE,MAAmC;IAC5F,IAAI,CAAC,MAAM;QAAE,OAAO,CAAC,CAAC;IACtB,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AACtE,CAAC"}
package/dist/report.d.ts CHANGED
@@ -6,8 +6,8 @@
6
6
  * the cases that failed: in JUnit, as an error rather than a failure.
7
7
  */
8
8
  import { type EvalCaseResult, type EvalReport } from './run.js';
9
- /** A case's status as its line starts: `PASS`, `FAIL`, or `JUDGE` when only the judge failed. */
10
- export declare const statusWord: (c: EvalCaseResult) => "PASS" | "JUDGE" | "FAIL";
9
+ /** A case's status as its line starts: `PASS`, `FAIL`, `JUDGE` when only the judge failed, or `STOP` when the spend guard stopped it. */
10
+ export declare const statusWord: (c: EvalCaseResult) => "STOP" | "PASS" | "JUDGE" | "FAIL";
11
11
  /** A case's line, and under it every failure. */
12
12
  export declare function caseLines(c: EvalCaseResult): string[];
13
13
  /** The report's last line: how many passed, failed and could not be judged. */
@@ -1 +1 @@
1
- {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAe,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAE7E,iGAAiG;AACjG,eAAO,MAAM,UAAU,GAAI,GAAG,cAAc,8BAAkF,CAAC;AAE/H,iDAAiD;AACjD,wBAAgB,SAAS,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,EAAE,CAErD;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAItD;AAED,uFAAuF;AACvF,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAEvD;AAiBD,kGAAkG;AAClG,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAoBtD"}
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAe,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAE7E,yIAAyI;AACzI,eAAO,MAAM,UAAU,GAAI,GAAG,cAAc,uCAAyG,CAAC;AAKtJ,iDAAiD;AACjD,wBAAgB,SAAS,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,EAAE,CAKrD;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAItD;AAED,uFAAuF;AACvF,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAEvD;AAiBD,kGAAkG;AAClG,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAuBtD"}
package/dist/report.js CHANGED
@@ -6,11 +6,16 @@
6
6
  * the cases that failed: in JUnit, as an error rather than a failure.
7
7
  */
8
8
  import { failureLine } from './run.js';
9
- /** A case's status as its line starts: `PASS`, `FAIL`, or `JUDGE` when only the judge failed. */
10
- export const statusWord = (c) => (c.status === 'passed' ? 'PASS' : c.status === 'unjudged' ? 'JUDGE' : 'FAIL');
9
+ /** A case's status as its line starts: `PASS`, `FAIL`, `JUDGE` when only the judge failed, or `STOP` when the spend guard stopped it. */
10
+ export const statusWord = (c) => (c.stoppedBy ? 'STOP' : c.status === 'passed' ? 'PASS' : c.status === 'unjudged' ? 'JUDGE' : 'FAIL');
11
+ /** In a model matrix, which model and run a case is: `[model] run 2 `. */
12
+ const slotOf = (c) => (c.model !== undefined ? `[${c.model}]${c.run !== undefined ? ` run ${c.run}` : ''} ` : '');
11
13
  /** A case's line, and under it every failure. */
12
14
  export function caseLines(c) {
13
- return [`${statusWord(c).padEnd(4)} ${c.suite} › ${c.scenario} [${c.channel}] ${c.title} (${c.durationMs} ms)`, ...c.failures.map((f) => ` ${failureLine(f)}`)];
15
+ return [
16
+ `${statusWord(c).padEnd(4)} ${slotOf(c)}${c.suite} › ${c.scenario} [${c.channel}] ${c.title} (${c.durationMs} ms)`,
17
+ ...c.failures.map((f) => ` ${failureLine(f)}`),
18
+ ];
14
19
  }
15
20
  /** The report's last line: how many passed, failed and could not be judged. */
16
21
  export function summaryLine(report) {
@@ -45,7 +50,10 @@ export function junitReport(report) {
45
50
  const time = cases.reduce((ms, c) => ms + c.durationMs, 0) / 1000;
46
51
  const body = cases
47
52
  .map((c) => {
48
- const head = ` <testcase classname="${xml(`${name}.${c.channel}`)}" name="${xml(`${c.scenario}: ${c.title}`)}" time="${(c.durationMs / 1000).toFixed(3)}"`;
53
+ // In a model matrix, each model's cases are a class of their own, and each run of a case its own test.
54
+ const classname = c.model !== undefined ? `${name}.${c.model}.${c.channel}` : `${name}.${c.channel}`;
55
+ const run = c.run !== undefined && c.run > 1 ? ` (run ${c.run})` : '';
56
+ const head = ` <testcase classname="${xml(classname)}" name="${xml(`${c.scenario}: ${c.title}${run}`)}" time="${(c.durationMs / 1000).toFixed(3)}"`;
49
57
  if (c.passed)
50
58
  return `${head}/>`;
51
59
  const message = c.failures.map(failureLine).join('\n');
@@ -1 +1 @@
1
- {"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAwC,MAAM,UAAU,CAAC;AAE7E,iGAAiG;AACjG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAiB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/H,iDAAiD;AACjD,MAAM,UAAU,SAAS,CAAC,CAAiB;IACzC,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,UAAU,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5K,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,WAAW,CAAC,MAAkB;IAC5C,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,wBAAwB,CAAC;IACpJ,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,QAAQ,yCAAyC,CAAC,CAAC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OAAO,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvD,mFAAmF;YACnF,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;YAC1D,OAAO,GAAG,IAAI,aAAa,GAAG,aAAa,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,oBAAoB,CAAC;QACrJ,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,OAAO,sBAAsB,GAAG,CAAC,IAAI,CAAC,YAAY,KAAK,CAAC,MAAM,eAAe,MAAM,aAAa,MAAM,WAAW,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,IAAI,kBAAkB,CAAC;IAChK,CAAC,CAAC,CAAC;IACH,OAAO,8DAA8D,MAAM,CAAC,KAAK,CAAC,MAAM,eAAe,MAAM,CAAC,MAAM,aAAa,MAAM,CAAC,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC;AAC9L,CAAC"}
package/dist/run.d.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  import { type ApprovalPreview } from '@ouispec/agent-core';
2
2
  import { type TurnOutcome } from '@ouispec/agent-worker';
3
3
  import type { AgentEvalExpectation, AgentEvalScenario, AgentEvalSuite } from '@ouispec/contract';
4
- import type { AgentEvalConfig, EvalMode } from './config.js';
5
- import { judge, type JudgeOptions } from './judge.js';
4
+ import type { AgentEvalConfig, EvalAgentConfig, EvalMode } from './config.js';
5
+ import { judge, type JudgeAsk } from './judge.js';
6
+ import { type EvalCandidate } from './models.js';
6
7
  import { type EvalPageRun } from './page.js';
7
- import { type EvalTurnUsage } from './usage.js';
8
+ import type { EvalTarget, SpendGuard } from './spend.js';
9
+ import { type EvalModelCall, type EvalTurnUsage } from './usage.js';
10
+ export { mergeExpectations } from './expectations.js';
8
11
  /** One assertion that did not hold, or why a case could not be run. */
9
12
  export interface EvalFailure {
10
13
  /** The turn it is about (0-based, in the scenario's turns); -1 for the case as a whole. */
@@ -62,6 +65,19 @@ export interface EvalTurnRecord {
62
65
  at: string;
63
66
  ran: EvalPageRun[];
64
67
  } | null;
68
+ /**
69
+ * Its calls that ran no tool because the model wrote them wrong: input that
70
+ * failed the tool's schema or would not parse, or a tool that does not exist.
71
+ */
72
+ invalidToolCalls: number;
73
+ /**
74
+ * Whether it declined: `provider`, a model call the provider stopped for its
75
+ * content; `reply`, a reply in the words of a refusal (`config.refusal`) on a
76
+ * turn that does not expect one; null otherwise.
77
+ */
78
+ refusal: 'provider' | 'reply' | null;
79
+ /** What its model calls cost at the candidate's prices, in US dollars; null outside a model matrix. */
80
+ costUsd: number | null;
65
81
  outcome: TurnOutcome['status'];
66
82
  stopReason?: string;
67
83
  }
@@ -81,6 +97,17 @@ export interface EvalCaseResult {
81
97
  cassette: string;
82
98
  modelRequests: number;
83
99
  durationMs: number;
100
+ /** In a model matrix: the candidate's id, and the run (1 for the first). */
101
+ model?: string;
102
+ run?: number;
103
+ /** What the agent's model calls cost at the candidate's prices, in US dollars; null outside a model matrix. */
104
+ costUsd: number | null;
105
+ /** The judge's calls, for the rubrics: never the agent's. */
106
+ judgeCalls: EvalModelCall[];
107
+ /** What the judge's calls cost at its prices, in US dollars; null when it has none. */
108
+ judgeCostUsd: number | null;
109
+ /** `max-cost`: the spend guard refused a request of this case, so it did not run to its end. */
110
+ stoppedBy?: 'max-cost';
84
111
  }
85
112
  export interface EvalReport {
86
113
  mode: EvalMode;
@@ -118,22 +145,42 @@ export interface EvalRunOptions {
118
145
  /** Where relative paths start when the configuration does not say (`config.root`). Default: the working directory. */
119
146
  root?: string;
120
147
  }
148
+ /**
149
+ * Every scenario on every channel it runs on, its suites read and checked,
150
+ * narrowed to the channels and scenarios asked for; and the recordings'
151
+ * directory.
152
+ */
153
+ export declare function evalTargets(config: AgentEvalConfig, options?: Pick<EvalRunOptions, 'channels' | 'scenarios' | 'root'>): {
154
+ targets: EvalTarget[];
155
+ cassettes: string;
156
+ };
121
157
  /** Every scenario on every channel it runs on, as cases to run. */
122
158
  export declare function evalCases(config: AgentEvalConfig, options?: EvalRunOptions): Promise<EvalCase[]>;
123
159
  /** Runs every case, one after another, and reports them all. */
124
160
  export declare function runEvals(config: AgentEvalConfig, options?: EvalRunOptions & {
125
161
  onCase?: (result: EvalCaseResult) => void;
126
162
  }): Promise<EvalReport>;
127
- export declare function runEvalCase(config: AgentEvalConfig, target: {
163
+ /**
164
+ * The agent's configuration as a candidate runs it: the candidate's provider
165
+ * options in place of the agent's own, and only what the model takes (no
166
+ * forced tool choice, no temperature where it takes none).
167
+ */
168
+ export declare function agentForCandidate(agent: EvalAgentConfig, candidate: EvalCandidate): EvalAgentConfig;
169
+ /** One case to run: a scenario on a channel, and in a model matrix the candidate, the run, and the run's spend guard. */
170
+ export interface EvalCaseTarget {
128
171
  suite: AgentEvalSuite;
129
172
  scenario: AgentEvalScenario;
130
173
  channel: string;
131
174
  mode: EvalMode;
132
175
  cassettes: string;
133
- }): Promise<EvalCaseResult>;
134
- /** A turn's general expectation and its channel's, as one: lists joined, the channel's single values winning. */
135
- export declare function mergeExpectations(general?: AgentEvalExpectation, channel?: AgentEvalExpectation): AgentEvalExpectation;
136
- type Judge = Parameters<typeof judge>[0];
176
+ candidate?: EvalCandidate;
177
+ /** The run, from 1. */
178
+ run?: number;
179
+ guard?: SpendGuard;
180
+ }
181
+ export declare function runEvalCase(config: AgentEvalConfig, target: EvalCaseTarget): Promise<EvalCaseResult>;
182
+ /** The judge of a scenario's rubrics; null for one that asks it nothing. */
183
+ type Judge = Parameters<typeof judge>[0] | null;
137
184
  /** One way a turn broke its expectation; `kind: 'judge'` when a rubric could not be judged at all. */
138
185
  export interface CheckFailure {
139
186
  assertion: string;
@@ -142,7 +189,6 @@ export interface CheckFailure {
142
189
  }
143
190
  /** Every way a turn breaks its expectation. */
144
191
  export declare function check(expect: AgentEvalExpectation, record: EvalTurnRecord, stored: string, judgeModel: Judge, options?: {
145
- judge?: JudgeOptions;
192
+ judge?: JudgeAsk;
146
193
  }): Promise<CheckFailure[]>;
147
- export {};
148
194
  //# sourceMappingURL=run.d.ts.map