@plune-ai/cli 0.39.7 → 0.39.8

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
@@ -1064,168 +1064,26 @@ var ConfigValidationError = class extends Error {
1064
1064
  }
1065
1065
  };
1066
1066
 
1067
- // src/config/env-overrides.ts
1068
- function applyEnvOverrides(config, env) {
1069
- const result = structuredClone(config);
1070
- const all = result.providers ?? [result.provider];
1071
- if (result.providers !== void 0) {
1072
- for (const name of ["PLUNE_PROVIDER", "PLUNE_MODEL"])
1073
- if (env[name] !== void 0)
1074
- throw new ConfigValidationError("Config validation failed", [
1075
- `${name} sets one model, but the config lists ${result.providers.length}: remove it or list a single model`
1076
- ]);
1077
- }
1078
- if (env["PLUNE_PROVIDER"] !== void 0) {
1079
- result.provider.type = env["PLUNE_PROVIDER"];
1080
- }
1081
- if (env["PLUNE_MODEL"] !== void 0) {
1082
- result.provider.model = env["PLUNE_MODEL"];
1083
- }
1084
- if (env["PLUNE_TIMEOUT"] !== void 0) {
1085
- const n = Number(env["PLUNE_TIMEOUT"]);
1086
- if (!isNaN(n)) for (const p of all) p.timeout = n;
1087
- }
1088
- if (env["PLUNE_MAX_RETRIES"] !== void 0) {
1089
- const n = Number(env["PLUNE_MAX_RETRIES"]);
1090
- if (!isNaN(n)) for (const p of all) p.max_retries = n;
1091
- }
1092
- return result;
1093
- }
1094
-
1095
- // src/config/discover.ts
1067
+ // src/config/schema.ts
1096
1068
  init_esm_shims();
1097
- import * as fs from "fs";
1098
- import * as path2 from "path";
1099
- var FILENAME = "plune.yaml";
1100
- var MAX_STEPS = 50;
1101
- function discoverConfigPath(cwd, override) {
1102
- if (override !== void 0) {
1103
- if (fs.existsSync(override)) {
1104
- return override;
1105
- }
1106
- throw new ConfigNotFoundError(`Config file not found: ${override}`);
1107
- }
1108
- let dir = cwd;
1109
- let steps = 0;
1110
- while (steps < MAX_STEPS) {
1111
- const candidate = path2.join(dir, FILENAME);
1112
- if (fs.existsSync(candidate)) {
1113
- return candidate;
1114
- }
1115
- const parent = path2.dirname(dir);
1116
- if (parent === dir) {
1117
- break;
1118
- }
1119
- dir = parent;
1120
- steps++;
1121
- }
1122
- throw new ConfigNotFoundError(
1123
- `No ${FILENAME} found. Run "plune init" to create one.`
1124
- );
1125
- }
1069
+ import { z } from "zod";
1126
1070
 
1127
- // src/config/mcp.ts
1071
+ // src/util/duration.ts
1128
1072
  init_esm_shims();
