@plune-ai/cli 0.39.16 → 0.40.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/dist/mcp-http.cjs CHANGED
@@ -840,10 +840,10 @@ function detailLines(body) {
840
840
  });
841
841
  return lines.length === 0 ? "" : "\n" + lines.join("\n");
842
842
  }
843
- function errorOf(err) {
843
+ function errorOf(err, tokenRejectedHint) {
844
844
  if (err instanceof PluneApiError) {
845
845
  if (err.status === 401)
846
- return { status: 401, code: "token_rejected", message: `Plune rejected the token (401): ${err.message}. Run \`plune login\` or set PLUNE_TOKEN to a live token.` };
846
+ return { status: 401, code: "token_rejected", message: `Plune rejected the token (401): ${err.message}. Run \`plune login\` or set PLUNE_TOKEN to a live token.${tokenRejectedHint === void 0 ? "" : ` ${tokenRejectedHint}`}` };
847
847
  if (err.status === 403 && err.message === READ_ONLY_REFUSAL)
848
848
  return { status: 403, code: "read_only_token", message: `Plune refused (403): ${readScopeMessage("it cannot write")}` };
849
849
  const quota = err.status === 429 && asRecord(err.body)["quota"] !== void 0;
@@ -911,7 +911,7 @@ function createPluneToolExecutor(opts) {
911
911
  const res = await call(req);
912
912
  results.push(withoutUndefined({ ok: true, status: res.status, id: idOf(res.body, i) }));
913
913
  } catch (err) {
914
- const e = errorOf(err);
914
+ const e = errorOf(err, opts.tokenRejectedHint);
915
915
  if (e.code === "token_rejected" || e.code === "read_only_token" || e.code === "network") throw err;
916
916
  results.push(withoutUndefined({ ok: false, status: e.status, error: e.message, code: e.code }));
917
917
  }
@@ -1189,7 +1189,7 @@ function createPluneToolExecutor(opts) {
1189
1189
  const out = await handler(args);
1190
1190
  return "ok" in out && typeof out["ok"] === "boolean" && ("error" in out || "data" in out) ? out : { ok: true, data: out };
1191
1191
  } catch (err) {
1192
- return { ok: false, error: errorOf(err) };
1192
+ return { ok: false, error: errorOf(err, opts.tokenRejectedHint) };
1193
1193
  }
1194
1194
  }
1195
1195
  };
@@ -1,4 +1,4 @@
1
- import { d as PluneToolExecutorOptions } from './execute-DLNnhkEM.cjs';
1
+ import { d as PluneToolExecutorOptions } from './execute-CD55D0di.cjs';
2
2
  import 'zod';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { d as PluneToolExecutorOptions } from './execute-DLNnhkEM.js';
1
+ import { d as PluneToolExecutorOptions } from './execute-CD55D0di.js';
2
2
  import 'zod';
3
3
 
4
4
  /**
package/dist/mcp-http.js CHANGED
@@ -816,10 +816,10 @@ function detailLines(body) {
816
816
  });
817
817
  return lines.length === 0 ? "" : "\n" + lines.join("\n");
818
818
  }
819
- function errorOf(err) {
819
+ function errorOf(err, tokenRejectedHint) {
820
820
  if (err instanceof PluneApiError) {
821
821
  if (err.status === 401)
822
- return { status: 401, code: "token_rejected", message: `Plune rejected the token (401): ${err.message}. Run \`plune login\` or set PLUNE_TOKEN to a live token.` };
822
+ return { status: 401, code: "token_rejected", message: `Plune rejected the token (401): ${err.message}. Run \`plune login\` or set PLUNE_TOKEN to a live token.${tokenRejectedHint === void 0 ? "" : ` ${tokenRejectedHint}`}` };
823
823
  if (err.status === 403 && err.message === READ_ONLY_REFUSAL)
824
824
  return { status: 403, code: "read_only_token", message: `Plune refused (403): ${readScopeMessage("it cannot write")}` };
825
825
  const quota = err.status === 429 && asRecord(err.body)["quota"] !== void 0;
@@ -887,7 +887,7 @@ function createPluneToolExecutor(opts) {
887
887
  const res = await call(req);
888
888
  results.push(withoutUndefined({ ok: true, status: res.status, id: idOf(res.body, i) }));
889
889
  } catch (err) {
890
- const e = errorOf(err);
890
+ const e = errorOf(err, opts.tokenRejectedHint);
891
891
  if (e.code === "token_rejected" || e.code === "read_only_token" || e.code === "network") throw err;
892
892
  results.push(withoutUndefined({ ok: false, status: e.status, error: e.message, code: e.code }));
893
893
  }
@@ -1165,7 +1165,7 @@ function createPluneToolExecutor(opts) {
1165
1165
  const out = await handler(args);
1166
1166
  return "ok" in out && typeof out["ok"] === "boolean" && ("error" in out || "data" in out) ? out : { ok: true, data: out };
1167
1167
  } catch (err) {
1168
- return { ok: false, error: errorOf(err) };
1168
+ return { ok: false, error: errorOf(err, opts.tokenRejectedHint) };
1169
1169
  }
1170
1170
  }
1171
1171
  };
@@ -842,10 +842,10 @@ function detailLines(body) {
842
842
  });
843
843
  return lines.length === 0 ? "" : "\n" + lines.join("\n");
844
844
  }
845
- function errorOf(err) {
845
+ function errorOf(err, tokenRejectedHint) {
846
846
  if (err instanceof PluneApiError) {
847
847
  if (err.status === 401)
848
- return { status: 401, code: "token_rejected", message: `Plune rejected the token (401): ${err.message}. Run \`plune login\` or set PLUNE_TOKEN to a live token.` };
848
+ return { status: 401, code: "token_rejected", message: `Plune rejected the token (401): ${err.message}. Run \`plune login\` or set PLUNE_TOKEN to a live token.${tokenRejectedHint === void 0 ? "" : ` ${tokenRejectedHint}`}` };
849
849
  if (err.status === 403 && err.message === READ_ONLY_REFUSAL)
850
850
  return { status: 403, code: "read_only_token", message: `Plune refused (403): ${readScopeMessage("it cannot write")}` };
851
851
  const quota = err.status === 429 && asRecord(err.body)["quota"] !== void 0;
@@ -913,7 +913,7 @@ function createPluneToolExecutor(opts) {
913
913
  const res = await call(req);
914
914
  results.push(withoutUndefined({ ok: true, status: res.status, id: idOf(res.body, i) }));
915
915
  } catch (err) {
916
- const e = errorOf(err);
916
+ const e = errorOf(err, opts.tokenRejectedHint);
917
917
  if (e.code === "token_rejected" || e.code === "read_only_token" || e.code === "network") throw err;
918
918
  results.push(withoutUndefined({ ok: false, status: e.status, error: e.message, code: e.code }));
919
919
  }
@@ -1191,7 +1191,7 @@ function createPluneToolExecutor(opts) {
1191
1191
  const out = await handler(args);
1192
1192
  return "ok" in out && typeof out["ok"] === "boolean" && ("error" in out || "data" in out) ? out : { ok: true, data: out };
1193
1193
  } catch (err) {
1194
- return { ok: false, error: errorOf(err) };
1194
+ return { ok: false, error: errorOf(err, opts.tokenRejectedHint) };
1195
1195
  }
1196
1196
  }
1197
1197
  };
@@ -1,4 +1,4 @@
1
- export { C as CONFIRM_TTL_MS, M as MAX_VISIBLE_TOOLS, P as PLUNE_TOOLS, a as PLUNE_TOOL_NAMES, b as PluneToolDefinition, c as PluneToolExecutor, d as PluneToolExecutorOptions, e as PluneToolName, T as TokenScope, f as ToolError, g as ToolOutcome, h as ToolVisibility, i as createPluneToolExecutor, j as defaultVisibleTools, k as isPluneToolName, o as offeredTo, p as pluneTool } from './execute-DLNnhkEM.cjs';
1
+ export { C as CONFIRM_TTL_MS, M as MAX_VISIBLE_TOOLS, P as PLUNE_TOOLS, a as PLUNE_TOOL_NAMES, b as PluneToolDefinition, c as PluneToolExecutor, d as PluneToolExecutorOptions, e as PluneToolName, T as TokenScope, f as ToolError, g as ToolOutcome, h as ToolVisibility, i as createPluneToolExecutor, j as defaultVisibleTools, k as isPluneToolName, o as offeredTo, p as pluneTool } from './execute-CD55D0di.cjs';
2
2
  import 'zod';
3
3
 
4
4
  /** The platform answered, with a status outside 2xx. */
@@ -1,4 +1,4 @@
1
- export { C as CONFIRM_TTL_MS, M as MAX_VISIBLE_TOOLS, P as PLUNE_TOOLS, a as PLUNE_TOOL_NAMES, b as PluneToolDefinition, c as PluneToolExecutor, d as PluneToolExecutorOptions, e as PluneToolName, T as TokenScope, f as ToolError, g as ToolOutcome, h as ToolVisibility, i as createPluneToolExecutor, j as defaultVisibleTools, k as isPluneToolName, o as offeredTo, p as pluneTool } from './execute-DLNnhkEM.js';
1
+ export { C as CONFIRM_TTL_MS, M as MAX_VISIBLE_TOOLS, P as PLUNE_TOOLS, a as PLUNE_TOOL_NAMES, b as PluneToolDefinition, c as PluneToolExecutor, d as PluneToolExecutorOptions, e as PluneToolName, T as TokenScope, f as ToolError, g as ToolOutcome, h as ToolVisibility, i as createPluneToolExecutor, j as defaultVisibleTools, k as isPluneToolName, o as offeredTo, p as pluneTool } from './execute-CD55D0di.js';
2
2
  import 'zod';
3
3
 
4
4
  /** The platform answered, with a status outside 2xx. */
package/dist/mcp-tools.js CHANGED
@@ -805,10 +805,10 @@ function detailLines(body) {
805
805
  });
