@cydm/pie 4.14.0 → 4.14.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/dist/builtin/extensions/ask-user/index.js +4 -4
- package/dist/builtin/extensions/cron/index.js +70 -17
- package/dist/builtin/extensions/im-forward/index.js +8 -8
- package/dist/builtin/extensions/memory/index.js +6 -6
- package/dist/builtin/extensions/pie-proc/README.md +12 -3
- package/dist/builtin/extensions/pie-proc/index.js +88 -45
- package/dist/builtin/extensions/plan-mode/index.js +4 -4
- package/dist/builtin/extensions/subagent/index.js +5 -5
- package/dist/builtin/extensions/todo/index.js +4 -4
- package/dist/chunks/{chunk-BOQIGMGQ.js → chunk-2WLKAMOH.js} +3 -3
- package/dist/chunks/{chunk-IK2FR2YF.js → chunk-DJ4LO7PQ.js} +1 -1
- package/dist/chunks/{chunk-MCR4JYI6.js → chunk-IM7DLPPY.js} +74 -8
- package/dist/chunks/{chunk-FD3KBPDR.js → chunk-IQDVL34H.js} +7 -7
- package/dist/chunks/{chunk-JKO42HZW.js → chunk-OQCKDEEE.js} +1 -1
- package/dist/chunks/{chunk-26KRUYZH.js → chunk-SAXKBFX3.js} +1 -1
- package/dist/chunks/{chunk-JJH77AUU.js → chunk-SYZR74QO.js} +4 -4
- package/dist/chunks/{chunk-KGWKRO7Z.js → chunk-TNRZEQD5.js} +2 -2
- package/dist/chunks/{chunk-UYDS75SI.js → chunk-TTSQWGAT.js} +2 -1
- package/dist/chunks/{chunk-EZZTMDWZ.js → chunk-X3ZVZB2R.js} +435 -17
- package/dist/chunks/{host-image-fallback-LPHB5CTL.js → host-image-fallback-AEKY2LSZ.js} +1 -1
- package/dist/chunks/{memory-git-ZJN6SPIU.js → memory-git-G56IXFWU.js} +5 -5
- package/dist/chunks/{model-registry-GLBIUOJR.js → model-registry-4LM2I6FR.js} +2 -2
- package/dist/chunks/{read-file-understanding-DFJPTTSB.js → read-file-understanding-GTNZHAK5.js} +5 -5
- package/dist/chunks/{src-KZ7YID3I.js → src-3YJ4UVEC.js} +3 -3
- package/dist/chunks/{src-ALHMJZ5R.js → src-APNP4M4N.js} +2 -2
- package/dist/chunks/{src-LEXKDSFV.js → src-T6AUO53N.js} +4 -4
- package/dist/chunks/{src-76Q33OY5.js → src-TNUD7EDH.js} +1 -1
- package/dist/chunks/{test-stream-OVGDTXOY.js → test-stream-EF2DHEHV.js} +1 -1
- package/dist/cli.js +16 -16
- package/package.json +1 -1
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
parseEntryIdSeq,
|
|
19
19
|
readAncestryPage,
|
|
20
20
|
requestInteraction
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-SYZR74QO.js";
|
|
22
22
|
import {
|
|
23
23
|
Agent,
|
|
24
24
|
getToolCallerIdentity
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-SAXKBFX3.js";
|
|
26
26
|
import {
|
|
27
27
|
ALL_THINKING_LEVELS,
|
|
28
28
|
AssistantMessageEventStream,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
hashText,
|
|
34
34
|
resolveThinkingSelection,
|
|
35
35
|
streamSimple
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-IM7DLPPY.js";
|
|
37
37
|
import {
|
|
38
38
|
Type
|
|
39
39
|
} from "./chunk-XXGYUYXI.js";
|
|
@@ -2388,6 +2388,259 @@ function transplantMessages(target, messages) {
|
|
|
2388
2388
|
}
|
|
2389
2389
|
}
|
|
2390
2390
|
|
|
2391
|
+
// ../../packages/shared-headless-capabilities/src/bash-policy-writes.ts
|
|
2392
|
+
function executableName(word) {
|
|
2393
|
+
const normalized = word.replace(/\\/g, "/").toLowerCase();
|
|
2394
|
+
const base = normalized.slice(normalized.lastIndexOf("/") + 1);
|
|
2395
|
+
return base.endsWith(".exe") ? base.slice(0, -4) : base;
|
|
2396
|
+
}
|
|
2397
|
+
var LEGACY_FILESYSTEM_WRITE_RE = /(^|[;&|\n])\s*(cp|mv|mkdir|touch|tee|sed|perl)\b/;
|
|
2398
|
+
var FILESYSTEM_WRITE_COMMANDS = /* @__PURE__ */ new Set(["cp", "mv", "mkdir", "touch", "tee", "sed", "perl"]);
|
|
2399
|
+
var SHELL_CONTROL_PREFIXES = /* @__PURE__ */ new Set(["!", "if", "then", "elif", "else", "do", "while", "until", "coproc", "{"]);
|
|
2400
|
+
var WRITE_WRAPPER_NAMES = /* @__PURE__ */ new Set(["env", "command", "exec", "nohup", "setsid", "time", "nice", "timeout", "xargs", "builtin"]);
|
|
2401
|
+
var WRITE_WRAPPER_VALUE_FLAGS = {
|
|
2402
|
+
env: /* @__PURE__ */ new Set(["-u", "--unset", "-C", "--chdir"]),
|
|
2403
|
+
exec: /* @__PURE__ */ new Set(["-a"]),
|
|
2404
|
+
time: /* @__PURE__ */ new Set(["-o", "-f", "--output", "--format"]),
|
|
2405
|
+
nice: /* @__PURE__ */ new Set(["-n", "--adjustment"]),
|
|
2406
|
+
timeout: /* @__PURE__ */ new Set(["-k", "--kill-after", "-s", "--signal"]),
|
|
2407
|
+
xargs: /* @__PURE__ */ new Set(["-a", "-d", "-E", "-I", "-L", "-n", "-P", "-s", "--arg-file", "--delimiter", "--eof", "--replace", "--max-lines", "--max-args", "--max-procs", "--max-chars"])
|
|
2408
|
+
};
|
|
2409
|
+
var STANDALONE_REDIR_RE = /^(?:\d+)?(?:>>?|<<?|<>|>&|<&|&>>?)$/;
|
|
2410
|
+
var INLINE_REDIR_RE = /^(?:\d+)?(?:>>?|<<?|<>|>&|<&|&>>?).+$/;
|
|
2411
|
+
function tokenizeCommandSegments(command, shell) {
|
|
2412
|
+
const escapeChar = shell === "powershell" ? "`" : "\\";
|
|
2413
|
+
const segments = [];
|
|
2414
|
+
const backtickBodies = [];
|
|
2415
|
+
const stack = [
|
|
2416
|
+
{ words: [], current: "", kind: "root", caseDepth: 0 }
|
|
2417
|
+
];
|
|
2418
|
+
const flushWord = () => {
|
|
2419
|
+
const top = stack[stack.length - 1];
|
|
2420
|
+
if (top.current) {
|
|
2421
|
+
if (top.words.length === 0) {
|
|
2422
|
+
const lower = top.current.toLowerCase();
|
|
2423
|
+
if (lower === "case") top.caseDepth += 1;
|
|
2424
|
+
else if (lower === "esac" && top.caseDepth > 0) top.caseDepth -= 1;
|
|
2425
|
+
}
|
|
2426
|
+
top.words.push(top.current);
|
|
2427
|
+
top.current = "";
|
|
2428
|
+
}
|
|
2429
|
+
};
|
|
2430
|
+
const flushSegment = () => {
|
|
2431
|
+
flushWord();
|
|
2432
|
+
const top = stack[stack.length - 1];
|
|
2433
|
+
if (top.words.length > 0) {
|
|
2434
|
+
segments.push(top.words);
|
|
2435
|
+
top.words = [];
|
|
2436
|
+
}
|
|
2437
|
+
};
|
|
2438
|
+
const readBacktickBody = (startIndex) => {
|
|
2439
|
+
let body = "";
|
|
2440
|
+
let i = startIndex + 1;
|
|
2441
|
+
for (; i < command.length; i += 1) {
|
|
2442
|
+
const c = command[i];
|
|
2443
|
+
if (c === "\\" && i + 1 < command.length) {
|
|
2444
|
+
const next = command[i + 1];
|
|
2445
|
+
if (next === "\n") {
|
|
2446
|
+
i += 1;
|
|
2447
|
+
continue;
|
|
2448
|
+
}
|
|
2449
|
+
if (next === "`" || next === "$" || next === "\\") {
|
|
2450
|
+
body += next;
|
|
2451
|
+
i += 1;
|
|
2452
|
+
continue;
|
|
2453
|
+
}
|
|
2454
|
+
body += c + next;
|
|
2455
|
+
i += 1;
|
|
2456
|
+
continue;
|
|
2457
|
+
}
|
|
2458
|
+
if (c === "`") break;
|
|
2459
|
+
body += c;
|
|
2460
|
+
}
|
|
2461
|
+
if (body) backtickBodies.push(body);
|
|
2462
|
+
return i;
|
|
2463
|
+
};
|
|
2464
|
+
for (let i = 0; i < command.length; i += 1) {
|
|
2465
|
+
const top = stack[stack.length - 1];
|
|
2466
|
+
const ch = command[i];
|
|
2467
|
+
if (top.quote === "'") {
|
|
2468
|
+
if (ch === "'") top.quote = void 0;
|
|
2469
|
+
else top.current += ch;
|
|
2470
|
+
continue;
|
|
2471
|
+
}
|
|
2472
|
+
if (top.quote === '"') {
|
|
2473
|
+
if (ch === escapeChar && i + 1 < command.length) {
|
|
2474
|
+
if (shell === "bash" && command[i + 1] === "\n") {
|
|
2475
|
+
i += 1;
|
|
2476
|
+
continue;
|
|
2477
|
+
}
|
|
2478
|
+
top.current += command[i + 1];
|
|
2479
|
+
i += 1;
|
|
2480
|
+
continue;
|
|
2481
|
+
}
|
|
2482
|
+
if (ch === '"') {
|
|
2483
|
+
top.quote = void 0;
|
|
2484
|
+
continue;
|
|
2485
|
+
}
|
|
2486
|
+
if (shell === "bash" && ch === "$" && command[i + 1] === "(") {
|
|
2487
|
+
stack.push({ words: [], current: "", kind: "paren", caseDepth: 0 });
|
|
2488
|
+
i += 1;
|
|
2489
|
+
continue;
|
|
2490
|
+
}
|
|
2491
|
+
if (shell === "bash" && ch === "`") {
|
|
2492
|
+
i = readBacktickBody(i);
|
|
2493
|
+
continue;
|
|
2494
|
+
}
|
|
2495
|
+
top.current += ch;
|
|
2496
|
+
continue;
|
|
2497
|
+
}
|
|
2498
|
+
if (ch === escapeChar && i + 1 < command.length) {
|
|
2499
|
+
if (shell === "bash" && command[i + 1] === "\n") {
|
|
2500
|
+
i += 1;
|
|
2501
|
+
continue;
|
|
2502
|
+
}
|
|
2503
|
+
top.current += command[i + 1];
|
|
2504
|
+
i += 1;
|
|
2505
|
+
continue;
|
|
2506
|
+
}
|
|
2507
|
+
if (ch === "'" || ch === '"') {
|
|
2508
|
+
top.quote = ch;
|
|
2509
|
+
continue;
|
|
2510
|
+
}
|
|
2511
|
+
if (shell === "bash" && ch === "`") {
|
|
2512
|
+
flushWord();
|
|
2513
|
+
i = readBacktickBody(i);
|
|
2514
|
+
continue;
|
|
2515
|
+
}
|
|
2516
|
+
if (shell !== "cmd" && ((ch === "$" || ch === "<" || ch === ">") && command[i + 1] === "(")) {
|
|
2517
|
+
flushWord();
|
|
2518
|
+
stack.push({ words: [], current: "", kind: "paren", caseDepth: 0 });
|
|
2519
|
+
i += 1;
|
|
2520
|
+
continue;
|
|
2521
|
+
}
|
|
2522
|
+
if (shell !== "cmd" && ch === "(") {
|
|
2523
|
+
flushWord();
|
|
2524
|
+
stack.push({ words: [], current: "", kind: "paren", caseDepth: 0 });
|
|
2525
|
+
continue;
|
|
2526
|
+
}
|
|
2527
|
+
if (shell !== "cmd" && ch === ")") {
|
|
2528
|
+
flushSegment();
|
|
2529
|
+
if (top.caseDepth === 0 && top.kind === "paren") {
|
|
2530
|
+
stack.pop();
|
|
2531
|
+
if (stack.length > 0 && stack[stack.length - 1].caseDepth > 0) {
|
|
2532
|
+
flushSegment();
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
continue;
|
|
2536
|
+
}
|
|
2537
|
+
if (ch === ";" || ch === "\n" || ch === "|") {
|
|
2538
|
+
if (ch === "|" && command[i + 1] === "|") i += 1;
|
|
2539
|
+
flushSegment();
|
|
2540
|
+
continue;
|
|
2541
|
+
}
|
|
2542
|
+
if (ch === "&") {
|
|
2543
|
+
const prev = top.current[top.current.length - 1];
|
|
2544
|
+
if (prev === ">" || prev === "<" || command[i + 1] === ">") {
|
|
2545
|
+
top.current += ch;
|
|
2546
|
+
continue;
|
|
2547
|
+
}
|
|
2548
|
+
if (command[i + 1] === "&") i += 1;
|
|
2549
|
+
flushSegment();
|
|
2550
|
+
continue;
|
|
2551
|
+
}
|
|
2552
|
+
if (/\s/.test(ch)) {
|
|
2553
|
+
flushWord();
|
|
2554
|
+
continue;
|
|
2555
|
+
}
|
|
2556
|
+
top.current += ch;
|
|
2557
|
+
}
|
|
2558
|
+
while (stack.length > 0) {
|
|
2559
|
+
flushSegment();
|
|
2560
|
+
stack.pop();
|
|
2561
|
+
}
|
|
2562
|
+
return { segments, backtickBodies };
|
|
2563
|
+
}
|
|
2564
|
+
function splitEnvSplitString(payload) {
|
|
2565
|
+
const normalized = payload.replace(/\\_/g, " ");
|
|
2566
|
+
const { segments } = tokenizeCommandSegments(normalized, "bash");
|
|
2567
|
+
return segments.flat();
|
|
2568
|
+
}
|
|
2569
|
+
function segmentHasFilesystemWrite(words, shell, depth = 0) {
|
|
2570
|
+
let index = 0;
|
|
2571
|
+
while (index < words.length) {
|
|
2572
|
+
const word = words[index];
|
|
2573
|
+
const lower = word.toLowerCase();
|
|
2574
|
+
if (SHELL_CONTROL_PREFIXES.has(lower) || shell === "powershell" && (word === "." || word === "&")) {
|
|
2575
|
+
index += 1;
|
|
2576
|
+
continue;
|
|
2577
|
+
}
|
|
2578
|
+
if (STANDALONE_REDIR_RE.test(word)) {
|
|
2579
|
+
index += 2;
|
|
2580
|
+
continue;
|
|
2581
|
+
}
|
|
2582
|
+
if (INLINE_REDIR_RE.test(word) || /^[A-Za-z_][A-Za-z0-9_]*=/.test(word)) {
|
|
2583
|
+
index += 1;
|
|
2584
|
+
continue;
|
|
2585
|
+
}
|
|
2586
|
+
const program = executableName(word);
|
|
2587
|
+
if (FILESYSTEM_WRITE_COMMANDS.has(program)) return true;
|
|
2588
|
+
if (program === "eval") {
|
|
2589
|
+
if (depth >= 2) return true;
|
|
2590
|
+
return hasFilesystemWriteCommand(words.slice(index + 1).join(" "), shell, depth + 1);
|
|
2591
|
+
}
|
|
2592
|
+
if (WRITE_WRAPPER_NAMES.has(program)) {
|
|
2593
|
+
const valueFlags = WRITE_WRAPPER_VALUE_FLAGS[program];
|
|
2594
|
+
index += 1;
|
|
2595
|
+
while (index < words.length) {
|
|
2596
|
+
const arg = words[index];
|
|
2597
|
+
if (arg === "--") {
|
|
2598
|
+
index += 1;
|
|
2599
|
+
break;
|
|
2600
|
+
}
|
|
2601
|
+
if (program === "env") {
|
|
2602
|
+
if (arg === "-S" || arg === "--split-string" || arg.startsWith("-S") || arg.startsWith("--split-string=")) {
|
|
2603
|
+
const separate = arg === "-S" || arg === "--split-string";
|
|
2604
|
+
const splitPayload = separate ? words[index + 1] : arg.startsWith("-S") ? arg.slice(2) : arg.slice("--split-string=".length);
|
|
2605
|
+
if (!splitPayload || depth >= 2) return true;
|
|
2606
|
+
const nextIndex = separate ? index + 2 : index + 1;
|
|
2607
|
+
const expanded = [...splitEnvSplitString(splitPayload), ...words.slice(nextIndex)];
|
|
2608
|
+
return segmentHasFilesystemWrite(expanded, shell, depth + 1) || hasFilesystemWriteCommand(splitPayload.replace(/\\_/g, " "), shell, depth + 1);
|
|
2609
|
+
}
|
|
2610
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*=/.test(arg)) {
|
|
2611
|
+
index += 1;
|
|
2612
|
+
continue;
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
if (valueFlags?.has(arg)) {
|
|
2616
|
+
index += 2;
|
|
2617
|
+
continue;
|
|
2618
|
+
}
|
|
2619
|
+
if (arg.startsWith("-")) {
|
|
2620
|
+
index += 1;
|
|
2621
|
+
continue;
|
|
2622
|
+
}
|
|
2623
|
+
break;
|
|
2624
|
+
}
|
|
2625
|
+
if (program === "timeout") index += 1;
|
|
2626
|
+
continue;
|
|
2627
|
+
}
|
|
2628
|
+
return false;
|
|
2629
|
+
}
|
|
2630
|
+
return false;
|
|
2631
|
+
}
|
|
2632
|
+
function hasFilesystemWriteCommand(command, shell, depth = 0) {
|
|
2633
|
+
const { segments, backtickBodies } = tokenizeCommandSegments(command, shell);
|
|
2634
|
+
for (const words of segments) {
|
|
2635
|
+
if (segmentHasFilesystemWrite(words, shell, depth)) return true;
|
|
2636
|
+
}
|
|
2637
|
+
for (const body of backtickBodies) {
|
|
2638
|
+
if (depth >= 4) return true;
|
|
2639
|
+
if (hasFilesystemWriteCommand(body, shell, depth + 1)) return true;
|
|
2640
|
+
}
|
|
2641
|
+
return false;
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2391
2644
|
// ../../packages/shared-headless-capabilities/src/bash-policy.ts
|
|
2392
2645
|
var DESTRUCTIVE_PATTERNS = [
|
|
2393
2646
|
{ pattern: /\bgit\s+reset\s+--hard\b/, warning: "may discard uncommitted changes", commandClass: "git_destructive" },
|
|
@@ -2669,10 +2922,171 @@ function resolveStaticCwdTarget(target, cwd, root) {
|
|
|
2669
2922
|
return resolved;
|
|
2670
2923
|
}
|
|
2671
2924
|
var DYNAMIC_EXECUTION_WARNING = "may execute nested shell or interpreter code";
|
|
2672
|
-
function
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2925
|
+
function stripBashComments(command) {
|
|
2926
|
+
let hasUnquotedHeredoc = false;
|
|
2927
|
+
{
|
|
2928
|
+
let q;
|
|
2929
|
+
for (let i = 0; i < command.length; i += 1) {
|
|
2930
|
+
const c = command[i];
|
|
2931
|
+
if (q) {
|
|
2932
|
+
if (q === '"' && c === "\\" && i + 1 < command.length) {
|
|
2933
|
+
i += 1;
|
|
2934
|
+
continue;
|
|
2935
|
+
}
|
|
2936
|
+
if (c === q) q = void 0;
|
|
2937
|
+
continue;
|
|
2938
|
+
}
|
|
2939
|
+
if (c === "'" || c === '"') {
|
|
2940
|
+
q = c;
|
|
2941
|
+
continue;
|
|
2942
|
+
}
|
|
2943
|
+
if (c === "\\" && i + 1 < command.length) {
|
|
2944
|
+
i += 1;
|
|
2945
|
+
continue;
|
|
2946
|
+
}
|
|
2947
|
+
if (c === "<" && command[i + 1] === "<") {
|
|
2948
|
+
if (command[i + 2] === "<") {
|
|
2949
|
+
i += 2;
|
|
2950
|
+
continue;
|
|
2951
|
+
}
|
|
2952
|
+
hasUnquotedHeredoc = true;
|
|
2953
|
+
break;
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
if (hasUnquotedHeredoc) return command;
|
|
2958
|
+
let result = "";
|
|
2959
|
+
let quote;
|
|
2960
|
+
let inWord = false;
|
|
2961
|
+
let inBacktick = false;
|
|
2962
|
+
let paramExpansionDepth = 0;
|
|
2963
|
+
let cmdSubDepth = 0;
|
|
2964
|
+
for (let index = 0; index < command.length; index += 1) {
|
|
2965
|
+
const char = command[index];
|
|
2966
|
+
if (quote) {
|
|
2967
|
+
result += char;
|
|
2968
|
+
if (quote === '"' && char === "\\" && index + 1 < command.length) {
|
|
2969
|
+
result += command[index + 1];
|
|
2970
|
+
index += 1;
|
|
2971
|
+
continue;
|
|
2972
|
+
}
|
|
2973
|
+
if (char === quote) quote = void 0;
|
|
2974
|
+
continue;
|
|
2975
|
+
}
|
|
2976
|
+
if (char === "'" || char === '"') {
|
|
2977
|
+
quote = char;
|
|
2978
|
+
inWord = true;
|
|
2979
|
+
result += char;
|
|
2980
|
+
continue;
|
|
2981
|
+
}
|
|
2982
|
+
if (char === "\\" && index + 1 < command.length) {
|
|
2983
|
+
const next = command[index + 1];
|
|
2984
|
+
if (next !== "\n") inWord = true;
|
|
2985
|
+
result += char;
|
|
2986
|
+
result += next;
|
|
2987
|
+
index += 1;
|
|
2988
|
+
continue;
|
|
2989
|
+
}
|
|
2990
|
+
if (char === "`") {
|
|
2991
|
+
inBacktick = !inBacktick;
|
|
2992
|
+
inWord = true;
|
|
2993
|
+
result += char;
|
|
2994
|
+
continue;
|
|
2995
|
+
}
|
|
2996
|
+
if (char === "$" && command[index + 1] === "{") {
|
|
2997
|
+
paramExpansionDepth += 1;
|
|
2998
|
+
inWord = true;
|
|
2999
|
+
result += "${";
|
|
3000
|
+
index += 1;
|
|
3001
|
+
continue;
|
|
3002
|
+
}
|
|
3003
|
+
if (char === "$" && command[index + 1] === "(") {
|
|
3004
|
+
cmdSubDepth += 1;
|
|
3005
|
+
inWord = true;
|
|
3006
|
+
result += "$(";
|
|
3007
|
+
index += 1;
|
|
3008
|
+
continue;
|
|
3009
|
+
}
|
|
3010
|
+
if (char === "{" && paramExpansionDepth > 0) {
|
|
3011
|
+
paramExpansionDepth += 1;
|
|
3012
|
+
inWord = true;
|
|
3013
|
+
result += char;
|
|
3014
|
+
continue;
|
|
3015
|
+
}
|
|
3016
|
+
if (char === "(" && cmdSubDepth > 0) {
|
|
3017
|
+
cmdSubDepth += 1;
|
|
3018
|
+
inWord = true;
|
|
3019
|
+
result += char;
|
|
3020
|
+
continue;
|
|
3021
|
+
}
|
|
3022
|
+
if (char === "}" && paramExpansionDepth > 0) {
|
|
3023
|
+
paramExpansionDepth -= 1;
|
|
3024
|
+
inWord = true;
|
|
3025
|
+
result += char;
|
|
3026
|
+
continue;
|
|
3027
|
+
}
|
|
3028
|
+
if (char === ")" && cmdSubDepth > 0) {
|
|
3029
|
+
cmdSubDepth -= 1;
|
|
3030
|
+
inWord = true;
|
|
3031
|
+
result += char;
|
|
3032
|
+
continue;
|
|
3033
|
+
}
|
|
3034
|
+
if (char === "#" && !inWord && !inBacktick && paramExpansionDepth === 0 && cmdSubDepth === 0) {
|
|
3035
|
+
while (index < command.length && command[index] !== "\n") {
|
|
3036
|
+
index += 1;
|
|
3037
|
+
}
|
|
3038
|
+
if (index < command.length && command[index] === "\n") {
|
|
3039
|
+
result += "\n";
|
|
3040
|
+
inWord = false;
|
|
3041
|
+
}
|
|
3042
|
+
continue;
|
|
3043
|
+
}
|
|
3044
|
+
if (/[\s;&|()]/.test(char)) {
|
|
3045
|
+
inWord = false;
|
|
3046
|
+
} else {
|
|
3047
|
+
inWord = true;
|
|
3048
|
+
}
|
|
3049
|
+
result += char;
|
|
3050
|
+
}
|
|
3051
|
+
if (quote || inBacktick || paramExpansionDepth > 0 || cmdSubDepth > 0) {
|
|
3052
|
+
return command;
|
|
3053
|
+
}
|
|
3054
|
+
return result;
|
|
3055
|
+
}
|
|
3056
|
+
var SAFE_PYTHON_TEST_MODULES = /* @__PURE__ */ new Set(["pytest", "unittest"]);
|
|
3057
|
+
var PYTHON_VALUE_OPTIONS = /* @__PURE__ */ new Set(["-W", "-X", "--check-hash-based-pycs"]);
|
|
3058
|
+
var PYTHON_SAFE_BOOL_FLAGS_RE = /^-[BEIOPqSsuv]+$/;
|
|
3059
|
+
function isPythonExecutable(program) {
|
|
3060
|
+
return /^python(?:\d+(?:\.\d+)?)?$/.test(program);
|
|
3061
|
+
}
|
|
3062
|
+
function hasDynamicPythonInvocation(args) {
|
|
3063
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
3064
|
+
const word = args[index];
|
|
3065
|
+
if (word === "--") return false;
|
|
3066
|
+
if (/^-[ce]/i.test(word)) return true;
|
|
3067
|
+
if (/^-m$/i.test(word)) {
|
|
3068
|
+
const mod = args[index + 1]?.toLowerCase();
|
|
3069
|
+
return !(mod && SAFE_PYTHON_TEST_MODULES.has(mod));
|
|
3070
|
+
}
|
|
3071
|
+
if (/^-m.+$/i.test(word)) {
|
|
3072
|
+
const mod = word.slice(2).toLowerCase();
|
|
3073
|
+
return !SAFE_PYTHON_TEST_MODULES.has(mod);
|
|
3074
|
+
}
|
|
3075
|
+
if (PYTHON_VALUE_OPTIONS.has(word)) {
|
|
3076
|
+
if (index + 1 >= args.length) return true;
|
|
3077
|
+
index += 1;
|
|
3078
|
+
continue;
|
|
3079
|
+
}
|
|
3080
|
+
if (/^(?:-W|-X|--check-hash-based-pycs=)/i.test(word)) {
|
|
3081
|
+
continue;
|
|
3082
|
+
}
|
|
3083
|
+
if (PYTHON_SAFE_BOOL_FLAGS_RE.test(word)) {
|
|
3084
|
+
continue;
|
|
3085
|
+
}
|
|
3086
|
+
if (word.startsWith("-")) return true;
|
|
3087
|
+
return false;
|
|
3088
|
+
}
|
|
3089
|
+
return false;
|
|
2676
3090
|
}
|
|
2677
3091
|
function hasDynamicExecutionInvocation(words) {
|
|
2678
3092
|
if (words.length === 0) return false;
|
|
@@ -2691,7 +3105,10 @@ function hasDynamicExecutionInvocation(words) {
|
|
|
2691
3105
|
if (program === "cmd") {
|
|
2692
3106
|
return words.slice(1).some((word) => /^\/(?:c|k)$/i.test(word));
|
|
2693
3107
|
}
|
|
2694
|
-
if (
|
|
3108
|
+
if (isPythonExecutable(program)) {
|
|
3109
|
+
return hasDynamicPythonInvocation(words.slice(1));
|
|
3110
|
+
}
|
|
3111
|
+
if (["perl", "ruby"].includes(program)) {
|
|
2695
3112
|
return words.slice(1).some((word) => /^(?:-c|-e|-m)$/i.test(word));
|
|
2696
3113
|
}
|
|
2697
3114
|
if (program === "node") {
|
|
@@ -2755,13 +3172,14 @@ function isStaticallyScopedRecursiveForceRemove(command, options) {
|
|
|
2755
3172
|
return sawRm;
|
|
2756
3173
|
}
|
|
2757
3174
|
function classifyShellCommand(command, shell = "bash", options) {
|
|
3175
|
+
const inspectedCommand = shell === "bash" ? stripBashComments(command) : command;
|
|
2758
3176
|
const warnings = [];
|
|
2759
3177
|
let commandClass = "unknown_shell";
|
|
2760
3178
|
let destructive = false;
|
|
2761
3179
|
const destructivePatterns = shell === "cmd" ? [...CMD_DESTRUCTIVE_PATTERNS, ...DESTRUCTIVE_PATTERNS] : DESTRUCTIVE_PATTERNS;
|
|
2762
|
-
const removeWarnings = recursiveRemoveWarnings(
|
|
3180
|
+
const removeWarnings = recursiveRemoveWarnings(inspectedCommand);
|
|
2763
3181
|
if (removeWarnings.length > 0) {
|
|
2764
|
-
if (shell === "bash" && isStaticallyScopedRecursiveForceRemove(
|
|
3182
|
+
if (shell === "bash" && isStaticallyScopedRecursiveForceRemove(inspectedCommand, options)) {
|
|
2765
3183
|
commandClass = "filesystem_write";
|
|
2766
3184
|
} else {
|
|
2767
3185
|
warnings.push(...removeWarnings);
|
|
@@ -2769,7 +3187,7 @@ function classifyShellCommand(command, shell = "bash", options) {
|
|
|
2769
3187
|
destructive = true;
|
|
2770
3188
|
}
|
|
2771
3189
|
}
|
|
2772
|
-
const dynamicWarnings = dynamicExecutionWarnings(
|
|
3190
|
+
const dynamicWarnings = dynamicExecutionWarnings(inspectedCommand);
|
|
2773
3191
|
if (dynamicWarnings.length > 0) {
|
|
2774
3192
|
warnings.push(...dynamicWarnings);
|
|
2775
3193
|
commandClass = "unknown_shell";
|
|
@@ -2807,7 +3225,7 @@ function classifyShellCommand(command, shell = "bash", options) {
|
|
|
2807
3225
|
}
|
|
2808
3226
|
}
|
|
2809
3227
|
for (const entry of destructivePatterns) {
|
|
2810
|
-
if (entry.pattern.test(
|
|
3228
|
+
if (entry.pattern.test(inspectedCommand)) {
|
|
2811
3229
|
warnings.push(entry.warning);
|
|
2812
3230
|
commandClass = entry.commandClass;
|
|
2813
3231
|
destructive = true;
|
|
@@ -2816,7 +3234,7 @@ function classifyShellCommand(command, shell = "bash", options) {
|
|
|
2816
3234
|
if (destructive) {
|
|
2817
3235
|
return { commandClass, riskWarnings: [...new Set(warnings)], destructive, requiresPermission: true };
|
|
2818
3236
|
}
|
|
2819
|
-
const normalized =
|
|
3237
|
+
const normalized = inspectedCommand.trim().toLowerCase();
|
|
2820
3238
|
const words = splitCommand(normalized).map(firstWord);
|
|
2821
3239
|
const primary = words[0] || firstWord(normalized);
|
|
2822
3240
|
if (shell === "powershell" && /\b(invoke-webrequest|iwr|invoke-restmethod|irm)\b/.test(normalized)) {
|
|
@@ -2827,12 +3245,12 @@ function classifyShellCommand(command, shell = "bash", options) {
|
|
|
2827
3245
|
commandClass = "filesystem_write";
|
|
2828
3246
|
} else if (/\b(npm|pnpm|yarn|bun)\s+(install|add|remove|update|ci)\b/.test(normalized)) {
|
|
2829
3247
|
commandClass = "package_manager";
|
|
2830
|
-
} else if (/\b(
|
|
2831
|
-
commandClass = "test_or_build";
|
|
2832
|
-
} else if (/\b(curl|wget|http|npx|pip|gem|brew)\b/.test(normalized)) {
|
|
3248
|
+
} else if (/\b(curl|wget|http|npx|pip3?|gem|brew)\b/.test(normalized)) {
|
|
2833
3249
|
commandClass = "network";
|
|
2834
|
-
} else if (
|
|
3250
|
+
} else if (commandClass === "filesystem_write" || LEGACY_FILESYSTEM_WRITE_RE.test(normalized) || hasFilesystemWriteCommand(inspectedCommand, shell)) {
|
|
2835
3251
|
commandClass = "filesystem_write";
|
|
3252
|
+
} else if (/\b(npm|pnpm|yarn|bun|cargo|go|mvn|gradle|pytest|python -m pytest)\s+(run\s+)?(test|build|check|lint|typecheck|verify)\b/.test(normalized) || /(?:^|[;&|\n])\s*(?:[^\s;|&]*\/)?python(?:\d+(?:\.\d+)?)?\s+-m\s*(?:pytest|unittest)\b/.test(normalized) || /(?:^|[;&|\n])\s*(?:[^\s;|&]*\/)?pytest\b/.test(normalized)) {
|
|
3253
|
+
commandClass = "test_or_build";
|
|
2836
3254
|
} else if (["ls", "pwd", "cat", "head", "tail", "grep", "rg", "find", "wc", "git", "diff", "test", "["].includes(primary)) {
|
|
2837
3255
|
commandClass = "diagnostic_read";
|
|
2838
3256
|
}
|
|
@@ -5,7 +5,7 @@ import "./chunk-LZQXQOPJ.js";
|
|
|
5
5
|
import * as os from "node:os";
|
|
6
6
|
async function describeImageViaUnderstandingChain(options) {
|
|
7
7
|
try {
|
|
8
|
-
const { understandReadFile } = await import("./read-file-understanding-
|
|
8
|
+
const { understandReadFile } = await import("./read-file-understanding-GTNZHAK5.js");
|
|
9
9
|
const ext = options.filePath.toLowerCase().split(".").pop() ?? "";
|
|
10
10
|
const mimeType = ext === "png" ? "image/png" : ext === "gif" ? "image/gif" : ext === "webp" ? "image/webp" : "image/jpeg";
|
|
11
11
|
const result = await understandReadFile(
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
ensureMemoryGitIgnore,
|
|
5
5
|
isMemoryGitInitialized,
|
|
6
6
|
readCuratedMemoryGitLog
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-DJ4LO7PQ.js";
|
|
8
|
+
import "./chunk-X3ZVZB2R.js";
|
|
9
|
+
import "./chunk-SYZR74QO.js";
|
|
10
|
+
import "./chunk-SAXKBFX3.js";
|
|
11
|
+
import "./chunk-IM7DLPPY.js";
|
|
12
12
|
import "./chunk-XXGYUYXI.js";
|
|
13
13
|
import "./chunk-LZQXQOPJ.js";
|
|
14
14
|
export {
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
validateModelsDocumentShape,
|
|
9
9
|
validateProfileConfig,
|
|
10
10
|
validatedRemoteCatalogs
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-TTSQWGAT.js";
|
|
12
12
|
import "./chunk-CBDQJMUI.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-IM7DLPPY.js";
|
|
14
14
|
import "./chunk-XXGYUYXI.js";
|
|
15
15
|
import "./chunk-LZQXQOPJ.js";
|
|
16
16
|
export {
|
package/dist/chunks/{read-file-understanding-DFJPTTSB.js → read-file-understanding-GTNZHAK5.js}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
understandReadFile
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-TNRZEQD5.js";
|
|
5
5
|
import "./chunk-F7EBZTZO.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-X3ZVZB2R.js";
|
|
7
|
+
import "./chunk-SYZR74QO.js";
|
|
8
|
+
import "./chunk-SAXKBFX3.js";
|
|
9
|
+
import "./chunk-IM7DLPPY.js";
|
|
10
10
|
import "./chunk-XXGYUYXI.js";
|
|
11
11
|
import "./chunk-LZQXQOPJ.js";
|
|
12
12
|
export {
|
|
@@ -146,9 +146,9 @@ import {
|
|
|
146
146
|
substituteArgs,
|
|
147
147
|
validateRetainedTailEntries,
|
|
148
148
|
verifyPreparedCompactionCommit
|
|
149
|
-
} from "./chunk-
|
|
150
|
-
import "./chunk-
|
|
151
|
-
import "./chunk-
|
|
149
|
+
} from "./chunk-SYZR74QO.js";
|
|
150
|
+
import "./chunk-SAXKBFX3.js";
|
|
151
|
+
import "./chunk-IM7DLPPY.js";
|
|
152
152
|
import "./chunk-XXGYUYXI.js";
|
|
153
153
|
import "./chunk-LZQXQOPJ.js";
|
|
154
154
|
export {
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
createToolCallerIdentity,
|
|
9
9
|
getAgentFailureMetadata,
|
|
10
10
|
getToolCallerIdentity
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-SAXKBFX3.js";
|
|
12
|
+
import "./chunk-IM7DLPPY.js";
|
|
13
13
|
import "./chunk-XXGYUYXI.js";
|
|
14
14
|
import "./chunk-LZQXQOPJ.js";
|
|
15
15
|
export {
|
|
@@ -230,12 +230,12 @@ import {
|
|
|
230
230
|
validateWikiPageContent,
|
|
231
231
|
wikiInboxItemToDreamSignal,
|
|
232
232
|
wikiInboxPath
|
|
233
|
-
} from "./chunk-
|
|
234
|
-
import "./chunk-
|
|
235
|
-
import "./chunk-
|
|
233
|
+
} from "./chunk-X3ZVZB2R.js";
|
|
234
|
+
import "./chunk-SYZR74QO.js";
|
|
235
|
+
import "./chunk-SAXKBFX3.js";
|
|
236
236
|
import {
|
|
237
237
|
hashText
|
|
238
|
-
} from "./chunk-
|
|
238
|
+
} from "./chunk-IM7DLPPY.js";
|
|
239
239
|
import "./chunk-XXGYUYXI.js";
|
|
240
240
|
import "./chunk-LZQXQOPJ.js";
|
|
241
241
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
EventStream
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IM7DLPPY.js";
|
|
5
5
|
import "./chunk-XXGYUYXI.js";
|
|
6
6
|
import "./chunk-LZQXQOPJ.js";
|
|
7
7
|
|