1129
- import * as path3 from "path";
1130
- var MCP_LIMIT_DEFAULTS = {
1131
- max_steps: 10,
1132
- max_tool_calls: 20,
1133
- max_total_tokens: 1e5,
1134
- timeout_ms: 12e4,
1135
- tool_timeout_ms: 3e4
1136
- };
1137
- function mcpLimits(config, evalConfig) {
1138
- return { ...MCP_LIMIT_DEFAULTS, ...config.mcp?.limits, ...evalConfig.mcp?.limits };
1139
- }
1140
- var REFERENCE = /\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}/g;
1141
- function expandVars(value, env) {
1142
- const literal = (text) => {
1143
- if (text.includes("${")) throw new Error('has a "${" that is not ${NAME} or ${NAME:-default}');
1144
- return text;
1145
- };
1146
- let out = "";
1147
- let last = 0;
1148
- for (const match of value.matchAll(REFERENCE)) {
1149
- const [whole, name, fallback] = match;
1150
- out += literal(value.slice(last, match.index));
1151
- const set = env[name];
1152
- if (set !== void 0 && set !== "") out += set;
1153
- else if (fallback !== void 0) out += fallback;
1154
- else
1155
- throw new Error(
1156
- `\${${name}} is not set or is empty, and has no default (\${${name}:-default})`
1157
- );
1158
- last = match.index + whole.length;
1159
- }
1160
- return out + literal(value.slice(last));
1161
- }
1162
- function serverValues(server) {
1163
- const out = [];
1164
- if (server.command !== void 0) out.push(["command", server.command]);
1165
- (server.args ?? []).forEach((arg, i) => out.push([`args.${i}`, arg]));
1166
- for (const [key, value] of Object.entries(server.env ?? {})) out.push([`env.${key}`, value]);
1167
- if (server.cwd !== void 0) out.push(["cwd", server.cwd]);
1168
- if (server.url !== void 0) out.push(["url", server.url]);
1169
- for (const [key, value] of Object.entries(server.headers ?? {}))
1170
- out.push([`headers.${key}`, value]);
1171
- return out;
1172
- }
1173
- function mcpVariableIssues(config, env) {
1174
- const issues = [];
1175
- for (const [name, server] of Object.entries(config.mcp?.servers ?? {})) {
1176
- for (const [field, value] of serverValues(server)) {
1177
- try {
1178
- expandVars(value, env);
1179
- } catch (err) {
1180
- issues.push(`mcp.servers.${name}.${field}: ${err.message}`);
1181
- }
1182
- }
1183
- }
1184
- return issues;
1185
- }
1186
- function resolveMcpServer(server, env = process.env, baseDir = process.cwd()) {
1187
- const fill = (value) => expandVars(value, env);
1188
- const fillAll = (entries = {}) => Object.fromEntries(Object.entries(entries).map(([key, value]) => [key, fill(value)]));
1189
- if (server.url !== void 0)
1190
- return { kind: "http", url: fill(server.url), headers: fillAll(server.headers) };
1191
- return {
1192
- kind: "stdio",
1193
- command: fill(server.command),
1194
- args: (server.args ?? []).map(fill),
1195
- env: fillAll(server.env),
1196
- ...server.cwd !== void 0 ? { cwd: path3.resolve(baseDir, fill(server.cwd)) } : {}
1197
- };
1198
- }
1199
- var SECRET_KEY = /authorization|token|key|secret|password/i;
1200
- function mcpSecretWarnings(config) {
1201
- const warnings = [];
1202
- for (const [name, server] of Object.entries(config.mcp?.servers ?? {})) {
1203
- for (const [field, entries] of [
1204
- ["env", server.env],
1205
- ["headers", server.headers]
1206
- ]) {
1207
- for (const [key, value] of Object.entries(entries ?? {})) {
1208
- if (SECRET_KEY.test(key) && !value.includes("${")) {
1209
- warnings.push(
1210
- `mcp.servers.${name}.${field}.${key} looks like a secret written into plune.yaml; use \${VAR} so it comes from the environment.`
1211
- );
1212
- }
1213
- }
1214
- }
1215
- }
1216
- return warnings;
1217
- }
1073
+ var MAX_TIMER_MS = 2147483647;
1218
1074
 
1219
1075
  // src/config/schema.ts
