@vitest-evals/core 0.13.1 → 0.15.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 +392 -147
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +383 -145
- 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 +152 -135
- package/dist/node.js.map +1 -1
- package/dist/node.mjs +152 -135
- 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/index.js
CHANGED
|
@@ -29,7 +29,6 @@ __export(index_exports, {
|
|
|
29
29
|
JsonPrimitiveSchema: () => JsonPrimitiveSchema,
|
|
30
30
|
JsonValueSchema: () => JsonValueSchema,
|
|
31
31
|
NormalizedErrorSchema: () => NormalizedErrorSchema,
|
|
32
|
-
NormalizedMessageSchema: () => NormalizedMessageSchema,
|
|
33
32
|
NormalizedSessionSchema: () => NormalizedSessionSchema,
|
|
34
33
|
NormalizedSpanAttributesSchema: () => NormalizedSpanAttributesSchema,
|
|
35
34
|
NormalizedSpanEventSchema: () => NormalizedSpanEventSchema,
|
|
@@ -40,7 +39,11 @@ __export(index_exports, {
|
|
|
40
39
|
ReportRunSchema: () => ReportRunSchema,
|
|
41
40
|
ReportWorkspaceSchema: () => ReportWorkspaceSchema,
|
|
42
41
|
TimingSummarySchema: () => TimingSummarySchema,
|
|
43
|
-
|
|
42
|
+
ToolCallSchema: () => ToolCallSchema,
|
|
43
|
+
TranscriptEventSchema: () => TranscriptEventSchema,
|
|
44
|
+
TranscriptMessageEventSchema: () => TranscriptMessageEventSchema,
|
|
45
|
+
TranscriptToolCallEventSchema: () => TranscriptToolCallEventSchema,
|
|
46
|
+
TranscriptToolResultEventSchema: () => TranscriptToolResultEventSchema,
|
|
44
47
|
UsageSummarySchema: () => UsageSummarySchema,
|
|
45
48
|
VitestJsonAssertionSchema: () => VitestJsonAssertionSchema,
|
|
46
49
|
VitestJsonFileSchema: () => VitestJsonFileSchema,
|
|
@@ -50,8 +53,12 @@ __export(index_exports, {
|
|
|
50
53
|
assistantMessages: () => assistantMessages,
|
|
51
54
|
collectReportWorkspace: () => collectReportWorkspace,
|
|
52
55
|
failedSpans: () => failedSpans,
|
|
56
|
+
isMessageEvent: () => isMessageEvent,
|
|
57
|
+
isToolCallEvent: () => isToolCallEvent,
|
|
58
|
+
isToolResultEvent: () => isToolResultEvent,
|
|
53
59
|
latestAssistantMessageContent: () => latestAssistantMessageContent,
|
|
54
60
|
messagesByRole: () => messagesByRole,
|
|
61
|
+
messagesToTranscriptEvents: () => messagesToTranscriptEvents,
|
|
55
62
|
parseReportWorkspace: () => parseReportWorkspace,
|
|
56
63
|
parseVitestJsonReport: () => parseVitestJsonReport,
|
|
57
64
|
readEvalTaskMeta: () => readEvalTaskMeta,
|
|
@@ -83,7 +90,7 @@ var JsonValueSchema = import_zod.z.lazy(
|
|
|
83
90
|
var JsonObjectSchema = import_zod.z.record(import_zod.z.string(), JsonValueSchema);
|
|
84
91
|
|
|
85
92
|
// src/harness/index.ts
|
|
86
|
-
var
|
|
93
|
+
var import_zod5 = require("zod");
|
|
87
94
|
|
|
88
95
|
// src/schema-utils.ts
|
|
89
96
|
var import_zod2 = require("zod");
|
|
@@ -114,10 +121,232 @@ function isRecord(value) {
|
|
|
114
121
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
115
122
|
}
|
|
116
123
|
|
|
124
|
+
// src/harness/errors.ts
|
|
125
|
+
var import_zod3 = require("zod");
|
|
126
|
+
var NormalizedErrorSchema = import_zod3.z.object({
|
|
127
|
+
message: import_zod3.z.string(),
|
|
128
|
+
type: import_zod3.z.string().optional()
|
|
129
|
+
}).catchall(JsonValueSchema);
|
|
130
|
+
|
|
131
|
+
// src/harness/transcript.ts
|
|
132
|
+
var import_zod4 = require("zod");
|
|
133
|
+
var TranscriptToolCallEventSchema = import_zod4.z.object({
|
|
134
|
+
type: import_zod4.z.literal("tool_call"),
|
|
135
|
+
id: import_zod4.z.string(),
|
|
136
|
+
name: import_zod4.z.string(),
|
|
137
|
+
arguments: JsonObjectSchema.optional(),
|
|
138
|
+
startedAt: import_zod4.z.string().optional(),
|
|
139
|
+
finishedAt: import_zod4.z.string().optional(),
|
|
140
|
+
durationMs: FiniteNumberSchema.optional(),
|
|
141
|
+
metadata: JsonObjectSchema.optional()
|
|
142
|
+
}).strict();
|
|
143
|
+
var TranscriptMessageEventSchema = import_zod4.z.object({
|
|
144
|
+
type: import_zod4.z.literal("message"),
|
|
145
|
+
role: import_zod4.z.enum(["system", "user", "assistant"]),
|
|
146
|
+
content: JsonValueSchema.optional(),
|
|
147
|
+
metadata: JsonObjectSchema.optional()
|
|
148
|
+
}).strict();
|
|
149
|
+
var TranscriptToolResultEventSchema = import_zod4.z.object({
|
|
150
|
+
type: import_zod4.z.literal("tool_result"),
|
|
151
|
+
toolCallId: import_zod4.z.string(),
|
|
152
|
+
name: import_zod4.z.string().optional(),
|
|
153
|
+
content: JsonValueSchema.optional(),
|
|
154
|
+
error: NormalizedErrorSchema.optional(),
|
|
155
|
+
startedAt: import_zod4.z.string().optional(),
|
|
156
|
+
finishedAt: import_zod4.z.string().optional(),
|
|
157
|
+
durationMs: FiniteNumberSchema.optional(),
|
|
158
|
+
metadata: JsonObjectSchema.optional()
|
|
159
|
+
}).strict();
|
|
160
|
+
var TranscriptEventSchema = import_zod4.z.discriminatedUnion("type", [
|
|
161
|
+
TranscriptMessageEventSchema,
|
|
162
|
+
TranscriptToolCallEventSchema,
|
|
163
|
+
TranscriptToolResultEventSchema
|
|
164
|
+
]);
|
|
165
|
+
function messagesToTranscriptEvents(messages) {
|
|
166
|
+
const events = [];
|
|
167
|
+
for (const [messageIndex, message] of messages.entries()) {
|
|
168
|
+
if (message.role === "tool") {
|
|
169
|
+
const partEvents2 = contentPartEvents(message);
|
|
170
|
+
if (partEvents2) {
|
|
171
|
+
events.push(...partEvents2);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (!hasTopLevelToolCallId(message)) {
|
|
175
|
+
throw new TypeError("Tool result messages must include toolCallId.");
|
|
176
|
+
}
|
|
177
|
+
events.push(toolResultMessageEvent(message, message.toolCallId));
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
const partEvents = message.role === "assistant" ? contentPartEvents(message) : void 0;
|
|
181
|
+
const partEventsHaveToolCalls = partEvents?.some(
|
|
182
|
+
(event) => event.type === "tool_call"
|
|
183
|
+
);
|
|
184
|
+
if (partEvents) {
|
|
185
|
+
events.push(...partEvents);
|
|
186
|
+
} else if (message.content !== void 0) {
|
|
187
|
+
events.push({
|
|
188
|
+
type: "message",
|
|
189
|
+
role: message.role,
|
|
190
|
+
content: message.content,
|
|
191
|
+
...message.metadata ? { metadata: message.metadata } : {}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
if (message.role !== "assistant") {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (partEventsHaveToolCalls) {
|
|
198
|
+
if ((message.toolCalls ?? []).length > 0) {
|
|
199
|
+
throw new TypeError(
|
|
200
|
+
"Assistant messages must not mix tool-call content parts with toolCalls."
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const messageToolCalls = message.toolCalls ?? [];
|
|
206
|
+
for (const [toolIndex, toolCall] of messageToolCalls.entries()) {
|
|
207
|
+
const rawToolCall = toolCall;
|
|
208
|
+
if (Object.prototype.hasOwnProperty.call(rawToolCall, "result") || Object.prototype.hasOwnProperty.call(rawToolCall, "error")) {
|
|
209
|
+
throw new TypeError(
|
|
210
|
+
"Assistant tool calls must use separate tool result messages."
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
if (typeof toolCall.name !== "string" || toolCall.name.length === 0) {
|
|
214
|
+
throw new TypeError("Assistant tool calls must include name.");
|
|
215
|
+
}
|
|
216
|
+
const id = toolCall.id ?? `message-${messageIndex}:tool-call-${toolIndex}`;
|
|
217
|
+
events.push({
|
|
218
|
+
type: "tool_call",
|
|
219
|
+
id,
|
|
220
|
+
name: toolCall.name,
|
|
221
|
+
...normalizeToolCallArguments(toolCall.arguments),
|
|
222
|
+
...toolCall.startedAt ? { startedAt: toolCall.startedAt } : {},
|
|
223
|
+
...toolCall.finishedAt ? { finishedAt: toolCall.finishedAt } : {},
|
|
224
|
+
...toolCall.durationMs !== void 0 ? { durationMs: toolCall.durationMs } : {},
|
|
225
|
+
...toolCall.metadata ? { metadata: toolCall.metadata } : {}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return events;
|
|
230
|
+
}
|
|
231
|
+
function contentPartEvents(message) {
|
|
232
|
+
if (!Array.isArray(message.content)) {
|
|
233
|
+
return void 0;
|
|
234
|
+
}
|
|
235
|
+
const events = [];
|
|
236
|
+
for (const part of message.content) {
|
|
237
|
+
if (!isJsonObject2(part) || typeof part.type !== "string") {
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (part.type === "text" && typeof part.text === "string") {
|
|
241
|
+
if (message.role === "tool") {
|
|
242
|
+
throw new TypeError("Text content parts require message role.");
|
|
243
|
+
}
|
|
244
|
+
events.push({
|
|
245
|
+
type: "message",
|
|
246
|
+
role: message.role,
|
|
247
|
+
content: part.text,
|
|
248
|
+
...recordMetadata(message.metadata)
|
|
249
|
+
});
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
if (part.type === "tool-call") {
|
|
253
|
+
if (message.role !== "assistant" || typeof part.toolCallId !== "string" || typeof part.toolName !== "string") {
|
|
254
|
+
throw new TypeError(
|
|
255
|
+
"Tool-call content parts require assistant role, toolCallId, and toolName."
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
events.push({
|
|
259
|
+
type: "tool_call",
|
|
260
|
+
id: part.toolCallId,
|
|
261
|
+
name: part.toolName,
|
|
262
|
+
...normalizeToolCallArguments(part.input),
|
|
263
|
+
...jsonTimeFields(part),
|
|
264
|
+
...jsonMetadata(part.metadata)
|
|
265
|
+
});
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
if (part.type === "tool-result") {
|
|
269
|
+
if (message.role !== "tool" || typeof part.toolCallId !== "string") {
|
|
270
|
+
throw new TypeError(
|
|
271
|
+
"Tool-result content parts require tool role and toolCallId."
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
if (hasTopLevelToolCallId(message)) {
|
|
275
|
+
throw new TypeError(
|
|
276
|
+
"Tool-result content parts must not include top-level toolCallId."
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
events.push({
|
|
280
|
+
type: "tool_result",
|
|
281
|
+
toolCallId: part.toolCallId,
|
|
282
|
+
...typeof part.toolName === "string" ? { name: part.toolName } : {},
|
|
283
|
+
...part.output !== void 0 ? { content: part.output } : {},
|
|
284
|
+
...part.error ? { error: part.error } : {},
|
|
285
|
+
...jsonTimeFields(part),
|
|
286
|
+
...jsonMetadata(part.metadata)
|
|
287
|
+
});
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
throw new TypeError(
|
|
291
|
+
"Message content parts must use the harness message contract."
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
return events.length > 0 ? events : void 0;
|
|
295
|
+
}
|
|
296
|
+
function toolResultMessageEvent(message, toolCallId) {
|
|
297
|
+
return {
|
|
298
|
+
type: "tool_result",
|
|
299
|
+
toolCallId,
|
|
300
|
+
...message.name ? { name: message.name } : {},
|
|
301
|
+
...message.content !== void 0 ? { content: message.content } : {},
|
|
302
|
+
...message.error ? { error: message.error } : {},
|
|
303
|
+
...timeFields(message),
|
|
304
|
+
...recordMetadata(message.metadata)
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
function hasTopLevelToolCallId(message) {
|
|
308
|
+
return typeof message.toolCallId === "string";
|
|
309
|
+
}
|
|
310
|
+
function timeFields(input) {
|
|
311
|
+
return {
|
|
312
|
+
...input.startedAt ? { startedAt: input.startedAt } : {},
|
|
313
|
+
...input.finishedAt ? { finishedAt: input.finishedAt } : {},
|
|
314
|
+
...input.durationMs !== void 0 ? { durationMs: input.durationMs } : {}
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function recordMetadata(metadata) {
|
|
318
|
+
return metadata ? { metadata } : {};
|
|
319
|
+
}
|
|
320
|
+
function jsonTimeFields(input) {
|
|
321
|
+
return {
|
|
322
|
+
...typeof input.startedAt === "string" ? { startedAt: input.startedAt } : {},
|
|
323
|
+
...typeof input.finishedAt === "string" ? { finishedAt: input.finishedAt } : {},
|
|
324
|
+
...typeof input.durationMs === "number" ? { durationMs: input.durationMs } : {}
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function jsonMetadata(value) {
|
|
328
|
+
return isJsonObject2(value) ? { metadata: value } : {};
|
|
329
|
+
}
|
|
330
|
+
function normalizeToolCallArguments(value) {
|
|
331
|
+
return value && typeof value === "object" && !Array.isArray(value) ? { arguments: value } : {};
|
|
332
|
+
}
|
|
333
|
+
function isJsonObject2(value) {
|
|
334
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
335
|
+
}
|
|
336
|
+
function isMessageEvent(event) {
|
|
337
|
+
return event.type === "message";
|
|
338
|
+
}
|
|
339
|
+
function isToolCallEvent(event) {
|
|
340
|
+
return event.type === "tool_call";
|
|
341
|
+
}
|
|
342
|
+
function isToolResultEvent(event) {
|
|
343
|
+
return event.type === "tool_result";
|
|
344
|
+
}
|
|
345
|
+
|
|
117
346
|
// src/harness/index.ts
|
|
118
|
-
var UsageSummarySchema =
|
|
119
|
-
provider:
|
|
120
|
-
model:
|
|
347
|
+
var UsageSummarySchema = import_zod5.z.object({
|
|
348
|
+
provider: import_zod5.z.string().optional(),
|
|
349
|
+
model: import_zod5.z.string().optional(),
|
|
121
350
|
inputTokens: FiniteNumberSchema.optional(),
|
|
122
351
|
outputTokens: FiniteNumberSchema.optional(),
|
|
123
352
|
reasoningTokens: FiniteNumberSchema.optional(),
|
|
@@ -126,81 +355,105 @@ var UsageSummarySchema = import_zod3.z.object({
|
|
|
126
355
|
retries: FiniteNumberSchema.optional(),
|
|
127
356
|
metadata: JsonObjectSchema.optional()
|
|
128
357
|
}).strict();
|
|
129
|
-
var TimingSummarySchema =
|
|
358
|
+
var TimingSummarySchema = import_zod5.z.object({
|
|
130
359
|
totalMs: FiniteNumberSchema.optional(),
|
|
131
360
|
metadata: JsonObjectSchema.optional()
|
|
132
361
|
}).strict();
|
|
133
|
-
var
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}).catchall(JsonValueSchema);
|
|
137
|
-
var ToolCallRecordSchema = import_zod3.z.object({
|
|
138
|
-
id: import_zod3.z.string().optional(),
|
|
139
|
-
name: import_zod3.z.string(),
|
|
140
|
-
arguments: JsonObjectSchema.optional(),
|
|
141
|
-
result: JsonValueSchema.optional(),
|
|
142
|
-
error: NormalizedErrorSchema.optional(),
|
|
143
|
-
startedAt: import_zod3.z.string().optional(),
|
|
144
|
-
finishedAt: import_zod3.z.string().optional(),
|
|
145
|
-
durationMs: FiniteNumberSchema.optional(),
|
|
146
|
-
metadata: JsonObjectSchema.optional()
|
|
147
|
-
}).strict();
|
|
148
|
-
var NormalizedMessageSchema = import_zod3.z.object({
|
|
149
|
-
role: import_zod3.z.enum(["system", "user", "assistant", "tool"]),
|
|
150
|
-
content: JsonValueSchema.optional(),
|
|
151
|
-
toolCalls: import_zod3.z.array(ToolCallRecordSchema).optional(),
|
|
152
|
-
metadata: JsonObjectSchema.optional()
|
|
362
|
+
var ToolCallBaseSchema = import_zod5.z.object({
|
|
363
|
+
name: import_zod5.z.string(),
|
|
364
|
+
arguments: JsonObjectSchema.optional()
|
|
153
365
|
}).strict();
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
366
|
+
var ToolCallSchema = import_zod5.z.discriminatedUnion("status", [
|
|
367
|
+
ToolCallBaseSchema.extend({
|
|
368
|
+
status: import_zod5.z.literal("pending")
|
|
369
|
+
}).strict(),
|
|
370
|
+
ToolCallBaseSchema.extend({
|
|
371
|
+
status: import_zod5.z.literal("ok"),
|
|
372
|
+
result: JsonValueSchema.optional()
|
|
373
|
+
}).strict(),
|
|
374
|
+
ToolCallBaseSchema.extend({
|
|
375
|
+
status: import_zod5.z.literal("error"),
|
|
376
|
+
error: NormalizedErrorSchema
|
|
377
|
+
}).strict()
|
|
378
|
+
]);
|
|
379
|
+
var NormalizedSessionSchema = import_zod5.z.object({
|
|
380
|
+
events: import_zod5.z.array(TranscriptEventSchema),
|
|
381
|
+
provider: import_zod5.z.string().optional(),
|
|
382
|
+
model: import_zod5.z.string().optional(),
|
|
158
383
|
metadata: JsonObjectSchema.optional()
|
|
159
384
|
}).strict();
|
|
160
385
|
var NormalizedSpanAttributesSchema = JsonObjectSchema;
|
|
161
|
-
var NormalizedSpanEventSchema =
|
|
162
|
-
name:
|
|
163
|
-
timestamp:
|
|
386
|
+
var NormalizedSpanEventSchema = import_zod5.z.object({
|
|
387
|
+
name: import_zod5.z.string(),
|
|
388
|
+
timestamp: import_zod5.z.string().optional(),
|
|
164
389
|
attributes: NormalizedSpanAttributesSchema.optional()
|
|
165
390
|
}).strict();
|
|
166
|
-
var NormalizedSpanSchema =
|
|
167
|
-
id:
|
|
168
|
-
traceId:
|
|
169
|
-
parentId:
|
|
170
|
-
name:
|
|
171
|
-
kind:
|
|
172
|
-
startedAt:
|
|
173
|
-
finishedAt:
|
|
391
|
+
var NormalizedSpanSchema = import_zod5.z.object({
|
|
392
|
+
id: import_zod5.z.string().optional(),
|
|
393
|
+
traceId: import_zod5.z.string().optional(),
|
|
394
|
+
parentId: import_zod5.z.string().optional(),
|
|
395
|
+
name: import_zod5.z.string(),
|
|
396
|
+
kind: import_zod5.z.enum(["run", "agent", "model", "tool", "guardrail", "handoff", "custom"]).optional(),
|
|
397
|
+
startedAt: import_zod5.z.string().optional(),
|
|
398
|
+
finishedAt: import_zod5.z.string().optional(),
|
|
174
399
|
durationMs: FiniteNumberSchema.optional(),
|
|
175
|
-
status:
|
|
400
|
+
status: import_zod5.z.enum(["ok", "error"]).optional(),
|
|
176
401
|
error: NormalizedErrorSchema.optional(),
|
|
177
402
|
attributes: NormalizedSpanAttributesSchema.optional(),
|
|
178
|
-
events:
|
|
403
|
+
events: import_zod5.z.array(NormalizedSpanEventSchema).optional()
|
|
179
404
|
}).strict();
|
|
180
|
-
var NormalizedTraceSchema =
|
|
181
|
-
id:
|
|
182
|
-
name:
|
|
183
|
-
startedAt:
|
|
184
|
-
finishedAt:
|
|
405
|
+
var NormalizedTraceSchema = import_zod5.z.object({
|
|
406
|
+
id: import_zod5.z.string().optional(),
|
|
407
|
+
name: import_zod5.z.string().optional(),
|
|
408
|
+
startedAt: import_zod5.z.string().optional(),
|
|
409
|
+
finishedAt: import_zod5.z.string().optional(),
|
|
185
410
|
durationMs: FiniteNumberSchema.optional(),
|
|
186
411
|
metadata: JsonObjectSchema.optional(),
|
|
187
|
-
spans:
|
|
412
|
+
spans: import_zod5.z.array(NormalizedSpanSchema)
|
|
188
413
|
}).strict();
|
|
189
|
-
var HarnessRunSchema =
|
|
414
|
+
var HarnessRunSchema = import_zod5.z.object({
|
|
190
415
|
output: JsonValueSchema.optional(),
|
|
191
416
|
session: NormalizedSessionSchema,
|
|
192
417
|
usage: UsageSummarySchema,
|
|
193
418
|
timings: TimingSummarySchema.optional(),
|
|
194
419
|
artifacts: JsonObjectSchema.optional(),
|
|
195
|
-
traces:
|
|
196
|
-
errors:
|
|
420
|
+
traces: import_zod5.z.array(NormalizedTraceSchema).optional(),
|
|
421
|
+
errors: import_zod5.z.array(JsonObjectSchema)
|
|
197
422
|
}).strict();
|
|
198
423
|
|
|
199
424
|
// src/harness/helpers.ts
|
|
200
425
|
function toolCalls(source) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
426
|
+
const resultsById = /* @__PURE__ */ new Map();
|
|
427
|
+
for (const message of toolResultsFromSource(source)) {
|
|
428
|
+
if (!resultsById.has(message.toolCallId)) {
|
|
429
|
+
resultsById.set(message.toolCallId, message);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return toolCallsFromSource(source).map((call) => {
|
|
433
|
+
const result = resultsById.get(call.id);
|
|
434
|
+
const normalizedCall = {
|
|
435
|
+
name: call.name,
|
|
436
|
+
...call.arguments ? { arguments: call.arguments } : {}
|
|
437
|
+
};
|
|
438
|
+
if (!result) {
|
|
439
|
+
return {
|
|
440
|
+
...normalizedCall,
|
|
441
|
+
status: "pending"
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
if (result.error) {
|
|
445
|
+
return {
|
|
446
|
+
...normalizedCall,
|
|
447
|
+
status: "error",
|
|
448
|
+
error: result.error
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
return {
|
|
452
|
+
...normalizedCall,
|
|
453
|
+
status: "ok",
|
|
454
|
+
...result.content !== void 0 ? { result: result.content } : {}
|
|
455
|
+
};
|
|
456
|
+
});
|
|
204
457
|
}
|
|
205
458
|
function spans(source) {
|
|
206
459
|
return spansFrom(source);
|
|
@@ -217,8 +470,8 @@ function failedSpans(source) {
|
|
|
217
470
|
);
|
|
218
471
|
}
|
|
219
472
|
function messagesByRole(source, role) {
|
|
220
|
-
return sessionFrom(source).
|
|
221
|
-
(
|
|
473
|
+
return sessionFrom(source).events.filter(
|
|
474
|
+
(event) => event.type === "message" && event.role === role
|
|
222
475
|
);
|
|
223
476
|
}
|
|
224
477
|
function systemMessages(source) {
|
|
@@ -234,11 +487,17 @@ function latestAssistantMessageContent(source) {
|
|
|
234
487
|
return [...messagesByRoleFromSource(source, "assistant")].reverse().find(hasNonEmptyMessageContent)?.content;
|
|
235
488
|
}
|
|
236
489
|
function toolMessages(source) {
|
|
237
|
-
return
|
|
490
|
+
return toolResultsFromSource(source);
|
|
238
491
|
}
|
|
239
492
|
function sessionFrom(source) {
|
|
240
493
|
return "session" in source ? source.session : source;
|
|
241
494
|
}
|
|
495
|
+
function toolResultsFromSource(source) {
|
|
496
|
+
return sessionFrom(source).events.filter(isToolResultEvent);
|
|
497
|
+
}
|
|
498
|
+
function toolCallsFromSource(source) {
|
|
499
|
+
return sessionFrom(source).events.filter(isToolCallEvent);
|
|
500
|
+
}
|
|
242
501
|
function tracesFrom(source) {
|
|
243
502
|
if (source === void 0) {
|
|
244
503
|
return [];
|
|
@@ -255,8 +514,8 @@ function isTraceList(source) {
|
|
|
255
514
|
return Array.isArray(source);
|
|
256
515
|
}
|
|
257
516
|
function messagesByRoleFromSource(source, role) {
|
|
258
|
-
return sessionFrom(source).
|
|
259
|
-
(
|
|
517
|
+
return sessionFrom(source).events.filter(
|
|
518
|
+
(event) => event.type === "message" && event.role === role
|
|
260
519
|
);
|
|
261
520
|
}
|
|
262
521
|
function hasNonEmptyMessageContent(message) {
|
|
@@ -264,71 +523,45 @@ function hasNonEmptyMessageContent(message) {
|
|
|
264
523
|
}
|
|
265
524
|
|
|
266
525
|
// src/report/metadata.ts
|
|
267
|
-
var
|
|
268
|
-
var HarnessMetaSchema =
|
|
269
|
-
name:
|
|
526
|
+
var import_zod6 = require("zod");
|
|
527
|
+
var HarnessMetaSchema = import_zod6.z.object({
|
|
528
|
+
name: import_zod6.z.string().optional(),
|
|
270
529
|
run: HarnessRunSchema.optional()
|
|
271
530
|
}).strict();
|
|
272
|
-
var EvalScoreSchema =
|
|
273
|
-
name:
|
|
531
|
+
var EvalScoreSchema = import_zod6.z.object({
|
|
532
|
+
name: import_zod6.z.string().optional(),
|
|
274
533
|
score: NullableFiniteNumberSchema,
|
|
275
534
|
metadata: JsonObjectSchema.optional()
|
|
276
535
|
}).strict();
|
|
277
|
-
var EvalMetaSchema =
|
|
278
|
-
scores:
|
|
536
|
+
var EvalMetaSchema = import_zod6.z.object({
|
|
537
|
+
scores: import_zod6.z.array(EvalScoreSchema).optional(),
|
|
279
538
|
avgScore: NullableFiniteNumberSchema,
|
|
280
539
|
output: JsonValueSchema.optional(),
|
|
281
|
-
thresholdFailed:
|
|
282
|
-
toolCalls:
|
|
540
|
+
thresholdFailed: import_zod6.z.boolean().optional(),
|
|
541
|
+
toolCalls: import_zod6.z.array(ToolCallSchema).optional()
|
|
283
542
|
}).strict();
|
|
284
|
-
var EvalTaskMetaSchema =
|
|
543
|
+
var EvalTaskMetaSchema = import_zod6.z.object({
|
|
285
544
|
eval: EvalMetaSchema.optional(),
|
|
286
545
|
harness: HarnessMetaSchema.optional()
|
|
287
546
|
}).strict();
|
|
288
|
-
var LenientToolCallRecordSchema = ToolCallRecordSchema.strip();
|
|
289
|
-
var LenientMessageSchema = NormalizedMessageSchema.extend({
|
|
290
|
-
toolCalls: import_zod4.z.array(LenientToolCallRecordSchema).optional().catch(void 0)
|
|
291
|
-
}).strip();
|
|
292
|
-
var LenientSessionSchema = NormalizedSessionSchema.extend({
|
|
293
|
-
messages: import_zod4.z.array(LenientMessageSchema).default([]).catch([])
|
|
294
|
-
}).strip();
|
|
295
|
-
var LenientSpanEventSchema = NormalizedSpanEventSchema.strip();
|
|
296
|
-
var LenientSpanSchema = NormalizedSpanSchema.extend({
|
|
297
|
-
events: import_zod4.z.array(LenientSpanEventSchema).optional().catch(void 0)
|
|
298
|
-
}).strip();
|
|
299
|
-
var LenientTraceSchema = NormalizedTraceSchema.extend({
|
|
300
|
-
spans: import_zod4.z.array(LenientSpanSchema).default([]).catch([])
|
|
301
|
-
}).strip();
|
|
302
|
-
var LenientHarnessRunSchema = HarnessRunSchema.extend({
|
|
303
|
-
session: LenientSessionSchema,
|
|
304
|
-
usage: UsageSummarySchema.strip().default({}),
|
|
305
|
-
timings: TimingSummarySchema.strip().optional(),
|
|
306
|
-
traces: import_zod4.z.array(LenientTraceSchema).optional().catch(void 0)
|
|
307
|
-
}).strip();
|
|
308
|
-
var LenientHarnessMetaSchema = HarnessMetaSchema.extend({
|
|
309
|
-
run: LenientHarnessRunSchema.optional().catch(void 0)
|
|
310
|
-
}).strip();
|
|
311
|
-
var LenientEvalScoreSchema = EvalScoreSchema.strip();
|
|
312
|
-
var LenientEvalMetaSchema = EvalMetaSchema.extend({
|
|
313
|
-
scores: import_zod4.z.array(LenientEvalScoreSchema).optional().catch(void 0),
|
|
314
|
-
toolCalls: import_zod4.z.array(LenientToolCallRecordSchema).optional().catch(void 0)
|
|
315
|
-
}).strip();
|
|
316
547
|
function readEvalTaskMeta(input) {
|
|
317
548
|
if (!isJsonObject(input)) {
|
|
318
549
|
return void 0;
|
|
319
550
|
}
|
|
320
|
-
const evalResult = LenientEvalMetaSchema.safeParse(input.eval);
|
|
321
|
-
const harnessResult = LenientHarnessMetaSchema.safeParse(input.harness);
|
|
322
551
|
const meta = {
|
|
323
|
-
...
|
|
324
|
-
...
|
|
552
|
+
...input.eval !== void 0 ? { eval: input.eval } : {},
|
|
553
|
+
...input.harness !== void 0 ? { harness: input.harness } : {}
|
|
325
554
|
};
|
|
326
|
-
|
|
555
|
+
if (!("eval" in meta) && !("harness" in meta)) {
|
|
556
|
+
return void 0;
|
|
557
|
+
}
|
|
558
|
+
const result = EvalTaskMetaSchema.safeParse(meta);
|
|
559
|
+
return result.success ? result.data : void 0;
|
|
327
560
|
}
|
|
328
561
|
|
|
329
562
|
// src/report/vitest-json.ts
|
|
330
|
-
var
|
|
331
|
-
var VitestJsonStatusSchema =
|
|
563
|
+
var import_zod7 = require("zod");
|
|
564
|
+
var VitestJsonStatusSchema = import_zod7.z.enum([
|
|
332
565
|
"passed",
|
|
333
566
|
"failed",
|
|
334
567
|
"skipped",
|
|
@@ -336,53 +569,53 @@ var VitestJsonStatusSchema = import_zod5.z.enum([
|
|
|
336
569
|
"todo",
|
|
337
570
|
"disabled"
|
|
338
571
|
]);
|
|
339
|
-
var VitestJsonLocationSchema =
|
|
572
|
+
var VitestJsonLocationSchema = import_zod7.z.object({
|
|
340
573
|
line: FiniteNumberSchema,
|
|
341
574
|
column: FiniteNumberSchema
|
|
342
575
|
}).passthrough();
|
|
343
|
-
var VitestJsonAssertionSchema =
|
|
344
|
-
ancestorTitles:
|
|
345
|
-
fullName:
|
|
576
|
+
var VitestJsonAssertionSchema = import_zod7.z.object({
|
|
577
|
+
ancestorTitles: import_zod7.z.array(import_zod7.z.string()).default([]),
|
|
578
|
+
fullName: import_zod7.z.string(),
|
|
346
579
|
status: VitestJsonStatusSchema,
|
|
347
|
-
title:
|
|
348
|
-
meta:
|
|
580
|
+
title: import_zod7.z.string(),
|
|
581
|
+
meta: import_zod7.z.unknown().optional(),
|
|
349
582
|
duration: FiniteNumberSchema.nullable().optional(),
|
|
350
|
-
failureMessages:
|
|
583
|
+
failureMessages: import_zod7.z.array(import_zod7.z.string()).nullable().optional(),
|
|
351
584
|
location: VitestJsonLocationSchema.nullable().optional(),
|
|
352
|
-
tags:
|
|
585
|
+
tags: import_zod7.z.array(import_zod7.z.string()).optional()
|
|
353
586
|
}).passthrough();
|
|
354
|
-
var VitestJsonFileSchema =
|
|
355
|
-
message:
|
|
356
|
-
name:
|
|
357
|
-
status:
|
|
587
|
+
var VitestJsonFileSchema = import_zod7.z.object({
|
|
588
|
+
message: import_zod7.z.string(),
|
|
589
|
+
name: import_zod7.z.string(),
|
|
590
|
+
status: import_zod7.z.enum(["failed", "passed"]),
|
|
358
591
|
startTime: OptionalFiniteNumberSchema,
|
|
359
592
|
endTime: OptionalFiniteNumberSchema,
|
|
360
|
-
assertionResults:
|
|
593
|
+
assertionResults: import_zod7.z.array(VitestJsonAssertionSchema).default([])
|
|
361
594
|
}).passthrough();
|
|
362
|
-
var VitestJsonReportSchema =
|
|
595
|
+
var VitestJsonReportSchema = import_zod7.z.object({
|
|
363
596
|
numFailedTests: FiniteNumberSchema,
|
|
364
597
|
numPassedTests: FiniteNumberSchema,
|
|
365
598
|
numPendingTests: FiniteNumberSchema,
|
|
366
599
|
numTodoTests: FiniteNumberSchema,
|
|
367
600
|
numTotalTests: FiniteNumberSchema,
|
|
368
601
|
startTime: FiniteNumberSchema,
|
|
369
|
-
success:
|
|
370
|
-
testResults:
|
|
602
|
+
success: import_zod7.z.boolean(),
|
|
603
|
+
testResults: import_zod7.z.array(VitestJsonFileSchema).default([])
|
|
371
604
|
}).passthrough();
|
|
372
605
|
function parseVitestJsonReport(input) {
|
|
373
606
|
return parseWithSchema(VitestJsonReportSchema, input, "Vitest JSON report");
|
|
374
607
|
}
|
|
375
608
|
|
|
376
609
|
// src/report/workspace.ts
|
|
377
|
-
var
|
|
610
|
+
var import_zod8 = require("zod");
|
|
378
611
|
var REPORT_WORKSPACE_SCHEMA_VERSION = 1;
|
|
379
|
-
var ReportRunSchema =
|
|
380
|
-
id:
|
|
381
|
-
source:
|
|
382
|
-
status:
|
|
612
|
+
var ReportRunSchema = import_zod8.z.object({
|
|
613
|
+
id: import_zod8.z.string(),
|
|
614
|
+
source: import_zod8.z.string().optional(),
|
|
615
|
+
status: import_zod8.z.enum(["passed", "failed"]),
|
|
383
616
|
startedAt: FiniteNumberSchema.optional(),
|
|
384
617
|
durationMs: FiniteNumberSchema.optional(),
|
|
385
|
-
totals:
|
|
618
|
+
totals: import_zod8.z.object({
|
|
386
619
|
total: FiniteNumberSchema,
|
|
387
620
|
passed: FiniteNumberSchema,
|
|
388
621
|
failed: FiniteNumberSchema,
|
|
@@ -392,28 +625,28 @@ var ReportRunSchema = import_zod6.z.object({
|
|
|
392
625
|
evalFailed: FiniteNumberSchema
|
|
393
626
|
})
|
|
394
627
|
}).strict();
|
|
395
|
-
var ReportCaseSchema =
|
|
396
|
-
id:
|
|
397
|
-
runId:
|
|
398
|
-
source:
|
|
399
|
-
file:
|
|
400
|
-
displayFile:
|
|
401
|
-
title:
|
|
402
|
-
fullName:
|
|
403
|
-
ancestorTitles:
|
|
404
|
-
tags:
|
|
405
|
-
displayName:
|
|
628
|
+
var ReportCaseSchema = import_zod8.z.object({
|
|
629
|
+
id: import_zod8.z.string(),
|
|
630
|
+
runId: import_zod8.z.string(),
|
|
631
|
+
source: import_zod8.z.string().optional(),
|
|
632
|
+
file: import_zod8.z.string(),
|
|
633
|
+
displayFile: import_zod8.z.string(),
|
|
634
|
+
title: import_zod8.z.string(),
|
|
635
|
+
fullName: import_zod8.z.string(),
|
|
636
|
+
ancestorTitles: import_zod8.z.array(import_zod8.z.string()),
|
|
637
|
+
tags: import_zod8.z.array(import_zod8.z.string()).optional(),
|
|
638
|
+
displayName: import_zod8.z.string(),
|
|
406
639
|
status: VitestJsonStatusSchema,
|
|
407
640
|
durationMs: FiniteNumberSchema.optional(),
|
|
408
641
|
location: VitestJsonLocationSchema.optional(),
|
|
409
|
-
failureMessages:
|
|
642
|
+
failureMessages: import_zod8.z.array(import_zod8.z.string()).default([]),
|
|
410
643
|
eval: EvalMetaSchema.optional(),
|
|
411
644
|
harness: HarnessMetaSchema.optional()
|
|
412
645
|
}).strict();
|
|
413
|
-
var ReportWorkspaceSchema =
|
|
414
|
-
schemaVersion:
|
|
415
|
-
runs:
|
|
416
|
-
cases:
|
|
646
|
+
var ReportWorkspaceSchema = import_zod8.z.object({
|
|
647
|
+
schemaVersion: import_zod8.z.literal(REPORT_WORKSPACE_SCHEMA_VERSION),
|
|
648
|
+
runs: import_zod8.z.array(ReportRunSchema),
|
|
649
|
+
cases: import_zod8.z.array(ReportCaseSchema)
|
|
417
650
|
}).strict();
|
|
418
651
|
function parseReportWorkspace(input) {
|
|
419
652
|
return parseWithSchema(ReportWorkspaceSchema, input, "report workspace");
|
|
@@ -432,6 +665,11 @@ function collectReportWorkspace(input, options = {}) {
|
|
|
432
665
|
if (!meta) {
|
|
433
666
|
continue;
|
|
434
667
|
}
|
|
668
|
+
const evalMeta = meta.eval ?? (meta.harness ? {
|
|
669
|
+
avgScore: assertion.status === "passed" ? 1 : assertion.status === "failed" ? 0 : null,
|
|
670
|
+
scores: [],
|
|
671
|
+
thresholdFailed: false
|
|
672
|
+
} : void 0);
|
|
435
673
|
runCases.push({
|
|
436
674
|
id: createCaseId(runId, file.name, assertion),
|
|
437
675
|
runId,
|
|
@@ -447,7 +685,7 @@ function collectReportWorkspace(input, options = {}) {
|
|
|
447
685
|
...typeof assertion.duration === "number" ? { durationMs: assertion.duration } : {},
|
|
448
686
|
...assertion.location ? { location: assertion.location } : {},
|
|
449
687
|
failureMessages: assertion.failureMessages ?? [],
|
|
450
|
-
...
|
|
688
|
+
...evalMeta ? { eval: evalMeta } : {},
|
|
451
689
|
...meta.harness ? { harness: meta.harness } : {}
|
|
452
690
|
});
|
|
453
691
|
}
|
|
@@ -547,7 +785,6 @@ function normalizeReportPath(path, workspace) {
|
|
|
547
785
|
JsonPrimitiveSchema,
|
|
548
786
|
JsonValueSchema,
|
|
549
787
|
NormalizedErrorSchema,
|
|
550
|
-
NormalizedMessageSchema,
|
|
551
788
|
NormalizedSessionSchema,
|
|
552
789
|
NormalizedSpanAttributesSchema,
|
|
553
790
|
NormalizedSpanEventSchema,
|
|
@@ -558,7 +795,11 @@ function normalizeReportPath(path, workspace) {
|
|
|
558
795
|
ReportRunSchema,
|
|
559
796
|
ReportWorkspaceSchema,
|
|
560
797
|
TimingSummarySchema,
|
|
561
|
-
|
|
798
|
+
ToolCallSchema,
|
|
799
|
+
TranscriptEventSchema,
|
|
800
|
+
TranscriptMessageEventSchema,
|
|
801
|
+
TranscriptToolCallEventSchema,
|
|
802
|
+
TranscriptToolResultEventSchema,
|
|
562
803
|
UsageSummarySchema,
|
|
563
804
|
VitestJsonAssertionSchema,
|
|
564
805
|
VitestJsonFileSchema,
|
|
@@ -568,8 +809,12 @@ function normalizeReportPath(path, workspace) {
|
|
|
568
809
|
assistantMessages,
|
|
569
810
|
collectReportWorkspace,
|
|
570
811
|
failedSpans,
|
|
812
|
+
isMessageEvent,
|
|
813
|
+
isToolCallEvent,
|
|
814
|
+
isToolResultEvent,
|
|
571
815
|
latestAssistantMessageContent,
|
|
572
816
|
messagesByRole,
|
|
817
|
+
messagesToTranscriptEvents,
|
|
573
818
|
parseReportWorkspace,
|
|
574
819
|
parseVitestJsonReport,
|
|
575
820
|
readEvalTaskMeta,
|