@plune-ai/cli 0.38.0 → 0.39.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/README.md +10 -10
- package/dist/cli.cjs +882 -349
- package/dist/index.cjs +1067 -59
- package/dist/index.d.cts +29 -8
- package/dist/index.d.ts +29 -8
- package/dist/index.js +1067 -59
- package/dist/mcp-tools.cjs +10 -10
- package/dist/mcp-tools.d.cts +7 -7
- package/dist/mcp-tools.d.ts +7 -7
- package/dist/mcp-tools.js +10 -10
- package/dist/reporter-core.cjs +265 -237
- package/dist/reporter-core.d.cts +111 -112
- package/dist/reporter-core.d.ts +111 -112
- package/dist/reporter-core.js +265 -237
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,21 +31,23 @@ function machineless(raw, repoRoot, home) {
|
|
|
31
31
|
if (repoRoot === void 0) text = text.replace(ANY_HOME, "~");
|
|
32
32
|
return text;
|
|
33
33
|
}
|
|
34
|
-
function pathIn(
|
|
35
|
-
const parts =
|
|
34
|
+
function pathIn(path12) {
|
|
35
|
+
const parts = path12.split(/[\\/]+/);
|
|
36
36
|
while (parts.length > 1 && parts.at(-1) === "") parts.pop();
|
|
37
37
|
if (!parts.some((part) => part !== "" && !/^[A-Za-z]:$/.test(part))) return void 0;
|
|
38
38
|
const joined = parts.map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("[\\\\/]+");
|
|
39
|
-
const escaped = /^\/(?!\/)/.test(
|
|
39
|
+
const escaped = /^\/(?!\/)/.test(path12) ? joined.replace("[\\\\/]+", "\\\\*\\/") : joined;
|
|
40
40
|
const url = "(?:(?:file|webpack|webpack-internal):(?:\\\\*\\/){2,3})?";
|
|
41
41
|
return new RegExp(`${url}${escaped}`, /^[A-Za-z]:$/.test(parts[0]) ? "gi" : "g");
|
|
42
42
|
}
|
|
43
|
-
var printable, PATH_START, HEADLINE_LIMIT, ANY_HOME;
|
|
43
|
+
var printable, mediaTypeOf, TEXT_TYPES, PATH_START, HEADLINE_LIMIT, ANY_HOME;
|
|
44
44
|
var init_failure_detail = __esm({
|
|
45
45
|
"src/reporter-core/failure-detail.ts"() {
|
|
46
46
|
"use strict";
|
|
47
47
|
init_esm_shims();
|
|
48
48
|
printable = (text) => text.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u202a-\u202e\u2066-\u2069]/g, "?");
|
|
49
|
+
mediaTypeOf = (contentType) => contentType?.split(";")[0]?.trim().toLowerCase() || void 0;
|
|
50
|
+
TEXT_TYPES = /* @__PURE__ */ new Set(["application/json", "text/plain"]);
|
|
49
51
|
PATH_START = "(?<![\\w.~%/\\\\-])";
|
|
50
52
|
HEADLINE_LIMIT = 8 * 1024;
|
|
51
53
|
ANY_HOME = /(?<=^|[\s'"`(=,[])(?:(?:file|webpack|webpack-internal):(?:\\*\/){2,3})?(?:\\*\/home\\*\/|\\*\/Users\\*\/|[A-Za-z]:[\\/]+Users[\\/]+)[^\\/\s'"`:*?<>|]+/g;
|
|
@@ -65,9 +67,9 @@ var init_exit_codes = __esm({
|
|
|
65
67
|
// src/mcp-testing/connect/journal.ts
|
|
66
68
|
import { closeSync, fchmodSync, openSync, writeSync } from "fs";
|
|
67
69
|
import { performance } from "perf_hooks";
|
|
68
|
-
function openJournal(
|
|
69
|
-
if (
|
|
70
|
-
const fd = openSync(
|
|
70
|
+
function openJournal(path12, redact) {
|
|
71
|
+
if (path12 === void 0) return NONE;
|
|
72
|
+
const fd = openSync(path12, "w", 384);
|
|
71
73
|
if (process.platform !== "win32") fchmodSync(fd, 384);
|
|
72
74
|
const start = performance.now();
|
|
73
75
|
let closed = false;
|
|
@@ -432,18 +434,18 @@ function readLines(stream, onLine, stats) {
|
|
|
432
434
|
if (stats !== void 0 && rest.length > stats.high) stats.high = rest.length;
|
|
433
435
|
partial = rest.slice(0, STDERR_LINE_LIMIT);
|
|
434
436
|
};
|
|
435
|
-
return new Promise((
|
|
437
|
+
return new Promise((resolve9) => {
|
|
436
438
|
let done = false;
|
|
437
439
|
const finish = () => {
|
|
438
440
|
if (done) return;
|
|
439
441
|
done = true;
|
|
440
442
|
feed(decoder.end());
|
|
441
443
|
if (partial !== "") onLine(partial.endsWith("\r") ? partial.slice(0, -1) : partial);
|
|
442
|
-
|
|
444
|
+
resolve9();
|
|
443
445
|
};
|
|
444
446
|
stream.on(
|
|
445
447
|
"data",
|
|
446
|
-
(
|
|
448
|
+
(chunk2) => feed(typeof chunk2 === "string" ? chunk2 : decoder.write(chunk2))
|
|
447
449
|
);
|
|
448
450
|
stream.once("end", finish);
|
|
449
451
|
stream.once("close", finish);
|
|
@@ -514,9 +516,9 @@ function watchOverflow(transport, over) {
|
|
|
514
516
|
const buffer = transport._readBuffer;
|
|
515
517
|
const append = buffer?.append?.bind(buffer);
|
|
516
518
|
if (buffer === void 0 || append === void 0) return;
|
|
517
|
-
buffer.append = (
|
|
519
|
+
buffer.append = (chunk2) => {
|
|
518
520
|
try {
|
|
519
|
-
append(
|
|
521
|
+
append(chunk2);
|
|
520
522
|
} catch (err) {
|
|
521
523
|
over();
|
|
522
524
|
throw err;
|
|
@@ -737,7 +739,7 @@ async function openSession(config, options = {}) {
|
|
|
737
739
|
const stdin = transport._process?.stdin;
|
|
738
740
|
if (stdin === null || stdin === void 0 || stdin.writableEnded)
|
|
739
741
|
throw spawnError !== void 0 ? await toConnectError(spawnError) : new ConnectError("exited-early", `${LEAD["exited-early"][0]}.`, [...tail]);
|
|
740
|
-
return new Promise((
|
|
742
|
+
return new Promise((resolve9, reject) => {
|
|
741
743
|
const done = () => {
|
|
742
744
|
clearTimeout(timer2);
|
|
743
745
|
listeners.delete(listener);
|
|
@@ -751,7 +753,7 @@ async function openSession(config, options = {}) {
|
|
|
751
753
|
const frame2 = parsed(line);
|
|
752
754
|
if (!answers(frame2, id)) return;
|
|
753
755
|
done();
|
|
754
|
-
|
|
756
|
+
resolve9({ frame: frame2, text: clean(line).slice(0, RAW_TEXT) });
|
|
755
757
|
};
|
|
756
758
|
const stop = () => {
|
|
757
759
|
done();
|
|
@@ -831,10 +833,10 @@ async function openSession(config, options = {}) {
|
|
|
831
833
|
const proc = transport._process;
|
|
832
834
|
if (proc === void 0) return true;
|
|
833
835
|
if (proc.exitCode !== null || proc.signalCode !== null) return true;
|
|
834
|
-
const exited = new Promise((
|
|
836
|
+
const exited = new Promise((resolve9) => proc.once("exit", () => resolve9(true)));
|
|
835
837
|
proc.stdin?.end();
|
|
836
838
|
let timer2;
|
|
837
|
-
const late = new Promise((
|
|
839
|
+
const late = new Promise((resolve9) => timer2 = setTimeout(() => resolve9(false), waitMs));
|
|
838
840
|
const result = await Promise.race([exited, late]);
|
|
839
841
|
clearTimeout(timer2);
|
|
840
842
|
return result;
|
|
@@ -1464,11 +1466,11 @@ var pluneConfigSchema = z.object({
|
|
|
1464
1466
|
config.evals.forEach((evalConfig, i) => {
|
|
1465
1467
|
const server = evalConfig.mcp?.server;
|
|
1466
1468
|
if (server === void 0) {
|
|
1467
|
-
const misplaced = (assertions,
|
|
1469
|
+
const misplaced = (assertions, path12) => assertions.forEach((a, j) => {
|
|
1468
1470
|
if (TOOL_CALL_TYPES.has(a.type))
|
|
1469
1471
|
ctx.addIssue({
|
|
1470
1472
|
code: "custom",
|
|
1471
|
-
path: [...
|
|
1473
|
+
path: [...path12, j, "type"],
|
|
1472
1474
|
message: `"${a.type}" reads the tool calls of an eval with mcp, and eval "${evalConfig.id}" has no mcp block`
|
|
1473
1475
|
});
|
|
1474
1476
|
});
|
|
@@ -1637,7 +1639,7 @@ function normalizeProviderError(err, secret, envVar) {
|
|
|
1637
1639
|
}
|
|
1638
1640
|
|
|
1639
1641
|
// src/providers/retry.ts
|
|
1640
|
-
var defaultSleep = (ms) => new Promise((
|
|
1642
|
+
var defaultSleep = (ms) => new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
1641
1643
|
function retryAfterMs(err) {
|
|
1642
1644
|
if (typeof err !== "object" || err === null || !("headers" in err)) return void 0;
|
|
1643
1645
|
const raw = readHeader(err.headers, "retry-after");
|
|
@@ -1659,7 +1661,7 @@ function readHeader(headers, name) {
|
|
|
1659
1661
|
return typeof v === "string" || typeof v === "number" ? v : void 0;
|
|
1660
1662
|
}
|
|
1661
1663
|
async function withRetry(fn, options) {
|
|
1662
|
-
const { base_delay_ms = 500, sleep = defaultSleep, random = Math.random } = options;
|
|
1664
|
+
const { base_delay_ms = 500, sleep: sleep2 = defaultSleep, random = Math.random } = options;
|
|
1663
1665
|
const maxRetries = Math.max(0, Math.floor(options.max_retries));
|
|
1664
1666
|
let attempt = 0;
|
|
1665
1667
|
for (; ; ) {
|
|
@@ -1675,7 +1677,7 @@ async function withRetry(fn, options) {
|
|
|
1675
1677
|
const backoff = base_delay_ms * 2 ** attempt;
|
|
1676
1678
|
const jitter = backoff * 0.1 * random();
|
|
1677
1679
|
const delay = Math.max(backoff + jitter, retryAfterMs(err) ?? 0);
|
|
1678
|
-
await
|
|
1680
|
+
await sleep2(delay);
|
|
1679
1681
|
attempt += 1;
|
|
1680
1682
|
}
|
|
1681
1683
|
}
|
|
@@ -2091,6 +2093,13 @@ function makeEstimateProvider(config, pricing) {
|
|
|
2091
2093
|
|
|
2092
2094
|
// src/providers/mock.ts
|
|
2093
2095
|
init_esm_shims();
|
|
2096
|
+
function picked(pick, tools) {
|
|
2097
|
+
const words = pick.toLowerCase().split(/\s+/).filter(Boolean);
|
|
2098
|
+
const hits = tools.filter(
|
|
2099
|
+
(t) => words.every((w) => (t.description ?? "").toLowerCase().includes(w))
|
|
2100
|
+
);
|
|
2101
|
+
return hits.length === 1 ? hits[0].name : void 0;
|
|
2102
|
+
}
|
|
2094
2103
|
var USAGE = { input_tokens: 10, output_tokens: 5 };
|
|
2095
2104
|
function parseMockScript(text) {
|
|
2096
2105
|
let parsed2;
|
|
@@ -2105,7 +2114,7 @@ function parseMockScript(text) {
|
|
|
2105
2114
|
if (t !== void 0 && typeof t !== "string") return false;
|
|
2106
2115
|
if (calls === void 0) return true;
|
|
2107
2116
|
return Array.isArray(calls) && calls.every(
|
|
2108
|
-
(c) => typeof c === "object" && c !== null && typeof c.name === "string"
|
|
2117
|
+
(c) => typeof c === "object" && c !== null && (typeof c.name === "string" || typeof c.pick === "string")
|
|
2109
2118
|
);
|
|
2110
2119
|
};
|
|
2111
2120
|
if (!Array.isArray(parsed2) || parsed2.length === 0 || !parsed2.every(isStep))
|
|
@@ -2124,14 +2133,13 @@ function makeMockProvider(script) {
|
|
|
2124
2133
|
respond: (req) => {
|
|
2125
2134
|
const step = req.messages.filter((m) => m.role === "assistant").length;
|
|
2126
2135
|
const entry = script[Math.min(step, script.length - 1)];
|
|
2127
|
-
const calls = entry.tool_calls ?? []
|
|
2136
|
+
const calls = (entry.tool_calls ?? []).flatMap((c) => {
|
|
2137
|
+
const name = "name" in c ? c.name : picked(c.pick, req.tools);
|
|
2138
|
+
return name === void 0 ? [] : [{ name, args: c.args ?? {} }];
|
|
2139
|
+
});
|
|
2128
2140
|
return Promise.resolve({
|
|
2129
2141
|
text: entry.text ?? "",
|
|
2130
|
-
tool_calls: calls.map((c, i) => ({
|
|
2131
|
-
id: `call_${step}_${i}`,
|
|
2132
|
-
name: c.name,
|
|
2133
|
-
args: c.args ?? {}
|
|
2134
|
-
})),
|
|
2142
|
+
tool_calls: calls.map((c, i) => ({ id: `call_${step}_${i}`, ...c })),
|
|
2135
2143
|
usage: USAGE,
|
|
2136
2144
|
finish_reason: calls.length > 0 ? "tool_calls" : "stop"
|
|
2137
2145
|
});
|
|
@@ -2180,7 +2188,7 @@ var XenovaEmbedder = class {
|
|
|
2180
2188
|
throw new Error(
|
|
2181
2189
|
"The `semantic-similarity` and RAG assertions need local embeddings, which ship separately: install @huggingface/transformers to enable them. Every other assertion works without it."
|
|
2182
2190
|
);
|
|
2183
|
-
}).then(({ pipeline }) =>
|
|
2191
|
+
}).then(({ pipeline: pipeline2 }) => pipeline2("feature-extraction", MODEL_ID));
|
|
2184
2192
|
return this.extractor;
|
|
2185
2193
|
}
|
|
2186
2194
|
};
|
|
@@ -3343,9 +3351,9 @@ var testCaseBaseSchema = z2.object({
|
|
|
3343
3351
|
schemaVersion: z2.literal(TEST_CASE_SCHEMA_VERSION),
|
|
3344
3352
|
id: z2.string().min(1),
|
|
3345
3353
|
externalKeys: z2.array(externalKeySchema).optional(),
|
|
3346
|
-
/**
|
|
3354
|
+
/** Optional, purely additive; schemaVersion stays 2. */
|
|
3347
3355
|
is_flaky: z2.boolean().optional(),
|
|
3348
|
-
/**
|
|
3356
|
+
/** Optional, purely additive; schemaVersion stays 2. */
|
|
3349
3357
|
is_muted: z2.boolean().optional()
|
|
3350
3358
|
});
|
|
3351
3359
|
var testCaseSchema = z2.discriminatedUnion("type", [
|
|
@@ -3411,7 +3419,7 @@ function segment(key) {
|
|
|
3411
3419
|
const plain = /^[A-Za-z_][\w-]*$/.test(key) && key.length <= 40 && !UUID.test(key) && !EMAIL.test(key);
|
|
3412
3420
|
return plain ? key : "*";
|
|
3413
3421
|
}
|
|
3414
|
-
var cap = (
|
|
3422
|
+
var cap = (path12) => path12.length > MAX_PATH ? path12.slice(0, MAX_PATH) : path12;
|
|
3415
3423
|
var hashOf = (v) => sha256(v).slice(0, 16);
|
|
3416
3424
|
function noteValue(out, v, at) {
|
|
3417
3425
|
if (typeof v !== "string" || v.length < MIN_VALUE) return;
|
|
@@ -3420,20 +3428,20 @@ function noteValue(out, v, at) {
|
|
|
3420
3428
|
where.add(at);
|
|
3421
3429
|
out.values.set(h, where);
|
|
3422
3430
|
}
|
|
3423
|
-
function walk(value,
|
|
3431
|
+
function walk(value, path12, depth, out) {
|
|
3424
3432
|
if (depth > SCAN_DEPTH) return;
|
|
3425
3433
|
if (typeof value === "string" && UUID.test(value)) {
|
|
3426
|
-
const at = cap(
|
|
3434
|
+
const at = cap(path12 === "" ? "(root)" : path12);
|
|
3427
3435
|
out.paths.add(at);
|
|
3428
3436
|
noteValue(out, value, at);
|
|
3429
3437
|
}
|
|
3430
3438
|
if (Array.isArray(value)) {
|
|
3431
|
-
for (const item of value.slice(0, SCAN_ITEMS)) walk(item, `${
|
|
3439
|
+
for (const item of value.slice(0, SCAN_ITEMS)) walk(item, `${path12}[]`, depth + 1, out);
|
|
3432
3440
|
return;
|
|
3433
3441
|
}
|
|
3434
3442
|
if (!isRecord3(value)) return;
|
|
3435
3443
|
for (const [key, v] of Object.entries(value)) {
|
|
3436
|
-
const at = cap(
|
|
3444
|
+
const at = cap(path12 === "" ? segment(key) : `${path12}.${segment(key)}`);
|
|
3437
3445
|
if (isIdKey(key) && (isScalar(v) || Array.isArray(v) && v.length > 0 && v.every(isScalar))) {
|
|
3438
3446
|
out.paths.add(at);
|
|
3439
3447
|
for (const x of Array.isArray(v) ? v : [v]) noteValue(out, x, at);
|
|
@@ -4556,7 +4564,7 @@ var rowResultSchema = z3.object({
|
|
|
4556
4564
|
error: runErrorSchema.optional(),
|
|
4557
4565
|
assertions: z3.array(assertionResultRecordSchema2),
|
|
4558
4566
|
cache_saved: savedSchema.optional(),
|
|
4559
|
-
/**
|
|
4567
|
+
/** Optional and additive — the same enum the platform validates on `POST /v1/runs`. */
|
|
4560
4568
|
inconclusive: z3.enum(ROW_INCONCLUSIVE).optional(),
|
|
4561
4569
|
/** Repeats (`runs` above 1). Optional and additive — a RunResult without it validates unchanged. */
|
|
4562
4570
|
attempts: z3.object({
|
|
@@ -4633,7 +4641,7 @@ var summarySchema = z3.object({
|
|
|
4633
4641
|
passed: z3.number(),
|
|
4634
4642
|
failed: z3.number(),
|
|
4635
4643
|
errored: z3.number(),
|
|
4636
|
-
/**
|
|
4644
|
+
/** Optional and additive — a RunResult written before them validates unchanged. */
|
|
4637
4645
|
blocked: z3.number().optional(),
|
|
4638
4646
|
skipped: z3.number().optional(),
|
|
4639
4647
|
cost_usd: z3.number(),
|
|
@@ -4772,7 +4780,7 @@ var JobReporter = class {
|
|
|
4772
4780
|
}
|
|
4773
4781
|
/**
|
|
4774
4782
|
* The upload is in: every row is on the platform. `subjectId` is what the job works on, learnt from the upload's
|
|
4775
|
-
* answer (the run an ingest landed in): the platform takes it while the job names none
|
|
4783
|
+
* answer (the run an ingest landed in): the platform takes it while the job names none.
|
|
4776
4784
|
*/
|
|
4777
4785
|
async uploaded(at) {
|
|
4778
4786
|
if (this.id === void 0) return;
|
|
@@ -4937,12 +4945,802 @@ function reportSyncFailure(err, write) {
|
|
|
4937
4945
|
|
|
4938
4946
|
// src/cli/commands/ingest.ts
|
|
4939
4947
|
init_esm_shims();
|
|
4948
|
+
import * as path11 from "path";
|
|
4949
|
+
|
|
4950
|
+
// src/reporter-core/client.ts
|
|
4951
|
+
init_esm_shims();
|
|
4952
|
+
import { createReadStream, openAsBlob } from "fs";
|
|
4953
|
+
import { pipeline } from "stream";
|
|
4954
|
+
import { Agent as HttpAgent, request as httpRequest } from "http";
|
|
4955
|
+
import { Agent as HttpsAgent, request as httpsRequest } from "https";
|
|
4956
|
+
var BACKOFF_BASE_MS = 300;
|
|
4957
|
+
var BACKOFF_CAP_MS = 1e4;
|
|
4958
|
+
var DEFAULT_RETRIES = 2;
|
|
4959
|
+
var RETRY_AFTER_CAP_MS = 6e4;
|
|
4960
|
+
function parseRetryAfter(raw, now = Date.now()) {
|
|
4961
|
+
const text = raw?.trim();
|
|
4962
|
+
if (text === void 0 || text === "") return null;
|
|
4963
|
+
const seconds = /^\d+(\.\d+)?$/.test(text) ? Number(text) : (Date.parse(text) - now) / 1e3;
|
|
4964
|
+
if (!Number.isFinite(seconds)) return null;
|
|
4965
|
+
return Math.min(Math.max(seconds, 0) * 1e3, RETRY_AFTER_CAP_MS);
|
|
4966
|
+
}
|
|
4967
|
+
var POOLS = { "http:": new HttpAgent({ keepAlive: true }), "https:": new HttpsAgent({ keepAlive: true }) };
|
|
4968
|
+
var IDLE_MS = 3e5;
|
|
4969
|
+
function nodeTransport(url, init, idleMs = IDLE_MS) {
|
|
4970
|
+
return new Promise((resolve9, reject) => {
|
|
4971
|
+
const target = new URL(url);
|
|
4972
|
+
const send = target.protocol === "https:" ? httpsRequest : httpRequest;
|
|
4973
|
+
const agent = POOLS[target.protocol === "https:" ? "https:" : "http:"];
|
|
4974
|
+
const req = send(target, { method: init.method, headers: init.headers, agent }, (res) => {
|
|
4975
|
+
const chunks = [];
|
|
4976
|
+
res.on("data", (chunk2) => chunks.push(chunk2));
|
|
4977
|
+
res.on("error", reject);
|
|
4978
|
+
res.on("end", () => {
|
|
4979
|
+
const status = res.statusCode ?? 0;
|
|
4980
|
+
const text = Buffer.concat(chunks).toString("utf8");
|
|
4981
|
+
resolve9({
|
|
4982
|
+
ok: status >= 200 && status <= 299,
|
|
4983
|
+
status,
|
|
4984
|
+
headers: {
|
|
4985
|
+
get: (name) => {
|
|
4986
|
+
const value = res.headers[name.toLowerCase()];
|
|
4987
|
+
return value === void 0 ? null : Array.isArray(value) ? value.join(", ") : value;
|
|
4988
|
+
}
|
|
4989
|
+
},
|
|
4990
|
+
json: async () => JSON.parse(text)
|
|
4991
|
+
});
|
|
4992
|
+
});
|
|
4993
|
+
});
|
|
4994
|
+
req.setTimeout(idleMs, () => req.destroy(new Error(`no answer from ${target.origin} in ${idleMs} ms`)));
|
|
4995
|
+
req.on("error", reject);
|
|
4996
|
+
req.end(init.body);
|
|
4997
|
+
});
|
|
4998
|
+
}
|
|
4999
|
+
var withoutLength = (headers) => Object.fromEntries(Object.entries(headers).filter(([name]) => name.toLowerCase() !== "content-length"));
|
|
5000
|
+
function nodePut(url, headers, source, idleMs) {
|
|
5001
|
+
return new Promise((resolve9, reject) => {
|
|
5002
|
+
const target = new URL(url);
|
|
5003
|
+
const send = target.protocol === "https:" ? httpsRequest : httpRequest;
|
|
5004
|
+
const length = "body" in source ? source.body.length : source.size;
|
|
5005
|
+
let answered;
|
|
5006
|
+
const settle = (err) => answered !== void 0 ? resolve9(answered) : reject(err);
|
|
5007
|
+
const req = send(
|
|
5008
|
+
target,
|
|
5009
|
+
{ method: "PUT", headers: { ...withoutLength(headers), "content-length": String(length) } },
|
|
5010
|
+
(res) => {
|
|
5011
|
+
const retry = res.headers["retry-after"];
|
|
5012
|
+
answered = { status: res.statusCode ?? 0, retryAfter: Array.isArray(retry) ? retry[0] ?? null : retry ?? null };
|
|
5013
|
+
res.on("error", settle);
|
|
5014
|
+
res.on("close", () => {
|
|
5015
|
+
resolve9(answered);
|
|
5016
|
+
req.destroy();
|
|
5017
|
+
});
|
|
5018
|
+
res.resume();
|
|
5019
|
+
}
|
|
5020
|
+
);
|
|
5021
|
+
req.setTimeout(idleMs, () => req.destroy(Object.assign(new Error("idle"), { code: "ETIMEDOUT" })));
|
|
5022
|
+
req.on("error", settle);
|
|
5023
|
+
if ("body" in source) req.end(source.body);
|
|
5024
|
+
else pipeline(createReadStream(source.path), req, (err) => err ? settle(err) : void 0);
|
|
5025
|
+
});
|
|
5026
|
+
}
|
|
5027
|
+
var codeOfError = (err) => {
|
|
5028
|
+
const code = err?.code;
|
|
5029
|
+
return typeof code === "string" && /^[A-Z0-9_]{2,40}$/.test(code) ? code : "network";
|
|
5030
|
+
};
|
|
5031
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
5032
|
+
async function detailOf(res) {
|
|
5033
|
+
try {
|
|
5034
|
+
const body = await res.json();
|
|
5035
|
+
const q = body.quota;
|
|
5036
|
+
return {
|
|
5037
|
+
...typeof body.shardsExpected === "number" && Number.isInteger(body.shardsExpected) ? { shardsExpected: body.shardsExpected } : {},
|
|
5038
|
+
detail: typeof body.error === "string" ? body.error : "",
|
|
5039
|
+
...typeof q === "object" && q !== null && !Array.isArray(q) ? { quota: q } : {},
|
|
5040
|
+
...typeof body.code === "string" && /^[a-z0-9_]{1,60}$/.test(body.code) ? { code: body.code } : {}
|
|
5041
|
+
};
|
|
5042
|
+
} catch {
|
|
5043
|
+
return { detail: "" };
|
|
5044
|
+
}
|
|
5045
|
+
}
|
|
5046
|
+
function describeQuota(q) {
|
|
5047
|
+
const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
5048
|
+
const kind = typeof q["kind"] === "string" ? q["kind"].slice(0, 60) : "limit";
|
|
5049
|
+
const [used, limit2] = [num(q["used"]), num(q["limit"])];
|
|
5050
|
+
const parts = [used !== void 0 && limit2 !== void 0 ? `${kind}: ${used} of ${limit2} used` : kind];
|
|
5051
|
+
if (typeof q["resetsAt"] === "string" && q["resetsAt"] !== "") parts.push(`resets ${q["resetsAt"].slice(0, 40)}`);
|
|
5052
|
+
return parts.join(", ");
|
|
5053
|
+
}
|
|
5054
|
+
function classify(status) {
|
|
5055
|
+
if (status === 401 || status === 403) return "auth";
|
|
5056
|
+
if (status === 409) return "conflict";
|
|
5057
|
+
if (status === 400) return "invalid";
|
|
5058
|
+
if (status === 429 || status >= 500) return "unavailable";
|
|
5059
|
+
return "other";
|
|
5060
|
+
}
|
|
5061
|
+
function createClient(opts) {
|
|
5062
|
+
const doFetch = opts.fetchImpl ?? nodeTransport;
|
|
5063
|
+
const wait = opts.wait ?? sleep;
|
|
5064
|
+
const uploadRetries = opts.uploadRetries === void 0 ? void 0 : Math.max(0, Math.floor(opts.uploadRetries));
|
|
5065
|
+
const random = opts.random ?? Math.random;
|
|
5066
|
+
const now = opts.now ?? Date.now;
|
|
5067
|
+
let pausedUntil = 0;
|
|
5068
|
+
const jittered = (ms) => Math.round(ms * (1 + random() * 0.5));
|
|
5069
|
+
async function backOff(attempt, said) {
|
|
5070
|
+
opts.onRetry?.();
|
|
5071
|
+
const ms = jittered(said ?? Math.min(BACKOFF_BASE_MS * 2 ** attempt, BACKOFF_CAP_MS));
|
|
5072
|
+
const until = now() + ms;
|
|
5073
|
+
pausedUntil = Math.max(pausedUntil, until);
|
|
5074
|
+
await wait(ms);
|
|
5075
|
+
return until;
|
|
5076
|
+
}
|
|
5077
|
+
async function respectPause(mine) {
|
|
5078
|
+
const left = pausedUntil - now();
|
|
5079
|
+
if (pausedUntil > mine && left > 0) await wait(left + Math.round(random() * 250));
|
|
5080
|
+
}
|
|
5081
|
+
const base = opts.apiUrl.replace(/\/+$/, "");
|
|
5082
|
+
const scrub = (text) => opts.token === "" ? text : text.split(opts.token).join("***");
|
|
5083
|
+
async function send(method, path12, payload, retries = DEFAULT_RETRIES) {
|
|
5084
|
+
let last = {
|
|
5085
|
+
kind: "unavailable",
|
|
5086
|
+
status: null,
|
|
5087
|
+
detail: "no attempt was made"
|
|
5088
|
+
};
|
|
5089
|
+
let mine = 0;
|
|
5090
|
+
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
5091
|
+
await respectPause(mine);
|
|
5092
|
+
let res;
|
|
5093
|
+
try {
|
|
5094
|
+
res = await doFetch(`${base}${path12}`, {
|
|
5095
|
+
method,
|
|
5096
|
+
headers: { "content-type": payload?.type ?? "application/json", authorization: `Bearer ${opts.token}` },
|
|
5097
|
+
// A DELETE carries none. Sending `"undefined"` as a body is what a naive
|
|
5098
|
+
// `JSON.stringify(body)` would do, and some proxies answer that with a 400 nobody can
|
|
5099
|
+
// explain.
|
|
5100
|
+
...payload === void 0 ? {} : { body: payload.body }
|
|
5101
|
+
});
|
|
5102
|
+
} catch (err) {
|
|
5103
|
+
last = { kind: "unavailable", status: null, detail: scrub(String(err)) };
|
|
5104
|
+
if (attempt >= Math.min(retries, DEFAULT_RETRIES)) break;
|
|
5105
|
+
mine = await backOff(attempt, null);
|
|
5106
|
+
continue;
|
|
5107
|
+
}
|
|
5108
|
+
if (res.ok) {
|
|
5109
|
+
if (res.status === 204) return { ok: true, status: res.status, body: void 0 };
|
|
5110
|
+
try {
|
|
5111
|
+
return { ok: true, status: res.status, body: await res.json() };
|
|
5112
|
+
} catch {
|
|
5113
|
+
return { ok: false, kind: "other", status: res.status, detail: "the answer was not JSON" };
|
|
5114
|
+
}
|
|
5115
|
+
}
|
|
5116
|
+
const said = await detailOf(res);
|
|
5117
|
+
const kind = classify(res.status);
|
|
5118
|
+
last = { kind, status: res.status, detail: scrub(said.detail), ...said.code !== void 0 ? { code: said.code } : {}, ...said.shardsExpected !== void 0 ? { shardsExpected: said.shardsExpected } : {} };
|
|
5119
|
+
if (kind !== "unavailable") break;
|
|
5120
|
+
const said429 = parseRetryAfter(res.headers.get("retry-after"), now());
|
|
5121
|
+
if (res.status === 429 && (said.quota !== void 0 || said429 === null)) {
|
|
5122
|
+
last.kind = "invalid";
|
|
5123
|
+
last.detail = `quota exceeded (${said.quota === void 0 ? "no Retry-After" : scrub(describeQuota(said.quota))})`;
|
|
5124
|
+
if (said.detail) last.detail += ` \u2014 ${scrub(said.detail)}`;
|
|
5125
|
+
break;
|
|
5126
|
+
}
|
|
5127
|
+
if (attempt >= (said429 === null ? Math.min(retries, DEFAULT_RETRIES) : retries)) break;
|
|
5128
|
+
mine = await backOff(attempt, said429);
|
|
5129
|
+
}
|
|
5130
|
+
return { ok: false, ...last };
|
|
5131
|
+
}
|
|
5132
|
+
return {
|
|
5133
|
+
post: (path12, body, retries) => send("POST", path12, { body: JSON.stringify(body), type: "application/json" }, retries),
|
|
5134
|
+
upload: (path12, bytes, contentType) => send("POST", path12, { body: bytes, type: contentType }, uploadRetries ?? DEFAULT_RETRIES),
|
|
5135
|
+
del: (path12) => send("DELETE", path12),
|
|
5136
|
+
get: (path12) => send("GET", path12),
|
|
5137
|
+
async put(url, headers, source) {
|
|
5138
|
+
const putRetries = uploadRetries ?? 3;
|
|
5139
|
+
let last = { ok: false, status: null, code: "network" };
|
|
5140
|
+
let mine = 0;
|
|
5141
|
+
for (let attempt = 0; attempt <= putRetries; attempt += 1) {
|
|
5142
|
+
await respectPause(mine);
|
|
5143
|
+
try {
|
|
5144
|
+
let status;
|
|
5145
|
+
let retryAfter;
|
|
5146
|
+
if (opts.fetchImpl === void 0) ({ status, retryAfter } = await nodePut(url, headers, source, IDLE_MS));
|
|
5147
|
+
else {
|
|
5148
|
+
const body = "body" in source ? source.body : await openAsBlob(source.path);
|
|
5149
|
+
const res = await opts.fetchImpl(url, { method: "PUT", headers: withoutLength(headers), body });
|
|
5150
|
+
await res.arrayBuffer().catch(() => void 0);
|
|
5151
|
+
status = res.status;
|
|
5152
|
+
retryAfter = res.headers.get("retry-after");
|
|
5153
|
+
}
|
|
5154
|
+
if (status >= 200 && status <= 299) return { ok: true };
|
|
5155
|
+
last = { ok: false, status, code: `bucket_${status}` };
|
|
5156
|
+
if (status < 500 && status !== 429) return last;
|
|
5157
|
+
const said = parseRetryAfter(retryAfter, now());
|
|
5158
|
+
if (attempt >= (said === null ? Math.min(putRetries, 3) : putRetries)) return last;
|
|
5159
|
+
mine = await backOff(attempt, said);
|
|
5160
|
+
continue;
|
|
5161
|
+
} catch (err) {
|
|
5162
|
+
last = { ok: false, status: null, code: codeOfError(err) };
|
|
5163
|
+
}
|
|
5164
|
+
if (attempt >= Math.min(putRetries, 3)) return last;
|
|
5165
|
+
mine = await backOff(attempt, null);
|
|
5166
|
+
}
|
|
5167
|
+
return last;
|
|
5168
|
+
}
|
|
5169
|
+
};
|
|
5170
|
+
}
|
|
5171
|
+
|
|
5172
|
+
// src/reporter-core/env.ts
|
|
5173
|
+
init_esm_shims();
|
|
5174
|
+
import * as path8 from "path";
|
|
5175
|
+
var UPLOAD_RETRIES = { min: 0, max: 20, default: 6 };
|
|
5176
|
+
|
|
5177
|
+
// src/reporter-core/session.ts
|
|
5178
|
+
init_esm_shims();
|
|
5179
|
+
import { createHash as createHash4, randomUUID } from "crypto";
|
|
5180
|
+
import { promises as disk } from "fs";
|
|
5181
|
+
import { basename as basename3, extname } from "path";
|
|
5182
|
+
import { TextDecoder as TextDecoder2 } from "util";
|
|
5183
|
+
init_failure_detail();
|
|
5184
|
+
|
|
5185
|
+
// src/reporter-core/files-batch.ts
|
|
5186
|
+
init_esm_shims();
|
|
5187
|
+
import { createHash as createHash3 } from "crypto";
|
|
5188
|
+
import { createReadStream as createReadStream2 } from "fs";
|
|
5189
|
+
var FILES_BATCH_MAX = 100;
|
|
5190
|
+
var DIRECT_BATCH_BYTES = 6 * 1024 * 1024;
|
|
5191
|
+
var BATCH_PIPELINES = 2;
|
|
5192
|
+
async function sha256File(path12) {
|
|
5193
|
+
const hash = createHash3("sha256");
|
|
5194
|
+
for await (const part of createReadStream2(path12)) hash.update(part);
|
|
5195
|
+
return hash.digest("hex");
|
|
5196
|
+
}
|
|
5197
|
+
var sha256Bytes = (bytes) => createHash3("sha256").update(bytes).digest("hex");
|
|
5198
|
+
var BUCKET_CODES = /* @__PURE__ */ new Set([
|
|
5199
|
+
"bucket_unreachable",
|
|
5200
|
+
"not_connected",
|
|
5201
|
+
"platform_not_configured",
|
|
5202
|
+
"upload_expired",
|
|
5203
|
+
"file_mismatch",
|
|
5204
|
+
"file_missing"
|
|
5205
|
+
]);
|
|
5206
|
+
|
|
5207
|
+
// src/reporter-core/fallback.ts
|
|
5208
|
+
init_esm_shims();
|
|
5209
|
+
import * as fs7 from "fs";
|
|
4940
5210
|
import * as path9 from "path";
|
|
5211
|
+
var DEFAULT_FALLBACK_PATH = path9.join(".plune", "pending-results.jsonl");
|
|
5212
|
+
|
|
5213
|
+
// src/reporter-core/session.ts
|
|
5214
|
+
var SCREENSHOT_TYPES = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/webp"]);
|
|
5215
|
+
var SCREENSHOT_BYTES = 2 * 1024 * 1024;
|
|
5216
|
+
var SCREENSHOTS_PER_RESULT = 20;
|
|
5217
|
+
var TEXT_BYTES = 512 * 1024;
|
|
5218
|
+
var TEXTS_PER_RESULT = 10;
|
|
5219
|
+
var UTF8 = new TextDecoder2("utf-8", { fatal: true });
|
|
5220
|
+
var TYPE_BY_EXTENSION = {
|
|
5221
|
+
".png": "image/png",
|
|
5222
|
+
".jpg": "image/jpeg",
|
|
5223
|
+
".jpeg": "image/jpeg",
|
|
5224
|
+
".webp": "image/webp"
|
|
5225
|
+
};
|
|
5226
|
+
var METADATA_TYPE = "application/plune.metadata+json";
|
|
5227
|
+
var NAME_MAX = 200;
|
|
5228
|
+
function nameOf(file) {
|
|
5229
|
+
const own2 = file.name.split(/[\\/]/).pop()?.trim() || (file.path === void 0 ? "" : basename3(file.path));
|
|
5230
|
+
const fileExt = file.path === void 0 ? "" : extname(file.path);
|
|
5231
|
+
const ownExt = extname(own2);
|
|
5232
|
+
const typed = ownExt !== "" && (ownExt.toLowerCase() === fileExt.toLowerCase() || TYPE_BY_EXTENSION[ownExt.toLowerCase()] !== void 0);
|
|
5233
|
+
const ext = typed ? ownExt : fileExt;
|
|
5234
|
+
let stem = typed ? own2.slice(0, -ownExt.length) : own2;
|
|
5235
|
+
if (stem.length + ext.length > NAME_MAX) {
|
|
5236
|
+
stem = stem.slice(0, Math.max(0, NAME_MAX - ext.length));
|
|
5237
|
+
if (/[\uD800-\uDBFF]$/.test(stem)) stem = stem.slice(0, -1);
|
|
5238
|
+
}
|
|
5239
|
+
return `${stem}${ext}`;
|
|
5240
|
+
}
|
|
5241
|
+
var SKIPPED = {
|
|
5242
|
+
hidden: "its name starts with an underscore, which hides an attachment in Playwright's own reports too",
|
|
5243
|
+
type: "Plune takes PNG, JPEG and WebP",
|
|
5244
|
+
limit: `a result holds at most ${SCREENSHOTS_PER_RESULT}`,
|
|
5245
|
+
missing: "the file cannot be read on this machine",
|
|
5246
|
+
size: "Plune takes a file of at most 2 MB",
|
|
5247
|
+
textLimit: `a result holds at most ${TEXTS_PER_RESULT} text files`,
|
|
5248
|
+
textSize: "Plune takes a text file of at most 512 KiB",
|
|
5249
|
+
empty: "the file is empty",
|
|
5250
|
+
binary: "the file holds a NUL byte, and Plune takes UTF-8 text without one",
|
|
5251
|
+
encoding: "Plune takes UTF-8 text only",
|
|
5252
|
+
noStorage: "no storage bucket is connected to this project"
|
|
5253
|
+
};
|
|
5254
|
+
var BUCKET_FOUND = "plune: storage bucket found for this project \u2014 screenshots, text, trace and video go straight to it over short-lived links.";
|
|
5255
|
+
var KINDS = {
|
|
5256
|
+
screenshot: { label: "screenshot", bytes: SCREENSHOT_BYTES, room: SCREENSHOTS_PER_RESULT, limit: "limit", size: "size" },
|
|
5257
|
+
text: { label: "text file", bytes: TEXT_BYTES, room: TEXTS_PER_RESULT, limit: "textLimit", size: "textSize" },
|
|
5258
|
+
// Only the label is used: a file of this kind has no home in the database, so no ceiling of its own is known here.
|
|
5259
|
+
file: { label: "file", bytes: 0, room: 0, limit: "limit", size: "size" }
|
|
5260
|
+
};
|
|
5261
|
+
function kindOf2(type) {
|
|
5262
|
+
if (type.startsWith("image/")) return "screenshot";
|
|
5263
|
+
return TEXT_TYPES.has(type) ? "text" : "file";
|
|
5264
|
+
}
|
|
5265
|
+
var codeOf2 = (out) => out.code ?? (out.status === null ? "network" : `http_${out.status}`);
|
|
5266
|
+
function linkOf(item) {
|
|
5267
|
+
const link = item;
|
|
5268
|
+
if (typeof link?.id !== "string" || typeof link.url !== "string") return void 0;
|
|
5269
|
+
const headers = typeof link.headers === "object" && link.headers !== null ? link.headers : {};
|
|
5270
|
+
return { id: link.id, url: link.url, headers };
|
|
5271
|
+
}
|
|
5272
|
+
function textTypeOf(contentType, type) {
|
|
5273
|
+
const charset = /;\s*charset\s*=\s*"?([^\s";]+)"?/i.exec(contentType)?.[1];
|
|
5274
|
+
return charset?.toLowerCase() === "utf-8" ? `${type}; charset=utf-8` : type;
|
|
5275
|
+
}
|
|
5276
|
+
function textRefusal(bytes) {
|
|
5277
|
+
if (bytes.length > TEXT_BYTES) return "textSize";
|
|
5278
|
+
if (bytes.length === 0) return "empty";
|
|
5279
|
+
if (bytes.includes(0)) return "binary";
|
|
5280
|
+
try {
|
|
5281
|
+
UTF8.decode(bytes);
|
|
5282
|
+
} catch {
|
|
5283
|
+
return "encoding";
|
|
5284
|
+
}
|
|
5285
|
+
return void 0;
|
|
5286
|
+
}
|
|
5287
|
+
var BATCH_BYTES = 8 * 1024 * 1024;
|
|
5288
|
+
var ENVELOPE_BYTES = Buffer.byteLength(JSON.stringify({ results: [] }));
|
|
5289
|
+
function chunk(items, size) {
|
|
5290
|
+
const out = [];
|
|
5291
|
+
for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
|
|
5292
|
+
return out;
|
|
5293
|
+
}
|
|
5294
|
+
function fileSender(options) {
|
|
5295
|
+
const { client, log, stats, uploadsAtOnce, uploadRetries } = options;
|
|
5296
|
+
const without = options.without ?? "its result is reported without it";
|
|
5297
|
+
let retried = 0;
|
|
5298
|
+
let uploadMs = 0;
|
|
5299
|
+
let requests = 0;
|
|
5300
|
+
let existed = 0;
|
|
5301
|
+
let batchMissing = false;
|
|
5302
|
+
const skipsSaid = /* @__PURE__ */ new Set();
|
|
5303
|
+
const countsOf = (kind) => kind === "text" ? stats.textFiles : kind === "file" ? stats.otherFiles : stats.screenshots;
|
|
5304
|
+
let bucketSeen = false;
|
|
5305
|
+
let noStorage = 0;
|
|
5306
|
+
let uploadsMissing = false;
|
|
5307
|
+
const failedSaid = /* @__PURE__ */ new Set();
|
|
5308
|
+
const codesSaid = /* @__PURE__ */ new Set();
|
|
5309
|
+
const rooms = /* @__PURE__ */ new Map();
|
|
5310
|
+
function skip(kind, name, why) {
|
|
5311
|
+
countsOf(kind).skipped += 1;
|
|
5312
|
+
if (why === "noStorage") noStorage += 1;
|
|
5313
|
+
const said = why === "noStorage" ? why : `${kind}/${why}`;
|
|
5314
|
+
if (skipsSaid.has(said)) return;
|
|
5315
|
+
skipsSaid.add(said);
|
|
5316
|
+
if (why === "noStorage") log(`plune: "${name}" not stored \u2014 ${SKIPPED[why]}.`);
|
|
5317
|
+
else log(`plune: ${KINDS[kind].label} "${name}" not uploaded \u2014 ${SKIPPED[why]}.`);
|
|
5318
|
+
}
|
|
5319
|
+
const filesOf = (job) => `/v1/${job.owner ?? "results"}/${encodeURIComponent(job.id)}/files`;
|
|
5320
|
+
function ask(job, size) {
|
|
5321
|
+
requests += 1;
|
|
5322
|
+
return client.post(`${filesOf(job)}/uploads`, {
|
|
5323
|
+
files: [{ name: job.name, contentType: job.type, size, ...job.key !== void 0 ? { key: job.key } : {} }]
|
|
5324
|
+
}, uploadRetries);
|
|
5325
|
+
}
|
|
5326
|
+
function failed(job, why) {
|
|
5327
|
+
countsOf(job.kind).failed += 1;
|
|
5328
|
+
if (!failedSaid.has(job.kind)) {
|
|
5329
|
+
failedSaid.add(job.kind);
|
|
5330
|
+
log(`plune: could not upload a ${KINDS[job.kind].label} (${why}) \u2014 ${without}.`);
|
|
5331
|
+
}
|
|
5332
|
+
}
|
|
5333
|
+
function failedToBucket(job, code) {
|
|
5334
|
+
countsOf(job.kind).failed += 1;
|
|
5335
|
+
if (codesSaid.has(code)) return;
|
|
5336
|
+
codesSaid.add(code);
|
|
5337
|
+
log(`plune: "${job.name}" not uploaded to your bucket (${code}) \u2014 ${without}.`);
|
|
5338
|
+
}
|
|
5339
|
+
function refusedHere(job, size) {
|
|
5340
|
+
if (job.kind === "screenshot") {
|
|
5341
|
+
if (!SCREENSHOT_TYPES.has(job.type)) return "type";
|
|
5342
|
+
if (size > SCREENSHOT_BYTES) return "size";
|
|
5343
|
+
}
|
|
5344
|
+
if (job.kind === "text" && size > TEXT_BYTES) return "textSize";
|
|
5345
|
+
return void 0;
|
|
5346
|
+
}
|
|
5347
|
+
async function uploadDirect(job, size) {
|
|
5348
|
+
const { kind } = job;
|
|
5349
|
+
if (kind === "file") return skip(kind, job.name, "noStorage");
|
|
5350
|
+
const { bytes: ceiling, size: tooBig } = KINDS[kind];
|
|
5351
|
+
if (size > ceiling) return skip(kind, job.name, tooBig);
|
|
5352
|
+
let bytes;
|
|
5353
|
+
if (job.body !== void 0) bytes = job.body;
|
|
5354
|
+
else {
|
|
5355
|
+
try {
|
|
5356
|
+
bytes = await disk.readFile(job.path);
|
|
5357
|
+
} catch {
|
|
5358
|
+
return skip(kind, job.name, "missing");
|
|
5359
|
+
}
|
|
5360
|
+
}
|
|
5361
|
+
const refusal = kind === "text" ? textRefusal(bytes) : void 0;
|
|
5362
|
+
if (refusal !== void 0) return skip(kind, job.name, refusal);
|
|
5363
|
+
requests += 1;
|
|
5364
|
+
const out = await client.upload(
|
|
5365
|
+
`${filesOf(job)}?name=${encodeURIComponent(job.name)}`,
|
|
5366
|
+
bytes,
|
|
5367
|
+
job.type
|
|
5368
|
+
);
|
|
5369
|
+
if (out.ok) countsOf(kind).uploaded += 1;
|
|
5370
|
+
else failed(job, out.detail || out.kind);
|
|
5371
|
+
}
|
|
5372
|
+
async function uploadToBucket(job, size, first) {
|
|
5373
|
+
const source = job.body !== void 0 ? { body: job.body } : { path: job.path, size };
|
|
5374
|
+
let link = first;
|
|
5375
|
+
for (let renewed = false; ; ) {
|
|
5376
|
+
const put = await client.put(link.url, link.headers, source);
|
|
5377
|
+
if (put.ok) break;
|
|
5378
|
+
if (put.status !== 403 || renewed) return failedToBucket(job, put.code);
|
|
5379
|
+
renewed = true;
|
|
5380
|
+
const again = await ask(job, size);
|
|
5381
|
+
if (!again.ok) return failedToBucket(job, codeOf2(again));
|
|
5382
|
+
const fresh = linkOf(again.body?.files?.[0]);
|
|
5383
|
+
if (fresh === void 0) return failedToBucket(job, "bad_answer");
|
|
5384
|
+
link = fresh;
|
|
5385
|
+
}
|
|
5386
|
+
requests += 1;
|
|
5387
|
+
const done = await client.post(`/v1/files/${encodeURIComponent(link.id)}/complete`, {}, uploadRetries);
|
|
5388
|
+
if (!done.ok) return failedToBucket(job, codeOf2(done));
|
|
5389
|
+
countsOf(job.kind).uploaded += 1;
|
|
5390
|
+
}
|
|
5391
|
+
let free = uploadsAtOnce;
|
|
5392
|
+
const waiting = [];
|
|
5393
|
+
async function gated(work) {
|
|
5394
|
+
if (free === 0) await new Promise((resolve9) => waiting.push(resolve9));
|
|
5395
|
+
else free -= 1;
|
|
5396
|
+
try {
|
|
5397
|
+
return await work();
|
|
5398
|
+
} finally {
|
|
5399
|
+
const next = waiting.shift();
|
|
5400
|
+
if (next !== void 0) next();
|
|
5401
|
+
else free += 1;
|
|
5402
|
+
}
|
|
5403
|
+
}
|
|
5404
|
+
async function plan(job) {
|
|
5405
|
+
const { kind } = job;
|
|
5406
|
+
let size;
|
|
5407
|
+
if (job.body !== void 0) size = job.body.length;
|
|
5408
|
+
else if (job.path === void 0) return void skip(kind, job.name, "missing");
|
|
5409
|
+
else {
|
|
5410
|
+
try {
|
|
5411
|
+
size = (await disk.stat(job.path)).size;
|
|
5412
|
+
} catch {
|
|
5413
|
+
return void skip(kind, job.name, "missing");
|
|
5414
|
+
}
|
|
5415
|
+
}
|
|
5416
|
+
if (size === 0) return void skip(kind, job.name, "empty");
|
|
5417
|
+
const direct = () => {
|
|
5418
|
+
if (kind === "file") return void skip(kind, job.name, "noStorage");
|
|
5419
|
+
const roomKey = `${job.id}/${kind}`;
|
|
5420
|
+
const left = rooms.get(roomKey) ?? KINDS[kind].room;
|
|
5421
|
+
if (left === 0) return void skip(kind, job.name, KINDS[kind].limit);
|
|
5422
|
+
rooms.set(roomKey, left - 1);
|
|
5423
|
+
return () => uploadDirect(job, size);
|
|
5424
|
+
};
|
|
5425
|
+
if (uploadsMissing) return direct();
|
|
5426
|
+
const out = await gated(() => ask(job, size));
|
|
5427
|
+
if (!out.ok) {
|
|
5428
|
+
if (out.status === 404 && out.detail === "" && out.code === void 0) {
|
|
5429
|
+
uploadsMissing = true;
|
|
5430
|
+
return direct();
|
|
5431
|
+
}
|
|
5432
|
+
if (out.code !== void 0) failedToBucket(job, out.code);
|
|
5433
|
+
else failed(job, out.detail || out.kind);
|
|
5434
|
+
return void 0;
|
|
5435
|
+
}
|
|
5436
|
+
const item = out.body?.files?.[0];
|
|
5437
|
+
if (item?.skipped === "no_storage") return void skip(kind, job.name, refusedHere(job, size) ?? "noStorage");
|
|
5438
|
+
if (item?.direct === true) return direct();
|
|
5439
|
+
const link = linkOf(item);
|
|
5440
|
+
if (link === void 0) return void failed(job, "bad_answer");
|
|
5441
|
+
if (!bucketSeen) {
|
|
5442
|
+
bucketSeen = true;
|
|
5443
|
+
log(BUCKET_FOUND);
|
|
5444
|
+
}
|
|
5445
|
+
return () => uploadToBucket(job, size, link);
|
|
5446
|
+
}
|
|
5447
|
+
async function uploadEach(jobs) {
|
|
5448
|
+
const byResult = /* @__PURE__ */ new Map();
|
|
5449
|
+
for (const job of jobs) byResult.set(job.id, [...byResult.get(job.id) ?? [], job]);
|
|
5450
|
+
await Promise.all(
|
|
5451
|
+
[...byResult.values()].map(async (group) => {
|
|
5452
|
+
const work = [];
|
|
5453
|
+
for (const job of group) {
|
|
5454
|
+
const act = await plan(job);
|
|
5455
|
+
if (act !== void 0) work.push(gated(act));
|
|
5456
|
+
}
|
|
5457
|
+
await Promise.all(work);
|
|
5458
|
+
})
|
|
5459
|
+
);
|
|
5460
|
+
}
|
|
5461
|
+
async function measure(job) {
|
|
5462
|
+
let size;
|
|
5463
|
+
if (job.body !== void 0) size = job.body.length;
|
|
5464
|
+
else if (job.path === void 0) return void skip(job.kind, job.name, "missing");
|
|
5465
|
+
else {
|
|
5466
|
+
try {
|
|
5467
|
+
size = (await disk.stat(job.path)).size;
|
|
5468
|
+
} catch {
|
|
5469
|
+
return void skip(job.kind, job.name, "missing");
|
|
5470
|
+
}
|
|
5471
|
+
}
|
|
5472
|
+
if (size === 0) return void skip(job.kind, job.name, "empty");
|
|
5473
|
+
return size;
|
|
5474
|
+
}
|
|
5475
|
+
const routeMissing = (out) => !out.ok && out.status === 404 && out.detail === "" && out.code === void 0;
|
|
5476
|
+
function takeRoom(job) {
|
|
5477
|
+
if (job.kind === "file") {
|
|
5478
|
+
skip(job.kind, job.name, "noStorage");
|
|
5479
|
+
return false;
|
|
5480
|
+
}
|
|
5481
|
+
const roomKey = `${job.id}/${job.kind}`;
|
|
5482
|
+
const left = rooms.get(roomKey) ?? KINDS[job.kind].room;
|
|
5483
|
+
if (left === 0) {
|
|
5484
|
+
skip(job.kind, job.name, KINDS[job.kind].limit);
|
|
5485
|
+
return false;
|
|
5486
|
+
}
|
|
5487
|
+
rooms.set(roomKey, left - 1);
|
|
5488
|
+
return true;
|
|
5489
|
+
}
|
|
5490
|
+
function refusedItem(job, size, item) {
|
|
5491
|
+
const code = item.code ?? "refused";
|
|
5492
|
+
if (code === "duplicate") existed += 1;
|
|
5493
|
+
else if (code === "no_storage") skip(job.kind, job.name, refusedHere(job, size) ?? "noStorage");
|
|
5494
|
+
else if (code === "too_many_files") skip(job.kind, job.name, KINDS[job.kind].limit);
|
|
5495
|
+
else if (BUCKET_CODES.has(code)) failedToBucket(job, code);
|
|
5496
|
+
else failed(job, code);
|
|
5497
|
+
}
|
|
5498
|
+
const itemPause = (round) => new Promise((r) => setTimeout(r, Math.min(250 * 2 ** round, 4e3)));
|
|
5499
|
+
async function batchOf(jobs) {
|
|
5500
|
+
if (batchMissing) return uploadEach(jobs);
|
|
5501
|
+
const sized = [];
|
|
5502
|
+
for (const job of jobs) {
|
|
5503
|
+
const size = await measure(job);
|
|
5504
|
+
if (size === void 0) continue;
|
|
5505
|
+
try {
|
|
5506
|
+
sized.push({ job, size, sha256: job.body !== void 0 ? sha256Bytes(job.body) : await sha256File(job.path) });
|
|
5507
|
+
} catch {
|
|
5508
|
+
skip(job.kind, job.name, "missing");
|
|
5509
|
+
}
|
|
5510
|
+
}
|
|
5511
|
+
if (sized.length === 0) return;
|
|
5512
|
+
const announced = await gated(() => {
|
|
5513
|
+
requests += 1;
|
|
5514
|
+
return client.post(
|
|
5515
|
+
"/v1/files/uploads-batch",
|
|
5516
|
+
{ items: sized.map((s) => ({ resultId: s.job.id, name: s.job.name, contentType: s.job.type, size: s.size, sha256: s.sha256 })) },
|
|
5517
|
+
uploadRetries
|
|
5518
|
+
);
|
|
5519
|
+
});
|
|
5520
|
+
if (routeMissing(announced)) {
|
|
5521
|
+
batchMissing = true;
|
|
5522
|
+
return uploadEach(sized.map((s) => s.job));
|
|
5523
|
+
}
|
|
5524
|
+
const verdicts = announced.ok ? announced.body?.items : void 0;
|
|
5525
|
+
if (!announced.ok || !Array.isArray(verdicts) || verdicts.length !== sized.length) {
|
|
5526
|
+
for (const s of sized) {
|
|
5527
|
+
if (announced.ok) failed(s.job, "bad_answer");
|
|
5528
|
+
else if (announced.code !== void 0) failedToBucket(s.job, announced.code);
|
|
5529
|
+
else failed(s.job, announced.detail || announced.kind);
|
|
5530
|
+
}
|
|
5531
|
+
return;
|
|
5532
|
+
}
|
|
5533
|
+
const puts = [];
|
|
5534
|
+
const directs = [];
|
|
5535
|
+
sized.forEach((s, i) => {
|
|
5536
|
+
const v = verdicts[i] ?? {};
|
|
5537
|
+
if (v.status === "exists") existed += 1;
|
|
5538
|
+
else if (v.status === "direct") {
|
|
5539
|
+
if (takeRoom(s.job)) directs.push(s);
|
|
5540
|
+
} else if (v.status === "upload") {
|
|
5541
|
+
const link = linkOf(v);
|
|
5542
|
+
if (link === void 0) return failed(s.job, "bad_answer");
|
|
5543
|
+
if (!bucketSeen) {
|
|
5544
|
+
bucketSeen = true;
|
|
5545
|
+
log(BUCKET_FOUND);
|
|
5546
|
+
}
|
|
5547
|
+
puts.push({ s, link });
|
|
5548
|
+
} else if (v.status === "refused") refusedItem(s.job, s.size, v);
|
|
5549
|
+
else failed(s.job, "bad_answer");
|
|
5550
|
+
});
|
|
5551
|
+
const toComplete = [];
|
|
5552
|
+
await Promise.all(
|
|
5553
|
+
puts.map(
|
|
5554
|
+
({ s, link: first }) => gated(async () => {
|
|
5555
|
+
const source = s.job.body !== void 0 ? { body: s.job.body } : { path: s.job.path, size: s.size };
|
|
5556
|
+
let link = first;
|
|
5557
|
+
for (let renewed = false; ; ) {
|
|
5558
|
+
const put = await client.put(link.url, link.headers, source);
|
|
5559
|
+
if (put.ok) break;
|
|
5560
|
+
if (put.status !== 403 || renewed) return failedToBucket(s.job, put.code);
|
|
5561
|
+
renewed = true;
|
|
5562
|
+
requests += 1;
|
|
5563
|
+
const again = await client.post(
|
|
5564
|
+
"/v1/files/uploads-batch",
|
|
5565
|
+
{ items: [{ resultId: s.job.id, name: s.job.name, contentType: s.job.type, size: s.size, sha256: s.sha256 }] },
|
|
5566
|
+
uploadRetries
|
|
5567
|
+
);
|
|
5568
|
+
const fresh = again.ok ? linkOf(again.body?.items?.[0]) : void 0;
|
|
5569
|
+
if (fresh === void 0) return failedToBucket(s.job, again.ok ? "bad_answer" : codeOf2(again));
|
|
5570
|
+
link = fresh;
|
|
5571
|
+
}
|
|
5572
|
+
toComplete.push({ job: s.job, id: link.id });
|
|
5573
|
+
})
|
|
5574
|
+
)
|
|
5575
|
+
);
|
|
5576
|
+
await complete(toComplete);
|
|
5577
|
+
await sendDirect(directs);
|
|
5578
|
+
}
|
|
5579
|
+
async function complete(items) {
|
|
5580
|
+
for (let round = 0; items.length > 0; round += 1) {
|
|
5581
|
+
const out = await gated(() => {
|
|
5582
|
+
requests += 1;
|
|
5583
|
+
return client.post("/v1/files/complete-batch", { ids: items.map((i) => i.id) }, uploadRetries);
|
|
5584
|
+
});
|
|
5585
|
+
if (routeMissing(out)) {
|
|
5586
|
+
await Promise.all(
|
|
5587
|
+
items.map(
|
|
5588
|
+
(i) => gated(async () => {
|
|
5589
|
+
requests += 1;
|
|
5590
|
+
const one = await client.post(`/v1/files/${encodeURIComponent(i.id)}/complete`, {}, uploadRetries);
|
|
5591
|
+
if (one.ok) countsOf(i.job.kind).uploaded += 1;
|
|
5592
|
+
else failedToBucket(i.job, codeOf2(one));
|
|
5593
|
+
})
|
|
5594
|
+
)
|
|
5595
|
+
);
|
|
5596
|
+
return;
|
|
5597
|
+
}
|
|
5598
|
+
const verdicts = out.ok ? out.body?.items : void 0;
|
|
5599
|
+
if (!out.ok || !Array.isArray(verdicts) || verdicts.length !== items.length) {
|
|
5600
|
+
for (const i of items) failedToBucket(i.job, out.ok ? "bad_answer" : codeOf2(out));
|
|
5601
|
+
return;
|
|
5602
|
+
}
|
|
5603
|
+
const again = [];
|
|
5604
|
+
items.forEach((i, at) => {
|
|
5605
|
+
const v = verdicts[at] ?? {};
|
|
5606
|
+
if (v.status === "ready") countsOf(i.job.kind).uploaded += 1;
|
|
5607
|
+
else if (v.retryable === true && round < Math.min(uploadRetries, 3)) again.push(i);
|
|
5608
|
+
else refusedItem(i.job, 0, v.status === "refused" ? v : { code: "bad_answer" });
|
|
5609
|
+
});
|
|
5610
|
+
items = again;
|
|
5611
|
+
if (items.length > 0) {
|
|
5612
|
+
retried += items.length;
|
|
5613
|
+
await itemPause(round);
|
|
5614
|
+
}
|
|
5615
|
+
}
|
|
5616
|
+
}
|
|
5617
|
+
async function sendDirect(items) {
|
|
5618
|
+
const groups = [];
|
|
5619
|
+
let bytes = 0;
|
|
5620
|
+
for (const item of items) {
|
|
5621
|
+
const group = groups[groups.length - 1];
|
|
5622
|
+
if (group === void 0 || group.length >= FILES_BATCH_MAX || bytes + item.size > DIRECT_BATCH_BYTES) {
|
|
5623
|
+
groups.push([item]);
|
|
5624
|
+
bytes = item.size;
|
|
5625
|
+
} else {
|
|
5626
|
+
group.push(item);
|
|
5627
|
+
bytes += item.size;
|
|
5628
|
+
}
|
|
5629
|
+
}
|
|
5630
|
+
for (const group of groups) {
|
|
5631
|
+
const body = [];
|
|
5632
|
+
const sent = [];
|
|
5633
|
+
for (const { job, size } of group) {
|
|
5634
|
+
const { kind } = job;
|
|
5635
|
+
if (size > KINDS[kind].bytes) {
|
|
5636
|
+
skip(kind, job.name, KINDS[kind].size);
|
|
5637
|
+
continue;
|
|
5638
|
+
}
|
|
5639
|
+
let data;
|
|
5640
|
+
try {
|
|
5641
|
+
data = job.body ?? await disk.readFile(job.path);
|
|
5642
|
+
} catch {
|
|
5643
|
+
skip(kind, job.name, "missing");
|
|
5644
|
+
continue;
|
|
5645
|
+
}
|
|
5646
|
+
const refusal = kind === "text" ? textRefusal(data) : void 0;
|
|
5647
|
+
if (refusal !== void 0) {
|
|
5648
|
+
skip(kind, job.name, refusal);
|
|
5649
|
+
continue;
|
|
5650
|
+
}
|
|
5651
|
+
body.push({ resultId: job.id, name: job.name, contentType: job.type, data: data.toString("base64") });
|
|
5652
|
+
sent.push({ job, size });
|
|
5653
|
+
}
|
|
5654
|
+
if (body.length === 0) continue;
|
|
5655
|
+
const out = await gated(() => {
|
|
5656
|
+
requests += 1;
|
|
5657
|
+
return client.post("/v1/files/direct-batch", { items: body }, uploadRetries);
|
|
5658
|
+
});
|
|
5659
|
+
if (routeMissing(out)) {
|
|
5660
|
+
batchMissing = true;
|
|
5661
|
+
for (const { job, size } of sent) await gated(() => uploadDirect(job, size));
|
|
5662
|
+
continue;
|
|
5663
|
+
}
|
|
5664
|
+
const verdicts = out.ok ? out.body?.items : void 0;
|
|
5665
|
+
if (!out.ok || !Array.isArray(verdicts) || verdicts.length !== sent.length) {
|
|
5666
|
+
for (const { job } of sent) failed(job, out.ok ? "bad_answer" : out.detail || out.kind);
|
|
5667
|
+
continue;
|
|
5668
|
+
}
|
|
5669
|
+
sent.forEach(({ job }, i) => {
|
|
5670
|
+
const v = verdicts[i] ?? {};
|
|
5671
|
+
if (v.status === "stored") countsOf(job.kind).uploaded += 1;
|
|
5672
|
+
else if (v.status === "exists") existed += 1;
|
|
5673
|
+
else refusedItem(job, 0, v.status === "refused" ? v : { code: "bad_answer" });
|
|
5674
|
+
});
|
|
5675
|
+
}
|
|
5676
|
+
}
|
|
5677
|
+
async function uploadBatched(jobs) {
|
|
5678
|
+
const batches = chunk(jobs, FILES_BATCH_MAX);
|
|
5679
|
+
let next = 0;
|
|
5680
|
+
await Promise.all(
|
|
5681
|
+
Array.from({ length: Math.min(BATCH_PIPELINES, batches.length) }, async () => {
|
|
5682
|
+
for (let at = next++; at < batches.length; at = next++) await batchOf(batches[at]);
|
|
5683
|
+
})
|
|
5684
|
+
);
|
|
5685
|
+
}
|
|
5686
|
+
async function upload(items, filesByKey) {
|
|
5687
|
+
if (filesByKey.size === 0 || !Array.isArray(items)) return;
|
|
5688
|
+
const jobs = [];
|
|
5689
|
+
for (const item of items) {
|
|
5690
|
+
if (item?.status !== "accepted" || typeof item.id !== "string" || typeof item.resultKey !== "string") continue;
|
|
5691
|
+
for (const file of filesByKey.get(item.resultKey) ?? []) {
|
|
5692
|
+
const type = mediaTypeOf(file.contentType) ?? (file.path === void 0 ? void 0 : TYPE_BY_EXTENSION[extname(file.path).toLowerCase()]);
|
|
5693
|
+
if (type === void 0 || type === METADATA_TYPE) continue;
|
|
5694
|
+
const kind = kindOf2(type);
|
|
5695
|
+
if (kind !== "text" && file.path === void 0) continue;
|
|
5696
|
+
const name = nameOf(file);
|
|
5697
|
+
if (file.name.startsWith("_")) skip(kind, name, "hidden");
|
|
5698
|
+
else {
|
|
5699
|
+
jobs.push({
|
|
5700
|
+
id: item.id,
|
|
5701
|
+
kind,
|
|
5702
|
+
name,
|
|
5703
|
+
type: kind === "text" ? textTypeOf(file.contentType ?? "", type) : type,
|
|
5704
|
+
...file.body !== void 0 ? { body: file.body } : {},
|
|
5705
|
+
...file.path !== void 0 ? { path: file.path } : {}
|
|
5706
|
+
});
|
|
5707
|
+
}
|
|
5708
|
+
}
|
|
5709
|
+
}
|
|
5710
|
+
const started = Date.now();
|
|
5711
|
+
if (batchMissing) await uploadEach(jobs);
|
|
5712
|
+
else await uploadBatched(jobs);
|
|
5713
|
+
uploadMs += Date.now() - started;
|
|
5714
|
+
}
|
|
5715
|
+
return {
|
|
5716
|
+
upload,
|
|
5717
|
+
uploadEach,
|
|
5718
|
+
onRetry: () => void (retried += 1),
|
|
5719
|
+
get bucketSeen() {
|
|
5720
|
+
return bucketSeen;
|
|
5721
|
+
},
|
|
5722
|
+
get noStorage() {
|
|
5723
|
+
return noStorage;
|
|
5724
|
+
},
|
|
5725
|
+
get existed() {
|
|
5726
|
+
return existed;
|
|
5727
|
+
},
|
|
5728
|
+
get retried() {
|
|
5729
|
+
return retried;
|
|
5730
|
+
},
|
|
5731
|
+
get uploadMs() {
|
|
5732
|
+
return uploadMs;
|
|
5733
|
+
},
|
|
5734
|
+
get requests() {
|
|
5735
|
+
return requests;
|
|
5736
|
+
}
|
|
5737
|
+
};
|
|
5738
|
+
}
|
|
4941
5739
|
|
|
4942
5740
|
// src/cli/commands/cairn-artifact.ts
|
|
4943
5741
|
init_esm_shims();
|
|
4944
|
-
import * as
|
|
4945
|
-
import * as
|
|
5742
|
+
import * as fs8 from "fs/promises";
|
|
5743
|
+
import * as path10 from "path";
|
|
4946
5744
|
|
|
4947
5745
|
// src/mcp-testing/scan/config/config.ts
|
|
4948
5746
|
init_esm_shims();
|
|
@@ -5634,13 +6432,21 @@ var CATALOG = [
|
|
|
5634
6432
|
check2({
|
|
5635
6433
|
id: "base-jsonrpc-parse-error",
|
|
5636
6434
|
title: "Invalid JSON is a parse error",
|
|
5637
|
-
description: "A message that is not valid JSON gets the error -32700 with id: null.",
|
|
6435
|
+
description: "A message that is not valid JSON gets the error -32700 with id: null. Over HTTP only: on stdio the client may not send such a line at all, and stdio-parse-error-advice reads the answer there. Over HTTP the endpoint is open to any POST, not only to what an MCP client writes, so the JSON-RPC 2.0 rule stands there: an input it cannot accept gets an error (https://modelcontextprotocol.io/specification/2025-11-25/basic/transports, Sending Messages to the Server).",
|
|
5638
6436
|
level: "MUST",
|
|
5639
6437
|
derived: true,
|
|
5640
6438
|
derivation: "basic/index, Messages: MCP messages MUST follow JSON-RPC 2.0; JSON-RPC 2.0 section 5 gives -32700 and a null id to a parse error.",
|
|
5641
6439
|
specRefs: [ref4(L2, "basic/index", "Messages")],
|
|
5642
6440
|
eras: BOTH3,
|
|
5643
|
-
transports:
|
|
6441
|
+
transports: HTTP
|
|
6442
|
+
}),
|
|
6443
|
+
unscored("advice", {
|
|
6444
|
+
id: "stdio-parse-error-advice",
|
|
6445
|
+
title: "Invalid JSON on stdio is answered with a parse error (advice)",
|
|
6446
|
+
description: `A line that is not valid JSON gets the error -32700 with id: null. Advice, not a requirement: the client "MUST NOT write anything to the server's stdin that is not a valid MCP message", so what a server does with one is not specified.`,
|
|
6447
|
+
specRefs: [ref4(L2, LT, "stdio")],
|
|
6448
|
+
eras: BOTH3,
|
|
6449
|
+
transports: ["stdio"]
|
|
5644
6450
|
}),
|
|
5645
6451
|
check2({
|
|
5646
6452
|
id: "base-unknown-method-error",
|
|
@@ -6038,7 +6844,7 @@ var CATALOG = [
|
|
|
6038
6844
|
check2({
|
|
6039
6845
|
id: "http-modern-get-delete-405",
|
|
6040
6846
|
title: "A modern-only server answers GET and DELETE with 405",
|
|
6041
|
-
description: "A server of the 2026-07-28 revision only answers GET and DELETE on its endpoint with 405 Method Not Allowed. A server that also
|
|
6847
|
+
description: "A server of the 2026-07-28 revision only answers GET and DELETE on its endpoint with 405 Method Not Allowed. A server that also serves 2025-11-25 (dual-era) is not-applicable: its server/discover names an earlier revision, or it answers an initialize sent as a 2025-11-25 client sends it.",
|
|
6042
6848
|
level: "SHOULD",
|
|
6043
6849
|
specRefs: [ref4(M2, MT, "Earlier Streamable HTTP Revisions")],
|
|
6044
6850
|
eras: ["modern"],
|
|
@@ -6214,7 +7020,7 @@ var CATALOG = [
|
|
|
6214
7020
|
check2({
|
|
6215
7021
|
id: "mod-no-session-id",
|
|
6216
7022
|
title: "A modern-only server neither mints nor echoes a session id",
|
|
6217
|
-
description: "server/discover sent with an Mcp-Session-Id gets an answer without Mcp-Session-Id. A dual-era server (supportedVersions names a revision before 2026-07-28) is not-applicable.",
|
|
7023
|
+
description: "server/discover sent with an Mcp-Session-Id gets an answer without Mcp-Session-Id. A dual-era server (supportedVersions names a revision before 2026-07-28, or it answers an initialize sent as a 2025-11-25 client sends it) is not-applicable.",
|
|
6218
7024
|
level: "SHOULD",
|
|
6219
7025
|
specRefs: [ref4(M2, MT, "Earlier Streamable HTTP Revisions")],
|
|
6220
7026
|
eras: MODERN3,
|
|
@@ -6352,7 +7158,7 @@ var BY_ID = new Map(CATALOG.map((e) => [e.id, e]));
|
|
|
6352
7158
|
|
|
6353
7159
|
// src/mcp-testing/conformance/profile.ts
|
|
6354
7160
|
init_esm_shims();
|
|
6355
|
-
import { createHash as
|
|
7161
|
+
import { createHash as createHash5 } from "crypto";
|
|
6356
7162
|
|
|
6357
7163
|
// src/mcp-testing/report/human.ts
|
|
6358
7164
|
init_exit_codes();
|
|
@@ -6485,14 +7291,14 @@ var NoCairnRunsError = class extends Error {
|
|
|
6485
7291
|
}
|
|
6486
7292
|
};
|
|
6487
7293
|
async function findLatestCairnRun(runsDir = "runs") {
|
|
6488
|
-
const entries = await
|
|
7294
|
+
const entries = await fs8.readdir(runsDir, { withFileTypes: true }).catch(() => null);
|
|
6489
7295
|
if (entries === null) throw new NoCairnRunsError(runsDir);
|
|
6490
7296
|
let newest;
|
|
6491
7297
|
for (const entry of entries) {
|
|
6492
7298
|
if (!entry.isDirectory()) continue;
|
|
6493
|
-
const dir =
|
|
7299
|
+
const dir = path10.join(runsDir, entry.name);
|
|
6494
7300
|
try {
|
|
6495
|
-
const report = await
|
|
7301
|
+
const report = await fs8.lstat(path10.join(dir, "report.json"));
|
|
6496
7302
|
if (!report.isFile()) continue;
|
|
6497
7303
|
if (newest === void 0 || report.mtimeMs > newest.at) {
|
|
6498
7304
|
newest = { dir, at: report.mtimeMs };
|
|
@@ -6549,7 +7355,7 @@ var MAX_MCP_CASES = 5e3;
|
|
|
6549
7355
|
async function checkSize(dir, file) {
|
|
6550
7356
|
let size;
|
|
6551
7357
|
try {
|
|
6552
|
-
const st = await
|
|
7358
|
+
const st = await fs8.stat(path10.join(dir, file));
|
|
6553
7359
|
if (!st.isFile()) throw new CairnArtifactShapeError(file, "", "is not a regular file");
|
|
6554
7360
|
size = st.size;
|
|
6555
7361
|
} catch (e) {
|
|
@@ -6567,7 +7373,7 @@ async function checkSize(dir, file) {
|
|
|
6567
7373
|
}
|
|
6568
7374
|
async function readJson(file) {
|
|
6569
7375
|
try {
|
|
6570
|
-
return JSON.parse(await
|
|
7376
|
+
return JSON.parse(await fs8.readFile(file, "utf8"));
|
|
6571
7377
|
} catch {
|
|
6572
7378
|
return void 0;
|
|
6573
7379
|
}
|
|
@@ -6607,7 +7413,7 @@ async function readMcpEvidence(dir, states) {
|
|
|
6607
7413
|
if (!await checkSize(dir, file)) return void 0;
|
|
6608
7414
|
let raw;
|
|
6609
7415
|
try {
|
|
6610
|
-
raw = JSON.parse(await
|
|
7416
|
+
raw = JSON.parse(await fs8.readFile(path10.join(dir, file), "utf8"));
|
|
6611
7417
|
} catch {
|
|
6612
7418
|
throw new CairnArtifactShapeError(file, "", "is not valid JSON");
|
|
6613
7419
|
}
|
|
@@ -6737,7 +7543,7 @@ async function casesFromMcp(dir, report) {
|
|
|
6737
7543
|
});
|
|
6738
7544
|
}
|
|
6739
7545
|
async function defaultReadEvidence(dir) {
|
|
6740
|
-
const raw = await readJson(
|
|
7546
|
+
const raw = await readJson(path10.join(dir, "api-evidence.json"));
|
|
6741
7547
|
if (!Array.isArray(raw)) return void 0;
|
|
6742
7548
|
return raw.map((r) => {
|
|
6743
7549
|
const rec = asRecord(r);
|
|
@@ -6781,7 +7587,7 @@ function casesFromApi(report, verdicts) {
|
|
|
6781
7587
|
}
|
|
6782
7588
|
async function readCairnRun(dir, deps = {}) {
|
|
6783
7589
|
await checkSize(dir, "report.json");
|
|
6784
|
-
const raw = await readJson(
|
|
7590
|
+
const raw = await readJson(path10.join(dir, "report.json"));
|
|
6785
7591
|
if (raw === void 0) throw new CairnRunNotFoundError(dir);
|
|
6786
7592
|
const report = asRecord(raw);
|
|
6787
7593
|
if (report["schemaVersion"] !== SUPPORTED_ARTIFACT_VERSION) {
|
|
@@ -6813,13 +7619,79 @@ async function readCairnRun(dir, deps = {}) {
|
|
|
6813
7619
|
return {
|
|
6814
7620
|
schemaVersion: INGEST_SCHEMA_VERSION,
|
|
6815
7621
|
run: {
|
|
6816
|
-
runId: str(report["runId"],
|
|
7622
|
+
runId: str(report["runId"], path10.basename(dir)),
|
|
6817
7623
|
mode,
|
|
6818
7624
|
target: str(report["url"], "unknown")
|
|
6819
7625
|
},
|
|
6820
7626
|
cases
|
|
6821
7627
|
};
|
|
6822
7628
|
}
|
|
7629
|
+
var DECLARED = { text: 500, name: 200, chapters: 200, perCase: 20 };
|
|
7630
|
+
var clip = (s) => s.slice(0, DECLARED.text).replace(/[\uD800-\uDBFF]$/, "");
|
|
7631
|
+
async function readCairnSessionFiles(dir) {
|
|
7632
|
+
const raw = await readJson(path10.join(dir, "screencasts", "screencasts.json"));
|
|
7633
|
+
if (!Array.isArray(raw)) return void 0;
|
|
7634
|
+
const root = await fs8.realpath(dir).catch(() => path10.resolve(dir));
|
|
7635
|
+
const within = (p) => {
|
|
7636
|
+
const rel = path10.relative(root, p);
|
|
7637
|
+
return rel !== "" && !rel.startsWith("..") && !path10.isAbsolute(rel);
|
|
7638
|
+
};
|
|
7639
|
+
let outside = 0;
|
|
7640
|
+
const inside = async (p) => {
|
|
7641
|
+
if (typeof p !== "string" || p === "") return void 0;
|
|
7642
|
+
const abs = path10.resolve(root, p);
|
|
7643
|
+
const real = await fs8.realpath(abs).catch(() => void 0);
|
|
7644
|
+
if (within(abs) && (real === void 0 || within(real))) {
|
|
7645
|
+
const file = real ?? abs;
|
|
7646
|
+
const size = await fs8.stat(file).then((s) => s.size, () => void 0);
|
|
7647
|
+
return { path: file, rel: path10.relative(root, abs).split(path10.sep).join("/"), ...size !== void 0 ? { size } : {} };
|
|
7648
|
+
}
|
|
7649
|
+
outside += 1;
|
|
7650
|
+
return void 0;
|
|
7651
|
+
};
|
|
7652
|
+
const byCase = /* @__PURE__ */ new Map();
|
|
7653
|
+
const screencasts = /* @__PURE__ */ new Map();
|
|
7654
|
+
let unmapped = 0;
|
|
7655
|
+
for (const entry of raw) {
|
|
7656
|
+
const rec = asRecord(entry);
|
|
7657
|
+
const found = [];
|
|
7658
|
+
for (const kind of ["video", "trace"]) {
|
|
7659
|
+
const at = await inside(own(rec, kind));
|
|
7660
|
+
if (at !== void 0) found.push({ file: { path: at.path, ...at.size !== void 0 ? { size: at.size } : {} }, rel: at.rel, kind });
|
|
7661
|
+
}
|
|
7662
|
+
if (found.length === 0) continue;
|
|
7663
|
+
const stableId = own(rec, "stableId");
|
|
7664
|
+
if (typeof stableId !== "string" || stableId === "") {
|
|
7665
|
+
unmapped += 1;
|
|
7666
|
+
continue;
|
|
7667
|
+
}
|
|
7668
|
+
byCase.set(stableId, [...byCase.get(stableId) ?? [], ...found.map((f) => f.file)]);
|
|
7669
|
+
const declared = screencasts.get(stableId) ?? [];
|
|
7670
|
+
const keys = new Set(declared.flatMap((s) => s.files.map((f) => f.key)));
|
|
7671
|
+
const title = clip(str(own(rec, "test")));
|
|
7672
|
+
const files = found.filter((f) => {
|
|
7673
|
+
if ((f.file.size ?? 0) < 1 || f.rel.length > DECLARED.text || path10.basename(f.file.path).length > DECLARED.name || keys.has(f.rel)) return false;
|
|
7674
|
+
keys.add(f.rel);
|
|
7675
|
+
return true;
|
|
7676
|
+
});
|
|
7677
|
+
if (title === "" || files.length === 0 || declared.length >= DECLARED.perCase) continue;
|
|
7678
|
+
for (const f of files) f.file.key = f.rel;
|
|
7679
|
+
const timing = own(rec, "timing");
|
|
7680
|
+
declared.push({
|
|
7681
|
+
title,
|
|
7682
|
+
...timing === "trace" || timing === "estimated" ? { timing } : {},
|
|
7683
|
+
chapters: (Array.isArray(own(rec, "chapters")) ? own(rec, "chapters") : []).flatMap((c) => {
|
|
7684
|
+
const chapter = asRecord(c);
|
|
7685
|
+
const t = clip(str(own(chapter, "title")));
|
|
7686
|
+
const atMs = own(chapter, "atMs");
|
|
7687
|
+
return t !== "" && Number.isInteger(atMs) && atMs >= 0 ? [{ title: t, atMs }] : [];
|
|
7688
|
+
}).slice(0, DECLARED.chapters),
|
|
7689
|
+
files: files.map((f) => ({ key: f.rel, name: path10.basename(f.file.path), kind: f.kind, size: f.file.size }))
|
|
7690
|
+
});
|
|
7691
|
+
screencasts.set(stableId, declared);
|
|
7692
|
+
}
|
|
7693
|
+
return { byCase, screencasts, unmapped, outside };
|
|
7694
|
+
}
|
|
6823
7695
|
|
|
6824
7696
|
// src/cli/commands/ingest.ts
|
|
6825
7697
|
var IngestNotLoggedInError = class extends Error {
|
|
@@ -6848,6 +7720,131 @@ var IngestHttpError = class extends Error {
|
|
|
6848
7720
|
}
|
|
6849
7721
|
status;
|
|
6850
7722
|
};
|
|
7723
|
+
var SESSION_FILE_MAX = 100 * 1024 * 1024;
|
|
7724
|
+
var SESSION_UPLOADS_AT_ONCE = 4;
|
|
7725
|
+
var TYPE_BY_EXTENSION2 = { ".webm": "video/webm", ".zip": "application/zip" };
|
|
7726
|
+
function itemsOf(body) {
|
|
7727
|
+
const items = body?.items;
|
|
7728
|
+
if (!Array.isArray(items)) return void 0;
|
|
7729
|
+
return items.flatMap((raw) => {
|
|
7730
|
+
const i = raw ?? {};
|
|
7731
|
+
if (typeof i["stableId"] !== "string") return [];
|
|
7732
|
+
const reviewItemId = typeof i["reviewItemId"] === "string" && i["reviewItemId"] !== "" ? i["reviewItemId"] : void 0;
|
|
7733
|
+
const resultId = typeof i["resultId"] === "string" && i["resultId"] !== "" ? i["resultId"] : void 0;
|
|
7734
|
+
if (reviewItemId === void 0 && resultId === void 0) return [];
|
|
7735
|
+
return [{ stableId: i["stableId"], ...reviewItemId !== void 0 ? { reviewItemId } : {}, ...resultId !== void 0 ? { resultId } : {} }];
|
|
7736
|
+
});
|
|
7737
|
+
}
|
|
7738
|
+
var RESULT_PAGES_MAX = 100;
|
|
7739
|
+
var namesOf = (files) => new Set(Array.isArray(files) ? files.flatMap((f) => typeof f?.name === "string" ? [f.name] : []) : []);
|
|
7740
|
+
async function heldBy(client, runId, jobs) {
|
|
7741
|
+
const held = /* @__PURE__ */ new Map();
|
|
7742
|
+
for (const job of jobs) {
|
|
7743
|
+
const key = targetOf(job);
|
|
7744
|
+
if (held.has(key) || job.owner !== "review-items") continue;
|
|
7745
|
+
const out = await client.get(`/v1/review-items/${encodeURIComponent(job.id)}`);
|
|
7746
|
+
held.set(key, out.ok ? namesOf(out.body?.files) : void 0);
|
|
7747
|
+
}
|
|
7748
|
+
const results = jobs.filter((j) => j.owner === void 0);
|
|
7749
|
+
if (results.length === 0) return held;
|
|
7750
|
+
let byResult = /* @__PURE__ */ new Map();
|
|
7751
|
+
let before;
|
|
7752
|
+
for (let page = 0; ; page += 1) {
|
|
7753
|
+
if (runId === "" || page >= RESULT_PAGES_MAX) {
|
|
7754
|
+
byResult = void 0;
|
|
7755
|
+
break;
|
|
7756
|
+
}
|
|
7757
|
+
const query = before === void 0 ? "" : `?before=${encodeURIComponent(before)}`;
|
|
7758
|
+
const out = await client.get(`/v1/runs/${encodeURIComponent(runId)}/results${query}`);
|
|
7759
|
+
if (!out.ok || !Array.isArray(out.body?.results)) {
|
|
7760
|
+
byResult = void 0;
|
|
7761
|
+
break;
|
|
7762
|
+
}
|
|
7763
|
+
for (const r of out.body.results) {
|
|
7764
|
+
if (typeof r?.id === "string") byResult.set(r.id, namesOf(r.files));
|
|
7765
|
+
}
|
|
7766
|
+
if (typeof out.body.next !== "string" || out.body.next === "") break;
|
|
7767
|
+
before = out.body.next;
|
|
7768
|
+
}
|
|
7769
|
+
for (const job of results) held.set(targetOf(job), byResult === void 0 ? void 0 : byResult.get(job.id) ?? /* @__PURE__ */ new Set());
|
|
7770
|
+
return held;
|
|
7771
|
+
}
|
|
7772
|
+
var targetOf = (job) => `${job.owner ?? "results"}/${job.id}`;
|
|
7773
|
+
async function sendSessionFiles(session, sent, platform) {
|
|
7774
|
+
if (session === void 0 || session.byCase.size === 0 && session.unmapped === 0 && session.outside === 0) return [];
|
|
7775
|
+
if (sent.items === void 0) {
|
|
7776
|
+
return ["session files not uploaded \u2014 this Plune is older than the routes that take them"];
|
|
7777
|
+
}
|
|
7778
|
+
const lines = [];
|
|
7779
|
+
if (session.outside > 0) lines.push(`${session.outside} file(s) not uploaded \u2014 the path leaves the run directory`);
|
|
7780
|
+
if (session.unmapped > 0) lines.push(`${session.unmapped} recording(s) name no case \u2014 not uploaded`);
|
|
7781
|
+
let jobs = [];
|
|
7782
|
+
let tooBig = 0;
|
|
7783
|
+
const placed = /* @__PURE__ */ new Set();
|
|
7784
|
+
for (const item of sent.items) {
|
|
7785
|
+
const paths = session.byCase.get(item.stableId);
|
|
7786
|
+
if (paths === void 0 || placed.has(item.stableId)) continue;
|
|
7787
|
+
placed.add(item.stableId);
|
|
7788
|
+
for (const { path: file, size, key } of paths) {
|
|
7789
|
+
const name = path11.basename(file);
|
|
7790
|
+
if (size !== void 0 && size > SESSION_FILE_MAX) {
|
|
7791
|
+
tooBig += 1;
|
|
7792
|
+
lines.push(`"${name}" skipped \u2014 larger than the ${SESSION_FILE_MAX / (1024 * 1024)} MiB a session file may be`);
|
|
7793
|
+
continue;
|
|
7794
|
+
}
|
|
7795
|
+
const type = TYPE_BY_EXTENSION2[path11.extname(file).toLowerCase()] ?? "application/octet-stream";
|
|
7796
|
+
jobs.push({
|
|
7797
|
+
id: item.reviewItemId ?? item.resultId,
|
|
7798
|
+
...item.reviewItemId !== void 0 ? { owner: "review-items" } : {},
|
|
7799
|
+
kind: "file",
|
|
7800
|
+
name,
|
|
7801
|
+
type,
|
|
7802
|
+
path: file,
|
|
7803
|
+
// Declared on the proposal only: a result's route has no declaration to match.
|
|
7804
|
+
...key !== void 0 && item.reviewItemId !== void 0 ? { key } : {}
|
|
7805
|
+
});
|
|
7806
|
+
}
|
|
7807
|
+
}
|
|
7808
|
+
const unplaced = [...session.byCase.keys()].filter((stableId) => !placed.has(stableId)).length;
|
|
7809
|
+
if (unplaced > 0) lines.push(`${unplaced} case(s) with recordings got no proposal or result in this run \u2014 not uploaded`);
|
|
7810
|
+
const client = createClient({
|
|
7811
|
+
apiUrl: platform.apiUrl,
|
|
7812
|
+
token: platform.token,
|
|
7813
|
+
uploadRetries: UPLOAD_RETRIES.default,
|
|
7814
|
+
...platform.fetchImpl !== void 0 ? { fetchImpl: platform.fetchImpl } : {}
|
|
7815
|
+
});
|
|
7816
|
+
if (sent.repeat && jobs.length > 0) {
|
|
7817
|
+
const held = await heldBy(client, sent.runId, jobs);
|
|
7818
|
+
let already = 0;
|
|
7819
|
+
let unknown = 0;
|
|
7820
|
+
jobs = jobs.filter((job) => {
|
|
7821
|
+
const names = held.get(targetOf(job));
|
|
7822
|
+
if (names === void 0) unknown += 1;
|
|
7823
|
+
else if (names.has(job.name)) already += 1;
|
|
7824
|
+
else return true;
|
|
7825
|
+
return false;
|
|
7826
|
+
});
|
|
7827
|
+
if (unknown > 0) lines.push(`${unknown} file(s) not sent again \u2014 what the platform holds could not be read`);
|
|
7828
|
+
lines.push(`${already} file(s) already on the platform, ${jobs.length} sent`);
|
|
7829
|
+
}
|
|
7830
|
+
const counts = { screenshots: { uploaded: 0, skipped: 0, failed: 0 }, textFiles: { uploaded: 0, skipped: 0, failed: 0 }, otherFiles: { uploaded: 0, skipped: 0, failed: 0 } };
|
|
7831
|
+
if (jobs.length > 0) {
|
|
7832
|
+
const notes = [];
|
|
7833
|
+
const files = fileSender({
|
|
7834
|
+
client,
|
|
7835
|
+
log: (line) => notes.push(line.replace(/^plune: /, "")),
|
|
7836
|
+
stats: counts,
|
|
7837
|
+
uploadsAtOnce: SESSION_UPLOADS_AT_ONCE,
|
|
7838
|
+
uploadRetries: UPLOAD_RETRIES.default,
|
|
7839
|
+
without: "the run is recorded without it"
|
|
7840
|
+
});
|
|
7841
|
+
await files.uploadEach(jobs);
|
|
7842
|
+
lines.push(...notes.filter((n) => !n.startsWith("storage bucket found")));
|
|
7843
|
+
}
|
|
7844
|
+
const { uploaded, skipped, failed } = counts.otherFiles;
|
|
7845
|
+
const total = `${uploaded} session file(s) uploaded` + (skipped + tooBig > 0 ? `, ${skipped + tooBig} skipped` : "") + (failed > 0 ? `, ${failed} failed to upload` : "");
|
|
7846
|
+
return [total, ...lines];
|
|
7847
|
+
}
|
|
6851
7848
|
async function safeErrorDetail2(res) {
|
|
6852
7849
|
try {
|
|
6853
7850
|
const body = await res.json();
|
|
@@ -6862,13 +7859,22 @@ async function handleIngest(deps) {
|
|
|
6862
7859
|
if (token === null) throw new IngestNotLoggedInError();
|
|
6863
7860
|
const dir = deps.dir ?? await findLatestCairnRun(deps.runsDir);
|
|
6864
7861
|
const payload = await readCairnRun(dir);
|
|
7862
|
+
const session = await readCairnSessionFiles(dir).catch(() => void 0);
|
|
7863
|
+
for (const c of payload.cases) {
|
|
7864
|
+
const screencasts = session?.screencasts.get(c.stableId);
|
|
7865
|
+
if (screencasts !== void 0) c.screencasts = screencasts;
|
|
7866
|
+
}
|
|
6865
7867
|
const doFetch = deps.fetchImpl ?? fetch;
|
|
6866
7868
|
const endpoint = `${apiUrl}/v1/ingest/cairn`;
|
|
6867
7869
|
const job = new JobReporter(doFetch, apiUrl, token, "ingest");
|
|
6868
|
-
await job.open(
|
|
7870
|
+
await job.open(path11.basename(path11.resolve(dir)), payload.cases.length);
|
|
6869
7871
|
try {
|
|
6870
|
-
const result = await upload();
|
|
7872
|
+
const { result, ...sent } = await upload();
|
|
6871
7873
|
await job.uploaded({ subjectId: result.runId || void 0 });
|
|
7874
|
+
const files = await sendSessionFiles(session, { ...sent, runId: result.runId }, { apiUrl, token, ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {} }).catch(
|
|
7875
|
+
() => ["session files not uploaded (an unexpected error) \u2014 the run is recorded"]
|
|
7876
|
+
);
|
|
7877
|
+
if (files.length > 0) result.files = files;
|
|
6872
7878
|
await job.finish({ ok: true });
|
|
6873
7879
|
if (job.problem !== void 0) result.jobProblem = job.problem;
|
|
6874
7880
|
return result;
|
|
@@ -6893,12 +7899,13 @@ async function handleIngest(deps) {
|
|
|
6893
7899
|
throw new IngestHttpError(res.status, detail);
|
|
6894
7900
|
}
|
|
6895
7901
|
const body = await res.json().catch(() => ({}));
|
|
6896
|
-
|
|
7902
|
+
const result = {
|
|
6897
7903
|
runId: typeof body.runId === "string" ? body.runId : "",
|
|
6898
7904
|
linked: typeof body.linked === "number" ? body.linked : 0,
|
|
6899
7905
|
proposed: typeof body.proposed === "number" ? body.proposed : 0,
|
|
6900
7906
|
skipped: typeof body.skipped === "number" ? body.skipped : 0
|
|
6901
7907
|
};
|
|
7908
|
+
return { result, items: itemsOf(body), repeat: res.status === 200 };
|
|
6902
7909
|
}
|
|
6903
7910
|
}
|
|
6904
7911
|
function reportIngestFailure(err, write) {
|
|
@@ -6919,7 +7926,8 @@ function formatIngestResult(r) {
|
|
|
6919
7926
|
`Ingested Cairn run \u2192 ${r.runId}`,
|
|
6920
7927
|
` ${r.linked} result(s) attached to existing cases`,
|
|
6921
7928
|
` ${r.proposed} case(s) proposed \u2014 review them in Plune to accept`,
|
|
6922
|
-
` ${r.skipped} skipped (already queued, already rejected, repeated, or never executed)
|
|
7929
|
+
` ${r.skipped} skipped (already queued, already rejected, repeated, or never executed)`,
|
|
7930
|
+
...(r.files ?? []).map((line, i) => i === 0 ? ` ${line}` : ` ${line}`)
|
|
6923
7931
|
];
|
|
6924
7932
|
return `${lines.join("\n")}
|
|
6925
7933
|
`;
|