dsh-eval 0.1.0-rc.6

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 hccccc01333
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # `dsh-eval`
2
+
3
+ English | [中文](README.zh.md)
4
+
5
+ Agent evaluation over headless dsh profiles: a benchmark YAML document, one headless dsh subprocess per case x trial, trace harvesting from persisted session logs, automatic metric folding, and JSON/markdown run reports.
6
+
7
+ The package is a bundle and a command-line app. Install it into a profile and run benchmarks with:
8
+
9
+ ```sh
10
+ dsh plugin --profile eval add dsh-eval
11
+ dsh eval run benchmark.yaml
12
+ dsh eval report eval-run.json
13
+ dsh eval compare eval-v1.json eval-v2.json
14
+ ```
15
+
16
+ `dsh eval` is a launcher alias for `--profile eval`; the eval profile composes `dsh-base` plus this bundle. Each trial spawns the benchmark-configured `dsh` command (default `dsh`) against the benchmark-configured profile (default `headless`) with a private temp workspace, an isolated `DSH_HOME`, and a patch overlay forcing plain-JSONL persistence and non-interactive workspace-write/never-approval permissions. The harvested primary session log becomes the trial's trace; subagent child logs are not yet included.
17
+
18
+ ## Benchmark document
19
+
20
+ ```yaml
21
+ name: skill-regression
22
+ model: deepseek-v4
23
+ profile: headless
24
+ command: [dsh]
25
+ trials: 3
26
+ timeoutMs: 600000
27
+ seed: 42
28
+ cases:
29
+ - id: fix-tests-001
30
+ prompt: Fix the failing tests in this workspace.
31
+ workspace: ./fixtures/fix-tests
32
+ expected:
33
+ tool: bash
34
+ check: ./check.sh
35
+ pricing:
36
+ deepseek-v4:
37
+ inputUsdPerMTokens: 0.27
38
+ cacheReadUsdPerMTokens: 0.07
39
+ cacheWriteUsdPerMTokens: 0.27
40
+ outputUsdPerMTokens: 1.10
41
+ ```
42
+
43
+ | Field | Default | Meaning |
44
+ |---|---|---|
45
+ | `name` | required | Benchmark name, also the run record's `benchmark` field. |
46
+ | `model` | required | Model id for pricing lookup and run reporting. |
47
+ | `profile` | `headless` | dsh profile each trial spawns. |
48
+ | `command` | `[dsh]` | dsh launcher argv. |
49
+ | `trials` | `1` | Trials per case. |
50
+ | `timeoutMs` | `600000` | Per-trial timeout; the direct child is killed on expiry. |
51
+ | `seed` | `0` | Reserved for future deterministic paired comparisons. |
52
+ | `cases[].id` | required | Stable case id. |
53
+ | `cases[].prompt` / `cases[].promptFile` | exactly one | Task text, inline or relative to the benchmark file. |
54
+ | `cases[].workspace` | absent | Workspace tree copied into each trial, relative or absolute. |
55
+ | `cases[].expected` | absent | Scripted grading: `tool` is a substring matched against recorded tool-call names; `check` is a command run in the trial workspace after the agent exits (exit 0 = task success). At least one is required when present. |
56
+ | `pricing` | absent | Per-million-token USD prices keyed by model id; absent models report `costUsd: null`. |
57
+
58
+ ## Metrics
59
+
60
+ The metric fold computes the automatic metrics directly from the session log: `turns`, `steps`, `toolCalls`, `toolResults`, `toolSuccess` plus `toolSuccessRate`, `invalidToolCalls` (results carrying an internal failure identity), `retries` (`llm/retry`), disjoint token buckets and totals, billed context tokens, `llmMs`/`toolMs`/`ttftMs`/`latencyMs`, and `costUsd` when pricing is configured. Scripted grading adds per-trial `taskSuccess` (check-command exit 0) and `toolSelectionAccuracy` (expected-tool match) and pools them into run-level rates. LLM-judge metrics (final-answer score, hallucination) are deferred.
61
+
62
+ ## Run report
63
+
64
+ `dsh eval run --out run.json` writes one JSON document per run: benchmark and model identity, per-trial outcomes with absolute trace paths, aggregate metrics (means for counts and wall times, pooled success rate), and pooled grading rates. `dsh eval report run.json` renders the run as markdown. Trial workspaces and traces stay under the run's `tempRoot` (a private temp directory) and are not deleted; remove them when the run is no longer needed.
65
+
66
+ ## Comparison
67
+
68
+ `dsh eval compare run-v1.json run-v2.json` renders both runs as a markdown table: benchmark/model identity, completed trials, steps, tool/task/tool-selection rates, invalid calls, retries, tokens, cost, and latency, with signed `B - A` deltas. Comparison is read-only over persisted runs; paired same-seed trials remain deferred.
69
+
70
+ ## Extension points
71
+
72
+ The runner is the only consumer today: `runBenchmark` takes a loaded benchmark and returns the run record, and the report module persists and renders it. Grader and comparison seams are deliberately deferred until a second consumer exists.
73
+
74
+ ## Model Experience
75
+
76
+ None, as the benchmark runner reads persisted session logs and spawns headless subprocesses without registering prompt sections, tool schemas, or any other model-facing behavior of its own.
77
+
78
+ #### KV Cache effect
79
+
80
+ None; this package neither assembles nor sends a provider request, so no request prefix exists for it to preserve or invalidate.
81
+
82
+ ## Known Limitations and Deferred Work
83
+
84
+ - **LLM-judge metrics are deferred** — final-answer score and hallucination need an LLM judge provider; scripted task success and tool-selection accuracy are implemented.
85
+ - **Paired comparison is deferred** — `dsh eval compare` compares persisted runs as-is; `seed` is validated but not yet used for deterministic paired trials, and per-arm leaderboards are not rendered.
86
+ - **Primary session only** — child subagent logs under `session.<n>.jsonl` are not harvested; aggregate numbers omit delegated work.
87
+ - **Replay mode is deferred** — real runs need the model credentials the spawned harness resolves; llm-replay wiring for keyless CI is a later step.
88
+ - **Direct-child timeout only** — a timed-out trial kills the direct dsh process; on Windows its descendants may survive.
89
+ - **Windows launcher commands** — the spawned command runs without a shell, so `.cmd`/`.bat` shims need a direct executable or `node <path>` override (`--dsh "node C:/.../apps/cli/lib/bin.js"`).
90
+ - **No atomic report write** — the run JSON is written in place; a crash mid-write can truncate the report.
package/README.zh.md ADDED
@@ -0,0 +1,91 @@
1
+ # `dsh-eval`
2
+
3
+ English | [中文](README.md)
4
+
5
+ 基于 headless dsh profile 的 Agent 评测:一份 benchmark YAML 文档、每个 case × trial 一个 headless dsh 子进程、从持久化 session 日志收集 trace、自动指标折叠,以及 JSON/Markdown 运行报告。
6
+
7
+ 该包既是 bundle 也是命令行应用。安装到 profile 后即可运行评测:
8
+
9
+ ```sh
10
+ dsh plugin --profile eval add dsh-eval
11
+ dsh eval run benchmark.yaml
12
+ dsh eval report eval-run.json
13
+ dsh eval compare eval-v1.json eval-v2.json
14
+ ```
15
+
16
+ `dsh eval` 是 `--profile eval` 的启动器别名;eval profile 由 `dsh-base` 加本 bundle 组成。每个 trial 使用独立的临时工作区、隔离的 `DSH_HOME` 和强制纯 JSONL 持久化与非交互 workspace-write/never-approval 权限的补丁层,以 benchmark 配置的 `dsh` 命令(默认 `dsh`)与 profile(默认 `headless`)运行。收获的主 session 日志即该 trial 的 trace;子 agent 日志暂不包含。
17
+
18
+ ## Benchmark 文档
19
+
20
+ ```yaml
21
+ name: skill-regression
22
+ model: deepseek-v4
23
+ profile: headless
24
+ command: [dsh]
25
+ trials: 3
26
+ timeoutMs: 600000
27
+ seed: 42
28
+ cases:
29
+ - id: fix-tests-001
30
+ prompt: Fix the failing tests in this workspace.
31
+ workspace: ./fixtures/fix-tests
32
+ expected:
33
+ tool: bash
34
+ check: ./check.sh
35
+ pricing:
36
+ deepseek-v4:
37
+ inputUsdPerMTokens: 0.27
38
+ cacheReadUsdPerMTokens: 0.07
39
+ cacheWriteUsdPerMTokens: 0.27
40
+ outputUsdPerMTokens: 1.10
41
+ ```
42
+
43
+ 字段:`name`/`model` 必填;`profile` 默认 `headless`;`command` 默认 `[dsh]`;`trials` 默认 `1`;`timeoutMs` 默认 `600000`;`seed` 默认 `0`(为未来确定性配对预留);每个 case 需要 `id` 和 `prompt` 或 `promptFile`(相对 benchmark 文件解析),可选 `workspace`;`expected` 为脚本化评分(`tool` 是匹配工具调用名的子串,`check` 是 agent 退出后在 trial 工作区运行的命令,退出码 0 视为任务成功,二者至少填一个);`pricing` 以模型 id 为键,缺省模型的 `costUsd` 为 `null`。
44
+
45
+ | 字段 | 默认 | 含义 |
46
+ |---|---|---|
47
+ | `name` | 必填 | Benchmark 名称,也是 run 记录的 `benchmark` 字段。 |
48
+ | `model` | 必填 | 用于定价查找与运行报告的模型 id。 |
49
+ | `profile` | `headless` | 每个 trial 启动的 dsh profile。 |
50
+ | `command` | `[dsh]` | dsh 启动器 argv。 |
51
+ | `trials` | `1` | 每个 case 的 trial 数。 |
52
+ | `timeoutMs` | `600000` | 每个 trial 的超时;到期直接杀掉子进程。 |
53
+ | `seed` | `0` | 为未来确定性配对比较预留。 |
54
+ | `cases[].id` | 必填 | 稳定 case id。 |
55
+ | `cases[].prompt` / `cases[].promptFile` | 二选一 | 任务文本,内联或相对 benchmark 文件。 |
56
+ | `cases[].workspace` | 缺省 | 复制进每个 trial 的工作区树,相对或绝对路径。 |
57
+ | `pricing` | 缺省 | 以模型 id 为键的每百万 token 美元价;缺省模型 `costUsd` 为 `null`。 |
58
+
59
+ ## 指标
60
+
61
+ 指标折叠直接由 session 日志计算自动指标:`turns`、`steps`、`toolCalls`、`toolResults`、`toolSuccess` 与 `toolSuccessRate`、`invalidToolCalls`(带内部失败身份的 result)、`retries`(`llm/retry`)、互斥 token 桶与合计、计费上下文 token、`llmMs`/`toolMs`/`ttftMs`/`latencyMs`,以及配置定价后的 `costUsd`。脚本化评分增加每个 trial 的 `taskSuccess`(check 命令退出码为 0)与 `toolSelectionAccuracy`(命中预期工具),并合并为 run 级比率。LLM judge 指标(最终答案得分、幻觉)延后。
62
+
63
+ ## 运行报告
64
+
65
+ `dsh eval run --out run.json` 每次运行写一份 JSON:benchmark 与模型标识、每个 trial 的结果与绝对 trace 路径、聚合指标(计数与耗时取均值、成功率取合并值)与合并评分比率。`dsh eval report run.json` 把 run 渲染为 markdown。trial 工作区与 trace 保留在 `tempRoot`(私有临时目录)中,不再需要时自行删除。
66
+
67
+ ## 对比
68
+
69
+ `dsh eval compare run-v1.json run-v2.json` 把两个 run 渲染成 markdown 表:benchmark/模型标识、完成 trial 数、steps、工具/任务/工具选择成功率、无效调用、重试、token、成本与延迟,并给出带符号的 `B - A` 差值。对比只读持久化 run;同 seed 配对 trial 仍延后。
70
+
71
+ ## 扩展点
72
+
73
+ v0.1 只有 runner 一个消费者:`runBenchmark` 接收已加载的 benchmark 并返回 run 记录,report 模块负责持久化与渲染。grader 与 compare 的 seam 留到出现第二个消费者时再定义。
74
+
75
+ ## Model Experience
76
+
77
+ None, as the benchmark runner reads persisted session logs and spawns headless subprocesses without registering prompt sections, tool schemas, or any other model-facing behavior of its own.
78
+
79
+ #### KV Cache effect
80
+
81
+ None; this package neither assembles nor sends a provider request, so no request prefix exists for it to preserve or invalidate.
82
+
83
+ ## Known Limitations and Deferred Work
84
+
85
+ - **LLM judge 指标延后** —— 最终答案得分与幻觉需要 LLM judge 提供方;脚本化任务成功与工具选择准确率已实现。
86
+ - **配对对比延后** —— `dsh eval compare` 按现状对比持久化 run;`seed` 仅校验未用于确定性配对 trial,按 arm 的榜单也未实现。
87
+ - **只收获主 session** —— 子 agent 的 `session.<n>.jsonl` 暂不收集,聚合数字不含委派工作。
88
+ - **回放模式延后** —— 真实运行需要子 harness 解析的模型凭据;llm-replay 的 keyless CI 接入是后续步骤。
89
+ - **超时只杀直接子进程** —— Windows 上被杀的 dsh 的后代进程可能存活。
90
+ - **Windows 启动器命令** —— 子进程不经 shell 启动,`.cmd`/`.bat` shim 需要直接可执行文件或 `node <path>` 覆盖(`--dsh "node C:/.../apps/cli/lib/bin.js"`)。
91
+ - **报告写入非原子** —— run JSON 原地写入,写入中途崩溃可能截断报告。
@@ -0,0 +1,6 @@
1
+ # The dsh-eval bundle patch: mounts the eval command-line app over dsh-base.
2
+ # The profile boots, the app parses `run <benchmark.yaml>` / `report <run.json>`,
3
+ # and the plugin spawns one headless dsh per case trial.
4
+ - insert:
5
+ - id: eval
6
+ name: 'dsh-eval'
package/lib/index.js ADDED
@@ -0,0 +1,88 @@
1
+ /**
2
+ * dsh-eval 鈥?agent evaluation over headless dsh profiles.
3
+ *
4
+ * The eval bundle mounts this command-line plugin over dsh-base. It parses
5
+ * `dsh --profile eval run <benchmark.yaml>` / `report <run.json>`, spawns one
6
+ * headless dsh subprocess per case x trial, harvests each persisted session
7
+ * log as a trace, folds automatic metrics, scripted grading (task success,
8
+ * tool-selection accuracy), and cross-run comparison, and writes a JSON run
9
+ * report. LLM-judge metrics (final-answer score, hallucination) and paired
10
+ * same-seed trials are deferred to later milestones.
11
+ *
12
+ * @module dsh-eval
13
+ */
14
+ import { loadBenchmark } from "./benchmark.js";
15
+ import { applyEval } from "./command.js";
16
+ import { compareRuns, renderCompareMarkdown } from "./compare.js";
17
+ import { renderMarkdownReport, writeRunReport, loadRunReport } from "./report.js";
18
+ import { runBenchmark } from "./runner.js";
19
+ /** Stable Cordis plugin name. */
20
+ export const name = 'eval';
21
+ /** The launcher-provided command line is the only required service. */
22
+ export const inject = ['cmdlineArgs'];
23
+ /** The process streams the eval app writes to; tests substitute captures. */
24
+ export const internals = {
25
+ stdout: process.stdout,
26
+ stderr: process.stderr,
27
+ };
28
+ /** Aggregate-success sentence for the run summary line. */
29
+ function summary(run) {
30
+ const aggregate = run.aggregate;
31
+ if (aggregate === null)
32
+ return 'no completed trials';
33
+ const rate = aggregate.toolSuccessRate === null ? 'n/a' : `${(aggregate.toolSuccessRate * 100).toFixed(1)}%`;
34
+ const taskRate = run.grading?.taskSuccessRate;
35
+ const task = taskRate === null || taskRate === undefined
36
+ ? ''
37
+ : `, task success ${(taskRate * 100).toFixed(1)}%`;
38
+ return `tool success ${rate}${task}, ${aggregate.steps.toFixed(1)} steps/trial`;
39
+ }
40
+ /**
41
+ * Execute one eval invocation to completion.
42
+ * @param values - the resolved command-line invocation.
43
+ * @param io - output streams for the report and diagnostics.
44
+ * @returns the process exit code; nonzero for any failure or a run with no
45
+ * completed trials.
46
+ */
47
+ export async function executeEval(values, io) {
48
+ try {
49
+ if (values.kind === 'report') {
50
+ const run = await loadRunReport(values.runPath);
51
+ io.stdout.write(renderMarkdownReport(run));
52
+ return 0;
53
+ }
54
+ if (values.kind === 'compare') {
55
+ const a = await loadRunReport(values.runPathA);
56
+ const b = await loadRunReport(values.runPathB);
57
+ io.stdout.write(renderCompareMarkdown(compareRuns(a, b)));
58
+ return 0;
59
+ }
60
+ const benchmark = await loadBenchmark(values.benchmarkPath);
61
+ const run = await runBenchmark(benchmark, {
62
+ ...(values.trials !== undefined ? { trials: values.trials } : {}),
63
+ ...(values.dshCommand !== undefined ? { command: values.dshCommand } : {}),
64
+ ...(values.profile !== undefined ? { profile: values.profile } : {}),
65
+ });
66
+ await writeRunReport(run, values.outPath);
67
+ io.stdout.write(`Wrote ${values.outPath} (${run.cases.length} trials, ${summary(run)})\n`);
68
+ return run.aggregate === null ? 1 : 0;
69
+ }
70
+ catch (error) {
71
+ io.stderr.write(`dsh eval: ${error instanceof Error ? error.message : String(error)}\n`);
72
+ return 1;
73
+ }
74
+ }
75
+ /**
76
+ * Mount the eval command-line app: parse the invocation, run it asynchronously,
77
+ * and request launcher exit with the result code.
78
+ * @param ctx - plugin context carrying the command line and launcher exit.
79
+ */
80
+ export function apply(ctx) {
81
+ const exit = ctx.get('appExit');
82
+ if (exit === undefined)
83
+ throw new Error('eval: the launcher must provide ctx.appExit before the tree mounts');
84
+ const values = applyEval(ctx);
85
+ if (values === undefined)
86
+ return;
87
+ void executeEval(values, internals).then((code) => { exit(code); });
88
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Package-owned invariant companion for `dsh-eval`.
3
+ * @module dsh-eval/invariant
4
+ */
5
+ const PACKAGE_NAME = 'dsh-eval';
6
+ /** Cordis companion plugin name. */
7
+ export const name = 'eval-invariant';
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export const inject = ['invariants'];
10
+ /**
11
+ * No runtime invariant: the package reads persisted session logs and spawns
12
+ * headless subprocesses; it appends no session events and owns no live
13
+ * authoritative stream, so no event/data relation exists for an independent
14
+ * companion to observe.
15
+ */
16
+ const install = () => { };
17
+ /**
18
+ * Register this package's invariant companion.
19
+ * @param ctx - Cordis context carrying the invariant service.
20
+ * @returns the installed registration's disposer after setup succeeds.
21
+ */
22
+ export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
23
+ /* jscpd:ignore-end */
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Benchmark document loading and validation for dsh-eval. YAML parses with
3
+ * js-yaml's safe loader; zod validates the parsed shape; prompt files and
4
+ * workspaces resolve against the benchmark file's directory.
5
+ *
6
+ * @module dsh-eval/benchmark
7
+ */
8
+ import type { Benchmark } from './types.ts';
9
+ /**
10
+ * Parse benchmark YAML text into a validated runtime document.
11
+ * @param text - the benchmark document's YAML source.
12
+ * @param baseDir - absolute directory used to resolve prompt and workspace paths.
13
+ * @returns the validated benchmark.
14
+ */
15
+ export declare function parseBenchmark(text: string, baseDir: string): Promise<Benchmark>;
16
+ /**
17
+ * Load and validate a benchmark document from disk.
18
+ * @param path - path to the benchmark YAML file.
19
+ * @returns the validated benchmark.
20
+ */
21
+ export declare function loadBenchmark(path: string): Promise<Benchmark>;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The eval app's commander program: `run <benchmark.yaml>` executes a
3
+ * benchmark and writes its JSON report; `report <run.json>` renders one as
4
+ * markdown. Parsing follows the cmdline contract: the action publishes an
5
+ * ordinary service, and help or a rejection publishes nothing.
6
+ *
7
+ * @module dsh-eval/command
8
+ */
9
+ import { Command } from 'commander';
10
+ import type { Context } from '@deepseek-ai/cordis';
11
+ /** What the eval app resolved from its command line. */
12
+ export type EvalStartupValues = {
13
+ kind: 'run';
14
+ benchmarkPath: string;
15
+ outPath: string;
16
+ trials?: number;
17
+ dshCommand?: readonly string[];
18
+ profile?: string;
19
+ } | {
20
+ kind: 'report';
21
+ runPath: string;
22
+ } | {
23
+ kind: 'compare';
24
+ runPathA: string;
25
+ runPathB: string;
26
+ };
27
+ /**
28
+ * Build a fresh eval commander program. The root action rejects a bare
29
+ * invocation; the `run` and `report` actions hand the resolved values to the
30
+ * publish callback. The callback, not a Cordis service, carries the values
31
+ * because the plugin's own fiber is not yet active when the parse action runs
32
+ * and a strict `ctx.get` would miss a just-provided service.
33
+ * @param publish - receives the resolved invocation once a subcommand runs.
34
+ * @returns the configured program.
35
+ */
36
+ export declare function evalCommand(publish: (values: EvalStartupValues) => void): Command;
37
+ /**
38
+ * Parse the launcher's inner arguments with the eval program and return what
39
+ * the invoked command published.
40
+ * @param ctx - plugin context carrying `cmdlineArgs` and `appExit`.
41
+ * @returns the resolved invocation, or undefined when help or an error exited.
42
+ */
43
+ export declare function applyEval(ctx: Context): EvalStartupValues | undefined;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Cross-run comparison for dsh-eval: two persisted run reports become a row
3
+ * list of metric values and deltas, rendered as a markdown table.
4
+ *
5
+ * @module dsh-eval/compare
6
+ */
7
+ import type { EvalRun } from './types.ts';
8
+ /** One compared metric row. */
9
+ export interface CompareRow {
10
+ /** Metric label. */
11
+ metric: string;
12
+ /** Run A's rendered value. */
13
+ a: string;
14
+ /** Run B's rendered value. */
15
+ b: string;
16
+ /** Signed delta (`b - a`) for numeric rows, or a dash for text rows. */
17
+ delta: string;
18
+ }
19
+ /**
20
+ * Build the comparison rows between two runs.
21
+ * @param a - the baseline run.
22
+ * @param b - the candidate run.
23
+ * @returns the row list in display order.
24
+ */
25
+ export declare function compareRuns(a: EvalRun, b: EvalRun): CompareRow[];
26
+ /**
27
+ * Render comparison rows as a markdown table.
28
+ * @param rows - the rows from {@link compareRuns}.
29
+ * @returns the markdown text.
30
+ */
31
+ export declare function renderCompareMarkdown(rows: readonly CompareRow[]): string;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * dsh-eval 鈥?agent evaluation over headless dsh profiles.
3
+ *
4
+ * The eval bundle mounts this command-line plugin over dsh-base. It parses
5
+ * `dsh --profile eval run <benchmark.yaml>` / `report <run.json>`, spawns one
6
+ * headless dsh subprocess per case x trial, harvests each persisted session
7
+ * log as a trace, folds automatic metrics, scripted grading (task success,
8
+ * tool-selection accuracy), and cross-run comparison, and writes a JSON run
9
+ * report. LLM-judge metrics (final-answer score, hallucination) and paired
10
+ * same-seed trials are deferred to later milestones.
11
+ *
12
+ * @module dsh-eval
13
+ */
14
+ import type { Context } from '@deepseek-ai/cordis';
15
+ import { type EvalStartupValues } from './command.ts';
16
+ /** Stable Cordis plugin name. */
17
+ export declare const name = "eval";
18
+ /** The launcher-provided command line is the only required service. */
19
+ export declare const inject: string[];
20
+ /** Process-facing output streams; tests substitute captures. */
21
+ export interface EvalIo {
22
+ stdout: {
23
+ write(chunk: string): unknown;
24
+ };
25
+ stderr: {
26
+ write(chunk: string): unknown;
27
+ };
28
+ }
29
+ /** The process streams the eval app writes to; tests substitute captures. */
30
+ export declare const internals: EvalIo;
31
+ /**
32
+ * Execute one eval invocation to completion.
33
+ * @param values - the resolved command-line invocation.
34
+ * @param io - output streams for the report and diagnostics.
35
+ * @returns the process exit code; nonzero for any failure or a run with no
36
+ * completed trials.
37
+ */
38
+ export declare function executeEval(values: EvalStartupValues, io: EvalIo): Promise<number>;
39
+ /**
40
+ * Mount the eval command-line app: parse the invocation, run it asynchronously,
41
+ * and request launcher exit with the result code.
42
+ * @param ctx - plugin context carrying the command line and launcher exit.
43
+ */
44
+ export declare function apply(ctx: Context): void;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Package-owned invariant companion for `dsh-eval`.
3
+ * @module dsh-eval/invariant
4
+ */
5
+ import type { Context } from '@deepseek-ai/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "eval-invariant";
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Register this package's invariant companion.
12
+ * @param ctx - Cordis context carrying the invariant service.
13
+ * @returns the installed registration's disposer after setup succeeds.
14
+ */
15
+ export declare const apply: (ctx: Context) => Promise<() => void>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Pure metric folding for dsh-eval: one pass over a session trace produces
3
+ * the automatic metric set, and pricing converts provider token buckets into
4
+ * USD. The fold mirrors session-stats wall-time semantics and adds the
5
+ * eval-owned failure and retry counters.
6
+ *
7
+ * @module dsh-eval/metrics
8
+ */
9
+ import type { SessionEvent } from '@deepseek-ai/dsh-session';
10
+ import type { BenchmarkPricing, EvalCaseMetrics, EvalTokenUsage } from './types.ts';
11
+ /**
12
+ * Fold a session trace into automatic metrics without pricing.
13
+ * @param events - the trace's durable events in log order.
14
+ * @returns the folded metrics with `costUsd: null`.
15
+ */
16
+ export declare function foldMetrics(events: readonly SessionEvent[]): EvalCaseMetrics;
17
+ /**
18
+ * Convert token buckets into USD using per-million-token prices.
19
+ * @param tokens - summed token buckets.
20
+ * @param pricing - per-million-token USD prices.
21
+ * @returns the estimated cost in USD.
22
+ */
23
+ export declare function computeCost(tokens: EvalTokenUsage, pricing: BenchmarkPricing): number;
24
+ /**
25
+ * Fold metrics and attach cost when a pricing table entry exists.
26
+ * @param events - the trace's durable events in log order.
27
+ * @param pricing - the benchmark model's pricing, or undefined for no cost.
28
+ * @returns the folded metrics.
29
+ */
30
+ export declare function computeMetrics(events: readonly SessionEvent[], pricing: BenchmarkPricing | undefined): EvalCaseMetrics;
31
+ /**
32
+ * Aggregate per-trial metrics: arithmetic means for counts and wall times,
33
+ * pooled success rate, and the mean cost when every trial priced it.
34
+ * @param items - completed trials' metrics.
35
+ * @returns the aggregate, or null when no trial is included.
36
+ */
37
+ export declare function aggregateMetrics(items: readonly EvalCaseMetrics[]): EvalCaseMetrics | null;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Run-report persistence and markdown rendering for dsh-eval.
3
+ *
4
+ * @module dsh-eval/report
5
+ */
6
+ import type { EvalRun } from './types.ts';
7
+ /**
8
+ * Write a run report as indented JSON with a trailing newline.
9
+ * @param run - the run record to persist.
10
+ * @param path - output path; parent directories are created.
11
+ */
12
+ export declare function writeRunReport(run: EvalRun, path: string): Promise<void>;
13
+ /**
14
+ * Load a persisted run report, rejecting anything without the required surface.
15
+ * @param path - path to the run JSON.
16
+ * @returns the loaded run record.
17
+ */
18
+ export declare function loadRunReport(path: string): Promise<EvalRun>;
19
+ /**
20
+ * Render a run report as a markdown table: one row per trial plus the
21
+ * aggregate row.
22
+ * @param run - the run record to render.
23
+ * @returns the markdown text.
24
+ */
25
+ export declare function renderMarkdownReport(run: EvalRun): string;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Benchmark runner for dsh-eval: one fresh subprocess per case x trial.
3
+ *
4
+ * Each trial owns a private temp directory with a copied workspace, an
5
+ * isolated DSH_HOME, and a patch overlay that forces plain-JSONL persistence
6
+ * and non-interactive workspace-scoped permissions. The spawned command is
7
+ * the same trusted dsh harness (credentials flow through deliberately: the
8
+ * child must reach the real model API, and the session log never stores
9
+ * them), so the defensive scrubbed-env rule's leak concern does not apply to
10
+ * this child. Timeout kills the direct child and reports timed-out orthogonally
11
+ * from its exit code; Windows descendants of a killed process may survive.
12
+ *
13
+ * @module dsh-eval/runner
14
+ */
15
+ import type { Benchmark, EvalRun } from './types.ts';
16
+ /** Runtime overrides applied to a loaded benchmark. */
17
+ export interface RunOptions {
18
+ /** Override the benchmark's dsh command argv. */
19
+ command?: readonly string[];
20
+ /** Override the benchmark's spawned profile. */
21
+ profile?: string;
22
+ /** Override the benchmark's trials per case. */
23
+ trials?: number;
24
+ /** Root for trial directories; defaults to the platform temp dir. */
25
+ tempRoot?: string;
26
+ }
27
+ /**
28
+ * Run every case x trial sequentially and aggregate the completed trials.
29
+ * @param benchmark - the loaded benchmark.
30
+ * @param options - runtime overrides and test seams.
31
+ * @returns the completed run record, written by the caller.
32
+ */
33
+ export declare function runBenchmark(benchmark: Benchmark, options?: RunOptions): Promise<EvalRun>;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Session-log harvesting and parsing for dsh-eval. A trial's headless dsh
3
+ * writes a plain-JSONL session log under its DSH_HOME; the importer reads the
4
+ * header line, decodes every event row (packed chunk rows included) through
5
+ * the session package's storage decoder, and enforces seq continuity.
6
+ *
7
+ * @module dsh-eval/trace
8
+ */
9
+ import type { EvalTrace } from './types.ts';
10
+ /**
11
+ * Parse a plain-JSONL session log into a trace.
12
+ * @param text - the log file's UTF-8 text, header line first.
13
+ * @returns the parsed trace.
14
+ * @throws when the header is missing or malformed, a row is not valid JSON,
15
+ * or event seqs are not contiguous.
16
+ */
17
+ export declare function parseSessionLog(text: string): EvalTrace;
18
+ /**
19
+ * Load and parse the primary session log at a path.
20
+ * @param path - absolute path to a `session.jsonl` file.
21
+ * @returns the parsed trace.
22
+ */
23
+ export declare function loadTrace(path: string): Promise<EvalTrace>;
24
+ /**
25
+ * Find the newest primary `session.jsonl` under a DSH_HOME tree, descending
26
+ * into directories without following symlinks.
27
+ * @param root - the DSH_HOME directory to scan.
28
+ * @returns the newest primary log's absolute path, or null when none exists.
29
+ */
30
+ export declare function findPrimarySessionLog(root: string): Promise<string | null>;