@vibgrate/cli 2026.813.1 → 2026.814.2
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/DOCS.md +258 -22
- package/NOTICE +7 -0
- package/README.md +273 -11
- package/dist/agent-5ANHRYEI.js +26 -0
- package/dist/{agent-N3CP3SPI.js.map → agent-5ANHRYEI.js.map} +1 -1
- package/dist/approvals-T2KXPJLV.js +9 -0
- package/dist/approvals-T2KXPJLV.js.map +1 -0
- package/dist/baseline-WVD6P5IO.js +9 -0
- package/dist/{baseline-ZMRZRGFI.js.map → baseline-WVD6P5IO.js.map} +1 -1
- package/dist/{checkpoint-4WFZMKEO.js → checkpoint-UYMYMMQO.js} +6 -3
- package/dist/checkpoint-UYMYMMQO.js.map +1 -0
- package/dist/chunk-2H2U3DC7.js +6 -0
- package/dist/{chunk-RT7P5AYU.js.map → chunk-2H2U3DC7.js.map} +1 -1
- package/dist/chunk-2U37PFB2.js +64 -0
- package/dist/chunk-2U37PFB2.js.map +1 -0
- package/dist/{chunk-GOPANQZT.js → chunk-54RGT2T5.js} +3 -3
- package/dist/{chunk-GOPANQZT.js.map → chunk-54RGT2T5.js.map} +1 -1
- package/dist/{chunk-OYHAF2J2.js → chunk-5GLQNMTI.js} +5 -5
- package/dist/{chunk-OYHAF2J2.js.map → chunk-5GLQNMTI.js.map} +1 -1
- package/dist/{chunk-EWZKOU66.js → chunk-75LJM5XD.js} +30 -66
- package/dist/chunk-75LJM5XD.js.map +1 -0
- package/dist/{chunk-KF2QT6RY.js → chunk-7NMXE6KG.js} +4 -4
- package/dist/{chunk-KF2QT6RY.js.map → chunk-7NMXE6KG.js.map} +1 -1
- package/dist/{chunk-UZP623Y4.js → chunk-7QDHQLUS.js} +4 -4
- package/dist/{chunk-UZP623Y4.js.map → chunk-7QDHQLUS.js.map} +1 -1
- package/dist/chunk-AJS4EL2C.js +266 -0
- package/dist/chunk-AJS4EL2C.js.map +1 -0
- package/dist/{chunk-Z3MUWXP3.js → chunk-BH54SLGZ.js} +4 -4
- package/dist/{chunk-Z3MUWXP3.js.map → chunk-BH54SLGZ.js.map} +1 -1
- package/dist/{chunk-CJNWHXQD.js → chunk-DSUGC7F5.js} +4 -4
- package/dist/{chunk-CJNWHXQD.js.map → chunk-DSUGC7F5.js.map} +1 -1
- package/dist/{chunk-FBVKQXBH.js → chunk-FOW5IF73.js} +3 -3
- package/dist/{chunk-FBVKQXBH.js.map → chunk-FOW5IF73.js.map} +1 -1
- package/dist/{chunk-6GQLEDVK.js → chunk-IHLLWBZU.js} +6 -5
- package/dist/chunk-IHLLWBZU.js.map +1 -0
- package/dist/{chunk-RHKJPTON.js → chunk-IHXNOY3R.js} +208 -56
- package/dist/chunk-IHXNOY3R.js.map +1 -0
- package/dist/{chunk-5JJBGBP2.js → chunk-JCN6MSXQ.js} +7 -7
- package/dist/{chunk-5JJBGBP2.js.map → chunk-JCN6MSXQ.js.map} +1 -1
- package/dist/{chunk-YJU7S7N6.js → chunk-KGPX4EUN.js} +4 -4
- package/dist/{chunk-YJU7S7N6.js.map → chunk-KGPX4EUN.js.map} +1 -1
- package/dist/{chunk-ADP6ITGF.js → chunk-N3XFY3PX.js} +68 -11
- package/dist/chunk-N3XFY3PX.js.map +1 -0
- package/dist/{chunk-JYM4QT6F.js → chunk-NKFXXP6W.js} +5 -5
- package/dist/{chunk-JYM4QT6F.js.map → chunk-NKFXXP6W.js.map} +1 -1
- package/dist/{chunk-5ROZODMW.js → chunk-TFAXW7VM.js} +2 -2
- package/dist/chunk-TFAXW7VM.js.map +1 -0
- package/dist/{chunk-6423BHLN.js → chunk-TNROG5CO.js} +19 -9
- package/dist/chunk-TNROG5CO.js.map +1 -0
- package/dist/chunk-TVDYEHIM.js +174 -0
- package/dist/chunk-TVDYEHIM.js.map +1 -0
- package/dist/{chunk-7ZHSSGUF.js → chunk-WQLZSVNF.js} +4 -3
- package/dist/chunk-WQLZSVNF.js.map +1 -0
- package/dist/{chunk-3WUTQYRY.js → chunk-WWGLVF7D.js} +9 -8
- package/dist/chunk-WWGLVF7D.js.map +1 -0
- package/dist/{chunk-KBP7GJV6.js → chunk-X76VPOYH.js} +19 -9
- package/dist/chunk-X76VPOYH.js.map +1 -0
- package/dist/{chunk-IJQOZ6ZD.js → chunk-YNV5M3JW.js} +8 -8
- package/dist/chunk-YNV5M3JW.js.map +1 -0
- package/dist/{chunk-Z3AYOZ3C.js → chunk-YQNTIBKS.js} +6 -6
- package/dist/{chunk-Z3AYOZ3C.js.map → chunk-YQNTIBKS.js.map} +1 -1
- package/dist/cli.js +1130 -489
- package/dist/cli.js.map +1 -1
- package/dist/embed-worker-main.js +4 -3
- package/dist/embed-worker-main.js.map +1 -1
- package/dist/{ensure-map-PHAJACFF.js → ensure-map-HQ7A5NDL.js} +15 -14
- package/dist/{ensure-map-PHAJACFF.js.map → ensure-map-HQ7A5NDL.js.map} +1 -1
- package/dist/fastembed-S6YEJYQV.js +292 -0
- package/dist/fastembed-S6YEJYQV.js.map +1 -0
- package/dist/graph-backend-W2TNTMY7.js +14 -0
- package/dist/{graph-backend-4B3MTVIW.js.map → graph-backend-W2TNTMY7.js.map} +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +14 -13
- package/dist/index.js.map +1 -1
- package/dist/{interactive-WUXMXFNM.js → interactive-EW2VJ3BZ.js} +32 -30
- package/dist/interactive-EW2VJ3BZ.js.map +1 -0
- package/dist/load-64RK5O6C.js +10 -0
- package/dist/{load-EUZSV73H.js.map → load-64RK5O6C.js.map} +1 -1
- package/dist/{run-outcome-O5PR7ZCK.js → run-outcome-6QNQIHPV.js} +6 -5
- package/dist/run-outcome-6QNQIHPV.js.map +1 -0
- package/dist/runtime-session-RJHH3KMF.js +21 -0
- package/dist/{runtime-session-PPQDTFIK.js.map → runtime-session-RJHH3KMF.js.map} +1 -1
- package/dist/session-4BGYASOH.js +16 -0
- package/dist/{session-WS7SOVJE.js.map → session-4BGYASOH.js.map} +1 -1
- package/dist/session-store-AQUORKWB.js +4 -0
- package/dist/{session-store-KGONLWHN.js.map → session-store-AQUORKWB.js.map} +1 -1
- package/dist/{stream-json-7MK3QQYG.js → stream-json-GY5N7WZT.js} +76 -24
- package/dist/stream-json-GY5N7WZT.js.map +1 -0
- package/dist/version-DPAMQW6M.js +4 -0
- package/dist/version-DPAMQW6M.js.map +1 -0
- package/dist/{vg-mcp-bridge-DQLCHBI6.js → vg-mcp-bridge-IGHJKKSL.js} +11 -10
- package/dist/vg-mcp-bridge-IGHJKKSL.js.map +1 -0
- package/dist/{vgd-Y25XSQGZ.js → vgd-ORPA5C2K.js} +12 -11
- package/dist/vgd-ORPA5C2K.js.map +1 -0
- package/dist/worktree-session-D575IQWM.js +82 -0
- package/dist/worktree-session-D575IQWM.js.map +1 -0
- package/package.json +4 -2
- package/dist/agent-N3CP3SPI.js +0 -24
- package/dist/baseline-ZMRZRGFI.js +0 -9
- package/dist/checkpoint-4WFZMKEO.js.map +0 -1
- package/dist/chunk-3WUTQYRY.js.map +0 -1
- package/dist/chunk-5ROZODMW.js.map +0 -1
- package/dist/chunk-6423BHLN.js.map +0 -1
- package/dist/chunk-6GQLEDVK.js.map +0 -1
- package/dist/chunk-7ZHSSGUF.js.map +0 -1
- package/dist/chunk-ADP6ITGF.js.map +0 -1
- package/dist/chunk-EWZKOU66.js.map +0 -1
- package/dist/chunk-IJQOZ6ZD.js.map +0 -1
- package/dist/chunk-KBP7GJV6.js.map +0 -1
- package/dist/chunk-RHKJPTON.js.map +0 -1
- package/dist/chunk-RT7P5AYU.js +0 -6
- package/dist/chunk-Z7FM3ETS.js +0 -126
- package/dist/chunk-Z7FM3ETS.js.map +0 -1
- package/dist/graph-backend-4B3MTVIW.js +0 -13
- package/dist/interactive-WUXMXFNM.js.map +0 -1
- package/dist/load-EUZSV73H.js +0 -9
- package/dist/run-outcome-O5PR7ZCK.js.map +0 -1
- package/dist/runtime-session-PPQDTFIK.js +0 -20
- package/dist/session-WS7SOVJE.js +0 -15
- package/dist/session-store-KGONLWHN.js +0 -4
- package/dist/stream-json-7MK3QQYG.js.map +0 -1
- package/dist/vg-mcp-bridge-DQLCHBI6.js.map +0 -1
- package/dist/vgd-Y25XSQGZ.js.map +0 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { isSecretPath, secretRefusal, secretEgressRefusal, redactText } from './chunk-543E6WDJ.js';
|
|
2
|
-
import {
|
|
3
|
-
import { localGraphBackend } from './chunk-
|
|
2
|
+
import { findMatchingRule, ruleLabel } from './chunk-TVDYEHIM.js';
|
|
3
|
+
import { localGraphBackend } from './chunk-54RGT2T5.js';
|
|
4
4
|
import { buildIdentifierTrieFromGraph, KvBlockRegistry, graphDraftCandidates, extractIdentifiers, scanIdentifiersAgainstTrie } from './chunk-5HYCB55P.js';
|
|
5
|
-
import {
|
|
5
|
+
import { buildAgentMessages, redactSecrets, unifiedDiff, applyEdit } from './chunk-N3XFY3PX.js';
|
|
6
6
|
import { resolve } from './chunk-VIWZ4QT7.js';
|
|
7
|
-
import { searchSymbols, resolveLib, loadCatalog, readDoc, localPackageDocs, resolveVersion } from './chunk-
|
|
7
|
+
import { searchSymbols, resolveLib, loadCatalog, readDoc, localPackageDocs, resolveVersion } from './chunk-7QDHQLUS.js';
|
|
8
8
|
import { resolveOne } from './chunk-J7LKEB2R.js';
|
|
9
|
-
import {
|
|
9
|
+
import { summarizeCapsule, CAPSULE_RANKING_VERSION, buildCodeContext, buildTaskCapsule, capsuleToCodeContext, recordCliCall, CLI_TOOL_ALIASES } from './chunk-DSUGC7F5.js';
|
|
10
|
+
import { userAskFromInstruction, isLocateOnlyInstruction, extractLiteralNeedles, impactOf } from './chunk-KGPX4EUN.js';
|
|
10
11
|
import { parseSource, langForExtension } from './chunk-UTNNGKKX.js';
|
|
11
|
-
import { analyzeQuestion, loadTopicTags } from './chunk-
|
|
12
|
+
import { analyzeQuestion, loadTopicTags } from './chunk-75LJM5XD.js';
|
|
12
13
|
import { repositoryIdFromRoot } from './chunk-BWPBB45M.js';
|
|
13
14
|
import { hashString, canonicalize } from './chunk-JFGYT6BI.js';
|
|
14
15
|
import { spawnSync, spawn } from 'child_process';
|
|
@@ -24,7 +25,6 @@ function buildCapsuleDelta(previous, next) {
|
|
|
24
25
|
const prevPrimary = keySet(previous.primary);
|
|
25
26
|
const nextPrimary = keySet(next.primary);
|
|
26
27
|
const prevSupport = keySet(previous.supporting);
|
|
27
|
-
keySet(next.supporting);
|
|
28
28
|
const addedPrimary = next.primary.filter((p) => !prevPrimary.has(symKey(p))).map((p) => ({ qualifiedName: p.qualifiedName, file: p.file, kind: p.kind }));
|
|
29
29
|
const removedPrimary = previous.primary.filter((p) => !nextPrimary.has(symKey(p))).map((p) => ({ qualifiedName: p.qualifiedName, file: p.file }));
|
|
30
30
|
const addedSupporting = next.supporting.filter((p) => !prevSupport.has(symKey(p))).map((p) => ({ qualifiedName: p.qualifiedName, file: p.file, kind: p.kind }));
|
|
@@ -337,6 +337,154 @@ function normalize2(file) {
|
|
|
337
337
|
return file.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
338
338
|
}
|
|
339
339
|
|
|
340
|
+
// src/code/safety.ts
|
|
341
|
+
var DANGEROUS = [
|
|
342
|
+
{ pattern: /\brm\s+(-[a-z]*f[a-z]*\s+)?(-[a-z]*r[a-z]*\s+)?(-[a-z]*\s+)*(\/|~|\$HOME|\.)(\s|$)/i, reason: "recursive/forced delete of a root or home path" },
|
|
343
|
+
{ pattern: /\brm\s+-[a-z]*r[a-z]*f|\brm\s+-[a-z]*f[a-z]*r/i, reason: "recursive force delete" },
|
|
344
|
+
{ pattern: /\bmkfs\b|\bmke2fs\b/i, reason: "formats a filesystem" },
|
|
345
|
+
{ pattern: /\bdd\b[^|]*\bof=\/dev\//i, reason: "writes raw to a device" },
|
|
346
|
+
{ pattern: />\s*\/dev\/(sd|nvme|hd|disk)/i, reason: "writes raw to a disk device" },
|
|
347
|
+
{ pattern: /:\s*\(\s*\)\s*\{[^}]*\}\s*;\s*:/, reason: "fork bomb" },
|
|
348
|
+
{ pattern: /\b(curl|wget|fetch)\b[^\n|]*\|\s*(sudo\s+)?(sh|bash|zsh|python|node|ruby|perl)\b/i, reason: "pipes a download straight into a shell/interpreter" },
|
|
349
|
+
{ pattern: /\bgit\s+push\b[^\n]*(--force\b|-f\b)/i, reason: "force-push (rewrites remote history)" },
|
|
350
|
+
{ pattern: /\bgit\s+(reset\s+--hard|clean\s+-[a-z]*f)/i, reason: "destroys uncommitted work" },
|
|
351
|
+
{ pattern: /\b(shutdown|reboot|halt|poweroff)\b/i, reason: "powers off / reboots the machine" },
|
|
352
|
+
{ pattern: /\bchmod\s+-R\s+0*777\s+(\/|~)/i, reason: "world-writable on a root/home path" },
|
|
353
|
+
{ pattern: /\bsudo\b/i, reason: "runs as root (never automatic)" },
|
|
354
|
+
{ pattern: /\beval\b\s+["'`]?\$\(/i, reason: "evaluates dynamically-constructed shell" }
|
|
355
|
+
];
|
|
356
|
+
function dangerousCommand(command, extraDeny = []) {
|
|
357
|
+
const cmd = command.trim();
|
|
358
|
+
for (const { pattern, reason } of DANGEROUS) {
|
|
359
|
+
if (pattern.test(cmd)) return reason;
|
|
360
|
+
}
|
|
361
|
+
for (const raw of extraDeny) {
|
|
362
|
+
if (!raw) continue;
|
|
363
|
+
try {
|
|
364
|
+
if (new RegExp(raw, "i").test(cmd)) return `matches a project denylist rule (${raw})`;
|
|
365
|
+
} catch {
|
|
366
|
+
if (cmd.toLowerCase().includes(raw.toLowerCase())) return `matches a project denylist rule (${raw})`;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
var READ_ONLY_ANY_ARGS = /* @__PURE__ */ new Set([
|
|
372
|
+
"ls",
|
|
373
|
+
"pwd",
|
|
374
|
+
"cat",
|
|
375
|
+
"head",
|
|
376
|
+
"tail",
|
|
377
|
+
"wc",
|
|
378
|
+
"cut",
|
|
379
|
+
"tr",
|
|
380
|
+
"nl",
|
|
381
|
+
"column",
|
|
382
|
+
"grep",
|
|
383
|
+
"egrep",
|
|
384
|
+
"fgrep",
|
|
385
|
+
"rg",
|
|
386
|
+
"file",
|
|
387
|
+
"stat",
|
|
388
|
+
"du",
|
|
389
|
+
"df",
|
|
390
|
+
"tree",
|
|
391
|
+
"which",
|
|
392
|
+
"whereis",
|
|
393
|
+
"whoami",
|
|
394
|
+
"id",
|
|
395
|
+
"uname",
|
|
396
|
+
"hostname",
|
|
397
|
+
"uptime",
|
|
398
|
+
"basename",
|
|
399
|
+
"dirname",
|
|
400
|
+
"realpath",
|
|
401
|
+
"readlink",
|
|
402
|
+
"echo",
|
|
403
|
+
"printf",
|
|
404
|
+
"true",
|
|
405
|
+
"false",
|
|
406
|
+
"diff",
|
|
407
|
+
"cmp",
|
|
408
|
+
"strings",
|
|
409
|
+
"md5sum",
|
|
410
|
+
"sha1sum",
|
|
411
|
+
"sha256sum",
|
|
412
|
+
"shasum",
|
|
413
|
+
"cksum",
|
|
414
|
+
// jq has no write-to-file flag of its own; file writes need a redirect,
|
|
415
|
+
// which the metacharacter screen already disqualifies. Membership here also
|
|
416
|
+
// applies the shared `--output` screen, unlike the old always-true guard.
|
|
417
|
+
"jq"
|
|
418
|
+
]);
|
|
419
|
+
var GUARDED = {
|
|
420
|
+
// find can write via -exec/-delete/-ok and the f* output actions.
|
|
421
|
+
find: (args) => !args.some((a) => /^-(exec|execdir|ok|okdir|delete|fprint|fprintf|fprint0|fls)$/.test(a)),
|
|
422
|
+
// date -s / --set sets the clock. Prefix match catches the attached getopt
|
|
423
|
+
// form too (`-s2020-01-01`).
|
|
424
|
+
date: (args) => !args.some((a) => a.startsWith("-s") || a.startsWith("--set")),
|
|
425
|
+
// sort -o / --output writes a file — including the attached form (`-oFILE`).
|
|
426
|
+
sort: (args) => !args.some((a) => a.startsWith("-o") || a.startsWith("--output")),
|
|
427
|
+
// uniq's second positional argument is an output file.
|
|
428
|
+
uniq: (args) => args.filter((a) => !a.startsWith("-")).length <= 1
|
|
429
|
+
};
|
|
430
|
+
var GIT_READ_ONLY = /* @__PURE__ */ new Set([
|
|
431
|
+
"status",
|
|
432
|
+
"log",
|
|
433
|
+
"diff",
|
|
434
|
+
"show",
|
|
435
|
+
"blame",
|
|
436
|
+
"shortlog",
|
|
437
|
+
"describe",
|
|
438
|
+
"ls-files",
|
|
439
|
+
"rev-parse",
|
|
440
|
+
"grep",
|
|
441
|
+
"show-ref",
|
|
442
|
+
"cat-file",
|
|
443
|
+
"count-objects",
|
|
444
|
+
"reflog"
|
|
445
|
+
]);
|
|
446
|
+
var PKG_READ_ONLY = /* @__PURE__ */ new Set(["ls", "list", "ll", "why", "view", "info", "outdated"]);
|
|
447
|
+
function readOnlySegment(segment) {
|
|
448
|
+
const tokens = segment.split(/\s+/).filter(Boolean);
|
|
449
|
+
if (!tokens.length) return false;
|
|
450
|
+
const head = tokens[0];
|
|
451
|
+
const args = tokens.slice(1);
|
|
452
|
+
if (head.includes("=")) return false;
|
|
453
|
+
if (args.length === 1 && /^(--version|--help)$/.test(args[0]) && /^[\w@-][\w.@-]*$/.test(head) && !head.includes("/") && !head.includes("\\")) {
|
|
454
|
+
return true;
|
|
455
|
+
}
|
|
456
|
+
if (READ_ONLY_ANY_ARGS.has(head)) {
|
|
457
|
+
if (args.some((a) => a.startsWith("--output"))) return false;
|
|
458
|
+
return true;
|
|
459
|
+
}
|
|
460
|
+
const guard = GUARDED[head];
|
|
461
|
+
if (guard) return guard(args);
|
|
462
|
+
if (head === "git") {
|
|
463
|
+
const sub = args[0];
|
|
464
|
+
if (!sub || sub.startsWith("-")) return false;
|
|
465
|
+
const rest = args.slice(1);
|
|
466
|
+
if (rest.some((a) => a.startsWith("--output"))) return false;
|
|
467
|
+
if (GIT_READ_ONLY.has(sub)) return true;
|
|
468
|
+
if (sub === "branch") return rest.every((a) => /^(-a|-r|-v|-vv|-l|--list|--all|--verbose)$/.test(a));
|
|
469
|
+
if (sub === "remote") return rest.every((a) => a === "-v" || a === "--verbose");
|
|
470
|
+
if (sub === "tag") return rest.every((a) => /^(-l|--list|-n\d*)$/.test(a));
|
|
471
|
+
if (sub === "stash") return rest[0] === "list" || rest[0] === "show";
|
|
472
|
+
if (sub === "config") return rest[0] === "-l" || rest[0] === "--list" || rest[0] === "--get" || rest[0] === "--get-all" || rest[0] === "--get-regexp";
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
if (head === "npm" || head === "pnpm" || head === "yarn") {
|
|
476
|
+
const sub = args[0];
|
|
477
|
+
return !!sub && PKG_READ_ONLY.has(sub);
|
|
478
|
+
}
|
|
479
|
+
return false;
|
|
480
|
+
}
|
|
481
|
+
function readOnlyCommand(command) {
|
|
482
|
+
const cmd = command.trim();
|
|
483
|
+
if (!cmd) return false;
|
|
484
|
+
if (/[><;&`\n(){}]|\$\(/.test(cmd)) return false;
|
|
485
|
+
return cmd.split("|").every((seg) => readOnlySegment(seg));
|
|
486
|
+
}
|
|
487
|
+
|
|
340
488
|
// src/code/patch-ir.ts
|
|
341
489
|
var PATCH_IR_SCHEMA_VERSION = "patch-ir/0";
|
|
342
490
|
function patchIRToCodeEdits(patch) {
|
|
@@ -593,38 +741,6 @@ function previewSides(before, after) {
|
|
|
593
741
|
return { before: b, after: a };
|
|
594
742
|
}
|
|
595
743
|
|
|
596
|
-
// src/code/safety.ts
|
|
597
|
-
var DANGEROUS = [
|
|
598
|
-
{ pattern: /\brm\s+(-[a-z]*f[a-z]*\s+)?(-[a-z]*r[a-z]*\s+)?(-[a-z]*\s+)*(\/|~|\$HOME|\.)(\s|$)/i, reason: "recursive/forced delete of a root or home path" },
|
|
599
|
-
{ pattern: /\brm\s+-[a-z]*r[a-z]*f|\brm\s+-[a-z]*f[a-z]*r/i, reason: "recursive force delete" },
|
|
600
|
-
{ pattern: /\bmkfs\b|\bmke2fs\b/i, reason: "formats a filesystem" },
|
|
601
|
-
{ pattern: /\bdd\b[^|]*\bof=\/dev\//i, reason: "writes raw to a device" },
|
|
602
|
-
{ pattern: />\s*\/dev\/(sd|nvme|hd|disk)/i, reason: "writes raw to a disk device" },
|
|
603
|
-
{ pattern: /:\s*\(\s*\)\s*\{[^}]*\}\s*;\s*:/, reason: "fork bomb" },
|
|
604
|
-
{ pattern: /\b(curl|wget|fetch)\b[^\n|]*\|\s*(sudo\s+)?(sh|bash|zsh|python|node|ruby|perl)\b/i, reason: "pipes a download straight into a shell/interpreter" },
|
|
605
|
-
{ pattern: /\bgit\s+push\b[^\n]*(--force\b|-f\b)/i, reason: "force-push (rewrites remote history)" },
|
|
606
|
-
{ pattern: /\bgit\s+(reset\s+--hard|clean\s+-[a-z]*f)/i, reason: "destroys uncommitted work" },
|
|
607
|
-
{ pattern: /\b(shutdown|reboot|halt|poweroff)\b/i, reason: "powers off / reboots the machine" },
|
|
608
|
-
{ pattern: /\bchmod\s+-R\s+0*777\s+(\/|~)/i, reason: "world-writable on a root/home path" },
|
|
609
|
-
{ pattern: /\bsudo\b/i, reason: "runs as root (never automatic)" },
|
|
610
|
-
{ pattern: /\beval\b\s+["'`]?\$\(/i, reason: "evaluates dynamically-constructed shell" }
|
|
611
|
-
];
|
|
612
|
-
function dangerousCommand(command, extraDeny = []) {
|
|
613
|
-
const cmd = command.trim();
|
|
614
|
-
for (const { pattern, reason } of DANGEROUS) {
|
|
615
|
-
if (pattern.test(cmd)) return reason;
|
|
616
|
-
}
|
|
617
|
-
for (const raw of extraDeny) {
|
|
618
|
-
if (!raw) continue;
|
|
619
|
-
try {
|
|
620
|
-
if (new RegExp(raw, "i").test(cmd)) return `matches a project denylist rule (${raw})`;
|
|
621
|
-
} catch {
|
|
622
|
-
if (cmd.toLowerCase().includes(raw.toLowerCase())) return `matches a project denylist rule (${raw})`;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
return null;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
744
|
// src/code/network-policy.ts
|
|
629
745
|
var NETWORK_POLICY_SCHEMA_VERSION = "network-policy/0";
|
|
630
746
|
var NETWORK_POLICY_VERSION = "network-policy@2026.07.0";
|
|
@@ -1822,8 +1938,8 @@ async function runSubagent(host, req) {
|
|
|
1822
1938
|
text: `Subagent starting${worktreePath ? ` in worktree ${worktreePath}` : " in-place"}\u2026`
|
|
1823
1939
|
});
|
|
1824
1940
|
try {
|
|
1825
|
-
const { runAgent: runAgent2 } = await import('./agent-
|
|
1826
|
-
const { nodeCodeFs } = await import('./session-
|
|
1941
|
+
const { runAgent: runAgent2 } = await import('./agent-5ANHRYEI.js');
|
|
1942
|
+
const { nodeCodeFs } = await import('./session-4BGYASOH.js');
|
|
1827
1943
|
const childFs = childRoot === host.root ? host.fsImpl : nodeCodeFs(childRoot);
|
|
1828
1944
|
const childApprove = async (action) => {
|
|
1829
1945
|
host.onEvent?.({
|
|
@@ -2222,10 +2338,10 @@ async function executeTool(call, ctx) {
|
|
|
2222
2338
|
finalSummary: `aborted: ${str(a.reason) || "no reason given"}`
|
|
2223
2339
|
};
|
|
2224
2340
|
default:
|
|
2225
|
-
return { content: `unknown tool "${call.name}". Available: ${AGENT_TOOLS.map((t) => t.name).join(", ")}`, mutated: false };
|
|
2341
|
+
return { content: `unknown tool "${call.name}". Available: ${AGENT_TOOLS.map((t) => t.name).join(", ")}`, mutated: false, failed: true };
|
|
2226
2342
|
}
|
|
2227
2343
|
} catch (e) {
|
|
2228
|
-
return { content: `tool ${call.name} failed: ${e.message}`, mutated: false };
|
|
2344
|
+
return { content: `tool ${call.name} failed: ${e.message}`, mutated: false, failed: true };
|
|
2229
2345
|
}
|
|
2230
2346
|
}
|
|
2231
2347
|
async function askUser(ctx, question, options) {
|
|
@@ -2317,7 +2433,7 @@ ${lines.join("\n")}`, mutated: false };
|
|
|
2317
2433
|
function readFile(ctx, path4, start, end) {
|
|
2318
2434
|
if (isSecretPath(path4)) return { content: secretRefusal(path4), mutated: false };
|
|
2319
2435
|
const content = ctx.fsImpl.read(path4);
|
|
2320
|
-
if (content === null) return { content: `${path4} not found`, mutated: false };
|
|
2436
|
+
if (content === null) return { content: `${path4} not found`, mutated: false, failed: true };
|
|
2321
2437
|
const lines = content.split("\n");
|
|
2322
2438
|
const from = start && start > 0 ? start - 1 : 0;
|
|
2323
2439
|
const to = end && end > 0 ? end : lines.length;
|
|
@@ -2403,7 +2519,7 @@ async function createFile(ctx, path4, content) {
|
|
|
2403
2519
|
}
|
|
2404
2520
|
const existing = ctx.fsImpl.read(path4);
|
|
2405
2521
|
if (existing !== null) return { content: `${path4} already exists \u2014 use edit_file`, mutated: false };
|
|
2406
|
-
if (!await ctx.approve({ kind: "create", file: path4, bytes: Buffer.byteLength(content) })) {
|
|
2522
|
+
if (!await ctx.approve({ kind: "create", file: path4, bytes: Buffer.byteLength(content), sides: previewSides("", content) })) {
|
|
2407
2523
|
return { content: `creating ${path4} was declined by the user`, mutated: false };
|
|
2408
2524
|
}
|
|
2409
2525
|
ctx.fsImpl.write(path4, content);
|
|
@@ -2412,7 +2528,7 @@ async function createFile(ctx, path4, content) {
|
|
|
2412
2528
|
async function deleteFile(ctx, path4) {
|
|
2413
2529
|
const before = ctx.fsImpl.read(path4);
|
|
2414
2530
|
if (before === null) return { content: `${path4} does not exist`, mutated: false };
|
|
2415
|
-
if (!await ctx.approve({ kind: "delete", file: path4 })) {
|
|
2531
|
+
if (!await ctx.approve({ kind: "delete", file: path4, sides: previewSides(before, "") })) {
|
|
2416
2532
|
return { content: `deleting ${path4} was declined by the user`, mutated: false };
|
|
2417
2533
|
}
|
|
2418
2534
|
ctx.fsImpl.remove(path4);
|
|
@@ -2425,7 +2541,7 @@ async function applyPatchTool(ctx, raw) {
|
|
|
2425
2541
|
}
|
|
2426
2542
|
const structural = validatePatchIR(patch);
|
|
2427
2543
|
if (!structural.ok) {
|
|
2428
|
-
return { content: `invalid PatchIR: ${structural.errors.join("; ")}`, mutated: false };
|
|
2544
|
+
return { content: `invalid PatchIR: ${structural.errors.join("; ")}`, mutated: false, failed: true };
|
|
2429
2545
|
}
|
|
2430
2546
|
if (ctx.enforceIdentifiers !== false && ctx.identifierTrie) {
|
|
2431
2547
|
const idCheck = enforceIdentifiersInPatch(patch, ctx.identifierTrie, {
|
|
@@ -2582,7 +2698,7 @@ function readNotebookTool(ctx, filePath, cell) {
|
|
|
2582
2698
|
if (!filePath) return { content: "read_notebook needs a path", mutated: false };
|
|
2583
2699
|
if (isSecretPath(filePath)) return { content: secretRefusal(filePath), mutated: false };
|
|
2584
2700
|
const raw = ctx.fsImpl.read(filePath);
|
|
2585
|
-
if (raw == null) return { content: `file not found: ${filePath}`, mutated: false };
|
|
2701
|
+
if (raw == null) return { content: `file not found: ${filePath}`, mutated: false, failed: true };
|
|
2586
2702
|
if (cell == null || Number.isNaN(cell)) {
|
|
2587
2703
|
const sum = summarizeNotebook(raw);
|
|
2588
2704
|
if (!sum.ok) return { content: sum.error, mutated: false };
|
|
@@ -2596,7 +2712,7 @@ async function editNotebookTool(ctx, filePath, cell, source) {
|
|
|
2596
2712
|
if (!filePath) return { content: "edit_notebook_cell needs a path", mutated: false };
|
|
2597
2713
|
if (isSecretPath(filePath)) return { content: secretRefusal(filePath), mutated: false };
|
|
2598
2714
|
const raw = ctx.fsImpl.read(filePath);
|
|
2599
|
-
if (raw == null) return { content: `file not found: ${filePath}`, mutated: false };
|
|
2715
|
+
if (raw == null) return { content: `file not found: ${filePath}`, mutated: false, failed: true };
|
|
2600
2716
|
const edited = editNotebookCell(raw, cell, source);
|
|
2601
2717
|
if (!edited.ok) return { content: edited.error, mutated: false };
|
|
2602
2718
|
const cellPreviewDiff = unifiedDiff(edited.before, edited.after, `${filePath}#cell${cell}`);
|
|
@@ -3481,9 +3597,26 @@ async function runAgent(options) {
|
|
|
3481
3597
|
if (action.kind === "patch") return action.files.map((f) => f.file);
|
|
3482
3598
|
return "file" in action && action.file ? [action.file] : [];
|
|
3483
3599
|
};
|
|
3600
|
+
const autoApproval = (action) => {
|
|
3601
|
+
if (action.kind === "run" && dangerousCommand(action.command, options.denyCommands)) return null;
|
|
3602
|
+
if (action.kind === "run" && readOnlyCommand(action.command)) return { note: null };
|
|
3603
|
+
const rules = options.approvalRules?.();
|
|
3604
|
+
if (rules?.length) {
|
|
3605
|
+
const rule = findMatchingRule(action, rules);
|
|
3606
|
+
if (rule) return { note: `Auto-approved by standing rule: ${ruleLabel(rule)}` };
|
|
3607
|
+
}
|
|
3608
|
+
return null;
|
|
3609
|
+
};
|
|
3484
3610
|
const approveAndCheckpoint = async (action) => {
|
|
3485
3611
|
if (options.plan) return false;
|
|
3486
|
-
|
|
3612
|
+
let approved;
|
|
3613
|
+
const shortCircuit = autoApproval(action);
|
|
3614
|
+
if (shortCircuit) {
|
|
3615
|
+
approved = true;
|
|
3616
|
+
if (shortCircuit.note) onEvent({ type: "notice", text: shortCircuit.note });
|
|
3617
|
+
} else {
|
|
3618
|
+
approved = await options.approve(action);
|
|
3619
|
+
}
|
|
3487
3620
|
if (!approved || !options.checkpoint) return approved;
|
|
3488
3621
|
const files = actionFiles(action);
|
|
3489
3622
|
if (!files.length) return approved;
|
|
@@ -3749,6 +3882,15 @@ Fix the failing tests, then call finish again.${verifyRounds === 0 ? " (last ver
|
|
|
3749
3882
|
}
|
|
3750
3883
|
currentStep = step;
|
|
3751
3884
|
onEvent({ type: "step", n: step });
|
|
3885
|
+
const injected = options.takeInjected?.();
|
|
3886
|
+
if (injected) {
|
|
3887
|
+
onEvent({ type: "injected", text: injected });
|
|
3888
|
+
messages.push({
|
|
3889
|
+
role: "user",
|
|
3890
|
+
content: `[The user sent this while you were working \u2014 factor it in before continuing:]
|
|
3891
|
+
${injected}`
|
|
3892
|
+
});
|
|
3893
|
+
}
|
|
3752
3894
|
const compacted = options.llmCompaction ? await compactWithModel(
|
|
3753
3895
|
messages,
|
|
3754
3896
|
contextBudget,
|
|
@@ -3783,7 +3925,8 @@ Fix the failing tests, then call finish again.${verifyRounds === 0 ? " (last ver
|
|
|
3783
3925
|
options.modelProfile,
|
|
3784
3926
|
identifierTrie,
|
|
3785
3927
|
draftCandidates,
|
|
3786
|
-
promptSegments
|
|
3928
|
+
promptSegments,
|
|
3929
|
+
options.reasoningEffort
|
|
3787
3930
|
);
|
|
3788
3931
|
result = c.result;
|
|
3789
3932
|
providerInfo = { id: c.provider.id, model: c.provider.model, fellBack: c.fellBack };
|
|
@@ -3796,7 +3939,12 @@ Fix the failing tests, then call finish again.${verifyRounds === 0 ? " (last ver
|
|
|
3796
3939
|
usage.promptTokens += result.usage.promptTokens ?? 0;
|
|
3797
3940
|
usage.completionTokens += result.usage.completionTokens ?? 0;
|
|
3798
3941
|
trajectory.recordUsage(result.usage.promptTokens ?? 0, result.usage.completionTokens ?? 0);
|
|
3799
|
-
onEvent({
|
|
3942
|
+
onEvent({
|
|
3943
|
+
type: "usage",
|
|
3944
|
+
promptTokens: result.usage.promptTokens ?? 0,
|
|
3945
|
+
completionTokens: result.usage.completionTokens ?? 0,
|
|
3946
|
+
...result.usage.cachedPromptTokens !== void 0 ? { cachedPromptTokens: result.usage.cachedPromptTokens } : {}
|
|
3947
|
+
});
|
|
3800
3948
|
}
|
|
3801
3949
|
const displayText = sanitizeAgentDisplayText(result.text ?? "");
|
|
3802
3950
|
if (displayText) onEvent({ type: "assistant", text: displayText });
|
|
@@ -3890,7 +4038,7 @@ ${gateNote}`;
|
|
|
3890
4038
|
(note: you have called this exact tool call ${n} times with no change \u2014 try a different approach, read more context, or call finish.)`;
|
|
3891
4039
|
}
|
|
3892
4040
|
trajectory.recordTool(call.name, step, toolResult.mutated);
|
|
3893
|
-
onEvent({ type: "tool-result", name: call.name, content, mutated: toolResult.mutated });
|
|
4041
|
+
onEvent({ type: "tool-result", name: call.name, content, mutated: toolResult.mutated, ...toolResult.failed ? { failed: true } : {} });
|
|
3894
4042
|
messages.push({ role: "tool", content, toolCallId: call.id, name: call.name });
|
|
3895
4043
|
if (toolResult.finished) {
|
|
3896
4044
|
if (await verifyOnFinish() === "retry") break;
|
|
@@ -3908,9 +4056,10 @@ ${gateNote}`;
|
|
|
3908
4056
|
}
|
|
3909
4057
|
return finish("max-steps", "reached the step limit before finishing", maxSteps);
|
|
3910
4058
|
}
|
|
3911
|
-
async function complete(providers, messages, tools, onEvent, stream, modelProfile, identifierTrie, draftCandidates, promptSegments) {
|
|
4059
|
+
async function complete(providers, messages, tools, onEvent, stream, modelProfile, identifierTrie, draftCandidates, promptSegments, reasoningEffort) {
|
|
3912
4060
|
if (providers.length === 0) throw new Error("no model provider available");
|
|
3913
4061
|
const onToken = stream ? (t) => onEvent({ type: "token", text: t }) : void 0;
|
|
4062
|
+
const onReasoningToken = stream ? (t) => onEvent({ type: "thinking", text: t }) : void 0;
|
|
3914
4063
|
let lastErr;
|
|
3915
4064
|
for (let i = 0; i < providers.length; i++) {
|
|
3916
4065
|
try {
|
|
@@ -3919,10 +4068,13 @@ async function complete(providers, messages, tools, onEvent, stream, modelProfil
|
|
|
3919
4068
|
tools,
|
|
3920
4069
|
stream,
|
|
3921
4070
|
onToken,
|
|
4071
|
+
onReasoningToken,
|
|
4072
|
+
...reasoningEffort ? { reasoningEffort } : {},
|
|
3922
4073
|
identifierTrie,
|
|
3923
4074
|
draftCandidates,
|
|
3924
4075
|
promptSegments
|
|
3925
4076
|
});
|
|
4077
|
+
if (!stream && result.reasoning) onEvent({ type: "thinking", text: result.reasoning });
|
|
3926
4078
|
return { result, provider: providers[i], fellBack: i > 0 };
|
|
3927
4079
|
} catch (e) {
|
|
3928
4080
|
lastErr = e;
|
|
@@ -4125,5 +4277,5 @@ function buildSpanIndex(graph) {
|
|
|
4125
4277
|
}
|
|
4126
4278
|
|
|
4127
4279
|
export { CONTEXT_POLICY_VERSION, DISCOVERY_TOOLS, MUTATION_TOOLS, compact, compactWithModel, computeFcsReport, createTrajectoryCollector, lookupModelCapabilities, renderFcsReportMarkdown, runAgent };
|
|
4128
|
-
//# sourceMappingURL=chunk-
|
|
4129
|
-
//# sourceMappingURL=chunk-
|
|
4280
|
+
//# sourceMappingURL=chunk-IHXNOY3R.js.map
|
|
4281
|
+
//# sourceMappingURL=chunk-IHXNOY3R.js.map
|