@agentproto/eval 0.2.11 → 0.3.1
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/README.md +53 -0
- package/dist/index.d.ts +295 -1
- package/dist/index.mjs +545 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/score.ts","../src/json.ts","../src/scorers.ts","../src/judge.ts","../src/events.ts","../src/run-eval.ts","../src/to-vitest.ts","../src/index.ts"],"names":["z","defineTool","implementTool","defineDriver"],"mappings":";;;;;;;;;;AAUO,IAAM,WAAA,GAAc,EAAE,MAAA,CAAO;AAAA;AAAA,EAElC,KAAA,EAAO,EAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA,CAAE,IAAI,CAAC,CAAA;AAAA;AAAA,EAE9B,MAAA,EAAQ,EAAE,OAAA,EAAQ;AAAA;AAAA,EAElB,KAAA,EAAO,EAAE,MAAA,EAAO;AAAA;AAAA,EAEhB,SAAA,EAAW,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AACxB,CAAC;ACEM,IAAM,kBAAwCA,CAAAA,CAAE,IAAA;AAAA,EAAK,MAC1DA,EAAE,KAAA,CAAM;AAAA,IACNA,EAAE,MAAA,EAAO;AAAA,IACTA,EAAE,MAAA,EAAO;AAAA,IACTA,EAAE,OAAA,EAAQ;AAAA,IACVA,EAAE,IAAA,EAAK;AAAA,IACPA,CAAAA,CAAE,MAAM,eAAe,CAAA;AAAA,IACvBA,CAAAA,CAAE,MAAA,CAAOA,CAAAA,CAAE,MAAA,IAAU,eAAe;AAAA,GACrC;AACH;;;AClBO,IAAM,iBAAiB,UAAA,CAAW;AAAA,EACvC,EAAA,EAAI,kBAAA;AAAA,EACJ,WAAA,EACE,6HAAA;AAAA,EAEF,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EAAaA,EAAE,MAAA,CAAO;AAAA,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is an AIP-14 TOOL whose `outputSchema` is exactly this — there is\n * no separate \"scorer port\". Reusing `Score` as the tool output means the\n * registry, retries, and `toMastraTool` / `toAiSdkTool` projections all apply\n * to scorers for free, identical to any other builtin tool.\n */\nexport const scoreSchema = z.object({\n /** Normalized score in [0, 1]. */\n value: z.number().min(0).max(1),\n /** Whether the score clears the scorer's own threshold. */\n passed: z.boolean(),\n /** Scorer id, e.g. \"exact-match\". */\n label: z.string(),\n /** Human-readable explanation of the outcome. */\n rationale: z.string().optional(),\n})\n\nexport type Score = z.infer<typeof scoreSchema>\n","import { z } from \"zod\"\n\n/**\n * Recursive JSON value union. Modelling the JSON payload explicitly (rather\n * than reaching for `any` / `unknown`) lets consumers inspect values with\n * proper narrowing and no casts. This is the ONE canonical `JsonValue` for the\n * package — scorers, the eval harness, and the vitest bridge all import it from\n * here so there is no divergent redeclaration.\n */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue }\n\n/** A plain JSON object (not `null`, not an array). */\nexport type JsonObject = { [key: string]: JsonValue }\n\n/** Zod schema mirroring {@link JsonValue}. */\nexport const jsonValueSchema: z.ZodType<JsonValue> = z.lazy(() =>\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(jsonValueSchema),\n z.record(z.string(), jsonValueSchema),\n ]),\n)\n","import { z } from \"zod\"\nimport { defineTool } from \"@agentproto/tool\"\nimport { implementTool } from \"@agentproto/driver\"\nimport { scoreSchema } from \"./score.js\"\nimport { jsonValueSchema, type JsonObject, type JsonValue } from \"./json.js\"\n\nexport type { JsonValue } from \"./json.js\"\n\n// ---------------------------------------------------------------------------\n// eval.exact-match\n// ---------------------------------------------------------------------------\n\nexport const exactMatchTool = defineTool({\n id: \"eval.exact-match\",\n description:\n \"Deterministic scorer: value 1 when `actual` equals `expected` \" +\n \"(optionally after trimming whitespace on both sides), else 0.\",\n version: \"0.1.0\",\n inputSchema: z.object({\n actual: z.string().describe(\"The produced string to score.\"),\n expected: z.string().describe(\"The reference string to compare against.\"),\n trim: z\n .boolean()\n .optional()\n .describe(\"Trim leading/trailing whitespace on both sides before comparing.\"),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\nexport const exactMatchImpl = implementTool(exactMatchTool, ({ input }) => {\n const a = input.trim ? input.actual.trim() : input.actual\n const b = input.trim ? input.expected.trim() : input.expected\n const equal = a === b\n return {\n value: equal ? 1 : 0,\n passed: equal,\n label: \"exact-match\",\n rationale: equal\n ? \"actual equals expected\"\n : \"actual does not equal expected\",\n }\n})\n\n// ---------------------------------------------------------------------------\n// eval.regex-match\n// ---------------------------------------------------------------------------\n\nexport const regexMatchTool = defineTool({\n id: \"eval.regex-match\",\n description:\n \"Deterministic scorer: value 1 when `actual` matches the RegExp built \" +\n \"from `pattern`/`flags`, else 0. An invalid pattern yields a typed \" +\n \"failure Score rather than a thrown error.\",\n version: \"0.1.0\",\n inputSchema: z.object({\n actual: z.string().describe(\"The produced string to test.\"),\n pattern: z.string().describe(\"RegExp source, compiled inside the body.\"),\n flags: z\n .string()\n .optional()\n .describe(\"RegExp flags, e.g. 'i', 'm', 'gimsuy'.\"),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\nexport const regexMatchImpl = implementTool(regexMatchTool, ({ input }) => {\n let regex: RegExp\n try {\n regex = new RegExp(input.pattern, input.flags)\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err)\n return {\n value: 0,\n passed: false,\n label: \"regex-match\",\n rationale: `invalid pattern: ${reason}`,\n }\n }\n const matched = regex.test(input.actual)\n return {\n value: matched ? 1 : 0,\n passed: matched,\n label: \"regex-match\",\n rationale: matched\n ? `actual matches /${input.pattern}/${input.flags ?? \"\"}`\n : `actual does not match /${input.pattern}/${input.flags ?? \"\"}`,\n }\n})\n\n// ---------------------------------------------------------------------------\n// eval.json-schema-valid\n// ---------------------------------------------------------------------------\n\n/**\n * A deliberately minimal, dependency-free JSON-schema shape.\n *\n * LIMITATION: this scorer checks ONLY the two most common structural\n * constraints on a top-level object — that every name in `required` is\n * present, and that any name in `properties` declaring a `type` has a value\n * of that primitive type. It does NOT recurse into nested schemas, and does\n * not implement the rest of JSON Schema (enum, format, oneOf, items, …). A\n * full validator (e.g. ajv) is a later step; keeping this package light is\n * the point.\n */\nexport interface MinimalJsonSchema {\n readonly type?: string\n readonly required?: readonly string[]\n readonly properties?: {\n readonly [key: string]: { readonly type?: string }\n }\n}\n\nconst minimalJsonSchemaSchema: z.ZodType<MinimalJsonSchema> = z.object({\n type: z.string().optional(),\n required: z.array(z.string()).optional(),\n properties: z\n .record(z.string(), z.object({ type: z.string().optional() }))\n .optional(),\n})\n\n/** Narrows a JSON value to a plain JSON object (not null, not an array). */\nfunction isJsonObject(value: JsonValue): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\n/** The JSON Schema primitive-type name for a runtime JSON value. */\nfunction jsonTypeOf(value: JsonValue): string {\n if (value === null) return \"null\"\n if (Array.isArray(value)) return \"array\"\n if (typeof value === \"number\") return \"number\"\n if (typeof value === \"boolean\") return \"boolean\"\n if (typeof value === \"string\") return \"string\"\n return \"object\"\n}\n\nexport const jsonSchemaValidTool = defineTool({\n id: \"eval.json-schema-valid\",\n description:\n \"Deterministic scorer: minimal structural check of a JSON value against \" +\n \"a schema's top-level `required` and `properties` type constraints only. \" +\n \"Not a full JSON Schema validator (no recursion, enum, format, …).\",\n version: \"0.1.0\",\n inputSchema: z.object({\n actual: jsonValueSchema.describe(\"The JSON value to validate.\"),\n schema: minimalJsonSchemaSchema.describe(\n \"Minimal JSON schema: top-level `required` and `properties.type` only.\",\n ),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\nexport const jsonSchemaValidImpl = implementTool(\n jsonSchemaValidTool,\n ({ input }) => {\n const { actual, schema } = input\n const violation = firstSchemaViolation(actual, schema)\n const valid = violation === undefined\n return {\n value: valid ? 1 : 0,\n passed: valid,\n label: \"json-schema-valid\",\n rationale: valid ? \"value satisfies the schema\" : violation,\n }\n },\n)\n\n/** Returns the first violation message, or undefined when the value is valid. */\nfunction firstSchemaViolation(\n actual: JsonValue,\n schema: MinimalJsonSchema,\n): string | undefined {\n const declaredType = schema.type ?? \"object\"\n const actualType = jsonTypeOf(actual)\n if (declaredType !== actualType) {\n return `expected top-level type '${declaredType}' but got '${actualType}'`\n }\n\n // Only object payloads carry required/properties semantics here.\n if (!isJsonObject(actual)) {\n return undefined\n }\n\n for (const key of schema.required ?? []) {\n if (!(key in actual)) {\n return `missing required property '${key}'`\n }\n }\n\n for (const [key, propSchema] of Object.entries(schema.properties ?? {})) {\n if (propSchema.type === undefined) continue\n const propValue = actual[key]\n if (propValue === undefined) continue\n const propType = jsonTypeOf(propValue)\n if (propType !== propSchema.type) {\n return `property '${key}' expected type '${propSchema.type}' but got '${propType}'`\n }\n }\n\n return undefined\n}\n\n// ---------------------------------------------------------------------------\n// eval.latency-budget\n// ---------------------------------------------------------------------------\n\nexport const latencyBudgetTool = defineTool({\n id: \"eval.latency-budget\",\n description:\n \"Deterministic scorer: passes when `durationMs` is within `budgetMs`. \" +\n \"value is 1 when within budget, else linearly decays toward 0 as the \" +\n \"overrun approaches one full budget.\",\n version: \"0.1.0\",\n inputSchema: z.object({\n durationMs: z\n .number()\n .min(0)\n .describe(\"Observed duration in milliseconds.\"),\n budgetMs: z\n .number()\n .positive()\n .describe(\"Allowed budget in milliseconds (must be > 0).\"),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\nexport const latencyBudgetImpl = implementTool(latencyBudgetTool, ({ input }) => {\n const { durationMs, budgetMs } = input\n const passed = durationMs <= budgetMs\n const value = passed\n ? 1\n : Math.max(0, 1 - (durationMs - budgetMs) / budgetMs)\n return {\n value,\n passed,\n label: \"latency-budget\",\n rationale: `durationMs=${durationMs}, budgetMs=${budgetMs}`,\n }\n})\n","import { z } from \"zod\"\nimport { defineTool } from \"@agentproto/tool\"\nimport { defineDriver, implementTool, type DriverHandle } from \"@agentproto/driver\"\nimport { scoreSchema } from \"./score.js\"\nimport { jsonValueSchema, type JsonValue } from \"./json.js\"\nimport type { ScorerBinding } from \"./run-eval.js\"\n\n/**\n * `llmJudge` — a model-backed scorer.\n *\n * Design (locked): a model-backed scorer stays a TOOL, exactly like the\n * deterministic scorers in `scorers.ts`. What differs is where the model\n * lives: the injected {@link JudgeFn} is closed over by the DRIVER (built by\n * {@link makeLlmJudgeDriver}), never threaded through tool input/context. That\n * keeps `eval.llm-judge`'s contract identical in shape to every other scorer\n * tool, so it composes with the existing `bindScorer` / `runEval` in\n * run-eval.ts with ZERO changes there.\n *\n * The judge itself is vendor-neutral: {@link JudgeFn} is just an injected\n * async function. This file has no LLM SDK and no network dependency — a real\n * adapter (an agent session, a supervisor judge-gate, …) is a documented\n * follow-up, not built here.\n */\n\n// ---------------------------------------------------------------------------\n// JudgeVerdict — what an injected judge returns\n// ---------------------------------------------------------------------------\n\n/** Zod schema for the raw verdict a {@link JudgeFn} produces. */\nexport const judgeVerdictSchema = z.object({\n /** Normalized judge score in [0, 1]. */\n value: z.number().min(0).max(1),\n /**\n * Explicit pass/fail from the judge. When present it WINS over the\n * threshold comparison — see {@link makeLlmJudgeDriver}.\n */\n passed: z.boolean().optional(),\n /** Human-readable explanation of the verdict. */\n rationale: z.string().optional(),\n})\n\nexport type JudgeVerdict = z.infer<typeof judgeVerdictSchema>\n\n// ---------------------------------------------------------------------------\n// JudgeFn — the injected capability\n// ---------------------------------------------------------------------------\n\n/**\n * The seam a real judge satisfies: given the produced `output`, free-form\n * grading `criteria`, and an optional `expected` reference, return a\n * {@link JudgeVerdict}. Callers supply this — a real LLM call, an agent\n * session, or the supervisor's judge-gate all satisfy the same shape.\n * Deliberately no LLM SDK / network types here: keeping this package\n * vendor-neutral is the point.\n */\nexport type JudgeFn = (args: {\n readonly output: JsonValue\n readonly criteria: string\n readonly expected?: JsonValue\n}) => Promise<JudgeVerdict>\n\n// ---------------------------------------------------------------------------\n// eval.llm-judge — the TOOL contract\n// ---------------------------------------------------------------------------\n\n/** Tool input for `eval.llm-judge`. */\nexport interface LlmJudgeInput {\n readonly output: JsonValue\n readonly criteria: string\n readonly expected?: JsonValue\n}\n\nexport const llmJudgeTool = defineTool({\n id: \"eval.llm-judge\",\n description:\n \"Model-backed scorer: hands `output` (plus free-form `criteria` and an \" +\n \"optional `expected` reference) to an injected judge and normalizes the \" +\n \"judge's verdict into the shared Score shape. The judge itself lives in \" +\n \"the driver (see makeLlmJudgeDriver) — this tool contract carries no \" +\n \"model call of its own.\",\n version: \"0.1.0\",\n inputSchema: z.object({\n output: jsonValueSchema.describe(\"The produced value to judge.\"),\n criteria: z.string().describe(\"Free-form grading criteria/rubric for the judge.\"),\n expected: jsonValueSchema\n .optional()\n .describe(\"Optional reference value the judge may compare against.\"),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\n// ---------------------------------------------------------------------------\n// makeLlmJudgeDriver — closes over the injected JudgeFn\n// ---------------------------------------------------------------------------\n\n/** Clamp a number into [0, 1]. */\nfunction clamp01(x: number): number {\n return Math.min(1, Math.max(0, x))\n}\n\nexport interface MakeLlmJudgeDriverOptions {\n /** Minimum `value` to count as passed when the judge omits `passed`. Default 0.5. */\n readonly threshold?: number\n}\n\n/**\n * Build a DRIVER that implements `eval.llm-judge` by delegating to `judge`.\n * This is the one seam where the injected model-backed capability enters the\n * system — everything downstream (`bindScorer`, `runEval`) stays unaware that\n * this scorer is model-backed at all.\n */\nexport function makeLlmJudgeDriver(\n judge: JudgeFn,\n opts?: MakeLlmJudgeDriverOptions,\n): DriverHandle {\n const threshold = opts?.threshold ?? 0.5\n return defineDriver({\n id: \"eval-llm-judge\",\n name: \"Eval LLM Judge (model-backed)\",\n description:\n \"Model-backed scorer driver: implements eval.llm-judge by awaiting an \" +\n \"injected JudgeFn and mapping its verdict to the shared Score shape. \" +\n \"The judge is supplied by the caller — no LLM SDK or network call here.\",\n version: \"0.1.0\",\n kind: \"builtin\",\n implements: [{ tool: \"eval.llm-judge\", version: \"0.1.0\" }],\n implementations: [\n implementTool(llmJudgeTool, async ({ input }) => {\n const verdict = await judge({\n output: input.output,\n criteria: input.criteria,\n expected: input.expected,\n })\n const value = clamp01(verdict.value)\n const passed = verdict.passed ?? value >= threshold\n return {\n value,\n passed,\n label: \"llm-judge\",\n ...(verdict.rationale ? { rationale: verdict.rationale } : {}),\n }\n }),\n ],\n })\n}\n\n// ---------------------------------------------------------------------------\n// llmJudge — convenience ScorerBinding factory\n// ---------------------------------------------------------------------------\n\nexport interface LlmJudgeBinding<A> {\n /** Label for this binding, e.g. \"helpfulness\". */\n readonly id: string\n /** The injected judge capability. */\n readonly judge: JudgeFn\n /** Free-form grading criteria/rubric handed to the judge on every call. */\n readonly criteria: string\n /** Minimum value to count as passed when the judge omits `passed`. Default 0.5. */\n readonly threshold?: number\n /** Derive the judge's `output` input from the target's output. */\n readonly mapOutput: (ctx: { output: A; expected?: JsonValue }) => JsonValue\n}\n\n/**\n * Convenience: build a {@link ScorerBinding} ready to drop into a suite's\n * `scorers` via `bindScorer` — wires up `eval.llm-judge`, a driver built with\n * {@link makeLlmJudgeDriver}, and the input mapping in one call.\n */\nexport function llmJudge<A>(binding: LlmJudgeBinding<A>): ScorerBinding<A, LlmJudgeInput> {\n const driver = makeLlmJudgeDriver(binding.judge, { threshold: binding.threshold })\n return {\n id: binding.id,\n tool: llmJudgeTool,\n driver,\n mapInput: (ctx) => ({\n output: binding.mapOutput({ output: ctx.output, expected: ctx.expected }),\n criteria: binding.criteria,\n expected: ctx.expected,\n }),\n }\n}\n","/**\n * Structured events emitted while an eval suite runs.\n *\n * The union mirrors the shape of `@agentproto/telemetry`'s `TelemetryEvent`:\n * a discriminated union keyed on `kind`, every member carrying a correlation\n * id (`runId`) and an ISO `at` timestamp so a sink can rebuild a per-run span\n * tree. It rides the same {@link Telemetry} port — a `runEval` call takes a\n * `Telemetry<EvalEvent>` sink.\n *\n * Sinks MUST tolerate unknown kinds — future versions may add event types\n * under the same `agentproto/eval/v1` schema (identical forward-compat\n * contract as the telemetry port).\n */\n\n/** Schema identifier for this event family. */\nexport const EVAL_EVENT_SCHEMA = \"agentproto/eval/v1\" as const\n\nexport type EvalEvent =\n | {\n readonly kind: \"eval.started\"\n readonly runId: string\n readonly at: string\n readonly suiteId: string\n readonly caseCount: number\n readonly scorerCount: number\n }\n | {\n readonly kind: \"eval.case.started\"\n readonly runId: string\n readonly at: string\n readonly caseId: string\n }\n | {\n readonly kind: \"eval.case.scored\"\n readonly runId: string\n readonly at: string\n readonly caseId: string\n readonly scorerId: string\n readonly value: number\n readonly passed: boolean\n }\n | {\n readonly kind: \"eval.case.finished\"\n readonly runId: string\n readonly at: string\n readonly caseId: string\n /** True when EVERY scorer bound to the case passed. */\n readonly passed: boolean\n }\n | {\n readonly kind: \"eval.finished\"\n readonly runId: string\n readonly at: string\n readonly suiteId: string\n readonly total: number\n readonly passedCount: number\n readonly meanValue: number\n readonly durationMs: number\n }\n","/**\n * `runEval` — the eval harness.\n *\n * The thesis this file proves: **an eval is a workflow that runs a target then\n * scores its output with scorer-tools, reporting through the telemetry port.**\n *\n * For each case we build a {@link RuntimeWorkflow} that composes\n * target → one scorer `tool` step per binding → a per-case aggregate transform\n * and execute it with `runWorkflow` (AIP-15). The target's structured output is\n * the input selector for every scorer step — that is where composable tool I/O\n * is demonstrated. `runEval` then aggregates across cases and emits\n * {@link EvalEvent}s through an injected `Telemetry<EvalEvent>` sink.\n *\n * The `target` is a plain async function here (not required to be a tool); a\n * tool/agent target is a documented follow-up.\n */\n\nimport { runWorkflow, type RuntimeWorkflow } from \"@agentproto/workflow-runtime\"\nimport type { Telemetry } from \"@agentproto/telemetry\"\nimport type { DriverHandle } from \"@agentproto/driver\"\nimport type { ToolHandle } from \"@agentproto/tool\"\nimport type { Score } from \"./score.js\"\nimport type { JsonValue } from \"./json.js\"\nimport type { EvalEvent } from \"./events.js\"\n\n/** One case: an input for the target and an optional expected reference. */\nexport interface EvalCase<I> {\n readonly id: string\n readonly input: I\n /** Optional reference value, modelled as JSON (never `unknown`/`any`). */\n readonly expected?: JsonValue\n}\n\n/** Context handed to a binding's `mapInput` when scoring one case's output. */\nexport interface ScorerInputContext<A> {\n readonly output: A\n readonly expected?: JsonValue\n}\n\n/**\n * One scorer applied to the target output. Generic over the target output type\n * `A` and the scorer's own input type `S` (captured when the binding is\n * authored). {@link bindScorer} erases `S` so heterogeneous scorers coexist in\n * one `EvalSuite.scorers` array without an `any`.\n */\nexport interface ScorerBinding<A, S = JsonValue> {\n /** Label for this binding, e.g. \"exact\". */\n readonly id: string\n /** The scorer TOOL contract — its `outputSchema` is the shared {@link Score}. */\n readonly tool: ToolHandle<S, Score>\n /** The DRIVER that implements the scorer tool. */\n readonly driver: DriverHandle\n /** Derive the scorer's input from the target's output (+ optional expected). */\n readonly mapInput: (ctx: ScorerInputContext<A>) => S\n}\n\n/**\n * The uniform, `S`-erased view of a binding stored in a suite. It exposes the\n * authored `id` plus a closure that runs the scorer for a given case output —\n * the existential box that lets a suite hold scorers with different input\n * types with no `any` at the collection boundary.\n */\nexport interface BoundScorer<A> {\n readonly id: string\n /** Build the AIP-15 tool step that scores one case's output. */\n toStep(stepId: string, output: A, expected?: JsonValue): RuntimeWorkflow[\"steps\"][number]\n}\n\n/**\n * Box a typed {@link ScorerBinding} into a {@link BoundScorer}, capturing the\n * scorer input type `S` inside the closure so the outer type is `S`-free.\n */\nexport function bindScorer<A, S>(binding: ScorerBinding<A, S>): BoundScorer<A> {\n return {\n id: binding.id,\n toStep(stepId, output, expected) {\n return {\n kind: \"tool\",\n id: stepId,\n tool: binding.tool,\n candidates: [binding.driver],\n input: () => binding.mapInput({ output, expected }),\n }\n },\n }\n}\n\nexport interface EvalSuite<A> {\n readonly id: string\n readonly cases: readonly EvalCase<unknown>[]\n readonly scorers: readonly BoundScorer<A>[]\n}\n\n/** One scorer's outcome on one case. */\nexport interface CaseScore {\n readonly scorerId: string\n readonly score: Score\n}\n\n/** The per-case rollup carried in the final report. */\nexport interface CaseReport {\n readonly caseId: string\n readonly passed: boolean\n readonly scores: readonly CaseScore[]\n}\n\nexport interface EvalReport {\n readonly runId: string\n readonly suiteId: string\n readonly total: number\n readonly passedCount: number\n /** Mean of every scorer value across every case (0 when there are none). */\n readonly meanValue: number\n readonly cases: readonly CaseReport[]\n}\n\nexport interface RunEvalOptions<I, A> {\n /** Produce the target output for a case input. */\n readonly target: (input: I) => Promise<A>\n /** Sink for {@link EvalEvent}s. Defaults to a no-op. */\n readonly telemetry?: Telemetry<EvalEvent>\n /** Correlation id for this run. Defaults to a deterministic suite-based id. */\n readonly runId?: string\n}\n\n/** A suite whose cases share the target input type `I`. */\nexport interface TypedEvalSuite<I, A> extends EvalSuite<A> {\n readonly cases: readonly EvalCase<I>[]\n}\n\n/** Per-process counter so a default runId is deterministic within a process. */\nlet runCounter = 0\n\nfunction defaultRunId(suiteId: string): string {\n runCounter += 1\n return `${suiteId}#${runCounter}`\n}\n\n/** The per-case aggregate: which scorers ran and whether all passed. */\ninterface CaseAggregate {\n readonly scores: readonly CaseScore[]\n readonly passed: boolean\n}\n\n/** Narrow a step-binding value to a {@link Score} without a cast. */\nfunction asScore(value: unknown): Score {\n if (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"passed\" in value &&\n \"label\" in value\n ) {\n const v: unknown = value.value\n const passed: unknown = value.passed\n const label: unknown = value.label\n const rationale: unknown = \"rationale\" in value ? value.rationale : undefined\n if (\n typeof v === \"number\" &&\n typeof passed === \"boolean\" &&\n typeof label === \"string\" &&\n (rationale === undefined || typeof rationale === \"string\")\n ) {\n return { value: v, passed, label, rationale }\n }\n }\n throw new Error(\"scorer step did not produce a valid Score\")\n}\n\n/**\n * Run every case in the suite, scoring each with all bound scorers, and return\n * the aggregated {@link EvalReport}. Emits `eval.started` … `eval.finished`.\n */\nexport async function runEval<I, A>(\n suite: TypedEvalSuite<I, A>,\n opts: RunEvalOptions<I, A>,\n): Promise<EvalReport> {\n const telemetry = opts.telemetry\n const runId = opts.runId ?? defaultRunId(suite.id)\n const start = Date.now()\n\n telemetry?.emit({\n kind: \"eval.started\",\n runId,\n at: new Date().toISOString(),\n suiteId: suite.id,\n caseCount: suite.cases.length,\n scorerCount: suite.scorers.length,\n })\n\n const caseReports: CaseReport[] = []\n let valueSum = 0\n let valueCount = 0\n\n for (const evalCase of suite.cases) {\n telemetry?.emit({\n kind: \"eval.case.started\",\n runId,\n at: new Date().toISOString(),\n caseId: evalCase.id,\n })\n\n const aggregate = await runCase(suite, evalCase, opts.target)\n\n for (const cs of aggregate.scores) {\n valueSum += cs.score.value\n valueCount += 1\n telemetry?.emit({\n kind: \"eval.case.scored\",\n runId,\n at: new Date().toISOString(),\n caseId: evalCase.id,\n scorerId: cs.scorerId,\n value: cs.score.value,\n passed: cs.score.passed,\n })\n }\n\n telemetry?.emit({\n kind: \"eval.case.finished\",\n runId,\n at: new Date().toISOString(),\n caseId: evalCase.id,\n passed: aggregate.passed,\n })\n\n caseReports.push({\n caseId: evalCase.id,\n passed: aggregate.passed,\n scores: aggregate.scores,\n })\n }\n\n const passedCount = caseReports.filter((c) => c.passed).length\n const meanValue = valueCount === 0 ? 0 : valueSum / valueCount\n\n const report: EvalReport = {\n runId,\n suiteId: suite.id,\n total: suite.cases.length,\n passedCount,\n meanValue,\n cases: caseReports,\n }\n\n telemetry?.emit({\n kind: \"eval.finished\",\n runId,\n at: new Date().toISOString(),\n suiteId: suite.id,\n total: report.total,\n passedCount,\n meanValue,\n durationMs: Date.now() - start,\n })\n\n return report\n}\n\n/**\n * Build and run the per-case workflow: `target` → one scorer tool-step per\n * binding → an aggregate transform, then read the aggregate off the run output.\n */\nasync function runCase<I, A>(\n suite: EvalSuite<A>,\n evalCase: EvalCase<I>,\n target: (input: I) => Promise<A>,\n): Promise<CaseAggregate> {\n const output = await target(evalCase.input)\n const scorerStepIds = suite.scorers.map((_, i) => `score_${i}`)\n\n const workflow: RuntimeWorkflow = {\n id: `${suite.id}:${evalCase.id}`,\n steps: [\n ...suite.scorers.map((scorer, i) =>\n scorer.toStep(scorerStepIds[i]!, output, evalCase.expected),\n ),\n {\n kind: \"transform\",\n id: \"aggregate\",\n compute: (b): CaseAggregate => {\n const scores: CaseScore[] = suite.scorers.map((scorer, i) => ({\n scorerId: scorer.id,\n score: asScore(b.steps[scorerStepIds[i]!]),\n }))\n return { scores, passed: scores.every((s) => s.score.passed) }\n },\n },\n ],\n output: (b) => b.steps.aggregate,\n }\n\n const { output: runOutput } = await runWorkflow({ workflow })\n return toCaseAggregate(runOutput)\n}\n\n/** Narrow the workflow output to a {@link CaseAggregate} without a cast. */\nfunction toCaseAggregate(value: unknown): CaseAggregate {\n if (\n typeof value === \"object\" &&\n value !== null &&\n \"scores\" in value &&\n \"passed\" in value &&\n Array.isArray(value.scores) &&\n typeof value.passed === \"boolean\"\n ) {\n const scores = value.scores.map((entry: unknown) => {\n if (\n typeof entry === \"object\" &&\n entry !== null &&\n \"scorerId\" in entry &&\n \"score\" in entry &&\n typeof entry.scorerId === \"string\"\n ) {\n return { scorerId: entry.scorerId, score: asScore(entry.score) }\n }\n throw new Error(\"invalid CaseScore in aggregate\")\n })\n return { scores, passed: value.passed }\n }\n throw new Error(\"workflow did not produce a CaseAggregate\")\n}\n","/**\n * `toVitest` — turn an {@link TypedEvalSuite} into vitest test registrations.\n *\n * The vitest primitives (`describe` / `it` / `expect`) are INJECTED by the\n * host's own `import ... from \"vitest\"`, so THIS source carries no vitest\n * runtime dependency (nothing to bundle, nothing to version-pin). It registers\n * one `it(caseId)` per case that runs the case through {@link runEval} and\n * asserts every scorer passed — the same workflow the harness runs, wired as a\n * CI gate.\n */\n\nimport { runEval, type RunEvalOptions, type TypedEvalSuite } from \"./run-eval.js\"\n\n/** The subset of vitest's `expect` this bridge needs. */\nexport interface ExpectApi {\n (actual: unknown): {\n toBe(expected: unknown): void\n }\n}\n\n/** The subset of vitest's `describe`/`it` this bridge needs. */\nexport interface VitestHooks {\n describe(name: string, body: () => void): void\n it(name: string, body: () => Promise<void> | void): void\n expect: ExpectApi\n}\n\nexport type ToVitestOptions<I, A> = RunEvalOptions<I, A>\n\n/**\n * Register `describe(suite.id)` with one `it` per case. Each `it` runs the\n * single-case suite through {@link runEval} and asserts the case passed (all\n * scorers green). Failing scorers surface as a failing vitest assertion.\n */\nexport function toVitest<I, A>(\n suite: TypedEvalSuite<I, A>,\n opts: ToVitestOptions<I, A>,\n hooks: VitestHooks,\n): void {\n const { describe, it, expect } = hooks\n describe(suite.id, () => {\n for (const evalCase of suite.cases) {\n it(evalCase.id, async () => {\n const singleCaseSuite: TypedEvalSuite<I, A> = {\n id: `${suite.id}:${evalCase.id}`,\n cases: [evalCase],\n scorers: suite.scorers,\n }\n const report = await runEval(singleCaseSuite, opts)\n const caseReport = report.cases[0]\n expect(caseReport?.passed).toBe(true)\n })\n }\n })\n}\n","/**\n * @agentproto/eval — deterministic reference scorers.\n *\n * A scorer IS an AIP-14 TOOL whose `outputSchema` is the shared {@link Score}\n * shape; there is no separate \"scorer port\". Each scorer is authored with\n * `defineTool` + `implementTool` and bundled in a single builtin AIP-30\n * PROVIDER, exactly like every other builtin. Invoke one through the driver:\n *\n * ```ts\n * import { runTool } from \"@agentproto/driver\"\n * import { exactMatchTool, evalScorersProvider } from \"@agentproto/eval\"\n *\n * const score = await runTool({\n * tool: exactMatchTool,\n * candidates: [evalScorersProvider],\n * input: { actual: \"hello\", expected: \"hello\" },\n * })\n * // → { value: 1, passed: true, label: \"exact-match\", rationale: \"…\" }\n * ```\n *\n * Alongside the deterministic scorers, `eval.llm-judge` (see judge.ts) is a\n * model-backed scorer whose judge is an INJECTED function — the driver\n * closes over it via `makeLlmJudgeDriver(judge)`. This package still carries\n * no LLM SDK or network dependency of its own; a real adapter (agent\n * session, supervisor judge-gate, …) is a documented follow-up.\n *\n * Spec: https://agentproto.sh/docs/aip-14 (TOOL), /docs/aip-30 (PROVIDER)\n */\n\nimport { defineDriver } from \"@agentproto/driver\"\nimport {\n exactMatchTool,\n exactMatchImpl,\n regexMatchTool,\n regexMatchImpl,\n jsonSchemaValidTool,\n jsonSchemaValidImpl,\n latencyBudgetTool,\n latencyBudgetImpl,\n} from \"./scorers.js\"\n\nexport const SPEC_NAME = \"agenteval/v1\" as const\nexport const SPEC_VERSION = \"1.0.0-alpha\" as const\n\nexport { scoreSchema, type Score } from \"./score.js\"\n\nexport {\n type JsonValue,\n type JsonObject,\n jsonValueSchema,\n} from \"./json.js\"\n\nexport {\n exactMatchTool,\n exactMatchImpl,\n regexMatchTool,\n regexMatchImpl,\n jsonSchemaValidTool,\n jsonSchemaValidImpl,\n latencyBudgetTool,\n latencyBudgetImpl,\n type MinimalJsonSchema,\n} from \"./scorers.js\"\n\nexport {\n judgeVerdictSchema,\n llmJudgeTool,\n makeLlmJudgeDriver,\n llmJudge,\n type JudgeVerdict,\n type JudgeFn,\n type LlmJudgeInput,\n type MakeLlmJudgeDriverOptions,\n type LlmJudgeBinding,\n} from \"./judge.js\"\n\nexport { EVAL_EVENT_SCHEMA, type EvalEvent } from \"./events.js\"\n\nexport {\n runEval,\n bindScorer,\n type EvalCase,\n type ScorerBinding,\n type ScorerInputContext,\n type BoundScorer,\n type EvalSuite,\n type TypedEvalSuite,\n type CaseScore,\n type CaseReport,\n type EvalReport,\n type RunEvalOptions,\n} from \"./run-eval.js\"\n\nexport {\n toVitest,\n type VitestHooks,\n type ExpectApi,\n type ToVitestOptions,\n} from \"./to-vitest.js\"\n\n/**\n * Builtin AIP-30 PROVIDER bundling the four deterministic ref scorers.\n * `kind: \"builtin\"` — pure in-process functions, no subprocess / network hop.\n */\nexport const evalScorersProvider = defineDriver({\n id: \"eval-scorers\",\n name: \"Eval Reference Scorers (built-in)\",\n description:\n \"In-process deterministic scorers: exact-match, regex-match, \" +\n \"json-schema-valid (minimal structural check), and latency-budget. \" +\n \"Each is an AIP-14 TOOL whose output is the shared Score shape.\",\n version: \"0.1.0\",\n kind: \"builtin\",\n implements: [\n { tool: \"eval.exact-match\", version: \"0.1.0\" },\n { tool: \"eval.regex-match\", version: \"0.1.0\" },\n { tool: \"eval.json-schema-valid\", version: \"0.1.0\" },\n { tool: \"eval.latency-budget\", version: \"0.1.0\" },\n ],\n implementations: [\n exactMatchImpl,\n regexMatchImpl,\n jsonSchemaValidImpl,\n latencyBudgetImpl,\n ],\n})\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/score.ts","../src/json.ts","../src/scorers.ts","../src/judge.ts","../src/events.ts","../src/run-eval.ts","../src/to-vitest.ts","../src/style/text-stats.ts","../src/style/lexicon.ts","../src/style/verdict.ts","../src/style/pairwise.ts","../src/style/style-embedding.ts","../src/style/outline-fidelity.ts","../src/style/index.ts","../src/index.ts"],"names":["z","defineTool","implementTool","clamp01","defineDriver"],"mappings":";;;;;;;;;;AAUO,IAAM,WAAA,GAAc,EAAE,MAAA,CAAO;AAAA;AAAA,EAElC,KAAA,EAAO,EAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA,CAAE,IAAI,CAAC,CAAA;AAAA;AAAA,EAE9B,MAAA,EAAQ,EAAE,OAAA,EAAQ;AAAA;AAAA,EAElB,KAAA,EAAO,EAAE,MAAA,EAAO;AAAA;AAAA,EAEhB,SAAA,EAAW,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AACxB,CAAC;ACEM,IAAM,kBAAwCA,CAAAA,CAAE,IAAA;AAAA,EAAK,MAC1DA,EAAE,KAAA,CAAM;AAAA,IACNA,EAAE,MAAA,EAAO;AAAA,IACTA,EAAE,MAAA,EAAO;AAAA,IACTA,EAAE,OAAA,EAAQ;AAAA,IACVA,EAAE,IAAA,EAAK;AAAA,IACPA,CAAAA,CAAE,MAAM,eAAe,CAAA;AAAA,IACvBA,CAAAA,CAAE,MAAA,CAAOA,CAAAA,CAAE,MAAA,IAAU,eAAe;AAAA,G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IAAA,EAAM,+BAAA;AAAA,EACN,WAAA,EACE,yIAAA;AAAA,EAGF,OAAA,EAAS,OAAA;AAAA,EACT,IAAA,EAAM,SAAA;AAAA,EACN,UAAA,EAAY;AAAA,IACV,EAAE,IAAA,EAAM,iBAAA,EAAmB,OAAA,EAAS,OAAA,EAAQ;AAAA,IAC5C,EAAE,IAAA,EAAM,uBAAA,EAAyB,OAAA,EAAS,OAAA;AAAQ,GACpD;AAAA,EACA,eAAA,EAAiB,CAAC,aAAA,EAAe,kBAAkB;AACrD,CAAC;;;AC5CM,IAAM,SAAA,GAAY;AAClB,IAAM,YAAA,GAAe;AAgErB,IAAM,sBAAsBA,YAAAA,CAAa;AAAA,EAC9C,EAAA,EAAI,cAAA;AAAA,EACJ,IAAA,EAAM,mCAAA;AAAA,EACN,WAAA,EACE,8LAAA;AAAA,EAGF,OAAA,EAAS,OAAA;AAAA,EACT,IAAA,EAAM,SAAA;AAAA,EACN,UAAA,EAAY;AAAA,IACV,EAAE,IAAA,EAAM,kBAAA,EAAoB,OAAA,EAAS,OAAA,EAAQ;AAAA,IAC7C,EAAE,IAAA,EAAM,kBAAA,EAAoB,OAAA,EAAS,OAAA,EAAQ;AAAA,IAC7C,EAAE,IAAA,EAAM,wBAAA,EAA0B,OAAA,EAAS,OAAA,EAAQ;AAAA,IACnD,EAAE,IAAA,EAAM,qBAAA,EAAuB,OAAA,EAAS,OAAA;AAAQ,GAClD;AAAA,EACA,eAAA,EAAiB;AAAA,IACf,cAAA;AAAA,IACA,cAAA;AAAA,IACA,mBAAA;AAAA,IACA;AAAA;AAEJ,CAAC","file":"index.mjs","sourcesContent":["import { z } from \"zod\"\n\n/**\n * The shared output shape every scorer produces.\n *\n * A scorer is an AIP-14 TOOL whose `outputSchema` is exactly this — there is\n * no separate \"scorer port\". Reusing `Score` as the tool output means the\n * registry, retries, and `toMastraTool` / `toAiSdkTool` projections all apply\n * to scorers for free, identical to any other builtin tool.\n */\nexport const scoreSchema = z.object({\n /** Normalized score in [0, 1]. */\n value: z.number().min(0).max(1),\n /** Whether the score clears the scorer's own threshold. */\n passed: z.boolean(),\n /** Scorer id, e.g. \"exact-match\". */\n label: z.string(),\n /** Human-readable explanation of the outcome. */\n rationale: z.string().optional(),\n})\n\nexport type Score = z.infer<typeof scoreSchema>\n","import { z } from \"zod\"\n\n/**\n * Recursive JSON value union. Modelling the JSON payload explicitly (rather\n * than reaching for `any` / `unknown`) lets consumers inspect values with\n * proper narrowing and no casts. This is the ONE canonical `JsonValue` for the\n * package — scorers, the eval harness, and the vitest bridge all import it from\n * here so there is no divergent redeclaration.\n */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue }\n\n/** A plain JSON object (not `null`, not an array). */\nexport type JsonObject = { [key: string]: JsonValue }\n\n/** Zod schema mirroring {@link JsonValue}. */\nexport const jsonValueSchema: z.ZodType<JsonValue> = z.lazy(() =>\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(jsonValueSchema),\n z.record(z.string(), jsonValueSchema),\n ]),\n)\n","import { z } from \"zod\"\nimport { defineTool } from \"@agentproto/tool\"\nimport { implementTool } from \"@agentproto/driver\"\nimport { scoreSchema } from \"./score.js\"\nimport { jsonValueSchema, type JsonObject, type JsonValue } from \"./json.js\"\n\nexport type { JsonValue } from \"./json.js\"\n\n// ---------------------------------------------------------------------------\n// eval.exact-match\n// ---------------------------------------------------------------------------\n\nexport const exactMatchTool = defineTool({\n id: \"eval.exact-match\",\n description:\n \"Deterministic scorer: value 1 when `actual` equals `expected` \" +\n \"(optionally after trimming whitespace on both sides), else 0.\",\n version: \"0.1.0\",\n inputSchema: z.object({\n actual: z.string().describe(\"The produced string to score.\"),\n expected: z.string().describe(\"The reference string to compare against.\"),\n trim: z\n .boolean()\n .optional()\n .describe(\"Trim leading/trailing whitespace on both sides before comparing.\"),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\nexport const exactMatchImpl = implementTool(exactMatchTool, ({ input }) => {\n const a = input.trim ? input.actual.trim() : input.actual\n const b = input.trim ? input.expected.trim() : input.expected\n const equal = a === b\n return {\n value: equal ? 1 : 0,\n passed: equal,\n label: \"exact-match\",\n rationale: equal\n ? \"actual equals expected\"\n : \"actual does not equal expected\",\n }\n})\n\n// ---------------------------------------------------------------------------\n// eval.regex-match\n// ---------------------------------------------------------------------------\n\nexport const regexMatchTool = defineTool({\n id: \"eval.regex-match\",\n description:\n \"Deterministic scorer: value 1 when `actual` matches the RegExp built \" +\n \"from `pattern`/`flags`, else 0. An invalid pattern yields a typed \" +\n \"failure Score rather than a thrown error.\",\n version: \"0.1.0\",\n inputSchema: z.object({\n actual: z.string().describe(\"The produced string to test.\"),\n pattern: z.string().describe(\"RegExp source, compiled inside the body.\"),\n flags: z\n .string()\n .optional()\n .describe(\"RegExp flags, e.g. 'i', 'm', 'gimsuy'.\"),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\nexport const regexMatchImpl = implementTool(regexMatchTool, ({ input }) => {\n let regex: RegExp\n try {\n regex = new RegExp(input.pattern, input.flags)\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err)\n return {\n value: 0,\n passed: false,\n label: \"regex-match\",\n rationale: `invalid pattern: ${reason}`,\n }\n }\n const matched = regex.test(input.actual)\n return {\n value: matched ? 1 : 0,\n passed: matched,\n label: \"regex-match\",\n rationale: matched\n ? `actual matches /${input.pattern}/${input.flags ?? \"\"}`\n : `actual does not match /${input.pattern}/${input.flags ?? \"\"}`,\n }\n})\n\n// ---------------------------------------------------------------------------\n// eval.json-schema-valid\n// ---------------------------------------------------------------------------\n\n/**\n * A deliberately minimal, dependency-free JSON-schema shape.\n *\n * LIMITATION: this scorer checks ONLY the two most common structural\n * constraints on a top-level object — that every name in `required` is\n * present, and that any name in `properties` declaring a `type` has a value\n * of that primitive type. It does NOT recurse into nested schemas, and does\n * not implement the rest of JSON Schema (enum, format, oneOf, items, …). A\n * full validator (e.g. ajv) is a later step; keeping this package light is\n * the point.\n */\nexport interface MinimalJsonSchema {\n readonly type?: string\n readonly required?: readonly string[]\n readonly properties?: {\n readonly [key: string]: { readonly type?: string }\n }\n}\n\nconst minimalJsonSchemaSchema: z.ZodType<MinimalJsonSchema> = z.object({\n type: z.string().optional(),\n required: z.array(z.string()).optional(),\n properties: z\n .record(z.string(), z.object({ type: z.string().optional() }))\n .optional(),\n})\n\n/** Narrows a JSON value to a plain JSON object (not null, not an array). */\nfunction isJsonObject(value: JsonValue): value is JsonObject {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\n/** The JSON Schema primitive-type name for a runtime JSON value. */\nfunction jsonTypeOf(value: JsonValue): string {\n if (value === null) return \"null\"\n if (Array.isArray(value)) return \"array\"\n if (typeof value === \"number\") return \"number\"\n if (typeof value === \"boolean\") return \"boolean\"\n if (typeof value === \"string\") return \"string\"\n return \"object\"\n}\n\nexport const jsonSchemaValidTool = defineTool({\n id: \"eval.json-schema-valid\",\n description:\n \"Deterministic scorer: minimal structural check of a JSON value against \" +\n \"a schema's top-level `required` and `properties` type constraints only. \" +\n \"Not a full JSON Schema validator (no recursion, enum, format, …).\",\n version: \"0.1.0\",\n inputSchema: z.object({\n actual: jsonValueSchema.describe(\"The JSON value to validate.\"),\n schema: minimalJsonSchemaSchema.describe(\n \"Minimal JSON schema: top-level `required` and `properties.type` only.\",\n ),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\nexport const jsonSchemaValidImpl = implementTool(\n jsonSchemaValidTool,\n ({ input }) => {\n const { actual, schema } = input\n const violation = firstSchemaViolation(actual, schema)\n const valid = violation === undefined\n return {\n value: valid ? 1 : 0,\n passed: valid,\n label: \"json-schema-valid\",\n rationale: valid ? \"value satisfies the schema\" : violation,\n }\n },\n)\n\n/** Returns the first violation message, or undefined when the value is valid. */\nfunction firstSchemaViolation(\n actual: JsonValue,\n schema: MinimalJsonSchema,\n): string | undefined {\n const declaredType = schema.type ?? \"object\"\n const actualType = jsonTypeOf(actual)\n if (declaredType !== actualType) {\n return `expected top-level type '${declaredType}' but got '${actualType}'`\n }\n\n // Only object payloads carry required/properties semantics here.\n if (!isJsonObject(actual)) {\n return undefined\n }\n\n for (const key of schema.required ?? []) {\n if (!(key in actual)) {\n return `missing required property '${key}'`\n }\n }\n\n for (const [key, propSchema] of Object.entries(schema.properties ?? {})) {\n if (propSchema.type === undefined) continue\n const propValue = actual[key]\n if (propValue === undefined) continue\n const propType = jsonTypeOf(propValue)\n if (propType !== propSchema.type) {\n return `property '${key}' expected type '${propSchema.type}' but got '${propType}'`\n }\n }\n\n return undefined\n}\n\n// ---------------------------------------------------------------------------\n// eval.latency-budget\n// ---------------------------------------------------------------------------\n\nexport const latencyBudgetTool = defineTool({\n id: \"eval.latency-budget\",\n description:\n \"Deterministic scorer: passes when `durationMs` is within `budgetMs`. \" +\n \"value is 1 when within budget, else linearly decays toward 0 as the \" +\n \"overrun approaches one full budget.\",\n version: \"0.1.0\",\n inputSchema: z.object({\n durationMs: z\n .number()\n .min(0)\n .describe(\"Observed duration in milliseconds.\"),\n budgetMs: z\n .number()\n .positive()\n .describe(\"Allowed budget in milliseconds (must be > 0).\"),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\nexport const latencyBudgetImpl = implementTool(latencyBudgetTool, ({ input }) => {\n const { durationMs, budgetMs } = input\n const passed = durationMs <= budgetMs\n const value = passed\n ? 1\n : Math.max(0, 1 - (durationMs - budgetMs) / budgetMs)\n return {\n value,\n passed,\n label: \"latency-budget\",\n rationale: `durationMs=${durationMs}, budgetMs=${budgetMs}`,\n }\n})\n","import { z } from \"zod\"\nimport { defineTool } from \"@agentproto/tool\"\nimport { defineDriver, implementTool, type DriverHandle } from \"@agentproto/driver\"\nimport { scoreSchema } from \"./score.js\"\nimport { jsonValueSchema, type JsonValue } from \"./json.js\"\nimport type { ScorerBinding } from \"./run-eval.js\"\n\n/**\n * `llmJudge` — a model-backed scorer.\n *\n * Design (locked): a model-backed scorer stays a TOOL, exactly like the\n * deterministic scorers in `scorers.ts`. What differs is where the model\n * lives: the injected {@link JudgeFn} is closed over by the DRIVER (built by\n * {@link makeLlmJudgeDriver}), never threaded through tool input/context. That\n * keeps `eval.llm-judge`'s contract identical in shape to every other scorer\n * tool, so it composes with the existing `bindScorer` / `runEval` in\n * run-eval.ts with ZERO changes there.\n *\n * The judge itself is vendor-neutral: {@link JudgeFn} is just an injected\n * async function. This file has no LLM SDK and no network dependency — a real\n * adapter (an agent session, a supervisor judge-gate, …) is a documented\n * follow-up, not built here.\n */\n\n// ---------------------------------------------------------------------------\n// JudgeVerdict — what an injected judge returns\n// ---------------------------------------------------------------------------\n\n/** Zod schema for the raw verdict a {@link JudgeFn} produces. */\nexport const judgeVerdictSchema = z.object({\n /** Normalized judge score in [0, 1]. */\n value: z.number().min(0).max(1),\n /**\n * Explicit pass/fail from the judge. When present it WINS over the\n * threshold comparison — see {@link makeLlmJudgeDriver}.\n */\n passed: z.boolean().optional(),\n /** Human-readable explanation of the verdict. */\n rationale: z.string().optional(),\n})\n\nexport type JudgeVerdict = z.infer<typeof judgeVerdictSchema>\n\n// ---------------------------------------------------------------------------\n// JudgeFn — the injected capability\n// ---------------------------------------------------------------------------\n\n/**\n * The seam a real judge satisfies: given the produced `output`, free-form\n * grading `criteria`, and an optional `expected` reference, return a\n * {@link JudgeVerdict}. Callers supply this — a real LLM call, an agent\n * session, or the supervisor's judge-gate all satisfy the same shape.\n * Deliberately no LLM SDK / network types here: keeping this package\n * vendor-neutral is the point.\n */\nexport type JudgeFn = (args: {\n readonly output: JsonValue\n readonly criteria: string\n readonly expected?: JsonValue\n}) => Promise<JudgeVerdict>\n\n// ---------------------------------------------------------------------------\n// eval.llm-judge — the TOOL contract\n// ---------------------------------------------------------------------------\n\n/** Tool input for `eval.llm-judge`. */\nexport interface LlmJudgeInput {\n readonly output: JsonValue\n readonly criteria: string\n readonly expected?: JsonValue\n}\n\nexport const llmJudgeTool = defineTool({\n id: \"eval.llm-judge\",\n description:\n \"Model-backed scorer: hands `output` (plus free-form `criteria` and an \" +\n \"optional `expected` reference) to an injected judge and normalizes the \" +\n \"judge's verdict into the shared Score shape. The judge itself lives in \" +\n \"the driver (see makeLlmJudgeDriver) — this tool contract carries no \" +\n \"model call of its own.\",\n version: \"0.1.0\",\n inputSchema: z.object({\n output: jsonValueSchema.describe(\"The produced value to judge.\"),\n criteria: z.string().describe(\"Free-form grading criteria/rubric for the judge.\"),\n expected: jsonValueSchema\n .optional()\n .describe(\"Optional reference value the judge may compare against.\"),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\n// ---------------------------------------------------------------------------\n// makeLlmJudgeDriver — closes over the injected JudgeFn\n// ---------------------------------------------------------------------------\n\n/** Clamp a number into [0, 1]. */\nfunction clamp01(x: number): number {\n return Math.min(1, Math.max(0, x))\n}\n\nexport interface MakeLlmJudgeDriverOptions {\n /** Minimum `value` to count as passed when the judge omits `passed`. Default 0.5. */\n readonly threshold?: number\n}\n\n/**\n * Build a DRIVER that implements `eval.llm-judge` by delegating to `judge`.\n * This is the one seam where the injected model-backed capability enters the\n * system — everything downstream (`bindScorer`, `runEval`) stays unaware that\n * this scorer is model-backed at all.\n */\nexport function makeLlmJudgeDriver(\n judge: JudgeFn,\n opts?: MakeLlmJudgeDriverOptions,\n): DriverHandle {\n const threshold = opts?.threshold ?? 0.5\n return defineDriver({\n id: \"eval-llm-judge\",\n name: \"Eval LLM Judge (model-backed)\",\n description:\n \"Model-backed scorer driver: implements eval.llm-judge by awaiting an \" +\n \"injected JudgeFn and mapping its verdict to the shared Score shape. \" +\n \"The judge is supplied by the caller — no LLM SDK or network call here.\",\n version: \"0.1.0\",\n kind: \"builtin\",\n implements: [{ tool: \"eval.llm-judge\", version: \"0.1.0\" }],\n implementations: [\n implementTool(llmJudgeTool, async ({ input }) => {\n const verdict = await judge({\n output: input.output,\n criteria: input.criteria,\n expected: input.expected,\n })\n const value = clamp01(verdict.value)\n const passed = verdict.passed ?? value >= threshold\n return {\n value,\n passed,\n label: \"llm-judge\",\n ...(verdict.rationale ? { rationale: verdict.rationale } : {}),\n }\n }),\n ],\n })\n}\n\n// ---------------------------------------------------------------------------\n// llmJudge — convenience ScorerBinding factory\n// ---------------------------------------------------------------------------\n\nexport interface LlmJudgeBinding<A> {\n /** Label for this binding, e.g. \"helpfulness\". */\n readonly id: string\n /** The injected judge capability. */\n readonly judge: JudgeFn\n /** Free-form grading criteria/rubric handed to the judge on every call. */\n readonly criteria: string\n /** Minimum value to count as passed when the judge omits `passed`. Default 0.5. */\n readonly threshold?: number\n /** Derive the judge's `output` input from the target's output. */\n readonly mapOutput: (ctx: { output: A; expected?: JsonValue }) => JsonValue\n}\n\n/**\n * Convenience: build a {@link ScorerBinding} ready to drop into a suite's\n * `scorers` via `bindScorer` — wires up `eval.llm-judge`, a driver built with\n * {@link makeLlmJudgeDriver}, and the input mapping in one call.\n */\nexport function llmJudge<A>(binding: LlmJudgeBinding<A>): ScorerBinding<A, LlmJudgeInput> {\n const driver = makeLlmJudgeDriver(binding.judge, { threshold: binding.threshold })\n return {\n id: binding.id,\n tool: llmJudgeTool,\n driver,\n mapInput: (ctx) => ({\n output: binding.mapOutput({ output: ctx.output, expected: ctx.expected }),\n criteria: binding.criteria,\n expected: ctx.expected,\n }),\n }\n}\n","/**\n * Structured events emitted while an eval suite runs.\n *\n * The union mirrors the shape of `@agentproto/telemetry`'s `TelemetryEvent`:\n * a discriminated union keyed on `kind`, every member carrying a correlation\n * id (`runId`) and an ISO `at` timestamp so a sink can rebuild a per-run span\n * tree. It rides the same {@link Telemetry} port — a `runEval` call takes a\n * `Telemetry<EvalEvent>` sink.\n *\n * Sinks MUST tolerate unknown kinds — future versions may add event types\n * under the same `agentproto/eval/v1` schema (identical forward-compat\n * contract as the telemetry port).\n */\n\n/** Schema identifier for this event family. */\nexport const EVAL_EVENT_SCHEMA = \"agentproto/eval/v1\" as const\n\nexport type EvalEvent =\n | {\n readonly kind: \"eval.started\"\n readonly runId: string\n readonly at: string\n readonly suiteId: string\n readonly caseCount: number\n readonly scorerCount: number\n }\n | {\n readonly kind: \"eval.case.started\"\n readonly runId: string\n readonly at: string\n readonly caseId: string\n }\n | {\n readonly kind: \"eval.case.scored\"\n readonly runId: string\n readonly at: string\n readonly caseId: string\n readonly scorerId: string\n readonly value: number\n readonly passed: boolean\n }\n | {\n readonly kind: \"eval.case.finished\"\n readonly runId: string\n readonly at: string\n readonly caseId: string\n /** True when EVERY scorer bound to the case passed. */\n readonly passed: boolean\n }\n | {\n readonly kind: \"eval.finished\"\n readonly runId: string\n readonly at: string\n readonly suiteId: string\n readonly total: number\n readonly passedCount: number\n readonly meanValue: number\n readonly durationMs: number\n }\n","/**\n * `runEval` — the eval harness.\n *\n * The thesis this file proves: **an eval is a workflow that runs a target then\n * scores its output with scorer-tools, reporting through the telemetry port.**\n *\n * For each case we build a {@link RuntimeWorkflow} that composes\n * target → one scorer `tool` step per binding → a per-case aggregate transform\n * and execute it with `runWorkflow` (AIP-15). The target's structured output is\n * the input selector for every scorer step — that is where composable tool I/O\n * is demonstrated. `runEval` then aggregates across cases and emits\n * {@link EvalEvent}s through an injected `Telemetry<EvalEvent>` sink.\n *\n * The `target` is a plain async function here (not required to be a tool); a\n * tool/agent target is a documented follow-up.\n */\n\nimport { runWorkflow, type RuntimeWorkflow } from \"@agentproto/workflow-runtime\"\nimport type { Telemetry } from \"@agentproto/telemetry\"\nimport type { DriverHandle } from \"@agentproto/driver\"\nimport type { ToolHandle } from \"@agentproto/tool\"\nimport type { Score } from \"./score.js\"\nimport type { JsonValue } from \"./json.js\"\nimport type { EvalEvent } from \"./events.js\"\n\n/** One case: an input for the target and an optional expected reference. */\nexport interface EvalCase<I> {\n readonly id: string\n readonly input: I\n /** Optional reference value, modelled as JSON (never `unknown`/`any`). */\n readonly expected?: JsonValue\n}\n\n/** Context handed to a binding's `mapInput` when scoring one case's output. */\nexport interface ScorerInputContext<A> {\n readonly output: A\n readonly expected?: JsonValue\n}\n\n/**\n * One scorer applied to the target output. Generic over the target output type\n * `A` and the scorer's own input type `S` (captured when the binding is\n * authored). {@link bindScorer} erases `S` so heterogeneous scorers coexist in\n * one `EvalSuite.scorers` array without an `any`.\n */\nexport interface ScorerBinding<A, S = JsonValue> {\n /** Label for this binding, e.g. \"exact\". */\n readonly id: string\n /** The scorer TOOL contract — its `outputSchema` is the shared {@link Score}. */\n readonly tool: ToolHandle<S, Score>\n /** The DRIVER that implements the scorer tool. */\n readonly driver: DriverHandle\n /** Derive the scorer's input from the target's output (+ optional expected). */\n readonly mapInput: (ctx: ScorerInputContext<A>) => S\n}\n\n/**\n * The uniform, `S`-erased view of a binding stored in a suite. It exposes the\n * authored `id` plus a closure that runs the scorer for a given case output —\n * the existential box that lets a suite hold scorers with different input\n * types with no `any` at the collection boundary.\n */\nexport interface BoundScorer<A> {\n readonly id: string\n /** Build the AIP-15 tool step that scores one case's output. */\n toStep(stepId: string, output: A, expected?: JsonValue): RuntimeWorkflow[\"steps\"][number]\n}\n\n/**\n * Box a typed {@link ScorerBinding} into a {@link BoundScorer}, capturing the\n * scorer input type `S` inside the closure so the outer type is `S`-free.\n */\nexport function bindScorer<A, S>(binding: ScorerBinding<A, S>): BoundScorer<A> {\n return {\n id: binding.id,\n toStep(stepId, output, expected) {\n return {\n kind: \"tool\",\n id: stepId,\n tool: binding.tool,\n candidates: [binding.driver],\n input: () => binding.mapInput({ output, expected }),\n }\n },\n }\n}\n\nexport interface EvalSuite<A> {\n readonly id: string\n readonly cases: readonly EvalCase<unknown>[]\n readonly scorers: readonly BoundScorer<A>[]\n}\n\n/** One scorer's outcome on one case. */\nexport interface CaseScore {\n readonly scorerId: string\n readonly score: Score\n}\n\n/** The per-case rollup carried in the final report. */\nexport interface CaseReport {\n readonly caseId: string\n readonly passed: boolean\n readonly scores: readonly CaseScore[]\n}\n\nexport interface EvalReport {\n readonly runId: string\n readonly suiteId: string\n readonly total: number\n readonly passedCount: number\n /** Mean of every scorer value across every case (0 when there are none). */\n readonly meanValue: number\n readonly cases: readonly CaseReport[]\n}\n\nexport interface RunEvalOptions<I, A> {\n /** Produce the target output for a case input. */\n readonly target: (input: I) => Promise<A>\n /** Sink for {@link EvalEvent}s. Defaults to a no-op. */\n readonly telemetry?: Telemetry<EvalEvent>\n /** Correlation id for this run. Defaults to a deterministic suite-based id. */\n readonly runId?: string\n}\n\n/** A suite whose cases share the target input type `I`. */\nexport interface TypedEvalSuite<I, A> extends EvalSuite<A> {\n readonly cases: readonly EvalCase<I>[]\n}\n\n/** Per-process counter so a default runId is deterministic within a process. */\nlet runCounter = 0\n\nfunction defaultRunId(suiteId: string): string {\n runCounter += 1\n return `${suiteId}#${runCounter}`\n}\n\n/** The per-case aggregate: which scorers ran and whether all passed. */\ninterface CaseAggregate {\n readonly scores: readonly CaseScore[]\n readonly passed: boolean\n}\n\n/** Narrow a step-binding value to a {@link Score} without a cast. */\nfunction asScore(value: unknown): Score {\n if (\n typeof value === \"object\" &&\n value !== null &&\n \"value\" in value &&\n \"passed\" in value &&\n \"label\" in value\n ) {\n const v: unknown = value.value\n const passed: unknown = value.passed\n const label: unknown = value.label\n const rationale: unknown = \"rationale\" in value ? value.rationale : undefined\n if (\n typeof v === \"number\" &&\n typeof passed === \"boolean\" &&\n typeof label === \"string\" &&\n (rationale === undefined || typeof rationale === \"string\")\n ) {\n return { value: v, passed, label, rationale }\n }\n }\n throw new Error(\"scorer step did not produce a valid Score\")\n}\n\n/**\n * Run every case in the suite, scoring each with all bound scorers, and return\n * the aggregated {@link EvalReport}. Emits `eval.started` … `eval.finished`.\n */\nexport async function runEval<I, A>(\n suite: TypedEvalSuite<I, A>,\n opts: RunEvalOptions<I, A>,\n): Promise<EvalReport> {\n const telemetry = opts.telemetry\n const runId = opts.runId ?? defaultRunId(suite.id)\n const start = Date.now()\n\n telemetry?.emit({\n kind: \"eval.started\",\n runId,\n at: new Date().toISOString(),\n suiteId: suite.id,\n caseCount: suite.cases.length,\n scorerCount: suite.scorers.length,\n })\n\n const caseReports: CaseReport[] = []\n let valueSum = 0\n let valueCount = 0\n\n for (const evalCase of suite.cases) {\n telemetry?.emit({\n kind: \"eval.case.started\",\n runId,\n at: new Date().toISOString(),\n caseId: evalCase.id,\n })\n\n const aggregate = await runCase(suite, evalCase, opts.target)\n\n for (const cs of aggregate.scores) {\n valueSum += cs.score.value\n valueCount += 1\n telemetry?.emit({\n kind: \"eval.case.scored\",\n runId,\n at: new Date().toISOString(),\n caseId: evalCase.id,\n scorerId: cs.scorerId,\n value: cs.score.value,\n passed: cs.score.passed,\n })\n }\n\n telemetry?.emit({\n kind: \"eval.case.finished\",\n runId,\n at: new Date().toISOString(),\n caseId: evalCase.id,\n passed: aggregate.passed,\n })\n\n caseReports.push({\n caseId: evalCase.id,\n passed: aggregate.passed,\n scores: aggregate.scores,\n })\n }\n\n const passedCount = caseReports.filter((c) => c.passed).length\n const meanValue = valueCount === 0 ? 0 : valueSum / valueCount\n\n const report: EvalReport = {\n runId,\n suiteId: suite.id,\n total: suite.cases.length,\n passedCount,\n meanValue,\n cases: caseReports,\n }\n\n telemetry?.emit({\n kind: \"eval.finished\",\n runId,\n at: new Date().toISOString(),\n suiteId: suite.id,\n total: report.total,\n passedCount,\n meanValue,\n durationMs: Date.now() - start,\n })\n\n return report\n}\n\n/**\n * Build and run the per-case workflow: `target` → one scorer tool-step per\n * binding → an aggregate transform, then read the aggregate off the run output.\n */\nasync function runCase<I, A>(\n suite: EvalSuite<A>,\n evalCase: EvalCase<I>,\n target: (input: I) => Promise<A>,\n): Promise<CaseAggregate> {\n const output = await target(evalCase.input)\n const scorerStepIds = suite.scorers.map((_, i) => `score_${i}`)\n\n const workflow: RuntimeWorkflow = {\n id: `${suite.id}:${evalCase.id}`,\n steps: [\n ...suite.scorers.map((scorer, i) =>\n scorer.toStep(scorerStepIds[i]!, output, evalCase.expected),\n ),\n {\n kind: \"transform\",\n id: \"aggregate\",\n compute: (b): CaseAggregate => {\n const scores: CaseScore[] = suite.scorers.map((scorer, i) => ({\n scorerId: scorer.id,\n score: asScore(b.steps[scorerStepIds[i]!]),\n }))\n return { scores, passed: scores.every((s) => s.score.passed) }\n },\n },\n ],\n output: (b) => b.steps.aggregate,\n }\n\n const { output: runOutput } = await runWorkflow({ workflow })\n return toCaseAggregate(runOutput)\n}\n\n/** Narrow the workflow output to a {@link CaseAggregate} without a cast. */\nfunction toCaseAggregate(value: unknown): CaseAggregate {\n if (\n typeof value === \"object\" &&\n value !== null &&\n \"scores\" in value &&\n \"passed\" in value &&\n Array.isArray(value.scores) &&\n typeof value.passed === \"boolean\"\n ) {\n const scores = value.scores.map((entry: unknown) => {\n if (\n typeof entry === \"object\" &&\n entry !== null &&\n \"scorerId\" in entry &&\n \"score\" in entry &&\n typeof entry.scorerId === \"string\"\n ) {\n return { scorerId: entry.scorerId, score: asScore(entry.score) }\n }\n throw new Error(\"invalid CaseScore in aggregate\")\n })\n return { scores, passed: value.passed }\n }\n throw new Error(\"workflow did not produce a CaseAggregate\")\n}\n","/**\n * `toVitest` — turn an {@link TypedEvalSuite} into vitest test registrations.\n *\n * The vitest primitives (`describe` / `it` / `expect`) are INJECTED by the\n * host's own `import ... from \"vitest\"`, so THIS source carries no vitest\n * runtime dependency (nothing to bundle, nothing to version-pin). It registers\n * one `it(caseId)` per case that runs the case through {@link runEval} and\n * asserts every scorer passed — the same workflow the harness runs, wired as a\n * CI gate.\n */\n\nimport { runEval, type RunEvalOptions, type TypedEvalSuite } from \"./run-eval.js\"\n\n/** The subset of vitest's `expect` this bridge needs. */\nexport interface ExpectApi {\n (actual: unknown): {\n toBe(expected: unknown): void\n }\n}\n\n/** The subset of vitest's `describe`/`it` this bridge needs. */\nexport interface VitestHooks {\n describe(name: string, body: () => void): void\n it(name: string, body: () => Promise<void> | void): void\n expect: ExpectApi\n}\n\nexport type ToVitestOptions<I, A> = RunEvalOptions<I, A>\n\n/**\n * Register `describe(suite.id)` with one `it` per case. Each `it` runs the\n * single-case suite through {@link runEval} and asserts the case passed (all\n * scorers green). Failing scorers surface as a failing vitest assertion.\n */\nexport function toVitest<I, A>(\n suite: TypedEvalSuite<I, A>,\n opts: ToVitestOptions<I, A>,\n hooks: VitestHooks,\n): void {\n const { describe, it, expect } = hooks\n describe(suite.id, () => {\n for (const evalCase of suite.cases) {\n it(evalCase.id, async () => {\n const singleCaseSuite: TypedEvalSuite<I, A> = {\n id: `${suite.id}:${evalCase.id}`,\n cases: [evalCase],\n scorers: suite.scorers,\n }\n const report = await runEval(singleCaseSuite, opts)\n const caseReport = report.cases[0]\n expect(caseReport?.passed).toBe(true)\n })\n }\n })\n}\n","import { z } from \"zod\"\nimport { defineTool } from \"@agentproto/tool\"\nimport { implementTool } from \"@agentproto/driver\"\nimport { scoreSchema } from \"../score.js\"\n\n/**\n * `eval.text-stats` — deterministic French style metrics.\n *\n * Pure text statistics for the target's French output: bullet-line ratio,\n * first-person ratio, question rate, and mean sentence length (+ whether\n * that length falls inside a caller-supplied band). No LLM, no network —\n * every threshold is passed in as input so the caller (not this package)\n * owns the gate. See DESIGN.md §7 for the default production bands\n * (bullets ≤ 0.02, first-person ≥ 0.6).\n */\n\n// ---------------------------------------------------------------------------\n// pure metric helpers\n// ---------------------------------------------------------------------------\n\n/**\n * French first-person markers. `\\b` is deliberately NOT used here: it is an\n * ASCII word-boundary even under the `u` flag, so it treats any accented\n * letter as a non-word character and creates a spurious boundary right\n * next to one — `/\\bmes\\b/iu.test(\"problèmes\")` is `true` because `è` reads\n * as `\\W`. That's exactly the class of bug `containsWord` in `lexicon.ts`\n * was rewritten to avoid, so the same accent-safe lookaround boundaries\n * (against `\\p{L}\\p{N}_`) are used here. Terms ending in an apostrophe\n * (elisions like `j'`, `m'`) get no trailing boundary — the letter right\n * after the apostrophe (`j'aime`) is the point, not a boundary.\n */\nconst FIRST_PERSON_TERMS = [\n \"je\", \"j'\", \"j\\u2019\", \"moi\", \"mon\", \"ma\", \"mes\", \"me\", \"m'\", \"m\\u2019\",\n \"nous\", \"notre\", \"nos\", \"mien(?:ne)?s?\",\n]\n\nconst FIRST_PERSON_RE = new RegExp(\n FIRST_PERSON_TERMS.map((term) => {\n const isElision = term.endsWith(\"'\") || term.endsWith(\"\\u2019\")\n return `(?<![\\\\p{L}\\\\p{N}_])${term}${isElision ? \"\" : \"(?![\\\\p{L}\\\\p{N}_])\"}`\n }).join(\"|\"),\n \"iu\",\n)\n\n/**\n * Sentence-final abbreviations that must NOT be treated as a sentence\n * boundary — lowercased, without the trailing period. `p` + `ex` covers\n * \"p. ex.\" (split across two chunks by the naive `.`-boundary split, then\n * re-merged token by token).\n */\nconst ABBREVIATIONS = new Set([\n \"m\", \"mme\", \"mlle\", \"dr\", \"st\", \"ste\", \"etc\", \"cf\", \"vs\", \"p\", \"ex\", \"no\", \"art\", \"vol\", \"pp\", \"chap\",\n])\n\n/** Split text into non-empty lines. */\nfunction splitLines(text: string): string[] {\n return text.split(\"\\n\").map((line) => line.trim()).filter((line) => line.length > 0)\n}\n\n/** True when `chunk` ends in an abbreviation (or a single capital initial) rather than a real sentence-final period. */\nfunction endsWithAbbreviation(chunk: string): boolean {\n const match = chunk.match(/(\\p{L}+)\\.$/u)\n if (!match) return false\n const word = match[1]!\n if (ABBREVIATIONS.has(word.toLowerCase())) return true\n return word.length === 1 && /\\p{Lu}/u.test(word)\n}\n\n/**\n * Split text into non-empty sentences on `.`/`!`/`?` boundaries, guarding\n * against abbreviations (`M.`, `Mme`, `Dr`, `etc.`, `cf.`, `p. ex.`) and\n * isolated capital initials (`J. Dupont`) so those periods don't count as\n * sentence ends.\n */\nexport function splitSentences(text: string): string[] {\n const chunks = text\n .split(/(?<=[.!?])\\s+|\\n+/u)\n .map((s) => s.trim())\n .filter((s) => s.length > 0)\n const sentences: string[] = []\n for (const chunk of chunks) {\n const prevIndex = sentences.length - 1\n const prev = prevIndex >= 0 ? sentences[prevIndex] : undefined\n if (prev !== undefined && endsWithAbbreviation(prev)) {\n sentences[prevIndex] = `${prev} ${chunk}`\n } else {\n sentences.push(chunk)\n }\n }\n return sentences\n}\n\n/** Fraction of lines that open with a bullet marker (`-`, `*`, `•`, or `1.`) followed by whitespace — a marker glued to the next character (`1.5 million`, `-42 degrés`) is prose, not a bullet. */\nexport function bulletsRatio(text: string): number {\n const lines = splitLines(text)\n if (lines.length === 0) return 0\n const bulletLines = lines.filter((line) => /^([-*•]|\\d+\\.)\\s+/u.test(line))\n return bulletLines.length / lines.length\n}\n\n/** Fraction of sentences carrying a French first-person marker. */\nexport function firstPersonRatio(text: string): number {\n const sentences = splitSentences(text)\n if (sentences.length === 0) return 0\n const firstPersonSentences = sentences.filter((s) => FIRST_PERSON_RE.test(s))\n return firstPersonSentences.length / sentences.length\n}\n\n/** Fraction of sentences ending in `?`. */\nexport function questionRate(text: string): number {\n const sentences = splitSentences(text)\n if (sentences.length === 0) return 0\n const questions = sentences.filter((s) => s.endsWith(\"?\"))\n return questions.length / sentences.length\n}\n\n/** Mean number of words per sentence. */\nexport function meanSentenceLength(text: string): number {\n const sentences = splitSentences(text)\n if (sentences.length === 0) return 0\n const total = sentences.reduce((sum, s) => {\n const words = s.split(/\\s+/u).filter((w) => w.length > 0)\n return sum + words.length\n }, 0)\n return total / sentences.length\n}\n\nexport interface TextStats {\n readonly bulletsRatio: number\n readonly firstPersonRatio: number\n readonly questionRate: number\n readonly meanSentenceLength: number\n readonly inBand: boolean\n}\n\nexport interface LengthBand {\n readonly min: number\n readonly max: number\n}\n\nconst DEFAULT_LENGTH_BAND: LengthBand = { min: 5, max: 30 }\n\n/** Compute every metric in one pass. */\nexport function computeTextStats(text: string, band: LengthBand = DEFAULT_LENGTH_BAND): TextStats {\n const length = meanSentenceLength(text)\n return {\n bulletsRatio: bulletsRatio(text),\n firstPersonRatio: firstPersonRatio(text),\n questionRate: questionRate(text),\n meanSentenceLength: length,\n inBand: length >= band.min && length <= band.max,\n }\n}\n\n// ---------------------------------------------------------------------------\n// eval.text-stats — the TOOL contract\n// ---------------------------------------------------------------------------\n\nconst textStatsThresholdsSchema = z.object({\n maxBulletsRatio: z.number().min(0).max(1).optional().describe(\"Default 0.02.\"),\n minFirstPersonRatio: z.number().min(0).max(1).optional().describe(\"Default 0.6.\"),\n lengthBand: z\n .object({ min: z.number().min(0), max: z.number().min(0) })\n .refine((band) => band.min <= band.max, { message: \"lengthBand.min must be <= lengthBand.max\" })\n .optional()\n .describe(\"Word-count band for mean sentence length. Default { min: 5, max: 30 }.\"),\n})\n\nexport const textStatsTool = defineTool({\n id: \"eval.text-stats\",\n description:\n \"Deterministic scorer: computes bullet-line ratio, first-person ratio, \" +\n \"question rate, and mean sentence length (+ inBand) over French text. \" +\n \"`passed` is derived from caller-supplied `thresholds` — this tool owns \" +\n \"no fixed gate.\",\n version: \"0.1.0\",\n inputSchema: z.object({\n text: z.string().describe(\"The French text to analyze.\"),\n thresholds: textStatsThresholdsSchema.optional(),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\nexport const textStatsImpl = implementTool(textStatsTool, ({ input }) => {\n const thresholds = input.thresholds ?? {}\n const maxBulletsRatio = thresholds.maxBulletsRatio ?? 0.02\n const minFirstPersonRatio = thresholds.minFirstPersonRatio ?? 0.6\n const band = thresholds.lengthBand ?? DEFAULT_LENGTH_BAND\n\n const stats = computeTextStats(input.text, band)\n const bulletsOk = stats.bulletsRatio <= maxBulletsRatio\n const firstPersonOk = stats.firstPersonRatio >= minFirstPersonRatio\n const checks = [bulletsOk, firstPersonOk, stats.inBand]\n const value = checks.filter(Boolean).length / checks.length\n const passed = checks.every(Boolean)\n\n return {\n value,\n passed,\n label: \"text-stats\",\n rationale:\n `bulletsRatio=${stats.bulletsRatio.toFixed(3)} (max ${maxBulletsRatio}), ` +\n `firstPersonRatio=${stats.firstPersonRatio.toFixed(3)} (min ${minFirstPersonRatio}), ` +\n `questionRate=${stats.questionRate.toFixed(3)}, ` +\n `meanSentenceLength=${stats.meanSentenceLength.toFixed(1)}, ` +\n `inBand=${stats.inBand} (band ${band.min}-${band.max})`,\n }\n})\n","import { z } from \"zod\"\nimport { defineTool } from \"@agentproto/tool\"\nimport { implementTool } from \"@agentproto/driver\"\nimport { scoreSchema } from \"../score.js\"\n\n/**\n * `eval.lexicon-hit-rate` — deterministic scorer: fraction of a caller-supplied\n * lexicon (a corpus's signature vocabulary) present in `text`. The lexicon\n * itself is an input, not baked into this package — `extractLexicon` below is\n * an offline helper to build one from a corpus, not something the tool calls.\n */\n\nconst WORD_RE = /\\p{L}[\\p{L}'’-]*/gu\n\n/** A minimal French stopword set — filtered out so a \"signature\" lexicon is distinctive, not just frequent function words. */\nconst FRENCH_STOPWORDS = new Set([\n \"le\", \"la\", \"les\", \"un\", \"une\", \"des\", \"de\", \"du\", \"et\", \"à\", \"au\", \"aux\",\n \"ce\", \"ces\", \"cet\", \"cette\", \"que\", \"qui\", \"quoi\", \"dont\", \"où\",\n \"je\", \"tu\", \"il\", \"elle\", \"on\", \"nous\", \"vous\", \"ils\", \"elles\",\n \"est\", \"sont\", \"été\", \"être\", \"avoir\", \"ai\", \"as\", \"a\", \"avons\", \"avez\", \"ont\",\n \"pour\", \"par\", \"sur\", \"sous\", \"dans\", \"avec\", \"sans\", \"ne\", \"pas\", \"plus\",\n \"mais\", \"ou\", \"si\", \"se\", \"sa\", \"son\", \"ses\", \"leur\", \"leurs\", \"en\", \"y\",\n])\n\nfunction tokenize(text: string): string[] {\n return (text.normalize(\"NFC\").toLowerCase().match(WORD_RE) ?? []).map((w) => w.trim()).filter((w) => w.length > 0)\n}\n\n/**\n * Checks whether `text` contains `term` as a whole word (case-insensitive,\n * Unicode-aware). Uses lookaround boundaries instead of `\\b`: `\\b` is an\n * ASCII word-boundary even under the `u` flag, so it never matches around an\n * accented letter (`/\\bécrire\\b/iu.test(\"il aime écrire\")` is `false`) —\n * lookarounds against `\\p{L}\\p{N}_` are boundary-correct for accented terms.\n */\nfunction containsWord(text: string, term: string): boolean {\n const escaped = term.normalize(\"NFC\").replace(/[.*+?^${}()|[\\]\\\\]/gu, \"\\\\$&\")\n const re = new RegExp(`(?<![\\\\p{L}\\\\p{N}_])${escaped}(?![\\\\p{L}\\\\p{N}_])`, \"iu\")\n return re.test(text.normalize(\"NFC\"))\n}\n\nexport interface ExtractLexiconOptions {\n /** Max number of terms to return. Default 20. */\n readonly top?: number\n /** Minimum term length (characters) to keep. Default 3. */\n readonly minLen?: number\n /**\n * Optional background corpus. When provided, terms are ranked by an\n * add-one-smoothed log-odds ratio of their rate in `corpusTexts` versus\n * their rate in `background`, surfacing terms disproportionately frequent\n * in the foreground corpus rather than merely frequent overall. This is a\n * simple frequency-ratio estimator, NOT the full variance-weighted\n * informative-Dirichlet log-odds estimator (Monroe et al. 2008) — it has\n * no correction for small counts beyond add-one smoothing, so rare terms\n * in a small background corpus can score unstably high. When omitted,\n * ranking falls back to raw frequency in `corpusTexts`.\n */\n readonly background?: readonly string[]\n}\n\nfunction countTerms(texts: readonly string[], minLen: number): Map<string, number> {\n const counts = new Map<string, number>()\n for (const text of texts) {\n for (const word of tokenize(text)) {\n if (word.length < minLen) continue\n if (FRENCH_STOPWORDS.has(word)) continue\n counts.set(word, (counts.get(word) ?? 0) + 1)\n }\n }\n return counts\n}\n\nfunction totalCount(counts: ReadonlyMap<string, number>): number {\n let total = 0\n for (const c of counts.values()) total += c\n return total\n}\n\n/**\n * Pure helper: extract a corpus's signature lexicon — the most frequent\n * non-stopword terms across `corpusTexts` — for use as `eval.lexicon-hit-rate`\n * input. Offline / caller-side; this tool never calls it itself.\n */\nexport function extractLexicon(corpusTexts: readonly string[], opts?: ExtractLexiconOptions): string[] {\n const top = opts?.top ?? 20\n const minLen = opts?.minLen ?? 3\n const counts = countTerms(corpusTexts, minLen)\n\n if (opts?.background && opts.background.length > 0) {\n const bgCounts = countTerms(opts.background, minLen)\n const fgTotal = totalCount(counts)\n const bgTotal = totalCount(bgCounts)\n return [...counts.entries()]\n .map(([word, fg]): [string, number] => {\n const bg = bgCounts.get(word) ?? 0\n const score = Math.log((fg + 1) / (fgTotal - fg + 1)) - Math.log((bg + 1) / (bgTotal - bg + 1))\n return [word, score]\n })\n .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))\n .slice(0, top)\n .map(([word]) => word)\n }\n\n return [...counts.entries()]\n .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))\n .slice(0, top)\n .map(([word]) => word)\n}\n\n// ---------------------------------------------------------------------------\n// eval.lexicon-hit-rate — the TOOL contract\n// ---------------------------------------------------------------------------\n\nexport const lexiconHitRateTool = defineTool({\n id: \"eval.lexicon-hit-rate\",\n description:\n \"Deterministic scorer: fraction of `lexicon` terms present as whole \" +\n \"words in `text` (case-insensitive). `passed = hitRate >= threshold` \" +\n \"(threshold default 0.5).\",\n version: \"0.1.0\",\n inputSchema: z.object({\n text: z.string().describe(\"The text to score.\"),\n lexicon: z.array(z.string()).min(1).describe(\"Signature terms to look for, e.g. from extractLexicon.\"),\n threshold: z.number().min(0).max(1).optional().describe(\"Minimum hit rate to pass. Default 0.5.\"),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\nexport const lexiconHitRateImpl = implementTool(lexiconHitRateTool, ({ input }) => {\n const threshold = input.threshold ?? 0.5\n const lexicon = input.lexicon\n const hits = lexicon.filter((term) => containsWord(input.text, term))\n const hitRate = lexicon.length === 0 ? 0 : hits.length / lexicon.length\n const passed = hitRate >= threshold\n return {\n value: hitRate,\n passed,\n label: \"lexicon-hit-rate\",\n rationale: `${hits.length}/${lexicon.length} lexicon terms found (threshold ${threshold}): ${hits.join(\", \") || \"none\"}`,\n }\n})\n","import { judgeVerdictSchema, type JudgeVerdict } from \"../judge.js\"\n\n/**\n * Validate a raw judge return value against {@link judgeVerdictSchema}. An\n * injected `JudgeFn` is caller-supplied and only nominally typed — a\n * misbehaving judge can hand back `NaN`, a missing `value`, or any other\n * malformed shape at runtime. Callers use this to fail the `Score` with a\n * rationale instead of letting a bad verdict propagate as `NaN`/`undefined`\n * downstream.\n */\nexport function parseVerdict(raw: unknown): JudgeVerdict | null {\n const parsed = judgeVerdictSchema.safeParse(raw)\n return parsed.success ? parsed.data : null\n}\n","import { z } from \"zod\"\nimport { defineTool } from \"@agentproto/tool\"\nimport { defineDriver, implementTool, type DriverHandle } from \"@agentproto/driver\"\nimport { scoreSchema } from \"../score.js\"\nimport type { JudgeFn } from \"../judge.js\"\nimport { parseVerdict } from \"./verdict.js\"\n\n/**\n * `eval.style-pairwise` — model-backed A/B scorer: which of `a`/`b` reads\n * closer to `reference` under `criteria`. Reuses the existing {@link JudgeFn}\n * seam from judge.ts (no new judge type) — the driver hands the judge\n * `{reference, a, b}` as `output` and reads back a single verdict whose\n * `value` encodes preference: 1 = `a` wins, 0 = `b` wins, 0.5 = tie.\n *\n * `pairwiseWinRate` below is a SEPARATE pure helper: callers run this tool\n * multiple times (varying which side is presented first, and across\n * multiple judges) and feed the resulting {winner} outcomes to it to get an\n * order-debiased win rate plus inter-judge agreement (Cohen's kappa).\n */\n\n// ---------------------------------------------------------------------------\n// eval.style-pairwise — the TOOL contract\n// ---------------------------------------------------------------------------\n\nexport interface StylePairwiseInput {\n readonly reference: string\n readonly a: string\n readonly b: string\n readonly criteria: string\n}\n\nexport const stylePairwiseTool = defineTool({\n id: \"eval.style-pairwise\",\n description:\n \"Model-backed scorer: asks an injected judge which of `a`/`b` is closer \" +\n \"in style to `reference` under `criteria`. value encodes preference \" +\n \"(1 = a wins, 0 = b wins, 0.5 = tie). The judge lives in the driver (see \" +\n \"makeStylePairwiseDriver) — this tool contract carries no model call.\",\n version: \"0.1.0\",\n inputSchema: z.object({\n reference: z.string().describe(\"The reference style text.\"),\n a: z.string().describe(\"Candidate A.\"),\n b: z.string().describe(\"Candidate B.\"),\n criteria: z.string().describe(\"Free-form grading criteria/rubric for the judge.\"),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\n// ---------------------------------------------------------------------------\n// makeStylePairwiseDriver — closes over the injected JudgeFn\n// ---------------------------------------------------------------------------\n\nfunction clamp01(x: number): number {\n return Math.min(1, Math.max(0, x))\n}\n\n/**\n * Build a DRIVER that implements `eval.style-pairwise` by delegating to\n * `judge` — the same {@link JudgeFn} shape as `eval.llm-judge`, reused rather\n * than threading a bespoke comparison type through this package.\n */\nexport function makeStylePairwiseDriver(judge: JudgeFn): DriverHandle {\n return defineDriver({\n id: \"eval-style-pairwise\",\n name: \"Eval Style Pairwise (model-backed)\",\n description:\n \"Model-backed scorer driver: implements eval.style-pairwise by \" +\n \"awaiting an injected JudgeFn over {reference, a, b} and mapping its \" +\n \"verdict.value to an a-vs-b preference score.\",\n version: \"0.1.0\",\n kind: \"builtin\",\n implements: [{ tool: \"eval.style-pairwise\", version: \"0.1.0\" }],\n implementations: [\n implementTool(stylePairwiseTool, async ({ input }) => {\n const raw = await judge({\n output: { reference: input.reference, a: input.a, b: input.b },\n criteria: input.criteria,\n expected: input.reference,\n })\n const verdict = parseVerdict(raw)\n if (!verdict) {\n return {\n value: 0,\n passed: false,\n label: \"style-pairwise\",\n rationale: \"judge returned a malformed verdict\",\n }\n }\n const value = clamp01(verdict.value)\n const passed = verdict.passed ?? value >= 0.5\n return {\n value,\n passed,\n label: \"style-pairwise\",\n ...(verdict.rationale ? { rationale: verdict.rationale } : {}),\n }\n }),\n ],\n })\n}\n\n// ---------------------------------------------------------------------------\n// pairwiseWinRate — pure helper over collected verdicts\n// ---------------------------------------------------------------------------\n\nexport type PairwiseWinner = \"a\" | \"b\" | \"tie\"\n\n/**\n * One collected pairwise outcome. `order` records which physical position\n * `a` was presented in when this verdict was produced; `winner` is the RAW\n * outcome as reported for that presentation (before un-swapping) — e.g. a\n * judge exhibiting pure position bias always picks the same physical slot,\n * which shows up here as `winner` tracking `order` rather than content.\n * `pairwiseWinRate` un-swaps `winner` back to the logical a/b before\n * aggregating, which is what neutralizes that bias.\n */\nexport interface PairwiseVerdict {\n /** Identifies which item this verdict scored — required so verdicts from different items are never zipped together. */\n readonly item: string\n /** Judge identity — distinguishes the (at least two) judges being compared. */\n readonly judge: string\n /** Physical presentation order this verdict was collected under. */\n readonly order: \"normal\" | \"swapped\"\n /** Raw winner as reported under `order` (not yet un-swapped). */\n readonly winner: PairwiseWinner\n}\n\nexport interface PairwiseWinRateResult {\n /** Logical a-win rate (ties count as 0.5), after order de-biasing. Averages the normal-order and swapped-order rates when both are present. */\n readonly winRate: number\n /**\n * Cohen's kappa agreement between the two most-represented judges, computed\n * over items both judges rated. `null` when there are fewer than two\n * judges, or fewer than two items in common — a `null` here means the\n * agreement gate has no evidence and any threshold check against it (e.g.\n * \"kappa >= 0.4\") must be treated as a FAILURE, not skipped.\n */\n readonly kappa: number | null\n /** Number of verdicts folded in. */\n readonly n: number\n /** Number of verdicts collected under `order: \"normal\"`. */\n readonly nNormal: number\n /** Number of verdicts collected under `order: \"swapped\"`. */\n readonly nSwapped: number\n /** `false` when one of the two presentation orders has zero verdicts — `winRate` then reflects only the order that is present, and is not order-debiased. */\n readonly balanced: boolean\n}\n\nfunction unswap(winner: PairwiseWinner, order: \"normal\" | \"swapped\"): PairwiseWinner {\n if (order === \"normal\" || winner === \"tie\") return winner\n return winner === \"a\" ? \"b\" : \"a\"\n}\n\nfunction aWinScore(winner: PairwiseWinner): number {\n if (winner === \"a\") return 1\n if (winner === \"tie\") return 0.5\n return 0\n}\n\n/** Cohen's kappa for two equal-length categorical rating sequences. Callers must ensure `r1.length >= 2`. */\nfunction cohenKappa(r1: readonly PairwiseWinner[], r2: readonly PairwiseWinner[]): number {\n const n = r1.length\n let agree = 0\n const categories: PairwiseWinner[] = [\"a\", \"b\", \"tie\"]\n const counts1 = new Map<PairwiseWinner, number>(categories.map((c) => [c, 0]))\n const counts2 = new Map<PairwiseWinner, number>(categories.map((c) => [c, 0]))\n for (let i = 0; i < n; i++) {\n const x1 = r1[i]!\n const x2 = r2[i]!\n if (x1 === x2) agree++\n counts1.set(x1, (counts1.get(x1) ?? 0) + 1)\n counts2.set(x2, (counts2.get(x2) ?? 0) + 1)\n }\n const po = agree / n\n const pe = categories.reduce((sum, c) => sum + ((counts1.get(c) ?? 0) / n) * ((counts2.get(c) ?? 0) / n), 0)\n if (pe >= 1) return po === 1 ? 1 : 0\n return (po - pe) / (1 - pe)\n}\n\n/**\n * Aggregate collected {@link PairwiseVerdict}s into an order-debiased win\n * rate and inter-judge Cohen's kappa.\n *\n * Win rate: each verdict is un-swapped against its `order` (neutralizing\n * position bias), then the normal-order rate and swapped-order rate are\n * averaged — not a flat average over all verdicts — so a judge that always\n * picks the physically-first slot nets out near 0.5 even if one order was\n * sampled more than the other. When only one order was collected at all,\n * `balanced` is `false` and `winRate` falls back to that order's rate alone.\n *\n * Kappa: verdicts are joined by `item` — for each of the two\n * most-represented judges, at most one (first-seen, un-swapped) winner is\n * kept per item, so a normal+swapped pair on the same item is one\n * observation, not two. Kappa is then computed over the items both judges\n * rated; see {@link PairwiseWinRateResult.kappa} for the `null` cases.\n */\nexport function pairwiseWinRate(verdicts: readonly PairwiseVerdict[]): PairwiseWinRateResult {\n const n = verdicts.length\n const normalized = verdicts.map((v) => ({ ...v, winner: unswap(v.winner, v.order) }))\n\n const normalGroup = normalized.filter((v) => v.order === \"normal\")\n const swappedGroup = normalized.filter((v) => v.order === \"swapped\")\n const nNormal = normalGroup.length\n const nSwapped = swappedGroup.length\n const rateNormal = nNormal === 0 ? null : normalGroup.reduce((sum, v) => sum + aWinScore(v.winner), 0) / nNormal\n const rateSwapped =\n nSwapped === 0 ? null : swappedGroup.reduce((sum, v) => sum + aWinScore(v.winner), 0) / nSwapped\n const balanced = nNormal > 0 && nSwapped > 0\n const winRate = rateNormal !== null && rateSwapped !== null ? (rateNormal + rateSwapped) / 2 : (rateNormal ?? rateSwapped ?? 0)\n\n const byJudge = new Map<string, Map<string, PairwiseWinner>>()\n for (const v of normalized) {\n let items = byJudge.get(v.judge)\n if (!items) {\n items = new Map()\n byJudge.set(v.judge, items)\n }\n if (!items.has(v.item)) items.set(v.item, v.winner)\n }\n const judges = [...byJudge.entries()].sort((a, b) => b[1].size - a[1].size)\n\n let kappa: number | null = null\n if (judges.length >= 2) {\n const [, items1] = judges[0]!\n const [, items2] = judges[1]!\n const commonItems = [...items1.keys()].filter((item) => items2.has(item)).sort()\n if (commonItems.length >= 2) {\n const r1 = commonItems.map((item) => items1.get(item)!)\n const r2 = commonItems.map((item) => items2.get(item)!)\n kappa = cohenKappa(r1, r2)\n }\n }\n\n return { winRate, kappa, n, nNormal, nSwapped, balanced }\n}\n","import { z } from \"zod\"\nimport { defineTool } from \"@agentproto/tool\"\nimport { defineDriver, implementTool, type DriverHandle } from \"@agentproto/driver\"\nimport { scoreSchema } from \"../score.js\"\n\n/**\n * `eval.style-embedding` — model-backed scorer: how close `candidate` sits\n * to the centroid of `references[]` in embedding space. The embedding\n * function is injected (`EmbedFn`, closed over by\n * {@link makeStyleEmbeddingDriver}) — this package has no model SDK and\n * makes no network call of its own, matching the `eval.llm-judge` /\n * `eval.style-pairwise` pattern.\n */\n\n// ---------------------------------------------------------------------------\n// cosineToCentroid — pure helper\n// ---------------------------------------------------------------------------\n\nfunction dot(a: readonly number[], b: readonly number[]): number {\n let sum = 0\n for (let i = 0; i < a.length; i++) sum += (a[i] ?? 0) * (b[i] ?? 0)\n return sum\n}\n\nfunction norm(v: readonly number[]): number {\n return Math.sqrt(dot(v, v))\n}\n\n/** Thrown by {@link centroid} / {@link cosineToCentroid} on mismatched embedding dimensions — callers crossing the tool boundary (the driver) must catch this and fail the `Score`, never let it propagate as a thrown error out of the tool contract. */\nexport class EmbeddingDimensionError extends RangeError {}\n\nfunction centroid(vectors: readonly (readonly number[])[]): number[] {\n const dims = vectors[0]?.length ?? 0\n for (const v of vectors) {\n if (v.length !== dims) {\n throw new EmbeddingDimensionError(`inconsistent embedding dimensions: expected ${dims}, got ${v.length}`)\n }\n }\n const sum = new Array(dims).fill(0) as number[]\n for (const v of vectors) {\n for (let i = 0; i < dims; i++) sum[i] = (sum[i] ?? 0) + (v[i] ?? 0)\n }\n return sum.map((x) => x / vectors.length)\n}\n\n/**\n * Pure helper: cosine similarity between `candidate` and the centroid of\n * `references`, clamped to `[0, 1]` via `max(0, cosine)` — NOT remapped from\n * `[-1, 1]` via `(cosine + 1) / 2`. That remap put an orthogonal candidate\n * (cosine 0, no signal) at 0.5, the same value as the default `passed`\n * threshold, so an uninformative embedding silently cleared the gate. Under\n * `max(0, cosine)`, orthogonal and opposing candidates both score 0. A\n * candidate equal to the centroid still returns exactly 1.\n *\n * Throws {@link EmbeddingDimensionError} if `candidate` and the references'\n * centroid have different dimensionality — callers at the tool boundary must\n * catch this (see {@link makeStyleEmbeddingDriver}) rather than let it cross\n * into a thrown error from the TOOL contract.\n */\nexport function cosineToCentroid(candidate: readonly number[], references: readonly (readonly number[])[]): number {\n if (references.length === 0) return 0\n const c = centroid(references)\n if (candidate.length !== c.length) {\n throw new EmbeddingDimensionError(\n `inconsistent embedding dimensions: candidate has ${candidate.length}, references have ${c.length}`,\n )\n }\n const cn = norm(c)\n const vn = norm(candidate)\n if (cn === 0 || vn === 0) return 0\n const cosine = dot(candidate, c) / (vn * cn)\n return Math.max(0, Math.min(1, cosine))\n}\n\n// ---------------------------------------------------------------------------\n// eval.style-embedding — the TOOL contract\n// ---------------------------------------------------------------------------\n\nexport interface StyleEmbeddingInput {\n readonly candidate: string\n readonly references: readonly string[]\n}\n\nexport const styleEmbeddingTool = defineTool({\n id: \"eval.style-embedding\",\n description:\n \"Model-backed scorer: embeds `candidate` and `references[]` via an \" +\n \"injected EmbedFn and scores value = cosine similarity of `candidate` \" +\n \"to the references' centroid, clamped to [0, 1] via max(0, cosine) \" +\n \"(orthogonal or opposing candidates score 0, not 0.5). The embedding \" +\n \"call lives in the driver (see makeStyleEmbeddingDriver) — this tool \" +\n \"contract carries no model call of its own.\",\n version: \"0.1.0\",\n inputSchema: z.object({\n candidate: z.string().describe(\"The text to score.\"),\n references: z.array(z.string()).min(1).describe(\"Reference texts defining the style centroid.\"),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\n// ---------------------------------------------------------------------------\n// makeStyleEmbeddingDriver — closes over the injected EmbedFn\n// ---------------------------------------------------------------------------\n\n/**\n * The seam a real embedding capability satisfies: given a batch of texts,\n * return one embedding vector per text, same order. Deliberately no model\n * SDK / network types here — vendor-neutral, like {@link JudgeFn}.\n */\nexport type EmbedFn = (texts: readonly string[]) => Promise<number[][]>\n\nexport interface MakeStyleEmbeddingDriverOptions {\n /** Minimum value to count as passed. Default 0.5. */\n readonly threshold?: number\n}\n\n/**\n * Build a DRIVER that implements `eval.style-embedding` by delegating to\n * `embed`. Embeds `[candidate, ...references]` in a single batch call so a\n * remote embedding backend sees one request per score.\n */\nexport function makeStyleEmbeddingDriver(embed: EmbedFn, opts?: MakeStyleEmbeddingDriverOptions): DriverHandle {\n const threshold = opts?.threshold ?? 0.5\n return defineDriver({\n id: \"eval-style-embedding\",\n name: \"Eval Style Embedding (model-backed)\",\n description:\n \"Model-backed scorer driver: implements eval.style-embedding by \" +\n \"awaiting an injected EmbedFn and scoring cosine similarity of the \" +\n \"candidate to the references' centroid. No LLM SDK or network call here.\",\n version: \"0.1.0\",\n kind: \"builtin\",\n implements: [{ tool: \"eval.style-embedding\", version: \"0.1.0\" }],\n implementations: [\n implementTool(styleEmbeddingTool, async ({ input }) => {\n const vectors = await embed([input.candidate, ...input.references])\n const [candidateVec, ...referenceVecs] = vectors\n let value: number\n try {\n value = cosineToCentroid(candidateVec ?? [], referenceVecs)\n } catch (err) {\n return {\n value: 0,\n passed: false,\n label: \"style-embedding\",\n rationale: err instanceof EmbeddingDimensionError ? err.message : \"embedding failed\",\n }\n }\n const passed = value >= threshold\n return {\n value,\n passed,\n label: \"style-embedding\",\n rationale: `cosine-to-centroid over ${referenceVecs.length} reference(s), threshold ${threshold}`,\n }\n }),\n ],\n })\n}\n","import { z } from \"zod\"\nimport { defineTool } from \"@agentproto/tool\"\nimport { defineDriver, implementTool, type DriverHandle } from \"@agentproto/driver\"\nimport { scoreSchema } from \"../score.js\"\nimport type { JudgeFn } from \"../judge.js\"\nimport { parseVerdict } from \"./verdict.js\"\n\n/**\n * `eval.outline-fidelity` — model-backed scorer: does `answer` cover every\n * point in `outline` without adding unsourced facts. Reuses the existing\n * {@link JudgeFn} seam (`output = answer`, `expected = outline`) — no new\n * judge type. Unlike `eval.llm-judge`, `passed` here is a FIXED gate\n * (`value >= 0.95`, per DESIGN.md §7), never overridden by the judge's own\n * `passed`.\n */\n\nexport interface OutlineFidelityInput {\n readonly outline: string\n readonly answer: string\n}\n\nexport const outlineFidelityTool = defineTool({\n id: \"eval.outline-fidelity\",\n description:\n \"Model-backed scorer: asks an injected judge whether `answer` covers \" +\n \"every point in `outline` with zero added facts. value = covered/total \" +\n \"as judged; passed = value >= 0.95, a fixed gate (not the judge's own \" +\n \"passed). The judge lives in the driver (see makeOutlineFidelityDriver).\",\n version: \"0.1.0\",\n inputSchema: z.object({\n outline: z.string().describe(\"The source outline — bullet points the answer must cover.\"),\n answer: z.string().describe(\"The produced prose answer to check for fidelity.\"),\n }),\n outputSchema: scoreSchema,\n mutates: [],\n approval: \"auto\",\n riskLevel: 0,\n})\n\nconst FIDELITY_THRESHOLD = 0.95\n\nconst FIDELITY_CRITERIA =\n \"Score how faithfully the answer covers the outline: value = (outline \" +\n \"points covered) / (total outline points), where any fact in the answer \" +\n \"not present in the outline counts as a violation and caps value at the \" +\n \"fraction covered. 1.0 means every outline point is covered and nothing \" +\n \"was added.\"\n\n/**\n * Build a DRIVER that implements `eval.outline-fidelity` by delegating to\n * `judge`, the same {@link JudgeFn} shape as `eval.llm-judge`.\n */\nexport function makeOutlineFidelityDriver(judge: JudgeFn): DriverHandle {\n return defineDriver({\n id: \"eval-outline-fidelity\",\n name: \"Eval Outline Fidelity (model-backed)\",\n description:\n \"Model-backed scorer driver: implements eval.outline-fidelity by \" +\n \"awaiting an injected JudgeFn over {answer, outline} and gating on a \" +\n \"fixed 0.95 threshold, not the judge's own passed.\",\n version: \"0.1.0\",\n kind: \"builtin\",\n implements: [{ tool: \"eval.outline-fidelity\", version: \"0.1.0\" }],\n implementations: [\n implementTool(outlineFidelityTool, async ({ input }) => {\n const raw = await judge({\n output: input.answer,\n criteria: FIDELITY_CRITERIA,\n expected: input.outline,\n })\n const verdict = parseVerdict(raw)\n if (!verdict) {\n return {\n value: 0,\n passed: false,\n label: \"outline-fidelity\",\n rationale: \"judge returned a malformed verdict\",\n }\n }\n const value = Math.min(1, Math.max(0, verdict.value))\n const passed = value >= FIDELITY_THRESHOLD\n return {\n value,\n passed,\n label: \"outline-fidelity\",\n ...(verdict.rationale ? { rationale: verdict.rationale } : {}),\n }\n }),\n ],\n })\n}\n","/**\n * Style scorers — F3.\n *\n * Five `eval.style-*` / style-adjacent TOOL contracts (see DESIGN.md §7):\n * two deterministic (`eval.text-stats`, `eval.lexicon-hit-rate`, bundled\n * below into `styleScorersProvider` exactly like `evalScorersProvider`) and\n * three model-backed (`eval.style-pairwise`, `eval.style-embedding`,\n * `eval.outline-fidelity`), each built by a `make*Driver(judge/embed)`\n * factory that closes over an injected, vendor-neutral capability — no LLM\n * SDK, no network dependency in this package.\n */\n\nimport { defineDriver } from \"@agentproto/driver\"\nimport { textStatsTool, textStatsImpl } from \"./text-stats.js\"\nimport { lexiconHitRateTool, lexiconHitRateImpl } from \"./lexicon.js\"\n\nexport {\n textStatsTool,\n textStatsImpl,\n bulletsRatio,\n firstPersonRatio,\n questionRate,\n meanSentenceLength,\n splitSentences,\n computeTextStats,\n type TextStats,\n type LengthBand,\n} from \"./text-stats.js\"\n\nexport {\n lexiconHitRateTool,\n lexiconHitRateImpl,\n extractLexicon,\n type ExtractLexiconOptions,\n} from \"./lexicon.js\"\n\nexport {\n stylePairwiseTool,\n makeStylePairwiseDriver,\n pairwiseWinRate,\n type StylePairwiseInput,\n type PairwiseWinner,\n type PairwiseVerdict,\n type PairwiseWinRateResult,\n} from \"./pairwise.js\"\n\nexport {\n styleEmbeddingTool,\n makeStyleEmbeddingDriver,\n cosineToCentroid,\n EmbeddingDimensionError,\n type StyleEmbeddingInput,\n type EmbedFn,\n type MakeStyleEmbeddingDriverOptions,\n} from \"./style-embedding.js\"\n\nexport { parseVerdict } from \"./verdict.js\"\n\nexport {\n outlineFidelityTool,\n makeOutlineFidelityDriver,\n type OutlineFidelityInput,\n} from \"./outline-fidelity.js\"\n\n/**\n * Builtin AIP-30 PROVIDER bundling the two deterministic style scorers —\n * the pair DESIGN.md §7 names as the only style scorers safe to sample in\n * prod (free, zero network). The three model-backed style tools have no\n * static provider: each needs an injected judge/embed via its\n * `make*Driver(...)` factory, same pattern as `eval.llm-judge`.\n */\nexport const styleScorersProvider = defineDriver({\n id: \"eval-style-scorers\",\n name: \"Eval Style Scorers (built-in)\",\n description:\n \"In-process deterministic style scorers: text-stats and \" +\n \"lexicon-hit-rate. Each is an AIP-14 TOOL whose output is the shared \" +\n \"Score shape.\",\n version: \"0.1.0\",\n kind: \"builtin\",\n implements: [\n { tool: \"eval.text-stats\", version: \"0.1.0\" },\n { tool: \"eval.lexicon-hit-rate\", version: \"0.1.0\" },\n ],\n implementations: [textStatsImpl, lexiconHitRateImpl],\n})\n","/**\n * @agentproto/eval — deterministic reference scorers.\n *\n * A scorer IS an AIP-14 TOOL whose `outputSchema` is the shared {@link Score}\n * shape; there is no separate \"scorer port\". Each scorer is authored with\n * `defineTool` + `implementTool` and bundled in a single builtin AIP-30\n * PROVIDER, exactly like every other builtin. Invoke one through the driver:\n *\n * ```ts\n * import { runTool } from \"@agentproto/driver\"\n * import { exactMatchTool, evalScorersProvider } from \"@agentproto/eval\"\n *\n * const score = await runTool({\n * tool: exactMatchTool,\n * candidates: [evalScorersProvider],\n * input: { actual: \"hello\", expected: \"hello\" },\n * })\n * // → { value: 1, passed: true, label: \"exact-match\", rationale: \"…\" }\n * ```\n *\n * Alongside the deterministic scorers, `eval.llm-judge` (see judge.ts) is a\n * model-backed scorer whose judge is an INJECTED function — the driver\n * closes over it via `makeLlmJudgeDriver(judge)`. This package still carries\n * no LLM SDK or network dependency of its own; a real adapter (agent\n * session, supervisor judge-gate, …) is a documented follow-up.\n *\n * Spec: https://agentproto.sh/docs/aip-14 (TOOL), /docs/aip-30 (PROVIDER)\n */\n\nimport { defineDriver } from \"@agentproto/driver\"\nimport {\n exactMatchTool,\n exactMatchImpl,\n regexMatchTool,\n regexMatchImpl,\n jsonSchemaValidTool,\n jsonSchemaValidImpl,\n latencyBudgetTool,\n latencyBudgetImpl,\n} from \"./scorers.js\"\n\nexport const SPEC_NAME = \"agenteval/v1\" as const\nexport const SPEC_VERSION = \"1.0.0-alpha\" as const\n\nexport { scoreSchema, type Score } from \"./score.js\"\n\nexport {\n type JsonValue,\n type JsonObject,\n jsonValueSchema,\n} from \"./json.js\"\n\nexport {\n exactMatchTool,\n exactMatchImpl,\n regexMatchTool,\n regexMatchImpl,\n jsonSchemaValidTool,\n jsonSchemaValidImpl,\n latencyBudgetTool,\n latencyBudgetImpl,\n type MinimalJsonSchema,\n} from \"./scorers.js\"\n\nexport {\n judgeVerdictSchema,\n llmJudgeTool,\n makeLlmJudgeDriver,\n llmJudge,\n type JudgeVerdict,\n type JudgeFn,\n type LlmJudgeInput,\n type MakeLlmJudgeDriverOptions,\n type LlmJudgeBinding,\n} from \"./judge.js\"\n\nexport { EVAL_EVENT_SCHEMA, type EvalEvent } from \"./events.js\"\n\nexport {\n runEval,\n bindScorer,\n type EvalCase,\n type ScorerBinding,\n type ScorerInputContext,\n type BoundScorer,\n type EvalSuite,\n type TypedEvalSuite,\n type CaseScore,\n type CaseReport,\n type EvalReport,\n type RunEvalOptions,\n} from \"./run-eval.js\"\n\nexport {\n toVitest,\n type VitestHooks,\n type ExpectApi,\n type ToVitestOptions,\n} from \"./to-vitest.js\"\n\nexport * from \"./style/index.js\"\n\n/**\n * Builtin AIP-30 PROVIDER bundling the four deterministic ref scorers.\n * `kind: \"builtin\"` — pure in-process functions, no subprocess / network hop.\n */\nexport const evalScorersProvider = defineDriver({\n id: \"eval-scorers\",\n name: \"Eval Reference Scorers (built-in)\",\n description:\n \"In-process deterministic scorers: exact-match, regex-match, \" +\n \"json-schema-valid (minimal structural check), and latency-budget. \" +\n \"Each is an AIP-14 TOOL whose output is the shared Score shape.\",\n version: \"0.1.0\",\n kind: \"builtin\",\n implements: [\n { tool: \"eval.exact-match\", version: \"0.1.0\" },\n { tool: \"eval.regex-match\", version: \"0.1.0\" },\n { tool: \"eval.json-schema-valid\", version: \"0.1.0\" },\n { tool: \"eval.latency-budget\", version: \"0.1.0\" },\n ],\n implementations: [\n exactMatchImpl,\n regexMatchImpl,\n jsonSchemaValidImpl,\n latencyBudgetImpl,\n ],\n})\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentproto/eval",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Deterministic reference scorers as AIP-14 TOOL contracts + one builtin AIP-30 PROVIDER. A scorer IS a tool whose outputSchema is the shared `Score` shape — no new scorer port. Ships exact-match, regex-match, json-schema-valid, and latency-budget. No LLM/model calls.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentproto",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"zod": "^4.6.5",
|
|
48
48
|
"@agentproto/driver": "0.2.3",
|
|
49
|
+
"@agentproto/workflow-runtime": "0.12.0",
|
|
49
50
|
"@agentproto/telemetry": "0.2.3",
|
|
50
|
-
"@agentproto/tool": "0.3.1"
|
|
51
|
-
"@agentproto/workflow-runtime": "0.11.1"
|
|
51
|
+
"@agentproto/tool": "0.3.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^25.9.5",
|