806
806
  return lines.length === 0 ? "" : "\n" + lines.join("\n");
807
807
  }
808
- function errorOf(err) {
808
+ function errorOf(err, tokenRejectedHint) {
809
809
  if (err instanceof PluneApiError) {
810
810
  if (err.status === 401)
811
- return { status: 401, code: "token_rejected", message: `Plune rejected the token (401): ${err.message}. Run \`plune login\` or set PLUNE_TOKEN to a live token.` };
811
+ return { status: 401, code: "token_rejected", message: `Plune rejected the token (401): ${err.message}. Run \`plune login\` or set PLUNE_TOKEN to a live token.${tokenRejectedHint === void 0 ? "" : ` ${tokenRejectedHint}`}` };
812
812
  if (err.status === 403 && err.message === READ_ONLY_REFUSAL)
813
813
  return { status: 403, code: "read_only_token", message: `Plune refused (403): ${readScopeMessage("it cannot write")}` };
814
814
  const quota = err.status === 429 && asRecord(err.body)["quota"] !== void 0;
@@ -876,7 +876,7 @@ function createPluneToolExecutor(opts) {
876
876
  const res = await call(req);
877
877
  results.push(withoutUndefined({ ok: true, status: res.status, id: idOf(res.body, i) }));
878
878
  } catch (err) {
879
- const e = errorOf(err);
879
+ const e = errorOf(err, opts.tokenRejectedHint);
880
880
  if (e.code === "token_rejected" || e.code === "read_only_token" || e.code === "network") throw err;
881
881
  results.push(withoutUndefined({ ok: false, status: e.status, error: e.message, code: e.code }));
882
882
  }
@@ -1154,7 +1154,7 @@ function createPluneToolExecutor(opts) {
1154
1154
  const out = await handler(args);
1155
1155
  return "ok" in out && typeof out["ok"] === "boolean" && ("error" in out || "data" in out) ? out : { ok: true, data: out };
1156
1156
  } catch (err) {
1157
- return { ok: false, error: errorOf(err) };
1157
+ return { ok: false, error: errorOf(err, opts.tokenRejectedHint) };
1158
1158
  }
1159
1159
  }
1160
1160
  };
@@ -56,11 +56,33 @@ var import_node_path3 = require("path");
56
56
  var import_node_util2 = require("util");
57
57
 
58
58
  // src/cli/api-url.ts
59
- var DEFAULT_API_URL = "https://beta-api.plune.ai";
59
+ var PRODUCTION_API_URL = "https://api.plune.ai";
60
+ var BETA_API_URL = "https://beta-api.plune.ai";
61
+ var DEFAULT_API_URL = PRODUCTION_API_URL;
62
+ var DASHBOARDS = /* @__PURE__ */ new Map([
63
+ [PRODUCTION_API_URL, "https://app.plune.ai"],
64
+ [BETA_API_URL, "https://beta.plune.ai"]
65
+ ]);
60
66
  function resolveApiUrl(explicit) {
61
- const raw = explicit ?? process.env["PLUNE_API_URL"] ?? DEFAULT_API_URL;
67
+ const raw = explicit?.trim() || process.env["PLUNE_API_URL"]?.trim() || DEFAULT_API_URL;
62
68
  return raw.replace(/\/+$/, "");
63
69
  }
70
+ function knownApi(apiUrl) {
71
+ try {
72
+ const origin = new URL(apiUrl.trim()).origin;
73
+ return DASHBOARDS.has(origin) ? origin : void 0;
74
+ } catch {
75
+ return void 0;
76
+ }
77
+ }
78
+ function tokenRefusedBy(apiUrl = resolveApiUrl()) {
79
+ const named = `The address that refused it is ${apiUrl}.`;
80
+ if (knownApi(apiUrl) !== PRODUCTION_API_URL) return named;
81
+ return `${named} A token from a beta account works only on the beta: run "plune login" with a token from ${DASHBOARDS.get(PRODUCTION_API_URL)}, or set PLUNE_API_URL=${BETA_API_URL} to keep using the beta account.`;
82
+ }
83
+ function ifTokenRefused(status, apiUrl) {
84
+ return status === 401 ? ` ${tokenRefusedBy(apiUrl)}` : "";
85
+ }
64
86
 
65
87
  // src/cli/credentials.ts
66
88
  var import_node_fs = require("fs");
@@ -1436,8 +1458,9 @@ async function startRun(passed, declared) {
1436
1458
  const token = cfg.token ?? loadToken() ?? "";
1437
1459
  const uploadsAtOnce = Math.min(Math.max(Math.floor(cfg.uploadConcurrency ?? UPLOAD_CONCURRENCY.default), UPLOAD_CONCURRENCY.min), UPLOAD_CONCURRENCY.max);
1438
1460
  const uploadRetries = Math.min(Math.max(Math.floor(cfg.uploadRetries ?? UPLOAD_RETRIES.default), UPLOAD_RETRIES.min), UPLOAD_RETRIES.max);
1461
+ const apiUrl = resolveApiUrl(cfg.apiUrl);
1439
1462
  const client = createClient({
1440
- apiUrl: resolveApiUrl(cfg.apiUrl),
1463
+ apiUrl,
1441
1464
  token,
1442
1465
  uploadRetries,
1443
1466
  onRetry: () => files.onRetry(),
@@ -1571,7 +1594,7 @@ async function startRun(passed, declared) {
1571
1594
  warnIfDropped(described, start.body.run, log);
1572
1595
  } else {
1573
1596
  const why = start.ok ? "the answer had no run" : start.detail || start.kind;
1574
- log(`plune: could not start the run (${why}). Results will be written to ${fallbackPath}.`);
1597
+ log(`plune: could not start the run (${why}). Results will be written to ${fallbackPath}.${start.ok ? "" : ifTokenRefused(start.status, apiUrl)}`);
1575
1598
  }
1576
1599
  }
1577
1600
  function matchFor(result) {
@@ -1779,7 +1802,7 @@ async function startRun(passed, declared) {
1779
1802
  if (out.ok) {
1780
1803
  log("plune: could not send results (the answer carried no counts).");
1781
1804
  } else if (out.kind === "auth") {
1782
- log('plune: the API token was refused \u2014 run "plune login" with a fresh one.');
1805
+ log(`plune: the API token was refused \u2014 run "plune login" with a fresh one.${ifTokenRefused(out.status, apiUrl)}`);
1783
1806
  offline = true;
1784
1807
  } else if (out.kind === "conflict") {
1785
1808
  log(`plune: this run is closed \u2014 ${out.detail}`);
@@ -443,7 +443,7 @@ interface RunStats extends SubmitCounts {
443
443
  }
444
444
  /** Everything the core needs to talk to a deployment. */
445
445
  interface ReporterConfig {
446
- /** Base URL. Falls back to `PLUNE_API_URL`, then beta — the same resolution `sync` uses. */
446
+ /** Base URL. Falls back to `PLUNE_API_URL`, then production — the same resolution `sync` uses. */
447
447
  apiUrl?: string;
448
448
  /** Bearer token. Falls back to the store `plune login` writes. */
449
449
  token?: string;
@@ -443,7 +443,7 @@ interface RunStats extends SubmitCounts {
443
443
  }
444
444
  /** Everything the core needs to talk to a deployment. */
445
445
  interface ReporterConfig {
446
- /** Base URL. Falls back to `PLUNE_API_URL`, then beta — the same resolution `sync` uses. */
446
+ /** Base URL. Falls back to `PLUNE_API_URL`, then production — the same resolution `sync` uses. */
447
447
  apiUrl?: string;
448
448
  /** Bearer token. Falls back to the store `plune login` writes. */
449
449
  token?: string;
@@ -5,11 +5,33 @@ import { basename as basename2, extname } from "path";
5
5
  import { TextDecoder } from "util";
6
6
 
7
7
  // src/cli/api-url.ts
8
- var DEFAULT_API_URL = "https://beta-api.plune.ai";
8
+ var PRODUCTION_API_URL = "https://api.plune.ai";
9
+ var BETA_API_URL = "https://beta-api.plune.ai";
10
+ var DEFAULT_API_URL = PRODUCTION_API_URL;
11
+ var DASHBOARDS = /* @__PURE__ */ new Map([
12
+ [PRODUCTION_API_URL, "https://app.plune.ai"],
13
+ [BETA_API_URL, "https://beta.plune.ai"]
14
+ ]);
9
15
  function resolveApiUrl(explicit) {
10
- const raw = explicit ?? process.env["PLUNE_API_URL"] ?? DEFAULT_API_URL;
16
+ const raw = explicit?.trim() || process.env["PLUNE_API_URL"]?.trim() || DEFAULT_API_URL;
11
17
  return raw.replace(/\/+$/, "");
12
18
  }
19
+ function knownApi(apiUrl) {
20
+ try {
21
+ const origin = new URL(apiUrl.trim()).origin;
22
+ return DASHBOARDS.has(origin) ? origin : void 0;
23
+ } catch {
24
+ return void 0;
25
+ }
26
+ }
27
+ function tokenRefusedBy(apiUrl = resolveApiUrl()) {
28
+ const named = `The address that refused it is ${apiUrl}.`;
29
+ if (knownApi(apiUrl) !== PRODUCTION_API_URL) return named;
30
+ return `${named} A token from a beta account works only on the beta: run "plune login" with a token from ${DASHBOARDS.get(PRODUCTION_API_URL)}, or set PLUNE_API_URL=${BETA_API_URL} to keep using the beta account.`;
31
+ }
32
+ function ifTokenRefused(status, apiUrl) {
33
+ return status === 401 ? ` ${tokenRefusedBy(apiUrl)}` : "";
34
+ }
13
35
 
14
36
  // src/cli/credentials.ts
15
37
  import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
@@ -1385,8 +1407,9 @@ async function startRun(passed, declared) {
1385
1407
  const token = cfg.token ?? loadToken() ?? "";
1386
1408
  const uploadsAtOnce = Math.min(Math.max(Math.floor(cfg.uploadConcurrency ?? UPLOAD_CONCURRENCY.default), UPLOAD_CONCURRENCY.min), UPLOAD_CONCURRENCY.max);
1387
1409
  const uploadRetries = Math.min(Math.max(Math.floor(cfg.uploadRetries ?? UPLOAD_RETRIES.default), UPLOAD_RETRIES.min), UPLOAD_RETRIES.max);
1410
+ const apiUrl = resolveApiUrl(cfg.apiUrl);
1388
1411
  const client = createClient({
1389
- apiUrl: resolveApiUrl(cfg.apiUrl),
1412
+ apiUrl,
1390
1413
  token,
1391
1414
  uploadRetries,
1392
1415
  onRetry: () => files.onRetry(),
@@ -1520,7 +1543,7 @@ async function startRun(passed, declared) {
1520
1543
  warnIfDropped(described, start.body.run, log);
1521
1544
  } else {
1522
1545
  const why = start.ok ? "the answer had no run" : start.detail || start.kind;
1523
- log(`plune: could not start the run (${why}). Results will be written to ${fallbackPath}.`);
1546
+ log(`plune: could not start the run (${why}). Results will be written to ${fallbackPath}.${start.ok ? "" : ifTokenRefused(start.status, apiUrl)}`);
1524
1547
  }
1525
1548
  }
1526
1549
  function matchFor(result) {
@@ -1728,7 +1751,7 @@ async function startRun(passed, declared) {
1728
1751
  if (out.ok) {
1729
1752
  log("plune: could not send results (the answer carried no counts).");
1730
1753
  } else if (out.kind === "auth") {
1731
- log('plune: the API token was refused \u2014 run "plune login" with a fresh one.');
1754
+ log(`plune: the API token was refused \u2014 run "plune login" with a fresh one.${ifTokenRefused(out.status, apiUrl)}`);
1732
1755
  offline = true;
1733
1756
  } else if (out.kind === "conflict") {
1734
1757
  log(`plune: this run is closed \u2014 ${out.detail}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plune-ai/cli",
3
- "version": "0.39.16",
3
+ "version": "0.40.1",
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": [