@vitest-evals/core 0.13.0 → 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 +429 -215
- package/dist/index.d.ts +429 -215
- package/dist/index.js +427 -160
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +418 -158
- 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/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ var JsonValueSchema = z.lazy(
|
|
|
16
16
|
var JsonObjectSchema = z.record(z.string(), JsonValueSchema);
|
|
17
17
|
|
|
18
18
|
// src/harness/index.ts
|
|
19
|
-
import { z as
|
|
19
|
+
import { z as z5 } from "zod";
|
|
20
20
|
|
|
21
21
|
// src/schema-utils.ts
|
|
22
22
|
import { z as z2 } from "zod";
|
|
@@ -47,10 +47,232 @@ function isRecord(value) {
|
|
|
47
47
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
// src/harness/errors.ts
|
|
51
|
+
import { z as z3 } from "zod";
|
|
52
|
+
var NormalizedErrorSchema = z3.object({
|
|
53
|
+
message: z3.string(),
|
|
54
|
+
type: z3.string().optional()
|
|
55
|
+
}).catchall(JsonValueSchema);
|
|
56
|
+
|
|
57
|
+
// src/harness/transcript.ts
|
|
58
|
+
import { z as z4 } from "zod";
|
|
59
|
+
var TranscriptToolCallEventSchema = z4.object({
|
|
60
|
+
type: z4.literal("tool_call"),
|
|
61
|
+
id: z4.string(),
|
|
62
|
+
name: z4.string(),
|
|
63
|
+
arguments: JsonObjectSchema.optional(),
|
|
64
|
+
startedAt: z4.string().optional(),
|
|
65
|
+
finishedAt: z4.string().optional(),
|
|
66
|
+
durationMs: FiniteNumberSchema.optional(),
|
|
67
|
+
metadata: JsonObjectSchema.optional()
|
|
68
|
+
}).strict();
|
|
69
|
+
var TranscriptMessageEventSchema = z4.object({
|
|
70
|
+
type: z4.literal("message"),
|
|
71
|
+
role: z4.enum(["system", "user", "assistant"]),
|
|
72
|
+
content: JsonValueSchema.optional(),
|
|
73
|
+
metadata: JsonObjectSchema.optional()
|
|
74
|
+
}).strict();
|
|
75
|
+
var TranscriptToolResultEventSchema = z4.object({
|
|
76
|
+
type: z4.literal("tool_result"),
|
|
77
|
+
toolCallId: z4.string(),
|
|
78
|
+
name: z4.string().optional(),
|
|
79
|
+
content: JsonValueSchema.optional(),
|
|
80
|
+
error: NormalizedErrorSchema.optional(),
|
|
81
|
+
startedAt: z4.string().optional(),
|
|
82
|
+
finishedAt: z4.string().optional(),
|
|
83
|
+
durationMs: FiniteNumberSchema.optional(),
|
|
84
|
+
metadata: JsonObjectSchema.optional()
|
|
85
|
+
}).strict();
|
|
86
|
+
var TranscriptEventSchema = z4.discriminatedUnion("type", [
|
|
87
|
+
TranscriptMessageEventSchema,
|
|
88
|
+
TranscriptToolCallEventSchema,
|
|
89
|
+
TranscriptToolResultEventSchema
|
|
90
|
+
]);
|
|
91
|
+
function messagesToTranscriptEvents(messages) {
|
|
92
|
+
const events = [];
|
|
93
|
+
for (const [messageIndex, message] of messages.entries()) {
|
|
94
|
+
if (message.role === "tool") {
|
|
95
|
+
const partEvents2 = contentPartEvents(message);
|
|
96
|
+
if (partEvents2) {
|
|
97
|
+
events.push(...partEvents2);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (!hasTopLevelToolCallId(message)) {
|
|
101
|
+
throw new TypeError("Tool result messages must include toolCallId.");
|
|
102
|
+
}
|
|
103
|
+
events.push(toolResultMessageEvent(message, message.toolCallId));
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const partEvents = message.role === "assistant" ? contentPartEvents(message) : void 0;
|
|
107
|
+
const partEventsHaveToolCalls = partEvents?.some(
|
|
108
|
+
(event) => event.type === "tool_call"
|
|
109
|
+
);
|
|
110
|
+
if (partEvents) {
|
|
111
|
+
events.push(...partEvents);
|
|
112
|
+
} else if (message.content !== void 0) {
|
|
113
|
+
events.push({
|
|
114
|
+
type: "message",
|
|
115
|
+
role: message.role,
|
|
116
|
+
content: message.content,
|
|
117
|
+
...message.metadata ? { metadata: message.metadata } : {}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (message.role !== "assistant") {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (partEventsHaveToolCalls) {
|
|
124
|
+
if ((message.toolCalls ?? []).length > 0) {
|
|
125
|
+
throw new TypeError(
|
|
126
|
+
"Assistant messages must not mix tool-call content parts with toolCalls."
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const messageToolCalls = message.toolCalls ?? [];
|
|
132
|
+
for (const [toolIndex, toolCall] of messageToolCalls.entries()) {
|
|
133
|
+
const rawToolCall = toolCall;
|
|
134
|
+
if (Object.prototype.hasOwnProperty.call(rawToolCall, "result") || Object.prototype.hasOwnProperty.call(rawToolCall, "error")) {
|
|
135
|
+
throw new TypeError(
|
|
136
|
+
"Assistant tool calls must use separate tool result messages."
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
if (typeof toolCall.name !== "string" || toolCall.name.length === 0) {
|
|
140
|
+
throw new TypeError("Assistant tool calls must include name.");
|
|
141
|
+
}
|
|
142
|
+
const id = toolCall.id ?? `message-${messageIndex}:tool-call-${toolIndex}`;
|
|
143
|
+
events.push({
|
|
144
|
+
type: "tool_call",
|
|
145
|
+
id,
|
|
146
|
+
name: toolCall.name,
|
|
147
|
+
...normalizeToolCallArguments(toolCall.arguments),
|
|
148
|
+
...toolCall.startedAt ? { startedAt: toolCall.startedAt } : {},
|
|
149
|
+
...toolCall.finishedAt ? { finishedAt: toolCall.finishedAt } : {},
|
|
150
|
+
...toolCall.durationMs !== void 0 ? { durationMs: toolCall.durationMs } : {},
|
|
151
|
+
...toolCall.metadata ? { metadata: toolCall.metadata } : {}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return events;
|
|
156
|
+
}
|
|
157
|
+
function contentPartEvents(message) {
|
|
158
|
+
if (!Array.isArray(message.content)) {
|
|
159
|
+
return void 0;
|
|
160
|
+
}
|
|
161
|
+
const events = [];
|
|
162
|
+
for (const part of message.content) {
|
|
163
|
+
if (!isJsonObject2(part) || typeof part.type !== "string") {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (part.type === "text" && typeof part.text === "string") {
|
|
167
|
+
if (message.role === "tool") {
|
|
168
|
+
throw new TypeError("Text content parts require message role.");
|
|
169
|
+
}
|
|
170
|
+
events.push({
|
|
171
|
+
type: "message",
|
|
172
|
+
role: message.role,
|
|
173
|
+
content: part.text,
|
|
174
|
+
...recordMetadata(message.metadata)
|
|
175
|
+
});
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (part.type === "tool-call") {
|
|
179
|
+
if (message.role !== "assistant" || typeof part.toolCallId !== "string" || typeof part.toolName !== "string") {
|
|
180
|
+
throw new TypeError(
|
|
181
|
+
"Tool-call content parts require assistant role, toolCallId, and toolName."
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
events.push({
|
|
185
|
+
type: "tool_call",
|
|
186
|
+
id: part.toolCallId,
|
|
187
|
+
name: part.toolName,
|
|
188
|
+
...normalizeToolCallArguments(part.input),
|
|
189
|
+
...jsonTimeFields(part),
|
|
190
|
+
...jsonMetadata(part.metadata)
|
|
191
|
+
});
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (part.type === "tool-result") {
|
|
195
|
+
if (message.role !== "tool" || typeof part.toolCallId !== "string") {
|
|
196
|
+
throw new TypeError(
|
|
197
|
+
"Tool-result content parts require tool role and toolCallId."
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
if (hasTopLevelToolCallId(message)) {
|
|
201
|
+
throw new TypeError(
|
|
202
|
+
"Tool-result content parts must not include top-level toolCallId."
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
events.push({
|
|
206
|
+
type: "tool_result",
|
|
207
|
+
toolCallId: part.toolCallId,
|
|
208
|
+
...typeof part.toolName === "string" ? { name: part.toolName } : {},
|
|
209
|
+
...part.output !== void 0 ? { content: part.output } : {},
|
|
210
|
+
...part.error ? { error: part.error } : {},
|
|
211
|
+
...jsonTimeFields(part),
|
|
212
|
+
...jsonMetadata(part.metadata)
|
|
213
|
+
});
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
throw new TypeError(
|
|
217
|
+
"Message content parts must use the harness message contract."
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
return events.length > 0 ? events : void 0;
|
|
221
|
+
}
|
|
222
|
+
function toolResultMessageEvent(message, toolCallId) {
|
|
223
|
+
return {
|
|
224
|
+
type: "tool_result",
|
|
225
|
+
toolCallId,
|
|
226
|
+
...message.name ? { name: message.name } : {},
|
|
227
|
+
...message.content !== void 0 ? { content: message.content } : {},
|
|
228
|
+
...message.error ? { error: message.error } : {},
|
|
229
|
+
...timeFields(message),
|
|
230
|
+
...recordMetadata(message.metadata)
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function hasTopLevelToolCallId(message) {
|
|
234
|
+
return typeof message.toolCallId === "string";
|
|
235
|
+
}
|
|
236
|
+
function timeFields(input) {
|
|
237
|
+
return {
|
|
238
|
+
...input.startedAt ? { startedAt: input.startedAt } : {},
|
|
239
|
+
...input.finishedAt ? { finishedAt: input.finishedAt } : {},
|
|
240
|
+
...input.durationMs !== void 0 ? { durationMs: input.durationMs } : {}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
function recordMetadata(metadata) {
|
|
244
|
+
return metadata ? { metadata } : {};
|
|
245
|
+
}
|
|
246
|
+
function jsonTimeFields(input) {
|
|
247
|
+
return {
|
|
248
|
+
...typeof input.startedAt === "string" ? { startedAt: input.startedAt } : {},
|
|
249
|
+
...typeof input.finishedAt === "string" ? { finishedAt: input.finishedAt } : {},
|
|
250
|
+
...typeof input.durationMs === "number" ? { durationMs: input.durationMs } : {}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function jsonMetadata(value) {
|
|
254
|
+
return isJsonObject2(value) ? { metadata: value } : {};
|
|
255
|
+
}
|
|
256
|
+
function normalizeToolCallArguments(value) {
|
|
257
|
+
return value && typeof value === "object" && !Array.isArray(value) ? { arguments: value } : {};
|
|
258
|
+
}
|
|
259
|
+
function isJsonObject2(value) {
|
|
260
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
261
|
+
}
|
|
262
|
+
function isMessageEvent(event) {
|
|
263
|
+
return event.type === "message";
|
|
264
|
+
}
|
|
265
|
+
function isToolCallEvent(event) {
|
|
266
|
+
return event.type === "tool_call";
|
|
267
|
+
}
|
|
268
|
+
function isToolResultEvent(event) {
|
|
269
|
+
return event.type === "tool_result";
|
|
270
|
+
}
|
|
271
|
+
|
|
50
272
|
// src/harness/index.ts
|
|
51
|
-
var UsageSummarySchema =
|
|
52
|
-
provider:
|
|
53
|
-
model:
|
|
273
|
+
var UsageSummarySchema = z5.object({
|
|
274
|
+
provider: z5.string().optional(),
|
|
275
|
+
model: z5.string().optional(),
|
|
54
276
|
inputTokens: FiniteNumberSchema.optional(),
|
|
55
277
|
outputTokens: FiniteNumberSchema.optional(),
|
|
56
278
|
reasoningTokens: FiniteNumberSchema.optional(),
|
|
@@ -59,182 +281,213 @@ var UsageSummarySchema = z3.object({
|
|
|
59
281
|
retries: FiniteNumberSchema.optional(),
|
|
60
282
|
metadata: JsonObjectSchema.optional()
|
|
61
283
|
}).strict();
|
|
62
|
-
var TimingSummarySchema =
|
|
284
|
+
var TimingSummarySchema = z5.object({
|
|
63
285
|
totalMs: FiniteNumberSchema.optional(),
|
|
64
286
|
metadata: JsonObjectSchema.optional()
|
|
65
287
|
}).strict();
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}).catchall(JsonValueSchema);
|
|
70
|
-
var ToolCallRecordSchema = z3.object({
|
|
71
|
-
id: z3.string().optional(),
|
|
72
|
-
name: z3.string(),
|
|
73
|
-
arguments: JsonObjectSchema.optional(),
|
|
74
|
-
result: JsonValueSchema.optional(),
|
|
75
|
-
error: NormalizedErrorSchema.optional(),
|
|
76
|
-
startedAt: z3.string().optional(),
|
|
77
|
-
finishedAt: z3.string().optional(),
|
|
78
|
-
durationMs: FiniteNumberSchema.optional(),
|
|
79
|
-
metadata: JsonObjectSchema.optional()
|
|
80
|
-
}).strict();
|
|
81
|
-
var NormalizedMessageSchema = z3.object({
|
|
82
|
-
role: z3.enum(["system", "user", "assistant", "tool"]),
|
|
83
|
-
content: JsonValueSchema.optional(),
|
|
84
|
-
toolCalls: z3.array(ToolCallRecordSchema).optional(),
|
|
85
|
-
metadata: JsonObjectSchema.optional()
|
|
288
|
+
var ToolCallBaseSchema = z5.object({
|
|
289
|
+
name: z5.string(),
|
|
290
|
+
arguments: JsonObjectSchema.optional()
|
|
86
291
|
}).strict();
|
|
87
|
-
var
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
292
|
+
var ToolCallSchema = z5.discriminatedUnion("status", [
|
|
293
|
+
ToolCallBaseSchema.extend({
|
|
294
|
+
status: z5.literal("pending")
|
|
295
|
+
}).strict(),
|
|
296
|
+
ToolCallBaseSchema.extend({
|
|
297
|
+
status: z5.literal("ok"),
|
|
298
|
+
result: JsonValueSchema.optional()
|
|
299
|
+
}).strict(),
|
|
300
|
+
ToolCallBaseSchema.extend({
|
|
301
|
+
status: z5.literal("error"),
|
|
302
|
+
error: NormalizedErrorSchema
|
|
303
|
+
}).strict()
|
|
304
|
+
]);
|
|
305
|
+
var NormalizedSessionSchema = z5.object({
|
|
306
|
+
events: z5.array(TranscriptEventSchema),
|
|
307
|
+
provider: z5.string().optional(),
|
|
308
|
+
model: z5.string().optional(),
|
|
91
309
|
metadata: JsonObjectSchema.optional()
|
|
92
310
|
}).strict();
|
|
93
311
|
var NormalizedSpanAttributesSchema = JsonObjectSchema;
|
|
94
|
-
var NormalizedSpanEventSchema =
|
|
95
|
-
name:
|
|
96
|
-
timestamp:
|
|
312
|
+
var NormalizedSpanEventSchema = z5.object({
|
|
313
|
+
name: z5.string(),
|
|
314
|
+
timestamp: z5.string().optional(),
|
|
97
315
|
attributes: NormalizedSpanAttributesSchema.optional()
|
|
98
316
|
}).strict();
|
|
99
|
-
var NormalizedSpanSchema =
|
|
100
|
-
id:
|
|
101
|
-
traceId:
|
|
102
|
-
parentId:
|
|
103
|
-
name:
|
|
104
|
-
kind:
|
|
105
|
-
startedAt:
|
|
106
|
-
finishedAt:
|
|
317
|
+
var NormalizedSpanSchema = z5.object({
|
|
318
|
+
id: z5.string().optional(),
|
|
319
|
+
traceId: z5.string().optional(),
|
|
320
|
+
parentId: z5.string().optional(),
|
|
321
|
+
name: z5.string(),
|
|
322
|
+
kind: z5.enum(["run", "agent", "model", "tool", "guardrail", "handoff", "custom"]).optional(),
|
|
323
|
+
startedAt: z5.string().optional(),
|
|
324
|
+
finishedAt: z5.string().optional(),
|
|
107
325
|
durationMs: FiniteNumberSchema.optional(),
|
|
108
|
-
status:
|
|
326
|
+
status: z5.enum(["ok", "error"]).optional(),
|
|
109
327
|
error: NormalizedErrorSchema.optional(),
|
|
110
328
|
attributes: NormalizedSpanAttributesSchema.optional(),
|
|
111
|
-
events:
|
|
329
|
+
events: z5.array(NormalizedSpanEventSchema).optional()
|
|
112
330
|
}).strict();
|
|
113
|
-
var NormalizedTraceSchema =
|
|
114
|
-
id:
|
|
115
|
-
name:
|
|
116
|
-
startedAt:
|
|
117
|
-
finishedAt:
|
|
331
|
+
var NormalizedTraceSchema = z5.object({
|
|
332
|
+
id: z5.string().optional(),
|
|
333
|
+
name: z5.string().optional(),
|
|
334
|
+
startedAt: z5.string().optional(),
|
|
335
|
+
finishedAt: z5.string().optional(),
|
|
118
336
|
durationMs: FiniteNumberSchema.optional(),
|
|
119
337
|
metadata: JsonObjectSchema.optional(),
|
|
120
|
-
spans:
|
|
338
|
+
spans: z5.array(NormalizedSpanSchema)
|
|
121
339
|
}).strict();
|
|
122
|
-
var HarnessRunSchema =
|
|
340
|
+
var HarnessRunSchema = z5.object({
|
|
123
341
|
output: JsonValueSchema.optional(),
|
|
124
342
|
session: NormalizedSessionSchema,
|
|
125
343
|
usage: UsageSummarySchema,
|
|
126
344
|
timings: TimingSummarySchema.optional(),
|
|
127
345
|
artifacts: JsonObjectSchema.optional(),
|
|
128
|
-
traces:
|
|
129
|
-
errors:
|
|
346
|
+
traces: z5.array(NormalizedTraceSchema).optional(),
|
|
347
|
+
errors: z5.array(JsonObjectSchema)
|
|
130
348
|
}).strict();
|
|
131
349
|
|
|
132
350
|
// src/harness/helpers.ts
|
|
133
|
-
function toolCalls(
|
|
134
|
-
|
|
351
|
+
function toolCalls(source) {
|
|
352
|
+
const resultsById = /* @__PURE__ */ new Map();
|
|
353
|
+
for (const message of toolResultsFromSource(source)) {
|
|
354
|
+
if (!resultsById.has(message.toolCallId)) {
|
|
355
|
+
resultsById.set(message.toolCallId, message);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return toolCallsFromSource(source).map((call) => {
|
|
359
|
+
const result = resultsById.get(call.id);
|
|
360
|
+
const normalizedCall = {
|
|
361
|
+
name: call.name,
|
|
362
|
+
...call.arguments ? { arguments: call.arguments } : {}
|
|
363
|
+
};
|
|
364
|
+
if (!result) {
|
|
365
|
+
return {
|
|
366
|
+
...normalizedCall,
|
|
367
|
+
status: "pending"
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
if (result.error) {
|
|
371
|
+
return {
|
|
372
|
+
...normalizedCall,
|
|
373
|
+
status: "error",
|
|
374
|
+
error: result.error
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
...normalizedCall,
|
|
379
|
+
status: "ok",
|
|
380
|
+
...result.content !== void 0 ? { result: result.content } : {}
|
|
381
|
+
};
|
|
382
|
+
});
|
|
135
383
|
}
|
|
136
|
-
function spans(
|
|
137
|
-
return (
|
|
384
|
+
function spans(source) {
|
|
385
|
+
return spansFrom(source);
|
|
138
386
|
}
|
|
139
|
-
function traceSpans(
|
|
140
|
-
return
|
|
387
|
+
function traceSpans(source) {
|
|
388
|
+
return spansFrom(source);
|
|
141
389
|
}
|
|
142
|
-
function spansByKind(
|
|
143
|
-
return
|
|
390
|
+
function spansByKind(source, kind) {
|
|
391
|
+
return spansFrom(source).filter((span) => span.kind === kind);
|
|
144
392
|
}
|
|
145
|
-
function failedSpans(
|
|
146
|
-
return
|
|
393
|
+
function failedSpans(source) {
|
|
394
|
+
return spansFrom(source).filter(
|
|
147
395
|
(span) => span.status === "error" || span.error !== void 0
|
|
148
396
|
);
|
|
149
397
|
}
|
|
150
|
-
function messagesByRole(
|
|
151
|
-
return
|
|
398
|
+
function messagesByRole(source, role) {
|
|
399
|
+
return sessionFrom(source).events.filter(
|
|
400
|
+
(event) => event.type === "message" && event.role === role
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
function systemMessages(source) {
|
|
404
|
+
return messagesByRoleFromSource(source, "system");
|
|
405
|
+
}
|
|
406
|
+
function userMessages(source) {
|
|
407
|
+
return messagesByRoleFromSource(source, "user");
|
|
408
|
+
}
|
|
409
|
+
function assistantMessages(source) {
|
|
410
|
+
return messagesByRoleFromSource(source, "assistant");
|
|
152
411
|
}
|
|
153
|
-
function
|
|
154
|
-
return
|
|
412
|
+
function latestAssistantMessageContent(source) {
|
|
413
|
+
return [...messagesByRoleFromSource(source, "assistant")].reverse().find(hasNonEmptyMessageContent)?.content;
|
|
155
414
|
}
|
|
156
|
-
function
|
|
157
|
-
return
|
|
415
|
+
function toolMessages(source) {
|
|
416
|
+
return toolResultsFromSource(source);
|
|
158
417
|
}
|
|
159
|
-
function
|
|
160
|
-
return
|
|
418
|
+
function sessionFrom(source) {
|
|
419
|
+
return "session" in source ? source.session : source;
|
|
161
420
|
}
|
|
162
|
-
function
|
|
163
|
-
return
|
|
421
|
+
function toolResultsFromSource(source) {
|
|
422
|
+
return sessionFrom(source).events.filter(isToolResultEvent);
|
|
164
423
|
}
|
|
165
|
-
function
|
|
166
|
-
return
|
|
424
|
+
function toolCallsFromSource(source) {
|
|
425
|
+
return sessionFrom(source).events.filter(isToolCallEvent);
|
|
426
|
+
}
|
|
427
|
+
function tracesFrom(source) {
|
|
428
|
+
if (source === void 0) {
|
|
429
|
+
return [];
|
|
430
|
+
}
|
|
431
|
+
if (isTraceList(source)) {
|
|
432
|
+
return source;
|
|
433
|
+
}
|
|
434
|
+
return source.traces ?? [];
|
|
435
|
+
}
|
|
436
|
+
function spansFrom(source) {
|
|
437
|
+
return tracesFrom(source).flatMap((trace) => trace.spans);
|
|
438
|
+
}
|
|
439
|
+
function isTraceList(source) {
|
|
440
|
+
return Array.isArray(source);
|
|
441
|
+
}
|
|
442
|
+
function messagesByRoleFromSource(source, role) {
|
|
443
|
+
return sessionFrom(source).events.filter(
|
|
444
|
+
(event) => event.type === "message" && event.role === role
|
|
445
|
+
);
|
|
167
446
|
}
|
|
168
447
|
function hasNonEmptyMessageContent(message) {
|
|
169
448
|
return message.content !== void 0 && (typeof message.content !== "string" || message.content.trim().length > 0);
|
|
170
449
|
}
|
|
171
450
|
|
|
172
451
|
// src/report/metadata.ts
|
|
173
|
-
import { z as
|
|
174
|
-
var HarnessMetaSchema =
|
|
175
|
-
name:
|
|
452
|
+
import { z as z6 } from "zod";
|
|
453
|
+
var HarnessMetaSchema = z6.object({
|
|
454
|
+
name: z6.string().optional(),
|
|
176
455
|
run: HarnessRunSchema.optional()
|
|
177
456
|
}).strict();
|
|
178
|
-
var EvalScoreSchema =
|
|
179
|
-
name:
|
|
457
|
+
var EvalScoreSchema = z6.object({
|
|
458
|
+
name: z6.string().optional(),
|
|
180
459
|
score: NullableFiniteNumberSchema,
|
|
181
460
|
metadata: JsonObjectSchema.optional()
|
|
182
461
|
}).strict();
|
|
183
|
-
var EvalMetaSchema =
|
|
184
|
-
scores:
|
|
462
|
+
var EvalMetaSchema = z6.object({
|
|
463
|
+
scores: z6.array(EvalScoreSchema).optional(),
|
|
185
464
|
avgScore: NullableFiniteNumberSchema,
|
|
186
465
|
output: JsonValueSchema.optional(),
|
|
187
|
-
thresholdFailed:
|
|
188
|
-
toolCalls:
|
|
466
|
+
thresholdFailed: z6.boolean().optional(),
|
|
467
|
+
toolCalls: z6.array(ToolCallSchema).optional()
|
|
189
468
|
}).strict();
|
|
190
|
-
var EvalTaskMetaSchema =
|
|
469
|
+
var EvalTaskMetaSchema = z6.object({
|
|
191
470
|
eval: EvalMetaSchema.optional(),
|
|
192
471
|
harness: HarnessMetaSchema.optional()
|
|
193
472
|
}).strict();
|
|
194
|
-
var LenientToolCallRecordSchema = ToolCallRecordSchema.strip();
|
|
195
|
-
var LenientMessageSchema = NormalizedMessageSchema.extend({
|
|
196
|
-
toolCalls: z4.array(LenientToolCallRecordSchema).optional().catch(void 0)
|
|
197
|
-
}).strip();
|
|
198
|
-
var LenientSessionSchema = NormalizedSessionSchema.extend({
|
|
199
|
-
messages: z4.array(LenientMessageSchema).default([]).catch([])
|
|
200
|
-
}).strip();
|
|
201
|
-
var LenientSpanEventSchema = NormalizedSpanEventSchema.strip();
|
|
202
|
-
var LenientSpanSchema = NormalizedSpanSchema.extend({
|
|
203
|
-
events: z4.array(LenientSpanEventSchema).optional().catch(void 0)
|
|
204
|
-
}).strip();
|
|
205
|
-
var LenientTraceSchema = NormalizedTraceSchema.extend({
|
|
206
|
-
spans: z4.array(LenientSpanSchema).default([]).catch([])
|
|
207
|
-
}).strip();
|
|
208
|
-
var LenientHarnessRunSchema = HarnessRunSchema.extend({
|
|
209
|
-
session: LenientSessionSchema,
|
|
210
|
-
usage: UsageSummarySchema.strip().default({}),
|
|
211
|
-
timings: TimingSummarySchema.strip().optional(),
|
|
212
|
-
traces: z4.array(LenientTraceSchema).optional().catch(void 0)
|
|
213
|
-
}).strip();
|
|
214
|
-
var LenientHarnessMetaSchema = HarnessMetaSchema.extend({
|
|
215
|
-
run: LenientHarnessRunSchema.optional().catch(void 0)
|
|
216
|
-
}).strip();
|
|
217
|
-
var LenientEvalScoreSchema = EvalScoreSchema.strip();
|
|
218
|
-
var LenientEvalMetaSchema = EvalMetaSchema.extend({
|
|
219
|
-
scores: z4.array(LenientEvalScoreSchema).optional().catch(void 0),
|
|
220
|
-
toolCalls: z4.array(LenientToolCallRecordSchema).optional().catch(void 0)
|
|
221
|
-
}).strip();
|
|
222
473
|
function readEvalTaskMeta(input) {
|
|
223
474
|
if (!isJsonObject(input)) {
|
|
224
475
|
return void 0;
|
|
225
476
|
}
|
|
226
|
-
const evalResult = LenientEvalMetaSchema.safeParse(input.eval);
|
|
227
|
-
const harnessResult = LenientHarnessMetaSchema.safeParse(input.harness);
|
|
228
477
|
const meta = {
|
|
229
|
-
...
|
|
230
|
-
...
|
|
478
|
+
...input.eval !== void 0 ? { eval: input.eval } : {},
|
|
479
|
+
...input.harness !== void 0 ? { harness: input.harness } : {}
|
|
231
480
|
};
|
|
232
|
-
|
|
481
|
+
if (!("eval" in meta) && !("harness" in meta)) {
|
|
482
|
+
return void 0;
|
|
483
|
+
}
|
|
484
|
+
const result = EvalTaskMetaSchema.safeParse(meta);
|
|
485
|
+
return result.success ? result.data : void 0;
|
|
233
486
|
}
|
|
234
487
|
|
|
235
488
|
// src/report/vitest-json.ts
|
|
236
|
-
import { z as
|
|
237
|
-
var VitestJsonStatusSchema =
|
|
489
|
+
import { z as z7 } from "zod";
|
|
490
|
+
var VitestJsonStatusSchema = z7.enum([
|
|
238
491
|
"passed",
|
|
239
492
|
"failed",
|
|
240
493
|
"skipped",
|
|
@@ -242,53 +495,53 @@ var VitestJsonStatusSchema = z5.enum([
|
|
|
242
495
|
"todo",
|
|
243
496
|
"disabled"
|
|
244
497
|
]);
|
|
245
|
-
var VitestJsonLocationSchema =
|
|
498
|
+
var VitestJsonLocationSchema = z7.object({
|
|
246
499
|
line: FiniteNumberSchema,
|
|
247
500
|
column: FiniteNumberSchema
|
|
248
501
|
}).passthrough();
|
|
249
|
-
var VitestJsonAssertionSchema =
|
|
250
|
-
ancestorTitles:
|
|
251
|
-
fullName:
|
|
502
|
+
var VitestJsonAssertionSchema = z7.object({
|
|
503
|
+
ancestorTitles: z7.array(z7.string()).default([]),
|
|
504
|
+
fullName: z7.string(),
|
|
252
505
|
status: VitestJsonStatusSchema,
|
|
253
|
-
title:
|
|
254
|
-
meta:
|
|
506
|
+
title: z7.string(),
|
|
507
|
+
meta: z7.unknown().optional(),
|
|
255
508
|
duration: FiniteNumberSchema.nullable().optional(),
|
|
256
|
-
failureMessages:
|
|
509
|
+
failureMessages: z7.array(z7.string()).nullable().optional(),
|
|
257
510
|
location: VitestJsonLocationSchema.nullable().optional(),
|
|
258
|
-
tags:
|
|
511
|
+
tags: z7.array(z7.string()).optional()
|
|
259
512
|
}).passthrough();
|
|
260
|
-
var VitestJsonFileSchema =
|
|
261
|
-
message:
|
|
262
|
-
name:
|
|
263
|
-
status:
|
|
513
|
+
var VitestJsonFileSchema = z7.object({
|
|
514
|
+
message: z7.string(),
|
|
515
|
+
name: z7.string(),
|
|
516
|
+
status: z7.enum(["failed", "passed"]),
|
|
264
517
|
startTime: OptionalFiniteNumberSchema,
|
|
265
518
|
endTime: OptionalFiniteNumberSchema,
|
|
266
|
-
assertionResults:
|
|
519
|
+
assertionResults: z7.array(VitestJsonAssertionSchema).default([])
|
|
267
520
|
}).passthrough();
|
|
268
|
-
var VitestJsonReportSchema =
|
|
521
|
+
var VitestJsonReportSchema = z7.object({
|
|
269
522
|
numFailedTests: FiniteNumberSchema,
|
|
270
523
|
numPassedTests: FiniteNumberSchema,
|
|
271
524
|
numPendingTests: FiniteNumberSchema,
|
|
272
525
|
numTodoTests: FiniteNumberSchema,
|
|
273
526
|
numTotalTests: FiniteNumberSchema,
|
|
274
527
|
startTime: FiniteNumberSchema,
|
|
275
|
-
success:
|
|
276
|
-
testResults:
|
|
528
|
+
success: z7.boolean(),
|
|
529
|
+
testResults: z7.array(VitestJsonFileSchema).default([])
|
|
277
530
|
}).passthrough();
|
|
278
531
|
function parseVitestJsonReport(input) {
|
|
279
532
|
return parseWithSchema(VitestJsonReportSchema, input, "Vitest JSON report");
|
|
280
533
|
}
|
|
281
534
|
|
|
282
535
|
// src/report/workspace.ts
|
|
283
|
-
import { z as
|
|
536
|
+
import { z as z8 } from "zod";
|
|
284
537
|
var REPORT_WORKSPACE_SCHEMA_VERSION = 1;
|
|
285
|
-
var ReportRunSchema =
|
|
286
|
-
id:
|
|
287
|
-
source:
|
|
288
|
-
status:
|
|
538
|
+
var ReportRunSchema = z8.object({
|
|
539
|
+
id: z8.string(),
|
|
540
|
+
source: z8.string().optional(),
|
|
541
|
+
status: z8.enum(["passed", "failed"]),
|
|
289
542
|
startedAt: FiniteNumberSchema.optional(),
|
|
290
543
|
durationMs: FiniteNumberSchema.optional(),
|
|
291
|
-
totals:
|
|
544
|
+
totals: z8.object({
|
|
292
545
|
total: FiniteNumberSchema,
|
|
293
546
|
passed: FiniteNumberSchema,
|
|
294
547
|
failed: FiniteNumberSchema,
|
|
@@ -298,28 +551,28 @@ var ReportRunSchema = z6.object({
|
|
|
298
551
|
evalFailed: FiniteNumberSchema
|
|
299
552
|
})
|
|
300
553
|
}).strict();
|
|
301
|
-
var ReportCaseSchema =
|
|
302
|
-
id:
|
|
303
|
-
runId:
|
|
304
|
-
source:
|
|
305
|
-
file:
|
|
306
|
-
displayFile:
|
|
307
|
-
title:
|
|
308
|
-
fullName:
|
|
309
|
-
ancestorTitles:
|
|
310
|
-
tags:
|
|
311
|
-
displayName:
|
|
554
|
+
var ReportCaseSchema = z8.object({
|
|
555
|
+
id: z8.string(),
|
|
556
|
+
runId: z8.string(),
|
|
557
|
+
source: z8.string().optional(),
|
|
558
|
+
file: z8.string(),
|
|
559
|
+
displayFile: z8.string(),
|
|
560
|
+
title: z8.string(),
|
|
561
|
+
fullName: z8.string(),
|
|
562
|
+
ancestorTitles: z8.array(z8.string()),
|
|
563
|
+
tags: z8.array(z8.string()).optional(),
|
|
564
|
+
displayName: z8.string(),
|
|
312
565
|
status: VitestJsonStatusSchema,
|
|
313
566
|
durationMs: FiniteNumberSchema.optional(),
|
|
314
567
|
location: VitestJsonLocationSchema.optional(),
|
|
315
|
-
failureMessages:
|
|
568
|
+
failureMessages: z8.array(z8.string()).default([]),
|
|
316
569
|
eval: EvalMetaSchema.optional(),
|
|
317
570
|
harness: HarnessMetaSchema.optional()
|
|
318
571
|
}).strict();
|
|
319
|
-
var ReportWorkspaceSchema =
|
|
320
|
-
schemaVersion:
|
|
321
|
-
runs:
|
|
322
|
-
cases:
|
|
572
|
+
var ReportWorkspaceSchema = z8.object({
|
|
573
|
+
schemaVersion: z8.literal(REPORT_WORKSPACE_SCHEMA_VERSION),
|
|
574
|
+
runs: z8.array(ReportRunSchema),
|
|
575
|
+
cases: z8.array(ReportCaseSchema)
|
|
323
576
|
}).strict();
|
|
324
577
|
function parseReportWorkspace(input) {
|
|
325
578
|
return parseWithSchema(ReportWorkspaceSchema, input, "report workspace");
|
|
@@ -452,7 +705,6 @@ export {
|
|
|
452
705
|
JsonPrimitiveSchema,
|
|
453
706
|
JsonValueSchema,
|
|
454
707
|
NormalizedErrorSchema,
|
|
455
|
-
NormalizedMessageSchema,
|
|
456
708
|
NormalizedSessionSchema,
|
|
457
709
|
NormalizedSpanAttributesSchema,
|
|
458
710
|
NormalizedSpanEventSchema,
|
|
@@ -463,7 +715,11 @@ export {
|
|
|
463
715
|
ReportRunSchema,
|
|
464
716
|
ReportWorkspaceSchema,
|
|
465
717
|
TimingSummarySchema,
|
|
466
|
-
|
|
718
|
+
ToolCallSchema,
|
|
719
|
+
TranscriptEventSchema,
|
|
720
|
+
TranscriptMessageEventSchema,
|
|
721
|
+
TranscriptToolCallEventSchema,
|
|
722
|
+
TranscriptToolResultEventSchema,
|
|
467
723
|
UsageSummarySchema,
|
|
468
724
|
VitestJsonAssertionSchema,
|
|
469
725
|
VitestJsonFileSchema,
|
|
@@ -473,8 +729,12 @@ export {
|
|
|
473
729
|
assistantMessages,
|
|
474
730
|
collectReportWorkspace,
|
|
475
731
|
failedSpans,
|
|
732
|
+
isMessageEvent,
|
|
733
|
+
isToolCallEvent,
|
|
734
|
+
isToolResultEvent,
|
|
476
735
|
latestAssistantMessageContent,
|
|
477
736
|
messagesByRole,
|
|
737
|
+
messagesToTranscriptEvents,
|
|
478
738
|
parseReportWorkspace,
|
|
479
739
|
parseVitestJsonReport,
|
|
480
740
|
readEvalTaskMeta,
|