1220
- init_esm_shims();
1221
- import { z } from "zod";
1076
+ var providerTimeoutSchema = z.number().int().positive().max(
1077
+ MAX_TIMER_MS,
1078
+ `must be at most ${MAX_TIMER_MS} ms (about 24.8 days), the longest a timer can wait: a longer timeout ends every model call at once`
1079
+ );
1222
1080
  var providerConfigSchema = z.object({
1223
1081
  type: z.enum(["anthropic", "openai", "openrouter"]),
1224
1082
  model: z.string().min(1),
1225
1083
  temperature: z.number().min(0).max(2).optional(),
1226
1084
  max_tokens: z.number().int().positive().optional(),
1227
1085
  concurrency: z.number().int().positive().optional(),
1228
- timeout: z.number().int().positive().optional(),
1086
+ timeout: providerTimeoutSchema.optional(),
1229
1087
  max_retries: z.number().int().min(0).optional(),
1230
1088
  // The values the OpenAI SDK's Chat Completions `reasoning_effort` accepts; only `openai` sends it.
1231
1089
  reasoning_effort: z.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional()
@@ -1371,7 +1229,6 @@ var evalRepeatsShape = {
1371
1229
  runs: z.number().int().min(1).max(MAX_RUNS).optional(),
1372
1230
  pass_threshold: z.number().gt(0, SHARE_MESSAGE).max(1, SHARE_MESSAGE).optional()
1373
1231
  };
1374
- var MAX_TIMER_MS = 2147483647;
1375
1232
  var limit = z.number().int().positive();
1376
1233
  var mcpLimitsSchema = z.object({
1377
1234
  max_steps: limit.optional(),
@@ -1491,6 +1348,166 @@ var pluneConfigSchema = z.object({
1491
1348
  return others.length === 0 ? { provider: first, ...rest } : { provider: first, providers: provider, ...rest };
1492
1349
  });
1493
1350
 
1351
+ // src/config/env-overrides.ts
1352
+ function applyEnvOverrides(config, env) {
1353
+ const result = structuredClone(config);
1354
+ const all = result.providers ?? [result.provider];
1355
+ if (result.providers !== void 0) {
1356
+ for (const name of ["PLUNE_PROVIDER", "PLUNE_MODEL"])
1357
+ if (env[name] !== void 0)
1358
+ throw new ConfigValidationError("Config validation failed", [
1359
+ `${name} sets one model, but the config lists ${result.providers.length}: remove it or list a single model`
1360
+ ]);
1361
+ }
1362
+ if (env["PLUNE_PROVIDER"] !== void 0) {
1363
+ result.provider.type = env["PLUNE_PROVIDER"];
1364
+ }
1365
+ if (env["PLUNE_MODEL"] !== void 0) {
1366
+ result.provider.model = env["PLUNE_MODEL"];
1367
+ }
1368
+ if (env["PLUNE_TIMEOUT"] !== void 0) {
1369
+ const n = Number(env["PLUNE_TIMEOUT"]);
1370
+ if (Number.isFinite(n)) {
1371
+ const r = providerTimeoutSchema.safeParse(n);
1372
+ if (!r.success)
1373
+ throw new ConfigValidationError(
1374
+ "Config validation failed",
1375
+ r.error.issues.map((issue) => `PLUNE_TIMEOUT=${env["PLUNE_TIMEOUT"]}: ${issue.message}`)
1376
+ );
1377
+ for (const p of all) p.timeout = n;
1378
+ }
1379
+ }
1380
+ if (env["PLUNE_MAX_RETRIES"] !== void 0) {
1381
+ const n = Number(env["PLUNE_MAX_RETRIES"]);
1382
+ if (!isNaN(n)) for (const p of all) p.max_retries = Number.isFinite(n) ? n : 0;
1383
+ }
1384
+ return result;
1385
+ }
1386
+
1387
+ // src/config/discover.ts
1388
+ init_esm_shims();
1389
+ import * as fs from "fs";
1390
+ import * as path2 from "path";
1391
+ var FILENAME = "plune.yaml";
1392
+ var MAX_STEPS = 50;
1393
+ function discoverConfigPath(cwd, override) {
1394
+ if (override !== void 0) {
1395
+ if (fs.existsSync(override)) {
1396
+ return override;
1397
+ }
1398
+ throw new ConfigNotFoundError(`Config file not found: ${override}`);
1399
+ }
1400
+ let dir = cwd;
1401
+ let steps = 0;
1402
+ while (steps < MAX_STEPS) {
1403
+ const candidate = path2.join(dir, FILENAME);
1404
+ if (fs.existsSync(candidate)) {
1405
+ return candidate;
1406
+ }
1407
+ const parent = path2.dirname(dir);
1408
+ if (parent === dir) {
1409
+ break;
1410
+ }
1411
+ dir = parent;
1412
+ steps++;
1413
+ }
1414
+ throw new ConfigNotFoundError(
1415
+ `No ${FILENAME} found. Run "plune init" to create one.`
1416
+ );
1417
+ }
1418
+
1419
+ // src/config/mcp.ts
1420
+ init_esm_shims();
1421
+ import * as path3 from "path";
1422
+ var MCP_LIMIT_DEFAULTS = {
1423
+ max_steps: 10,
1424
+ max_tool_calls: 20,
1425
+ max_total_tokens: 1e5,
1426
+ timeout_ms: 12e4,
1427
+ tool_timeout_ms: 3e4
1428
+ };
1429
+ function mcpLimits(config, evalConfig) {
1430
+ return { ...MCP_LIMIT_DEFAULTS, ...config.mcp?.limits, ...evalConfig.mcp?.limits };
1431
+ }
1432
+ var REFERENCE = /\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}/g;
1433
+ function expandVars(value, env) {
1434
+ const literal = (text) => {
1435
+ if (text.includes("${")) throw new Error('has a "${" that is not ${NAME} or ${NAME:-default}');
1436
+ return text;
1437
+ };
1438
+ let out = "";
1439
+ let last = 0;
1440
+ for (const match of value.matchAll(REFERENCE)) {
1441
+ const [whole, name, fallback] = match;
1442
+ out += literal(value.slice(last, match.index));
1443
+ const set = env[name];
1444
+ if (set !== void 0 && set !== "") out += set;
1445
+ else if (fallback !== void 0) out += fallback;
1446
+ else
1447
+ throw new Error(
1448
+ `\${${name}} is not set or is empty, and has no default (\${${name}:-default})`
1449
+ );
1450
+ last = match.index + whole.length;
1451
+ }
1452
+ return out + literal(value.slice(last));
1453
+ }
1454
+ function serverValues(server) {
1455
+ const out = [];
1456
+ if (server.command !== void 0) out.push(["command", server.command]);
1457
+ (server.args ?? []).forEach((arg, i) => out.push([`args.${i}`, arg]));
1458
+ for (const [key, value] of Object.entries(server.env ?? {})) out.push([`env.${key}`, value]);
1459
+ if (server.cwd !== void 0) out.push(["cwd", server.cwd]);
1460
+ if (server.url !== void 0) out.push(["url", server.url]);
1461
+ for (const [key, value] of Object.entries(server.headers ?? {}))
1462
+ out.push([`headers.${key}`, value]);
1463
+ return out;
1464
+ }
1465
+ function mcpVariableIssues(config, env) {
1466
+ const issues = [];
1467
+ for (const [name, server] of Object.entries(config.mcp?.servers ?? {})) {
1468
+ for (const [field, value] of serverValues(server)) {
1469
+ try {
1470
+ expandVars(value, env);
1471
+ } catch (err) {
1472
+ issues.push(`mcp.servers.${name}.${field}: ${err.message}`);
1473
+ }
1474
+ }
1475
+ }
1476
+ return issues;
1477
+ }
1478
+ function resolveMcpServer(server, env = process.env, baseDir = process.cwd()) {
1479
+ const fill = (value) => expandVars(value, env);
1480
+ const fillAll = (entries = {}) => Object.fromEntries(Object.entries(entries).map(([key, value]) => [key, fill(value)]));
1481
+ if (server.url !== void 0)
1482
+ return { kind: "http", url: fill(server.url), headers: fillAll(server.headers) };
1483
+ return {
1484
+ kind: "stdio",
1485
+ command: fill(server.command),
1486
+ args: (server.args ?? []).map(fill),
1487
+ env: fillAll(server.env),
1488
+ ...server.cwd !== void 0 ? { cwd: path3.resolve(baseDir, fill(server.cwd)) } : {}
1489
+ };
1490
+ }
1491
+ var SECRET_KEY = /authorization|token|key|secret|password/i;
1492
+ function mcpSecretWarnings(config) {
1493
+ const warnings = [];
1494
+ for (const [name, server] of Object.entries(config.mcp?.servers ?? {})) {
1495
+ for (const [field, entries] of [
1496
+ ["env", server.env],
1497
+ ["headers", server.headers]
1498
+ ]) {
1499
+ for (const [key, value] of Object.entries(entries ?? {})) {
1500
+ if (SECRET_KEY.test(key) && !value.includes("${")) {
1501
+ warnings.push(
1502
+ `mcp.servers.${name}.${field}.${key} looks like a secret written into plune.yaml; use \${VAR} so it comes from the environment.`
1503
+ );
1504
+ }
1505
+ }
1506
+ }
1507
+ }
1508
+ return warnings;
1509
+ }
1510
+
1494
1511
  // src/config/loader.ts
1495
1512
  async function loadConfig(opts = {}) {
1496
1513
  const { configPath, cwd = process.cwd(), env = process.env } = opts;
@@ -3942,13 +3959,11 @@ async function runAgentRow(p) {
3942
3959
  const clean = cleaned.get(c);
3943
3960
  if (out.result === void 0 || clean === void 0) return;
3944
3961
  const whole = Buffer.from(mask?.text(clean.text) ?? clean.text, "utf8");
3945
- const keep = Math.min(Buffer.byteLength(out.result.text, "utf8"), whole.length);
3962
+ const keep = Buffer.byteLength(out.result.text, "utf8");
3946
3963
  out.result = {
3947
3964
  ...out.result,
3948
- text: keep < whole.length ? firstBytes(whole, keep) : whole.toString("utf8"),
3949
- truncated: out.result.truncated || keep < whole.length
3965
+ text: out.result.truncated && keep < whole.length ? firstBytes(whole, keep) : whole.toString("utf8")
3950
3966
  };
3951
- if (out.result.truncated) agent.collection = "partial";
3952
3967
  if (clean.unread === void 0) return;
3953
3968
  const u = unread.get(c.name) ?? { steps: /* @__PURE__ */ new Set(), count: 0, why: clean.unread };
3954
3969
  u.steps.add(s.index);
package/dist/mcp-http.cjs CHANGED
@@ -1194,7 +1194,9 @@ function createPluneToolExecutor(opts) {
1194
1194
  var annotationsOf = (tool) => ({
1195
1195
  title: tool.title,
1196
1196
  readOnlyHint: !tool.write,
1197
- destructiveHint: tool.name === "plune_api_request",
1197
+ // plune_mission_update overwrites fields and can remove the address, plune_cases_update replaces a case's title, tags
1198
+ // and steps whole; the other writers only add.
1199
+ destructiveHint: tool.name === "plune_api_request" || tool.name === "plune_mission_update" || tool.name === "plune_cases_update",
1198
1200
  openWorldHint: false
1199
1201
  });
1200
1202
  var listed = (tool) => ({
package/dist/mcp-http.js CHANGED
@@ -1170,7 +1170,9 @@ function createPluneToolExecutor(opts) {
1170
1170
  var annotationsOf = (tool) => ({
1171
1171
  title: tool.title,
1172
1172
  readOnlyHint: !tool.write,
1173
- destructiveHint: tool.name === "plune_api_request",
1173
+ // plune_mission_update overwrites fields and can remove the address, plune_cases_update replaces a case's title, tags
1174
+ // and steps whole; the other writers only add.
1175
+ destructiveHint: tool.name === "plune_api_request" || tool.name === "plune_mission_update" || tool.name === "plune_cases_update",
1174
1176
  openWorldHint: false
1175
1177
  });
1176
1178
  var listed = (tool) => ({
@@ -904,8 +904,8 @@ function textRefusal(bytes) {
904
904
  return void 0;
905
905
  }
906
906
  function withoutTargets(result) {
907
- if (result.targets === void 0) return result;
908
- const { targets: _targets, ...rest } = result;
907
+ if (result.targets === void 0 && result.traceUrl === void 0) return result;
908
+ const { targets: _targets, traceUrl: _traceUrl, ...rest } = result;
909
909
  return rest;
910
910
  }
911
911
  function onDisk(deferred) {
@@ -1743,8 +1743,8 @@ async function startRun(passed, declared) {
1743
1743
  { results, ...configuration !== void 0 ? { configuration } : {} }
1744
1744
  );
1745
1745
  let out = await post(part);
1746
- if (!out.ok && out.kind === "invalid" && out.status === 400 && part.some((r) => r.targets !== void 0)) {
1747
- if (!targetsRefused) log("plune: the platform does not take targets on a result yet \u2014 the results are sent without them.");
1746
+ if (!out.ok && out.kind === "invalid" && out.status === 400 && part.some((r) => r.targets !== void 0 || r.traceUrl !== void 0)) {
1747
+ if (!targetsRefused) log("plune: the platform does not take targets or a trace link on a result yet \u2014 the results are sent without them.");
1748
1748
  targetsRefused = true;
1749
1749
  part = part.map(withoutTargets);
1750
1750
  out = await post(part);
@@ -228,6 +228,11 @@ interface PendingResult {
228
228
  * again without them (see `send`).
229
229
  */
230
230
  targets?: string[];
231
+ /**
232
+ * The link to this attempt's trace in the team's own observability (Langfuse, OTel): https, already checked by
233
+ * `traceUrlProblem`. Absent rather than empty; a platform older than the field is handled as for `targets`.
234
+ */
235
+ traceUrl?: string;
231
236
  }
232
237
  /**
233
238
  * What a failed attempt says about itself on the run page: every field
@@ -228,6 +228,11 @@ interface PendingResult {
228
228
  * again without them (see `send`).
229
229
  */
230
230
  targets?: string[];
231
+ /**
232
+ * The link to this attempt's trace in the team's own observability (Langfuse, OTel): https, already checked by
233
+ * `traceUrlProblem`. Absent rather than empty; a platform older than the field is handled as for `targets`.
234
+ */
235
+ traceUrl?: string;
231
236
  }
232
237
  /**
233
238
  * What a failed attempt says about itself on the run page: every field
@@ -854,8 +854,8 @@ function textRefusal(bytes) {
854
854
  return void 0;
855
855
  }
856
856
  function withoutTargets(result) {
857
- if (result.targets === void 0) return result;
858
- const { targets: _targets, ...rest } = result;
857
+ if (result.targets === void 0 && result.traceUrl === void 0) return result;
858
+ const { targets: _targets, traceUrl: _traceUrl, ...rest } = result;
859
859
  return rest;
860
860
  }
861
861
  function onDisk(deferred) {
@@ -1693,8 +1693,8 @@ async function startRun(passed, declared) {
1693
1693
  { results, ...configuration !== void 0 ? { configuration } : {} }
1694
1694
  );
1695
1695
  let out = await post(part);
1696
- if (!out.ok && out.kind === "invalid" && out.status === 400 && part.some((r) => r.targets !== void 0)) {
1697
- if (!targetsRefused) log("plune: the platform does not take targets on a result yet \u2014 the results are sent without them.");
1696
+ if (!out.ok && out.kind === "invalid" && out.status === 400 && part.some((r) => r.targets !== void 0 || r.traceUrl !== void 0)) {
1697
+ if (!targetsRefused) log("plune: the platform does not take targets or a trace link on a result yet \u2014 the results are sent without them.");
1698
1698
  targetsRefused = true;
1699
1699
  part = part.map(withoutTargets);
1700
1700
  out = await post(part);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@plune-ai/cli",
3
- "version": "0.39.7",
4
- "mcpName": "io.github.plune-ai/cli",
3
+ "version": "0.39.8",
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": [
7
7
  "ai",