@b4run/evals 0.8.28

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.
@@ -0,0 +1,74 @@
1
+ import type { AgentRunResult, FixtureSet, ScriptBuilder } from "@b4run/testing";
2
+ /** One dataset row. `input` is the user message for agent routes (v1). */
3
+ export interface EvalCase {
4
+ readonly name?: string;
5
+ readonly input: unknown;
6
+ readonly expected?: unknown;
7
+ /** Per-case aimock fixtures for replay mode; ignored under --live. */
8
+ readonly fixtures?: FixtureSet | ScriptBuilder;
9
+ readonly metadata?: Record<string, unknown>;
10
+ }
11
+ /** Inline cases, a path to a committed .json/.jsonl, or a (sync/async) factory. */
12
+ export type Dataset = readonly EvalCase[] | string | (() => EvalCase[] | Promise<EvalCase[]>);
13
+ /** A scorer may return a 0..1 number, a boolean, or a rich verdict. */
14
+ export type Score = number | boolean | {
15
+ readonly score: number;
16
+ readonly label?: string;
17
+ readonly reason?: string;
18
+ };
19
+ export interface Scorer {
20
+ readonly name: string;
21
+ /** This scorer's own pass bar (used by gate.perScorer and case-pass). */
22
+ readonly threshold?: number;
23
+ readonly score: (run: AgentRunResult, testCase: EvalCase) => Score | Promise<Score>;
24
+ }
25
+ export interface EvalDefinition {
26
+ readonly name: string;
27
+ /** Route key like "/chat#agent"; defaults to the co-located route at load time. */
28
+ readonly route?: string;
29
+ readonly dataset: Dataset;
30
+ readonly scorers: readonly Scorer[];
31
+ /** Sugar for gate.mean(threshold). Ignored if `gate` is set. */
32
+ readonly threshold?: number;
33
+ readonly gate?: GatePolicy;
34
+ }
35
+ /** Normalized score for one (case, scorer) pair. */
36
+ export interface CaseScore {
37
+ readonly scorer: string;
38
+ readonly score: number;
39
+ readonly label?: string;
40
+ readonly reason?: string;
41
+ }
42
+ export interface CaseResult {
43
+ readonly name: string;
44
+ readonly scores: readonly CaseScore[];
45
+ readonly mean: number;
46
+ /** Every scorer met its bar (scorer.threshold ?? DEFAULT_CASE_BAR). */
47
+ readonly passed: boolean;
48
+ }
49
+ export interface ScorerAggregate {
50
+ readonly scorer: string;
51
+ readonly mean: number;
52
+ readonly threshold?: number;
53
+ }
54
+ /** Pre-gate report fed to gate policies. */
55
+ export interface ScoredReport {
56
+ readonly name: string;
57
+ readonly cases: readonly CaseResult[];
58
+ readonly byScorer: readonly ScorerAggregate[];
59
+ readonly mean: number;
60
+ }
61
+ export interface EvalReport extends ScoredReport {
62
+ /** Whether a gate/threshold was configured (informational evals are false). */
63
+ readonly gated: boolean;
64
+ readonly passed: boolean;
65
+ readonly reason?: string;
66
+ }
67
+ export type GateResult = {
68
+ readonly passed: boolean;
69
+ readonly reason?: string;
70
+ };
71
+ export type GatePolicy = (report: ScoredReport) => GateResult;
72
+ /** A case "passes" when every scorer ≥ its threshold, defaulting to this bar. */
73
+ export declare const DEFAULT_CASE_BAR = 0.5;
74
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE/E,0EAA0E;AAC1E,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,aAAa,CAAA;IAC9C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC5C;AAED,mFAAmF;AACnF,MAAM,MAAM,OAAO,GAAG,SAAS,QAAQ,EAAE,GAAG,MAAM,GAAG,CAAC,MAAM,QAAQ,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;AAE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ACrB,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAA;IACrC,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAA;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAC/E,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,UAAU,CAAA;AAE7D,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,MAAM,CAAA"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ /** A case "passes" when every scorer ≥ its threshold, defaulting to this bar. */
2
+ export const DEFAULT_CASE_BAR = 0.5;
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@b4run/evals",
3
+ "version": "0.8.28",
4
+ "private": false,
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "description": "Evaluation definitions, scorers, datasets, and runners for B4.run agents.",
8
+ "keywords": [
9
+ "b4",
10
+ "typescript",
11
+ "ai-agents",
12
+ "evals",
13
+ "testing",
14
+ "llm"
15
+ ],
16
+ "homepage": "https://github.com/cacheplane/b4run/tree/main/packages/evals#readme",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/cacheplane/b4run.git",
20
+ "directory": "packages/evals"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/cacheplane/b4run/issues"
24
+ },
25
+ "engines": {
26
+ "node": ">=24.0.0"
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "types": "./dist/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "default": "./dist/index.js"
36
+ }
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "peerDependencies": {
42
+ "@b4run/testing": "0.8.28"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "26.1.2",
46
+ "@b4run/config-typescript": "0.8.28",
47
+ "@b4run/testing": "0.8.28"
48
+ },
49
+ "scripts": {
50
+ "build": "tsc -b tsconfig.json",
51
+ "lint": "biome check --config-path ../config-biome/biome.json package.json src test tsconfig.json vitest.config.ts",
52
+ "test": "vitest --run --config vitest.config.ts --passWithNoTests",
53
+ "typecheck": "tsc --noEmit && tsc -p tsconfig.test.json"
54
+ }
55
+ }