@plune-ai/cli 0.39.14 → 0.39.16

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/dist/index.cjs CHANGED
@@ -1172,10 +1172,26 @@ var jsonSchemaAssertionSchema = import_zod.z.object({
1172
1172
  schema: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()),
1173
1173
  extract: import_zod.z.enum(["auto", "strict"]).optional()
1174
1174
  });
1175
+ var jevJudgeSchema = import_zod.z.strictObject({
1176
+ type: import_zod.z.literal("jev"),
1177
+ // A full version, never an alias: `jev-latest` would change the judge under a run without a word.
1178
+ model: import_zod.z.string().regex(/^jev-\d+\.\d+\.\d+$/, "must be a full Jev version such as jev-1.14.0; an alias such as jev-latest is not taken"),
1179
+ timeout: providerTimeoutSchema.optional()
1180
+ });
1181
+ var partialProviderSchema = providerConfigSchema.partial();
1182
+ var llmJudgeProviderField = import_zod.z.any().transform((value, ctx) => {
1183
+ const jev = typeof value === "object" && value !== null && value.type === "jev";
1184
+ const r = (jev ? jevJudgeSchema : partialProviderSchema).safeParse(value);
1185
+ if (r.success) return r.data;
1186
+ for (const issue of r.error.issues) ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
1187
+ return import_zod.z.NEVER;
1188
+ });
1175
1189
  var llmJudgeAssertionSchema = import_zod.z.object({
1176
1190
  type: import_zod.z.literal("llm-judge"),
1177
1191
  criteria: import_zod.z.string().min(1),
1178
- provider: providerConfigSchema.partial().optional(),
1192
+ // `type: jev` is a judge of another kind (a decision model) with fields of its own; anything else is the eval's
1193
+ // provider with these fields over it.
1194
+ provider: llmJudgeProviderField.optional(),
1179
1195
  // The judge's score floor, not the eval's share of passing runs (that one is `evalRepeatsShape`).
1180
1196
  pass_threshold: import_zod.z.number().min(0, "pass_threshold (llm-judge: minimum judge score) must be between 0 and 1").max(1, "pass_threshold (llm-judge: minimum judge score) must be between 0 and 1").optional()
1181
1197
  });
@@ -1752,11 +1768,16 @@ init_cjs_shims();
1752
1768
  // src/providers/prices.ts
1753
1769
  init_cjs_shims();
