@plune-ai/cli 0.39.6 → 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/README.md +63 -0
- package/dist/cli.cjs +703 -378
- package/dist/execute-CR3Ixbxj.d.cts +944 -0
- package/dist/execute-CR3Ixbxj.d.ts +944 -0
- package/dist/index.cjs +331 -159
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +331 -159
- package/dist/mcp-http.cjs +1293 -0
- package/dist/mcp-http.d.cts +25 -0
- package/dist/mcp-http.d.ts +25 -0
- package/dist/mcp-http.js +1268 -0
- package/dist/mcp-tools.cjs +173 -9
- package/dist/mcp-tools.d.cts +3 -938
- package/dist/mcp-tools.d.ts +3 -938
- package/dist/mcp-tools.js +173 -9
- package/dist/reporter-core.cjs +51 -4
- package/dist/reporter-core.d.cts +10 -0
- package/dist/reporter-core.d.ts +10 -0
- package/dist/reporter-core.js +51 -4
- package/package.json +7 -1
- package/skills/plune/SKILL.md +23 -0
package/dist/index.cjs
CHANGED
|
@@ -1102,168 +1102,26 @@ var ConfigValidationError = class extends Error {
|
|
|
1102
1102
|
}
|
|
1103
1103
|
};
|
|
1104
1104
|
|
|
1105
|
-
// src/config/
|
|
1106
|
-
function applyEnvOverrides(config, env) {
|
|
1107
|
-
const result = structuredClone(config);
|
|
1108
|
-
const all = result.providers ?? [result.provider];
|
|
1109
|
-
if (result.providers !== void 0) {
|
|
1110
|
-
for (const name of ["PLUNE_PROVIDER", "PLUNE_MODEL"])
|
|
1111
|
-
if (env[name] !== void 0)
|
|
1112
|
-
throw new ConfigValidationError("Config validation failed", [
|
|
1113
|
-
`${name} sets one model, but the config lists ${result.providers.length}: remove it or list a single model`
|
|
1114
|
-
]);
|
|
1115
|
-
}
|
|
1116
|
-
if (env["PLUNE_PROVIDER"] !== void 0) {
|
|
1117
|
-
result.provider.type = env["PLUNE_PROVIDER"];
|
|
1118
|
-
}
|
|
1119
|
-
if (env["PLUNE_MODEL"] !== void 0) {
|
|
1120
|
-
result.provider.model = env["PLUNE_MODEL"];
|
|
1121
|
-
}
|
|
1122
|
-
if (env["PLUNE_TIMEOUT"] !== void 0) {
|
|
1123
|
-
const n = Number(env["PLUNE_TIMEOUT"]);
|
|
1124
|
-
if (!isNaN(n)) for (const p of all) p.timeout = n;
|
|
1125
|
-
}
|
|
1126
|
-
if (env["PLUNE_MAX_RETRIES"] !== void 0) {
|
|
1127
|
-
const n = Number(env["PLUNE_MAX_RETRIES"]);
|
|
1128
|
-
if (!isNaN(n)) for (const p of all) p.max_retries = n;
|
|
1129
|
-
}
|
|
1130
|
-
return result;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
// src/config/discover.ts
|
|
1105
|
+
// src/config/schema.ts
|
|
1134
1106
|
init_cjs_shims();
|
|
1135
|
-
var
|
|
1136
|
-
var path = __toESM(require("path"), 1);
|
|
1137
|
-
var FILENAME = "plune.yaml";
|
|
1138
|
-
var MAX_STEPS = 50;
|
|
1139
|
-
function discoverConfigPath(cwd, override) {
|
|
1140
|
-
if (override !== void 0) {
|
|
1141
|
-
if (fs.existsSync(override)) {
|
|
1142
|
-
return override;
|
|
1143
|
-
}
|
|
1144
|
-
throw new ConfigNotFoundError(`Config file not found: ${override}`);
|
|
1145
|
-
}
|
|
1146
|
-
let dir = cwd;
|
|
1147
|
-
let steps = 0;
|
|
1148
|
-
while (steps < MAX_STEPS) {
|
|
1149
|
-
const candidate = path.join(dir, FILENAME);
|
|
1150
|
-
if (fs.existsSync(candidate)) {
|
|
1151
|
-
return candidate;
|
|
1152
|
-
}
|
|
1153
|
-
const parent = path.dirname(dir);
|
|
1154
|
-
if (parent === dir) {
|
|
1155
|
-
break;
|
|
1156
|
-
}
|
|
1157
|
-
dir = parent;
|
|
1158
|
-
steps++;
|
|
1159
|
-
}
|
|
1160
|
-
throw new ConfigNotFoundError(
|
|
1161
|
-
`No ${FILENAME} found. Run "plune init" to create one.`
|
|
1162
|
-
);
|
|
1163
|
-
}
|
|
1107
|
+
var import_zod = require("zod");
|
|
1164
1108
|
|
|
1165
|
-
// src/
|
|
1109
|
+
// src/util/duration.ts
|
|
1166
1110
|
init_cjs_shims();
|
|
1167
|
-
var
|
|
1168
|
-
var MCP_LIMIT_DEFAULTS = {
|
|
1169
|
-
max_steps: 10,
|
|
1170
|
-
max_tool_calls: 20,
|
|
1171
|
-
max_total_tokens: 1e5,
|
|
1172
|
-
timeout_ms: 12e4,
|
|
1173
|
-
tool_timeout_ms: 3e4
|
|
1174
|
-
};
|
|
1175
|
-
function mcpLimits(config, evalConfig) {
|
|
1176
|
-
return { ...MCP_LIMIT_DEFAULTS, ...config.mcp?.limits, ...evalConfig.mcp?.limits };
|
|
1177
|
-
}
|
|
1178
|
-
var REFERENCE = /\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}/g;
|
|
1179
|
-
function expandVars(value, env) {
|
|
1180
|
-
const literal = (text) => {
|
|
1181
|
-
if (text.includes("${")) throw new Error('has a "${" that is not ${NAME} or ${NAME:-default}');
|
|
1182
|
-
return text;
|
|
1183
|
-
};
|
|
1184
|
-
let out = "";
|
|
1185
|
-
let last = 0;
|
|
1186
|
-
for (const match of value.matchAll(REFERENCE)) {
|
|
1187
|
-
const [whole, name, fallback] = match;
|
|
1188
|
-
out += literal(value.slice(last, match.index));
|
|
1189
|
-
const set = env[name];
|
|
1190
|
-
if (set !== void 0 && set !== "") out += set;
|
|
1191
|
-
else if (fallback !== void 0) out += fallback;
|
|
1192
|
-
else
|
|
1193
|
-
throw new Error(
|
|
1194
|
-
`\${${name}} is not set or is empty, and has no default (\${${name}:-default})`
|
|
1195
|
-
);
|
|
1196
|
-
last = match.index + whole.length;
|
|
1197
|
-
}
|
|
1198
|
-
return out + literal(value.slice(last));
|
|
1199
|
-
}
|
|
1200
|
-
function serverValues(server) {
|
|
1201
|
-
const out = [];
|
|
1202
|
-
if (server.command !== void 0) out.push(["command", server.command]);
|
|
1203
|
-
(server.args ?? []).forEach((arg, i) => out.push([`args.${i}`, arg]));
|
|
1204
|
-
for (const [key, value] of Object.entries(server.env ?? {})) out.push([`env.${key}`, value]);
|
|
1205
|
-
if (server.cwd !== void 0) out.push(["cwd", server.cwd]);
|
|
1206
|
-
if (server.url !== void 0) out.push(["url", server.url]);
|
|
1207
|
-
for (const [key, value] of Object.entries(server.headers ?? {}))
|
|
1208
|
-
out.push([`headers.${key}`, value]);
|
|
1209
|
-
return out;
|
|
1210
|
-
}
|
|
1211
|
-
function mcpVariableIssues(config, env) {
|
|
1212
|
-
const issues = [];
|
|
1213
|
-
for (const [name, server] of Object.entries(config.mcp?.servers ?? {})) {
|
|
1214
|
-
for (const [field, value] of serverValues(server)) {
|
|
1215
|
-
try {
|
|
1216
|
-
expandVars(value, env);
|
|
1217
|
-
} catch (err) {
|
|
1218
|
-
issues.push(`mcp.servers.${name}.${field}: ${err.message}`);
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
return issues;
|
|
1223
|
-
}
|
|
1224
|
-
function resolveMcpServer(server, env = process.env, baseDir = process.cwd()) {
|
|
1225
|
-
const fill = (value) => expandVars(value, env);
|
|
1226
|
-
const fillAll = (entries = {}) => Object.fromEntries(Object.entries(entries).map(([key, value]) => [key, fill(value)]));
|
|
1227
|
-
if (server.url !== void 0)
|
|
1228
|
-
return { kind: "http", url: fill(server.url), headers: fillAll(server.headers) };
|
|
1229
|
-
return {
|
|
1230
|
-
kind: "stdio",
|
|
1231
|
-
command: fill(server.command),
|
|
1232
|
-
args: (server.args ?? []).map(fill),
|
|
1233
|
-
env: fillAll(server.env),
|
|
1234
|
-
...server.cwd !== void 0 ? { cwd: path2.resolve(baseDir, fill(server.cwd)) } : {}
|
|
1235
|
-
};
|
|
1236
|
-
}
|
|
1237
|
-
var SECRET_KEY = /authorization|token|key|secret|password/i;
|
|
1238
|
-
function mcpSecretWarnings(config) {
|
|
1239
|
-
const warnings = [];
|
|
1240
|
-
for (const [name, server] of Object.entries(config.mcp?.servers ?? {})) {
|
|
1241
|
-
for (const [field, entries] of [
|
|
1242
|
-
["env", server.env],
|
|
1243
|
-
["headers", server.headers]
|
|
1244
|
-
]) {
|
|
1245
|
-
for (const [key, value] of Object.entries(entries ?? {})) {
|
|
1246
|
-
if (SECRET_KEY.test(key) && !value.includes("${")) {
|
|
1247
|
-
warnings.push(
|
|
1248
|
-
`mcp.servers.${name}.${field}.${key} looks like a secret written into plune.yaml; use \${VAR} so it comes from the environment.`
|
|
1249
|
-
);
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
return warnings;
|
|
1255
|
-
}
|
|
1111
|
+
var MAX_TIMER_MS = 2147483647;
|
|
1256
1112
|
|
|
1257
1113
|
// src/config/schema.ts
|
|
1258
|
-
|
|
1259
|
-
|
|
1114
|
+
var providerTimeoutSchema = import_zod.z.number().int().positive().max(
|
|
1115
|
+
MAX_TIMER_MS,
|
|
1116
|
+
`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`
|
|
1117
|
+
);
|
|
1260
1118
|
var providerConfigSchema = import_zod.z.object({
|
|
1261
1119
|
type: import_zod.z.enum(["anthropic", "openai", "openrouter"]),
|
|
1262
1120
|
model: import_zod.z.string().min(1),
|
|
1263
1121
|
temperature: import_zod.z.number().min(0).max(2).optional(),
|
|
1264
1122
|
max_tokens: import_zod.z.number().int().positive().optional(),
|
|
1265
1123
|
concurrency: import_zod.z.number().int().positive().optional(),
|
|
1266
|
-
timeout:
|
|
1124
|
+
timeout: providerTimeoutSchema.optional(),
|
|
1267
1125
|
max_retries: import_zod.z.number().int().min(0).optional(),
|
|
1268
1126
|
// The values the OpenAI SDK's Chat Completions `reasoning_effort` accepts; only `openai` sends it.
|
|
1269
1127
|
reasoning_effort: import_zod.z.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional()
|
|
@@ -1409,7 +1267,6 @@ var evalRepeatsShape = {
|
|
|
1409
1267
|
runs: import_zod.z.number().int().min(1).max(MAX_RUNS).optional(),
|
|
1410
1268
|
pass_threshold: import_zod.z.number().gt(0, SHARE_MESSAGE).max(1, SHARE_MESSAGE).optional()
|
|
1411
1269
|
};
|
|
1412
|
-
var MAX_TIMER_MS = 2147483647;
|
|
1413
1270
|
var limit = import_zod.z.number().int().positive();
|
|
1414
1271
|
var mcpLimitsSchema = import_zod.z.object({
|
|
1415
1272
|
max_steps: limit.optional(),
|
|
@@ -1529,6 +1386,166 @@ var pluneConfigSchema = import_zod.z.object({
|
|
|
1529
1386
|
return others.length === 0 ? { provider: first, ...rest } : { provider: first, providers: provider, ...rest };
|
|
1530
1387
|
});
|
|
1531
1388
|
|
|
1389
|
+
// src/config/env-overrides.ts
|
|
1390
|
+
function applyEnvOverrides(config, env) {
|
|
1391
|
+
const result = structuredClone(config);
|
|
1392
|
+
const all = result.providers ?? [result.provider];
|
|
1393
|
+
if (result.providers !== void 0) {
|
|
1394
|
+
for (const name of ["PLUNE_PROVIDER", "PLUNE_MODEL"])
|
|
1395
|
+
if (env[name] !== void 0)
|
|
1396
|
+
throw new ConfigValidationError("Config validation failed", [
|
|
1397
|
+
`${name} sets one model, but the config lists ${result.providers.length}: remove it or list a single model`
|
|
1398
|
+
]);
|
|
1399
|
+
}
|
|
1400
|
+
if (env["PLUNE_PROVIDER"] !== void 0) {
|
|
1401
|
+
result.provider.type = env["PLUNE_PROVIDER"];
|
|
1402
|
+
}
|
|
1403
|
+
if (env["PLUNE_MODEL"] !== void 0) {
|
|
1404
|
+
result.provider.model = env["PLUNE_MODEL"];
|
|
1405
|
+
}
|
|
1406
|
+
if (env["PLUNE_TIMEOUT"] !== void 0) {
|
|
1407
|
+
const n = Number(env["PLUNE_TIMEOUT"]);
|
|
1408
|
+
if (Number.isFinite(n)) {
|
|
1409
|
+
const r = providerTimeoutSchema.safeParse(n);
|
|
1410
|
+
if (!r.success)
|
|
1411
|
+
throw new ConfigValidationError(
|
|
1412
|
+
"Config validation failed",
|
|
1413
|
+
r.error.issues.map((issue) => `PLUNE_TIMEOUT=${env["PLUNE_TIMEOUT"]}: ${issue.message}`)
|
|
1414
|
+
);
|
|
1415
|
+
for (const p of all) p.timeout = n;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
if (env["PLUNE_MAX_RETRIES"] !== void 0) {
|
|
1419
|
+
const n = Number(env["PLUNE_MAX_RETRIES"]);
|
|
1420
|
+
if (!isNaN(n)) for (const p of all) p.max_retries = Number.isFinite(n) ? n : 0;
|
|
1421
|
+
}
|
|
1422
|
+
return result;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
// src/config/discover.ts
|
|
1426
|
+
init_cjs_shims();
|
|
1427
|
+
var fs = __toESM(require("fs"), 1);
|
|
1428
|
+
var path = __toESM(require("path"), 1);
|
|
1429
|
+
var FILENAME = "plune.yaml";
|
|
1430
|
+
var MAX_STEPS = 50;
|
|
1431
|
+
function discoverConfigPath(cwd, override) {
|
|
1432
|
+
if (override !== void 0) {
|
|
1433
|
+
if (fs.existsSync(override)) {
|
|
1434
|
+
return override;
|
|
1435
|
+
}
|
|
1436
|
+
throw new ConfigNotFoundError(`Config file not found: ${override}`);
|
|
1437
|
+
}
|
|
1438
|
+
let dir = cwd;
|
|
1439
|
+
let steps = 0;
|
|
1440
|
+
while (steps < MAX_STEPS) {
|
|
1441
|
+
const candidate = path.join(dir, FILENAME);
|
|
1442
|
+
if (fs.existsSync(candidate)) {
|
|
1443
|
+
return candidate;
|
|
1444
|
+
}
|
|
1445
|
+
const parent = path.dirname(dir);
|
|
1446
|
+
if (parent === dir) {
|
|
1447
|
+
break;
|
|
1448
|
+
}
|
|
1449
|
+
dir = parent;
|
|
1450
|
+
steps++;
|
|
1451
|
+
}
|
|
1452
|
+
throw new ConfigNotFoundError(
|
|
1453
|
+
`No ${FILENAME} found. Run "plune init" to create one.`
|
|
1454
|
+
);
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
// src/config/mcp.ts
|
|
1458
|
+
init_cjs_shims();
|
|
1459
|
+
var path2 = __toESM(require("path"), 1);
|
|
1460
|
+
var MCP_LIMIT_DEFAULTS = {
|
|
1461
|
+
max_steps: 10,
|
|
1462
|
+
max_tool_calls: 20,
|
|
1463
|
+
max_total_tokens: 1e5,
|
|
1464
|
+
timeout_ms: 12e4,
|
|
1465
|
+
tool_timeout_ms: 3e4
|
|
1466
|
+
};
|
|
1467
|
+
function mcpLimits(config, evalConfig) {
|
|
1468
|
+
return { ...MCP_LIMIT_DEFAULTS, ...config.mcp?.limits, ...evalConfig.mcp?.limits };
|
|
1469
|
+
}
|
|
1470
|
+
var REFERENCE = /\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}/g;
|
|
1471
|
+
function expandVars(value, env) {
|
|
1472
|
+
const literal = (text) => {
|
|
1473
|
+
if (text.includes("${")) throw new Error('has a "${" that is not ${NAME} or ${NAME:-default}');
|
|
1474
|
+
return text;
|
|
1475
|
+
};
|
|
1476
|
+
let out = "";
|
|
1477
|
+
let last = 0;
|
|
1478
|
+
for (const match of value.matchAll(REFERENCE)) {
|
|
1479
|
+
const [whole, name, fallback] = match;
|
|
1480
|
+
out += literal(value.slice(last, match.index));
|
|
1481
|
+
const set = env[name];
|
|
1482
|
+
if (set !== void 0 && set !== "") out += set;
|
|
1483
|
+
else if (fallback !== void 0) out += fallback;
|
|
1484
|
+
else
|
|
1485
|
+
throw new Error(
|
|
1486
|
+
`\${${name}} is not set or is empty, and has no default (\${${name}:-default})`
|
|
1487
|
+
);
|
|
1488
|
+
last = match.index + whole.length;
|
|
1489
|
+
}
|
|
1490
|
+
return out + literal(value.slice(last));
|
|
1491
|
+
}
|
|
1492
|
+
function serverValues(server) {
|
|
1493
|
+
const out = [];
|
|
1494
|
+
if (server.command !== void 0) out.push(["command", server.command]);
|
|
1495
|
+
(server.args ?? []).forEach((arg, i) => out.push([`args.${i}`, arg]));
|
|
1496
|
+
for (const [key, value] of Object.entries(server.env ?? {})) out.push([`env.${key}`, value]);
|
|
1497
|
+
if (server.cwd !== void 0) out.push(["cwd", server.cwd]);
|
|
1498
|
+
if (server.url !== void 0) out.push(["url", server.url]);
|
|
1499
|
+
for (const [key, value] of Object.entries(server.headers ?? {}))
|
|
1500
|
+
out.push([`headers.${key}`, value]);
|
|
1501
|
+
return out;
|
|
1502
|
+
}
|
|
1503
|
+
function mcpVariableIssues(config, env) {
|
|
1504
|
+
const issues = [];
|
|
1505
|
+
for (const [name, server] of Object.entries(config.mcp?.servers ?? {})) {
|
|
1506
|
+
for (const [field, value] of serverValues(server)) {
|
|
1507
|
+
try {
|
|
1508
|
+
expandVars(value, env);
|
|
1509
|
+
} catch (err) {
|
|
1510
|
+
issues.push(`mcp.servers.${name}.${field}: ${err.message}`);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
return issues;
|
|
1515
|
+
}
|
|
1516
|
+
function resolveMcpServer(server, env = process.env, baseDir = process.cwd()) {
|
|
1517
|
+
const fill = (value) => expandVars(value, env);
|
|
1518
|
+
const fillAll = (entries = {}) => Object.fromEntries(Object.entries(entries).map(([key, value]) => [key, fill(value)]));
|
|
1519
|
+
if (server.url !== void 0)
|
|
1520
|
+
return { kind: "http", url: fill(server.url), headers: fillAll(server.headers) };
|
|
1521
|
+
return {
|
|
1522
|
+
kind: "stdio",
|
|
1523
|
+
command: fill(server.command),
|
|
1524
|
+
args: (server.args ?? []).map(fill),
|
|
1525
|
+
env: fillAll(server.env),
|
|
1526
|
+
...server.cwd !== void 0 ? { cwd: path2.resolve(baseDir, fill(server.cwd)) } : {}
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
var SECRET_KEY = /authorization|token|key|secret|password/i;
|
|
1530
|
+
function mcpSecretWarnings(config) {
|
|
1531
|
+
const warnings = [];
|
|
1532
|
+
for (const [name, server] of Object.entries(config.mcp?.servers ?? {})) {
|
|
1533
|
+
for (const [field, entries] of [
|
|
1534
|
+
["env", server.env],
|
|
1535
|
+
["headers", server.headers]
|
|
1536
|
+
]) {
|
|
1537
|
+
for (const [key, value] of Object.entries(entries ?? {})) {
|
|
1538
|
+
if (SECRET_KEY.test(key) && !value.includes("${")) {
|
|
1539
|
+
warnings.push(
|
|
1540
|
+
`mcp.servers.${name}.${field}.${key} looks like a secret written into plune.yaml; use \${VAR} so it comes from the environment.`
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
return warnings;
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1532
1549
|
// src/config/loader.ts
|
|
1533
1550
|
async function loadConfig(opts = {}) {
|
|
1534
1551
|
const { configPath, cwd = process.cwd(), env = process.env } = opts;
|
|
@@ -1700,7 +1717,7 @@ function readHeader(headers, name) {
|
|
|
1700
1717
|
}
|
|
1701
1718
|
async function withRetry(fn, options) {
|
|
1702
1719
|
const { base_delay_ms = 500, sleep: sleep2 = defaultSleep, random = Math.random } = options;
|
|
1703
|
-
const maxRetries = Math.max(0, Math.floor(options.max_retries));
|
|
1720
|
+
const maxRetries = Number.isFinite(options.max_retries) ? Math.max(0, Math.floor(options.max_retries)) : 0;
|
|
1704
1721
|
let attempt = 0;
|
|
1705
1722
|
for (; ; ) {
|
|
1706
1723
|
try {
|
|
@@ -3340,14 +3357,17 @@ var DEFAULT_MAX_TOKENS = 1024;
|
|
|
3340
3357
|
function buildJudge(provider, cfg, onUsage) {
|
|
3341
3358
|
return {
|
|
3342
3359
|
async ask(prompt5) {
|
|
3360
|
+
const maxTokens = cfg.max_tokens ?? DEFAULT_MAX_TOKENS;
|
|
3343
3361
|
const res = await provider.complete({
|
|
3344
3362
|
provider: cfg.type,
|
|
3345
3363
|
model: cfg.model,
|
|
3346
3364
|
...cfg.temperature !== void 0 ? { temperature: cfg.temperature } : {},
|
|
3347
|
-
max_tokens:
|
|
3365
|
+
max_tokens: maxTokens,
|
|
3348
3366
|
prompt_resolved: prompt5
|
|
3349
3367
|
});
|
|
3350
3368
|
onUsage(res.usage);
|
|
3369
|
+
if (res.finish_reason === "length")
|
|
3370
|
+
throw new Error(`judge reply was cut off at max_tokens (${maxTokens}); raise max_tokens for the judge model`);
|
|
3351
3371
|
return res.output;
|
|
3352
3372
|
}
|
|
3353
3373
|
};
|
|
@@ -3533,6 +3553,70 @@ function scanIds(result) {
|
|
|
3533
3553
|
values: [...found.values].map(([hash, at]) => ({ hash, paths: [...at].sort() }))
|
|
3534
3554
|
};
|
|
3535
3555
|
}
|
|
3556
|
+
var ID_MARK = "<id>";
|
|
3557
|
+
var UUID_IN_TEXT = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;
|
|
3558
|
+
var redactUuids = (text) => text.replace(UUID_IN_TEXT, ID_MARK);
|
|
3559
|
+
var STR = String.raw`"(?:[^"\\]|\\.)*?(?:"|(?= \(cut\)))`;
|
|
3560
|
+
var NUM = String.raw`-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?`;
|
|
3561
|
+
var VAL = `(?:${STR}|${NUM})`;
|
|
3562
|
+
var PAIR = new RegExp(
|
|
3563
|
+
String.raw`"((?:[^"\\]|\\.)*)":(${VAL}|\[(?:${VAL}(?:,${VAL})*)?(?:\]|(?= \(cut\))))`,
|
|
3564
|
+
"g"
|
|
3565
|
+
);
|
|
3566
|
+
var redactReason = (text) => redactUuids(
|
|
3567
|
+
text.replace(
|
|
3568
|
+
PAIR,
|
|
3569
|
+
(whole, key) => isIdKey(key) ? `"${key}":${JSON.stringify(ID_MARK)}` : whole
|
|
3570
|
+
)
|
|
3571
|
+
);
|
|
3572
|
+
function strip(value, depth, st) {
|
|
3573
|
+
if (typeof value === "string") return redactUuids(value);
|
|
3574
|
+
if (depth > SCAN_DEPTH) {
|
|
3575
|
+
if (typeof value === "object" && value !== null) st.whole = false;
|
|
3576
|
+
return value;
|
|
3577
|
+
}
|
|
3578
|
+
if (Array.isArray(value)) {
|
|
3579
|
+
if (value.length > SCAN_ITEMS) st.whole = false;
|
|
3580
|
+
return value.map((v, i) => i < SCAN_ITEMS ? strip(v, depth + 1, st) : v);
|
|
3581
|
+
}
|
|
3582
|
+
if (!isRecord3(value)) return value;
|
|
3583
|
+
const out = {};
|
|
3584
|
+
for (const [key, v] of Object.entries(value)) {
|
|
3585
|
+
let name = redactUuids(key);
|
|
3586
|
+
for (let n = 2; name !== key && Object.hasOwn(out, name); n++) name = `${ID_MARK}#${n}`;
|
|
3587
|
+
out[name] = isIdKey(key) && (isScalar(v) || Array.isArray(v) && v.length > 0 && v.every(isScalar)) ? Array.isArray(v) ? v.map(() => ID_MARK) : ID_MARK : strip(v, depth + 1, st);
|
|
3588
|
+
}
|
|
3589
|
+
return out;
|
|
3590
|
+
}
|
|
3591
|
+
function redactIds(value) {
|
|
3592
|
+
const st = { whole: true };
|
|
3593
|
+
return { value: strip(value, 0, st), whole: st.whole };
|
|
3594
|
+
}
|
|
3595
|
+
function redactAnswer(result) {
|
|
3596
|
+
let unread;
|
|
3597
|
+
const ids = (v) => {
|
|
3598
|
+
const r = redactIds(v);
|
|
3599
|
+
if (!r.whole)
|
|
3600
|
+
unread ??= `the answer is deeper than ${SCAN_DEPTH} levels or has more than ${SCAN_ITEMS} items in a list`;
|
|
3601
|
+
return r.value;
|
|
3602
|
+
};
|
|
3603
|
+
if (!isRecord3(result))
|
|
3604
|
+
return { result: ids(result), ...unread !== void 0 ? { unread } : {} };
|
|
3605
|
+
const out = { ...result };
|
|
3606
|
+
if (result.structuredContent !== void 0) out.structuredContent = ids(result.structuredContent);
|
|
3607
|
+
if (Array.isArray(result.content))
|
|
3608
|
+
out.content = result.content.map((block) => {
|
|
3609
|
+
if (!isRecord3(block) || block.type !== "text" || typeof block.text !== "string")
|
|
3610
|
+
return ids(block);
|
|
3611
|
+
try {
|
|
3612
|
+
return { ...block, text: JSON.stringify(ids(JSON.parse(block.text))) };
|
|
3613
|
+
} catch {
|
|
3614
|
+
unread ??= "the answer is not JSON";
|
|
3615
|
+
return { ...block, text: redactUuids(block.text) };
|
|
3616
|
+
}
|
|
3617
|
+
});
|
|
3618
|
+
return { result: out, ...unread !== void 0 ? { unread } : {} };
|
|
3619
|
+
}
|
|
3536
3620
|
var list = (steps) => steps.join(", ");
|
|
3537
3621
|
function frictionAdvice(calls) {
|
|
3538
3622
|
const acc = /* @__PURE__ */ new Map();
|
|
@@ -3640,6 +3724,7 @@ function resultText(result) {
|
|
|
3640
3724
|
(b) => isRecord4(b) && b.type === "text" && typeof b.text === "string" ? b.text : JSON.stringify(b)
|
|
3641
3725
|
).join("\n");
|
|
3642
3726
|
}
|
|
3727
|
+
var firstBytes = (whole, keep) => whole.subarray(0, keep).toString("utf8").replace(/�$/, "");
|
|
3643
3728
|
function excerpts() {
|
|
3644
3729
|
let left = TRANSCRIPT_BYTES;
|
|
3645
3730
|
const state = {
|
|
@@ -3650,7 +3735,7 @@ function excerpts() {
|
|
|
3650
3735
|
left -= keep;
|
|
3651
3736
|
const truncated = keep < whole.length;
|
|
3652
3737
|
if (truncated) state.any = true;
|
|
3653
|
-
const kept = truncated ? whole
|
|
3738
|
+
const kept = truncated ? firstBytes(whole, keep) : text;
|
|
3654
3739
|
return { text: kept, bytes: whole.length, truncated };
|
|
3655
3740
|
}
|
|
3656
3741
|
};
|
|
@@ -3704,6 +3789,7 @@ async function runAgentRow(p) {
|
|
|
3704
3789
|
let error;
|
|
3705
3790
|
let session;
|
|
3706
3791
|
const scanned = /* @__PURE__ */ new Map();
|
|
3792
|
+
const cleaned = /* @__PURE__ */ new Map();
|
|
3707
3793
|
const overrides = p.toolDescriptions ?? {};
|
|
3708
3794
|
const replaced = /* @__PURE__ */ new Set();
|
|
3709
3795
|
try {
|
|
@@ -3849,6 +3935,17 @@ async function runAgentRow(p) {
|
|
|
3849
3935
|
succeeded ||= !rec.is_error;
|
|
3850
3936
|
if (got.kind === "result" && !rec.is_error) scanned.set(rec, scanIds(got.result));
|
|
3851
3937
|
rec.result = kept.cut(text);
|
|
3938
|
+
if (got.kind === "result") {
|
|
3939
|
+
const r = redactAnswer(got.result);
|
|
3940
|
+
cleaned.set(rec, {
|
|
3941
|
+
text: resultText(r.result),
|
|
3942
|
+
...r.unread !== void 0 ? { unread: r.unread } : {}
|
|
3943
|
+
});
|
|
3944
|
+
} else
|
|
3945
|
+
cleaned.set(rec, {
|
|
3946
|
+
text: redactUuids(text),
|
|
3947
|
+
unread: "the answer is an error message, not JSON"
|
|
3948
|
+
});
|
|
3852
3949
|
answer(rec, c, text);
|
|
3853
3950
|
}
|
|
3854
3951
|
messages.push(
|
|
@@ -3889,8 +3986,44 @@ async function runAgentRow(p) {
|
|
|
3889
3986
|
tool,
|
|
3890
3987
|
sha256: sha256(overrides[tool])
|
|
3891
3988
|
}));
|
|
3989
|
+
const storeWithoutIds = (said = [], err) => {
|
|
3990
|
+
for (const r of said) if (r.reason !== void 0) r.reason = redactReason(r.reason);
|
|
3991
|
+
if (err !== void 0) err.message = redactReason(err.message);
|
|
3992
|
+
const unread = /* @__PURE__ */ new Map();
|
|
3993
|
+
transcript.steps.forEach(
|
|
3994
|
+
(s, si) => s.calls.forEach((c, ci) => {
|
|
3995
|
+
const out = agent.steps[si].calls[ci];
|
|
3996
|
+
out.args = redactIds(out.args).value;
|
|
3997
|
+
const clean = cleaned.get(c);
|
|
3998
|
+
if (out.result === void 0 || clean === void 0) return;
|
|
3999
|
+
const whole = Buffer.from(mask?.text(clean.text) ?? clean.text, "utf8");
|
|
4000
|
+
const keep = Buffer.byteLength(out.result.text, "utf8");
|
|
4001
|
+
out.result = {
|
|
4002
|
+
...out.result,
|
|
4003
|
+
text: out.result.truncated && keep < whole.length ? firstBytes(whole, keep) : whole.toString("utf8")
|
|
4004
|
+
};
|
|
4005
|
+
if (clean.unread === void 0) return;
|
|
4006
|
+
const u = unread.get(c.name) ?? { steps: /* @__PURE__ */ new Set(), count: 0, why: clean.unread };
|
|
4007
|
+
u.steps.add(s.index);
|
|
4008
|
+
u.count++;
|
|
4009
|
+
unread.set(c.name, u);
|
|
4010
|
+
})
|
|
4011
|
+
);
|
|
4012
|
+
return [...unread].map(([tool, u]) => {
|
|
4013
|
+
const steps = [...u.steps].sort((x, y) => x - y);
|
|
4014
|
+
return {
|
|
4015
|
+
type: "ids-not-redacted",
|
|
4016
|
+
tool,
|
|
4017
|
+
steps,
|
|
4018
|
+
count: u.count,
|
|
4019
|
+
reason: `${tool}: ${u.why}, so only UUID-shaped values were replaced in its stored answer; other identifiers may remain (steps ${steps.join(", ")})`
|
|
4020
|
+
};
|
|
4021
|
+
});
|
|
4022
|
+
};
|
|
3892
4023
|
const spent = usages.length > 0 ? { usage: sumUsage(usages) } : {};
|
|
3893
4024
|
if (error !== void 0) {
|
|
4025
|
+
const notes = storeWithoutIds();
|
|
4026
|
+
if (notes.length > 0) agent.advice = notes;
|
|
3894
4027
|
return {
|
|
3895
4028
|
vars: p.row.vars,
|
|
3896
4029
|
output: null,
|
|
@@ -3911,7 +4044,11 @@ async function runAgentRow(p) {
|
|
|
3911
4044
|
const signals = (mask?.value(friction) ?? friction).filter(
|
|
3912
4045
|
(f) => !(f.type === "identical-retry" && covered.some((c) => c.tool === void 0 || c.tool === f.tool))
|
|
3913
4046
|
);
|
|
3914
|
-
const findings = [
|
|
4047
|
+
const findings = [
|
|
4048
|
+
...advice,
|
|
4049
|
+
...signals,
|
|
4050
|
+
...storeWithoutIds([...records, ...advice], assertionError)
|
|
4051
|
+
];
|
|
3915
4052
|
if (findings.length > 0) agent.advice = findings;
|
|
3916
4053
|
const usage = sumUsage(usages);
|
|
3917
4054
|
return {
|
|
@@ -4728,8 +4865,26 @@ var evalResultSchema = import_zod3.z.object({
|
|
|
4728
4865
|
model: import_zod3.z.string().optional()
|
|
4729
4866
|
}).optional(),
|
|
4730
4867
|
/** The type and model of a cell of a multi-model run. Optional and additive. */
|
|
4731
|
-
provider: import_zod3.z.object({ type: import_zod3.z.string(), model: import_zod3.z.string() }).optional()
|
|
4868
|
+
provider: import_zod3.z.object({ type: import_zod3.z.string(), model: import_zod3.z.string() }).optional(),
|
|
4869
|
+
/** The link to the eval's trace in your own observability (Langfuse, OTel). Optional and additive; `plune sync` drops one `traceUrlProblem` refuses. */
|
|
4870
|
+
traceUrl: import_zod3.z.string().optional()
|
|
4732
4871
|
});
|
|
4872
|
+
var TRACE_URL_MAX = 2048;
|
|
4873
|
+
function traceUrlProblem(value) {
|
|
4874
|
+
if (typeof value !== "string") return "not a string";
|
|
4875
|
+
const url = value.trim();
|
|
4876
|
+
if (url.length > TRACE_URL_MAX) return `longer than ${TRACE_URL_MAX} characters`;
|
|
4877
|
+
if (!/^[^\s\p{Cc}\p{Cf}]+$/u.test(url)) return "must not contain spaces or control characters";
|
|
4878
|
+
let parsed2;
|
|
4879
|
+
try {
|
|
4880
|
+
parsed2 = new URL(url);
|
|
4881
|
+
} catch {
|
|
4882
|
+
return "must be an https address";
|
|
4883
|
+
}
|
|
4884
|
+
if (parsed2.protocol !== "https:" || parsed2.hostname === "") return "must be an https address";
|
|
4885
|
+
if (parsed2.username !== "" || parsed2.password !== "") return "must carry no user name or password";
|
|
4886
|
+
return void 0;
|
|
4887
|
+
}
|
|
4733
4888
|
var runResultSchema = import_zod3.z.object({
|
|
4734
4889
|
schemaVersion: import_zod3.z.literal(RUN_RESULT_SCHEMA_VERSION),
|
|
4735
4890
|
plune_version: import_zod3.z.string(),
|
|
@@ -4900,7 +5055,7 @@ var SyncHttpError = class extends Error {
|
|
|
4900
5055
|
}
|
|
4901
5056
|
status;
|
|
4902
5057
|
};
|
|
4903
|
-
function readRun(cwd, file) {
|
|
5058
|
+
function readRun(cwd, file, warn) {
|
|
4904
5059
|
const target = file !== void 0 ? path6.resolve(cwd, file) : path6.join(cwd, ".plune", "last-run.json");
|
|
4905
5060
|
let raw;
|
|
4906
5061
|
try {
|
|
@@ -4916,12 +5071,29 @@ function readRun(cwd, file) {
|
|
|
4916
5071
|
} catch {
|
|
4917
5072
|
throw new SyncFileError(`Run file is not valid JSON: ${target}`);
|
|
4918
5073
|
}
|
|
5074
|
+
dropBadTraceLinks(json, warn);
|
|
4919
5075
|
try {
|
|
4920
5076
|
return parseRunResult(json);
|
|
4921
5077
|
} catch {
|
|
4922
5078
|
throw new SyncFileError(`Run file does not match the RunResult schema: ${target}`);
|
|
4923
5079
|
}
|
|
4924
5080
|
}
|
|
5081
|
+
function dropBadTraceLinks(json, warn) {
|
|
5082
|
+
const evals = json?.evals;
|
|
5083
|
+
if (!Array.isArray(evals)) return;
|
|
5084
|
+
for (const e of evals) {
|
|
5085
|
+
if (typeof e !== "object" || e === null || !("traceUrl" in e)) continue;
|
|
5086
|
+
const entry = e;
|
|
5087
|
+
const problem = traceUrlProblem(entry.traceUrl);
|
|
5088
|
+
if (problem === void 0) {
|
|
5089
|
+
entry.traceUrl = entry.traceUrl.trim();
|
|
5090
|
+
continue;
|
|
5091
|
+
}
|
|
5092
|
+
delete entry.traceUrl;
|
|
5093
|
+
warn(`plune: eval "${String(entry.id)}": trace link not sent (${problem}) \u2014 the eval is synced without it.
|
|
5094
|
+
`);
|
|
5095
|
+
}
|
|
5096
|
+
}
|
|
4925
5097
|
async function safeErrorDetail(res) {
|
|
4926
5098
|
try {
|
|
4927
5099
|
const body = await res.json();
|
|
@@ -4935,7 +5107,7 @@ async function handleSync(deps = {}) {
|
|
|
4935
5107
|
const apiUrl = resolveApiUrl(deps.apiUrl);
|
|
4936
5108
|
const token = (deps.loadToken ?? loadToken)();
|
|
4937
5109
|
if (token === null) throw new NotLoggedInError();
|
|
4938
|
-
const run = readRun(cwd, deps.file);
|
|
5110
|
+
const run = readRun(cwd, deps.file, deps.warn ?? ((line) => process.stderr.write(line)));
|
|
4939
5111
|
const doFetch = deps.fetchImpl ?? fetch;
|
|
4940
5112
|
const endpoint = `${apiUrl}/v1/runs`;
|
|
4941
5113
|
const payload = JSON.stringify(run);
|
package/dist/index.d.cts
CHANGED
|
@@ -174,7 +174,10 @@ interface AgentCall {
|
|
|
174
174
|
*/
|
|
175
175
|
error_kind?: 'content' | 'protocol' | 'timeout' | 'not-offered' | 'bad-arguments';
|
|
176
176
|
duration_ms?: number;
|
|
177
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* The answer as text: `bytes` is its size before `text` was cut to the stored excerpt. Identifier values in `text`
|
|
179
|
+
* and in `args` are stored as `"<id>"` (the checks read them first); see `ids-not-redacted` for a text answer.
|
|
180
|
+
*/
|
|
178
181
|
result?: {
|
|
179
182
|
text: string;
|
|
180
183
|
bytes: number;
|
|
@@ -694,6 +697,8 @@ interface SyncDeps {
|
|
|
694
697
|
fetchImpl?: typeof fetch;
|
|
695
698
|
/** `--fail-on-failures`: read the run's summary back once after the upload and judge it. */
|
|
696
699
|
failOnFailures?: boolean;
|
|
700
|
+
/** Where a warning line goes (a trace link not sent). Defaults to stderr. */
|
|
701
|
+
warn?: (line: string) => void;
|
|
697
702
|
}
|
|
698
703
|
interface SyncResult {
|
|
699
704
|
/** Server-assigned run id. */
|
|
@@ -1067,6 +1072,7 @@ declare const runResultSchema: z.ZodObject<{
|
|
|
1067
1072
|
type: z.ZodString;
|
|
1068
1073
|
model: z.ZodString;
|
|
1069
1074
|
}, z.core.$strip>>;
|
|
1075
|
+
traceUrl: z.ZodOptional<z.ZodString>;
|
|
1070
1076
|
}, z.core.$strip>>;
|
|
1071
1077
|
}, z.core.$strip>;
|
|
1072
1078
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -174,7 +174,10 @@ interface AgentCall {
|
|
|
174
174
|
*/
|
|
175
175
|
error_kind?: 'content' | 'protocol' | 'timeout' | 'not-offered' | 'bad-arguments';
|
|
176
176
|
duration_ms?: number;
|
|
177
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* The answer as text: `bytes` is its size before `text` was cut to the stored excerpt. Identifier values in `text`
|
|
179
|
+
* and in `args` are stored as `"<id>"` (the checks read them first); see `ids-not-redacted` for a text answer.
|
|
180
|
+
*/
|
|
178
181
|
result?: {
|
|
179
182
|
text: string;
|
|
180
183
|
bytes: number;
|
|
@@ -694,6 +697,8 @@ interface SyncDeps {
|
|
|
694
697
|
fetchImpl?: typeof fetch;
|
|
695
698
|
/** `--fail-on-failures`: read the run's summary back once after the upload and judge it. */
|
|
696
699
|
failOnFailures?: boolean;
|
|
700
|
+
/** Where a warning line goes (a trace link not sent). Defaults to stderr. */
|
|
701
|
+
warn?: (line: string) => void;
|
|
697
702
|
}
|
|
698
703
|
interface SyncResult {
|
|
699
704
|
/** Server-assigned run id. */
|
|
@@ -1067,6 +1072,7 @@ declare const runResultSchema: z.ZodObject<{
|
|
|
1067
1072
|
type: z.ZodString;
|
|
1068
1073
|
model: z.ZodString;
|
|
1069
1074
|
}, z.core.$strip>>;
|
|
1075
|
+
traceUrl: z.ZodOptional<z.ZodString>;
|
|
1070
1076
|
}, z.core.$strip>>;
|
|
1071
1077
|
}, z.core.$strip>;
|
|
1072
1078
|
/**
|