@wudao-org/core 0.4.20 → 0.5.0
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 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/agents/aimd.js +1 -1
- package/dist/agents/aimd.js.map +1 -1
- package/dist/agents/mail.d.ts.map +1 -1
- package/dist/agents/mail.js +4 -0
- package/dist/agents/mail.js.map +1 -1
- package/dist/agents/registry.d.ts +2 -2
- package/dist/agents/registry.d.ts.map +1 -1
- package/dist/agents/roster.js +1 -1
- package/dist/agents/roster.js.map +1 -1
- package/dist/agents/steer.d.ts.map +1 -1
- package/dist/agents/steer.js +4 -0
- package/dist/agents/steer.js.map +1 -1
- package/dist/compaction-economics.d.ts +5 -5
- package/dist/compaction-economics.d.ts.map +1 -1
- package/dist/compaction-economics.js +8 -8
- package/dist/compaction-economics.js.map +1 -1
- package/dist/compaction-markers.d.ts +5 -0
- package/dist/compaction-markers.d.ts.map +1 -1
- package/dist/compaction-markers.js.map +1 -1
- package/dist/compaction-plan.d.ts +28 -0
- package/dist/compaction-plan.d.ts.map +1 -0
- package/dist/compaction-plan.js +85 -0
- package/dist/compaction-plan.js.map +1 -0
- package/dist/compaction-summarizer.d.ts +13 -0
- package/dist/compaction-summarizer.d.ts.map +1 -1
- package/dist/compaction-summarizer.js +56 -1
- package/dist/compaction-summarizer.js.map +1 -1
- package/dist/compaction-tier2-static.d.ts +18 -1
- package/dist/compaction-tier2-static.d.ts.map +1 -1
- package/dist/compaction-tier2-static.js +34 -12
- package/dist/compaction-tier2-static.js.map +1 -1
- package/dist/compaction-tiers.d.ts.map +1 -1
- package/dist/compaction-tiers.js +6 -1
- package/dist/compaction-tiers.js.map +1 -1
- package/dist/compaction.d.ts.map +1 -1
- package/dist/compaction.js +25 -4
- package/dist/compaction.js.map +1 -1
- package/dist/goal-state.d.ts +1 -1
- package/dist/goal-state.js +1 -1
- package/dist/goal-state.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/loop-safety.js +1 -1
- package/dist/loop-safety.js.map +1 -1
- package/dist/loop.d.ts +4 -3
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +75 -6
- package/dist/loop.js.map +1 -1
- package/dist/model-client.d.ts +2 -2
- package/dist/model-client.js +1 -1
- package/dist/model-client.js.map +1 -1
- package/dist/runner.js +1 -1
- package/dist/runner.js.map +1 -1
- package/dist/todo-generator.d.ts +3 -3
- package/dist/todo-generator.d.ts.map +1 -1
- package/dist/todo-generator.js +1 -1
- package/dist/tool-prompt.d.ts +14 -0
- package/dist/tool-prompt.d.ts.map +1 -0
- package/dist/tool-prompt.js +60 -0
- package/dist/tool-prompt.js.map +1 -0
- package/dist/tool.d.ts +25 -0
- package/dist/tool.d.ts.map +1 -1
- package/dist/tool.js +15 -0
- package/dist/tool.js.map +1 -1
- package/dist/tools/ask-user.d.ts.map +1 -1
- package/dist/tools/ask-user.js +5 -0
- package/dist/tools/ask-user.js.map +1 -1
- package/dist/tools/context-remaining.d.ts.map +1 -1
- package/dist/tools/context-remaining.js +4 -0
- package/dist/tools/context-remaining.js.map +1 -1
- package/dist/tools/continue-task.d.ts.map +1 -1
- package/dist/tools/continue-task.js +4 -0
- package/dist/tools/continue-task.js.map +1 -1
- package/dist/tools/critic-review.d.ts.map +1 -1
- package/dist/tools/critic-review.js +5 -0
- package/dist/tools/critic-review.js.map +1 -1
- package/dist/tools/ctx-inspect.d.ts.map +1 -1
- package/dist/tools/ctx-inspect.js +4 -0
- package/dist/tools/ctx-inspect.js.map +1 -1
- package/dist/tools/edit.d.ts.map +1 -1
- package/dist/tools/edit.js +4 -0
- package/dist/tools/edit.js.map +1 -1
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +1 -0
- package/dist/tools/glob.js.map +1 -1
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +1 -0
- package/dist/tools/grep.js.map +1 -1
- package/dist/tools/log-slimming.d.ts +2 -2
- package/dist/tools/log-slimming.d.ts.map +1 -1
- package/dist/tools/log-slimming.js +4 -4
- package/dist/tools/log-slimming.js.map +1 -1
- package/dist/tools/monitor.d.ts.map +1 -1
- package/dist/tools/monitor.js +11 -0
- package/dist/tools/monitor.js.map +1 -1
- package/dist/tools/new-context.d.ts.map +1 -1
- package/dist/tools/new-context.js +5 -0
- package/dist/tools/new-context.js.map +1 -1
- package/dist/tools/notebook.d.ts.map +1 -1
- package/dist/tools/notebook.js +1 -0
- package/dist/tools/notebook.js.map +1 -1
- package/dist/tools/notes.d.ts.map +1 -1
- package/dist/tools/notes.js +6 -0
- package/dist/tools/notes.js.map +1 -1
- package/dist/tools/python-kernel.d.ts.map +1 -1
- package/dist/tools/python-kernel.js +5 -0
- package/dist/tools/python-kernel.js.map +1 -1
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +5 -0
- package/dist/tools/read-file.js.map +1 -1
- package/dist/tools/run-script.d.ts.map +1 -1
- package/dist/tools/run-script.js +1 -0
- package/dist/tools/run-script.js.map +1 -1
- package/dist/tools/search-history.d.ts.map +1 -1
- package/dist/tools/search-history.js +5 -1
- package/dist/tools/search-history.js.map +1 -1
- package/dist/tools/session-result.d.ts.map +1 -1
- package/dist/tools/session-result.js +4 -0
- package/dist/tools/session-result.js.map +1 -1
- package/dist/tools/shell.d.ts +1 -1
- package/dist/tools/shell.d.ts.map +1 -1
- package/dist/tools/shell.js +10 -1
- package/dist/tools/shell.js.map +1 -1
- package/dist/tools/sleep.d.ts.map +1 -1
- package/dist/tools/sleep.js +4 -0
- package/dist/tools/sleep.js.map +1 -1
- package/dist/tools/task.d.ts.map +1 -1
- package/dist/tools/task.js +5 -0
- package/dist/tools/task.js.map +1 -1
- package/dist/tools/todo.d.ts.map +1 -1
- package/dist/tools/todo.js +5 -0
- package/dist/tools/todo.js.map +1 -1
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +5 -0
- package/dist/tools/web-fetch.js.map +1 -1
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +4 -0
- package/dist/tools/web-search.js.map +1 -1
- package/dist/tools/write-file.d.ts.map +1 -1
- package/dist/tools/write-file.js +4 -0
- package/dist/tools/write-file.js.map +1 -1
- package/dist/tools/write-verify.d.ts.map +1 -1
- package/dist/tools/write-verify.js +6 -2
- package/dist/tools/write-verify.js.map +1 -1
- package/dist/turn-budget.d.ts +18 -0
- package/dist/turn-budget.d.ts.map +1 -0
- package/dist/turn-budget.js +61 -0
- package/dist/turn-budget.js.map +1 -0
- package/dist/turn-slicing.d.ts +5 -0
- package/dist/turn-slicing.d.ts.map +1 -1
- package/dist/turn-slicing.js +7 -0
- package/dist/turn-slicing.js.map +1 -1
- package/package.json +1 -1
- package/dist/tools/run-command.d.ts +0 -47
- package/dist/tools/run-command.d.ts.map +0 -1
- package/dist/tools/run-command.js +0 -415
- package/dist/tools/run-command.js.map +0 -1
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
import { exec, execFile, spawn } from "node:child_process";
|
|
2
|
-
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { buildTool } from "../tool.js";
|
|
6
|
-
import { needsLongOutputShaping, shapeLongOutput } from "./long-output.js";
|
|
7
|
-
import { mergeLoginShellEnv, scrubChildEnvOf, scrubSnapshotEnv } from "./shell-snapshot.js";
|
|
8
|
-
import { splitJsBin } from "./js-bin.js";
|
|
9
|
-
// ω99-46: the proxy half of the child-env policy — ONE overlay function, so
|
|
10
|
-
// every harness-spawned child (run_command, monitor, terminal, skill expand,
|
|
11
|
-
// the login-shell capture) sees the active egress policy through the same
|
|
12
|
-
// boundary instead of a second decision point.
|
|
13
|
-
import { applyEgressChildEnv } from "../net/egress.js";
|
|
14
|
-
// ω99-49: the streaming face — bounded sliding window + adaptive publisher.
|
|
15
|
-
import { OutputCapture } from "./output-capture.js";
|
|
16
|
-
const PROBE_TIMEOUT_MS = 5_000;
|
|
17
|
-
// The tool's contract is `sh -c` (posix quoting: single-quoted awk programs,
|
|
18
|
-
// \n escapes, `a && b`). Node's exec defaults to ComSpec (cmd.exe) on win32,
|
|
19
|
-
// which rejects that entire grammar. When a POSIX sh is discoverable (Git
|
|
20
|
-
// Bash's, the ubiquitous install), the host path uses it; without one,
|
|
21
|
-
// today's cmd.exe behavior stands (unchanged for machines without Git).
|
|
22
|
-
let cachedSh; // null = probed, not found
|
|
23
|
-
function hostShell() {
|
|
24
|
-
if (process.platform !== "win32")
|
|
25
|
-
return {};
|
|
26
|
-
if (cachedSh === null)
|
|
27
|
-
return {};
|
|
28
|
-
if (cachedSh !== undefined)
|
|
29
|
-
return { shell: cachedSh };
|
|
30
|
-
const candidates = [
|
|
31
|
-
join(process.env.ProgramFiles ?? "C:\\Program Files", "Git", "usr", "bin", "sh.exe"),
|
|
32
|
-
join(process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)", "Git", "usr", "bin", "sh.exe"),
|
|
33
|
-
join(process.env.LocalAppData ?? "", "Programs", "Git", "usr", "bin", "sh.exe"),
|
|
34
|
-
];
|
|
35
|
-
for (const c of candidates) {
|
|
36
|
-
if (existsSync(c)) {
|
|
37
|
-
cachedSh = c;
|
|
38
|
-
return { shell: c };
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
cachedSh = null;
|
|
42
|
-
return {};
|
|
43
|
-
}
|
|
44
|
-
const strArg = (v) => (typeof v === "string" ? v : "");
|
|
45
|
-
/** ω99-49: the terminal buffers' cap law, byte-identical to the pre-ω99-49
|
|
46
|
-
* append lambda (@f8882d4 run-command.ts:91-92) and exported for the
|
|
47
|
-
* differential acceptance pin (tests/o99-49-bounded-shell-output.test.ts).
|
|
48
|
-
* Head-kept, hard stop at maxBuffer — the exec()/execFile()-faithful cap
|
|
49
|
-
* that keeps the terminal ToolResult bytes unchanged. */
|
|
50
|
-
export function capBuffer(prev, text, maxBuffer) {
|
|
51
|
-
return prev.length >= maxBuffer ? prev : (prev + text).slice(0, maxBuffer);
|
|
52
|
-
}
|
|
53
|
-
// 波次 8 #43 (hermes kill_process_tree): exec()'s timeout kill reaches ONLY
|
|
54
|
-
// the direct child — the `sh -c` shell. Backgrounded grandchildren (`cmd &`,
|
|
55
|
-
// pipe tails, daemons) get reparented and keep running: writing files,
|
|
56
|
-
// holding locks, squatting the port. On POSIX the shell path spawns DETACHED
|
|
57
|
-
// (own process group, pgid = child pid); the timeout kill signals the
|
|
58
|
-
// NEGATIVE pid so the whole group dies — TERM first, then KILL after a 2s
|
|
59
|
-
// grace for TERM-immune stragglers (the escalation's SIGKILL surfaces as the
|
|
60
|
-
// honest `[killed by SIGKILL]` label, not a timeout label). Win32 (and any
|
|
61
|
-
// explicit shell override) keeps exec(): no process groups to signal there.
|
|
62
|
-
// Error shapes are exec()-faithful: null on success, {code} on nonzero exit,
|
|
63
|
-
// {killed:true, signal:"SIGTERM", code:null} on timeout — finish()'s exit /
|
|
64
|
-
// not-found / timeout labels key on exactly those.
|
|
65
|
-
// ω99-49: the optional onUpdate rides along as an ADDITIVE streaming face —
|
|
66
|
-
// every chunk feeds both the legacy terminal buffers (byte-identical law
|
|
67
|
-
// below) and the OutputCapture live window. Absent → the exact pre-ω99-49
|
|
68
|
-
// code path (no capture object is even constructed).
|
|
69
|
-
function execWithGroupKill(command, opts, done, onUpdate) {
|
|
70
|
-
if (process.platform === "win32" || opts.shell !== undefined) {
|
|
71
|
-
// windowsHide: a console-subsystem child of a console-LESS parent (the
|
|
72
|
-
// desktop sidecar) would otherwise get its own visible console window —
|
|
73
|
-
// closing it kills the command mid-run. No-op in terminals (attached).
|
|
74
|
-
exec(command, { windowsHide: true, ...opts }, done);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const child = spawn(command, {
|
|
78
|
-
cwd: opts.cwd,
|
|
79
|
-
env: opts.env,
|
|
80
|
-
detached: true, // own process group — the group kill hinges on this
|
|
81
|
-
// stdin stays an open, never-written pipe: exec()'s exact posture (the
|
|
82
|
-
// interactive-hang detection depends on prompt-waiting tools NOT seeing
|
|
83
|
-
// an early EOF that /dev/null would give them).
|
|
84
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
85
|
-
shell: true, // POSIX: /bin/sh -c (what exec() does without opts.shell)
|
|
86
|
-
});
|
|
87
|
-
let stdout = "";
|
|
88
|
-
let stderr = "";
|
|
89
|
-
let settled = false;
|
|
90
|
-
let killedByTimeout = false;
|
|
91
|
-
let escalation;
|
|
92
|
-
// ω99-49: the terminal buffers' byte law, extracted VERBATIM from the
|
|
93
|
-
// pre-ω99-49 append lambda (@f8882d4 run-command.ts:91-92) and exported
|
|
94
|
-
// for the differential pin — UTF-16-code-unit slice, head-kept, hard stop
|
|
95
|
-
// at maxBuffer. This is the exec()/execFile() maxBuffer-faithful cap: the
|
|
96
|
-
// process-level生死线 semantics (drop past the cap, never kill) unchanged.
|
|
97
|
-
const capture = onUpdate === undefined ? undefined : new OutputCapture({ onUpdate });
|
|
98
|
-
const append = (prev, chunk) => prev.length >= opts.maxBuffer ? prev : capBuffer(prev, chunk.toString("utf8"), opts.maxBuffer);
|
|
99
|
-
child.stdout?.on("data", (c) => { stdout = append(stdout, c); capture?.push(c); });
|
|
100
|
-
child.stderr?.on("data", (c) => { stderr = append(stderr, c); capture?.push(c); });
|
|
101
|
-
const timer = setTimeout(() => {
|
|
102
|
-
killedByTimeout = true;
|
|
103
|
-
// Signal the GROUP (-pid); ESRCH just means an earlier death won.
|
|
104
|
-
try {
|
|
105
|
-
if (child.pid !== undefined)
|
|
106
|
-
process.kill(-child.pid, "SIGTERM");
|
|
107
|
-
}
|
|
108
|
-
catch { /* group already gone */ }
|
|
109
|
-
escalation = setTimeout(() => {
|
|
110
|
-
try {
|
|
111
|
-
if (child.pid !== undefined)
|
|
112
|
-
process.kill(-child.pid, "SIGKILL");
|
|
113
|
-
}
|
|
114
|
-
catch { /* group already gone */ }
|
|
115
|
-
}, 2_000);
|
|
116
|
-
}, opts.timeout);
|
|
117
|
-
const settle = (err) => {
|
|
118
|
-
if (settled)
|
|
119
|
-
return;
|
|
120
|
-
settled = true;
|
|
121
|
-
clearTimeout(timer);
|
|
122
|
-
if (escalation !== undefined)
|
|
123
|
-
clearTimeout(escalation);
|
|
124
|
-
capture?.finish(); // terminal forced flush BEFORE the result settles
|
|
125
|
-
done(err, stdout, stderr);
|
|
126
|
-
};
|
|
127
|
-
child.on("error", (e) => settle(e)); // spawn failure (ENOENT …)
|
|
128
|
-
child.on("close", (code, signal) => {
|
|
129
|
-
if (killedByTimeout) {
|
|
130
|
-
settle(Object.assign(new Error("Command timed out"), { killed: true, signal: signal ?? "SIGTERM", code: code ?? null }));
|
|
131
|
-
}
|
|
132
|
-
else if (code !== 0 && code !== null) {
|
|
133
|
-
settle(Object.assign(new Error(`Command failed with exit code ${code}`), { killed: false, signal: null, code }));
|
|
134
|
-
}
|
|
135
|
-
else if (code === null) {
|
|
136
|
-
// externally signalled (not our timeout) — surface the signal verbatim
|
|
137
|
-
settle(Object.assign(new Error("Command killed"), { killed: signal !== null, signal: signal ?? undefined, code: null }));
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
settle(null);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
// M51 §3 — the destructive-command classifier feeding run_command's
|
|
145
|
-
// isDestructive annotation (and through it the sidecar's tool_flags). A
|
|
146
|
-
// conservative OR of well-known state-destroying shapes; matched against the
|
|
147
|
-
// FIRST token of any command segment (`;`/`&`/`|` separated) so `cat f; rm f`
|
|
148
|
-
// still trips. false = "not obviously destructive", never "safe".
|
|
149
|
-
const DESTRUCTIVE_FIRST_TOKEN = /(?:^|[;&|]\s*)(?:rm|rmdir|unlink|shred|dd|mkfs[\w.]*|fdisk|parted|truncate|mv|kill|pkill|killall|shutdown|reboot)\b/;
|
|
150
|
-
const DESTRUCTIVE_PATTERNS = [
|
|
151
|
-
DESTRUCTIVE_FIRST_TOKEN,
|
|
152
|
-
/\bgit\s+push\s+(?:.*\s)?(?:--force(?:-with-lease)?\b|-f\b)/,
|
|
153
|
-
/\bgit\s+reset\s+--hard\b/,
|
|
154
|
-
/\bgit\s+clean\b/,
|
|
155
|
-
/\bgit\s+(?:checkout|restore)\s+--\s/,
|
|
156
|
-
/\bdocker\s+(?:rm|rmi|system\s+prune|volume\s+(?:rm|prune))\b/,
|
|
157
|
-
/\bnpm\s+publish\b/,
|
|
158
|
-
/(?:^|[\s;])>\s*\S/, // output redirection truncates the target
|
|
159
|
-
];
|
|
160
|
-
/** Pure: does this command look destructive? Exported for tests. */
|
|
161
|
-
export function commandLooksDestructive(command) {
|
|
162
|
-
return DESTRUCTIVE_PATTERNS.some((re) => re.test(command));
|
|
163
|
-
}
|
|
164
|
-
// 波次 7 #34 (OH B2) — interactive-hang detection. A model-driven shell has
|
|
165
|
-
// no human to answer prompts: a command that waits on stdin burns its whole
|
|
166
|
-
// timeout and reads as a generic timeout on retry. Deterministic head scan
|
|
167
|
-
// (false positives only add a hint line to the timeout label; false
|
|
168
|
-
// negatives merely miss one). Plain token split — the same first-token
|
|
169
|
-
// reading the destructive classifier uses.
|
|
170
|
-
const INTERACTIVE_HEADS = new Set(["sudo", "passwd", "create-next-app", "create-vite", "create-react-app", "create-expo-app"]);
|
|
171
|
-
const PACKAGE_MANAGERS = new Set(["npm", "pnpm", "yarn", "bun"]);
|
|
172
|
-
/** Pure: does this command look like it will wait on interactive input?
|
|
173
|
-
* Exported for tests. */
|
|
174
|
-
export function looksInteractive(command) {
|
|
175
|
-
const tokens = command.trim().split(/\s+/).filter(Boolean);
|
|
176
|
-
const head = tokens[0] ?? "";
|
|
177
|
-
if (head === "")
|
|
178
|
-
return false;
|
|
179
|
-
if (INTERACTIVE_HEADS.has(head))
|
|
180
|
-
return true;
|
|
181
|
-
if (PACKAGE_MANAGERS.has(head)) {
|
|
182
|
-
const sub = tokens[1] ?? "";
|
|
183
|
-
// `pm create X` always scaffolds through a prompt flow; `npm init`
|
|
184
|
-
// prompts unless -y/--yes is present.
|
|
185
|
-
if (sub === "create")
|
|
186
|
-
return true;
|
|
187
|
-
if (head === "npm" && sub === "init")
|
|
188
|
-
return !(tokens.includes("-y") || tokens.includes("--yes"));
|
|
189
|
-
}
|
|
190
|
-
if (head === "npx")
|
|
191
|
-
return /^create-/.test(tokens[1] ?? "");
|
|
192
|
-
// Prompt flags on file operations: `-i` alone or bundled (`rm -if`).
|
|
193
|
-
if (head === "rm" || head === "mv" || head === "cp") {
|
|
194
|
-
return tokens.slice(1).some((t) => t === "-i" || (/^-[a-zA-Z]+$/.test(t) && t.includes("i")));
|
|
195
|
-
}
|
|
196
|
-
return false;
|
|
197
|
-
}
|
|
198
|
-
/** Credential-shaped env scrub shared by every harness-spawned child (host
|
|
199
|
-
* shell, docker CLI, and — since M50 — the run_script PTC child). Returns a
|
|
200
|
-
* fresh env object: `*API_KEY`/`*ACCESS_KEY`/`*TOKEN`/`*SECRET`/`*PASSWORD`/
|
|
201
|
-
* `*CREDENTIALS` suffixes and `WUDAO_*`/`OPENAI_*` prefixes are dropped. */
|
|
202
|
-
export function scrubChildEnv() {
|
|
203
|
-
// ω-4d: the rules live once, in the pure scrubChildEnvOf (shell-snapshot.ts),
|
|
204
|
-
// so the process-env scrub and the login-shell snapshot cannot drift apart.
|
|
205
|
-
// ω99-46: the proxy overlay rides the same boundary — applyEgressChildEnv
|
|
206
|
-
// publishes the ACTIVE egress policy's names (HTTPS_PROXY/HTTP_PROXY/
|
|
207
|
-
// NO_PROXY + NODE_USE_ENV_PROXY, withheld for values Node cannot parse).
|
|
208
|
-
// No active policy = empty overlay = the env above, byte-identical.
|
|
209
|
-
return applyEgressChildEnv(scrubChildEnvOf(process.env));
|
|
210
|
-
}
|
|
211
|
-
export function createRunCommandTool(options) {
|
|
212
|
-
const timeoutMs = options.timeoutMs ?? 30_000;
|
|
213
|
-
const maxOutputBytes = options.maxOutputBytes ?? 65_536;
|
|
214
|
-
const image = options.sandbox?.image ?? "node:22-alpine";
|
|
215
|
-
const dockerPath = options.sandbox?.dockerPath ?? "docker";
|
|
216
|
-
const spillDir = options.spillDir;
|
|
217
|
-
const longOutput = options.longOutput;
|
|
218
|
-
// Availability probe, cached per tool instance (success AND failure — a
|
|
219
|
-
// down daemon keeps denying rather than re-probing on every call).
|
|
220
|
-
let probe;
|
|
221
|
-
// dockerPath may be the two-word `node <entry.mjs>` form (win32 embedders/
|
|
222
|
-
// tests point at JS fake-dockers; see splitJsBin).
|
|
223
|
-
const dockerExe = splitJsBin(dockerPath);
|
|
224
|
-
const runProbe = () => (probe ??= new Promise((resolve) => {
|
|
225
|
-
execFile(dockerExe.exe, [...dockerExe.prefix, "version", "--format", "{{.Server.Version}}"], { timeout: PROBE_TIMEOUT_MS }, (err, _stdout, stderr) => {
|
|
226
|
-
if (err !== null) {
|
|
227
|
-
// Prefer the daemon's own stderr (e.g. "cannot connect to the Docker
|
|
228
|
-
// daemon") over execFile's multi-line "Command failed: ..." wrapper;
|
|
229
|
-
// collapse whitespace so the denial stays a single line.
|
|
230
|
-
const detail = String(stderr ?? "").trim();
|
|
231
|
-
const reason = (detail || err.message).replace(/\s+/g, " ").trim();
|
|
232
|
-
resolve({ ok: false, reason });
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
resolve({ ok: true });
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
}));
|
|
239
|
-
// Scrub credential-shaped env vars so a model-issued `printenv` can't
|
|
240
|
-
// exfiltrate keys. (The model can still `cat .env` — file-level protection
|
|
241
|
-
// is a documented v1 limitation.) Applied to the host shell AND the docker
|
|
242
|
-
// CLI itself; note the container env is whatever the image ships by default
|
|
243
|
-
// — no `-e` flags are passed, so nothing from the host leaks INTO it.
|
|
244
|
-
// Exported (M50) so run_script's child gets the identical hygiene.
|
|
245
|
-
const scrubbedEnv = () => scrubChildEnv();
|
|
246
|
-
// With spill enabled, let the child produce more than the inline cap so the
|
|
247
|
-
// spilled file is genuinely the FULL output (16× the cap, ≥1MB). Without
|
|
248
|
-
// spill the buffer matches the inline cap — the pre-M24 behavior.
|
|
249
|
-
const execMaxBuffer = () => (spillDir ? Math.max(maxOutputBytes * 16, 1_048_576) : maxOutputBytes);
|
|
250
|
-
// Spill the FULL raw output to disk (best-effort: a failed write just means
|
|
251
|
-
// no path note — the truncated output still returns). Sync because finish()
|
|
252
|
-
// runs inside exec callbacks; deterministic name = content hash, so
|
|
253
|
-
// identical outputs share one file.
|
|
254
|
-
const spill = (raw) => {
|
|
255
|
-
if (!spillDir)
|
|
256
|
-
return undefined;
|
|
257
|
-
try {
|
|
258
|
-
mkdirSync(spillDir, { recursive: true });
|
|
259
|
-
const name = `${createHash("sha256").update(raw).digest("hex").slice(0, 16)}.txt`;
|
|
260
|
-
const path = join(spillDir, name);
|
|
261
|
-
writeFileSync(path, raw, "utf8");
|
|
262
|
-
return path;
|
|
263
|
-
}
|
|
264
|
-
catch {
|
|
265
|
-
return undefined;
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
// Shared result shaping: combined output (spilling the full text when the
|
|
269
|
-
// cap bites), not-found note, exit/signal label.
|
|
270
|
-
const finish = (command, err, stdout, stderr) => {
|
|
271
|
-
const stdoutText = String(stdout);
|
|
272
|
-
const stderrText = String(stderr);
|
|
273
|
-
const raw = `${stdoutText}${stderrText ? (stdoutText ? "\n" : "") + stderrText : ""}`;
|
|
274
|
-
// M46 §2: long outputs keep head + tail around an omission marker, with
|
|
275
|
-
// the full text spilled for read_file paging. Only when the spill write
|
|
276
|
-
// succeeds — otherwise fall through to the byte-cap path below (the
|
|
277
|
-
// pre-M46 behavior is the documented fallback).
|
|
278
|
-
if (longOutput !== undefined && needsLongOutputShaping(raw, longOutput)) {
|
|
279
|
-
const path = spill(raw);
|
|
280
|
-
const shaped = path === undefined ? undefined : shapeLongOutput({ raw, config: longOutput, spillPath: path });
|
|
281
|
-
if (shaped !== undefined) {
|
|
282
|
-
return { content: `$ ${command}\n${shaped}${notFoundNoteFor(err, stderrText, command)}\n${exitLabelFor(err, command)}`, isError: exitCodeOf(err) !== 0 };
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
const truncated = raw.length > maxOutputBytes;
|
|
286
|
-
const combined = truncated ? raw.slice(0, maxOutputBytes) : raw;
|
|
287
|
-
const spillNote = truncated ? (() => {
|
|
288
|
-
const path = spill(raw);
|
|
289
|
-
return path === undefined ? "" : `\n(full output: ${path})`;
|
|
290
|
-
})() : "";
|
|
291
|
-
const notFoundNote = notFoundNoteFor(err, stderrText, command);
|
|
292
|
-
const exitLabel = exitLabelFor(err, command);
|
|
293
|
-
return { content: `$ ${command}\n${combined}${notFoundNote}${spillNote}\n${exitLabel}`, isError: exitCodeOf(err) !== 0 };
|
|
294
|
-
};
|
|
295
|
-
// Shared exit/signal/not-found labels (used by both the shaped and the
|
|
296
|
-
// byte-cap result paths).
|
|
297
|
-
const execErrOf = (err) => err;
|
|
298
|
-
// Legacy exit code semantics, byte-faithful: no error → 0; an error with
|
|
299
|
-
// no code → 1; a code (even a string like ENOENT) interpolates verbatim.
|
|
300
|
-
const exitCodeOf = (err) => {
|
|
301
|
-
if (err === null || err === undefined)
|
|
302
|
-
return 0;
|
|
303
|
-
return execErrOf(err)?.code ?? 1;
|
|
304
|
-
};
|
|
305
|
-
// The command runs via `sh -c` (host) or `docker … sh -c` (sandbox), so a
|
|
306
|
-
// missing binary surfaces either as a direct spawn ENOENT (code ===
|
|
307
|
-
// "ENOENT") or as the shell's exit 127.
|
|
308
|
-
const notFoundNoteFor = (err, stderr, command) => {
|
|
309
|
-
if (err === null || err === undefined)
|
|
310
|
-
return "";
|
|
311
|
-
const code = execErrOf(err)?.code;
|
|
312
|
-
if (code === "ENOENT" || code === 127)
|
|
313
|
-
return "\ncommand not found or not executable";
|
|
314
|
-
// win32 cmd.exe: an unknown command exits 1 with a LOCALIZED "not
|
|
315
|
-
// recognized" message (GBK-mojibake by the time Node decoded it — never
|
|
316
|
-
// match the text). The codepage-stable shape: stderr opens with the
|
|
317
|
-
// first command word wrapped in single quotes.
|
|
318
|
-
if (process.platform === "win32" && code === 1 && command !== undefined) {
|
|
319
|
-
const text = String(stderr ?? "");
|
|
320
|
-
if (text.startsWith(`'${command.split(" ")[0]}'`)) {
|
|
321
|
-
return "\ncommand not found or not executable";
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return "";
|
|
325
|
-
};
|
|
326
|
-
// exec()/execFile() kill with SIGTERM on timeout (killed=true). A child
|
|
327
|
-
// terminated by any OTHER signal carries err.signal but killed=false —
|
|
328
|
-
// label the actual signal; the timeout label is reserved for SIGTERM kills.
|
|
329
|
-
// 波次 7 #34 (OH B2): a timeout on an interactive-looking command carries
|
|
330
|
-
// the non-interactive hint — without it a prompt-waiting burn reads as a
|
|
331
|
-
// generic timeout and the model retries blind.
|
|
332
|
-
const exitLabelFor = (err, command) => {
|
|
333
|
-
if (err === null || err === undefined)
|
|
334
|
-
return "[exit 0]";
|
|
335
|
-
const e = execErrOf(err);
|
|
336
|
-
if (e?.signal !== null && e?.signal !== undefined && e?.signal !== "SIGTERM")
|
|
337
|
-
return `[killed by ${e.signal}]`;
|
|
338
|
-
if (e?.killed) {
|
|
339
|
-
return looksInteractive(command)
|
|
340
|
-
? `[timeout after ${timeoutMs / 1000}s — likely waiting for interactive input; re-run with non-interactive flags (e.g. --yes / -y) or pre-supply every argument]`
|
|
341
|
-
: `[timeout after ${timeoutMs / 1000}s]`;
|
|
342
|
-
}
|
|
343
|
-
return `[exit ${exitCodeOf(err)}]`;
|
|
344
|
-
};
|
|
345
|
-
return buildTool({
|
|
346
|
-
name: "run_command",
|
|
347
|
-
description: "Run a shell command in the workspace. Returns combined stdout+stderr and the exit code.",
|
|
348
|
-
// M51 §3: open-world (a shell can reach the network); destructive per
|
|
349
|
-
// command — the conservative first-token/pattern scan below. false is NOT
|
|
350
|
-
// "safe", it is "not obviously destructive" (the sidecar still classifies).
|
|
351
|
-
isOpenWorld: () => true,
|
|
352
|
-
isDestructive: (args) => commandLooksDestructive(strArg(args.command)),
|
|
353
|
-
parameters: {
|
|
354
|
-
type: "object",
|
|
355
|
-
properties: { command: { type: "string", description: "The shell command to run." } },
|
|
356
|
-
required: ["command"],
|
|
357
|
-
additionalProperties: false,
|
|
358
|
-
},
|
|
359
|
-
// ω99-49: the optional live-output channel (loop-threaded, per-call).
|
|
360
|
-
// Absent → every path below is byte-identical to the pre-ω99-49 tool.
|
|
361
|
-
// Streaming exists on the POSIX host executor (the spawn branch of
|
|
362
|
-
// execWithGroupKill, our own capture layer); the sandbox (execFile) and
|
|
363
|
-
// win32/explicit-shell (exec) branches buffer inside Node and do not
|
|
364
|
-
// stream — their terminal results still carry the full output, and the
|
|
365
|
-
// loop seam is generic so any future capture layer plugs in here.
|
|
366
|
-
async execute({ command }, onUpdate) {
|
|
367
|
-
if (options.sandbox !== undefined) {
|
|
368
|
-
const probed = await runProbe();
|
|
369
|
-
if (!probed.ok) {
|
|
370
|
-
return {
|
|
371
|
-
content: `run_command failed: sandbox required but Docker is unavailable (${probed.reason})`,
|
|
372
|
-
isError: true,
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
return new Promise((resolveP) => {
|
|
376
|
-
// Arg-array invocation — the docker command itself is never wrapped
|
|
377
|
-
// in a shell; the USER command goes to `sh -c` INSIDE the container.
|
|
378
|
-
// No-network, capped memory/CPU, workspace mounted read-write at
|
|
379
|
-
// /workspace (the container's working dir).
|
|
380
|
-
execFile(dockerExe.exe, [
|
|
381
|
-
...dockerExe.prefix,
|
|
382
|
-
"run", "--rm", "-i",
|
|
383
|
-
"--network", "none",
|
|
384
|
-
"--memory", "512m",
|
|
385
|
-
"--cpus", "1",
|
|
386
|
-
"-v", `${options.workspaceRoot}:/workspace`,
|
|
387
|
-
"-w", "/workspace",
|
|
388
|
-
"--entrypoint", "sh",
|
|
389
|
-
image,
|
|
390
|
-
"-c", command,
|
|
391
|
-
], { timeout: timeoutMs, maxBuffer: execMaxBuffer(), env: scrubbedEnv() }, (err, stdout, stderr) => resolveP(finish(command, err, stdout, stderr)));
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
// ω-4d: lazily merge the login-shell snapshot (rc-applied env, one
|
|
395
|
-
// capture per session — the provider memoizes; failure resolves
|
|
396
|
-
// undefined and today's env stands). The sandbox branch above NEVER
|
|
397
|
-
// consults the provider; both merge operands are scrubbed, so the
|
|
398
|
-
// product is (§5 case 4's both-directions pin).
|
|
399
|
-
const snapshot = options.sandbox === undefined && options.loginShellEnv !== undefined
|
|
400
|
-
? await options.loginShellEnv().catch(() => undefined)
|
|
401
|
-
: undefined;
|
|
402
|
-
const env = snapshot !== undefined
|
|
403
|
-
? mergeLoginShellEnv(scrubbedEnv(), scrubSnapshotEnv(snapshot))
|
|
404
|
-
: scrubbedEnv();
|
|
405
|
-
return new Promise((resolveP) => {
|
|
406
|
-
// 波次 8 #43: group-kill executor (POSIX); win32/explicit-shell
|
|
407
|
-
// callers fall back to exec() inside.
|
|
408
|
-
execWithGroupKill(command, { cwd: options.workspaceRoot, timeout: timeoutMs, maxBuffer: execMaxBuffer(), env, ...hostShell() }, (err, stdout, stderr) => {
|
|
409
|
-
resolveP(finish(command, err, stdout, stderr));
|
|
410
|
-
}, onUpdate);
|
|
411
|
-
});
|
|
412
|
-
},
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
//# sourceMappingURL=run-command.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-command.js","sourceRoot":"","sources":["../../src/tools/run-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,aAA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