@vitest-evals/core 0.13.1 → 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/dist/index.d.mts +404 -201
- package/dist/index.d.ts +404 -201
- package/dist/index.js +386 -146
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +377 -144
- package/dist/index.mjs.map +1 -1
- package/dist/node.d.mts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +146 -134
- package/dist/node.js.map +1 -1
- package/dist/node.mjs +146 -134
- package/dist/node.mjs.map +1 -1
- package/dist/{workspace-BNgjyW7W.d.mts → workspace-DSZKph1P.d.mts} +90 -66
- package/dist/{workspace-BNgjyW7W.d.ts → workspace-DSZKph1P.d.ts} +90 -66
- package/package.json +1 -1
package/dist/node.mjs
CHANGED
|
@@ -3,13 +3,13 @@ import { readdir, readFile, stat } from "fs/promises";
|
|
|
3
3
|
import { extname, isAbsolute, relative, resolve, sep } from "path";
|
|
4
4
|
|
|
5
5
|
// src/report/workspace.ts
|
|
6
|
-
import { z as
|
|
6
|
+
import { z as z8 } from "zod";
|
|
7
7
|
|
|
8
8
|
// src/report/metadata.ts
|
|
9
|
-
import { z as
|
|
9
|
+
import { z as z6 } from "zod";
|
|
10
10
|
|
|
11
11
|
// src/harness/index.ts
|
|
12
|
-
import { z as
|
|
12
|
+
import { z as z5 } from "zod";
|
|
13
13
|
|
|
14
14
|
// src/json.ts
|
|
15
15
|
import { z } from "zod";
|
|
@@ -57,10 +57,52 @@ function isRecord(value) {
|
|
|
57
57
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
// src/harness/errors.ts
|
|
61
|
+
import { z as z3 } from "zod";
|
|
62
|
+
var NormalizedErrorSchema = z3.object({
|
|
63
|
+
message: z3.string(),
|
|
64
|
+
type: z3.string().optional()
|
|
65
|
+
}).catchall(JsonValueSchema);
|
|
66
|
+
|
|
67
|
+
// src/harness/transcript.ts
|
|
68
|
+
import { z as z4 } from "zod";
|
|
69
|
+
var TranscriptToolCallEventSchema = z4.object({
|
|
70
|
+
type: z4.literal("tool_call"),
|
|
71
|
+
id: z4.string(),
|
|
72
|
+
name: z4.string(),
|
|
73
|
+
arguments: JsonObjectSchema.optional(),
|
|
74
|
+
startedAt: z4.string().optional(),
|
|
75
|
+
finishedAt: z4.string().optional(),
|
|
76
|
+
durationMs: FiniteNumberSchema.optional(),
|
|
77
|
+
metadata: JsonObjectSchema.optional()
|
|
78
|
+
}).strict();
|
|
79
|
+
var TranscriptMessageEventSchema = z4.object({
|
|
80
|
+
type: z4.literal("message"),
|
|
81
|
+
role: z4.enum(["system", "user", "assistant"]),
|
|
82
|
+
content: JsonValueSchema.optional(),
|
|
83
|
+
metadata: JsonObjectSchema.optional()
|
|
84
|
+
}).strict();
|
|
85
|
+
var TranscriptToolResultEventSchema = z4.object({
|
|
86
|
+
type: z4.literal("tool_result"),
|
|
87
|
+
toolCallId: z4.string(),
|
|
88
|
+
name: z4.string().optional(),
|
|
89
|
+
content: JsonValueSchema.optional(),
|
|
90
|
+
error: NormalizedErrorSchema.optional(),
|
|
91
|
+
startedAt: z4.string().optional(),
|
|
92
|
+
finishedAt: z4.string().optional(),
|
|
93
|
+
durationMs: FiniteNumberSchema.optional(),
|
|
94
|
+
metadata: JsonObjectSchema.optional()
|
|
95
|
+
}).strict();
|
|
96
|
+
var TranscriptEventSchema = z4.discriminatedUnion("type", [
|
|
97
|
+
TranscriptMessageEventSchema,
|
|
98
|
+
TranscriptToolCallEventSchema,
|
|
99
|
+
TranscriptToolResultEventSchema
|
|
100
|
+
]);
|
|
101
|
+
|
|
60
102
|
// src/harness/index.ts
|
|
61
|
-
var UsageSummarySchema =
|
|
62
|
-
provider:
|
|
63
|
-
model:
|
|
103
|
+
var UsageSummarySchema = z5.object({
|
|
104
|
+
provider: z5.string().optional(),
|
|
105
|
+
model: z5.string().optional(),
|
|
64
106
|
inputTokens: FiniteNumberSchema.optional(),
|
|
65
107
|
outputTokens: FiniteNumberSchema.optional(),
|
|
66
108
|
reasoningTokens: FiniteNumberSchema.optional(),
|
|
@@ -69,141 +111,111 @@ var UsageSummarySchema = z3.object({
|
|
|
69
111
|
retries: FiniteNumberSchema.optional(),
|
|
70
112
|
metadata: JsonObjectSchema.optional()
|
|
71
113
|
}).strict();
|
|
72
|
-
var TimingSummarySchema =
|
|
114
|
+
var TimingSummarySchema = z5.object({
|
|
73
115
|
totalMs: FiniteNumberSchema.optional(),
|
|
74
116
|
metadata: JsonObjectSchema.optional()
|
|
75
117
|
}).strict();
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}).catchall(JsonValueSchema);
|
|
80
|
-
var ToolCallRecordSchema = z3.object({
|
|
81
|
-
id: z3.string().optional(),
|
|
82
|
-
name: z3.string(),
|
|
83
|
-
arguments: JsonObjectSchema.optional(),
|
|
84
|
-
result: JsonValueSchema.optional(),
|
|
85
|
-
error: NormalizedErrorSchema.optional(),
|
|
86
|
-
startedAt: z3.string().optional(),
|
|
87
|
-
finishedAt: z3.string().optional(),
|
|
88
|
-
durationMs: FiniteNumberSchema.optional(),
|
|
89
|
-
metadata: JsonObjectSchema.optional()
|
|
90
|
-
}).strict();
|
|
91
|
-
var NormalizedMessageSchema = z3.object({
|
|
92
|
-
role: z3.enum(["system", "user", "assistant", "tool"]),
|
|
93
|
-
content: JsonValueSchema.optional(),
|
|
94
|
-
toolCalls: z3.array(ToolCallRecordSchema).optional(),
|
|
95
|
-
metadata: JsonObjectSchema.optional()
|
|
118
|
+
var ToolCallBaseSchema = z5.object({
|
|
119
|
+
name: z5.string(),
|
|
120
|
+
arguments: JsonObjectSchema.optional()
|
|
96
121
|
}).strict();
|
|
97
|
-
var
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
122
|
+
var ToolCallSchema = z5.discriminatedUnion("status", [
|
|
123
|
+
ToolCallBaseSchema.extend({
|
|
124
|
+
status: z5.literal("pending")
|
|
125
|
+
}).strict(),
|
|
126
|
+
ToolCallBaseSchema.extend({
|
|
127
|
+
status: z5.literal("ok"),
|
|
128
|
+
result: JsonValueSchema.optional()
|
|
129
|
+
}).strict(),
|
|
130
|
+
ToolCallBaseSchema.extend({
|
|
131
|
+
status: z5.literal("error"),
|
|
132
|
+
error: NormalizedErrorSchema
|
|
133
|
+
}).strict()
|
|
134
|
+
]);
|
|
135
|
+
var NormalizedSessionSchema = z5.object({
|
|
136
|
+
events: z5.array(TranscriptEventSchema),
|
|
137
|
+
provider: z5.string().optional(),
|
|
138
|
+
model: z5.string().optional(),
|
|
101
139
|
metadata: JsonObjectSchema.optional()
|
|
102
140
|
}).strict();
|
|
103
141
|
var NormalizedSpanAttributesSchema = JsonObjectSchema;
|
|
104
|
-
var NormalizedSpanEventSchema =
|
|
105
|
-
name:
|
|
106
|
-
timestamp:
|
|
142
|
+
var NormalizedSpanEventSchema = z5.object({
|
|
143
|
+
name: z5.string(),
|
|
144
|
+
timestamp: z5.string().optional(),
|
|
107
145
|
attributes: NormalizedSpanAttributesSchema.optional()
|
|
108
146
|
}).strict();
|
|
109
|
-
var NormalizedSpanSchema =
|
|
110
|
-
id:
|
|
111
|
-
traceId:
|
|
112
|
-
parentId:
|
|
113
|
-
name:
|
|
114
|
-
kind:
|
|
115
|
-
startedAt:
|
|
116
|
-
finishedAt:
|
|
147
|
+
var NormalizedSpanSchema = z5.object({
|
|
148
|
+
id: z5.string().optional(),
|
|
149
|
+
traceId: z5.string().optional(),
|
|
150
|
+
parentId: z5.string().optional(),
|
|
151
|
+
name: z5.string(),
|
|
152
|
+
kind: z5.enum(["run", "agent", "model", "tool", "guardrail", "handoff", "custom"]).optional(),
|
|
153
|
+
startedAt: z5.string().optional(),
|
|
154
|
+
finishedAt: z5.string().optional(),
|
|
117
155
|
durationMs: FiniteNumberSchema.optional(),
|
|
118
|
-
status:
|
|
156
|
+
status: z5.enum(["ok", "error"]).optional(),
|
|
119
157
|
error: NormalizedErrorSchema.optional(),
|
|
120
158
|
attributes: NormalizedSpanAttributesSchema.optional(),
|
|
121
|
-
events:
|
|
159
|
+
events: z5.array(NormalizedSpanEventSchema).optional()
|
|
122
160
|
}).strict();
|
|
123
|
-
var NormalizedTraceSchema =
|
|
124
|
-
id:
|
|
125
|
-
name:
|
|
126
|
-
startedAt:
|
|
127
|
-
finishedAt:
|
|
161
|
+
var NormalizedTraceSchema = z5.object({
|
|
162
|
+
id: z5.string().optional(),
|
|
163
|
+
name: z5.string().optional(),
|
|
164
|
+
startedAt: z5.string().optional(),
|
|
165
|
+
finishedAt: z5.string().optional(),
|
|
128
166
|
durationMs: FiniteNumberSchema.optional(),
|
|
129
167
|
metadata: JsonObjectSchema.optional(),
|
|
130
|
-
spans:
|
|
168
|
+
spans: z5.array(NormalizedSpanSchema)
|
|
131
169
|
}).strict();
|
|
132
|
-
var HarnessRunSchema =
|
|
170
|
+
var HarnessRunSchema = z5.object({
|
|
133
171
|
output: JsonValueSchema.optional(),
|
|
134
172
|
session: NormalizedSessionSchema,
|
|
135
173
|
usage: UsageSummarySchema,
|
|
136
174
|
timings: TimingSummarySchema.optional(),
|
|
137
175
|
artifacts: JsonObjectSchema.optional(),
|
|
138
|
-
traces:
|
|
139
|
-
errors:
|
|
176
|
+
traces: z5.array(NormalizedTraceSchema).optional(),
|
|
177
|
+
errors: z5.array(JsonObjectSchema)
|
|
140
178
|
}).strict();
|
|
141
179
|
|
|
142
180
|
// src/report/metadata.ts
|
|
143
|
-
var HarnessMetaSchema =
|
|
144
|
-
name:
|
|
181
|
+
var HarnessMetaSchema = z6.object({
|
|
182
|
+
name: z6.string().optional(),
|
|
145
183
|
run: HarnessRunSchema.optional()
|
|
146
184
|
}).strict();
|
|
147
|
-
var EvalScoreSchema =
|
|
148
|
-
name:
|
|
185
|
+
var EvalScoreSchema = z6.object({
|
|
186
|
+
name: z6.string().optional(),
|
|
149
187
|
score: NullableFiniteNumberSchema,
|
|
150
188
|
metadata: JsonObjectSchema.optional()
|
|
151
189
|
}).strict();
|
|
152
|
-
var EvalMetaSchema =
|
|
153
|
-
scores:
|
|
190
|
+
var EvalMetaSchema = z6.object({
|
|
191
|
+
scores: z6.array(EvalScoreSchema).optional(),
|
|
154
192
|
avgScore: NullableFiniteNumberSchema,
|
|
155
193
|
output: JsonValueSchema.optional(),
|
|
156
|
-
thresholdFailed:
|
|
157
|
-
toolCalls:
|
|
194
|
+
thresholdFailed: z6.boolean().optional(),
|
|
195
|
+
toolCalls: z6.array(ToolCallSchema).optional()
|
|
158
196
|
}).strict();
|
|
159
|
-
var EvalTaskMetaSchema =
|
|
197
|
+
var EvalTaskMetaSchema = z6.object({
|
|
160
198
|
eval: EvalMetaSchema.optional(),
|
|
161
199
|
harness: HarnessMetaSchema.optional()
|
|
162
200
|
}).strict();
|
|
163
|
-
var LenientToolCallRecordSchema = ToolCallRecordSchema.strip();
|
|
164
|
-
var LenientMessageSchema = NormalizedMessageSchema.extend({
|
|
165
|
-
toolCalls: z4.array(LenientToolCallRecordSchema).optional().catch(void 0)
|
|
166
|
-
}).strip();
|
|
167
|
-
var LenientSessionSchema = NormalizedSessionSchema.extend({
|
|
168
|
-
messages: z4.array(LenientMessageSchema).default([]).catch([])
|
|
169
|
-
}).strip();
|
|
170
|
-
var LenientSpanEventSchema = NormalizedSpanEventSchema.strip();
|
|
171
|
-
var LenientSpanSchema = NormalizedSpanSchema.extend({
|
|
172
|
-
events: z4.array(LenientSpanEventSchema).optional().catch(void 0)
|
|
173
|
-
}).strip();
|
|
174
|
-
var LenientTraceSchema = NormalizedTraceSchema.extend({
|
|
175
|
-
spans: z4.array(LenientSpanSchema).default([]).catch([])
|
|
176
|
-
}).strip();
|
|
177
|
-
var LenientHarnessRunSchema = HarnessRunSchema.extend({
|
|
178
|
-
session: LenientSessionSchema,
|
|
179
|
-
usage: UsageSummarySchema.strip().default({}),
|
|
180
|
-
timings: TimingSummarySchema.strip().optional(),
|
|
181
|
-
traces: z4.array(LenientTraceSchema).optional().catch(void 0)
|
|
182
|
-
}).strip();
|
|
183
|
-
var LenientHarnessMetaSchema = HarnessMetaSchema.extend({
|
|
184
|
-
run: LenientHarnessRunSchema.optional().catch(void 0)
|
|
185
|
-
}).strip();
|
|
186
|
-
var LenientEvalScoreSchema = EvalScoreSchema.strip();
|
|
187
|
-
var LenientEvalMetaSchema = EvalMetaSchema.extend({
|
|
188
|
-
scores: z4.array(LenientEvalScoreSchema).optional().catch(void 0),
|
|
189
|
-
toolCalls: z4.array(LenientToolCallRecordSchema).optional().catch(void 0)
|
|
190
|
-
}).strip();
|
|
191
201
|
function readEvalTaskMeta(input) {
|
|
192
202
|
if (!isJsonObject(input)) {
|
|
193
203
|
return void 0;
|
|
194
204
|
}
|
|
195
|
-
const evalResult = LenientEvalMetaSchema.safeParse(input.eval);
|
|
196
|
-
const harnessResult = LenientHarnessMetaSchema.safeParse(input.harness);
|
|
197
205
|
const meta = {
|
|
198
|
-
...
|
|
199
|
-
...
|
|
206
|
+
...input.eval !== void 0 ? { eval: input.eval } : {},
|
|
207
|
+
...input.harness !== void 0 ? { harness: input.harness } : {}
|
|
200
208
|
};
|
|
201
|
-
|
|
209
|
+
if (!("eval" in meta) && !("harness" in meta)) {
|
|
210
|
+
return void 0;
|
|
211
|
+
}
|
|
212
|
+
const result = EvalTaskMetaSchema.safeParse(meta);
|
|
213
|
+
return result.success ? result.data : void 0;
|
|
202
214
|
}
|
|
203
215
|
|
|
204
216
|
// src/report/vitest-json.ts
|
|
205
|
-
import { z as
|
|
206
|
-
var VitestJsonStatusSchema =
|
|
217
|
+
import { z as z7 } from "zod";
|
|
218
|
+
var VitestJsonStatusSchema = z7.enum([
|
|
207
219
|
"passed",
|
|
208
220
|
"failed",
|
|
209
221
|
"skipped",
|
|
@@ -211,38 +223,38 @@ var VitestJsonStatusSchema = z5.enum([
|
|
|
211
223
|
"todo",
|
|
212
224
|
"disabled"
|
|
213
225
|
]);
|
|
214
|
-
var VitestJsonLocationSchema =
|
|
226
|
+
var VitestJsonLocationSchema = z7.object({
|
|
215
227
|
line: FiniteNumberSchema,
|
|
216
228
|
column: FiniteNumberSchema
|
|
217
229
|
}).passthrough();
|
|
218
|
-
var VitestJsonAssertionSchema =
|
|
219
|
-
ancestorTitles:
|
|
220
|
-
fullName:
|
|
230
|
+
var VitestJsonAssertionSchema = z7.object({
|
|
231
|
+
ancestorTitles: z7.array(z7.string()).default([]),
|
|
232
|
+
fullName: z7.string(),
|
|
221
233
|
status: VitestJsonStatusSchema,
|
|
222
|
-
title:
|
|
223
|
-
meta:
|
|
234
|
+
title: z7.string(),
|
|
235
|
+
meta: z7.unknown().optional(),
|
|
224
236
|
duration: FiniteNumberSchema.nullable().optional(),
|
|
225
|
-
failureMessages:
|
|
237
|
+
failureMessages: z7.array(z7.string()).nullable().optional(),
|
|
226
238
|
location: VitestJsonLocationSchema.nullable().optional(),
|
|
227
|
-
tags:
|
|
239
|
+
tags: z7.array(z7.string()).optional()
|
|
228
240
|
}).passthrough();
|
|
229
|
-
var VitestJsonFileSchema =
|
|
230
|
-
message:
|
|
231
|
-
name:
|
|
232
|
-
status:
|
|
241
|
+
var VitestJsonFileSchema = z7.object({
|
|
242
|
+
message: z7.string(),
|
|
243
|
+
name: z7.string(),
|
|
244
|
+
status: z7.enum(["failed", "passed"]),
|
|
233
245
|
startTime: OptionalFiniteNumberSchema,
|
|
234
246
|
endTime: OptionalFiniteNumberSchema,
|
|
235
|
-
assertionResults:
|
|
247
|
+
assertionResults: z7.array(VitestJsonAssertionSchema).default([])
|
|
236
248
|
}).passthrough();
|
|
237
|
-
var VitestJsonReportSchema =
|
|
249
|
+
var VitestJsonReportSchema = z7.object({
|
|
238
250
|
numFailedTests: FiniteNumberSchema,
|
|
239
251
|
numPassedTests: FiniteNumberSchema,
|
|
240
252
|
numPendingTests: FiniteNumberSchema,
|
|
241
253
|
numTodoTests: FiniteNumberSchema,
|
|
242
254
|
numTotalTests: FiniteNumberSchema,
|
|
243
255
|
startTime: FiniteNumberSchema,
|
|
244
|
-
success:
|
|
245
|
-
testResults:
|
|
256
|
+
success: z7.boolean(),
|
|
257
|
+
testResults: z7.array(VitestJsonFileSchema).default([])
|
|
246
258
|
}).passthrough();
|
|
247
259
|
function parseVitestJsonReport(input) {
|
|
248
260
|
return parseWithSchema(VitestJsonReportSchema, input, "Vitest JSON report");
|
|
@@ -250,13 +262,13 @@ function parseVitestJsonReport(input) {
|
|
|
250
262
|
|
|
251
263
|
// src/report/workspace.ts
|
|
252
264
|
var REPORT_WORKSPACE_SCHEMA_VERSION = 1;
|
|
253
|
-
var ReportRunSchema =
|
|
254
|
-
id:
|
|
255
|
-
source:
|
|
256
|
-
status:
|
|
265
|
+
var ReportRunSchema = z8.object({
|
|
266
|
+
id: z8.string(),
|
|
267
|
+
source: z8.string().optional(),
|
|
268
|
+
status: z8.enum(["passed", "failed"]),
|
|
257
269
|
startedAt: FiniteNumberSchema.optional(),
|
|
258
270
|
durationMs: FiniteNumberSchema.optional(),
|
|
259
|
-
totals:
|
|
271
|
+
totals: z8.object({
|
|
260
272
|
total: FiniteNumberSchema,
|
|
261
273
|
passed: FiniteNumberSchema,
|
|
262
274
|
failed: FiniteNumberSchema,
|
|
@@ -266,28 +278,28 @@ var ReportRunSchema = z6.object({
|
|
|
266
278
|
evalFailed: FiniteNumberSchema
|
|
267
279
|
})
|
|
268
280
|
}).strict();
|
|
269
|
-
var ReportCaseSchema =
|
|
270
|
-
id:
|
|
271
|
-
runId:
|
|
272
|
-
source:
|
|
273
|
-
file:
|
|
274
|
-
displayFile:
|
|
275
|
-
title:
|
|
276
|
-
fullName:
|
|
277
|
-
ancestorTitles:
|
|
278
|
-
tags:
|
|
279
|
-
displayName:
|
|
281
|
+
var ReportCaseSchema = z8.object({
|
|
282
|
+
id: z8.string(),
|
|
283
|
+
runId: z8.string(),
|
|
284
|
+
source: z8.string().optional(),
|
|
285
|
+
file: z8.string(),
|
|
286
|
+
displayFile: z8.string(),
|
|
287
|
+
title: z8.string(),
|
|
288
|
+
fullName: z8.string(),
|
|
289
|
+
ancestorTitles: z8.array(z8.string()),
|
|
290
|
+
tags: z8.array(z8.string()).optional(),
|
|
291
|
+
displayName: z8.string(),
|
|
280
292
|
status: VitestJsonStatusSchema,
|
|
281
293
|
durationMs: FiniteNumberSchema.optional(),
|
|
282
294
|
location: VitestJsonLocationSchema.optional(),
|
|
283
|
-
failureMessages:
|
|
295
|
+
failureMessages: z8.array(z8.string()).default([]),
|
|
284
296
|
eval: EvalMetaSchema.optional(),
|
|
285
297
|
harness: HarnessMetaSchema.optional()
|
|
286
298
|
}).strict();
|
|
287
|
-
var ReportWorkspaceSchema =
|
|
288
|
-
schemaVersion:
|
|
289
|
-
runs:
|
|
290
|
-
cases:
|
|
299
|
+
var ReportWorkspaceSchema = z8.object({
|
|
300
|
+
schemaVersion: z8.literal(REPORT_WORKSPACE_SCHEMA_VERSION),
|
|
301
|
+
runs: z8.array(ReportRunSchema),
|
|
302
|
+
cases: z8.array(ReportCaseSchema)
|
|
291
303
|
}).strict();
|
|
292
304
|
function collectReportWorkspace(input, options = {}) {
|
|
293
305
|
const entries = Array.isArray(input) ? input : [input];
|