@databricks/appkit-ui 0.73.0 → 0.74.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/CLAUDE.md CHANGED
@@ -99,9 +99,11 @@ npx @databricks/appkit docs <query>
99
99
  - [Function: createWorkspaceClient()](./docs/api/appkit/Function.createWorkspaceClient.md): Construct an AppKit workspace client.
100
100
  - [Function: database()](./docs/api/appkit/Function.database.md): Create a typed database plugin registration for a finalized schema.
101
101
  - [Function: defineEval()](./docs/api/appkit/Function.defineEval.md): Define an agent eval. Default-export the result from a
102
+ - [Function: defineEvalConfig()](./docs/api/appkit/Function.defineEvalConfig.md): Define per-directory eval config. Default-export from evals.config.ts.
102
103
  - [Function: defineManifest()](./docs/api/appkit/Function.defineManifest.md): Validates a raw manifest (typically a manifest.json import) against the
103
104
  - [Function: defineSchema()](./docs/api/appkit/Function.defineSchema.md): Compile one declared schema. The returned type keeps the table names the
104
105
  - [Function: defineTool()](./docs/api/appkit/Function.defineTool.md): Defines a single tool entry for a plugin's internal registry.
106
+ - [Function: discoverEvalConfigs()](./docs/api/appkit/Function.discoverEvalConfigs.md): Discover the per-agent evals.config.ts (from defineEvalConfig) at
105
107
  - [Function: discoverEvalFiles()](./docs/api/appkit/Function.discoverEvalFiles.md): Discover evals under /server/agents//evals/ — co-located
106
108
  - [Function: enumColumn()](./docs/api/appkit/Function.enumColumn.md): Parameters
107
109
  - [Function: equals()](./docs/api/appkit/Function.equals.md): Passes when the value equals expected exactly.
@@ -113,6 +115,8 @@ npx @databricks/appkit docs <query>
113
115
  - [Function: formatEvalDetail()](./docs/api/appkit/Function.formatEvalDetail.md): Indented detail lines for a failing eval (error + failing assertions).
114
116
  - [Function: formatEvalHeadline()](./docs/api/appkit/Function.formatEvalHeadline.md): The one-line header for a single eval result (no failure detail).
115
117
  - [Function: formatEvalResults()](./docs/api/appkit/Function.formatEvalResults.md): Render all results as a human-readable console report (non-streaming).
118
+ - [Function: formatResultsJson()](./docs/api/appkit/Function.formatResultsJson.md): Render results as a machine-readable JSON report (2-space indented):
119
+ - [Function: formatResultsJUnit()](./docs/api/appkit/Function.formatResultsJUnit.md): Render results as JUnit XML for standard CI test reporters: a single
116
120
  - [Function: formatSummaryLine()](./docs/api/appkit/Function.formatSummaryLine.md): The final PASS/FAIL summary line.
117
121
  - [Function: fromSupervisorApi()](./docs/api/appkit/Function.fromSupervisorApi.md): Creates an AgentAdapter backed by the Databricks AI Gateway
118
122
  - [Function: functionToolToDefinition()](./docs/api/appkit/Function.functionToolToDefinition.md): Parameters
@@ -148,11 +152,13 @@ npx @databricks/appkit docs <query>
148
152
  - [Function: runAgent()](./docs/api/appkit/Function.runAgent.md): Standalone agent execution without createApp. Resolves the adapter, binds
149
153
  - [Function: runEval()](./docs/api/appkit/Function.runEval.md): Run a single eval against a driver. Never throws for assertion or agent
150
154
  - [Function: runEvalsInDir()](./docs/api/appkit/Function.runEvalsInDir.md): Discover, load, and run every eval under each agent's evals/ dir, driving
155
+ - [Function: runWithRetries()](./docs/api/appkit/Function.runWithRetries.md): Run attempt up to 1 + retries times, stopping as soon as it returns a
151
156
  - [Function: summarize()](./docs/api/appkit/Function.summarize.md): Parameters
152
157
  - [Function: text()](./docs/api/appkit/Function.text.md): Returns
153
158
  - [Function: timestamp()](./docs/api/appkit/Function.timestamp.md): Parameters
154
159
  - [Function: tool()](./docs/api/appkit/Function.tool.md): Factory for defining function tools with Zod schemas.
155
160
  - [Function: toolsFromRegistry()](./docs/api/appkit/Function.toolsFromRegistry.md): Produces the AgentToolDefinition[] a ToolProvider exposes to the LLM,
161
+ - [Function: userTurns()](./docs/api/appkit/Function.userTurns.md): Extract every user-message content, in order, from an MLflow
156
162
  - [Function: uuid()](./docs/api/appkit/Function.uuid.md): Returns
157
163
  - [Function: varchar()](./docs/api/appkit/Function.varchar.md): Parameters
158
164
  - [Interface: AgentAdapter](./docs/api/appkit/Interface.AgentAdapter.md): Properties
@@ -174,6 +180,7 @@ npx @databricks/appkit docs <query>
174
180
  - [Interface: DatabricksAuth](./docs/api/appkit/Interface.DatabricksAuth.md): Resolved Databricks host + bearer token for the eval runner's REST calls.
175
181
  - [Interface: DatasetRow](./docs/api/appkit/Interface.DatasetRow.md): One row of a managed evaluation dataset. inputs are the kwargs passed to the
176
182
  - [Interface: DiscoveredEval](./docs/api/appkit/Interface.DiscoveredEval.md): An eval file found under server/agents//evals/.
183
+ - [Interface: DiscoveredEvalConfig](./docs/api/appkit/Interface.DiscoveredEvalConfig.md): A per-agent evals.config.ts found under server/agents//evals/.
177
184
  - [Interface: DriveResult](./docs/api/appkit/Interface.DriveResult.md): What a driver returns for a single t.send.
178
185
  - [Interface: EndpointConfig](./docs/api/appkit/Interface.EndpointConfig.md): Properties
179
186
  - [Interface: EntityMutationHooks<TTable>](./docs/api/appkit/Interface.EntityMutationHooks.md): Mutation lifecycle for one entity. A before hook may return a replacement
@@ -1,4 +1,5 @@
1
- import { Command } from "commander";
1
+ import fs from "node:fs";
2
+ import { Command, Option } from "commander";
2
3
 
3
4
  //#region src/cli/commands/agent/eval.ts
4
5
  /**
@@ -24,6 +25,17 @@ function parseHeaders(values) {
24
25
  return headers;
25
26
  }
26
27
  /**
28
+ * Parse `--min-pass-rate`: a finite number in `[0, 1]`, or `undefined` when
29
+ * unset. Throws on blank, out-of-range, or non-numeric input so a bad gate
30
+ * value fails fast instead of silently disabling or inverting the CI gate.
31
+ */
32
+ function parsePassRate(raw) {
33
+ if (raw === void 0) return void 0;
34
+ const n = Number(raw);
35
+ if (raw.trim() === "" || !Number.isFinite(n) || n < 0 || n > 1) throw new Error(`Invalid --min-pass-rate "${raw}" — expected a number in [0, 1]`);
36
+ return n;
37
+ }
38
+ /**
27
39
  * Native MLflow "Evaluation run" config — only when creds + an experiment are
28
40
  * all present (traces live in the app; the run + scores are driven from here).
29
41
  */
@@ -47,17 +59,22 @@ function resolveJudge(opts, auth) {
47
59
  model
48
60
  } : void 0;
49
61
  }
