dsh-eval 0.1.0-rc.6 → 0.3.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/src/compare.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * @module dsh-eval/compare
6
6
  */
7
7
 
8
- import type { EvalRun } from './types.ts'
8
+ import type { EvalRun, EvalTrialResult } from './types.ts'
9
9
 
10
10
  /** One compared metric row. */
11
11
  export interface CompareRow {
@@ -19,6 +19,26 @@ export interface CompareRow {
19
19
  delta: string
20
20
  }
21
21
 
22
+ /** Paired same-case statistics over two runs. */
23
+ export interface PairedStats {
24
+ /** Number of case x trial pairs completed in both runs. */
25
+ pairs: number
26
+ /** Pairs where run B beat run A on the primary metric. */
27
+ wins: number
28
+ /** Pairs where run A beat run B on the primary metric. */
29
+ losses: number
30
+ /** Pairs with equal primary-metric outcomes. */
31
+ ties: number
32
+ /** The metric used for win/lose/tie classification. */
33
+ primaryMetric: 'task success' | 'tool selection accuracy' | 'final answer score'
34
+ /** Mean per-pair step delta (`b - a`), or null when no pair is numeric. */
35
+ meanStepsDelta: number | null
36
+ /** Mean per-pair token delta (`b - a`), or null when no pair is numeric. */
37
+ meanTokensDelta: number | null
38
+ /** Mean per-pair judge score delta (`b - a`), or null without judge verdicts. */
39
+ meanScoreDelta: number | null
40
+ }
41
+
22
42
  /** Render a nullable number with a dash placeholder. */
23
43
  function formatNumber(value: number | null, digits = 1): string {
24
44
  return value === null ? '–' : value.toFixed(digits)
@@ -36,6 +56,97 @@ function formatDelta(a: number | null, b: number | null, unit: 'pp' | '' = ''):
36
56
  return `${delta >= 0 ? '+' : ''}${delta.toFixed(1)}${unit}`
37
57
  }
38
58
 
59
+ /** A metric that can classify a paired winner. */
60
+ type PairedMetric = 'task success' | 'tool selection accuracy' | 'final answer score'
61
+
62
+ /** Read one trial's primary-metric outcome, or null when the trial lacks it. */
63
+ function metricOutcome(result: EvalTrialResult, metric: PairedMetric): boolean | number | null {
64
+ if (metric === 'task success') return result.grade?.taskSuccess ?? null
65
+ if (metric === 'tool selection accuracy') return result.grade?.toolSelectionAccuracy ?? null
66
+ return result.judge?.finalAnswerScore ?? null
67
+ }
68
+
69
+ /** Pick the first metric with data in every paired trial of a run. */
70
+ function pickMetric(
71
+ pairs: readonly { a: EvalTrialResult; b: EvalTrialResult }[],
72
+ ): PairedMetric {
73
+ for (const metric of ['task success', 'tool selection accuracy', 'final answer score'] as const) {
74
+ if (pairs.every(pair => metricOutcome(pair.a, metric) !== null && metricOutcome(pair.b, metric) !== null)) {
75
+ return metric
76
+ }
77
+ }
78
+ return 'final answer score'
79
+ }
80
+
81
+ /** Classify one pair: 1 for a B win, -1 for an A win, 0 for a tie. */
82
+ function pairSign(aValue: boolean | number | null, bValue: boolean | number | null): number {
83
+ if (aValue === null || bValue === null) return 0
84
+ if (typeof aValue === 'boolean' || typeof bValue === 'boolean') {
85
+ const aBool = aValue === true
86
+ const bBool = bValue === true
87
+ return bBool === aBool ? 0 : (bBool ? 1 : -1)
88
+ }
89
+ return bValue > aValue ? 1 : (bValue < aValue ? -1 : 0)
90
+ }
91
+
92
+ /**
93
+ * Pair both runs' trials by case id and trial index and compute win/lose/tie
94
+ * plus mean deltas. Trials are paired as-is; the runs' `seed` is recorded
95
+ * provenance for the pairing, not a guarantee of identical model output.
96
+ * @param a - the baseline run.
97
+ * @param b - the candidate run.
98
+ * @returns paired statistics, or null when no trial is completed in both runs.
99
+ */
100
+ export function pairedCompare(a: EvalRun, b: EvalRun): PairedStats | null {
101
+ const byKey = new Map<string, EvalTrialResult>()
102
+ for (const result of b.cases) {
103
+ if (result.status === 'completed') byKey.set(`${result.caseId}\u0000${result.trial}`, result)
104
+ }
105
+ const pairs: { a: EvalTrialResult; b: EvalTrialResult }[] = []
106
+ for (const result of a.cases) {
107
+ if (result.status !== 'completed') continue
108
+ const match = byKey.get(`${result.caseId}\u0000${result.trial}`)
109
+ if (match !== undefined) pairs.push({ a: result, b: match })
110
+ }
111
+ if (pairs.length === 0) return null
112
+ const primaryMetric = pickMetric(pairs)
113
+ let wins = 0
114
+ let losses = 0
115
+ let ties = 0
116
+ const stepDeltas: number[] = []
117
+ const tokenDeltas: number[] = []
118
+ const scoreDeltas: number[] = []
119
+ for (const pair of pairs) {
120
+ const sign = pairSign(metricOutcome(pair.a, primaryMetric), metricOutcome(pair.b, primaryMetric))
121
+ if (sign > 0) wins += 1
122
+ else if (sign < 0) losses += 1
123
+ else ties += 1
124
+ const aMetrics = pair.a.metrics
125
+ const bMetrics = pair.b.metrics
126
+ if (aMetrics !== undefined && bMetrics !== undefined) {
127
+ stepDeltas.push(bMetrics.steps - aMetrics.steps)
128
+ tokenDeltas.push(bMetrics.totalTokens - aMetrics.totalTokens)
129
+ }
130
+ const aScore = pair.a.judge?.finalAnswerScore
131
+ const bScore = pair.b.judge?.finalAnswerScore
132
+ if (aScore !== null && aScore !== undefined && bScore !== null && bScore !== undefined) {
133
+ scoreDeltas.push(bScore - aScore)
134
+ }
135
+ }
136
+ const mean = (values: readonly number[]): number | null =>
137
+ values.length === 0 ? null : values.reduce((total, value) => total + value, 0) / values.length
138
+ return {
139
+ pairs: pairs.length,
140
+ wins,
141
+ losses,
142
+ ties,
143
+ primaryMetric,
144
+ meanStepsDelta: mean(stepDeltas),
145
+ meanTokensDelta: mean(tokenDeltas),
146
+ meanScoreDelta: mean(scoreDeltas),
147
+ }
148
+ }
149
+
39
150
  /** Pull one nullable numeric value from a run for comparison. */
40
151
  type RunSelector = (run: EvalRun) => number | null
41
152
 
@@ -58,7 +169,7 @@ export function compareRuns(a: EvalRun, b: EvalRun): CompareRow[] {
58
169
  }
59
170
  }
