@stigmer/eval-runtime 0.0.0-stage → 3.41.1-dev.20261011143907.gb2e0845f35f1
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/LICENSE +190 -0
- package/expect.d.ts +116 -0
- package/expect.d.ts.map +1 -0
- package/expect.js +363 -0
- package/expect.js.map +1 -0
- package/index.d.ts +5 -0
- package/index.d.ts.map +1 -0
- package/index.js +9 -0
- package/index.js.map +1 -0
- package/mock.d.ts +56 -0
- package/mock.d.ts.map +1 -0
- package/mock.js +167 -0
- package/mock.js.map +1 -0
- package/package.json +29 -4
- package/src/expect.ts +395 -0
- package/src/index.ts +33 -0
- package/src/mock.ts +176 -0
- package/src/transcript.ts +254 -0
- package/src/try-stop.ts +94 -0
- package/transcript.d.ts +84 -0
- package/transcript.d.ts.map +1 -0
- package/transcript.js +230 -0
- package/transcript.js.map +1 -0
- package/try-stop.d.ts +49 -0
- package/try-stop.d.ts.map +1 -0
- package/try-stop.js +84 -0
- package/try-stop.js.map +1 -0
- package/README.md +0 -3
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin-eval format's transcripts: a Claude Code session saved as
|
|
3
|
+
* `.jsonl`, one record per line, read as the conversation a model saw.
|
|
4
|
+
*
|
|
5
|
+
* One reader for every use of the format's transcripts. The suite reader
|
|
6
|
+
* checks a case's `history_file` with it at push; the runner turns the same
|
|
7
|
+
* messages into a resumed try's first input; the `baseline` grader renders
|
|
8
|
+
* a reference transcript from it as text for the judge. Kept here so a
|
|
9
|
+
* history the server accepted is the history the runner resumes.
|
|
10
|
+
*
|
|
11
|
+
* What a record is. Claude Code writes `{"type": "user" | "assistant",
|
|
12
|
+
* "message": {"role", "content"}}` per record, beside records of other
|
|
13
|
+
* types (`summary`, `system`, file snapshots) and sidechain records a
|
|
14
|
+
* sub-agent wrote (`isSidechain: true`). Only the main conversation's user
|
|
15
|
+
* and assistant records are a conversation; the rest are dropped. An
|
|
16
|
+
* assistant reply is often split over several records, one per content
|
|
17
|
+
* block, and tool results arrive one per record, so consecutive records of
|
|
18
|
+
* one role are joined into one message, which is also what a model API
|
|
19
|
+
* requires.
|
|
20
|
+
*
|
|
21
|
+
* What a block is. `text`, `tool_use` and `tool_result` are kept; a call
|
|
22
|
+
* or result missing its id is kept with an empty one, which a rendering
|
|
23
|
+
* shows and the pairing rule refuses.
|
|
24
|
+
* `thinking` and `redacted_thinking` are dropped: a thinking block carries
|
|
25
|
+
* a signature that binds it to the turn that produced it, and a resumed
|
|
26
|
+
* conversation is a new turn. An image becomes the words "[image]", since
|
|
27
|
+
* nothing here carries media.
|
|
28
|
+
*
|
|
29
|
+
* The pairing rule, checked only when asked ({@link parseTranscript}'s
|
|
30
|
+
* `requirePairing`): every `tool_use` is answered by a `tool_result` in the
|
|
31
|
+
* user message right after it, and every `tool_result` answers a
|
|
32
|
+
* `tool_use` of the assistant message right before it, as a model API
|
|
33
|
+
* requires of a history it is sent. A rendering for a judge does not need
|
|
34
|
+
* it and reads leniently.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/** One content block of a transcript message. */
|
|
38
|
+
export type TranscriptBlock =
|
|
39
|
+
| { readonly type: "text"; readonly text: string }
|
|
40
|
+
| {
|
|
41
|
+
readonly type: "tool_use";
|
|
42
|
+
readonly id: string;
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
45
|
+
}
|
|
46
|
+
| {
|
|
47
|
+
readonly type: "tool_result";
|
|
48
|
+
readonly toolUseId: string;
|
|
49
|
+
/** The result's text; non-text parts named in brackets. */
|
|
50
|
+
readonly content: string;
|
|
51
|
+
readonly isError: boolean;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** One message of a transcript, records of one role joined. */
|
|
55
|
+
export interface TranscriptMessage {
|
|
56
|
+
readonly role: "user" | "assistant";
|
|
57
|
+
readonly blocks: readonly TranscriptBlock[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** A parsed transcript, or why it cannot be resumed. */
|
|
61
|
+
export type TranscriptParse =
|
|
62
|
+
| { readonly ok: true; readonly messages: readonly TranscriptMessage[] }
|
|
63
|
+
| { readonly ok: false; readonly error: string };
|
|
64
|
+
|
|
65
|
+
/** How strictly {@link parseTranscript} reads. */
|
|
66
|
+
export interface TranscriptParseOptions {
|
|
67
|
+
/** Refuse a transcript whose tool calls and results do not pair (the module header). */
|
|
68
|
+
readonly requirePairing: boolean;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Read a `.jsonl` transcript. A line that is not JSON is an error naming
|
|
73
|
+
* its number; so is an empty conversation, and, under `requirePairing`, an
|
|
74
|
+
* unpaired tool call or result.
|
|
75
|
+
*/
|
|
76
|
+
export function parseTranscript(text: string, options: TranscriptParseOptions): TranscriptParse {
|
|
77
|
+
const messages: { role: "user" | "assistant"; blocks: TranscriptBlock[] }[] = [];
|
|
78
|
+
const lines = text.split("\n");
|
|
79
|
+
for (let i = 0; i < lines.length; i++) {
|
|
80
|
+
const line = (lines[i] ?? "").trim();
|
|
81
|
+
if (line === "") continue;
|
|
82
|
+
let record: unknown;
|
|
83
|
+
try {
|
|
84
|
+
record = JSON.parse(line);
|
|
85
|
+
} catch {
|
|
86
|
+
return { ok: false, error: `line ${i + 1} is not JSON` };
|
|
87
|
+
}
|
|
88
|
+
const read = messageOf(record);
|
|
89
|
+
if (read === undefined || read.blocks.length === 0) continue;
|
|
90
|
+
const last = messages.at(-1);
|
|
91
|
+
if (last !== undefined && last.role === read.role) {
|
|
92
|
+
last.blocks.push(...read.blocks);
|
|
93
|
+
} else {
|
|
94
|
+
messages.push({ role: read.role, blocks: [...read.blocks] });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (messages.length === 0) {
|
|
98
|
+
return { ok: false, error: "it holds no user or assistant message" };
|
|
99
|
+
}
|
|
100
|
+
if (options.requirePairing) {
|
|
101
|
+
const unpaired = pairingError(messages);
|
|
102
|
+
if (unpaired !== undefined) return { ok: false, error: unpaired };
|
|
103
|
+
}
|
|
104
|
+
return { ok: true, messages };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A transcript as text for a judge, one message per line: "role: text",
|
|
109
|
+
* with tool calls and results named in brackets. Records that are not the
|
|
110
|
+
* conversation are dropped as {@link parseTranscript} drops them; a line
|
|
111
|
+
* that is not JSON is kept where it stands, as written, so a judge still
|
|
112
|
+
* reads what an author put there.
|
|
113
|
+
*/
|
|
114
|
+
export function renderTranscript(text: string): string {
|
|
115
|
+
const out: string[] = [];
|
|
116
|
+
let last: { role: "user" | "assistant"; parts: string[] } | undefined;
|
|
117
|
+
for (const raw of text.split("\n")) {
|
|
118
|
+
const line = raw.trim();
|
|
119
|
+
if (line === "") continue;
|
|
120
|
+
let record: unknown;
|
|
121
|
+
try {
|
|
122
|
+
record = JSON.parse(line);
|
|
123
|
+
} catch {
|
|
124
|
+
if (last !== undefined) out.push(`${last.role}: ${last.parts.join(" ")}`);
|
|
125
|
+
last = undefined;
|
|
126
|
+
out.push(line);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const read = messageOf(record);
|
|
130
|
+
if (read === undefined || read.blocks.length === 0) continue;
|
|
131
|
+
const parts = read.blocks.map(renderBlock);
|
|
132
|
+
if (last !== undefined && last.role === read.role) {
|
|
133
|
+
last.parts.push(...parts);
|
|
134
|
+
} else {
|
|
135
|
+
if (last !== undefined) out.push(`${last.role}: ${last.parts.join(" ")}`);
|
|
136
|
+
last = { role: read.role, parts };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (last !== undefined) out.push(`${last.role}: ${last.parts.join(" ")}`);
|
|
140
|
+
return out.join("\n");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function renderBlock(block: TranscriptBlock): string {
|
|
144
|
+
switch (block.type) {
|
|
145
|
+
case "text":
|
|
146
|
+
return block.text;
|
|
147
|
+
case "tool_use":
|
|
148
|
+
return `[called ${block.name} ${JSON.stringify(block.input)}]`;
|
|
149
|
+
case "tool_result":
|
|
150
|
+
return `[tool result: ${block.content}]`;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** The main conversation's message a record carries, or `undefined` for any other record. */
|
|
155
|
+
function messageOf(
|
|
156
|
+
record: unknown,
|
|
157
|
+
): { readonly role: "user" | "assistant"; readonly blocks: readonly TranscriptBlock[] } | undefined {
|
|
158
|
+
if (!isRecord(record) || record["isSidechain"] === true) return undefined;
|
|
159
|
+
const type = record["type"];
|
|
160
|
+
if (type !== "user" && type !== "assistant") return undefined;
|
|
161
|
+
const message = record["message"];
|
|
162
|
+
if (!isRecord(message)) return undefined;
|
|
163
|
+
const content = message["content"];
|
|
164
|
+
if (typeof content === "string") {
|
|
165
|
+
return content.trim() === "" ? undefined : { role: type, blocks: [{ type: "text", text: content }] };
|
|
166
|
+
}
|
|
167
|
+
if (!Array.isArray(content)) return undefined;
|
|
168
|
+
return { role: type, blocks: content.flatMap(blockOf) };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function blockOf(block: unknown): TranscriptBlock[] {
|
|
172
|
+
if (!isRecord(block)) return [];
|
|
173
|
+
switch (block["type"]) {
|
|
174
|
+
case "text":
|
|
175
|
+
return typeof block["text"] === "string" && block["text"] !== ""
|
|
176
|
+
? [{ type: "text", text: block["text"] }]
|
|
177
|
+
: [];
|
|
178
|
+
case "tool_use": {
|
|
179
|
+
const id = typeof block["id"] === "string" ? block["id"] : "";
|
|
180
|
+
const name = block["name"];
|
|
181
|
+
if (typeof name !== "string") return [];
|
|
182
|
+
const input = isRecord(block["input"]) ? block["input"] : {};
|
|
183
|
+
return [{ type: "tool_use", id, name, input }];
|
|
184
|
+
}
|
|
185
|
+
case "tool_result": {
|
|
186
|
+
const toolUseId = typeof block["tool_use_id"] === "string" ? block["tool_use_id"] : "";
|
|
187
|
+
return [
|
|
188
|
+
{
|
|
189
|
+
type: "tool_result",
|
|
190
|
+
toolUseId,
|
|
191
|
+
content: resultText(block["content"]),
|
|
192
|
+
isError: block["is_error"] === true,
|
|
193
|
+
},
|
|
194
|
+
];
|
|
195
|
+
}
|
|
196
|
+
case "image":
|
|
197
|
+
return [{ type: "text", text: "[image]" }];
|
|
198
|
+
default:
|
|
199
|
+
return [];
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** A tool result's content as text: a string as is, text parts joined, other parts named. */
|
|
204
|
+
function resultText(content: unknown): string {
|
|
205
|
+
if (typeof content === "string") return content;
|
|
206
|
+
if (!Array.isArray(content)) return "";
|
|
207
|
+
return content
|
|
208
|
+
.map((part: unknown) => {
|
|
209
|
+
if (!isRecord(part)) return "";
|
|
210
|
+
if (part["type"] === "text" && typeof part["text"] === "string") return part["text"];
|
|
211
|
+
return `[${typeof part["type"] === "string" ? part["type"] : "content"}]`;
|
|
212
|
+
})
|
|
213
|
+
.join("\n");
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** The first pairing violation (the module header), or `undefined`. */
|
|
217
|
+
function pairingError(messages: readonly TranscriptMessage[]): string | undefined {
|
|
218
|
+
for (const [i, message] of messages.entries()) {
|
|
219
|
+
const before = messages[i - 1];
|
|
220
|
+
const after = messages[i + 1];
|
|
221
|
+
if (message.role === "assistant") {
|
|
222
|
+
const answered = new Set(
|
|
223
|
+
after?.blocks.flatMap((b) => (b.type === "tool_result" ? [b.toolUseId] : [])) ?? [],
|
|
224
|
+
);
|
|
225
|
+
for (const block of message.blocks) {
|
|
226
|
+
if (block.type === "tool_use" && !answered.has(block.id)) {
|
|
227
|
+
return `the call ${block.name} (${block.id}) has no tool_result in the next user message`;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (message.blocks.some((b) => b.type === "tool_result")) {
|
|
231
|
+
return `an assistant message carries a tool_result`;
|
|
232
|
+
}
|
|
233
|
+
} else {
|
|
234
|
+
const asked = new Set(
|
|
235
|
+
before?.role === "assistant"
|
|
236
|
+
? before.blocks.flatMap((b) => (b.type === "tool_use" ? [b.id] : []))
|
|
237
|
+
: [],
|
|
238
|
+
);
|
|
239
|
+
for (const block of message.blocks) {
|
|
240
|
+
if (block.type === "tool_result" && !asked.has(block.toolUseId)) {
|
|
241
|
+
return `the tool_result for ${block.toolUseId} answers no call of the assistant message before it`;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (message.blocks.some((b) => b.type === "tool_use")) {
|
|
245
|
+
return `a user message carries a tool_use`;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
253
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
254
|
+
}
|
package/src/try-stop.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a run says the platform stopped it for one of a plugin-eval try's own
|
|
3
|
+
* reasons, in words a person reads on the run and the eval parses back.
|
|
4
|
+
*
|
|
5
|
+
* A run's status names no termination reason: a stopped run carries one
|
|
6
|
+
* error sentence. The runner writes these sentences with
|
|
7
|
+
* {@link formatTryStop} and the eval's case workflow reads them with
|
|
8
|
+
* {@link parseTryStop}, so the wording lives once, here, rather than as a
|
|
9
|
+
* literal each side copies. A typed reason belongs to the run's event log
|
|
10
|
+
* when it carries one; until then this pair is the contract.
|
|
11
|
+
*
|
|
12
|
+
* The stops:
|
|
13
|
+
* - `cost-limit`: the run's cost cap. Not an eval stop alone (any run has
|
|
14
|
+
* a cap), but the eval tells a try stopped at its own share by it.
|
|
15
|
+
* - `scaffold-failed`: the case's scaffold script exited non-zero or ran
|
|
16
|
+
* past its limit, before the agent started. The try scores 0 with the
|
|
17
|
+
* error "scaffold failed: <detail>", as the format scores it.
|
|
18
|
+
* - `mock-aborted`: a mock stopped the run: its input guard was violated,
|
|
19
|
+
* its agent ended the run, or the agent mocks' call budget ran out. The
|
|
20
|
+
* try scores 0 with no error, reported as aborted.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** A try's own stop, as both sides read it. */
|
|
24
|
+
export type TryStop =
|
|
25
|
+
| { readonly kind: "cost-limit"; readonly estimatedCostUsd: number; readonly maxCostUsd: number }
|
|
26
|
+
| { readonly kind: "scaffold-failed"; readonly detail: string }
|
|
27
|
+
| { readonly kind: "mock-aborted"; readonly server: string; readonly tool: string; readonly reason: string };
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The leading words of a cost-cap stop. Kept stable: a client may tell
|
|
31
|
+
* this stop from the others by them.
|
|
32
|
+
*/
|
|
33
|
+
export const COST_LIMIT_ERROR_PREFIX = "Agent reached the cost limit";
|
|
34
|
+
|
|
35
|
+
const SCAFFOLD_PREFIX = "The eval case's scaffold failed: ";
|
|
36
|
+
const MOCK_PREFIX = "A mock stopped the run: ";
|
|
37
|
+
|
|
38
|
+
/** The run error for a try's stop. */
|
|
39
|
+
export function formatTryStop(stop: TryStop): string {
|
|
40
|
+
switch (stop.kind) {
|
|
41
|
+
case "cost-limit":
|
|
42
|
+
return (
|
|
43
|
+
`${COST_LIMIT_ERROR_PREFIX} for this message ` +
|
|
44
|
+
`(~$${stop.estimatedCostUsd.toFixed(4)} of the $${stop.maxCostUsd.toFixed(2)} budget). ` +
|
|
45
|
+
`Send another message to continue.`
|
|
46
|
+
);
|
|
47
|
+
case "scaffold-failed":
|
|
48
|
+
return `${SCAFFOLD_PREFIX}${oneLine(stop.detail)}`;
|
|
49
|
+
case "mock-aborted":
|
|
50
|
+
return `${MOCK_PREFIX}server ${JSON.stringify(stop.server)}, tool ${JSON.stringify(stop.tool)}: ${oneLine(stop.reason)}`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The try stop a run error names, or `undefined` for any other error. A
|
|
56
|
+
* cost-limit stop's amounts are read when present and 0 otherwise; the
|
|
57
|
+
* eval compares the run's own estimate, not these.
|
|
58
|
+
*/
|
|
59
|
+
export function parseTryStop(error: string): TryStop | undefined {
|
|
60
|
+
if (error.startsWith(COST_LIMIT_ERROR_PREFIX)) {
|
|
61
|
+
const amounts = /\(~\$([0-9.]+) of the \$([0-9.]+) budget\)/.exec(error);
|
|
62
|
+
return {
|
|
63
|
+
kind: "cost-limit",
|
|
64
|
+
estimatedCostUsd: Number(amounts?.[1] ?? 0),
|
|
65
|
+
maxCostUsd: Number(amounts?.[2] ?? 0),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (error.startsWith(SCAFFOLD_PREFIX)) {
|
|
69
|
+
return { kind: "scaffold-failed", detail: error.slice(SCAFFOLD_PREFIX.length) };
|
|
70
|
+
}
|
|
71
|
+
if (error.startsWith(MOCK_PREFIX)) {
|
|
72
|
+
const parts = /^server ("(?:[^"\\]|\\.)*"), tool ("(?:[^"\\]|\\.)*"): ([\s\S]*)$/.exec(error.slice(MOCK_PREFIX.length));
|
|
73
|
+
if (parts === null) return undefined;
|
|
74
|
+
const server = unquoted(parts[1] ?? '""');
|
|
75
|
+
const tool = unquoted(parts[2] ?? '""');
|
|
76
|
+
if (server === undefined || tool === undefined) return undefined;
|
|
77
|
+
return { kind: "mock-aborted", server, tool, reason: parts[3] ?? "" };
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** A JSON string literal's value, or `undefined` for an escape JSON refuses. */
|
|
83
|
+
function unquoted(literal: string): string | undefined {
|
|
84
|
+
try {
|
|
85
|
+
return JSON.parse(literal) as string;
|
|
86
|
+
} catch {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** A detail on one line, so the sentence stays one. */
|
|
92
|
+
function oneLine(text: string): string {
|
|
93
|
+
return text.replace(/\s*[\r\n]+\s*/g, " ").trim();
|
|
94
|
+
}
|
package/transcript.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin-eval format's transcripts: a Claude Code session saved as
|
|
3
|
+
* `.jsonl`, one record per line, read as the conversation a model saw.
|
|
4
|
+
*
|
|
5
|
+
* One reader for every use of the format's transcripts. The suite reader
|
|
6
|
+
* checks a case's `history_file` with it at push; the runner turns the same
|
|
7
|
+
* messages into a resumed try's first input; the `baseline` grader renders
|
|
8
|
+
* a reference transcript from it as text for the judge. Kept here so a
|
|
9
|
+
* history the server accepted is the history the runner resumes.
|
|
10
|
+
*
|
|
11
|
+
* What a record is. Claude Code writes `{"type": "user" | "assistant",
|
|
12
|
+
* "message": {"role", "content"}}` per record, beside records of other
|
|
13
|
+
* types (`summary`, `system`, file snapshots) and sidechain records a
|
|
14
|
+
* sub-agent wrote (`isSidechain: true`). Only the main conversation's user
|
|
15
|
+
* and assistant records are a conversation; the rest are dropped. An
|
|
16
|
+
* assistant reply is often split over several records, one per content
|
|
17
|
+
* block, and tool results arrive one per record, so consecutive records of
|
|
18
|
+
* one role are joined into one message, which is also what a model API
|
|
19
|
+
* requires.
|
|
20
|
+
*
|
|
21
|
+
* What a block is. `text`, `tool_use` and `tool_result` are kept; a call
|
|
22
|
+
* or result missing its id is kept with an empty one, which a rendering
|
|
23
|
+
* shows and the pairing rule refuses.
|
|
24
|
+
* `thinking` and `redacted_thinking` are dropped: a thinking block carries
|
|
25
|
+
* a signature that binds it to the turn that produced it, and a resumed
|
|
26
|
+
* conversation is a new turn. An image becomes the words "[image]", since
|
|
27
|
+
* nothing here carries media.
|
|
28
|
+
*
|
|
29
|
+
* The pairing rule, checked only when asked ({@link parseTranscript}'s
|
|
30
|
+
* `requirePairing`): every `tool_use` is answered by a `tool_result` in the
|
|
31
|
+
* user message right after it, and every `tool_result` answers a
|
|
32
|
+
* `tool_use` of the assistant message right before it, as a model API
|
|
33
|
+
* requires of a history it is sent. A rendering for a judge does not need
|
|
34
|
+
* it and reads leniently.
|
|
35
|
+
*/
|
|
36
|
+
/** One content block of a transcript message. */
|
|
37
|
+
export type TranscriptBlock = {
|
|
38
|
+
readonly type: "text";
|
|
39
|
+
readonly text: string;
|
|
40
|
+
} | {
|
|
41
|
+
readonly type: "tool_use";
|
|
42
|
+
readonly id: string;
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
45
|
+
} | {
|
|
46
|
+
readonly type: "tool_result";
|
|
47
|
+
readonly toolUseId: string;
|
|
48
|
+
/** The result's text; non-text parts named in brackets. */
|
|
49
|
+
readonly content: string;
|
|
50
|
+
readonly isError: boolean;
|
|
51
|
+
};
|
|
52
|
+
/** One message of a transcript, records of one role joined. */
|
|
53
|
+
export interface TranscriptMessage {
|
|
54
|
+
readonly role: "user" | "assistant";
|
|
55
|
+
readonly blocks: readonly TranscriptBlock[];
|
|
56
|
+
}
|
|
57
|
+
/** A parsed transcript, or why it cannot be resumed. */
|
|
58
|
+
export type TranscriptParse = {
|
|
59
|
+
readonly ok: true;
|
|
60
|
+
readonly messages: readonly TranscriptMessage[];
|
|
61
|
+
} | {
|
|
62
|
+
readonly ok: false;
|
|
63
|
+
readonly error: string;
|
|
64
|
+
};
|
|
65
|
+
/** How strictly {@link parseTranscript} reads. */
|
|
66
|
+
export interface TranscriptParseOptions {
|
|
67
|
+
/** Refuse a transcript whose tool calls and results do not pair (the module header). */
|
|
68
|
+
readonly requirePairing: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Read a `.jsonl` transcript. A line that is not JSON is an error naming
|
|
72
|
+
* its number; so is an empty conversation, and, under `requirePairing`, an
|
|
73
|
+
* unpaired tool call or result.
|
|
74
|
+
*/
|
|
75
|
+
export declare function parseTranscript(text: string, options: TranscriptParseOptions): TranscriptParse;
|
|
76
|
+
/**
|
|
77
|
+
* A transcript as text for a judge, one message per line: "role: text",
|
|
78
|
+
* with tool calls and results named in brackets. Records that are not the
|
|
79
|
+
* conversation are dropped as {@link parseTranscript} drops them; a line
|
|
80
|
+
* that is not JSON is kept where it stands, as written, so a judge still
|
|
81
|
+
* reads what an author put there.
|
|
82
|
+
*/
|
|
83
|
+
export declare function renderTranscript(text: string): string;
|
|
84
|
+
//# sourceMappingURL=transcript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["src/transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,iDAAiD;AACjD,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACnD,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEN,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;CAC7C;AAED,wDAAwD;AACxD,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAA;CAAE,GACtE;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,kDAAkD;AAClD,MAAM,WAAW,sBAAsB;IACrC,wFAAwF;IACxF,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,eAAe,CA6B9F;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA2BrD"}
|
package/transcript.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin-eval format's transcripts: a Claude Code session saved as
|
|
3
|
+
* `.jsonl`, one record per line, read as the conversation a model saw.
|
|
4
|
+
*
|
|
5
|
+
* One reader for every use of the format's transcripts. The suite reader
|
|
6
|
+
* checks a case's `history_file` with it at push; the runner turns the same
|
|
7
|
+
* messages into a resumed try's first input; the `baseline` grader renders
|
|
8
|
+
* a reference transcript from it as text for the judge. Kept here so a
|
|
9
|
+
* history the server accepted is the history the runner resumes.
|
|
10
|
+
*
|
|
11
|
+
* What a record is. Claude Code writes `{"type": "user" | "assistant",
|
|
12
|
+
* "message": {"role", "content"}}` per record, beside records of other
|
|
13
|
+
* types (`summary`, `system`, file snapshots) and sidechain records a
|
|
14
|
+
* sub-agent wrote (`isSidechain: true`). Only the main conversation's user
|
|
15
|
+
* and assistant records are a conversation; the rest are dropped. An
|
|
16
|
+
* assistant reply is often split over several records, one per content
|
|
17
|
+
* block, and tool results arrive one per record, so consecutive records of
|
|
18
|
+
* one role are joined into one message, which is also what a model API
|
|
19
|
+
* requires.
|
|
20
|
+
*
|
|
21
|
+
* What a block is. `text`, `tool_use` and `tool_result` are kept; a call
|
|
22
|
+
* or result missing its id is kept with an empty one, which a rendering
|
|
23
|
+
* shows and the pairing rule refuses.
|
|
24
|
+
* `thinking` and `redacted_thinking` are dropped: a thinking block carries
|
|
25
|
+
* a signature that binds it to the turn that produced it, and a resumed
|
|
26
|
+
* conversation is a new turn. An image becomes the words "[image]", since
|
|
27
|
+
* nothing here carries media.
|
|
28
|
+
*
|
|
29
|
+
* The pairing rule, checked only when asked ({@link parseTranscript}'s
|
|
30
|
+
* `requirePairing`): every `tool_use` is answered by a `tool_result` in the
|
|
31
|
+
* user message right after it, and every `tool_result` answers a
|
|
32
|
+
* `tool_use` of the assistant message right before it, as a model API
|
|
33
|
+
* requires of a history it is sent. A rendering for a judge does not need
|
|
34
|
+
* it and reads leniently.
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Read a `.jsonl` transcript. A line that is not JSON is an error naming
|
|
38
|
+
* its number; so is an empty conversation, and, under `requirePairing`, an
|
|
39
|
+
* unpaired tool call or result.
|
|
40
|
+
*/
|
|
41
|
+
export function parseTranscript(text, options) {
|
|
42
|
+
const messages = [];
|
|
43
|
+
const lines = text.split("\n");
|
|
44
|
+
for (let i = 0; i < lines.length; i++) {
|
|
45
|
+
const line = (lines[i] ?? "").trim();
|
|
46
|
+
if (line === "")
|
|
47
|
+
continue;
|
|
48
|
+
let record;
|
|
49
|
+
try {
|
|
50
|
+
record = JSON.parse(line);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return { ok: false, error: `line ${i + 1} is not JSON` };
|
|
54
|
+
}
|
|
55
|
+
const read = messageOf(record);
|
|
56
|
+
if (read === undefined || read.blocks.length === 0)
|
|
57
|
+
continue;
|
|
58
|
+
const last = messages.at(-1);
|
|
59
|
+
if (last !== undefined && last.role === read.role) {
|
|
60
|
+
last.blocks.push(...read.blocks);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
messages.push({ role: read.role, blocks: [...read.blocks] });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (messages.length === 0) {
|
|
67
|
+
return { ok: false, error: "it holds no user or assistant message" };
|
|
68
|
+
}
|
|
69
|
+
if (options.requirePairing) {
|
|
70
|
+
const unpaired = pairingError(messages);
|
|
71
|
+
if (unpaired !== undefined)
|
|
72
|
+
return { ok: false, error: unpaired };
|
|
73
|
+
}
|
|
74
|
+
return { ok: true, messages };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A transcript as text for a judge, one message per line: "role: text",
|
|
78
|
+
* with tool calls and results named in brackets. Records that are not the
|
|
79
|
+
* conversation are dropped as {@link parseTranscript} drops them; a line
|
|
80
|
+
* that is not JSON is kept where it stands, as written, so a judge still
|
|
81
|
+
* reads what an author put there.
|
|
82
|
+
*/
|
|
83
|
+
export function renderTranscript(text) {
|
|
84
|
+
const out = [];
|
|
85
|
+
let last;
|
|
86
|
+
for (const raw of text.split("\n")) {
|
|
87
|
+
const line = raw.trim();
|
|
88
|
+
if (line === "")
|
|
89
|
+
continue;
|
|
90
|
+
let record;
|
|
91
|
+
try {
|
|
92
|
+
record = JSON.parse(line);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
if (last !== undefined)
|
|
96
|
+
out.push(`${last.role}: ${last.parts.join(" ")}`);
|
|
97
|
+
last = undefined;
|
|
98
|
+
out.push(line);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const read = messageOf(record);
|
|
102
|
+
if (read === undefined || read.blocks.length === 0)
|
|
103
|
+
continue;
|
|
104
|
+
const parts = read.blocks.map(renderBlock);
|
|
105
|
+
if (last !== undefined && last.role === read.role) {
|
|
106
|
+
last.parts.push(...parts);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
if (last !== undefined)
|
|
110
|
+
out.push(`${last.role}: ${last.parts.join(" ")}`);
|
|
111
|
+
last = { role: read.role, parts };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (last !== undefined)
|
|
115
|
+
out.push(`${last.role}: ${last.parts.join(" ")}`);
|
|
116
|
+
return out.join("\n");
|
|
117
|
+
}
|
|
118
|
+
function renderBlock(block) {
|
|
119
|
+
switch (block.type) {
|
|
120
|
+
case "text":
|
|
121
|
+
return block.text;
|
|
122
|
+
case "tool_use":
|
|
123
|
+
return `[called ${block.name} ${JSON.stringify(block.input)}]`;
|
|
124
|
+
case "tool_result":
|
|
125
|
+
return `[tool result: ${block.content}]`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** The main conversation's message a record carries, or `undefined` for any other record. */
|
|
129
|
+
function messageOf(record) {
|
|
130
|
+
if (!isRecord(record) || record["isSidechain"] === true)
|
|
131
|
+
return undefined;
|
|
132
|
+
const type = record["type"];
|
|
133
|
+
if (type !== "user" && type !== "assistant")
|
|
134
|
+
return undefined;
|
|
135
|
+
const message = record["message"];
|
|
136
|
+
if (!isRecord(message))
|
|
137
|
+
return undefined;
|
|
138
|
+
const content = message["content"];
|
|
139
|
+
if (typeof content === "string") {
|
|
140
|
+
return content.trim() === "" ? undefined : { role: type, blocks: [{ type: "text", text: content }] };
|
|
141
|
+
}
|
|
142
|
+
if (!Array.isArray(content))
|
|
143
|
+
return undefined;
|
|
144
|
+
return { role: type, blocks: content.flatMap(blockOf) };
|
|
145
|
+
}
|
|
146
|
+
function blockOf(block) {
|
|
147
|
+
if (!isRecord(block))
|
|
148
|
+
return [];
|
|
149
|
+
switch (block["type"]) {
|
|
150
|
+
case "text":
|
|
151
|
+
return typeof block["text"] === "string" && block["text"] !== ""
|
|
152
|
+
? [{ type: "text", text: block["text"] }]
|
|
153
|
+
: [];
|
|
154
|
+
case "tool_use": {
|
|
155
|
+
const id = typeof block["id"] === "string" ? block["id"] : "";
|
|
156
|
+
const name = block["name"];
|
|
157
|
+
if (typeof name !== "string")
|
|
158
|
+
return [];
|
|
159
|
+
const input = isRecord(block["input"]) ? block["input"] : {};
|
|
160
|
+
return [{ type: "tool_use", id, name, input }];
|
|
161
|
+
}
|
|
162
|
+
case "tool_result": {
|
|
163
|
+
const toolUseId = typeof block["tool_use_id"] === "string" ? block["tool_use_id"] : "";
|
|
164
|
+
return [
|
|
165
|
+
{
|
|
166
|
+
type: "tool_result",
|
|
167
|
+
toolUseId,
|
|
168
|
+
content: resultText(block["content"]),
|
|
169
|
+
isError: block["is_error"] === true,
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
case "image":
|
|
174
|
+
return [{ type: "text", text: "[image]" }];
|
|
175
|
+
default:
|
|
176
|
+
return [];
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/** A tool result's content as text: a string as is, text parts joined, other parts named. */
|
|
180
|
+
function resultText(content) {
|
|
181
|
+
if (typeof content === "string")
|
|
182
|
+
return content;
|
|
183
|
+
if (!Array.isArray(content))
|
|
184
|
+
return "";
|
|
185
|
+
return content
|
|
186
|
+
.map((part) => {
|
|
187
|
+
if (!isRecord(part))
|
|
188
|
+
return "";
|
|
189
|
+
if (part["type"] === "text" && typeof part["text"] === "string")
|
|
190
|
+
return part["text"];
|
|
191
|
+
return `[${typeof part["type"] === "string" ? part["type"] : "content"}]`;
|
|
192
|
+
})
|
|
193
|
+
.join("\n");
|
|
194
|
+
}
|
|
195
|
+
/** The first pairing violation (the module header), or `undefined`. */
|
|
196
|
+
function pairingError(messages) {
|
|
197
|
+
for (const [i, message] of messages.entries()) {
|
|
198
|
+
const before = messages[i - 1];
|
|
199
|
+
const after = messages[i + 1];
|
|
200
|
+
if (message.role === "assistant") {
|
|
201
|
+
const answered = new Set(after?.blocks.flatMap((b) => (b.type === "tool_result" ? [b.toolUseId] : [])) ?? []);
|
|
202
|
+
for (const block of message.blocks) {
|
|
203
|
+
if (block.type === "tool_use" && !answered.has(block.id)) {
|
|
204
|
+
return `the call ${block.name} (${block.id}) has no tool_result in the next user message`;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (message.blocks.some((b) => b.type === "tool_result")) {
|
|
208
|
+
return `an assistant message carries a tool_result`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
const asked = new Set(before?.role === "assistant"
|
|
213
|
+
? before.blocks.flatMap((b) => (b.type === "tool_use" ? [b.id] : []))
|
|
214
|
+
: []);
|
|
215
|
+
for (const block of message.blocks) {
|
|
216
|
+
if (block.type === "tool_result" && !asked.has(block.toolUseId)) {
|
|
217
|
+
return `the tool_result for ${block.toolUseId} answers no call of the assistant message before it`;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (message.blocks.some((b) => b.type === "tool_use")) {
|
|
221
|
+
return `a user message carries a tool_use`;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
function isRecord(value) {
|
|
228
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=transcript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.js","sourceRoot":"","sources":["src/transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAoCH;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,OAA+B;IAC3E,MAAM,QAAQ,GAAgE,EAAE,CAAC;IACjF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACrC,IAAI,IAAI,KAAK,EAAE;YAAE,SAAS;QAC1B,IAAI,MAAe,CAAC;QACpB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,E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