@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.js CHANGED
@@ -1134,10 +1134,26 @@ 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
+ // A full version, never an alias: `jev-latest` would change the judge under a run without a word.
1140
+ model: 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"),
1141
+ timeout: providerTimeoutSchema.optional()
1142
+ });
1143
+ var partialProviderSchema = providerConfigSchema.partial();
1144
+ var llmJudgeProviderField = z.any().transform((value, ctx) => {
1145
+ const jev = typeof value === "object" && value !== null && value.type === "jev";
1146
+ const r = (jev ? jevJudgeSchema : partialProviderSchema).safeParse(value);
1147
+ if (r.success) return r.data;
1148
+ for (const issue of r.error.issues) ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
1149
+ return z.NEVER;
1150
+ });
1137
1151
  var llmJudgeAssertionSchema = z.object({
1138
1152
  type: z.literal("llm-judge"),
1139
1153
  criteria: z.string().min(1),
1140
- provider: providerConfigSchema.partial().optional(),
1154
+ // `type: jev` is a judge of another kind (a decision model) with fields of its own; anything else is the eval's
1155
+ // provider with these fields over it.
1156
+ provider: llmJudgeProviderField.optional(),
1141
1157
  // The judge's score floor, not the eval's share of passing runs (that one is `evalRepeatsShape`).
1142
1158
  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
1159
  });
@@ -1714,11 +1730,16 @@ init_esm_shims();
1714
1730
  // src/providers/prices.ts
1715
1731
  init_esm_shims();
