@plune-ai/cli 0.39.14 → 0.39.15

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,25 @@ 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
+ model: import_zod.z.string().min(1),
1178
+ timeout: providerTimeoutSchema.optional()
1179
+ });
1180
+ var partialProviderSchema = providerConfigSchema.partial();
1181
+ var llmJudgeProviderField = import_zod.z.any().transform((value, ctx) => {
1182
+ const jev = typeof value === "object" && value !== null && value.type === "jev";
1183
+ const r = (jev ? jevJudgeSchema : partialProviderSchema).safeParse(value);
1184
+ if (r.success) return r.data;
1185
+ for (const issue of r.error.issues) ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
1186
+ return import_zod.z.NEVER;
1187
+ });
1175
1188
  var llmJudgeAssertionSchema = import_zod.z.object({
1176
1189
  type: import_zod.z.literal("llm-judge"),
1177
1190
  criteria: import_zod.z.string().min(1),
1178
- provider: providerConfigSchema.partial().optional(),
1191
+ // `type: jev` is a judge of another kind (a decision model) with fields of its own; anything else is the eval's
1192
+ // provider with these fields over it.
1193
+ provider: llmJudgeProviderField.optional(),
1179
1194
  // The judge's score floor, not the eval's share of passing runs (that one is `evalRepeatsShape`).
1180
1195
  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
1196
  });