50
- /** Progress reporter: stream each eval as it runs instead of going silent. */
51
- function makeProgressReporter(runner, url) {
62
+ /**
63
+ * Progress reporter: stream each eval as it runs instead of going silent. In a
64
+ * machine reporter (json/junit) the live per-eval streaming is suppressed and
65
+ * banners go to stderr (via `info`), keeping stdout clean for the report.
66
+ */
67
+ function makeProgressReporter(runner, url, machine, info) {
52
68
  return (event) => {
53
69
  switch (event.type) {
54
70
  case "discovered":
55
- console.log(`Running ${event.total} eval${event.total === 1 ? "" : "s"} against ${url}\n`);
71
+ info(`Running ${event.total} eval${event.total === 1 ? "" : "s"} against ${url}\n`);
56
72
  break;
57
73
  case "run-created":
58
- console.log(`MLflow evaluation run: ${event.runId}\n`);
74
+ info(`MLflow evaluation run: ${event.runId}\n`);
59
75
  break;
60
76
  case "result":
77
+ if (machine) break;
61
78
  console.log(`[${event.index + 1}/${event.total}] ${runner.formatEvalHeadline(event.result)}`);
62
79
  for (const line of runner.formatEvalDetail(event.result)) console.log(line);
63
80
  break;
@@ -67,33 +84,53 @@ function makeProgressReporter(runner, url) {
67
84
  function formatFailureLine(f) {
68
85
  return ` ✗ trace ${f.traceId}: ${f.status ?? ""} ${f.error ?? ""}`.trim();
69
86
  }
70
- /** Print the MLflow assessment/finish outcome after a run that created one. */
71
- function printMlflowOutcome(mlflow) {
87
+ /**
88
+ * Print the MLflow assessment/finish outcome after a run that created one. The
89
+ * summary line goes through `info` (stderr under a machine reporter); per-trace
90
+ * failures and finish errors always go to stderr.
91
+ */
92
+ function printMlflowOutcome(mlflow, info) {
72
93
  const { report, finish } = mlflow;
73
- console.log(`MLflow: ${report.written} assessment(s) written` + (report.skipped ? `, ${report.skipped} skipped` : "") + (report.failures.length ? `, ${report.failures.length} failed` : ""));
94
+ info(`MLflow: ${report.written} assessment(s) written` + (report.skipped ? `, ${report.skipped} skipped` : "") + (report.failures.length ? `, ${report.failures.length} failed` : ""));
74
95
  for (const f of report.failures) console.error(formatFailureLine(f));
75
96
  if (finish.metricsError) console.error(` ⚠ metrics not logged: ${finish.metricsError}`);
76
97
  if (!finish.finished) console.error(` ✗ run left RUNNING — failed to finish: ${finish.finishError ?? "unknown"}`);
77
98
  }
78
99
  async function runAgentEval(filter, opts) {
79
100
  const runner = await loadRunner();
80
- const auth = await runner.resolveDatabricksAuth({
101
+ const credentials = {
81
102
  profile: opts.profile ?? process.env.DATABRICKS_CONFIG_PROFILE,
82
103
  host: opts.databricksHost ?? process.env.DATABRICKS_HOST,
83
104
  token: opts.databricksToken ?? process.env.DATABRICKS_TOKEN
84
- }) ?? {};
105
+ };
106
+ const auth = await runner.resolveDatabricksAuth(credentials) ?? {};
85
107
  const warehouseId = opts.warehouseId ?? process.env.DATABRICKS_WAREHOUSE_ID;
86
- const workspaceClient = runner.resolveWorkspaceClient({
87
- profile: opts.profile ?? process.env.DATABRICKS_CONFIG_PROFILE,
88
- host: opts.databricksHost ?? process.env.DATABRICKS_HOST,
89
- token: opts.databricksToken ?? process.env.DATABRICKS_TOKEN
90
- });
108
+ const workspaceClient = runner.resolveWorkspaceClient(credentials);
109
+ const parsedTimeout = opts.timeout ? Number.parseInt(opts.timeout, 10) : void 0;
110
+ const timeoutMs = parsedTimeout && parsedTimeout > 0 ? parsedTimeout : void 0;
111
+ const parsedRetries = opts.retries ? Number.parseInt(opts.retries, 10) : void 0;
112
+ const retries = parsedRetries && parsedRetries > 0 ? parsedRetries : void 0;
113
+ let minPassRate;
114
+ try {
115
+ minPassRate = parsePassRate(opts.minPassRate);
116
+ } catch (err) {
117
+ console.error(err instanceof Error ? err.message : String(err));
118
+ process.exitCode = 1;
119
+ return;
120
+ }
121
+ const reporter = opts.reporter ?? "text";
122
+ const machine = reporter !== "text";
123
+ const info = (msg) => {
124
+ if (machine) console.error(msg);
125
+ else console.log(msg);
126
+ };
91
127
  let summary;
92
128
  try {
93
129
  summary = await runner.runEvalsInDir({
94
130
  rootDir: opts.root,
95
131
  baseUrl: opts.url,
96
132
  filter,
133
+ tags: opts.tag,
97
134
  strict: opts.strict,
98
135
  headers: opts.header ? parseHeaders(opts.header) : void 0,
99
136
  concurrency: opts.concurrency,
@@ -101,19 +138,43 @@ async function runAgentEval(filter, opts) {
101
138
  judge: resolveJudge(opts, auth),
102
139
  workspaceClient,
103
140
  warehouseId,
104
- onEvent: makeProgressReporter(runner, opts.url)
141
+ timeoutMs,
142
+ retries,
143
+ onEvent: makeProgressReporter(runner, opts.url, machine, info)
105
144
  });
106
145
  } catch (err) {
107
146
  console.error(`\nEval run failed: ${err instanceof Error ? err.message : String(err)}`);
108
147
  process.exitCode = 1;
109
148
  return;
110
149
  }
111
- console.log(`\n${runner.formatSummaryLine(summary.results)}`);
112
- if (summary.mlflow) printMlflowOutcome(summary.mlflow);
113
- else console.log("\nMLflow evaluation run skipped — pass --experiment (or set MLFLOW_EXPERIMENT_ID) plus --profile/--databricks-host to create one.");
114
- if (!runner.summarize(summary.results).allPassed) process.exitCode = 1;
150
+ info(`\n${runner.formatSummaryLine(summary.results)}`);
151
+ if (summary.mlflow) printMlflowOutcome(summary.mlflow, info);
152
+ else info("\nMLflow evaluation run skipped — pass --experiment (or set MLFLOW_EXPERIMENT_ID) plus --profile/--databricks-host to create one.");
153
+ if (machine) {
154
+ const report = reporter === "json" ? runner.formatResultsJson(summary.results) : runner.formatResultsJUnit(summary.results);
155
+ if (opts.output) {
156
+ try {
157
+ fs.writeFileSync(opts.output, `${report}\n`);
158
+ } catch (err) {
159
+ console.error(`Failed to write ${reporter} report to ${opts.output}: ${err instanceof Error ? err.message : String(err)}`);
160
+ process.exitCode = 1;
161
+ return;
162
+ }
163
+ info(`Wrote ${reporter} report to ${opts.output}`);
164
+ } else process.stdout.write(`${report}\n`);
165
+ }
166
+ const stats = runner.summarize(summary.results);
167
+ if (minPassRate !== void 0) {
168
+ const ok = stats.passRate >= minPassRate;
169
+ info(`Pass rate ${(stats.passRate * 100).toFixed(0)}% (threshold ${(minPassRate * 100).toFixed(0)}%) — ${ok ? "OK" : "below threshold"}`);
170
+ if (!ok) process.exitCode = 1;
171
+ } else if (!stats.allPassed) process.exitCode = 1;
115
172
  }
116
- const agentEvalCommand = new Command("eval").description("Run agent evals (server/agents/<id>/evals/*.eval.ts) against a running app").argument("[filter]", "Only run evals whose <agent>/<id> contains this substring (or an exact agent id)").option("--url <url>", "Base URL of the running app", "http://localhost:3000").option("--strict", "Fail on soft-assertion misses too", false).option("--concurrency <n>", "Max evals to run concurrently (default 4; keep at or below the app's max concurrent streams per user)", (v) => Number.parseInt(v, 10)).option("--root <dir>", "Project root containing server/agents/ (default: cwd)").option("--header <header...>", "Extra request header as 'Key: value' (repeatable)").option("--profile <name>", "Databricks CLI profile to authenticate with via OAuth (default: DATABRICKS_CONFIG_PROFILE)").option("--databricks-host <host>", "Databricks host for writing MLflow assessments (default: DATABRICKS_HOST)").option("--databricks-token <token>", "Databricks token for writing MLflow assessments (default: DATABRICKS_TOKEN)").option("--experiment <id>", "MLflow experiment id for the evaluation run (default: MLFLOW_EXPERIMENT_ID)").option("--warehouse-id <id>", "SQL warehouse id for reading managed eval datasets and writing assessments to UC-backed experiments (default: DATABRICKS_WAREHOUSE_ID, or MLFLOW_TRACING_SQL_WAREHOUSE_ID for assessments)").option("--judge-model <endpoint>", "Databricks serving endpoint to use as the LLM judge for t.judge.* (default: APPKIT_JUDGE_MODEL)").action(runAgentEval);
173
+ const agentEvalCommand = new Command("eval").description("Run agent evals (server/agents/<id>/evals/*.eval.ts) against a running app").argument("[filter]", "Only run evals whose <agent>/<id> contains this substring (or an exact agent id)").option("--url <url>", "Base URL of the running app", "http://localhost:3000").option("--strict", "Fail on soft-assertion misses too", false).option("--concurrency <n>", "Max evals to run concurrently (default 4; keep at or below the app's max concurrent streams per user)", (v) => Number.parseInt(v, 10)).option("--root <dir>", "Project root containing server/agents/ (default: cwd)").option("--header <header...>", "Extra request header as 'Key: value' (repeatable)").option("--tag <tag...>", "Only run evals tagged with one of these tags (repeatable)").option("--profile <name>", "Databricks CLI profile to authenticate with via OAuth (default: DATABRICKS_CONFIG_PROFILE)").option("--databricks-host <host>", "Databricks host for writing MLflow assessments (default: DATABRICKS_HOST)").option("--databricks-token <token>", "Databricks token for writing MLflow assessments (default: DATABRICKS_TOKEN)").option("--experiment <id>", "MLflow experiment id for the evaluation run (default: MLFLOW_EXPERIMENT_ID)").option("--warehouse-id <id>", "SQL warehouse id for reading managed eval datasets and writing assessments to UC-backed experiments (default: DATABRICKS_WAREHOUSE_ID, or MLFLOW_TRACING_SQL_WAREHOUSE_ID for assessments)").option("--judge-model <endpoint>", "Databricks serving endpoint to use as the LLM judge for t.judge.* (default: APPKIT_JUDGE_MODEL)").option("--timeout <ms>", "Default per-eval timeout in ms (a per-eval timeoutMs overrides it)").option("--retries <n>", "Re-run an eval up to N times when it fails on an infra error (turn/timeout); assertion failures are not retried").option("--min-pass-rate <rate>", "Gate on aggregate pass rate (0..1) instead of requiring every eval to pass; exit 1 when below").addOption(new Option("--reporter <format>", "Report format: text (live console), json (dashboards), or junit (CI test reporters)").choices([
174
+ "text",
175
+ "json",
176
+ "junit"
177
+ ]).default("text")).option("--output <file>", "Write the json/junit report to this file instead of stdout (ignored for text)").action(runAgentEval);
117
178
 
118
179
  //#endregion
119
180
  export { agentEvalCommand };
@@ -1 +1 @@
1
- {"version":3,"file":"eval.js","names":[],"sources":["../../../../src/cli/commands/agent/eval.ts"],"sourcesContent":["import { Command } from \"commander\";\n\ninterface EvalRunSummary {\n results: unknown[];\n mlflow?: {\n runId: string;\n report: {\n written: number;\n skipped: number;\n failures: Array<{ traceId: string; status?: number; error?: string }>;\n };\n finish: { finished: boolean; metricsError?: string; finishError?: string };\n };\n}\n\ntype EvalProgress =\n | { type: \"discovered\"; total: number }\n | { type: \"run-created\"; runId: string }\n | { type: \"start\"; id: string; index: number; total: number }\n | { type: \"result\"; result: unknown; index: number; total: number };\n\n/** Subset of `@databricks/appkit/beta`'s eval runner used by this command. */\ninterface EvalRunner {\n runEvalsInDir(opts: {\n rootDir?: string;\n baseUrl: string;\n filter?: string;\n strict?: boolean;\n headers?: Record<string, string>;\n concurrency?: number;\n mlflow?: {\n host: string;\n token: string;\n experimentId: string;\n sqlWarehouseId?: string;\n };\n judge?: { host: string; token: string; model: string };\n workspaceClient?: unknown;\n warehouseId?: string;\n onEvent?: (event: EvalProgress) => void;\n }): Promise<EvalRunSummary>;\n resolveDatabricksAuth(opts: {\n profile?: string;\n host?: string;\n token?: string;\n }): Promise<{ host: string; token: string } | undefined>;\n resolveWorkspaceClient(opts: {\n profile?: string;\n host?: string;\n token?: string;\n }): unknown;\n formatEvalHeadline(result: unknown): string;\n evalGlyph(result: unknown): string;\n formatEvalDetail(result: unknown): string[];\n formatSummaryLine(results: unknown[]): string;\n summarize(results: unknown[]): { allPassed: boolean };\n}\n\n/**\n * Loaded at runtime from the consuming project so this command (which ships in\n * `@databricks/shared`) doesn't take a build-time dependency on appkit. The\n * specifier is a variable so the type checker treats it as `any`.\n */\nasync function loadRunner(): Promise<EvalRunner> {\n const spec = \"@databricks/appkit/beta\";\n try {\n return (await import(spec)) as unknown as EvalRunner;\n } catch (err) {\n throw new Error(\n \"Could not load @databricks/appkit. Run `appkit agent eval` from a \" +\n \"project with @databricks/appkit installed. \" +\n `Cause: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n}\n\nfunction parseHeaders(values: string[]): Record<string, string> {\n const headers: Record<string, string> = {};\n for (const v of values) {\n const i = v.indexOf(\":\");\n if (i === -1) continue;\n headers[v.slice(0, i).trim()] = v.slice(i + 1).trim();\n }\n return headers;\n}\n\ninterface EvalOptions {\n url: string;\n strict?: boolean;\n root?: string;\n header?: string[];\n profile?: string;\n databricksHost?: string;\n databricksToken?: string;\n experiment?: string;\n judgeModel?: string;\n concurrency?: number;\n warehouseId?: string;\n}\n\n/** Resolved Databricks host + bearer (either field may be absent). */\ntype Auth = { host?: string; token?: string };\n\n/**\n * Native MLflow \"Evaluation run\" config — only when creds + an experiment are\n * all present (traces live in the app; the run + scores are driven from here).\n */\nfunction resolveMlflow(opts: EvalOptions, auth: Auth) {\n const experimentId = opts.experiment ?? process.env.MLFLOW_EXPERIMENT_ID;\n if (!(auth.host && auth.token && experimentId)) return undefined;\n // UC-backed experiments need a SQL warehouse to write assessments to their\n // V4 traces. Mirror mlflow's env var, and accept the common DATABRICKS one.\n const sqlWarehouseId =\n opts.warehouseId ??\n process.env.MLFLOW_TRACING_SQL_WAREHOUSE_ID ??\n process.env.DATABRICKS_WAREHOUSE_ID;\n return {\n host: auth.host,\n token: auth.token,\n experimentId,\n ...(sqlWarehouseId ? { sqlWarehouseId } : {}),\n };\n}\n\n/** LLM-as-judge config — reuses the Databricks creds + a judge serving endpoint. */\nfunction resolveJudge(opts: EvalOptions, auth: Auth) {\n const model = opts.judgeModel ?? process.env.APPKIT_JUDGE_MODEL;\n return model && auth.host && auth.token\n ? { host: auth.host, token: auth.token, model }\n : undefined;\n}\n\n/** Progress reporter: stream each eval as it runs instead of going silent. */\nfunction makeProgressReporter(\n runner: EvalRunner,\n url: string,\n): (event: EvalProgress) => void {\n return (event) => {\n switch (event.type) {\n case \"discovered\":\n console.log(\n `Running ${event.total} eval${event.total === 1 ? \"\" : \"s\"} against ${url}\\n`,\n );\n break;\n case \"run-created\":\n console.log(`MLflow evaluation run: ${event.runId}\\n`);\n break;\n case \"result\": {\n // One full line per completion — evals run concurrently, so a split\n // \"start … glyph\" prefix would interleave into garbage.\n console.log(\n `[${event.index + 1}/${event.total}] ${runner.formatEvalHeadline(event.result)}`,\n );\n for (const line of runner.formatEvalDetail(event.result)) {\n console.log(line);\n }\n break;\n }\n }\n };\n}\n\nfunction formatFailureLine(f: {\n traceId: string;\n status?: number;\n error?: string;\n}): string {\n return ` ✗ trace ${f.traceId}: ${f.status ?? \"\"} ${f.error ?? \"\"}`.trim();\n}\n\n/** Print the MLflow assessment/finish outcome after a run that created one. */\nfunction printMlflowOutcome(\n mlflow: NonNullable<EvalRunSummary[\"mlflow\"]>,\n): void {\n const { report, finish } = mlflow;\n console.log(\n `MLflow: ${report.written} assessment(s) written` +\n (report.skipped ? `, ${report.skipped} skipped` : \"\") +\n (report.failures.length ? `, ${report.failures.length} failed` : \"\"),\n );\n for (const f of report.failures) {\n console.error(formatFailureLine(f));\n }\n if (finish.metricsError) {\n console.error(` ⚠ metrics not logged: ${finish.metricsError}`);\n }\n if (!finish.finished) {\n console.error(\n ` ✗ run left RUNNING — failed to finish: ${finish.finishError ?? \"unknown\"}`,\n );\n }\n}\n\nasync function runAgentEval(\n filter: string | undefined,\n opts: EvalOptions,\n): Promise<void> {\n const runner = await loadRunner();\n\n // Resolve Databricks host + bearer the AppKit-native way: an explicit\n // host/token (or DATABRICKS_* env) wins; otherwise the SDK mints an OAuth\n // token from the CLI profile — so no hand-set PAT is required.\n const auth: Auth =\n (await runner.resolveDatabricksAuth({\n profile: opts.profile ?? process.env.DATABRICKS_CONFIG_PROFILE,\n host: opts.databricksHost ?? process.env.DATABRICKS_HOST,\n token: opts.databricksToken ?? process.env.DATABRICKS_TOKEN,\n })) ?? {};\n\n // Managed-dataset reads: a workspace client (same profile/host/token) + a SQL\n // warehouse. Only needed by evals that declare `dataset`.\n const warehouseId = opts.warehouseId ?? process.env.DATABRICKS_WAREHOUSE_ID;\n const workspaceClient = runner.resolveWorkspaceClient({\n profile: opts.profile ?? process.env.DATABRICKS_CONFIG_PROFILE,\n host: opts.databricksHost ?? process.env.DATABRICKS_HOST,\n token: opts.databricksToken ?? process.env.DATABRICKS_TOKEN,\n });\n\n let summary: EvalRunSummary;\n try {\n summary = await runner.runEvalsInDir({\n rootDir: opts.root,\n baseUrl: opts.url,\n filter,\n strict: opts.strict,\n headers: opts.header ? parseHeaders(opts.header) : undefined,\n concurrency: opts.concurrency,\n mlflow: resolveMlflow(opts, auth),\n judge: resolveJudge(opts, auth),\n workspaceClient,\n warehouseId,\n onEvent: makeProgressReporter(runner, opts.url),\n });\n } catch (err) {\n // Setup failures (e.g. a bad --experiment for the MLflow run) reject before\n // any eval runs; surface a clean message + non-zero exit rather than an\n // unhandled promise rejection with a raw stack.\n console.error(\n `\\nEval run failed: ${err instanceof Error ? err.message : String(err)}`,\n );\n process.exitCode = 1;\n return;\n }\n console.log(`\\n${runner.formatSummaryLine(summary.results)}`);\n\n if (summary.mlflow) {\n printMlflowOutcome(summary.mlflow);\n } else {\n console.log(\n \"\\nMLflow evaluation run skipped — pass --experiment (or set\" +\n \" MLFLOW_EXPERIMENT_ID) plus --profile/--databricks-host to create one.\",\n );\n }\n\n if (!runner.summarize(summary.results).allPassed) {\n process.exitCode = 1;\n }\n}\n\nexport const agentEvalCommand = new Command(\"eval\")\n .description(\n \"Run agent evals (server/agents/<id>/evals/*.eval.ts) against a running app\",\n )\n .argument(\n \"[filter]\",\n \"Only run evals whose <agent>/<id> contains this substring (or an exact agent id)\",\n )\n .option(\"--url <url>\", \"Base URL of the running app\", \"http://localhost:3000\")\n .option(\"--strict\", \"Fail on soft-assertion misses too\", false)\n .option(\n \"--concurrency <n>\",\n \"Max evals to run concurrently (default 4; keep at or below the app's max concurrent streams per user)\",\n (v) => Number.parseInt(v, 10),\n )\n .option(\n \"--root <dir>\",\n \"Project root containing server/agents/ (default: cwd)\",\n )\n .option(\n \"--header <header...>\",\n \"Extra request header as 'Key: value' (repeatable)\",\n )\n .option(\n \"--profile <name>\",\n \"Databricks CLI profile to authenticate with via OAuth (default: DATABRICKS_CONFIG_PROFILE)\",\n )\n .option(\n \"--databricks-host <host>\",\n \"Databricks host for writing MLflow assessments (default: DATABRICKS_HOST)\",\n )\n .option(\n \"--databricks-token <token>\",\n \"Databricks token for writing MLflow assessments (default: DATABRICKS_TOKEN)\",\n )\n .option(\n \"--experiment <id>\",\n \"MLflow experiment id for the evaluation run (default: MLFLOW_EXPERIMENT_ID)\",\n )\n .option(\n \"--warehouse-id <id>\",\n \"SQL warehouse id for reading managed eval datasets and writing assessments to UC-backed experiments (default: DATABRICKS_WAREHOUSE_ID, or MLFLOW_TRACING_SQL_WAREHOUSE_ID for assessments)\",\n )\n .option(\n \"--judge-model <endpoint>\",\n \"Databricks serving endpoint to use as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;GACA,QAAQ,KAAK;GACb,SAAS,KAAK,SAAS,aAAa,KAAK,OAAO,GAAG;GACnD,aAAa,KAAK;GAClB,QAAQ,cAAc,MAAM,KAAK;GACjC,OAAO,aAAa,MAAM,KAAK;GAC/B;GACA;GACA,SAAS,qBAAqB,QAAQ,KAAK,IAAI;GAChD,CAAC;UACK,KAAK;AAIZ,UAAQ,MACN,sBAAsB,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GACvE;AACD,UAAQ,WAAW;AACnB;;AAEF,SAAQ,IAAI,KAAK,OAAO,kBAAkB,QAAQ,QAAQ,GAAG;AAE7D,KAAI,QAAQ,OACV,oBAAmB,QAAQ,OAAO;KAElC,SAAQ,IACN,oIAED;AAGH,KAAI,CAAC,OAAO,UAAU,QAAQ,QAAQ,CAAC,UACrC,SAAQ,WAAW;;AAIvB,MAAa,mBAAmB,IAAI,QAAQ,OAAO,CAChD,YACC,6EACD,CACA,SACC,YACA,mFACD,CACA,OAAO,eAAe,+BAA+B,wBAAwB,CAC7E,OAAO,YAAY,qCAAqC,MAAM,CAC9D,OACC,qBACA,0GACC,MAAM,OAAO,SAAS,GAAG,GAAG,CAC9B,CACA,OACC,gBACA,wDACD,CACA,OACC,wBACA,oDACD,CACA,OACC,oBACA,6FACD,CACA,OACC,4BACA,4EACD,CACA,OACC,8BACA,8EACD,CACA,OACC,qBACA,8EACD,CACA,OACC,uBACA,6LACD,CACA,OACC,4BACA,kGACD,CACA,OAAO,aAAa"}
1
+ {"version":3,"file":"eval.js","names":[],"sources":["../../../../src/cli/commands/agent/eval.ts"],"sourcesContent":["import fs from \"node:fs\";\n\nimport { Command, Option } from \"commander\";\n\ninterface EvalRunSummary {\n results: unknown[];\n mlflow?: {\n runId: string;\n report: {\n written: number;\n skipped: number;\n failures: Array<{ traceId: string; status?: number; error?: string }>;\n };\n finish: { finished: boolean; metricsError?: string; finishError?: string };\n };\n}\n\ntype EvalProgress =\n | { type: \"discovered\"; total: number }\n | { type: \"run-created\"; runId: string }\n | { type: \"start\"; id: string; index: number; total: number }\n | { type: \"result\"; result: unknown; index: number; total: number };\n\n/** Subset of `@databricks/appkit/beta`'s eval runner used by this command. */\ninterface EvalRunner {\n runEvalsInDir(opts: {\n rootDir?: string;\n baseUrl: string;\n filter?: string;\n tags?: string[];\n strict?: boolean;\n headers?: Record<string, string>;\n concurrency?: number;\n mlflow?: {\n host: string;\n token: string;\n experimentId: string;\n sqlWarehouseId?: string;\n };\n judge?: { host: string; token: string; model: string };\n workspaceClient?: unknown;\n warehouseId?: string;\n timeoutMs?: number;\n retries?: number;\n onEvent?: (event: EvalProgress) => void;\n }): Promise<EvalRunSummary>;\n resolveDatabricksAuth(opts: {\n profile?: string;\n host?: string;\n token?: string;\n }): Promise<{ host: string; token: string } | undefined>;\n resolveWorkspaceClient(opts: {\n profile?: string;\n host?: string;\n token?: string;\n }): unknown;\n formatEvalHeadline(result: unknown): string;\n evalGlyph(result: unknown): string;\n formatEvalDetail(result: unknown): string[];\n formatSummaryLine(results: unknown[]): string;\n formatResultsJson(results: unknown[]): string;\n formatResultsJUnit(results: unknown[]): string;\n summarize(results: unknown[]): { allPassed: boolean; passRate: number };\n}\n\n/**\n * Loaded at runtime from the consuming project so this command (which ships in\n * `@databricks/shared`) doesn't take a build-time dependency on appkit. The\n * specifier is a variable so the type checker treats it as `any`.\n */\nasync function loadRunner(): Promise<EvalRunner> {\n const spec = \"@databricks/appkit/beta\";\n try {\n return (await import(spec)) as unknown as EvalRunner;\n } catch (err) {\n throw new Error(\n \"Could not load @databricks/appkit. Run `appkit agent eval` from a \" +\n \"project with @databricks/appkit installed. \" +\n `Cause: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n}\n\nfunction parseHeaders(values: string[]): Record<string, string> {\n const headers: Record<string, string> = {};\n for (const v of values) {\n const i = v.indexOf(\":\");\n if (i === -1) continue;\n headers[v.slice(0, i).trim()] = v.slice(i + 1).trim();\n }\n return headers;\n}\n\n/**\n * Parse `--min-pass-rate`: a finite number in `[0, 1]`, or `undefined` when\n * unset. Throws on blank, out-of-range, or non-numeric input so a bad gate\n * value fails fast instead of silently disabling or inverting the CI gate.\n */\nexport function parsePassRate(raw: string | undefined): number | undefined {\n if (raw === undefined) return undefined;\n const n = Number(raw);\n // Reject blank too: `Number(\"\")` is 0, which would silently disable the gate.\n if (raw.trim() === \"\" || !Number.isFinite(n) || n < 0 || n > 1) {\n throw new Error(\n `Invalid --min-pass-rate \"${raw}\" — expected a number in [0, 1]`,\n );\n }\n return n;\n}\n\ninterface EvalOptions {\n url: string;\n strict?: boolean;\n root?: string;\n header?: string[];\n tag?: string[];\n profile?: string;\n databricksHost?: string;\n databricksToken?: string;\n experiment?: string;\n judgeModel?: string;\n concurrency?: number;\n warehouseId?: string;\n timeout?: string;\n retries?: string;\n minPassRate?: string;\n reporter?: \"text\" | \"json\" | \"junit\";\n output?: string;\n}\n\n/** Resolved Databricks host + bearer (either field may be absent). */\ntype Auth = { host?: string; token?: string };\n\n/**\n * Native MLflow \"Evaluation run\" config — only when creds + an experiment are\n * all present (traces live in the app; the run + scores are driven from here).\n */\nfunction resolveMlflow(opts: EvalOptions, auth: Auth) {\n const experimentId = opts.experiment ?? process.env.MLFLOW_EXPERIMENT_ID;\n if (!(auth.host && auth.token && experimentId)) return undefined;\n // UC-backed experiments need a SQL warehouse to write assessments to their\n // V4 traces. Mirror mlflow's env var, and accept the common DATABRICKS one.\n const sqlWarehouseId =\n opts.warehouseId ??\n process.env.MLFLOW_TRACING_SQL_WAREHOUSE_ID ??\n process.env.DATABRICKS_WAREHOUSE_ID;\n return {\n host: auth.host,\n token: auth.token,\n experimentId,\n ...(sqlWarehouseId ? { sqlWarehouseId } : {}),\n };\n}\n\n/** LLM-as-judge config — reuses the Databricks creds + a judge serving endpoint. */\nfunction resolveJudge(opts: EvalOptions, auth: Auth) {\n const model = opts.judgeModel ?? process.env.APPKIT_JUDGE_MODEL;\n return model && auth.host && auth.token\n ? { host: auth.host, token: auth.token, model }\n : undefined;\n}\n\n/**\n * Progress reporter: stream each eval as it runs instead of going silent. In a\n * machine reporter (json/junit) the live per-eval streaming is suppressed and\n * banners go to stderr (via `info`), keeping stdout clean for the report.\n */\nfunction makeProgressReporter(\n runner: EvalRunner,\n url: string,\n machine: boolean,\n info: (msg: string) => void,\n): (event: EvalProgress) => void {\n return (event) => {\n switch (event.type) {\n case \"discovered\":\n info(\n `Running ${event.total} eval${event.total === 1 ? \"\" : \"s\"} against ${url}\\n`,\n );\n break;\n case \"run-created\":\n info(`MLflow evaluation run: ${event.runId}\\n`);\n break;\n case \"result\": {\n if (machine) break;\n // One full line per completion — evals run concurrently, so a split\n // \"start … glyph\" prefix would interleave into garbage.\n console.log(\n `[${event.index + 1}/${event.total}] ${runner.formatEvalHeadline(event.result)}`,\n );\n for (const line of runner.formatEvalDetail(event.result)) {\n console.log(line);\n }\n break;\n }\n }\n };\n}\n\nfunction formatFailureLine(f: {\n traceId: string;\n status?: number;\n error?: string;\n}): string {\n return ` ✗ trace ${f.traceId}: ${f.status ?? \"\"} ${f.error ?? \"\"}`.trim();\n}\n\n/**\n * Print the MLflow assessment/finish outcome after a run that created one. The\n * summary line goes through `info` (stderr under a machine reporter); per-trace\n * failures and finish errors always go to stderr.\n */\nfunction printMlflowOutcome(\n mlflow: NonNullable<EvalRunSummary[\"mlflow\"]>,\n info: (msg: string) => void,\n): void {\n const { report, finish } = mlflow;\n info(\n `MLflow: ${report.written} assessment(s) written` +\n (report.skipped ? `, ${report.skipped} skipped` : \"\") +\n (report.failures.length ? `, ${report.failures.length} failed` : \"\"),\n );\n for (const f of report.failures) {\n console.error(formatFailureLine(f));\n }\n if (finish.metricsError) {\n console.error(` ⚠ metrics not logged: ${finish.metricsError}`);\n }\n if (!finish.finished) {\n console.error(\n ` ✗ run left RUNNING — failed to finish: ${finish.finishError ?? \"unknown\"}`,\n );\n }\n}\n\nasync function runAgentEval(\n filter: string | undefined,\n opts: EvalOptions,\n): Promise<void> {\n const runner = await loadRunner();\n\n // Databricks credentials shared by auth resolution and the workspace client:\n // an explicit flag/DATABRICKS_* env wins, else the SDK resolves from the CLI\n // profile.\n const credentials = {\n profile: opts.profile ?? process.env.DATABRICKS_CONFIG_PROFILE,\n host: opts.databricksHost ?? process.env.DATABRICKS_HOST,\n token: opts.databricksToken ?? process.env.DATABRICKS_TOKEN,\n };\n\n // Resolve Databricks host + bearer the AppKit-native way: an explicit\n // host/token wins; otherwise the SDK mints an OAuth token from the CLI\n // profile — so no hand-set PAT is required.\n const auth: Auth = (await runner.resolveDatabricksAuth(credentials)) ?? {};\n\n // Managed-dataset reads: a workspace client (same profile/host/token) + a SQL\n // warehouse. Only needed by evals that declare `dataset`.\n const warehouseId = opts.warehouseId ?? process.env.DATABRICKS_WAREHOUSE_ID;\n const workspaceClient = runner.resolveWorkspaceClient(credentials);\n\n // Runner-level default per-eval timeout (ms). A per-eval `timeoutMs` wins.\n const parsedTimeout = opts.timeout\n ? Number.parseInt(opts.timeout, 10)\n : undefined;\n const timeoutMs =\n parsedTimeout && parsedTimeout > 0 ? parsedTimeout : undefined;\n\n // Extra attempts for evals that fail on an infra error (turn/timeout). Junk\n // or negative input falls back to no retries.\n const parsedRetries = opts.retries\n ? Number.parseInt(opts.retries, 10)\n : undefined;\n const retries =\n parsedRetries && parsedRetries > 0 ? parsedRetries : undefined;\n\n // Validate up front so a bad gate value fails before the run, not after.\n let minPassRate: number | undefined;\n try {\n minPassRate = parsePassRate(opts.minPassRate);\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exitCode = 1;\n return;\n }\n\n // In a machine reporter (json/junit), stdout is reserved for the report (it\n // may be piped), so human-facing lines go to stderr and the per-eval live\n // streaming is suppressed. Text mode keeps its current stdout behavior.\n const reporter = opts.reporter ?? \"text\";\n const machine = reporter !== \"text\";\n const info = (msg: string): void => {\n if (machine) console.error(msg);\n else console.log(msg);\n };\n\n let summary: EvalRunSummary;\n try {\n summary = await runner.runEvalsInDir({\n rootDir: opts.root,\n baseUrl: opts.url,\n filter,\n tags: opts.tag,\n strict: opts.strict,\n headers: opts.header ? parseHeaders(opts.header) : undefined,\n concurrency: opts.concurrency,\n mlflow: resolveMlflow(opts, auth),\n judge: resolveJudge(opts, auth),\n workspaceClient,\n warehouseId,\n timeoutMs,\n retries,\n onEvent: makeProgressReporter(runner, opts.url, machine, info),\n });\n } catch (err) {\n // Setup failures (e.g. a bad --experiment for the MLflow run) reject before\n // any eval runs; surface a clean message + non-zero exit rather than an\n // unhandled promise rejection with a raw stack.\n console.error(\n `\\nEval run failed: ${err instanceof Error ? err.message : String(err)}`,\n );\n process.exitCode = 1;\n return;\n }\n\n // The final human summary always shows (stderr for machine reporters so it\n // never pollutes the report on stdout/file).\n info(`\\n${runner.formatSummaryLine(summary.results)}`);\n\n if (summary.mlflow) {\n printMlflowOutcome(summary.mlflow, info);\n } else {\n info(\n \"\\nMLflow evaluation run skipped — pass --experiment (or set\" +\n \" MLFLOW_EXPERIMENT_ID) plus --profile/--databricks-host to create one.\",\n );\n }\n\n // Machine-readable report: build the string with a pure formatter, then emit\n // it to --output <file> or stdout (kept clean of the human noise above).\n if (machine) {\n const report =\n reporter === \"json\"\n ? runner.formatResultsJson(summary.results)\n : runner.formatResultsJUnit(summary.results);\n if (opts.output) {\n try {\n fs.writeFileSync(opts.output, `${report}\\n`);\n } catch (err) {\n console.error(\n `Failed to write ${reporter} report to ${opts.output}: ${\n err instanceof Error ? err.message : String(err)\n }`,\n );\n process.exitCode = 1;\n return;\n }\n info(`Wrote ${reporter} report to ${opts.output}`);\n } else {\n process.stdout.write(`${report}\\n`);\n }\n }\n\n const stats = runner.summarize(summary.results);\n if (minPassRate !== undefined) {\n // Threshold mode: gate on the aggregate pass rate rather than requiring\n // every eval to pass.\n const ok = stats.passRate >= minPassRate;\n info(\n `Pass rate ${(stats.passRate * 100).toFixed(0)}% (threshold ${(\n minPassRate * 100\n ).toFixed(0)}%) — ${ok ? \"OK\" : \"below threshold\"}`,\n );\n if (!ok) process.exitCode = 1;\n } else if (!stats.allPassed) {\n process.exitCode = 1;\n }\n}\n\nexport const agentEvalCommand = new Command(\"eval\")\n .description(\n \"Run agent evals (server/agents/<id>/evals/*.eval.ts) against a running app\",\n )\n .argument(\n \"[filter]\",\n \"Only run evals whose <agent>/<id> contains this substring (or an exact agent id)\",\n )\n .option(\"--url <url>\", \"Base URL of the running app\", \"http://localhost:3000\")\n .option(\"--strict\", \"Fail on soft-assertion misses too\", false)\n .option(\n \"--concurrency <n>\",\n \"Max evals to run concurrently (default 4; keep at or below the app's max concurrent streams per user)\",\n (v) => Number.parseInt(v, 10),\n )\n .option(\n \"--root <dir>\",\n \"Project root containing server/agents/ (default: cwd)\",\n )\n .option(\n \"--header <header...>\",\n \"Extra request header as 'Key: value' (repeatable)\",\n )\n .option(\n \"--tag <tag...>\",\n \"Only run evals tagged with one of these tags (repeatable)\",\n )\n .option(\n \"--profile <name>\",\n \"Databricks CLI profile to authenticate with via OAuth (default: DATABRICKS_CONFIG_PROFILE)\",\n )\n .option(\n \"--databricks-host <host>\",\n \"Databricks host for writing MLflow assessments (default: DATABRICKS_HOST)\",\n )\n .option(\n \"--databricks-token <token>\",\n \"Databricks token for writing MLflow assessments (default: DATABRICKS_TOKEN)\",\n )\n .option(\n \"--experiment <id>\",\n \"MLflow experiment id for the evaluation run (default: MLFLOW_EXPERIMENT_ID)\",\n )\n .option(\n \"--warehouse-id <id>\",\n \"SQL warehouse id for reading managed eval datasets and writing assessments to UC-backed experiments (default: DATABRICKS_WAREHOUSE_ID, or MLFLOW_TRACING_SQL_WAREHOUSE_ID for assessments)\",\n )\n .option(\n \"--judge-model <endpoint>\",\n \"Databricks serving endpoint to use as the LLM judge for t.judge.* (default: APPKIT_JUDGE_MODEL)\",\n )\n .option(\n \"--timeout <ms>\",\n \"Default per-eval timeout in ms (a per-eval timeoutMs overrides it)\",\n )\n .option(\n \"--retries <n>\",\n \"Re-run an eval up to N times when it fails on an infra error (turn/timeout); assertion failures are not retried\",\n )\n .option(\n \"--min-pass-rate <rate>\",\n \"Gate on aggregate pass rate (0..1) instead of requiring every eval to pass; exit 1 when below\",\n )\n .addOption(\n new Option(\n \"--reporter <format>\",\n \"Report format: text (live console), json (dashboards), or junit (CI test reporters)\",\n )\n .choices([\"text\", \"json\", \"junit\"])\n .default(\"text\"),\n )\n .option(\n \"--output <file>\",\n \"Write the json/junit report to this file instead of stdout (ignored for text)\",\n )\n .action(runAgentEval);\n"],"mappings":";;;;;;;;;AAsEA,eAAe,aAAkC;CAC/C,MAAM,OAAO;AACb,KAAI;AACF,SAAQ,MAAM,OAAO;UACd,KAAK;AACZ,QAAM,IAAI,MACR,yHAEY,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GAC7D;;;AAIL,SAAS,aAAa,QAA0C;CAC9D,MAAM,UAAkC,EAAE;AAC1C,MAAK,MAAM,KAAK,QAAQ;EACtB,MAAM,IAAI,EAAE,QAAQ,IAAI;AACxB,MAAI,MAAM,GAAI;AACd,UAAQ,EAAE,MAAM,GAAG,EAAE,CAAC,MAAM,IAAI,EAAE,MAAM,IAAI,EAAE,CAAC,MAAM;;AAEvD,QAAO;;;;;;;AAQT,SAAgB,cAAc,KAA6C;AACzE,KAAI,QAAQ,OAAW,QAAO;CAC9B,MAAM,IAAI,OAAO,IAAI;AAErB,KAAI,IAAI,MAAM,KAAK,MAAM,CAAC,OAAO,SAAS,EAAE,IAAI,IAAI,KAAK,IAAI,EAC3D,OAAM,IAAI,MACR,4BAA4B,IAAI,iCACjC;AAEH,QAAO;;;;;;AA8BT,SAAS,cAAc,MAAmB,MAAY;CACpD,MAAM,eAAe,KAAK,cAAc,QAAQ,IAAI;AACpD,KAAI,EAAE,KAAK,QAAQ,KAAK,SAAS,cAAe,QAAO;CAGvD,MAAM,iBACJ,KAAK,eACL,QAAQ,IAAI,mCACZ,QAAQ,IAAI;AACd,QAAO;EACL,MAAM,KAAK;EACX,OAAO,KAAK;EACZ;EACA,GAAI,iBAAiB,EAAE,gBAAgB,GAAG,EAAE;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ACC,uBACA,6LACD,CACA,OACC,4BACA,kGACD,CACA,OACC,kBACA,qEACD,CACA,OACC,iBACA,kHACD,CACA,OACC,0BACA,gGACD,CACA,UACC,IAAI,OACF,uBACA,sFACD,CACE,QAAQ;CAAC;CAAQ;CAAQ;CAAQ,CAAC,CAClC,QAAQ,OAAO,CACnB,CACA,OACC,mBACA,gFACD,CACA,OAAO,aAAa"}
@@ -0,0 +1,18 @@
1
+ # Function: defineEvalConfig()
2
+
3
+ ```ts
4
+ function defineEvalConfig(config: EvalConfig): EvalConfig;
5
+
6
+ ```
7
+
8
+ Define per-directory eval config. Default-export from `evals.config.ts`.
9
+
10
+ ## Parameters[​](#parameters "Direct link to Parameters")
11
+
12
+ | Parameter | Type |
13
+ | --------- | ------------ |
14
+ | `config` | `EvalConfig` |
15
+
16
+ ## Returns[​](#returns "Direct link to Returns")
17
+
18
+ `EvalConfig`
@@ -0,0 +1,18 @@
1
+ # Function: discoverEvalConfigs()
2
+
3
+ ```ts
4
+ function discoverEvalConfigs(rootDir: string): DiscoveredEvalConfig[];
5
+
6
+ ```
7
+
8
+ Discover the per-agent `evals.config.ts` (from [defineEvalConfig](./docs/api/appkit/Function.defineEvalConfig.md)) at `<rootDir>/server/agents/<agent>/evals/evals.config.ts`. Config is per-agent: each agent's config applies only to that agent's evals. Agents without a config file are omitted. Returns a stable, sorted list.
9
+
10
+ ## Parameters[​](#parameters "Direct link to Parameters")
11
+
12
+ | Parameter | Type |
13
+ | --------- | -------- |
14
+ | `rootDir` | `string` |
15
+
16
+ ## Returns[​](#returns "Direct link to Returns")
17
+
18
+ [`DiscoveredEvalConfig`](./docs/api/appkit/Interface.DiscoveredEvalConfig.md)\[]
@@ -0,0 +1,18 @@
1
+ # Function: formatResultsJUnit()
2
+
3
+ ```ts
4
+ function formatResultsJUnit(results: EvalResult[]): string;
5
+
6
+ ```
7
+
8
+ Render results as JUnit XML for standard CI test reporters: a single `<testsuite name="appkit-agent-evals">` with one `<testcase>` per result. Failures carry a `<failure>` (error or failing-gate summary); skips a `<skipped>`. All attribute/text values are XML-escaped.
9
+
10
+ ## Parameters[​](#parameters "Direct link to Parameters")
11
+
12
+ | Parameter | Type |
13
+ | --------- | ------------------------------------------------------------------ |
14
+ | `results` | [`EvalResult`](./docs/api/appkit/Interface.EvalResult.md)\[] |
15
+
16
+ ## Returns[​](#returns "Direct link to Returns")
17
+
18
+ `string`
@@ -0,0 +1,18 @@
1
+ # Function: formatResultsJson()
2
+
3
+ ```ts
4
+ function formatResultsJson(results: EvalResult[]): string;
5
+
6
+ ```
7
+
8
+ Render results as a machine-readable JSON report (2-space indented): `{ summary: EvalSummary, results: EvalResult[] }`. Faithful to the types — every field present on a result round-trips.
9
+
10
+ ## Parameters[​](#parameters "Direct link to Parameters")
11
+
12
+ | Parameter | Type |
13
+ | --------- | ------------------------------------------------------------------ |
14
+ | `results` | [`EvalResult`](./docs/api/appkit/Interface.EvalResult.md)\[] |
15
+
16
+ ## Returns[​](#returns "Direct link to Returns")
17
+
18
+ `string`
@@ -0,0 +1,28 @@
1
+ # Function: runWithRetries()
2
+
3
+ ```ts
4
+ function runWithRetries(
5
+ retries: number,
6
+ attempt: (attemptNumber: number) => Promise<EvalResult>,
7
+ options: {
8
+ baseDelayMs?: number;
9
+ }): Promise<EvalResult>;
10
+
11
+ ```
12
+
13
+ Run `attempt` up to `1 + retries` times, stopping as soon as it returns a result that is neither a thrown error / per-eval timeout (`error`) nor a transport/agent turn failure (`infraFailure`). Assertion failures set neither, so a failed-but-completed eval is returned on the first try and never retried. Returns the last result when every attempt failed on infra.
14
+
15
+ Between attempts it waits a full-jittered exponential backoff (infra flakes are overload-correlated). `retries` is coerced to a finite non-negative integer; `baseDelayMs: 0` disables the wait (tests).
16
+
17
+ ## Parameters[​](#parameters "Direct link to Parameters")
18
+
19
+ | Parameter | Type |
20
+ | ---------------------- | --------------------------------------------------------------------------------------------------------- |
21
+ | `retries` | `number` |
22
+ | `attempt` | (`attemptNumber`: `number`) => `Promise`<[`EvalResult`](./docs/api/appkit/Interface.EvalResult.md)> |
23
+ | `options` | { `baseDelayMs?`: `number`; } |
24
+ | `options.baseDelayMs?` | `number` |
25
+
26
+ ## Returns[​](#returns "Direct link to Returns")
27
+
28
+ `Promise`<[`EvalResult`](./docs/api/appkit/Interface.EvalResult.md)>
@@ -0,0 +1,20 @@
1
+ # Function: userTurns()
2
+
3
+ ```ts
4
+ function userTurns(input: Record<string, unknown>): string[];
5
+
6
+ ```
7
+
8
+ Extract every user-message content, in order, from an MLflow `{"messages":[{"role":"user","content":"..."}]}` input. A dataset row can carry a full multi-turn conversation; replaying these against one thread (one `t.send` per returned string) lets the agent see the accumulating history.
9
+
10
+ Only `role === "user"` turns are returned — any interleaved `assistant`/ `system` messages in the row are ignored, since the agent generates its own responses; you never inject the dataset's assistant turns. A single-user-turn row yields a one-element array (backward compatible); a row with no `messages` yields `[]`.
11
+
12
+ ## Parameters[​](#parameters "Direct link to Parameters")
13
+
14
+ | Parameter | Type |
15
+ | --------- | ----------------------------- |
16
+ | `input` | `Record`<`string`, `unknown`> |
17
+
18
+ ## Returns[​](#returns "Direct link to Returns")
19
+
20
+ `string`\[]
@@ -0,0 +1,25 @@
1
+ # Interface: DiscoveredEvalConfig
2
+
3
+ A per-agent `evals.config.ts` found under `server/agents/<agent>/evals/`.
4
+
5
+ ## Properties[​](#properties "Direct link to Properties")
6
+
7
+ ### agent[​](#agent "Direct link to agent")
8
+
9
+ ```ts
10
+ agent: string;
11
+
12
+ ```
13
+
14
+ The agent id whose evals this config applies to.
15
+
16
+ ***
17
+
18
+ ### file[​](#file "Direct link to file")
19
+
20
+ ```ts
21
+ file: string;
22
+
23
+ ```
24
+
25
+ Absolute path to the `evals.config.ts` file.
@@ -37,6 +37,34 @@ Whether the turn completed without an agent/stream error.
37
37
 
38
38
  ***
39
39
 
40
+ ### toolCallDetails[​](#toolcalldetails "Direct link to toolCallDetails")
41
+
42
+ ```ts
43
+ toolCallDetails: {
44
+ args: Record<string, unknown>;
45
+ name: string;
46
+ }[];
47
+
48
+ ```
49
+
50
+ Tool calls with their parsed arguments, in call order.
51
+
52
+ #### args[​](#args "Direct link to args")
53
+
54
+ ```ts
55
+ args: Record<string, unknown>;
56
+
57
+ ```
58
+
59
+ #### name[​](#name "Direct link to name")
60
+
61
+ ```ts
62
+ name: string;
63
+
64
+ ```
65
+
66
+ ***
67
+
40
68
  ### toolCalls[​](#toolcalls "Direct link to toolCalls")
41
69
 
42
70
  ```ts
@@ -52,6 +52,28 @@ optional description: string;
52
52
 
53
53
  Short human description, shown in reports.
54
54
 
55
+ ***
56
+
57
+ ### tags?[​](#tags "Direct link to tags?")
58
+
59
+ ```ts
60
+ optional tags: string[];
61
+
62
+ ```
63
+
64
+ Free-form tags for filtering (see the runner's `tags` / `--tag` option).
65
+
66
+ ***
67
+
68
+ ### timeoutMs?[​](#timeoutms "Direct link to timeoutMs?")
69
+
70
+ ```ts
71
+ optional timeoutMs: number;
72
+
73
+ ```
74
+
75
+ Per-eval timeout (ms): `runEval` races the test against it and records a non-passing result instead of hanging. Overrides the runner/CLI default.
76
+
55
77
  ## Methods[​](#methods "Direct link to Methods")
56
78
 
57
79
  ### test()[​](#test "Direct link to test()")
@@ -22,15 +22,21 @@ Drop the current conversation so the next `send` starts a fresh thread. Optional
22
22
  ### send()[​](#send "Direct link to send()")
23
23
 
24
24
  ```ts
25
- send(message: string): Promise<DriveResult>;
25
+ send(message: string, options?: {
26
+ signal?: AbortSignal;
27
+ }): Promise<DriveResult>;
26
28
 
27
29
  ```
28
30
 
31
+ Drive one turn. `options.signal`, when provided, aborts the in-flight turn: the runner passes its per-eval timeout signal so a timed-out eval cancels the request instead of leaking a live stream.
32
+
29
33
  #### Parameters[​](#parameters "Direct link to Parameters")
30
34
 
31
- | Parameter | Type |
32
- | --------- | -------- |
33
- | `message` | `string` |
35
+ | Parameter | Type |
36
+ | ----------------- | ----------------------------- |
37
+ | `message` | `string` |
38
+ | `options?` | { `signal?`: `AbortSignal`; } |
39
+ | `options.signal?` | `AbortSignal` |
34
40
 
35
41
  #### Returns[​](#returns-1 "Direct link to Returns")
36
42
 
@@ -42,6 +42,17 @@ id: string;
42
42
 
43
43
  ***
44
44
 
45
+ ### infraFailure?[​](#infrafailure "Direct link to infraFailure?")
46
+
47
+ ```ts
48
+ optional infraFailure: boolean;
49
+
50
+ ```
51
+
52
+ A turn failed at the transport/agent level (`succeeded: false`), not on an assertion — a retryable infra flake, distinct from `error`.
53
+
54
+ ***
55
+
45
56
  ### passed[​](#passed "Direct link to passed")
46
57
 
47
58
  ```ts
@@ -31,6 +31,17 @@ passed: number;
31
31
 
32
32
  ***
33
33
 
34
+ ### passRate[​](#passrate "Direct link to passRate")
35
+
36
+ ```ts
37
+ passRate: number;
38
+
39
+ ```
40
+
41
+ Fraction of scored (non-skipped) evals that passed, 0..1 (1 when none scored).
42
+
43
+ ***
44
+
34
45
  ### skipped[​](#skipped "Direct link to skipped")
35
46
 
36
47
  ```ts
@@ -43,3 +43,14 @@ optional strict: boolean;
43
43
  ```
44
44
 
45
45
  When true, soft assertion failures also fail the eval.
46
+
47
+ ***
48
+
49
+ ### timeoutMs?[​](#timeoutms "Direct link to timeoutMs?")
50
+
51
+ ```ts
52
+ optional timeoutMs: number;
53
+
54
+ ```
55
+
56
+ Runner-level default per-eval timeout (ms). `def.timeoutMs` wins over this; when both are unset the eval runs unbounded (current behavior).
@@ -160,6 +160,17 @@ Progress callback, invoked as evals are discovered, started, and finished.
160
160
 
161
161
  ***
162
162
 
163
+ ### retries?[​](#retries "Direct link to retries?")
164
+
165
+ ```ts
166
+ optional retries: number;
167
+
168
+ ```
169
+
170
+ Re-run an eval up to this many extra times when it fails on infrastructure — a thrown error/timeout (`result.error`) or a transport/agent turn failure (`result.infraFailure`). Assertion failures are never retried. Defaults to `0`.
171
+
172
+ ***
173
+
163
174
  ### rootDir?[​](#rootdir "Direct link to rootDir?")
164
175
 
165
176
  ```ts
@@ -182,6 +193,17 @@ Soft assertion failures also fail the eval.
182
193
 
183
194
  ***
184
195
 
196
+ ### tags?[​](#tags "Direct link to tags?")
197
+
198
+ ```ts
199
+ optional tags: string[];
200
+
201
+ ```
202
+
203
+ Only run evals whose `tags` intersect this list. Empty/undefined runs all. Tags live on the eval def, so filtering happens after each file is loaded.
204
+
205
+ ***
206
+
185
207
  ### timeoutMs?[​](#timeoutms "Direct link to timeoutMs?")
186
208
 
187
209
  ```ts
@@ -189,7 +211,7 @@ optional timeoutMs: number;
189
211
 
190
212
  ```
191
213
 
192
- Per-turn wall-clock timeout (ms) before a turn is failed. Defaults to 120s.
214
+ Default per-eval timeout (ms): `runEval` races the whole test against it and it also caps each driver turn. A per-eval `def.timeoutMs` overrides it, and it wins over an agent's `evals.config.ts` `timeoutMs`. Unbounded when unset.
193
215
 
194
216
  ***
195
217