1716
1732
  var PRICE_TABLE = {
1733
+ // TypeSafe Jev, the experimental judge of `llm-judge`: input tokens only, its output is not billed.
1734
+ // Source: docs.typesafe.ai, read on 2026-11-24 (USD 0.042 per million input tokens).
1735
+ "jev-1.14.0": { input_per_1k_usd: 42e-6, output_per_1k_usd: 0 },
1717
1736
  // Anthropic, current models. Source: platform.claude.com/docs/en/about-claude/pricing — base
1718
1737
  // input and output tokens per million, read on 2026-09-29, kept here per thousand.
1719
1738
  "claude-fable-5-1": { input_per_1k_usd: 0.01, output_per_1k_usd: 0.05 },
1720
1739
  "claude-opus-5-5": { input_per_1k_usd: 4e-3, output_per_1k_usd: 0.02 },
1721
1740
  "claude-sonnet-5-5": { input_per_1k_usd: 2e-3, output_per_1k_usd: 0.01 },
1741
+ // Read on 2026-11-24 from https://openrouter.ai/api/v1/models, which passes Anthropic's list price through.
1742
+ "claude-haiku-5-5": { input_per_1k_usd: 1e-4, output_per_1k_usd: 5e-4 },
1722
1743
  "claude-haiku-4-5": { input_per_1k_usd: 1e-3, output_per_1k_usd: 5e-3 },
1723
1744
  // The dated id of the same model; a config may name either.
1724
1745
  "claude-haiku-4-5-20251001": { input_per_1k_usd: 1e-3, output_per_1k_usd: 5e-3 },
@@ -2750,6 +2771,18 @@ var llmJudge = {
2750
2771
  }
2751
2772
  const criteria = interpolate(ctx.params.criteria, ctx);
2752
2773
  const threshold = ctx.params.pass_threshold ?? DEFAULT_PASS_THRESHOLD;
2774
+ if (ctx.judge.decide !== void 0) {
2775
+ const { probability: p } = await ctx.judge.decide({
2776
+ criteria,
2777
+ output: ctx.output,
2778
+ ...ctx.input !== void 0 ? { input: ctx.input } : {}
2779
+ });
2780
+ return {
2781
+ passed: p >= threshold,
2782
+ score: p,
2783
+ reason: `probability ${p.toFixed(3)} that the answer meets the criteria vs threshold ${threshold}; this judge gives no reason`
2784
+ };
2785
+ }
2753
2786
  const { score, reason } = parseScored(
2754
2787
  await askJson(ctx.judge, prompt(criteria, ctx.output, ctx.input))
2755
2788
  );
@@ -4094,9 +4127,25 @@ async function assess(p, output, input, transcript) {
4094
4127
  let assertionError;
4095
4128
  for (const assertion of p.assertions) {
4096
4129
  const own2 = assertion.type === "llm-judge" ? assertion.provider : void 0;
4097
- const judgeCfg = own2 === void 0 ? p.providerConfig : { ...p.providerConfig, ...own2 };
4130
+ const jev = own2?.type === "jev" ? own2 : void 0;
4131
+ const judgeCfg = own2 === void 0 || own2.type === "jev" ? p.providerConfig : { ...p.providerConfig, ...own2 };
4098
4132
  let judgedBy;
4099
4133
  const judge = () => {
4134
+ if (jev !== void 0) {
4135
+ if (p.jevJudge === void 0) throw new Error("this run cannot build the jev judge of an llm-judge check");
4136
+ const inner2 = p.jevJudge(jev, (c) => {
4137
+ judgeCost += c.cost_usd;
4138
+ if (c.priced === false) judgeUnpriced = true;
4139
+ });
4140
+ return {
4141
+ ask: (q) => inner2.ask(q),
4142
+ decide: async (q) => {
4143
+ const answer = await inner2.decide(q);
4144
+ judgedBy = `jev/${answer.model}`;
4145
+ return answer;
4146
+ }
4147
+ };
4148
+ }
4100
4149
  let provider = p.provider;
4101
4150
  if (own2 !== void 0) {
4102
4151
  if (p.resolveJudge === void 0)
@@ -4160,7 +4209,15 @@ async function runRow(p) {
4160
4209
  if (p.dryRun) {
4161
4210
  const est = estimateUsage(prompt5, maxTokens);
4162
4211
  const cost = p.provider.estimateCost(est);
4163
- return dryRunRow(p.row.vars, { ...est, ...costFields(cost) });
4212
+ let judged = 0;
4213
+ let unpriced = cost.priced === false;
4214
+ for (const a of p.assertions) {
4215
+ if (a.type !== "llm-judge" || a.provider?.type !== "jev" || p.jevCost === void 0) continue;
4216
+ const c = p.jevCost(a.provider.model, Math.ceil((prompt5.length + maxTokens * 4 + a.criteria.length) / 3));
4217
+ judged += c.cost_usd;
4218
+ if (c.priced === false) unpriced = true;
4219
+ }
4220
+ return dryRunRow(p.row.vars, { ...est, cost_usd: cost.cost_usd + judged, ...unpriced ? { priced: false } : cost.priced === void 0 ? {} : { priced: cost.priced } });
4164
4221
  }
4165
4222
  const key = cacheKey(
4166
4223
  {
@@ -4457,6 +4514,8 @@ async function runOrchestration(config, options, deps) {
4457
4514
  providerConfig,
4458
4515
  provider,
4459
4516
  resolveJudge,
4517
+ ...deps.jevJudge !== void 0 ? { jevJudge: deps.jevJudge } : {},
4518
+ ...deps.jevCost !== void 0 ? { jevCost: deps.jevCost } : {},
4460
4519
  embedder: deps.embedder,
4461
4520
  cache: deps.cache,
4462
4521
  now: deps.now,
@@ -4558,6 +4617,113 @@ function typeName(value) {
4558
4617
  return value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
4559
4618
  }
4560
4619
 
4620
+ // src/judge/jev.ts
4621
+ init_esm_shims();
4622
+ var JEV_BASE_URL = "https://api.typesafe.ai";
4623
+ var JEV_KEY_ENV = "TYPESAFE_API_KEY";
4624
+ var JEV_MAX_STATE_CHARS = 16e3;
4625
+ var JEV_BASE_URL_ENV = "PLUNE_JEV_BASE_URL";
4626
+ var DEFAULT_TIMEOUT_MS = 3e4;
4627
+ var INSTRUCTIONS = "Does the answer meet the criterion?";
4628
+ var YES = "the answer meets the criterion";
4629
+ var NO = "the answer does not meet the criterion";
4630
+ function jevState(q) {
4631
+ const request = q.input === void 0 ? "" : `Request:
4632
+ ${q.input}
4633
+
4634
+ `;
4635
+ return `${request}Answer:
4636
+ ${q.output}
4637
+
4638
+ Criterion:
4639
+ ${q.criteria}`;
4640
+ }
4641
+ function jevBaseUrl(env) {
4642
+ const own2 = env[JEV_BASE_URL_ENV];
4643
+ const [name, value] = own2 !== void 0 && own2 !== "" ? [JEV_BASE_URL_ENV, own2] : ["TYPESAFE_BASE_URL", env["TYPESAFE_BASE_URL"]];
4644
+ if (value === void 0 || value === "") return JEV_BASE_URL;
4645
+ let url;
4646
+ try {
4647
+ url = new URL(value);
4648
+ } catch {
4649
+ url = void 0;
4650
+ }
4651
+ const ok = url !== void 0 && url.protocol === "https:" && (url.hostname === "typesafe.ai" || url.hostname.endsWith(".typesafe.ai"));
4652
+ if (!ok)
4653
+ throw new Error(
4654
+ `${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`)
4655
+ );
4656
+ return value.replace(/\/+$/, "");
4657
+ }
4658
+ function jevCost(model, inputTokens, pricing) {
4659
+ return resolveCostEntry({ input_tokens: inputTokens, output_tokens: 0 }, model, void 0, pricing);
4660
+ }
4661
+ var jevTokenEstimate = (chars) => Math.ceil(chars / 3);
4662
+ function probability(json) {
4663
+ const answer = json?.answers?.q;
4664
+ const p = answer?.type === "noul" ? answer.noul : void 0;
4665
+ if (typeof p !== "number" || !Number.isFinite(p) || p < 0 || p > 1)
4666
+ throw new ProviderError("JEV_ANSWER", "jev returned no probability for the question asked");
4667
+ return p;
4668
+ }
4669
+ function makeJevJudge(cfg, deps) {
4670
+ return {
4671
+ ask: () => Promise.reject(new Error("a jev judge answers a yes-or-no question only: it cannot judge this kind of check")),
4672
+ async decide(q) {
4673
+ const base = jevBaseUrl(deps.env);
4674
+ const key = deps.env[JEV_KEY_ENV];
4675
+ if (key === void 0 || key === "")
4676
+ throw new AuthError(`${JEV_KEY_ENV} is not set: the jev judge of an llm-judge check needs it`, JEV_KEY_ENV);
4677
+ const state = jevState(q);
4678
+ if (state.length > JEV_MAX_STATE_CHARS)
4679
+ throw new ProviderError(
4680
+ "JEV_INPUT_TOO_LONG",
4681
+ `the request, answer and criterion are ${state.length} characters together; a jev judge takes ${JEV_MAX_STATE_CHARS}. Nothing was sent`
4682
+ );
4683
+ const body = JSON.stringify({
4684
+ state,
4685
+ model: cfg.model,
4686
+ questions: { q: { type: "noul", instructions: INSTRUCTIONS, criteria: { true: YES, false: NO } } }
4687
+ });
4688
+ const send = async () => {
4689
+ try {
4690
+ return await deps.fetchFn(`${base}/v1/systemone`, {
4691
+ method: "POST",
4692
+ headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
4693
+ body,
4694
+ redirect: "error",
4695
+ signal: AbortSignal.timeout(cfg.timeout ?? DEFAULT_TIMEOUT_MS)
4696
+ });
4697
+ } catch (err) {
4698
+ throw new ProviderError("JEV_UNREACHABLE", `jev did not answer: ${err instanceof Error ? err.message : String(err)}`);
4699
+ }
4700
+ };
4701
+ let res = await send();
4702
+ if (res.status === 429 || res.status >= 500) res = await send();
4703
+ if (res.status === 401 || res.status === 403)
4704
+ throw new AuthError(`jev refused the key in ${JEV_KEY_ENV} (HTTP ${res.status})`, JEV_KEY_ENV);
4705
+ if (!res.ok) throw new ProviderError("JEV_HTTP", `jev answered HTTP ${res.status}`);
4706
+ const json = await res.json();
4707
+ const p = probability(json);
4708
+ const tokens = json.usage?.input_tokens;
4709
+ const billed = typeof tokens === "number" && tokens >= 0 ? tokens : jevTokenEstimate(state.length);
4710
+ const answered = json.model;
4711
+ const model = typeof answered === "string" && answered !== "" ? answered : cfg.model;
4712
+ deps.onCost(jevCost(model, billed, deps.pricing));
4713
+ return { probability: p, model };
4714
+ }
4715
+ };
4716
+ }
4717
+ var warned = false;
4718
+ function warnJevExperimental(write = (l) => process.stderr.write(l)) {
4719
+ if (warned) return;
4720
+ warned = true;
4721
+ write(
4722
+ `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
4723
+ `
4724
+ );
4725
+ }
4726
+
4561
4727
  // src/cli/commands/run.ts
4562
4728
  var NOOP_CACHE = { get: () => void 0, set: () => {
4563
4729
  }, delete: () => {
@@ -4653,7 +4819,20 @@ function buildRealDeps(config, baseDir, dryRun) {
4653
4819
  now: Date.now,
4654
4820
  loadDataset,
4655
4821
  baseDir,
4656
- connectMcp: makeMcpConnect(config, baseDir, process.env)
4822
+ connectMcp: makeMcpConnect(config, baseDir, process.env),
4823
+ // A dry run stops before any check, so it never builds this judge. Mock mode sends nothing: no jev judge there.
4824
+ ...isMockMode(process.env) ? {} : {
4825
+ jevJudge: (cfg, onCost) => {
4826
+ warnJevExperimental();
4827
+ return makeJevJudge(cfg, {
4828
+ env: process.env,
4829
+ fetchFn: fetch,
4830
+ onCost,
4831
+ ...config.pricing !== void 0 ? { pricing: config.pricing } : {}
4832
+ });
4833
+ },
4834
+ jevCost: (model, inputTokens) => jevCost(model, inputTokens, config.pricing)
4835
+ }
4657
4836
  };
4658
4837
  }
4659
4838
  function persist(result, baseDir) {
@@ -4661,11 +4840,21 @@ function persist(result, baseDir) {
4661
4840
  fs5.mkdirSync(dir, { recursive: true });
4662
4841
  fs5.writeFileSync(path6.join(dir, "last-run.json"), JSON.stringify(result, null, 2));
4663
4842
  }
4843
+ function jevAddressCheck(config, env) {
4844
+ const checks = [...config.defaults?.assertions ?? [], ...config.evals.flatMap((ev) => ev.assertions)];
4845
+ if (!checks.some((a) => a.type === "llm-judge" && a.provider?.type === "jev")) return;
4846
+ try {
4847
+ jevBaseUrl(env);
4848
+ } catch (err) {
4849
+ throw new RunConfigError(err.message);
4850
+ }
4851
+ }
4664
4852
  async function handleRun(options, depsFactory) {
4665
4853
  const config = await loadConfig(
4666
4854
  options.configPath !== void 0 ? { configPath: options.configPath } : {}
4667
4855
  );
4668
4856
  const baseDir = options.configPath !== void 0 ? path6.dirname(path6.resolve(options.configPath)) : process.cwd();
4857
+ jevAddressCheck(config, process.env);
4669
4858
  for (const warning of [...mcpSecretWarnings(config), ...selfJudgeWarnings(config)])
4670
4859
  process.stderr.write(`warning: ${warning}
4671
4860
  `);
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.16",
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": [
@@ -101,7 +101,8 @@
101
101
  "tsup": "^8.0.0",
102
102
  "tsx": "^4.7.0",
103
103
  "typescript": "^5.4.0",
104
- "vitest": "^1.6.0"
104
+ "vitest": "^1.6.0",
105
+ "xmllint-wasm": "5.3.0"
105
106
  },
106
107
  "repository": {
107
108
  "type": "git",