@@ -1757,6 +1772,8 @@ var PRICE_TABLE = {
1757
1772
  "claude-fable-5-1": { input_per_1k_usd: 0.01, output_per_1k_usd: 0.05 },
1758
1773
  "claude-opus-5-5": { input_per_1k_usd: 4e-3, output_per_1k_usd: 0.02 },
1759
1774
  "claude-sonnet-5-5": { input_per_1k_usd: 2e-3, output_per_1k_usd: 0.01 },
1775
+ // Read on 2026-11-24 from https://openrouter.ai/api/v1/models, which passes Anthropic's list price through.
1776
+ "claude-haiku-5-5": { input_per_1k_usd: 1e-4, output_per_1k_usd: 5e-4 },
1760
1777
  "claude-haiku-4-5": { input_per_1k_usd: 1e-3, output_per_1k_usd: 5e-3 },
1761
1778
  // The dated id of the same model; a config may name either.
1762
1779
  "claude-haiku-4-5-20251001": { input_per_1k_usd: 1e-3, output_per_1k_usd: 5e-3 },
@@ -2788,6 +2805,18 @@ var llmJudge = {
2788
2805
  }
2789
2806
  const criteria = interpolate(ctx.params.criteria, ctx);
2790
2807
  const threshold = ctx.params.pass_threshold ?? DEFAULT_PASS_THRESHOLD;
2808
+ if (ctx.judge.decide !== void 0) {
2809
+ const p = await ctx.judge.decide({
2810
+ criteria,
2811
+ output: ctx.output,
2812
+ ...ctx.input !== void 0 ? { input: ctx.input } : {}
2813
+ });
2814
+ return {
2815
+ passed: p >= threshold,
2816
+ score: p,
2817
+ reason: `probability ${p.toFixed(3)} that the answer meets the criteria vs threshold ${threshold}; this judge gives no reason`
2818
+ };
2819
+ }
2791
2820
  const { score, reason } = parseScored(
2792
2821
  await askJson(ctx.judge, prompt(criteria, ctx.output, ctx.input))
2793
2822
  );
@@ -4132,9 +4161,23 @@ async function assess(p, output, input, transcript) {
4132
4161
  let assertionError;
4133
4162
  for (const assertion of p.assertions) {
4134
4163
  const own2 = assertion.type === "llm-judge" ? assertion.provider : void 0;
4135
- const judgeCfg = own2 === void 0 ? p.providerConfig : { ...p.providerConfig, ...own2 };
4164
+ const jev = own2?.type === "jev" ? own2 : void 0;
4165
+ const judgeCfg = own2 === void 0 || own2.type === "jev" ? p.providerConfig : { ...p.providerConfig, ...own2 };
4136
4166
  let judgedBy;
4137
4167
  const judge = () => {
4168
+ if (jev !== void 0) {
4169
+ if (p.jevJudge === void 0) throw new Error("this run cannot build the jev judge of an llm-judge check");
4170
+ const inner2 = p.jevJudge(jev, (usd) => {
4171
+ judgeCost += usd;
4172
+ });
4173
+ return {
4174
+ ask: (q) => inner2.ask(q),
4175
+ decide: (q) => {
4176
+ judgedBy = `jev/${jev.model}`;
4177
+ return inner2.decide(q);
4178
+ }
4179
+ };
4180
+ }
4138
4181
  let provider = p.provider;
4139
4182
  if (own2 !== void 0) {
4140
4183
  if (p.resolveJudge === void 0)
@@ -4495,6 +4538,7 @@ async function runOrchestration(config, options, deps) {
4495
4538
  providerConfig,
4496
4539
  provider,
4497
4540
  resolveJudge,
4541
+ ...deps.jevJudge !== void 0 ? { jevJudge: deps.jevJudge } : {},
4498
4542
  embedder: deps.embedder,
4499
4543
  cache: deps.cache,
4500
4544
  now: deps.now,
@@ -4596,6 +4640,89 @@ function typeName(value) {
4596
4640
  return value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
4597
4641
  }
4598
4642
 
4643
+ // src/judge/jev.ts
4644
+ init_cjs_shims();
4645
+ var JEV_BASE_URL = "https://api.typesafe.ai";
4646
+ var JEV_KEY_ENV = "TYPESAFE_API_KEY";
4647
+ var JEV_MAX_STATE_CHARS = 16e3;
4648
+ var JEV_USD_PER_1M_INPUT_TOKENS = 0.042;
4649
+ var DEFAULT_TIMEOUT_MS = 3e4;
4650
+ var INSTRUCTIONS = "Does the answer meet the criterion?";
4651
+ var YES = "the answer meets the criterion";
4652
+ var NO = "the answer does not meet the criterion";
4653
+ function jevState(q) {
4654
+ const request = q.input === void 0 ? "" : `Request:
4655
+ ${q.input}
4656
+
4657
+ `;
4658
+ return `${request}Answer:
4659
+ ${q.output}
4660
+
4661
+ Criterion:
4662
+ ${q.criteria}`;
4663
+ }
4664
+ function probability(json) {
4665
+ const answer = json?.answers?.q;
4666
+ const p = answer?.type === "noul" ? answer.noul : void 0;
4667
+ if (typeof p !== "number" || !Number.isFinite(p) || p < 0 || p > 1)
4668
+ throw new ProviderError("JEV_ANSWER", "jev returned no probability for the question asked");
4669
+ return p;
4670
+ }
4671
+ function makeJevJudge(cfg, deps) {
4672
+ return {
4673
+ ask: () => Promise.reject(new Error("a jev judge answers a yes-or-no question only: it cannot judge this kind of check")),
4674
+ async decide(q) {
4675
+ const key = deps.env[JEV_KEY_ENV];
4676
+ if (key === void 0 || key === "")
4677
+ throw new AuthError(`${JEV_KEY_ENV} is not set: the jev judge of an llm-judge check needs it`, JEV_KEY_ENV);
4678
+ const state = jevState(q);
4679
+ if (state.length > JEV_MAX_STATE_CHARS)
4680
+ throw new ProviderError(
4681
+ "JEV_INPUT_TOO_LONG",
4682
+ `the request, answer and criterion are ${state.length} characters together; a jev judge takes ${JEV_MAX_STATE_CHARS}. Nothing was sent`
4683
+ );
4684
+ const body = JSON.stringify({
4685
+ state,
4686
+ model: cfg.model,
4687
+ questions: { q: { type: "noul", instructions: INSTRUCTIONS, criteria: { true: YES, false: NO } } }
4688
+ });
4689
+ const send = async () => {
4690
+ try {
4691
+ return await deps.fetchFn(`${JEV_BASE_URL}/v1/systemone`, {
4692
+ method: "POST",
4693
+ headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
4694
+ body,
4695
+ redirect: "error",
4696
+ signal: AbortSignal.timeout(cfg.timeout ?? DEFAULT_TIMEOUT_MS)
4697
+ });
4698
+ } catch (err) {
4699
+ throw new ProviderError("JEV_UNREACHABLE", `jev did not answer: ${err instanceof Error ? err.message : String(err)}`);
4700
+ }
4701
+ };
4702
+ let res = await send();
4703
+ if (res.status === 429 || res.status >= 500) res = await send();
4704
+ if (res.status === 401 || res.status === 403)
4705
+ throw new AuthError(`jev refused the key in ${JEV_KEY_ENV} (HTTP ${res.status})`, JEV_KEY_ENV);
4706
+ if (!res.ok) throw new ProviderError("JEV_HTTP", `jev answered HTTP ${res.status}`);
4707
+ const json = await res.json();
4708
+ const p = probability(json);
4709
+ const tokens = json.usage?.input_tokens;
4710
+ const billed = typeof tokens === "number" && tokens >= 0 ? tokens : Math.ceil(state.length / 3);
4711
+ deps.onCost(billed / 1e6 * JEV_USD_PER_1M_INPUT_TOKENS);
4712
+ return p;
4713
+ }
4714
+ };
4715
+ }
4716
+ var warned = false;
4717
+ function warnJevExperimental(write = (l) => process.stderr.write(l)) {
4718
+ if (warned) return;
4719
+ warned = true;
4720
+ write(
4721
+ `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
4722
+ `
4723
+ );
4724
+ }
4725
+
4599
4726
  // src/cli/commands/run.ts
4600
4727
  var NOOP_CACHE = { get: () => void 0, set: () => {
4601
4728
  }, delete: () => {
@@ -4691,7 +4818,14 @@ function buildRealDeps(config, baseDir, dryRun) {
4691
4818
  now: Date.now,
4692
4819
  loadDataset,
4693
4820
  baseDir,
4694
- connectMcp: makeMcpConnect(config, baseDir, process.env)
4821
+ connectMcp: makeMcpConnect(config, baseDir, process.env),
4822
+ // A dry run stops before any check, so it never builds this judge. Mock mode sends nothing: no jev judge there.
4823
+ ...isMockMode(process.env) ? {} : {
4824
+ jevJudge: (cfg, onCost) => {
4825
+ warnJevExperimental();
4826
+ return makeJevJudge(cfg, { env: process.env, fetchFn: fetch, onCost });
4827
+ }
4828
+ }
4695
4829
  };
4696
4830
  }
4697
4831
  function persist(result, baseDir) {
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,22 @@ 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
+ interface Judge {
613
+ /** Ask the judge LLM a prompt and return its raw text response. */
614
+ ask(prompt: string): Promise<string>;
615
+ /**
616
+ * Only a decision model has it (the experimental `jev` judge of an `llm-judge` check): the probability, 0 to 1,
617
+ * that the answer meets the criteria. Such a judge gives no reason, and its `ask` throws.
618
+ */
619
+ decide?(question: DecisionQuestion): Promise<number>;
620
+ }
621
+
596
622
  interface Cache {
597
623
  /** Return the cached completion, or undefined on a miss. `maxAgeMs` (optional) expires old entries. */
598
624
  get(key: string, opts?: {
@@ -640,6 +666,33 @@ interface AgentServer {
640
666
  /** Opens a session with the server named in `mcp.servers`; a failure rejects with a message already masked. */
641
667
  type AgentConnect = (server: string, timeoutMs: number) => Promise<AgentServer>;
642
668
 
669
+ interface RowParams {
670
+ template: string;
671
+ assertions: AssertionConfig[];
672
+ row: DatasetRow;
673
+ providerConfig: ProviderConfig;
674
+ provider: Provider;
675
+ embedder: Embedder;
676
+ cache: Cache;
677
+ now: () => number;
678
+ dryRun: boolean;
679
+ noCache: boolean;
680
+ /** Every row must be answered from the cache; a miss ends the row without a model call. */
681
+ cacheStrict?: boolean;
682
+ /** Entries older than this count as a miss. */
683
+ cacheMaxAgeMs?: number;
684
+ /** Test seam: the policy version in the key (default CACHE_POLICY_VERSION). */
685
+ policyVersion?: number;
686
+ /** Which repeat of the row this is, from 0 (`runs`); from 1 on it has a cache key of its own. */
687
+ attempt?: number;
688
+ /**
689
+ * The provider of a judge config other than the eval's: an `llm-judge` with a `provider` of its own
690
+ * (plune-ai/cli#373). Without it such a check errors the row rather than be judged by the wrong model.
691
+ */
692
+ resolveJudge?: (cfg: ProviderConfig) => Provider;
693
+ /** Builds the experimental `jev` judge of an `llm-judge` check; `onCost` is charged to the row. Without it such a check errors the row. */
694
+ jevJudge?: (cfg: JevJudgeConfig, onCost: (usd: number) => void) => Judge;
695
+ }
643
696
  interface RunDeps {
644
697
  resolveProvider(cfg: ProviderConfig): Provider;
645
698
  embedder: Embedder;
@@ -649,6 +702,8 @@ interface RunDeps {
649
702
  baseDir: string;
650
703
  /** Opens a session with an `mcp.servers` entry, one per agentic row. Needed only by an eval with `mcp`. */
651
704
  connectMcp?: AgentConnect;
705
+ /** Builds the experimental `jev` judge of an `llm-judge` check. A run without it errors the rows of such a check. */
706
+ jevJudge?: RowParams['jevJudge'];
652
707
  }
653
708
 
654
709
  interface RunOptions {
@@ -757,27 +812,20 @@ declare const assertionConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
757
812
  }, z.core.$strip>, z.ZodObject<{
758
813
  type: z.ZodLiteral<"llm-judge">;
759
814
  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>>;
815
+ provider: z.ZodOptional<z.ZodPipe<z.ZodAny, z.ZodTransform<{
816
+ type: "jev";
817
+ model: string;
818
+ timeout?: number | undefined;
819
+ } | {
820
+ type?: "anthropic" | "openai" | "openrouter" | undefined;
821
+ model?: string | undefined;
822
+ temperature?: number | undefined;
823
+ max_tokens?: number | undefined;
824
+ concurrency?: number | undefined;
825
+ timeout?: number | undefined;
826
+ max_retries?: number | undefined;
827
+ reasoning_effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | undefined;
828
+ }, any>>>;
781
829
  pass_threshold: z.ZodOptional<z.ZodNumber>;
782
830
  }, z.core.$strip>, z.ZodObject<{
783
831
  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,22 @@ 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
+ interface Judge {
613
+ /** Ask the judge LLM a prompt and return its raw text response. */
614
+ ask(prompt: string): Promise<string>;
615
+ /**
616
+ * Only a decision model has it (the experimental `jev` judge of an `llm-judge` check): the probability, 0 to 1,
617
+ * that the answer meets the criteria. Such a judge gives no reason, and its `ask` throws.
618
+ */
619
+ decide?(question: DecisionQuestion): Promise<number>;
620
+ }
621
+
596
622
  interface Cache {
597
623
  /** Return the cached completion, or undefined on a miss. `maxAgeMs` (optional) expires old entries. */
598
624
  get(key: string, opts?: {
@@ -640,6 +666,33 @@ interface AgentServer {
640
666
  /** Opens a session with the server named in `mcp.servers`; a failure rejects with a message already masked. */
641
667
  type AgentConnect = (server: string, timeoutMs: number) => Promise<AgentServer>;
642
668
 
669
+ interface RowParams {
670
+ template: string;
671
+ assertions: AssertionConfig[];
672
+ row: DatasetRow;
673
+ providerConfig: ProviderConfig;
674
+ provider: Provider;
675
+ embedder: Embedder;
676
+ cache: Cache;
677
+ now: () => number;
678
+ dryRun: boolean;
679
+ noCache: boolean;
680
+ /** Every row must be answered from the cache; a miss ends the row without a model call. */
681
+ cacheStrict?: boolean;
682
+ /** Entries older than this count as a miss. */
683
+ cacheMaxAgeMs?: number;
684
+ /** Test seam: the policy version in the key (default CACHE_POLICY_VERSION). */
685
+ policyVersion?: number;
686
+ /** Which repeat of the row this is, from 0 (`runs`); from 1 on it has a cache key of its own. */
687
+ attempt?: number;
688
+ /**
689
+ * The provider of a judge config other than the eval's: an `llm-judge` with a `provider` of its own
690
+ * (plune-ai/cli#373). Without it such a check errors the row rather than be judged by the wrong model.
691
+ */
692
+ resolveJudge?: (cfg: ProviderConfig) => Provider;
693
+ /** Builds the experimental `jev` judge of an `llm-judge` check; `onCost` is charged to the row. Without it such a check errors the row. */
694
+ jevJudge?: (cfg: JevJudgeConfig, onCost: (usd: number) => void) => Judge;
695
+ }
643
696
  interface RunDeps {
644
697
  resolveProvider(cfg: ProviderConfig): Provider;
645
698
  embedder: Embedder;
@@ -649,6 +702,8 @@ interface RunDeps {
649
702
  baseDir: string;
650
703
  /** Opens a session with an `mcp.servers` entry, one per agentic row. Needed only by an eval with `mcp`. */
651
704
  connectMcp?: AgentConnect;
705
+ /** Builds the experimental `jev` judge of an `llm-judge` check. A run without it errors the rows of such a check. */
706
+ jevJudge?: RowParams['jevJudge'];
652
707
  }
653
708
 
654
709
  interface RunOptions {
@@ -757,27 +812,20 @@ declare const assertionConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
757
812
  }, z.core.$strip>, z.ZodObject<{
758
813
  type: z.ZodLiteral<"llm-judge">;
759
814
  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>>;
815
+ provider: z.ZodOptional<z.ZodPipe<z.ZodAny, z.ZodTransform<{
816
+ type: "jev";
817
+ model: string;
818
+ timeout?: number | undefined;
819
+ } | {
820
+ type?: "anthropic" | "openai" | "openrouter" | undefined;
821
+ model?: string | undefined;
822
+ temperature?: number | undefined;
823
+ max_tokens?: number | undefined;
824
+ concurrency?: number | undefined;
825
+ timeout?: number | undefined;
826
+ max_retries?: number | undefined;
827
+ reasoning_effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | undefined;
828
+ }, any>>>;
781
829
  pass_threshold: z.ZodOptional<z.ZodNumber>;
782
830
  }, z.core.$strip>, z.ZodObject<{
783
831
  type: z.ZodLiteral<"semantic-similarity">;
package/dist/index.js CHANGED
@@ -1134,10 +1134,25 @@ var jsonSchemaAssertionSchema = z.object({
1134
1134
  schema: z.record(z.string(), z.unknown()),
1135
1135
  extract: z.enum(["auto", "strict"]).optional()
1136
1136
  });
1137
+ var jevJudgeSchema = z.strictObject({
1138
+ type: z.literal("jev"),
1139
+ model: z.string().min(1),
1140
+ timeout: providerTimeoutSchema.optional()
1141
+ });
1142
+ var partialProviderSchema = providerConfigSchema.partial();
1143
+ var llmJudgeProviderField = z.any().transform((value, ctx) => {
1144
+ const jev = typeof value === "object" && value !== null && value.type === "jev";
1145
+ const r = (jev ? jevJudgeSchema : partialProviderSchema).safeParse(value);
1146
+ if (r.success) return r.data;
1147
+ for (const issue of r.error.issues) ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
1148
+ return z.NEVER;
1149
+ });
1137
1150
  var llmJudgeAssertionSchema = z.object({
1138
1151
  type: z.literal("llm-judge"),
1139
1152
  criteria: z.string().min(1),
1140
- provider: providerConfigSchema.partial().optional(),
1153
+ // `type: jev` is a judge of another kind (a decision model) with fields of its own; anything else is the eval's
1154
+ // provider with these fields over it.
1155
+ provider: llmJudgeProviderField.optional(),
1141
1156
  // The judge's score floor, not the eval's share of passing runs (that one is `evalRepeatsShape`).
1142
1157
  pass_threshold: 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()
1143
1158
  });
@@ -1719,6 +1734,8 @@ var PRICE_TABLE = {
1719
1734
  "claude-fable-5-1": { input_per_1k_usd: 0.01, output_per_1k_usd: 0.05 },
1720
1735
  "claude-opus-5-5": { input_per_1k_usd: 4e-3, output_per_1k_usd: 0.02 },
1721
1736
  "claude-sonnet-5-5": { input_per_1k_usd: 2e-3, output_per_1k_usd: 0.01 },
1737
+ // Read on 2026-11-24 from https://openrouter.ai/api/v1/models, which passes Anthropic's list price through.
1738
+ "claude-haiku-5-5": { input_per_1k_usd: 1e-4, output_per_1k_usd: 5e-4 },
1722
1739
  "claude-haiku-4-5": { input_per_1k_usd: 1e-3, output_per_1k_usd: 5e-3 },
1723
1740
  // The dated id of the same model; a config may name either.
1724
1741
  "claude-haiku-4-5-20251001": { input_per_1k_usd: 1e-3, output_per_1k_usd: 5e-3 },
@@ -2750,6 +2767,18 @@ var llmJudge = {
2750
2767
  }
2751
2768
  const criteria = interpolate(ctx.params.criteria, ctx);
2752
2769
  const threshold = ctx.params.pass_threshold ?? DEFAULT_PASS_THRESHOLD;
2770
+ if (ctx.judge.decide !== void 0) {
2771
+ const p = await ctx.judge.decide({
2772
+ criteria,
2773
+ output: ctx.output,
2774
+ ...ctx.input !== void 0 ? { input: ctx.input } : {}
2775
+ });
2776
+ return {
2777
+ passed: p >= threshold,
2778
+ score: p,
2779
+ reason: `probability ${p.toFixed(3)} that the answer meets the criteria vs threshold ${threshold}; this judge gives no reason`
2780
+ };
2781
+ }
2753
2782
  const { score, reason } = parseScored(
2754
2783
  await askJson(ctx.judge, prompt(criteria, ctx.output, ctx.input))
2755
2784
  );
@@ -4094,9 +4123,23 @@ async function assess(p, output, input, transcript) {
4094
4123
  let assertionError;
4095
4124
  for (const assertion of p.assertions) {
4096
4125
  const own2 = assertion.type === "llm-judge" ? assertion.provider : void 0;
4097
- const judgeCfg = own2 === void 0 ? p.providerConfig : { ...p.providerConfig, ...own2 };
4126
+ const jev = own2?.type === "jev" ? own2 : void 0;
4127
+ const judgeCfg = own2 === void 0 || own2.type === "jev" ? p.providerConfig : { ...p.providerConfig, ...own2 };
4098
4128
  let judgedBy;
4099
4129
  const judge = () => {
4130
+ if (jev !== void 0) {
4131
+ if (p.jevJudge === void 0) throw new Error("this run cannot build the jev judge of an llm-judge check");
4132
+ const inner2 = p.jevJudge(jev, (usd) => {
4133
+ judgeCost += usd;
4134
+ });
4135
+ return {
4136
+ ask: (q) => inner2.ask(q),
4137
+ decide: (q) => {
4138
+ judgedBy = `jev/${jev.model}`;
4139
+ return inner2.decide(q);
4140
+ }
4141
+ };
4142
+ }
4100
4143
  let provider = p.provider;
4101
4144
  if (own2 !== void 0) {
4102
4145
  if (p.resolveJudge === void 0)
@@ -4457,6 +4500,7 @@ async function runOrchestration(config, options, deps) {
4457
4500
  providerConfig,
4458
4501
  provider,
4459
4502
  resolveJudge,
4503
+ ...deps.jevJudge !== void 0 ? { jevJudge: deps.jevJudge } : {},
4460
4504
  embedder: deps.embedder,
4461
4505
  cache: deps.cache,
4462
4506
  now: deps.now,
@@ -4558,6 +4602,89 @@ function typeName(value) {
4558
4602
  return value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
4559
4603
  }
4560
4604
 
4605
+ // src/judge/jev.ts
4606
+ init_esm_shims();
4607
+ var JEV_BASE_URL = "https://api.typesafe.ai";
4608
+ var JEV_KEY_ENV = "TYPESAFE_API_KEY";
4609
+ var JEV_MAX_STATE_CHARS = 16e3;
4610
+ var JEV_USD_PER_1M_INPUT_TOKENS = 0.042;
4611
+ var DEFAULT_TIMEOUT_MS = 3e4;
4612
+ var INSTRUCTIONS = "Does the answer meet the criterion?";
4613
+ var YES = "the answer meets the criterion";
4614
+ var NO = "the answer does not meet the criterion";
4615
+ function jevState(q) {
4616
+ const request = q.input === void 0 ? "" : `Request:
4617
+ ${q.input}
4618
+
4619
+ `;
4620
+ return `${request}Answer:
4621
+ ${q.output}
4622
+
4623
+ Criterion:
4624
+ ${q.criteria}`;
4625
+ }
4626
+ function probability(json) {
4627
+ const answer = json?.answers?.q;
4628
+ const p = answer?.type === "noul" ? answer.noul : void 0;
4629
+ if (typeof p !== "number" || !Number.isFinite(p) || p < 0 || p > 1)
4630
+ throw new ProviderError("JEV_ANSWER", "jev returned no probability for the question asked");
4631
+ return p;
4632
+ }
4633
+ function makeJevJudge(cfg, deps) {
4634
+ return {
4635
+ ask: () => Promise.reject(new Error("a jev judge answers a yes-or-no question only: it cannot judge this kind of check")),
4636
+ async decide(q) {
4637
+ const key = deps.env[JEV_KEY_ENV];
4638
+ if (key === void 0 || key === "")
4639
+ throw new AuthError(`${JEV_KEY_ENV} is not set: the jev judge of an llm-judge check needs it`, JEV_KEY_ENV);
4640
+ const state = jevState(q);
4641
+ if (state.length > JEV_MAX_STATE_CHARS)
4642
+ throw new ProviderError(
4643
+ "JEV_INPUT_TOO_LONG",
4644
+ `the request, answer and criterion are ${state.length} characters together; a jev judge takes ${JEV_MAX_STATE_CHARS}. Nothing was sent`
4645
+ );
4646
+ const body = JSON.stringify({
4647
+ state,
4648
+ model: cfg.model,
4649
+ questions: { q: { type: "noul", instructions: INSTRUCTIONS, criteria: { true: YES, false: NO } } }
4650
+ });
4651
+ const send = async () => {
4652
+ try {
4653
+ return await deps.fetchFn(`${JEV_BASE_URL}/v1/systemone`, {
4654
+ method: "POST",
4655
+ headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
4656
+ body,
4657
+ redirect: "error",
4658
+ signal: AbortSignal.timeout(cfg.timeout ?? DEFAULT_TIMEOUT_MS)
4659
+ });
4660
+ } catch (err) {
4661
+ throw new ProviderError("JEV_UNREACHABLE", `jev did not answer: ${err instanceof Error ? err.message : String(err)}`);
4662
+ }
4663
+ };
4664
+ let res = await send();
4665
+ if (res.status === 429 || res.status >= 500) res = await send();
4666
+ if (res.status === 401 || res.status === 403)
4667
+ throw new AuthError(`jev refused the key in ${JEV_KEY_ENV} (HTTP ${res.status})`, JEV_KEY_ENV);
4668
+ if (!res.ok) throw new ProviderError("JEV_HTTP", `jev answered HTTP ${res.status}`);
4669
+ const json = await res.json();
4670
+ const p = probability(json);
4671
+ const tokens = json.usage?.input_tokens;
4672
+ const billed = typeof tokens === "number" && tokens >= 0 ? tokens : Math.ceil(state.length / 3);
4673
+ deps.onCost(billed / 1e6 * JEV_USD_PER_1M_INPUT_TOKENS);
4674
+ return p;
4675
+ }
4676
+ };
4677
+ }
4678
+ var warned = false;
4679
+ function warnJevExperimental(write = (l) => process.stderr.write(l)) {
4680
+ if (warned) return;
4681
+ warned = true;
4682
+ write(
4683
+ `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
4684
+ `
4685
+ );
4686
+ }
4687
+
4561
4688
  // src/cli/commands/run.ts
4562
4689
  var NOOP_CACHE = { get: () => void 0, set: () => {
4563
4690
  }, delete: () => {
@@ -4653,7 +4780,14 @@ function buildRealDeps(config, baseDir, dryRun) {
4653
4780
  now: Date.now,
4654
4781
  loadDataset,
4655
4782
  baseDir,
4656
- connectMcp: makeMcpConnect(config, baseDir, process.env)
4783
+ connectMcp: makeMcpConnect(config, baseDir, process.env),
4784
+ // A dry run stops before any check, so it never builds this judge. Mock mode sends nothing: no jev judge there.
4785
+ ...isMockMode(process.env) ? {} : {
4786
+ jevJudge: (cfg, onCost) => {
4787
+ warnJevExperimental();
4788
+ return makeJevJudge(cfg, { env: process.env, fetchFn: fetch, onCost });
4789
+ }
4790
+ }
4657
4791
  };
4658
4792
  }
4659
4793
  function persist(result, baseDir) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plune-ai/cli",
3
- "version": "0.39.14",
3
+ "version": "0.39.15",
4
4
  "mcpName": "ai.plune/cli",
5
5
  "description": "AI-powered assertion testing for LLM apps — write assertions, run them against any provider, get a pass/fail report (local, CI, or diff).",
6
6
  "keywords": [