@cogitator-ai/evals 0.13.2 → 0.14.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/README.md +94 -14
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/plugin-evals/execute.d.ts +45 -0
- package/dist/plugin-evals/execute.d.ts.map +1 -0
- package/dist/plugin-evals/execute.js +508 -0
- package/dist/plugin-evals/execute.js.map +1 -0
- package/dist/plugin-evals/files.d.ts +17 -0
- package/dist/plugin-evals/files.d.ts.map +1 -0
- package/dist/plugin-evals/files.js +46 -0
- package/dist/plugin-evals/files.js.map +1 -0
- package/dist/plugin-evals/glob.d.ts +8 -0
- package/dist/plugin-evals/glob.d.ts.map +1 -0
- package/dist/plugin-evals/glob.js +63 -0
- package/dist/plugin-evals/glob.js.map +1 -0
- package/dist/plugin-evals/graders.d.ts +21 -0
- package/dist/plugin-evals/graders.d.ts.map +1 -0
- package/dist/plugin-evals/graders.js +198 -0
- package/dist/plugin-evals/graders.js.map +1 -0
- package/dist/plugin-evals/index.d.ts +4 -0
- package/dist/plugin-evals/index.d.ts.map +1 -0
- package/dist/plugin-evals/index.js +3 -0
- package/dist/plugin-evals/index.js.map +1 -0
- package/dist/plugin-evals/judge.d.ts +33 -0
- package/dist/plugin-evals/judge.d.ts.map +1 -0
- package/dist/plugin-evals/judge.js +73 -0
- package/dist/plugin-evals/judge.js.map +1 -0
- package/dist/plugin-evals/mocks.d.ts +34 -0
- package/dist/plugin-evals/mocks.d.ts.map +1 -0
- package/dist/plugin-evals/mocks.js +373 -0
- package/dist/plugin-evals/mocks.js.map +1 -0
- package/dist/plugin-evals/report.d.ts +4 -0
- package/dist/plugin-evals/report.d.ts.map +1 -0
- package/dist/plugin-evals/report.js +177 -0
- package/dist/plugin-evals/report.js.map +1 -0
- package/dist/plugin-evals/runner.d.ts +23 -0
- package/dist/plugin-evals/runner.d.ts.map +1 -0
- package/dist/plugin-evals/runner.js +582 -0
- package/dist/plugin-evals/runner.js.map +1 -0
- package/dist/plugin-evals/schema.d.ts +179 -0
- package/dist/plugin-evals/schema.d.ts.map +1 -0
- package/dist/plugin-evals/schema.js +194 -0
- package/dist/plugin-evals/schema.js.map +1 -0
- package/dist/plugin-evals/suite.d.ts +40 -0
- package/dist/plugin-evals/suite.d.ts.map +1 -0
- package/dist/plugin-evals/suite.js +476 -0
- package/dist/plugin-evals/suite.js.map +1 -0
- package/dist/plugin-evals/tools.d.ts +42 -0
- package/dist/plugin-evals/tools.d.ts.map +1 -0
- package/dist/plugin-evals/tools.js +136 -0
- package/dist/plugin-evals/tools.js.map +1 -0
- package/dist/plugin-evals/transcript.d.ts +35 -0
- package/dist/plugin-evals/transcript.d.ts.map +1 -0
- package/dist/plugin-evals/transcript.js +149 -0
- package/dist/plugin-evals/transcript.js.map +1 -0
- package/dist/plugin-evals/types.d.ts +378 -0
- package/dist/plugin-evals/types.d.ts.map +1 -0
- package/dist/plugin-evals/types.js +2 -0
- package/dist/plugin-evals/types.js.map +1 -0
- package/dist/reporters/html-format.d.ts +5 -2
- package/dist/reporters/html-format.d.ts.map +1 -1
- package/dist/reporters/html-format.js +6 -3
- package/dist/reporters/html-format.js.map +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Default runs per arm, as Claude Code's `runs` */
|
|
3
|
+
export declare const DEFAULT_RUNS = 3;
|
|
4
|
+
/** Default turn cap of a run */
|
|
5
|
+
export declare const DEFAULT_MAX_TURNS = 10;
|
|
6
|
+
/** Default wall-clock cap of a run, in seconds */
|
|
7
|
+
export declare const DEFAULT_TIMEOUT_SECONDS = 300;
|
|
8
|
+
/** The frontmatter of a case's `prompt.md`: an unknown key is an error */
|
|
9
|
+
export declare const PromptFrontmatterSchema: z.ZodObject<{
|
|
10
|
+
model: z.ZodOptional<z.ZodString>;
|
|
11
|
+
max_turns: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
timeout_seconds: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
|
+
append_system_prompt: z.ZodOptional<z.ZodString>;
|
|
15
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodTransform<string, string | number | boolean>>>>;
|
|
16
|
+
name: z.ZodOptional<z.ZodString>;
|
|
17
|
+
description: z.ZodOptional<z.ZodString>;
|
|
18
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
19
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
20
|
+
runs: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
expected_outcome: z.ZodOptional<z.ZodString>;
|
|
22
|
+
schema_version: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"1.1">, z.ZodLiteral<1.1>]>>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
/** A case's `case.yaml` */
|
|
25
|
+
export declare const CaseYamlSchema: z.ZodObject<{
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
execution: z.ZodOptional<z.ZodObject<{
|
|
28
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
29
|
+
model: z.ZodOptional<z.ZodString>;
|
|
30
|
+
max_turns: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
timeout_seconds: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
allowed_tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
|
+
append_system_prompt: z.ZodOptional<z.ZodString>;
|
|
34
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodTransform<string, string | number | boolean>>>>;
|
|
35
|
+
}, z.core.$strict>>;
|
|
36
|
+
context: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
scaffold_script: z.ZodOptional<z.ZodString>;
|
|
38
|
+
history_file: z.ZodOptional<z.ZodString>;
|
|
39
|
+
add_dirs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
}, z.core.$strict>>;
|
|
41
|
+
graders: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
42
|
+
description: z.ZodOptional<z.ZodString>;
|
|
43
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
44
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
runs: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
expected_outcome: z.ZodOptional<z.ZodString>;
|
|
47
|
+
schema_version: z.ZodUnion<readonly [z.ZodLiteral<"1.1">, z.ZodLiteral<1.1>]>;
|
|
48
|
+
}, z.core.$strict>;
|
|
49
|
+
export type PromptFrontmatter = z.output<typeof PromptFrontmatterSchema>;
|
|
50
|
+
export type CaseYaml = z.output<typeof CaseYamlSchema>;
|
|
51
|
+
/** A grader's options, from a `graders/*.md` frontmatter (with its body) or a `case.yaml` entry */
|
|
52
|
+
export declare const GraderSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
53
|
+
type: z.ZodLiteral<"regex">;
|
|
54
|
+
pattern: z.ZodString;
|
|
55
|
+
flags: z.ZodDefault<z.ZodString>;
|
|
56
|
+
match: z.ZodDefault<z.ZodString>;
|
|
57
|
+
target: z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
|
|
58
|
+
last_message: "last_message";
|
|
59
|
+
trace: "trace";
|
|
60
|
+
files: "files";
|
|
61
|
+
mock_calls: "mock_calls";
|
|
62
|
+
}>, z.ZodObject<{
|
|
63
|
+
source: z.ZodLiteral<"file">;
|
|
64
|
+
path: z.ZodString;
|
|
65
|
+
}, z.core.$strict>]>>;
|
|
66
|
+
name: z.ZodOptional<z.ZodString>;
|
|
67
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
68
|
+
arm: z.ZodOptional<z.ZodEnum<{
|
|
69
|
+
"with-only": "with-only";
|
|
70
|
+
both: "both";
|
|
71
|
+
}>>;
|
|
72
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
73
|
+
type: z.ZodLiteral<"tool_used">;
|
|
74
|
+
tool: z.ZodString;
|
|
75
|
+
input_match: z.ZodOptional<z.ZodString>;
|
|
76
|
+
min: z.ZodDefault<z.ZodNumber>;
|
|
77
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
name: z.ZodOptional<z.ZodString>;
|
|
79
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
80
|
+
arm: z.ZodOptional<z.ZodEnum<{
|
|
81
|
+
"with-only": "with-only";
|
|
82
|
+
both: "both";
|
|
83
|
+
}>>;
|
|
84
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
85
|
+
type: z.ZodLiteral<"tool_order">;
|
|
86
|
+
before: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
87
|
+
tool: z.ZodString;
|
|
88
|
+
input_match: z.ZodOptional<z.ZodString>;
|
|
89
|
+
}, z.core.$strict>]>;
|
|
90
|
+
after: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
91
|
+
tool: z.ZodString;
|
|
92
|
+
input_match: z.ZodOptional<z.ZodString>;
|
|
93
|
+
}, z.core.$strict>]>;
|
|
94
|
+
name: z.ZodOptional<z.ZodString>;
|
|
95
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
96
|
+
arm: z.ZodOptional<z.ZodEnum<{
|
|
97
|
+
"with-only": "with-only";
|
|
98
|
+
both: "both";
|
|
99
|
+
}>>;
|
|
100
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
101
|
+
type: z.ZodLiteral<"file_exists">;
|
|
102
|
+
path: z.ZodString;
|
|
103
|
+
exists: z.ZodDefault<z.ZodBoolean>;
|
|
104
|
+
name: z.ZodOptional<z.ZodString>;
|
|
105
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
106
|
+
arm: z.ZodOptional<z.ZodEnum<{
|
|
107
|
+
"with-only": "with-only";
|
|
108
|
+
both: "both";
|
|
109
|
+
}>>;
|
|
110
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
111
|
+
type: z.ZodLiteral<"llm">;
|
|
112
|
+
criteria: z.ZodString;
|
|
113
|
+
focus: z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
|
|
114
|
+
last_message: "last_message";
|
|
115
|
+
trace: "trace";
|
|
116
|
+
files: "files";
|
|
117
|
+
mock_calls: "mock_calls";
|
|
118
|
+
}>, z.ZodObject<{
|
|
119
|
+
source: z.ZodLiteral<"file">;
|
|
120
|
+
path: z.ZodString;
|
|
121
|
+
}, z.core.$strict>]>>;
|
|
122
|
+
name: z.ZodOptional<z.ZodString>;
|
|
123
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
124
|
+
arm: z.ZodOptional<z.ZodEnum<{
|
|
125
|
+
"with-only": "with-only";
|
|
126
|
+
both: "both";
|
|
127
|
+
}>>;
|
|
128
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
129
|
+
type: z.ZodLiteral<"baseline">;
|
|
130
|
+
baseline_file: z.ZodString;
|
|
131
|
+
criteria: z.ZodString;
|
|
132
|
+
name: z.ZodOptional<z.ZodString>;
|
|
133
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
134
|
+
arm: z.ZodOptional<z.ZodEnum<{
|
|
135
|
+
"with-only": "with-only";
|
|
136
|
+
both: "both";
|
|
137
|
+
}>>;
|
|
138
|
+
}, z.core.$strict>], "type">;
|
|
139
|
+
export type GraderInput = z.output<typeof GraderSchema>;
|
|
140
|
+
/** The frontmatter of a mocked tool, `mocks/<server>/<tool>.md` */
|
|
141
|
+
export declare const MockFrontmatterSchema: z.ZodObject<{
|
|
142
|
+
type: z.ZodDefault<z.ZodEnum<{
|
|
143
|
+
fixed: "fixed";
|
|
144
|
+
agent: "agent";
|
|
145
|
+
}>>;
|
|
146
|
+
expect: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
147
|
+
error: z.ZodDefault<z.ZodBoolean>;
|
|
148
|
+
abort_when: z.ZodOptional<z.ZodString>;
|
|
149
|
+
}, z.core.$strict>;
|
|
150
|
+
/** A server's `_tools.json`: a saved `tools/list` response, or its `tools` array */
|
|
151
|
+
export declare const ToolsListSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
152
|
+
tools: z.ZodArray<z.ZodObject<{
|
|
153
|
+
name: z.ZodString;
|
|
154
|
+
}, z.core.$loose>>;
|
|
155
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
156
|
+
name: z.ZodString;
|
|
157
|
+
}, z.core.$loose>>]>;
|
|
158
|
+
/** Zod issues in one line: `path: message, path: message` */
|
|
159
|
+
export declare function issuesText(error: z.ZodError): string;
|
|
160
|
+
/** A Markdown file split into its YAML frontmatter (empty without one) and its body */
|
|
161
|
+
export interface MarkdownParts {
|
|
162
|
+
fields: Record<string, unknown>;
|
|
163
|
+
body: string;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The frontmatter between the first two `---` lines of `text` read as a YAML mapping, and the
|
|
167
|
+
* body after it. A file without frontmatter is all body
|
|
168
|
+
*/
|
|
169
|
+
export declare function readMarkdown(text: string): MarkdownParts | {
|
|
170
|
+
error: string;
|
|
171
|
+
};
|
|
172
|
+
/** `text` read as YAML, or why it is not valid YAML */
|
|
173
|
+
export declare function readYaml(text: string): {
|
|
174
|
+
value: unknown;
|
|
175
|
+
} | {
|
|
176
|
+
error: string;
|
|
177
|
+
};
|
|
178
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
179
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/plugin-evals/schema.ts"],"names":[],"mappings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uDAAuD;AACvD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAS7E;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { parseDocument } from 'yaml';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/** Default runs per arm, as Claude Code's `runs` */
|
|
4
|
+
export const DEFAULT_RUNS = 3;
|
|
5
|
+
/** Default turn cap of a run */
|
|
6
|
+
export const DEFAULT_MAX_TURNS = 10;
|
|
7
|
+
/** Default wall-clock cap of a run, in seconds */
|
|
8
|
+
export const DEFAULT_TIMEOUT_SECONDS = 300;
|
|
9
|
+
const ENV_KEY = /^EVAL_[A-Z0-9_]*$/;
|
|
10
|
+
const schemaVersion = z.union([z.literal('1.1'), z.literal(1.1)], {
|
|
11
|
+
error: 'must be "1.1"',
|
|
12
|
+
});
|
|
13
|
+
const nonEmpty = z.string().trim().min(1, 'must not be empty');
|
|
14
|
+
const envSchema = z
|
|
15
|
+
.record(z.string(), z.union([z.string(), z.number(), z.boolean()]).transform(String))
|
|
16
|
+
.superRefine((env, context) => {
|
|
17
|
+
for (const key of Object.keys(env)) {
|
|
18
|
+
if (!ENV_KEY.test(key)) {
|
|
19
|
+
context.addIssue({
|
|
20
|
+
code: 'custom',
|
|
21
|
+
path: [key],
|
|
22
|
+
message: 'environment keys must match EVAL_[A-Z0-9_]*',
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const runFields = {
|
|
28
|
+
model: nonEmpty.optional(),
|
|
29
|
+
max_turns: z.number().int().min(1).max(200).optional(),
|
|
30
|
+
timeout_seconds: z.number().positive().max(3600).optional(),
|
|
31
|
+
allowed_tools: z.array(nonEmpty).optional(),
|
|
32
|
+
append_system_prompt: z.string().optional(),
|
|
33
|
+
env: envSchema.optional(),
|
|
34
|
+
};
|
|
35
|
+
const caseFields = {
|
|
36
|
+
name: nonEmpty.optional(),
|
|
37
|
+
description: z.string().optional(),
|
|
38
|
+
tags: z.array(nonEmpty).optional(),
|
|
39
|
+
plugins: z.array(nonEmpty).optional(),
|
|
40
|
+
runs: z.number().int().min(1).max(50).optional(),
|
|
41
|
+
expected_outcome: z.string().optional(),
|
|
42
|
+
};
|
|
43
|
+
/** The frontmatter of a case's `prompt.md`: an unknown key is an error */
|
|
44
|
+
export const PromptFrontmatterSchema = z.strictObject({
|
|
45
|
+
schema_version: schemaVersion.optional(),
|
|
46
|
+
...caseFields,
|
|
47
|
+
...runFields,
|
|
48
|
+
});
|
|
49
|
+
/** A case's `case.yaml` */
|
|
50
|
+
export const CaseYamlSchema = z.strictObject({
|
|
51
|
+
schema_version: schemaVersion,
|
|
52
|
+
...caseFields,
|
|
53
|
+
name: nonEmpty,
|
|
54
|
+
execution: z.strictObject({ ...runFields, prompt: z.string().optional() }).optional(),
|
|
55
|
+
context: z
|
|
56
|
+
.strictObject({
|
|
57
|
+
scaffold_script: nonEmpty.optional(),
|
|
58
|
+
history_file: nonEmpty.optional(),
|
|
59
|
+
add_dirs: z.array(nonEmpty).optional(),
|
|
60
|
+
})
|
|
61
|
+
.optional(),
|
|
62
|
+
graders: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
63
|
+
});
|
|
64
|
+
const regexSource = z.string().refine((source) => {
|
|
65
|
+
try {
|
|
66
|
+
new RegExp(source);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}, { error: 'is not a valid JavaScript regular expression (put case-insensitivity in flags: i)' });
|
|
73
|
+
const targetSchema = z.union([
|
|
74
|
+
z.enum(['last_message', 'trace', 'files', 'mock_calls']),
|
|
75
|
+
z.strictObject({ source: z.literal('file'), path: nonEmpty }),
|
|
76
|
+
], { error: 'must be last_message, trace, files, mock_calls or { source: file, path: <path> }' });
|
|
77
|
+
const toolMatcher = z.union([
|
|
78
|
+
nonEmpty,
|
|
79
|
+
z.strictObject({ tool: nonEmpty, input_match: regexSource.optional() }),
|
|
80
|
+
]);
|
|
81
|
+
const graderBase = {
|
|
82
|
+
name: nonEmpty.optional(),
|
|
83
|
+
weight: z.number().positive().default(1),
|
|
84
|
+
arm: z.enum(['with-only', 'both']).optional(),
|
|
85
|
+
};
|
|
86
|
+
/** A grader's options, from a `graders/*.md` frontmatter (with its body) or a `case.yaml` entry */
|
|
87
|
+
export const GraderSchema = z.discriminatedUnion('type', [
|
|
88
|
+
z.strictObject({
|
|
89
|
+
...graderBase,
|
|
90
|
+
type: z.literal('regex'),
|
|
91
|
+
pattern: regexSource,
|
|
92
|
+
flags: z
|
|
93
|
+
.string()
|
|
94
|
+
.regex(/^[imsu]*$/, 'may only hold the flags i, m, s and u')
|
|
95
|
+
.default(''),
|
|
96
|
+
match: z
|
|
97
|
+
.string()
|
|
98
|
+
.regex(/^(?:contains|not_contains|count:\d+)$/, 'must be contains, not_contains or count:N')
|
|
99
|
+
.default('contains'),
|
|
100
|
+
target: targetSchema.default('last_message'),
|
|
101
|
+
}),
|
|
102
|
+
z.strictObject({
|
|
103
|
+
...graderBase,
|
|
104
|
+
type: z.literal('tool_used'),
|
|
105
|
+
tool: nonEmpty,
|
|
106
|
+
input_match: regexSource.optional(),
|
|
107
|
+
min: z.number().int().min(0).default(1),
|
|
108
|
+
max: z.number().int().min(0).optional(),
|
|
109
|
+
}),
|
|
110
|
+
z.strictObject({
|
|
111
|
+
...graderBase,
|
|
112
|
+
type: z.literal('tool_order'),
|
|
113
|
+
before: toolMatcher,
|
|
114
|
+
after: toolMatcher,
|
|
115
|
+
}),
|
|
116
|
+
z.strictObject({
|
|
117
|
+
...graderBase,
|
|
118
|
+
type: z.literal('file_exists'),
|
|
119
|
+
path: nonEmpty,
|
|
120
|
+
exists: z.boolean().default(true),
|
|
121
|
+
}),
|
|
122
|
+
z.strictObject({
|
|
123
|
+
...graderBase,
|
|
124
|
+
type: z.literal('llm'),
|
|
125
|
+
criteria: nonEmpty,
|
|
126
|
+
focus: targetSchema.default('last_message'),
|
|
127
|
+
}),
|
|
128
|
+
z.strictObject({
|
|
129
|
+
...graderBase,
|
|
130
|
+
type: z.literal('baseline'),
|
|
131
|
+
baseline_file: nonEmpty,
|
|
132
|
+
criteria: nonEmpty,
|
|
133
|
+
}),
|
|
134
|
+
], { error: 'type must be one of regex, tool_used, tool_order, file_exists, llm, baseline' });
|
|
135
|
+
/** The frontmatter of a mocked tool, `mocks/<server>/<tool>.md` */
|
|
136
|
+
export const MockFrontmatterSchema = z.strictObject({
|
|
137
|
+
type: z.enum(['fixed', 'agent']).default('fixed'),
|
|
138
|
+
expect: z.record(z.string(), z.unknown()).optional(),
|
|
139
|
+
error: z.boolean().default(false),
|
|
140
|
+
abort_when: z.string().optional(),
|
|
141
|
+
});
|
|
142
|
+
/** A server's `_tools.json`: a saved `tools/list` response, or its `tools` array */
|
|
143
|
+
export const ToolsListSchema = z.union([
|
|
144
|
+
z.object({ tools: z.array(z.looseObject({ name: nonEmpty })) }),
|
|
145
|
+
z.array(z.looseObject({ name: nonEmpty })),
|
|
146
|
+
]);
|
|
147
|
+
/** Zod issues in one line: `path: message, path: message` */
|
|
148
|
+
export function issuesText(error) {
|
|
149
|
+
return error.issues
|
|
150
|
+
.map((issue) => {
|
|
151
|
+
const path = issue.path.map(String).join('.');
|
|
152
|
+
return path === '' ? issue.message : `${path}: ${issue.message}`;
|
|
153
|
+
})
|
|
154
|
+
.join(', ');
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The frontmatter between the first two `---` lines of `text` read as a YAML mapping, and the
|
|
158
|
+
* body after it. A file without frontmatter is all body
|
|
159
|
+
*/
|
|
160
|
+
export function readMarkdown(text) {
|
|
161
|
+
const source = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
|
|
162
|
+
const lines = source.split('\n');
|
|
163
|
+
if (lines[0]?.trimEnd() !== '---')
|
|
164
|
+
return { fields: {}, body: source };
|
|
165
|
+
const end = lines.findIndex((line, index) => index > 0 && line.trimEnd() === '---');
|
|
166
|
+
if (end === -1)
|
|
167
|
+
return { error: 'the frontmatter has no closing --- line' };
|
|
168
|
+
const parsed = readYaml(lines.slice(1, end).join('\n'));
|
|
169
|
+
if ('error' in parsed)
|
|
170
|
+
return parsed;
|
|
171
|
+
if (parsed.value === null || parsed.value === undefined) {
|
|
172
|
+
return { fields: {}, body: lines.slice(end + 1).join('\n') };
|
|
173
|
+
}
|
|
174
|
+
if (!isRecord(parsed.value))
|
|
175
|
+
return { error: 'the frontmatter is not a YAML mapping' };
|
|
176
|
+
return { fields: parsed.value, body: lines.slice(end + 1).join('\n') };
|
|
177
|
+
}
|
|
178
|
+
/** `text` read as YAML, or why it is not valid YAML */
|
|
179
|
+
export function readYaml(text) {
|
|
180
|
+
try {
|
|
181
|
+
const document = parseDocument(text, { prettyErrors: false });
|
|
182
|
+
const [problem] = document.errors;
|
|
183
|
+
if (problem)
|
|
184
|
+
return { error: `invalid YAML: ${problem.message}` };
|
|
185
|
+
return { value: document.toJS({ maxAliasCount: 100 }) };
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
return { error: `invalid YAML: ${error instanceof Error ? error.message : String(error)}` };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
export function isRecord(value) {
|
|
192
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/plugin-evals/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,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QAAQ,CAAC,MAAM,CAAC;QAClC,IAAI,OAAO;YAAE,OAAO,EAAE,KAAK,EAAE,iBAAiB,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAClE,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE,CAAY,EAAE,CAAC;IACrE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,iBAAiB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;IAC9F,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { PluginEvalCase } from './types.js';
|
|
2
|
+
/** A plugin eval run that cannot start: no plugin, no cases, a bad option */
|
|
3
|
+
export declare class PluginEvalError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
/** A case directory, loaded or with why it did not load */
|
|
7
|
+
export interface SuiteCase {
|
|
8
|
+
name: string;
|
|
9
|
+
/** The case directory relative to the eval directory */
|
|
10
|
+
path: string;
|
|
11
|
+
case?: PluginEvalCase;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
/** The plugin under test and the cases to run */
|
|
15
|
+
export interface LoadedSuite {
|
|
16
|
+
pluginRoot: string;
|
|
17
|
+
evalDir: string;
|
|
18
|
+
/** Where `results/<timestamp>/` goes */
|
|
19
|
+
resultsDir: string;
|
|
20
|
+
/** The target named an installed plugin instead of a path */
|
|
21
|
+
named: boolean;
|
|
22
|
+
cases: SuiteCase[];
|
|
23
|
+
warnings: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface SuiteOptions {
|
|
26
|
+
target?: string;
|
|
27
|
+
cwd: string;
|
|
28
|
+
evalDir?: string;
|
|
29
|
+
caseGlob?: string;
|
|
30
|
+
tags?: readonly string[];
|
|
31
|
+
/** The install path of an installed plugin by `name` or `name@marketplace`, if there is one */
|
|
32
|
+
installed: (id: string) => Promise<string | undefined>;
|
|
33
|
+
}
|
|
34
|
+
/** Whether `dir` holds a plugin manifest Cogitator reads */
|
|
35
|
+
export declare function isPluginRoot(dir: string): boolean;
|
|
36
|
+
/** Resolves the target, finds the eval directory and loads every case the filters keep */
|
|
37
|
+
export declare function loadSuite(options: SuiteOptions): Promise<LoadedSuite>;
|
|
38
|
+
/** Loads one case: its prompt, settings, graders, context and mocks */
|
|
39
|
+
export declare function loadCase(dir: string, path: string, pluginRoot: string, suiteMocks: string | undefined): PluginEvalCase;
|
|
40
|
+
//# sourceMappingURL=suite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suite.d.ts","sourceRoot":"","sources":["../../src/plugin-evals/suite.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,SAAS,CAAC;AAEjB,6EAA6E;AAC7E,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAMD,2DAA2D;AAC3D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,iDAAiD;AACjD,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,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