@plune-ai/cli 0.39.2 → 0.39.4

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.
@@ -50,7 +50,7 @@ module.exports = __toCommonJS(reporter_core_exports);
50
50
 
51
51
  // src/reporter-core/session.ts
52
52
  var import_node_crypto2 = require("crypto");
53
- var import_node_fs5 = require("fs");
53
+ var import_node_fs6 = require("fs");
54
54
  var import_node_path3 = require("path");
55
55
  var import_node_util2 = require("util");
56
56
 
@@ -266,6 +266,7 @@ function createClient(opts) {
266
266
  upload: (path3, bytes, contentType) => send("POST", path3, { body: bytes, type: contentType }, uploadRetries ?? DEFAULT_RETRIES),
267
267
  del: (path3) => send("DELETE", path3),
268
268
  get: (path3) => send("GET", path3),
269
+ patch: (path3, body) => send("PATCH", path3, { body: JSON.stringify(body), type: "application/json" }),
269
270
  async put(url, headers, source) {
270
271
  const putRetries = uploadRetries ?? 3;
271
272
  let last = { ok: false, status: null, code: "network" };
@@ -626,11 +627,179 @@ function appendBatch(file, batch) {
626
627
  `, "utf8");
627
628
  }
628
629
 
630
+ // src/reporter-core/code-snapshot.ts
631
+ var import_node_fs5 = require("fs");
632
+ var SNAPSHOT_MAX_BYTES = 16384;
633
+ var CALL = /\b(?:test|it)(?:\.(?:skip|fixme|only|fail|slow))?\s*\(/g;
634
+ var BEFORE_REGEX = /* @__PURE__ */ new Set([..."(,=:[!&|?{};+-*%<>~^"]);
635
+ function skipString(src, i, quote) {
636
+ for (let j = i + 1; j < src.length; j += 1) {
637
+ const c = src[j];
638
+ if (c === "\\") j += 1;
639
+ else if (c === quote) return j + 1;
640
+ else if (c === "\n") return -1;
641
+ }
642
+ return -1;
643
+ }
644
+ function skipTemplate(src, i) {
645
+ for (let j = i + 1; j < src.length; j += 1) {
646
+ const c = src[j];
647
+ if (c === "\\") j += 1;
648
+ else if (c === "`") return j + 1;
649
+ else if (c === "$" && src[j + 1] === "{") {
650
+ const end = matching(src, j + 2, "}");
651
+ if (end < 0) return -1;
652
+ j = end;
653
+ }
654
+ }
655
+ return -1;
656
+ }
657
+ function skipRegex(src, i) {
658
+ let inClass = false;
659
+ for (let j = i + 1; j < src.length; j += 1) {
660
+ const c = src[j];
661
+ if (c === "\\") j += 1;
662
+ else if (c === "\n") return -1;
663
+ else if (c === "[") inClass = true;
664
+ else if (c === "]") inClass = false;
665
+ else if (c === "/" && !inClass) {
666
+ let k = j + 1;
667
+ while (k < src.length && /[a-z]/i.test(src[k])) k += 1;
668
+ return k;
669
+ }
670
+ }
671
+ return -1;
672
+ }
673
+ function matching(src, i, close) {
674
+ const stack = [close];
675
+ let prev = "(";
676
+ while (i < src.length) {
677
+ const c = src[i];
678
+ const next = src[i + 1];
679
+ let to = -2;
680
+ if (c === "/" && next === "/") to = src.indexOf("\n", i);
681
+ else if (c === "/" && next === "*")
682
+ to = src.indexOf("*/", i + 2) < 0 ? -1 : src.indexOf("*/", i + 2) + 2;
683
+ else if (c === "'" || c === '"') to = skipString(src, i, c);
684
+ else if (c === "`") to = skipTemplate(src, i);
685
+ else if (c === "/" && BEFORE_REGEX.has(prev)) to = skipRegex(src, i);
686
+ if (to === -1) return -1;
687
+ if (to !== -2) {
688
+ if (c !== "/" || next !== "/" && next !== "*") prev = "a";
689
+ i = to;
690
+ continue;
691
+ }
692
+ if (c === "(") stack.push(")");
693
+ else if (c === "[") stack.push("]");
694
+ else if (c === "{") stack.push("}");
695
+ else if (c === ")" || c === "]" || c === "}") {
696
+ if (stack.pop() !== c) return -1;
697
+ if (stack.length === 0) return i;
698
+ }
699
+ if (!/\s/.test(c)) prev = c;
700
+ i += 1;
701
+ }
702
+ return -1;
703
+ }
704
+ function callTextAt(source, line, column) {
705
+ const lines = source.split("\n");
706
+ if (line < 1 || line > lines.length) return void 0;
707
+ const lineStart = lines.slice(0, line - 1).reduce((n, l) => n + l.length + 1, 0);
708
+ const lineEnd = lineStart + lines[line - 1].length;
709
+ const heads = [];
710
+ CALL.lastIndex = lineStart;
711
+ for (let h = CALL.exec(source); h !== null && h.index < lineEnd; h = CALL.exec(source))
712
+ heads.push(h);
713
+ const at = column === void 0 ? -1 : lineStart + column - 1;
714
+ const head = heads.find((h) => h.index <= at && at < h.index + h[0].length) ?? (heads.length === 1 ? heads[0] : void 0);
715
+ if (head === void 0) return void 0;
716
+ const end = matching(source, head.index + head[0].length, ")");
717
+ if (end < 0) return void 0;
718
+ const text = source.slice(head.index, end + 1).replace(/\r\n/g, "\n");
719
+ return Buffer.byteLength(text, "utf8") <= SNAPSHOT_MAX_BYTES ? text : void 0;
720
+ }
721
+ var CREDENTIAL = "password|passphrase|passwd|pass|pwd|token|secret|api[-_]?key|private[-_]?key|credential|auth|session|cookie";
722
+ var LITERAL = String.raw`(?<q>['"\x60])(?:\\.|(?!\k<q>)[^\\\n])*\k<q>`;
723
+ var TYPING = "(?:fill|type|pressSequentially)";
724
+ var SHAPES = [
725
+ { kind: "github-token", re: /\b(?:ghp|gho|ghs|ghu)_[A-Za-z0-9]{36}\b|\bgithub_pat_\w{20,}/g },
726
+ { kind: "api-key", re: /\bsk-[\w-]{20,}/g },
727
+ { kind: "api-key", re: /\b[sr]k_(?:live|test)_[A-Za-z0-9]{10,}/g },
728
+ { kind: "npm-token", re: /\bnpm_[A-Za-z0-9]{20,}/g },
729
+ { kind: "google-key", re: /\bAIza[\w-]{30,}/g },
730
+ { kind: "plune-token", re: /\bplune_[A-Za-z0-9_]{16,}/g },
731
+ { kind: "aws-key", re: /\bAKIA[0-9A-Z]{16}\b/g },
732
+ { kind: "slack-token", re: /\bxox[abprs]-[A-Za-z0-9-]{10,}/g },
733
+ {
734
+ kind: "private-key",
735
+ re: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g
736
+ },
737
+ { kind: "jwt", re: /\beyJ[\w-]{10,}\.[\w-]{10,}\.[\w-]{10,}/g }
738
+ ];
739
+ var PLACES = [
740
+ // `password = '…'`, `apiKey: "…"`, `'x-api-key': '…'`
741
+ new RegExp(
742
+ String.raw`(?<lead>\b(?<role>[\w$-]*(?:${CREDENTIAL})[\w$-]*)['"]?\s*[:=]\s*)${LITERAL}`,
743
+ "gi"
744
+ ),
745
+ // `setToken('…')`: the call is named for a credential
746
+ new RegExp(String.raw`(?<lead>\b(?<role>[\w$]*(?:${CREDENTIAL})[\w$]*)\s*\(\s*)${LITERAL}`, "gi"),
747
+ // `.fill('#password', '…')`, `.type('#pwd', '…')`: the field is named in the same call
748
+ new RegExp(
749
+ String.raw`(?<lead>\.${TYPING}\(\s*['"][^'"\n]*?(?<role>${CREDENTIAL})[^'"\n]*['"]\s*,\s*)${LITERAL}`,
750
+ "gi"
751
+ ),
752
+ // `getByLabel('Password').fill('…')`, `getByRole('textbox', { name: 'Password' }).type('…')`: … or
753
+ // anywhere in the call the typing is chained off
754
+ new RegExp(
755
+ String.raw`(?<lead>\([^()\n]*?(?<role>${CREDENTIAL})[^()\n]*\)\s*\.${TYPING}\(\s*)${LITERAL}`,
756
+ "gi"
757
+ ),
758
+ // `{ name: 'session', value: '…' }`: a cookie (or any name/value pair) named for a credential
759
+ new RegExp(
760
+ String.raw`(?<lead>\bname\s*:\s*['"][^'"\n]*?(?<role>${CREDENTIAL})[^'"\n]*['"]\s*,\s*value\s*:\s*)${LITERAL}`,
761
+ "gi"
762
+ )
763
+ ];
764
+ var HEADER_LINE = /((?:^|\\[nr]|\x60)[ \t>*<+-]*['"]?)((?:proxy-)?authorization|(?:set-)?cookie|[\w-]*session[\w-]*)(['"]?[ \t]*:[ \t]*)(?![\w$.]+(?:\([^()\n]*\))?[ \t]*[,;)}\]])[^\s'"\x60\\][^\r\n'"\x60\\]*/gim;
765
+ var QUERY_PARAM = /([?&][\w.-]*(?:token|key|secret|password|passwd|pass|pwd|auth|signature|sig|credential|session)[\w.-]*=)(?!‹)[^&#\s'"\x60]+/gi;
766
+ function maskCredentials(text) {
767
+ let out = text;
768
+ for (const { kind, re } of SHAPES) out = out.replace(re, `\u2039${kind}\u203A`);
769
+ for (const re of PLACES) {
770
+ out = out.replace(re, (...args) => {
771
+ const groups = args.at(-1);
772
+ return `${groups.lead}${groups.q}\u2039${groups.role.toLowerCase().replace(/^[^a-z]+/, "")}\u203A${groups.q}`;
773
+ });
774
+ }
775
+ return out.replace(HEADER_LINE, "$1$2$3\u2039header\u203A").replace(/\b(Bearer)([ \t]+)(?!‹)[\w.~+/=-]{8,}/g, "$1$2\u2039credential\u203A").replace(
776
+ /\b(Basic|Token)([ \t]+)(?!‹)(?=[\w.~+/=-]*[\d=+/]|[\w.~+/=-]*[a-z][\w.~+/=-]*[A-Z])[\w.~+/=-]{8,}/g,
777
+ "$1$2\u2039credential\u203A"
778
+ ).replace(/\b(PLUNE_[A-Z0-9_]*=)(?!‹)[^\s'"\x60;,)]+/g, "$1\u2039env-secret\u203A").replace(QUERY_PARAM, "$1\u2039credential\u203A").replace(/\b([a-z][\w+.-]*:\/\/)[^\s/@'"\x60]+@/gi, "$1\u2039credential\u203A@");
779
+ }
780
+ function snapshotAt(at, files) {
781
+ let source = files.get(at.file);
782
+ if (source === void 0) {
783
+ try {
784
+ source = (0, import_node_fs5.readFileSync)(at.file, "utf8");
785
+ } catch {
786
+ source = null;
787
+ }
788
+ files.set(at.file, source);
789
+ }
790
+ if (source === null) return void 0;
791
+ const text = callTextAt(source, at.line, at.column);
792
+ if (text === void 0) return void 0;
793
+ const masked = maskCredentials(text);
794
+ return Buffer.byteLength(masked, "utf8") <= SNAPSHOT_MAX_BYTES ? masked : void 0;
795
+ }
796
+
629
797
  // src/reporter-core/session.ts
630
798
  var RESOLVE_CHUNK = 500;
631
799
  var BATCH_MAX = 500;
632
800
  var DISCOVER_MAX = 500;
633
801
  var BATCH_DEFAULT = 500;
802
+ var SNAPSHOT_UPDATES_MAX = 100;
634
803
  var SEND_CONCURRENCY = 4;
635
804
  var EXPECTED_MAX = 1e4;
636
805
  var KEY_MAX = 1024;
@@ -709,7 +878,13 @@ function textRefusal(bytes) {
709
878
  }
710
879
  return void 0;
711
880
  }
712
- function onDisk(result) {
881
+ function withoutTargets(result) {
882
+ if (result.targets === void 0) return result;
883
+ const { targets: _targets, ...rest } = result;
884
+ return rest;
885
+ }
886
+ function onDisk(deferred) {
887
+ const result = withoutTargets(deferred);
713
888
  if (!("files" in result) || result.files === void 0) return result;
714
889
  const { files, ...rest } = result;
715
890
  const kept = files.filter((f) => f.path !== void 0).map(({ body: _body, ...file }) => file);
@@ -822,7 +997,7 @@ function fileSender(options) {
822
997
  if (job.body !== void 0) bytes = job.body;
823
998
  else {
824
999
  try {
825
- bytes = await import_node_fs5.promises.readFile(job.path);
1000
+ bytes = await import_node_fs6.promises.readFile(job.path);
826
1001
  } catch {
827
1002
  return skip(kind, job.name, "missing");
828
1003
  }
@@ -877,7 +1052,7 @@ function fileSender(options) {
877
1052
  else if (job.path === void 0) return void skip(kind, job.name, "missing");
878
1053
  else {
879
1054
  try {
880
- size = (await import_node_fs5.promises.stat(job.path)).size;
1055
+ size = (await import_node_fs6.promises.stat(job.path)).size;
881
1056
  } catch {
882
1057
  return void skip(kind, job.name, "missing");
883
1058
  }
@@ -933,7 +1108,7 @@ function fileSender(options) {
933
1108
  else if (job.path === void 0) return void skip(job.kind, job.name, "missing");
934
1109
  else {
935
1110
  try {
936
- size = (await import_node_fs5.promises.stat(job.path)).size;
1111
+ size = (await import_node_fs6.promises.stat(job.path)).size;
937
1112
  } catch {
938
1113
  return void skip(job.kind, job.name, "missing");
939
1114
  }
@@ -1107,7 +1282,7 @@ function fileSender(options) {
1107
1282
  }
1108
1283
  let data;
1109
1284
  try {
1110
- data = job.body ?? await import_node_fs5.promises.readFile(job.path);
1285
+ data = job.body ?? await import_node_fs6.promises.readFile(job.path);
1111
1286
  } catch {
1112
1287
  skip(kind, job.name, "missing");
1113
1288
  continue;
@@ -1261,8 +1436,12 @@ async function startRun(passed, declared) {
1261
1436
  let runId = null;
1262
1437
  let joined = false;
1263
1438
  let offline = token === "";
1439
+ let targetsRefused = false;
1264
1440
  let done = false;
1265
1441
  const shortened = /* @__PURE__ */ new Set();
1442
+ const specFiles = /* @__PURE__ */ new Map();
1443
+ const snapshotByKey = /* @__PURE__ */ new Map();
1444
+ const snapshots = /* @__PURE__ */ new Map();
1266
1445
  function bound(keys) {
1267
1446
  return keys.map((key) => {
1268
1447
  const fit = boundKey(key);
@@ -1416,6 +1595,8 @@ async function startRun(passed, declared) {
1416
1595
  const { keys: _keys, files: files2, ...rest } = pending;
1417
1596
  submissions.push({ ...rest, testCaseId: r.id });
1418
1597
  if (files2 !== void 0) filesByKey.set(pending.resultKey, files2);
1598
+ const text = snapshotByKey.get(pending.resultKey);
1599
+ if (text !== void 0) snapshots.set(r.id, text);
1419
1600
  }
1420
1601
  if (submissions.length > 0) {
1421
1602
  const before = stats.deferred;
@@ -1425,6 +1606,46 @@ async function startRun(passed, declared) {
1425
1606
  }
1426
1607
  }
1427
1608
  }
1609
+ async function syncSnapshots() {
1610
+ if (snapshots.size === 0 || offline) return;
1611
+ const stored = /* @__PURE__ */ new Map();
1612
+ let cursor = null;
1613
+ do {
1614
+ const query = `type=automated&stability=0&limit=200${cursor === null ? "" : `&cursor=${encodeURIComponent(cursor)}`}`;
1615
+ const out = await client.get(`/v1/test-cases?${query}`);
1616
+ if (!out.ok || !Array.isArray(out.body?.testCases)) {
1617
+ log(`plune: could not update the code snapshots (${out.ok ? "the case list had no cases" : out.detail || out.kind}).`);
1618
+ return;
1619
+ }
1620
+ for (const row of out.body.testCases) {
1621
+ if (typeof row?.id === "string" && snapshots.has(row.id)) stored.set(row.id, row.codeSnapshotHash ?? null);
1622
+ }
1623
+ cursor = typeof out.body.nextCursor === "string" ? out.body.nextCursor : null;
1624
+ } while (cursor !== null && stored.size < snapshots.size);
1625
+ const sha = (text) => (0, import_node_crypto2.createHash)("sha256").update(text).digest("hex");
1626
+ const due = [...snapshots].filter(([id, text]) => stored.has(id) && stored.get(id) !== sha(text)).sort(([a], [b]) => sha(`${runId}:${a}`).localeCompare(sha(`${runId}:${b}`)));
1627
+ let updated = 0;
1628
+ let refused = 0;
1629
+ let tried = 0;
1630
+ for (const [id, text] of due.slice(0, SNAPSHOT_UPDATES_MAX)) {
1631
+ tried += 1;
1632
+ const out = await client.patch(`/v1/test-cases/${encodeURIComponent(id)}`, { codeSnapshot: text });
1633
+ if (out.ok) {
1634
+ updated += 1;
1635
+ continue;
1636
+ }
1637
+ if (out.kind === "auth" || out.kind === "unavailable" || out.status === 429) {
1638
+ log(`plune: could not update the code snapshot of test case ${id} (${out.detail || out.kind}); the rest are left as they are.`);
1639
+ break;
1640
+ }
1641
+ refused += 1;
1642
+ }
1643
+ const left = due.length - tried;
1644
+ const parts = [`${updated} code snapshot(s) updated`];
1645
+ if (refused > 0) parts.push(`${refused} not updated`);
1646
+ if (left > 0 && tried === Math.min(due.length, SNAPSHOT_UPDATES_MAX)) parts.push(`${left} left for the next run`);
1647
+ if (updated + refused > 0) log(`plune: ${parts.join(", ")}`);
1648
+ }
1428
1649
  const sending = /* @__PURE__ */ new Set();
1429
1650
  let sendError;
1430
1651
  let answered = false;
@@ -1467,6 +1688,8 @@ async function startRun(passed, declared) {
1467
1688
  if (match.kind === "found") {
1468
1689
  const { keys: _keys, files: files2, ...rest } = result;
1469
1690
  submissions.push({ ...rest, testCaseId: match.testCaseId });
1691
+ const text = snapshotByKey.get(result.resultKey);
1692
+ if (text !== void 0) snapshots.set(match.testCaseId, text);
1470
1693
  if (files2 !== void 0) filesByKey.set(result.resultKey, files2);
1471
1694
  } else if (match.kind === "unmatched") {
1472
1695
  stats.unresolved += 1;
@@ -1483,16 +1706,24 @@ async function startRun(passed, declared) {
1483
1706
  await send(submissions, filesByKey);
1484
1707
  }
1485
1708
  async function send(submissions, filesByKey) {
1486
- for (const part of packed(submissions)) {
1709
+ for (const packedPart of packed(submissions)) {
1710
+ let part = targetsRefused ? packedPart.map(withoutTargets) : packedPart;
1487
1711
  if (offline) {
1488
1712
  defer(part);
1489
1713
  continue;
1490
1714
  }
1491
- const out = await client.post(
1715
+ const post = (results) => client.post(
1492
1716
  `/v1/runs/${runId}/results`,
1493
1717
  // The job's combination on every batch; a refusal of it is a 422 said below as it came.
1494
- { results: part, ...configuration !== void 0 ? { configuration } : {} }
1718
+ { results, ...configuration !== void 0 ? { configuration } : {} }
1495
1719
  );
1720
+ let out = await post(part);
1721
+ if (!out.ok && out.kind === "invalid" && out.status === 400 && part.some((r) => r.targets !== void 0)) {
1722
+ if (!targetsRefused) log("plune: the platform does not take targets on a result yet \u2014 the results are sent without them.");
1723
+ targetsRefused = true;
1724
+ part = part.map(withoutTargets);
1725
+ out = await post(part);
1726
+ }
1496
1727
  const counts = out.ok ? out.body?.counts : void 0;
1497
1728
  const told = COUNTED.filter((k) => typeof counts?.[k] === "number");
1498
1729
  if (told.length > 0) {
@@ -1572,7 +1803,10 @@ async function startRun(passed, declared) {
1572
1803
  return stats;
1573
1804
  },
1574
1805
  async add(result) {
1575
- buffer.push({ ...result, keys: bound(result.keys) });
1806
+ const { codeAt, ...rest } = result;
1807
+ const text = codeAt === void 0 ? void 0 : snapshotAt(codeAt, specFiles);
1808
+ if (text !== void 0) snapshotByKey.set(result.resultKey, text);
1809
+ buffer.push({ ...rest, keys: bound(result.keys) });
1576
1810
  if (buffer.length >= batchSize) await flushBuffer();
1577
1811
  },
1578
1812
  flush,
@@ -1581,6 +1815,7 @@ async function startRun(passed, declared) {
1581
1815
  done = true;
1582
1816
  await flush();
1583
1817
  await offer();
1818
+ await syncSnapshots();
1584
1819
  let frozen;
1585
1820
  if (runId !== null && !offline) {
1586
1821
  const out = await client.post(`/v1/runs/${runId}/events`, {
@@ -1604,6 +1839,7 @@ async function startRun(passed, declared) {
1604
1839
  done = true;
1605
1840
  await flush();
1606
1841
  await offer();
1842
+ await syncSnapshots();
1607
1843
  let frozen;
1608
1844
  const after = [];
1609
1845
  const shard = env.shard;
@@ -72,6 +72,8 @@ interface PlatformClient {
72
72
  del<T>(path: string): Promise<ClientOutcome<T>>;
73
73
  /** A GET, through the same retries, classification and token scrubbing. */
74
74
  get<T>(path: string): Promise<ClientOutcome<T>>;
75
+ /** A PATCH with a JSON body, the same way as a POST. */
76
+ patch<T>(path: string, body: unknown): Promise<ClientOutcome<T>>;
75
77
  /**
76
78
  * The bytes to a short-lived link of the customer's bucket: exactly the headers the
77
79
  * link came with, no token of ours. Network failures and 5xx wait and try again, up to three times; a 403
@@ -196,6 +198,16 @@ interface PendingResult {
196
198
  */
197
199
  title?: string;
198
200
  specRef?: string;
201
+ /**
202
+ * Where the test is declared on this machine: its file (absolute, or from the working directory) and
203
+ * the line of its `test()` call. Never sent as it is: the core reads the call's text from it and, for a
204
+ * matched automated case, sends that as the case's code snapshot.
205
+ */
206
+ codeAt?: {
207
+ file: string;
208
+ line: number;
209
+ column?: number;
210
+ };
199
211
  execution?: Execution;
200
212
  errorContext?: string;
201
213
  /** What failed and where, for a failed attempt; a pass carries none. Built by `failureOf`. */
@@ -210,6 +222,12 @@ interface PendingResult {
210
222
  * fallback file either, which keeps a file by its path and leaves the bytes out.
211
223
  */
212
224
  files?: ResultFile[];
225
+ /**
226
+ * What the test is about, beside who it is (a tool of an MCP server): stored with the result, never part of its
227
+ * identity. Absent rather than empty. A platform older than the field refuses the batch; the session then sends it
228
+ * again without them (see `send`).
229
+ */
230
+ targets?: string[];
213
231
  }
214
232
  /**
215
233
  * What a failed attempt says about itself on the run page: every field
@@ -283,7 +301,7 @@ interface FailedAttempt {
283
301
  repoRoot?: string;
284
302
  }
285
303
  /** What a run submission looks like once a key has resolved. Built by the core, never by a caller. */
286
- interface ResultSubmission extends Omit<PendingResult, 'keys' | 'testCaseId' | 'files'> {
304
+ interface ResultSubmission extends Omit<PendingResult, 'keys' | 'testCaseId' | 'files' | 'codeAt'> {
287
305
  testCaseId: string;
288
306
  }
289
307
  /** One entry of the "what this run intended to execute" list, from which the platform derives
@@ -72,6 +72,8 @@ interface PlatformClient {
72
72
  del<T>(path: string): Promise<ClientOutcome<T>>;
73
73
  /** A GET, through the same retries, classification and token scrubbing. */
74
74
  get<T>(path: string): Promise<ClientOutcome<T>>;
75
+ /** A PATCH with a JSON body, the same way as a POST. */
76
+ patch<T>(path: string, body: unknown): Promise<ClientOutcome<T>>;
75
77
  /**
76
78
  * The bytes to a short-lived link of the customer's bucket: exactly the headers the
77
79
  * link came with, no token of ours. Network failures and 5xx wait and try again, up to three times; a 403
@@ -196,6 +198,16 @@ interface PendingResult {
196
198
  */
197
199
  title?: string;
198
200
  specRef?: string;
201
+ /**
202
+ * Where the test is declared on this machine: its file (absolute, or from the working directory) and
203
+ * the line of its `test()` call. Never sent as it is: the core reads the call's text from it and, for a
204
+ * matched automated case, sends that as the case's code snapshot.
205
+ */
206
+ codeAt?: {
207
+ file: string;
208
+ line: number;
209
+ column?: number;
210
+ };
199
211
  execution?: Execution;
200
212
  errorContext?: string;
201
213
  /** What failed and where, for a failed attempt; a pass carries none. Built by `failureOf`. */
@@ -210,6 +222,12 @@ interface PendingResult {
210
222
  * fallback file either, which keeps a file by its path and leaves the bytes out.
211
223
  */
212
224
  files?: ResultFile[];
225
+ /**
226
+ * What the test is about, beside who it is (a tool of an MCP server): stored with the result, never part of its
227
+ * identity. Absent rather than empty. A platform older than the field refuses the batch; the session then sends it
228
+ * again without them (see `send`).
229
+ */
230
+ targets?: string[];
213
231
  }
214
232
  /**
215
233
  * What a failed attempt says about itself on the run page: every field
@@ -283,7 +301,7 @@ interface FailedAttempt {
283
301
  repoRoot?: string;
284
302
  }
285
303
  /** What a run submission looks like once a key has resolved. Built by the core, never by a caller. */
286
- interface ResultSubmission extends Omit<PendingResult, 'keys' | 'testCaseId' | 'files'> {
304
+ interface ResultSubmission extends Omit<PendingResult, 'keys' | 'testCaseId' | 'files' | 'codeAt'> {
287
305
  testCaseId: string;
288
306
  }
289
307
  /** One entry of the "what this run intended to execute" list, from which the platform derives