60
171
  const numeric = (selector: RunSelector, label: string): CompareRow => rates(selector, label, '')
61
- return [
172
+ const rows: CompareRow[] = [
62
173
  { metric: 'benchmark', a: a.benchmark, b: b.benchmark, delta: '–' },
63
174
  { metric: 'model', a: a.model, b: b.model, delta: '–' },
64
175
  numeric(run => completed(run), 'completed trials'),
@@ -72,6 +183,28 @@ export function compareRuns(a: EvalRun, b: EvalRun): CompareRow[] {
72
183
  numeric(run => run.aggregate?.costUsd ?? null, 'cost/trial (USD)'),
73
184
  numeric(run => run.aggregate?.latencyMs ?? null, 'latency/trial (ms)'),
74
185
  ]
186
+ const paired = pairedCompare(a, b)
187
+ if (paired !== null) {
188
+ rows.push(
189
+ { metric: 'paired trials', a: String(paired.pairs), b: String(paired.pairs), delta: '–' },
190
+ {
191
+ metric: `paired ${paired.primaryMetric} (B/A/ties)`,
192
+ a: `${paired.wins}/${paired.losses}/${paired.ties}`,
193
+ b: '–',
194
+ delta: '–',
195
+ },
196
+ ...(paired.meanStepsDelta === null ? [] : [{
197
+ metric: 'paired steps delta (B-A)', a: '–', b: '–', delta: formatDelta(0, paired.meanStepsDelta),
198
+ }]),
199
+ ...(paired.meanTokensDelta === null ? [] : [{
200
+ metric: 'paired tokens delta (B-A)', a: '–', b: '–', delta: formatDelta(0, paired.meanTokensDelta),
201
+ }]),
202
+ ...(paired.meanScoreDelta === null ? [] : [{
203
+ metric: 'paired final-answer delta (B-A)', a: '–', b: '–', delta: formatDelta(0, paired.meanScoreDelta),
204
+ }]),
205
+ )
206
+ }
207
+ return rows
75
208
  }
76
209
 
77
210
  /**
package/src/import.ts ADDED
@@ -0,0 +1,327 @@
1
+ /**
2
+ * Cross-harness trace import: Codex and Claude Code session JSONL become the
3
+ * eval trace vocabulary so report and compare can fold metrics over runs
4
+ * recorded by other agents. Each importer synthesizes one turn (and one step)
5
+ * per user message, preserving assistant text and tool calls/results; model
6
+ * token usage is not part of either external format, so token metrics stay
7
+ * zero.
8
+ *
9
+ * @module dsh-eval/import
10
+ */
11
+
12
+ import { readFile } from 'node:fs/promises'
13
+ import { basename, dirname, resolve } from 'node:path'
14
+ import { computeMetrics } from './metrics.ts'
15
+ import { parseSessionLog } from './trace.ts'
16
+ import type { EvalRun, EvalTrace } from './types.ts'
17
+
18
+ /** Synthetic event-time spacing keeps imported metrics deterministic. */
19
+ const STEP_MS = 1000
20
+ /** Epoch base for imported traces without a real timestamp. */
21
+ const BASE_MS = 1_700_000_000_000
22
+
23
+ /** A pending event row before seq/time assignment. */
24
+ interface ParsedEvent {
25
+ type: string
26
+ data: unknown
27
+ }
28
+
29
+ /** Join an external-log line's timestamp (ISO or epoch) with a synthetic offset. */
30
+ function eventTime(lineIndex: number): number {
31
+ return BASE_MS + lineIndex * STEP_MS
32
+ }
33
+
34
+ /** Extract display text from a string, a text block, or a block array. */
35
+ function textOf(value: unknown): string {
36
+ if (typeof value === 'string') return value
37
+ if (Array.isArray(value)) {
38
+ return value.flatMap((block) => {
39
+ if (typeof block !== 'object' || block === null) return []
40
+ const text = (block as Record<string, unknown>).text
41
+ return typeof text === 'string' ? [text] : []
42
+ }).join('')
43
+ }
44
+ return ''
45
+ }
46
+
47
+ /** Stable synthetic session id from the source filename. */
48
+ function sessionIdFrom(source: string): string {
49
+ const safe = basename(source).replace(/[^A-Za-z0-9._-]/gu, '-').replace(/^-+|-+$/gu, '')
50
+ return safe === '' ? 'imported' : safe
51
+ }
52
+
53
+ /** Assemble parsed events into a validated trace with contiguous seqs. */
54
+ function assembleTrace(events: readonly ParsedEvent[], id: string): EvalTrace {
55
+ const lines = [
56
+ JSON.stringify({ type: 'session', version: 0, id, createdAt: eventTime(0), delegationDepth: 0 }),
57
+ ...events.map((event, index) => JSON.stringify({ seq: index, time: eventTime(index + 1), type: event.type, data: event.data })),
58
+ '',
59
+ ]
60
+ return parseSessionLog(lines.join('\n'))
61
+ }
62
+
63
+ /** Close the current synthesized turn with step/end and turn/end. */
64
+ function closeTurn(
65
+ events: ParsedEvent[],
66
+ turn: number,
67
+ step: number,
68
+ open: boolean,
69
+ ): boolean {
70
+ if (!open) return false
71
+ events.push({ type: 'step/end', data: { turn, step } })
72
+ events.push({ type: 'turn/end', data: { turn, reason: { kind: 'completed' } } })
73
+ return true
74
+ }
75
+
76
+ /**
77
+ * Import a Codex session JSONL (lines of `response_item` records) as a trace.
78
+ * @param text - the Codex log's UTF-8 text.
79
+ * @param source - the source file path, used for the synthetic session id.
80
+ * @returns the imported trace; non-`response_item` lines are skipped.
81
+ */
82
+ export function importCodexLog(text: string, source: string): EvalTrace {
83
+ const events: ParsedEvent[] = []
84
+ let turn = 0
85
+ let step = 0
86
+ let open = false
87
+ let callCounter = 0
88
+ let messageCounter = 0
89
+ const close = (): void => {
90
+ open = closeTurn(events, turn, step, open)
91
+ }
92
+ for (const line of text.split(/\r?\n/u)) {
93
+ if (line.trim() === '') continue
94
+ let record: unknown
95
+ try {
96
+ record = JSON.parse(line)
97
+ } catch {
98
+ continue
99
+ }
100
+ if (typeof record !== 'object' || record === null) continue
101
+ const row = record as Record<string, unknown>
102
+ if (row.type !== 'response_item' || typeof row.payload !== 'object' || row.payload === null) continue
103
+ const payload = row.payload as Record<string, unknown>
104
+ if (payload.type === 'message' && payload.role === 'user') {
105
+ close()
106
+ turn += 1
107
+ step = 0
108
+ open = true
109
+ messageCounter += 1
110
+ events.push({ type: 'turn/start', data: { turn } })
111
+ events.push({
112
+ type: 'user/message',
113
+ data: {
114
+ id: `user-${messageCounter}`,
115
+ role: 'user',
116
+ content: [{ type: 'text', text: textOf(payload.content) }],
117
+ source: { kind: 'user' },
118
+ },
119
+ })
120
+ events.push({ type: 'step/start', data: { turn, step } })
121
+ } else if (payload.type === 'message' && payload.role === 'assistant') {
122
+ messageCounter += 1
123
+ events.push({
124
+ type: 'assistant/message',
125
+ data: {
126
+ turn,
127
+ step,
128
+ message: {
129
+ id: `assistant-${messageCounter}`,
130
+ role: 'assistant',
131
+ content: [{ type: 'text', text: textOf(payload.content) }],
132
+ source: { kind: 'model' },
133
+ },
134
+ },
135
+ })
136
+ } else if (payload.type === 'function_call') {
137
+ callCounter += 1
138
+ const callId = typeof payload.call_id === 'string' ? payload.call_id : `codex-call-${callCounter}`
139
+ const name = typeof payload.name === 'string' ? payload.name : 'tool'
140
+ const argumentsText = typeof payload.arguments === 'string' ? payload.arguments : '{}'
141
+ events.push({ type: 'tool/call', data: { turn, step, callId, name, arguments: argumentsText } })
142
+ } else if (payload.type === 'function_call_output') {
143
+ callCounter += 1
144
+ const callId = typeof payload.call_id === 'string' ? payload.call_id : `codex-call-${callCounter}`
145
+ const output = textOf(payload.output ?? payload.content)
146
+ events.push({
147
+ type: 'tool/result',
148
+ data: {
149
+ turn,
150
+ step,
151
+ message: {
152
+ id: `tool-result-${callCounter}`,
153
+ role: 'user',
154
+ content: [{ type: 'tool-result', text: output, isError: payload.is_error === true }],
155
+ source: { kind: 'tool', callId },
156
+ },
157
+ },
158
+ })
159
+ }
160
+ }
161
+ close()
162
+ return assembleTrace(events, sessionIdFrom(source))
163
+ }
164
+
165
+ /** Whether a Claude Code user message carries only tool results (not a new turn). */
166
+ function isToolResultUser(content: unknown): boolean {
167
+ if (!Array.isArray(content)) return false
168
+ return content.every(block =>
169
+ typeof block === 'object' && block !== null && (block as Record<string, unknown>).type === 'tool_result')
170
+ }
171
+
172
+ /**
173
+ * Import a Claude Code session JSONL (lines of `user`/`assistant` records) as
174
+ * a trace.
175
+ * @param text - the Claude Code log's UTF-8 text.
176
+ * @param source - the source file path, used for the synthetic session id.
177
+ * @returns the imported trace; non-user/assistant lines are skipped.
178
+ */
179
+ export function importClaudeLog(text: string, source: string): EvalTrace {
180
+ const events: ParsedEvent[] = []
181
+ let turn = 0
182
+ let step = 0
183
+ let open = false
184
+ let messageCounter = 0
185
+ const close = (): void => {
186
+ open = closeTurn(events, turn, step, open)
187
+ }
188
+ for (const line of text.split(/\r?\n/u)) {
189
+ if (line.trim() === '') continue
190
+ let record: unknown
191
+ try {
192
+ record = JSON.parse(line)
193
+ } catch {
194
+ continue
195
+ }
196
+ if (typeof record !== 'object' || record === null) continue
197
+ const row = record as Record<string, unknown>
198
+ if ((row.type !== 'user' && row.type !== 'assistant')
199
+ || typeof row.message !== 'object' || row.message === null) continue
200
+ const message = row.message as Record<string, unknown>
201
+ const content = message.content
202
+ if (row.type === 'user' && !isToolResultUser(content)) {
203
+ close()
204
+ turn += 1
205
+ step = 0
206
+ open = true
207
+ messageCounter += 1
208
+ events.push({ type: 'turn/start', data: { turn } })
209
+ events.push({
210
+ type: 'user/message',
211
+ data: {
212
+ id: `user-${messageCounter}`,
213
+ role: 'user',
214
+ content: [{ type: 'text', text: textOf(content) }],
215
+ source: { kind: 'user' },
216
+ },
217
+ })
218
+ events.push({ type: 'step/start', data: { turn, step } })
219
+ continue
220
+ }
221
+ if (row.type === 'assistant') {
222
+ if (typeof content === 'string') {
223
+ messageCounter += 1
224
+ events.push({
225
+ type: 'assistant/message',
226
+ data: {
227
+ turn,
228
+ step,
229
+ message: {
230
+ id: `assistant-${messageCounter}`,
231
+ role: 'assistant',
232
+ content: [{ type: 'text', text: content }],
233
+ source: { kind: 'model' },
234
+ },
235
+ },
236
+ })
237
+ } else {
238
+ for (const block of Array.isArray(content) ? content : []) {
239
+ if (typeof block !== 'object' || block === null) continue
240
+ const item = block as Record<string, unknown>
241
+ if (item.type === 'text') {
242
+ messageCounter += 1
243
+ events.push({
244
+ type: 'assistant/message',
245
+ data: {
246
+ turn,
247
+ step,
248
+ message: {
249
+ id: `assistant-${messageCounter}`,
250
+ role: 'assistant',
251
+ content: [{ type: 'text', text: typeof item.text === 'string' ? item.text : '' }],
252
+ source: { kind: 'model' },
253
+ },
254
+ },
255
+ })
256
+ } else if (item.type === 'tool_use') {
257
+ const callId = typeof item.id === 'string' ? item.id : `claude-call-${messageCounter}`
258
+ const name = typeof item.name === 'string' ? item.name : 'tool'
259
+ const argumentsText = JSON.stringify(item.input ?? {})
260
+ events.push({ type: 'tool/call', data: { turn, step, callId, name, arguments: argumentsText } })
261
+ }
262
+ }
263
+ }
264
+ continue
265
+ }
266
+ // Reaching here means a tool-result user message: the plain-user branch
267
+ // above already excluded non-tool-result content.
268
+ const blocks = content as readonly Record<string, unknown>[]
269
+ for (const item of blocks) {
270
+ const callId = typeof item.tool_use_id === 'string' ? item.tool_use_id : `claude-call-${messageCounter}`
271
+ events.push({
272
+ type: 'tool/result',
273
+ data: {
274
+ turn,
275
+ step,
276
+ message: {
277
+ id: `tool-result-${messageCounter}`,
278
+ role: 'user',
279
+ content: [{ type: 'tool-result', text: textOf(item.content), isError: item.is_error === true }],
280
+ source: { kind: 'tool', callId },
281
+ },
282
+ },
283
+ })
284
+ }
285
+ }
286
+ close()
287
+ return assembleTrace(events, sessionIdFrom(source))
288
+ }
289
+
290
+ /** Import formats the CLI accepts. */
291
+ export type ImportFormat = 'codex' | 'claude-code'
292
+
293
+ /**
294
+ * Load an external session log and build a one-trial run record from it.
295
+ * @param format - the external harness format.
296
+ * @param path - the session JSONL path.
297
+ * @param caseId - the imported trial's case id.
298
+ * @returns the run record with one completed trial.
299
+ */
300
+ export async function importTraceFile(format: ImportFormat, path: string, caseId: string): Promise<EvalRun> {
301
+ const absolute = resolve(path)
302
+ const text = await readFile(absolute, 'utf8')
303
+ const trace = format === 'codex'
304
+ ? importCodexLog(text, absolute)
305
+ : importClaudeLog(text, absolute)
306
+ const metrics = computeMetrics(trace.events, undefined)
307
+ return {
308
+ benchmark: `import:${format}`,
309
+ model: 'imported',
310
+ createdAt: Date.now(),
311
+ trials: 1,
312
+ seed: 0,
313
+ pricing: null,
314
+ tempRoot: dirname(absolute),
315
+ cases: [{
316
+ caseId,
317
+ trial: 1,
318
+ status: 'completed',
319
+ tracePath: absolute,
320
+ exitCode: null,
321
+ timedOut: false,
322
+ metrics,
323
+ }],
324
+ aggregate: metrics,
325
+ grading: null,
326
+ }
327
+ }
package/src/index.ts CHANGED
@@ -16,6 +16,8 @@ import type { Context } from '@deepseek-ai/cordis'
16
16
  import { loadBenchmark } from './benchmark.ts'
17
17
  import { applyEval, type EvalStartupValues } from './command.ts'
18
18
  import { compareRuns, renderCompareMarkdown } from './compare.ts'
19
+ import { importTraceFile } from './import.ts'
20
+ import { llmJudgeChat, type JudgeChat } from './judge.ts'
19
21
  import { renderMarkdownReport, writeRunReport, loadRunReport } from './report.ts'
20
22
  import { runBenchmark } from './runner.ts'
21
23
 
@@ -36,6 +38,17 @@ export const internals: EvalIo = {
36
38
  stderr: process.stderr,
37
39
  }
38
40
 
41
+ /**
42
+ * Resolve the production judge chat seam from the mounted llm service, or
43
+ * undefined when the composition carries no llm service.
44
+ * @param ctx - the plugin context.
45
+ * @returns a chat seam over the llm stream, or undefined without llm.
46
+ */
47
+ export function resolveJudgeChat(ctx: Context): JudgeChat | undefined {
48
+ const llm = ctx.get('llm')
49
+ return llm === undefined ? undefined : llmJudgeChat(llm.stream)
50
+ }
51
+
39
52
  /** Aggregate-success sentence for the run summary line. */
40
53
  function summary(run: Awaited<ReturnType<typeof runBenchmark>>): string {
41
54
  const aggregate = run.aggregate
@@ -45,18 +58,33 @@ function summary(run: Awaited<ReturnType<typeof runBenchmark>>): string {
45
58
  const task = taskRate === null || taskRate === undefined
46
59
  ? ''
47
60
  : `, task success ${(taskRate * 100).toFixed(1)}%`
48
- return `tool success ${rate}${task}, ${aggregate.steps.toFixed(1)} steps/trial`
61
+ const judgeScore = run.grading?.finalAnswerScore
62
+ const score = judgeScore === null || judgeScore === undefined
63
+ ? ''
64
+ : `, judge score ${judgeScore.toFixed(1)}`
65
+ return `tool success ${rate}${task}${score}, ${aggregate.steps.toFixed(1)} steps/trial`
49
66
  }
50
67
 
51
68
  /**
52
69
  * Execute one eval invocation to completion.
53
70
  * @param values - the resolved command-line invocation.
54
71
  * @param io - output streams for the report and diagnostics.
72
+ * @param services - injected runtime seams, e.g. the LLM-judge chat.
55
73
  * @returns the process exit code; nonzero for any failure or a run with no
56
74
  * completed trials.
57
75
  */
58
- export async function executeEval(values: EvalStartupValues, io: EvalIo): Promise<number> {
76
+ export async function executeEval(
77
+ values: EvalStartupValues,
78
+ io: EvalIo,
79
+ services: { judgeChat?: JudgeChat | undefined } = {},
80
+ ): Promise<number> {
59
81
  try {
82
+ if (values.kind === 'import') {
83
+ const run = await importTraceFile(values.format, values.path, values.caseId)
84
+ await writeRunReport(run, values.outPath)
85
+ io.stdout.write(`Wrote ${values.outPath} (1 imported trial, ${summary(run)})\n`)
86
+ return 0
87
+ }
60
88
  if (values.kind === 'report') {
61
89
  const run = await loadRunReport(values.runPath)
62
90
  io.stdout.write(renderMarkdownReport(run))
@@ -73,6 +101,7 @@ export async function executeEval(values: EvalStartupValues, io: EvalIo): Promis
73
101
  ...(values.trials !== undefined ? { trials: values.trials } : {}),
74
102
  ...(values.dshCommand !== undefined ? { command: values.dshCommand } : {}),
75
103
  ...(values.profile !== undefined ? { profile: values.profile } : {}),
104
+ ...(services.judgeChat !== undefined ? { judgeChat: services.judgeChat } : {}),
76
105
  })
77
106
  await writeRunReport(run, values.outPath)
78
107
  io.stdout.write(`Wrote ${values.outPath} (${run.cases.length} trials, ${summary(run)})\n`)
@@ -91,7 +120,8 @@ export async function executeEval(values: EvalStartupValues, io: EvalIo): Promis
91
120
  export function apply(ctx: Context): void {
92
121
  const exit = ctx.get('appExit')
93
122
  if (exit === undefined) throw new Error('eval: the launcher must provide ctx.appExit before the tree mounts')
123
+ const judgeChat = resolveJudgeChat(ctx)
94
124
  const values = applyEval(ctx)
95
125
  if (values === undefined) return
96
- void executeEval(values, internals).then((code) => { exit(code) })
126
+ void executeEval(values, internals, { judgeChat }).then((code) => { exit(code) })
97
127
  }