1754
1770
  var PRICE_TABLE = {
1771
+ // TypeSafe Jev, the experimental judge of `llm-judge`: input tokens only, its output is not billed.
1772
+ // Source: docs.typesafe.ai, read on 2026-11-24 (USD 0.042 per million input tokens).
1773
+ "jev-1.14.0": { input_per_1k_usd: 42e-6, output_per_1k_usd: 0 },
1755
1774
  // Anthropic, current models. Source: platform.claude.com/docs/en/about-claude/pricing — base
1756
1775
  // input and output tokens per million, read on 2026-09-29, kept here per thousand.
1757
1776
  "claude-fable-5-1": { input_per_1k_usd: 0.01, output_per_1k_usd: 0.05 },
1758
1777
  "claude-opus-5-5": { input_per_1k_usd: 4e-3, output_per_1k_usd: 0.02 },
1759
1778
  "claude-sonnet-5-5": { input_per_1k_usd: 2e-3, output_per_1k_usd: 0.01 },
1779
+ // Read on 2026-11-24 from https://openrouter.ai/api/v1/models, which passes Anthropic's list price through.
1780
+ "claude-haiku-5-5": { input_per_1k_usd: 1e-4, output_per_1k_usd: 5e-4 },
1760
1781
  "claude-haiku-4-5": { input_per_1k_usd: 1e-3, output_per_1k_usd: 5e-3 },
1761
1782
  // The dated id of the same model; a config may name either.
1762
1783
  "claude-haiku-4-5-20251001": { input_per_1k_usd: 1e-3, output_per_1k_usd: 5e-3 },
@@ -2788,6 +2809,18 @@ var llmJudge = {
2788
2809
  }
2789
2810
  const criteria = interpolate(ctx.params.criteria, ctx);
2790
2811
  const threshold = ctx.params.pass_threshold ?? DEFAULT_PASS_THRESHOLD;
2812
+ if (ctx.judge.decide !== void 0) {
2813
+ const { probability: p } = await ctx.judge.decide({
2814
+ criteria,
2815
+ output: ctx.output,
2816
+ ...ctx.input !== void 0 ? { input: ctx.input } : {}
2817
+ });
2818
+ return {
2819
+ passed: p >= threshold,
2820
+ score: p,
2821
+ reason: `probability ${p.toFixed(3)} that the answer meets the criteria vs threshold ${threshold}; this judge gives no reason`
2822
+ };
2823
+ }
2791
2824
  const { score, reason } = parseScored(
2792
2825
  await askJson(ctx.judge, prompt(criteria, ctx.output, ctx.input))
2793
2826
  );
@@ -4132,9 +4165,25 @@ async function assess(p, output, input, transcript) {
4132
4165
  let assertionError;
4133
4166
  for (const assertion of p.assertions) {
4134
4167
  const own2 = assertion.type === "llm-judge" ? assertion.provider : void 0;
4135
- const judgeCfg = own2 === void 0 ? p.providerConfig : { ...p.providerConfig, ...own2 };
4168
+ const jev = own2?.type === "jev" ? own2 : void 0;
4169
+ const judgeCfg = own2 === void 0 || own2.type === "jev" ? p.providerConfig : { ...p.providerConfig, ...own2 };
4136
4170
  let judgedBy;
4137
4171
  const judge = () => {
4172
+ if (jev !== void 0) {
4173
+ if (p.jevJudge === void 0) throw new Error("this run cannot build the jev judge of an llm-judge check");
4174
+ const inner2 = p.jevJudge(jev, (c) => {
4175
+ judgeCost += c.cost_usd;
4176
+ if (c.priced === false) judgeUnpriced = true;
4177
+ });
4178
+ return {
4179
+ ask: (q) => inner2.ask(q),
4180
+ decide: async (q) => {
4181
+ const answer = await inner2.decide(q);
4182
+ judgedBy = `jev/${answer.model}`;
4183
+ return answer;
4184
+ }
4185
+ };
4186
+ }
4138
4187
  let provider = p.provider;
4139
4188
  if (own2 !== void 0) {
4140
4189
  if (p.resolveJudge === void 0)
@@ -4198,7 +4247,15 @@ async function runRow(p) {
4198
4247
  if (p.dryRun) {
4199
4248
  const est = estimateUsage(prompt5, maxTokens);
4200
4249
  const cost = p.provider.estimateCost(est);
4201
- return dryRunRow(p.row.vars, { ...est, ...costFields(cost) });
4250
+ let judged = 0;
4251
+ let unpriced = cost.priced === false;
4252
+ for (const a of p.assertions) {
4253
+ if (a.type !== "llm-judge" || a.provider?.type !== "jev" || p.jevCost === void 0) continue;
4254
+ const c = p.jevCost(a.provider.model, Math.ceil((prompt5.length + maxTokens * 4 + a.criteria.length) / 3));
4255
+ judged += c.cost_usd;
4256
+ if (c.priced === false) unpriced = true;
4257
+ }
4258
+ return dryRunRow(p.row.vars, { ...est, cost_usd: cost.cost_usd + judged, ...unpriced ? { priced: false } : cost.priced === void 0 ? {} : { priced: cost.priced } });
4202
4259
  }
4203
4260
  const key = cacheKey(
4204
4261
  {
@@ -4495,6 +4552,8 @@ async function runOrchestration(config, options, deps) {
4495
4552
  providerConfig,
4496
4553
  provider,
4497
4554
  resolveJudge,
4555
+ ...deps.jevJudge !== void 0 ? { jevJudge: deps.jevJudge } : {},
4556
+ ...deps.jevCost !== void 0 ? { jevCost: deps.jevCost } : {},
4498
4557
  embedder: deps.embedder,
4499
4558
  cache: deps.cache,
4500
4559
  now: deps.now,
@@ -4596,6 +4655,113 @@ function typeName(value) {
4596
4655
  return value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
4597
4656
  }
4598
4657
 
4658
+ // src/judge/jev.ts
4659
+ init_cjs_shims();
4660
+ var JEV_BASE_URL = "https://api.typesafe.ai";
4661
+ var JEV_KEY_ENV = "TYPESAFE_API_KEY";
4662
+ var JEV_MAX_STATE_CHARS = 16e3;
4663
+ var JEV_BASE_URL_ENV = "PLUNE_JEV_BASE_URL";
4664
+ var DEFAULT_TIMEOUT_MS = 3e4;
4665
+ var INSTRUCTIONS = "Does the answer meet the criterion?";
4666
+ var YES = "the answer meets the criterion";
4667
+ var NO = "the answer does not meet the criterion";
4668
+ function jevState(q) {
4669
+ const request = q.input === void 0 ? "" : `Request:
4670
+ ${q.input}
4671
+
4672
+ `;
4673
+ return `${request}Answer:
4674
+ ${q.output}
4675
+
4676
+ Criterion:
4677
+ ${q.criteria}`;
4678
+ }
4679
+ function jevBaseUrl(env) {
4680
+ const own2 = env[JEV_BASE_URL_ENV];
4681
+ const [name, value] = own2 !== void 0 && own2 !== "" ? [JEV_BASE_URL_ENV, own2] : ["TYPESAFE_BASE_URL", env["TYPESAFE_BASE_URL"]];
4682
+ if (value === void 0 || value === "") return JEV_BASE_URL;
4683
+ let url;
4684
+ try {
4685
+ url = new URL(value);
4686
+ } catch {
4687
+ url = void 0;
4688
+ }
4689
+ const ok = url !== void 0 && url.protocol === "https:" && (url.hostname === "typesafe.ai" || url.hostname.endsWith(".typesafe.ai"));
4690
+ if (!ok)
4691
+ throw new Error(
4692
+ `${name} is ${value}: the jev judge asks only an https address under typesafe.ai, so that another model is not judged and reported as Jev. ` + (name === JEV_BASE_URL_ENV ? `Unset it or set it to ${JEV_BASE_URL}` : `Set ${JEV_BASE_URL_ENV}=${JEV_BASE_URL} for plune and keep TYPESAFE_BASE_URL for your other tools`)
4693
+ );
4694
+ return value.replace(/\/+$/, "");
4695
+ }
4696
+ function jevCost(model, inputTokens, pricing) {
4697
+ return resolveCostEntry({ input_tokens: inputTokens, output_tokens: 0 }, model, void 0, pricing);
4698
+ }
4699
+ var jevTokenEstimate = (chars) => Math.ceil(chars / 3);
4700
+ function probability(json) {
4701
+ const answer = json?.answers?.q;
4702
+ const p = answer?.type === "noul" ? answer.noul : void 0;
4703
+ if (typeof p !== "number" || !Number.isFinite(p) || p < 0 || p > 1)
4704
+ throw new ProviderError("JEV_ANSWER", "jev returned no probability for the question asked");
4705
+ return p;
4706
+ }
4707
+ function makeJevJudge(cfg, deps) {
4708
+ return {
4709
+ ask: () => Promise.reject(new Error("a jev judge answers a yes-or-no question only: it cannot judge this kind of check")),
4710
+ async decide(q) {
4711
+ const base = jevBaseUrl(deps.env);
4712
+ const key = deps.env[JEV_KEY_ENV];
4713
+ if (key === void 0 || key === "")
4714
+ throw new AuthError(`${JEV_KEY_ENV} is not set: the jev judge of an llm-judge check needs it`, JEV_KEY_ENV);
4715
+ const state = jevState(q);
4716
+ if (state.length > JEV_MAX_STATE_CHARS)
4717
+ throw new ProviderError(
4718
+ "JEV_INPUT_TOO_LONG",
4719
+ `the request, answer and criterion are ${state.length} characters together; a jev judge takes ${JEV_MAX_STATE_CHARS}. Nothing was sent`
4720
+ );
4721
+ const body = JSON.stringify({
4722
+ state,
4723
+ model: cfg.model,
4724
+ questions: { q: { type: "noul", instructions: INSTRUCTIONS, criteria: { true: YES, false: NO } } }
4725
+ });
4726
+ const send = async () => {
4727
+ try {
4728
+ return await deps.fetchFn(`${base}/v1/systemone`, {
4729
+ method: "POST",
4730
+ headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
4731
+ body,
4732
+ redirect: "error",
4733
+ signal: AbortSignal.timeout(cfg.timeout ?? DEFAULT_TIMEOUT_MS)
4734
+ });
4735
+ } catch (err) {
4736
+ throw new ProviderError("JEV_UNREACHABLE", `jev did not answer: ${err instanceof Error ? err.message : String(err)}`);
4737
+ }
4738
+ };
4739
+ let res = await send();
4740
+ if (res.status === 429 || res.status >= 500) res = await send();
4741
+ if (res.status === 401 || res.status === 403)
4742
+ throw new AuthError(`jev refused the key in ${JEV_KEY_ENV} (HTTP ${res.status})`, JEV_KEY_ENV);
4743
+ if (!res.ok) throw new ProviderError("JEV_HTTP", `jev answered HTTP ${res.status}`);
4744
+ const json = await res.json();
4745
+ const p = probability(json);
4746
+ const tokens = json.usage?.input_tokens;
4747
+ const billed = typeof tokens === "number" && tokens >= 0 ? tokens : jevTokenEstimate(state.length);
4748
+ const answered = json.model;
4749
+ const model = typeof answered === "string" && answered !== "" ? answered : cfg.model;
4750
+ deps.onCost(jevCost(model, billed, deps.pricing));
4751
+ return { probability: p, model };
4752
+ }
4753
+ };
4754
+ }
4755
+ var warned = false;
4756
+ function warnJevExperimental(write = (l) => process.stderr.write(l)) {
4757
+ if (warned) return;
4758
+ warned = true;
4759
+ write(
4760
+ `warning: the jev judge is experimental. It gives a probability and no reason, sends the request, answer and criterion to ${new URL(JEV_BASE_URL).host}, and was measured on answers with a clear right or wrong only. See docs/guide/assertions.md#an-experimental-judge-jev
4761
+ `
4762
+ );
4763
+ }
4764
+
4599
4765
  // src/cli/commands/run.ts
4600
4766
  var NOOP_CACHE = { get: () => void 0, set: () => {
4601
4767
  }, delete: () => {
@@ -4691,7 +4857,20 @@ function buildRealDeps(config, baseDir, dryRun) {
4691
4857
  now: Date.now,
4692
4858
  loadDataset,
4693
4859
  baseDir,
4694
- connectMcp: makeMcpConnect(config, baseDir, process.env)
4860
+ connectMcp: makeMcpConnect(config, baseDir, process.env),
4861
+ // A dry run stops before any check, so it never builds this judge. Mock mode sends nothing: no jev judge there.
4862
+ ...isMockMode(process.env) ? {} : {
4863
+ jevJudge: (cfg, onCost) => {
4864
+ warnJevExperimental();
4865
+ return makeJevJudge(cfg, {
4866
+ env: process.env,
4867
+ fetchFn: fetch,
4868
+ onCost,
4869
+ ...config.pricing !== void 0 ? { pricing: config.pricing } : {}
4870
+ });
4871
+ },
4872
+ jevCost: (model, inputTokens) => jevCost(model, inputTokens, config.pricing)
4873
+ }
4695
4874
  };
4696
4875
  }
4697
4876
  function persist(result, baseDir) {
@@ -4699,11 +4878,21 @@ function persist(result, baseDir) {
4699
4878
  fs5.mkdirSync(dir, { recursive: true });
4700
4879
  fs5.writeFileSync(path5.join(dir, "last-run.json"), JSON.stringify(result, null, 2));
4701
4880
  }
4881
+ function jevAddressCheck(config, env) {
4882
+ const checks = [...config.defaults?.assertions ?? [], ...config.evals.flatMap((ev) => ev.assertions)];
4883
+ if (!checks.some((a) => a.type === "llm-judge" && a.provider?.type === "jev")) return;
4884
+ try {
4885
+ jevBaseUrl(env);
4886
+ } catch (err) {
4887
+ throw new RunConfigError(err.message);
4888
+ }
4889
+ }
4702
4890
  async function handleRun(options, depsFactory) {
4703
4891
  const config = await loadConfig(
4704
4892
  options.configPath !== void 0 ? { configPath: options.configPath } : {}
4705
4893
  );
4706
4894
  const baseDir = options.configPath !== void 0 ? path5.dirname(path5.resolve(options.configPath)) : process.cwd();
4895
+ jevAddressCheck(config, process.env);
4707
4896
  for (const warning of [...mcpSecretWarnings(config), ...selfJudgeWarnings(config)])
4708
4897
  process.stderr.write(`warning: ${warning}
4709
4898
  `);
package/dist/index.d.cts CHANGED
@@ -317,10 +317,20 @@ interface JsonSchemaAssertion {
317
317
  schema: object;
318
318
  extract?: 'auto' | 'strict';
319
319
  }
320
+ /**
321
+ * The experimental Jev judge of an `llm-judge` check. A decision model, not a text model: it cannot be an eval's
322
+ * provider, takes none of the eval provider's fields, and its model is always named.
323
+ */
324
+ interface JevJudgeConfig {
325
+ type: 'jev';
326
+ model: string;
327
+ /** Milliseconds for one request (default 30 000). */
328
+ timeout?: number;
329
+ }
320
330
  interface LlmJudgeAssertion {
321
331
  type: 'llm-judge';
322
332
  criteria: string;
323
- provider?: Partial<ProviderConfig>;
333
+ provider?: Partial<ProviderConfig> | JevJudgeConfig;
324
334
  /** The minimum judge score (0–1). Not the eval's `pass_threshold`, which is a share of runs. */
325
335
  pass_threshold?: number;
326
336
  }
@@ -593,6 +603,27 @@ interface Embedder {
593
603
  embed(texts: string[]): Promise<Float32Array[]>;
594
604
  }
595
605
 
606
+ /** What a decision judge is asked: does `output`, the answer to `input`, meet `criteria`? */
607
+ interface DecisionQuestion {
608
+ criteria: string;
609
+ output: string;
610
+ input?: string;
611
+ }
612
+ /** A decision judge's answer: the probability of "yes", and the exact model version that gave it. */
613
+ interface DecisionAnswer {
614
+ probability: number;
615
+ model: string;
616
+ }
617
+ interface Judge {
618
+ /** Ask the judge LLM a prompt and return its raw text response. */
619
+ ask(prompt: string): Promise<string>;
620
+ /**
621
+ * Only a decision model has it (the experimental `jev` judge of an `llm-judge` check): the probability, 0 to 1,
622
+ * that the answer meets the criteria. Such a judge gives no reason, and its `ask` throws.
623
+ */
624
+ decide?(question: DecisionQuestion): Promise<DecisionAnswer>;
625
+ }
626
+
596
627
  interface Cache {
597
628
  /** Return the cached completion, or undefined on a miss. `maxAgeMs` (optional) expires old entries. */
598
629
  get(key: string, opts?: {
@@ -640,6 +671,41 @@ interface AgentServer {
640
671
  /** Opens a session with the server named in `mcp.servers`; a failure rejects with a message already masked. */
641
672
  type AgentConnect = (server: string, timeoutMs: number) => Promise<AgentServer>;
642
673
 
674
+ interface RowParams {
675
+ template: string;
676
+ assertions: AssertionConfig[];
677
+ row: DatasetRow;
678
+ providerConfig: ProviderConfig;
679
+ provider: Provider;
680
+ embedder: Embedder;
681
+ cache: Cache;
682
+ now: () => number;
683
+ dryRun: boolean;
684
+ noCache: boolean;
685
+ /** Every row must be answered from the cache; a miss ends the row without a model call. */
686
+ cacheStrict?: boolean;
687
+ /** Entries older than this count as a miss. */
688
+ cacheMaxAgeMs?: number;
689
+ /** Test seam: the policy version in the key (default CACHE_POLICY_VERSION). */
690
+ policyVersion?: number;
691
+ /** Which repeat of the row this is, from 0 (`runs`); from 1 on it has a cache key of its own. */
692
+ attempt?: number;
693
+ /**
694
+ * The provider of a judge config other than the eval's: an `llm-judge` with a `provider` of its own
695
+ * (plune-ai/cli#373). Without it such a check errors the row rather than be judged by the wrong model.
696
+ */
697
+ resolveJudge?: (cfg: ProviderConfig) => Provider;
698
+ /** Builds the experimental `jev` judge of an `llm-judge` check; `onCost` is charged to the row. Without it such a check errors the row. */
699
+ jevJudge?: (cfg: JevJudgeConfig, onCost: (cost: {
700
+ cost_usd: number;
701
+ priced?: boolean;
702
+ }) => void) => Judge;
703
+ /** Prices a `jev` judge call of so many input tokens, for a dry run. Without it a dry run leaves such a check out of the estimate. */
704
+ jevCost?: (model: string, inputTokens: number) => {
705
+ cost_usd: number;
706
+ priced?: boolean;
707
+ };
708
+ }
643
709
  interface RunDeps {
644
710
  resolveProvider(cfg: ProviderConfig): Provider;
645
711
  embedder: Embedder;
@@ -649,6 +715,10 @@ interface RunDeps {
649
715
  baseDir: string;
650
716
  /** Opens a session with an `mcp.servers` entry, one per agentic row. Needed only by an eval with `mcp`. */
651
717
  connectMcp?: AgentConnect;
718
+ /** Builds the experimental `jev` judge of an `llm-judge` check. A run without it errors the rows of such a check. */
719
+ jevJudge?: RowParams['jevJudge'];
720
+ /** Prices a `jev` judge call for a dry run. */
721
+ jevCost?: RowParams['jevCost'];
652
722
  }
653
723
 
654
724
  interface RunOptions {
@@ -757,27 +827,20 @@ declare const assertionConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
757
827
  }, z.core.$strip>, z.ZodObject<{
758
828
  type: z.ZodLiteral<"llm-judge">;
759
829
  criteria: z.ZodString;
760
- provider: z.ZodOptional<z.ZodObject<{
761
- type: z.ZodOptional<z.ZodEnum<{
762
- anthropic: "anthropic";
763
- openai: "openai";
764
- openrouter: "openrouter";
765
- }>>;
766
- model: z.ZodOptional<z.ZodString>;
767
- temperature: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
768
- max_tokens: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
769
- concurrency: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
770
- timeout: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
771
- max_retries: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
772
- reasoning_effort: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
773
- none: "none";
774
- minimal: "minimal";
775
- low: "low";
776
- medium: "medium";
777
- high: "high";
778
- xhigh: "xhigh";
779
- }>>>;
780
- }, z.core.$strip>>;
830
+ provider: z.ZodOptional<z.ZodPipe<z.ZodAny, z.ZodTransform<{
831
+ type: "jev";
832
+ model: string;
833
+ timeout?: number | undefined;
834
+ } | {
835
+ type?: "anthropic" | "openai" | "openrouter" | undefined;
836
+ model?: string | undefined;
837
+ temperature?: number | undefined;
838
+ max_tokens?: number | undefined;
839
+ concurrency?: number | undefined;
840
+ timeout?: number | undefined;
841
+ max_retries?: number | undefined;
842
+ reasoning_effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | undefined;
843
+ }, any>>>;
781
844
  pass_threshold: z.ZodOptional<z.ZodNumber>;
782
845
  }, z.core.$strip>, z.ZodObject<{
783
846
  type: z.ZodLiteral<"semantic-similarity">;
package/dist/index.d.ts CHANGED
@@ -317,10 +317,20 @@ interface JsonSchemaAssertion {
317
317
  schema: object;
318
318
  extract?: 'auto' | 'strict';
319
319
  }
320
+ /**
321
+ * The experimental Jev judge of an `llm-judge` check. A decision model, not a text model: it cannot be an eval's
322
+ * provider, takes none of the eval provider's fields, and its model is always named.
323
+ */
324
+ interface JevJudgeConfig {
325
+ type: 'jev';
326
+ model: string;
327
+ /** Milliseconds for one request (default 30 000). */
328
+ timeout?: number;
329
+ }
320
330
  interface LlmJudgeAssertion {
321
331
  type: 'llm-judge';
322
332
  criteria: string;
323
- provider?: Partial<ProviderConfig>;
333
+ provider?: Partial<ProviderConfig> | JevJudgeConfig;
324
334
  /** The minimum judge score (0–1). Not the eval's `pass_threshold`, which is a share of runs. */
325
335
  pass_threshold?: number;
326
336
  }
@@ -593,6 +603,27 @@ interface Embedder {
593
603
  embed(texts: string[]): Promise<Float32Array[]>;
594
604
  }
595
605
 
606
+ /** What a decision judge is asked: does `output`, the answer to `input`, meet `criteria`? */
607
+ interface DecisionQuestion {
608
+ criteria: string;
609
+ output: string;
610
+ input?: string;
611
+ }
612
+ /** A decision judge's answer: the probability of "yes", and the exact model version that gave it. */
613
+ interface DecisionAnswer {
614
+ probability: number;
615
+ model: string;
616
+ }
617
+ interface Judge {
618
+ /** Ask the judge LLM a prompt and return its raw text response. */
619
+ ask(prompt: string): Promise<string>;
620
+ /**
621
+ * Only a decision model has it (the experimental `jev` judge of an `llm-judge` check): the probability, 0 to 1,
622
+ * that the answer meets the criteria. Such a judge gives no reason, and its `ask` throws.
623
+ */
624
+ decide?(question: DecisionQuestion): Promise<DecisionAnswer>;
625
+ }
626
+
596
627
  interface Cache {
597
628
  /** Return the cached completion, or undefined on a miss. `maxAgeMs` (optional) expires old entries. */
598
629
  get(key: string, opts?: {
@@ -640,6 +671,41 @@ interface AgentServer {
640
671
  /** Opens a session with the server named in `mcp.servers`; a failure rejects with a message already masked. */
641
672
  type AgentConnect = (server: string, timeoutMs: number) => Promise<AgentServer>;
642
673
 
674
+ interface RowParams {
675
+ template: string;
676
+ assertions: AssertionConfig[];
677
+ row: DatasetRow;
678
+ providerConfig: ProviderConfig;
679
+ provider: Provider;
680
+ embedder: Embedder;
681
+ cache: Cache;
682
+ now: () => number;
683
+ dryRun: boolean;
684
+ noCache: boolean;
685
+ /** Every row must be answered from the cache; a miss ends the row without a model call. */
686
+ cacheStrict?: boolean;
687
+ /** Entries older than this count as a miss. */
688
+ cacheMaxAgeMs?: number;
689
+ /** Test seam: the policy version in the key (default CACHE_POLICY_VERSION). */
690
+ policyVersion?: number;
691
+ /** Which repeat of the row this is, from 0 (`runs`); from 1 on it has a cache key of its own. */
692
+ attempt?: number;
693
+ /**
694
+ * The provider of a judge config other than the eval's: an `llm-judge` with a `provider` of its own
695
+ * (plune-ai/cli#373). Without it such a check errors the row rather than be judged by the wrong model.
696
+ */
697
+ resolveJudge?: (cfg: ProviderConfig) => Provider;
698
+ /** Builds the experimental `jev` judge of an `llm-judge` check; `onCost` is charged to the row. Without it such a check errors the row. */
699
+ jevJudge?: (cfg: JevJudgeConfig, onCost: (cost: {
700
+ cost_usd: number;
701
+ priced?: boolean;
702
+ }) => void) => Judge;
703
+ /** Prices a `jev` judge call of so many input tokens, for a dry run. Without it a dry run leaves such a check out of the estimate. */
704
+ jevCost?: (model: string, inputTokens: number) => {
705
+ cost_usd: number;
706
+ priced?: boolean;
707
+ };
708
+ }
643
709
  interface RunDeps {
644
710
  resolveProvider(cfg: ProviderConfig): Provider;
645
711
  embedder: Embedder;
@@ -649,6 +715,10 @@ interface RunDeps {
649
715
  baseDir: string;
650
716
  /** Opens a session with an `mcp.servers` entry, one per agentic row. Needed only by an eval with `mcp`. */
651
717
  connectMcp?: AgentConnect;
718
+ /** Builds the experimental `jev` judge of an `llm-judge` check. A run without it errors the rows of such a check. */
719
+ jevJudge?: RowParams['jevJudge'];
720
+ /** Prices a `jev` judge call for a dry run. */
721
+ jevCost?: RowParams['jevCost'];
652
722
  }
653
723
 
654
724
  interface RunOptions {
@@ -757,27 +827,20 @@ declare const assertionConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
757
827
  }, z.core.$strip>, z.ZodObject<{
758
828
  type: z.ZodLiteral<"llm-judge">;
759
829
  criteria: z.ZodString;
760
- provider: z.ZodOptional<z.ZodObject<{
761
- type: z.ZodOptional<z.ZodEnum<{
762
- anthropic: "anthropic";
763
- openai: "openai";
764
- openrouter: "openrouter";
765
- }>>;
766
- model: z.ZodOptional<z.ZodString>;
767
- temperature: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
768
- max_tokens: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
769
- concurrency: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
770
- timeout: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
771
- max_retries: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
772
- reasoning_effort: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
773
- none: "none";
774
- minimal: "minimal";
775
- low: "low";
776
- medium: "medium";
777
- high: "high";
778
- xhigh: "xhigh";
779
- }>>>;
780
- }, z.core.$strip>>;
830
+ provider: z.ZodOptional<z.ZodPipe<z.ZodAny, z.ZodTransform<{
831
+ type: "jev";
832
+ model: string;
833
+ timeout?: number | undefined;
834
+ } | {
835
+ type?: "anthropic" | "openai" | "openrouter" | undefined;
836
+ model?: string | undefined;
837
+ temperature?: number | undefined;
838
+ max_tokens?: number | undefined;
839
+ concurrency?: number | undefined;
840
+ timeout?: number | undefined;
841
+ max_retries?: number | undefined;
842
+ reasoning_effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | undefined;
843
+ }, any>>>;
781
844
  pass_threshold: z.ZodOptional<z.ZodNumber>;
782
845
  }, z.core.$strip>, z.ZodObject<{
783
846
  type: z.ZodLiteral<"semantic-similarity">;