@dirgha/code 1.21.0 → 1.23.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/CHANGELOG.md +171 -0
- package/README.md +8 -4
- package/dist/auth/keypool.js +40 -26
- package/dist/auth/keypool.js.map +1 -1
- package/dist/auth/keystore.js +16 -11
- package/dist/auth/keystore.js.map +1 -1
- package/dist/cli/config.d.ts +36 -5
- package/dist/cli/config.js +31 -3
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/first-run.js +40 -24
- package/dist/cli/first-run.js.map +1 -1
- package/dist/cli/flows/wizard.js +12 -18
- package/dist/cli/flows/wizard.js.map +1 -1
- package/dist/cli/interactive.d.ts +4 -0
- package/dist/cli/interactive.js +45 -1
- package/dist/cli/interactive.js.map +1 -1
- package/dist/cli/main.js +69 -18
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/slash/fleet.js +19 -1
- package/dist/cli/slash/fleet.js.map +1 -1
- package/dist/cli/slash/index.d.ts +2 -1
- package/dist/cli/slash/index.js +3 -1
- package/dist/cli/slash/index.js.map +1 -1
- package/dist/cli/slash/models.js +4 -2
- package/dist/cli/slash/models.js.map +1 -1
- package/dist/cli/slash/paste.js +4 -7
- package/dist/cli/slash/paste.js.map +1 -1
- package/dist/cli/slash/sandbox.d.ts +21 -0
- package/dist/cli/slash/sandbox.js +84 -0
- package/dist/cli/slash/sandbox.js.map +1 -0
- package/dist/cli/slash.d.ts +5 -0
- package/dist/cli/slash.js +26 -10
- package/dist/cli/slash.js.map +1 -1
- package/dist/cli/subcommands/audit.js +28 -8
- package/dist/cli/subcommands/audit.js.map +1 -1
- package/dist/cli/subcommands/doctor.d.ts +4 -0
- package/dist/cli/subcommands/doctor.js +148 -21
- package/dist/cli/subcommands/doctor.js.map +1 -1
- package/dist/cli/subcommands/feature-setup.js +6 -6
- package/dist/cli/subcommands/feature-setup.js.map +1 -1
- package/dist/cli/subcommands/memory.js +23 -0
- package/dist/cli/subcommands/memory.js.map +1 -1
- package/dist/cli/subcommands/telemetry.d.ts +2 -1
- package/dist/cli/subcommands/telemetry.js +47 -34
- package/dist/cli/subcommands/telemetry.js.map +1 -1
- package/dist/context/branch.d.ts +2 -2
- package/dist/context/branch.js +40 -23
- package/dist/context/branch.js.map +1 -1
- package/dist/context/compaction.js +45 -22
- package/dist/context/compaction.js.map +1 -1
- package/dist/context/default-soul.md +1 -0
- package/dist/context/git-state.js +31 -18
- package/dist/context/git-state.js.map +1 -1
- package/dist/context/knowledge.js +31 -20
- package/dist/context/knowledge.js.map +1 -1
- package/dist/context/memory.js +8 -1
- package/dist/context/memory.js.map +1 -1
- package/dist/context/mode-enforcement.js +11 -1
- package/dist/context/mode-enforcement.js.map +1 -1
- package/dist/context/mode.js +67 -30
- package/dist/context/mode.js.map +1 -1
- package/dist/context/primer.d.ts +17 -0
- package/dist/context/primer.js +50 -3
- package/dist/context/primer.js.map +1 -1
- package/dist/context/session.d.ts +4 -0
- package/dist/context/session.js.map +1 -1
- package/dist/embeddings/iface.d.ts +26 -0
- package/dist/embeddings/iface.js +15 -0
- package/dist/embeddings/iface.js.map +1 -0
- package/dist/embeddings/local.d.ts +24 -0
- package/dist/embeddings/local.js +112 -0
- package/dist/embeddings/local.js.map +1 -0
- package/dist/embeddings/remote.d.ts +31 -0
- package/dist/embeddings/remote.js +88 -0
- package/dist/embeddings/remote.js.map +1 -0
- package/dist/embeddings/select.d.ts +24 -0
- package/dist/embeddings/select.js +39 -0
- package/dist/embeddings/select.js.map +1 -0
- package/dist/fleet/apply-back.js +5 -1
- package/dist/fleet/apply-back.js.map +1 -1
- package/dist/fleet/cli-command.d.ts +2 -0
- package/dist/fleet/cli-command.js +15 -1
- package/dist/fleet/cli-command.js.map +1 -1
- package/dist/fleet/runner.js +35 -2
- package/dist/fleet/runner.js.map +1 -1
- package/dist/fleet/scratchpad.js +1 -2
- package/dist/fleet/scratchpad.js.map +1 -1
- package/dist/fleet/state.d.ts +4 -0
- package/dist/fleet/state.js +11 -2
- package/dist/fleet/state.js.map +1 -1
- package/dist/fleet/templates.d.ts +4 -0
- package/dist/fleet/templates.js.map +1 -1
- package/dist/fleet/types.d.ts +4 -0
- package/dist/fleet/types.js.map +1 -1
- package/dist/intelligence/failover-chain.js +10 -1
- package/dist/intelligence/failover-chain.js.map +1 -1
- package/dist/intelligence/health-monitor.d.ts +8 -8
- package/dist/intelligence/health-monitor.js +105 -74
- package/dist/intelligence/health-monitor.js.map +1 -1
- package/dist/intelligence/prices.d.ts +6 -4
- package/dist/intelligence/prices.js +36 -10
- package/dist/intelligence/prices.js.map +1 -1
- package/dist/kernel/agent-loop.js +60 -17
- package/dist/kernel/agent-loop.js.map +1 -1
- package/dist/kernel/types.d.ts +3 -0
- package/dist/lsp/client.js +29 -16
- package/dist/lsp/client.js.map +1 -1
- package/dist/lsp/detector.js +7 -6
- package/dist/lsp/detector.js.map +1 -1
- package/dist/mcp/client.d.ts +1 -1
- package/dist/mcp/client.js +19 -16
- package/dist/mcp/client.js.map +1 -1
- package/dist/mcp/transport.js +46 -38
- package/dist/mcp/transport.js.map +1 -1
- package/dist/providers/deepseek.js +1 -1
- package/dist/providers/deepseek.js.map +1 -1
- package/dist/providers/dispatch.js +15 -1
- package/dist/providers/dispatch.js.map +1 -1
- package/dist/providers/index.d.ts +11 -0
- package/dist/providers/index.js +29 -2
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/nvidia.js +1 -1
- package/dist/providers/nvidia.js.map +1 -1
- package/dist/providers/openai-compat.js +4 -2
- package/dist/providers/openai-compat.js.map +1 -1
- package/dist/providers/openrouter.js +1 -1
- package/dist/providers/openrouter.js.map +1 -1
- package/dist/safety/audit-log.d.ts +15 -0
- package/dist/safety/audit-log.js +21 -0
- package/dist/safety/audit-log.js.map +1 -1
- package/dist/state/db-telemetry.d.ts +21 -0
- package/dist/state/db-telemetry.js +116 -0
- package/dist/state/db-telemetry.js.map +1 -0
- package/dist/state/db.d.ts +7 -0
- package/dist/state/db.js +132 -7
- package/dist/state/db.js.map +1 -1
- package/dist/state/sync-index.d.ts +74 -0
- package/dist/state/sync-index.js +246 -0
- package/dist/state/sync-index.js.map +1 -0
- package/dist/state/transaction.d.ts +62 -0
- package/dist/state/transaction.js +65 -0
- package/dist/state/transaction.js.map +1 -0
- package/dist/state/vec.d.ts +28 -0
- package/dist/state/vec.js +113 -0
- package/dist/state/vec.js.map +1 -0
- package/dist/telemetry/gateway-push.d.ts +17 -0
- package/dist/telemetry/gateway-push.js +48 -0
- package/dist/telemetry/gateway-push.js.map +1 -0
- package/dist/telemetry/index.d.ts +9 -0
- package/dist/telemetry/index.js +9 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/tools/browser.js +24 -16
- package/dist/tools/browser.js.map +1 -1
- package/dist/tools/checkpoint.d.ts +6 -1
- package/dist/tools/checkpoint.js +79 -62
- package/dist/tools/checkpoint.js.map +1 -1
- package/dist/tools/cron.js +1 -3
- package/dist/tools/cron.js.map +1 -1
- package/dist/tools/db-workspace-info.d.ts +10 -0
- package/dist/tools/db-workspace-info.js +76 -0
- package/dist/tools/db-workspace-info.js.map +1 -0
- package/dist/tools/diff.js +25 -21
- package/dist/tools/diff.js.map +1 -1
- package/dist/tools/exec.d.ts +6 -1
- package/dist/tools/exec.js +46 -4
- package/dist/tools/exec.js.map +1 -1
- package/dist/tools/fs-edit.d.ts +3 -5
- package/dist/tools/fs-edit.js +8 -23
- package/dist/tools/fs-edit.js.map +1 -1
- package/dist/tools/fs-ls.js +6 -8
- package/dist/tools/fs-ls.js.map +1 -1
- package/dist/tools/fs-read.d.ts +1 -1
- package/dist/tools/fs-read.js +37 -28
- package/dist/tools/fs-read.js.map +1 -1
- package/dist/tools/fs-write.d.ts +1 -1
- package/dist/tools/fs-write.js +33 -33
- package/dist/tools/fs-write.js.map +1 -1
- package/dist/tools/git.js +12 -6
- package/dist/tools/git.js.map +1 -1
- package/dist/tools/github.d.ts +13 -0
- package/dist/tools/github.js +257 -0
- package/dist/tools/github.js.map +1 -0
- package/dist/tools/graph-neighbors.d.ts +9 -0
- package/dist/tools/graph-neighbors.js +77 -0
- package/dist/tools/graph-neighbors.js.map +1 -0
- package/dist/tools/graph-traverse.d.ts +10 -0
- package/dist/tools/graph-traverse.js +90 -0
- package/dist/tools/graph-traverse.js.map +1 -0
- package/dist/tools/index.d.ts +10 -2
- package/dist/tools/index.js +17 -4
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/kb-search.d.ts +13 -0
- package/dist/tools/kb-search.js +113 -0
- package/dist/tools/kb-search.js.map +1 -0
- package/dist/tools/multimodal.js +11 -12
- package/dist/tools/multimodal.js.map +1 -1
- package/dist/tools/registry.d.ts +10 -0
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/rtk.js +22 -9
- package/dist/tools/rtk.js.map +1 -1
- package/dist/tools/search-glob.d.ts +1 -1
- package/dist/tools/search-glob.js +42 -24
- package/dist/tools/search-glob.js.map +1 -1
- package/dist/tools/search-grep.d.ts +1 -1
- package/dist/tools/search-grep.js +56 -32
- package/dist/tools/search-grep.js.map +1 -1
- package/dist/tools/shell.d.ts +7 -1
- package/dist/tools/shell.js +178 -61
- package/dist/tools/shell.js.map +1 -1
- package/dist/tools/transactional-write.d.ts +10 -0
- package/dist/tools/transactional-write.js +132 -0
- package/dist/tools/transactional-write.js.map +1 -0
- package/dist/tui/ink/App.d.ts +2 -1
- package/dist/tui/ink/App.js +319 -83
- package/dist/tui/ink/App.js.map +1 -1
- package/dist/tui/ink/components/DenseToolMessage.js +23 -8
- package/dist/tui/ink/components/DenseToolMessage.js.map +1 -1
- package/dist/tui/ink/components/InputBox.js +16 -25
- package/dist/tui/ink/components/InputBox.js.map +1 -1
- package/dist/tui/ink/components/KeySetOverlay.d.ts +1 -1
- package/dist/tui/ink/components/KeySetOverlay.js +18 -16
- package/dist/tui/ink/components/KeySetOverlay.js.map +1 -1
- package/dist/tui/ink/components/Logo.d.ts +20 -0
- package/dist/tui/ink/components/Logo.js +67 -1
- package/dist/tui/ink/components/Logo.js.map +1 -1
- package/dist/tui/ink/components/ModelPicker.d.ts +2 -2
- package/dist/tui/ink/components/ModelPicker.js +34 -26
- package/dist/tui/ink/components/ModelPicker.js.map +1 -1
- package/dist/tui/ink/components/PasteCollapse.d.ts +3 -1
- package/dist/tui/ink/components/PasteCollapse.js +11 -9
- package/dist/tui/ink/components/PasteCollapse.js.map +1 -1
- package/dist/tui/ink/components/SandboxPicker.d.ts +18 -0
- package/dist/tui/ink/components/SandboxPicker.js +77 -0
- package/dist/tui/ink/components/SandboxPicker.js.map +1 -0
- package/dist/tui/ink/components/SpinnerGlyph.d.ts +4 -4
- package/dist/tui/ink/components/SpinnerGlyph.js +34 -14
- package/dist/tui/ink/components/SpinnerGlyph.js.map +1 -1
- package/dist/tui/ink/components/StatusBar.d.ts +7 -0
- package/dist/tui/ink/components/StatusBar.js +11 -5
- package/dist/tui/ink/components/StatusBar.js.map +1 -1
- package/dist/tui/ink/components/ThinkingBlock.d.ts +15 -4
- package/dist/tui/ink/components/ThinkingBlock.js +34 -17
- package/dist/tui/ink/components/ThinkingBlock.js.map +1 -1
- package/dist/tui/ink/components/ToolBox.js +23 -13
- package/dist/tui/ink/components/ToolBox.js.map +1 -1
- package/dist/tui/ink/components/VirtualTranscript.d.ts +19 -0
- package/dist/tui/ink/components/VirtualTranscript.js +31 -0
- package/dist/tui/ink/components/VirtualTranscript.js.map +1 -0
- package/dist/tui/ink/index.js +17 -1
- package/dist/tui/ink/index.js.map +1 -1
- package/dist/tui/ink/markdown/syntax-highlight.d.ts +13 -0
- package/dist/tui/ink/markdown/syntax-highlight.js +91 -0
- package/dist/tui/ink/markdown/syntax-highlight.js.map +1 -0
- package/dist/tui/ink/theme-context.js +6 -3
- package/dist/tui/ink/theme-context.js.map +1 -1
- package/dist/tui/ink/use-declined-versions.js +6 -2
- package/dist/tui/ink/use-declined-versions.js.map +1 -1
- package/dist/tui/ink/use-elapsed.d.ts +14 -0
- package/dist/tui/ink/use-elapsed.js +61 -0
- package/dist/tui/ink/use-elapsed.js.map +1 -0
- package/dist/tui/ink/use-event-projection.d.ts +10 -0
- package/dist/tui/ink/use-event-projection.js +111 -12
- package/dist/tui/ink/use-event-projection.js.map +1 -1
- package/dist/tui/ink/use-flicker-detector.d.ts +12 -0
- package/dist/tui/ink/use-flicker-detector.js +37 -0
- package/dist/tui/ink/use-flicker-detector.js.map +1 -0
- package/dist/tui/ink/use-overlays.d.ts +2 -2
- package/dist/tui/ink/use-overlays.js +16 -17
- package/dist/tui/ink/use-overlays.js.map +1 -1
- package/dist/tui/ink/use-render-metrics.d.ts +14 -0
- package/dist/tui/ink/use-render-metrics.js +106 -0
- package/dist/tui/ink/use-render-metrics.js.map +1 -0
- package/dist/tui/ink/use-transcript-scroll.d.ts +19 -0
- package/dist/tui/ink/use-transcript-scroll.js +83 -0
- package/dist/tui/ink/use-transcript-scroll.js.map +1 -0
- package/dist/utils/env.d.ts +1 -0
- package/dist/utils/env.js +60 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/fs.d.ts +10 -0
- package/dist/utils/fs.js +37 -0
- package/dist/utils/fs.js.map +1 -0
- package/package.json +10 -7
|
@@ -3,27 +3,34 @@
|
|
|
3
3
|
* to a Node-native line scan. Always returns file:line:match triples,
|
|
4
4
|
* capped by resultLimit to keep the LLM reply compact.
|
|
5
5
|
*/
|
|
6
|
-
import { spawn } from
|
|
7
|
-
import { readFile, readdir, stat } from
|
|
8
|
-
import {
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
import { readFile, readdir, stat } from "node:fs/promises";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { isValidCwdPath } from "../utils/fs.js";
|
|
9
10
|
const DEFAULT_LIMIT = 200;
|
|
10
11
|
export const searchGrepTool = {
|
|
11
|
-
name:
|
|
12
|
-
description:
|
|
12
|
+
name: "search_grep",
|
|
13
|
+
description: "Search for a regex pattern across files under a directory. Prefers ripgrep when installed.",
|
|
13
14
|
inputSchema: {
|
|
14
|
-
type:
|
|
15
|
+
type: "object",
|
|
15
16
|
properties: {
|
|
16
|
-
pattern: { type:
|
|
17
|
-
path: { type:
|
|
18
|
-
resultLimit: { type:
|
|
19
|
-
ignoreCase: { type:
|
|
20
|
-
filePattern: {
|
|
17
|
+
pattern: { type: "string" },
|
|
18
|
+
path: { type: "string" },
|
|
19
|
+
resultLimit: { type: "integer", minimum: 1 },
|
|
20
|
+
ignoreCase: { type: "boolean" },
|
|
21
|
+
filePattern: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Glob to limit files (ripgrep --glob).",
|
|
24
|
+
},
|
|
21
25
|
},
|
|
22
|
-
required: [
|
|
26
|
+
required: ["pattern"],
|
|
23
27
|
},
|
|
24
28
|
async execute(rawInput, ctx) {
|
|
25
29
|
const input = rawInput;
|
|
26
|
-
const
|
|
30
|
+
const check = isValidCwdPath(ctx.cwd, input.path ?? ".");
|
|
31
|
+
if (!check.valid)
|
|
32
|
+
return { content: check.error, isError: true };
|
|
33
|
+
const root = check.resolved;
|
|
27
34
|
const limit = input.resultLimit ?? DEFAULT_LIMIT;
|
|
28
35
|
const rg = await runRipgrep(input, root, limit);
|
|
29
36
|
if (rg)
|
|
@@ -32,34 +39,51 @@ export const searchGrepTool = {
|
|
|
32
39
|
},
|
|
33
40
|
};
|
|
34
41
|
async function runRipgrep(input, root, limit) {
|
|
35
|
-
const args = [
|
|
42
|
+
const args = [
|
|
43
|
+
"--line-number",
|
|
44
|
+
"--no-heading",
|
|
45
|
+
"--color",
|
|
46
|
+
"never",
|
|
47
|
+
`--max-count=${limit}`,
|
|
48
|
+
];
|
|
36
49
|
if (input.ignoreCase)
|
|
37
|
-
args.push(
|
|
50
|
+
args.push("--ignore-case");
|
|
38
51
|
if (input.filePattern)
|
|
39
|
-
args.push(
|
|
40
|
-
args.push(
|
|
41
|
-
const child = spawn(
|
|
52
|
+
args.push("--glob", input.filePattern);
|
|
53
|
+
args.push("--", input.pattern, root);
|
|
54
|
+
const child = spawn("rg", args, {
|
|
55
|
+
cwd: root,
|
|
56
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
57
|
+
});
|
|
42
58
|
const out = [];
|
|
43
59
|
const errChunks = [];
|
|
44
|
-
child.stdout.on(
|
|
45
|
-
|
|
60
|
+
child.stdout.on("data", (buf) => {
|
|
61
|
+
out.push(buf.toString("utf8"));
|
|
62
|
+
});
|
|
63
|
+
child.stderr.on("data", (buf) => {
|
|
64
|
+
errChunks.push(buf);
|
|
65
|
+
});
|
|
46
66
|
const exitCode = await new Promise((resolveExit, rejectExit) => {
|
|
47
|
-
child.on(
|
|
48
|
-
child.on(
|
|
67
|
+
child.on("error", (err) => rejectExit(err));
|
|
68
|
+
child.on("exit", (code) => resolveExit(code ?? -1));
|
|
49
69
|
}).catch(() => -1);
|
|
70
|
+
const stderrText = Buffer.concat(errChunks)
|
|
71
|
+
.toString("utf8")
|
|
72
|
+
.trim();
|
|
50
73
|
if (exitCode === -1 || exitCode === 2)
|
|
51
74
|
return undefined;
|
|
52
|
-
const joined = out.join(
|
|
53
|
-
const lines = joined.length > 0 ? joined.split(
|
|
75
|
+
const joined = out.join("");
|
|
76
|
+
const lines = joined.length > 0 ? joined.split("\n").filter((l) => l.length > 0) : [];
|
|
54
77
|
const truncated = lines.length >= limit;
|
|
78
|
+
const content = lines.length > 0 ? lines.join("\n") : "(no matches)";
|
|
55
79
|
return {
|
|
56
|
-
content:
|
|
57
|
-
data: { matches: lines.length, truncated, engine:
|
|
80
|
+
content: stderrText ? `${content}\n\n[stderr]\n${stderrText}` : content,
|
|
81
|
+
data: { matches: lines.length, truncated, engine: "ripgrep" },
|
|
58
82
|
isError: false,
|
|
59
83
|
};
|
|
60
84
|
}
|
|
61
85
|
async function nodeScan(input, root, limit) {
|
|
62
|
-
const flags = input.ignoreCase ?
|
|
86
|
+
const flags = input.ignoreCase ? "gi" : "g";
|
|
63
87
|
let regex;
|
|
64
88
|
try {
|
|
65
89
|
regex = new RegExp(input.pattern, flags);
|
|
@@ -76,7 +100,7 @@ async function nodeScan(input, root, limit) {
|
|
|
76
100
|
}
|
|
77
101
|
const names = await readdir(dir).catch(() => []);
|
|
78
102
|
for (const name of names) {
|
|
79
|
-
if (name ===
|
|
103
|
+
if (name === "node_modules" || name === ".git" || name === "dist")
|
|
80
104
|
continue;
|
|
81
105
|
const abs = join(dir, name);
|
|
82
106
|
const info = await stat(abs).catch(() => undefined);
|
|
@@ -85,8 +109,8 @@ async function nodeScan(input, root, limit) {
|
|
|
85
109
|
if (info.isDirectory())
|
|
86
110
|
await walk(abs);
|
|
87
111
|
else if (info.isFile() && info.size < 512 * 1024) {
|
|
88
|
-
const text = await readFile(abs,
|
|
89
|
-
const lines = text.split(
|
|
112
|
+
const text = await readFile(abs, "utf8").catch(() => "");
|
|
113
|
+
const lines = text.split("\n");
|
|
90
114
|
for (let i = 0; i < lines.length; i++) {
|
|
91
115
|
regex.lastIndex = 0; // reset state between tests — global-flag RegExp retains lastIndex
|
|
92
116
|
if (regex.test(lines[i])) {
|
|
@@ -102,8 +126,8 @@ async function nodeScan(input, root, limit) {
|
|
|
102
126
|
}
|
|
103
127
|
await walk(root);
|
|
104
128
|
return {
|
|
105
|
-
content: matches.length > 0 ? matches.join(
|
|
106
|
-
data: { matches: matches.length, truncated, engine:
|
|
129
|
+
content: matches.length > 0 ? matches.join("\n") : "(no matches)",
|
|
130
|
+
data: { matches: matches.length, truncated, engine: "node" },
|
|
107
131
|
isError: false,
|
|
108
132
|
};
|
|
109
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-grep.js","sourceRoot":"","sources":["../../src/tools/search-grep.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"search-grep.js","sour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@@ -7,11 +7,17 @@
|
|
|
7
7
|
* the model does not misread a capped stream as a complete one.
|
|
8
8
|
*
|
|
9
9
|
* Platform routing (1.13.0):
|
|
10
|
-
* posix → spawn(
|
|
10
|
+
* posix → spawn('/bin/sh', ['-c', command])
|
|
11
11
|
* win32 → prefer pwsh > powershell > cmd.exe via env detection;
|
|
12
12
|
* fall back to cmd if PowerShell isn't on PATH. PowerShell
|
|
13
13
|
* handles quoting + UTF-8 + multi-line scripts more cleanly
|
|
14
14
|
* than cmd.exe's relic Windows-95 parser.
|
|
15
|
+
*
|
|
16
|
+
* Streaming mode (1.14.0):
|
|
17
|
+
* When `streamOutput: true` is passed, each stdout/stderr chunk is
|
|
18
|
+
* forwarded to `ctx.onProgress` as it arrives so the TUI can display
|
|
19
|
+
* live output. Accumulated output is still returned in the final
|
|
20
|
+
* ToolResult for the model. Backwards-compatible: default is false.
|
|
15
21
|
*/
|
|
16
22
|
import type { Tool } from "./registry.js";
|
|
17
23
|
export declare const shellTool: Tool;
|
package/dist/tools/shell.js
CHANGED
|
@@ -7,45 +7,60 @@
|
|
|
7
7
|
* the model does not misread a capped stream as a complete one.
|
|
8
8
|
*
|
|
9
9
|
* Platform routing (1.13.0):
|
|
10
|
-
* posix → spawn(
|
|
10
|
+
* posix → spawn('/bin/sh', ['-c', command])
|
|
11
11
|
* win32 → prefer pwsh > powershell > cmd.exe via env detection;
|
|
12
12
|
* fall back to cmd if PowerShell isn't on PATH. PowerShell
|
|
13
13
|
* handles quoting + UTF-8 + multi-line scripts more cleanly
|
|
14
14
|
* than cmd.exe's relic Windows-95 parser.
|
|
15
|
+
*
|
|
16
|
+
* Streaming mode (1.14.0):
|
|
17
|
+
* When `streamOutput: true` is passed, each stdout/stderr chunk is
|
|
18
|
+
* forwarded to `ctx.onProgress` as it arrives so the TUI can display
|
|
19
|
+
* live output. Accumulated output is still returned in the final
|
|
20
|
+
* ToolResult for the model. Backwards-compatible: default is false.
|
|
15
21
|
*/
|
|
16
|
-
import { spawn,
|
|
17
|
-
|
|
22
|
+
import { spawn, execFile } from "node:child_process";
|
|
23
|
+
import { StringDecoder } from "node:string_decoder";
|
|
24
|
+
import { resolve, sep } from "node:path";
|
|
25
|
+
import { promisify } from "node:util";
|
|
26
|
+
const execFileAsync = promisify(execFile);
|
|
27
|
+
/** Cached PowerShell executable detection (probed async at first use). */
|
|
18
28
|
let cachedWindowsShell = null;
|
|
19
|
-
|
|
29
|
+
let windowsShellPromise = null;
|
|
30
|
+
async function resolveWindowsShell() {
|
|
20
31
|
if (cachedWindowsShell)
|
|
21
32
|
return cachedWindowsShell;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
if (!windowsShellPromise) {
|
|
34
|
+
windowsShellPromise = (async () => {
|
|
35
|
+
for (const exe of ["pwsh", "powershell"]) {
|
|
36
|
+
try {
|
|
37
|
+
await execFileAsync(exe, ["-NoLogo", "-Command", "exit 0"], {
|
|
38
|
+
timeout: 3000,
|
|
39
|
+
});
|
|
40
|
+
cachedWindowsShell = {
|
|
41
|
+
cmd: exe,
|
|
42
|
+
args: (script) => [
|
|
43
|
+
"-NoLogo",
|
|
44
|
+
"-NoProfile",
|
|
45
|
+
"-NonInteractive",
|
|
46
|
+
"-OutputFormat",
|
|
47
|
+
"Text",
|
|
48
|
+
"-Command",
|
|
49
|
+
script,
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
return cachedWindowsShell;
|
|
53
|
+
}
|
|
54
|
+
catch { }
|
|
55
|
+
}
|
|
28
56
|
cachedWindowsShell = {
|
|
29
|
-
cmd: exe,
|
|
30
|
-
args: (script) => [
|
|
31
|
-
"-NoLogo",
|
|
32
|
-
"-NoProfile",
|
|
33
|
-
"-NonInteractive",
|
|
34
|
-
"-OutputFormat",
|
|
35
|
-
"Text",
|
|
36
|
-
"-Command",
|
|
37
|
-
script,
|
|
38
|
-
],
|
|
57
|
+
cmd: process.env.ComSpec ?? "cmd.exe",
|
|
58
|
+
args: (script) => ["/d", "/s", "/c", script],
|
|
39
59
|
};
|
|
40
60
|
return cachedWindowsShell;
|
|
41
|
-
}
|
|
61
|
+
})();
|
|
42
62
|
}
|
|
43
|
-
|
|
44
|
-
cachedWindowsShell = {
|
|
45
|
-
cmd: process.env.ComSpec ?? "cmd.exe",
|
|
46
|
-
args: (script) => ["/d", "/s", "/c", script],
|
|
47
|
-
};
|
|
48
|
-
return cachedWindowsShell;
|
|
63
|
+
return windowsShellPromise;
|
|
49
64
|
}
|
|
50
65
|
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
51
66
|
const MAX_OUTPUT_BYTES = 256 * 1024;
|
|
@@ -59,7 +74,19 @@ export const shellTool = {
|
|
|
59
74
|
properties: {
|
|
60
75
|
command: { type: "string" },
|
|
61
76
|
cwd: { type: "string" },
|
|
62
|
-
timeoutMs: {
|
|
77
|
+
timeoutMs: {
|
|
78
|
+
type: "integer",
|
|
79
|
+
minimum: 1000,
|
|
80
|
+
description: "Hard timeout in milliseconds (default 120 000). On expiry the child " +
|
|
81
|
+
"receives SIGTERM then SIGKILL after 2 s.",
|
|
82
|
+
},
|
|
83
|
+
streamOutput: {
|
|
84
|
+
type: "boolean",
|
|
85
|
+
description: "When true, forward each output chunk to the progress bus so the " +
|
|
86
|
+
"TUI can display live output while the command runs. " +
|
|
87
|
+
"Accumulated output is still returned in the final result. " +
|
|
88
|
+
"Default: false.",
|
|
89
|
+
},
|
|
63
90
|
},
|
|
64
91
|
required: ["command"],
|
|
65
92
|
},
|
|
@@ -69,39 +96,106 @@ export const shellTool = {
|
|
|
69
96
|
const input = rawInput;
|
|
70
97
|
const cwd = input.cwd ?? ctx.cwd;
|
|
71
98
|
const timeoutMs = input.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
99
|
+
const streamOutput = input.streamOutput ?? false;
|
|
100
|
+
if (cwd !== ctx.cwd) {
|
|
101
|
+
const resolved = resolve(cwd);
|
|
102
|
+
const base = resolve(ctx.cwd);
|
|
103
|
+
const baseSep = base.endsWith(sep) ? base : base + sep;
|
|
104
|
+
if (resolved !== base && !resolved.startsWith(baseSep)) {
|
|
105
|
+
return { content: `cwd escapes workspace: ${cwd}`, isError: true };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Sandbox routing — when the user enabled `auto` or `strict` mode
|
|
109
|
+
// via `/sandbox`, forward the command to the platform sandbox
|
|
110
|
+
// adapter (bwrap / sandbox-exec / Job Object) so the spawned
|
|
111
|
+
// child can only write inside `cwd`. `strict` additionally bans
|
|
112
|
+
// network. `off` keeps the legacy direct-spawn path below.
|
|
113
|
+
const sandboxActive = (ctx.sandboxMode === "auto" || ctx.sandboxMode === "strict") &&
|
|
114
|
+
ctx.sandbox !== null;
|
|
115
|
+
const sandbox = ctx.sandbox;
|
|
116
|
+
if (sandboxActive &&
|
|
117
|
+
sandbox !== null &&
|
|
118
|
+
(await sandbox.available().catch(() => false))) {
|
|
119
|
+
const cmd = process.platform === "win32"
|
|
120
|
+
? (await resolveWindowsShell()).args(input.command)
|
|
121
|
+
: ["/bin/sh", "-c", input.command];
|
|
122
|
+
const fullCmd = process.platform === "win32"
|
|
123
|
+
? [(await resolveWindowsShell()).cmd, ...cmd]
|
|
124
|
+
: cmd;
|
|
125
|
+
try {
|
|
126
|
+
const result = await sandbox.exec({
|
|
127
|
+
command: fullCmd,
|
|
128
|
+
cwd,
|
|
129
|
+
env: ctx.env,
|
|
130
|
+
writablePaths: [cwd],
|
|
131
|
+
networkAllowed: ctx.sandboxMode !== "strict",
|
|
132
|
+
timeoutMs,
|
|
133
|
+
signal: ctx.signal,
|
|
134
|
+
});
|
|
135
|
+
const stdout = result.stdout.length > MAX_OUTPUT_BYTES
|
|
136
|
+
? result.stdout.slice(0, MAX_OUTPUT_BYTES)
|
|
137
|
+
: result.stdout;
|
|
138
|
+
const stderr = result.stderr.length > MAX_OUTPUT_BYTES
|
|
139
|
+
? result.stderr.slice(0, MAX_OUTPUT_BYTES)
|
|
140
|
+
: result.stderr;
|
|
141
|
+
const truncated = result.stdout.length > MAX_OUTPUT_BYTES ||
|
|
142
|
+
result.stderr.length > MAX_OUTPUT_BYTES;
|
|
143
|
+
const sandboxLabel = `[sandbox: ${result.platform}/${ctx.sandboxMode}]`;
|
|
144
|
+
const content = [
|
|
145
|
+
sandboxLabel,
|
|
146
|
+
stdout && `STDOUT:\n${stdout}`,
|
|
147
|
+
stderr && `STDERR:\n${stderr}`,
|
|
148
|
+
`Exit: ${result.exitCode}${result.timedOut ? " (timeout)" : ""}`,
|
|
149
|
+
truncated && "(output truncated)",
|
|
150
|
+
]
|
|
151
|
+
.filter(Boolean)
|
|
152
|
+
.join("\n\n") || sandboxLabel;
|
|
153
|
+
return {
|
|
154
|
+
content,
|
|
155
|
+
isError: result.exitCode !== 0,
|
|
156
|
+
data: {
|
|
157
|
+
exitCode: result.exitCode,
|
|
158
|
+
stdoutBytes: stdout.length,
|
|
159
|
+
stderrBytes: stderr.length,
|
|
160
|
+
truncated,
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
166
|
+
return {
|
|
167
|
+
content: `Sandbox exec failed (${ctx.sandboxMode}): ${msg}`,
|
|
168
|
+
isError: true,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
81
172
|
const child = process.platform === "win32"
|
|
82
|
-
? (() => {
|
|
83
|
-
const shell = resolveWindowsShell();
|
|
173
|
+
? (async () => {
|
|
174
|
+
const shell = await resolveWindowsShell();
|
|
84
175
|
return spawn(shell.cmd, shell.args(input.command), {
|
|
85
176
|
cwd,
|
|
86
177
|
env: ctx.env,
|
|
87
|
-
stdio: ["
|
|
178
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
88
179
|
windowsHide: true,
|
|
89
180
|
});
|
|
90
181
|
})()
|
|
91
|
-
: spawn(input.command, {
|
|
182
|
+
: spawn("/bin/sh", ["-c", input.command], {
|
|
92
183
|
cwd,
|
|
93
184
|
env: ctx.env,
|
|
94
|
-
stdio: ["
|
|
95
|
-
shell: true,
|
|
185
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
96
186
|
});
|
|
187
|
+
const childProcess = await (child instanceof Promise
|
|
188
|
+
? child
|
|
189
|
+
: Promise.resolve(child));
|
|
97
190
|
const stdoutChunks = [];
|
|
98
191
|
const stderrChunks = [];
|
|
99
192
|
let stdoutBytes = 0;
|
|
100
193
|
let stderrBytes = 0;
|
|
101
194
|
let truncated = false;
|
|
102
|
-
// Shared total so combined stdout+stderr never exceeds MAX_OUTPUT_BYTES.
|
|
103
195
|
let totalBytes = 0;
|
|
104
|
-
const
|
|
196
|
+
const stdoutDecoder = new StringDecoder("utf8");
|
|
197
|
+
const stderrDecoder = new StringDecoder("utf8");
|
|
198
|
+
const onData = (chunks, decoder, trackBytes, label) => (buf) => {
|
|
105
199
|
const remaining = MAX_OUTPUT_BYTES - totalBytes;
|
|
106
200
|
if (remaining <= 0) {
|
|
107
201
|
truncated = true;
|
|
@@ -113,30 +207,53 @@ export const shellTool = {
|
|
|
113
207
|
trackBytes(slice.length);
|
|
114
208
|
if (buf.length > remaining)
|
|
115
209
|
truncated = true;
|
|
116
|
-
const text =
|
|
117
|
-
if (text.trim().length > 0)
|
|
118
|
-
|
|
210
|
+
const text = decoder.write(slice);
|
|
211
|
+
if (text.trim().length > 0) {
|
|
212
|
+
// In streaming mode forward every non-empty chunk immediately;
|
|
213
|
+
// in non-streaming mode the existing behaviour is preserved
|
|
214
|
+
// (progress is still emitted so the TUI spinner stays alive,
|
|
215
|
+
// but callers that don't pass onProgress see no difference).
|
|
216
|
+
if (streamOutput) {
|
|
217
|
+
ctx.onProgress?.(label === "STDERR" ? `[stderr] ${text.trimEnd()}` : text.trimEnd());
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
ctx.onProgress?.(text.trimEnd());
|
|
221
|
+
}
|
|
222
|
+
}
|
|
119
223
|
};
|
|
120
|
-
|
|
224
|
+
childProcess.stdout.on("data", onData(stdoutChunks, stdoutDecoder, (n) => {
|
|
121
225
|
stdoutBytes += n;
|
|
122
|
-
}));
|
|
123
|
-
|
|
226
|
+
}, "STDOUT"));
|
|
227
|
+
childProcess.stderr.on("data", onData(stderrChunks, stderrDecoder, (n) => {
|
|
124
228
|
stderrBytes += n;
|
|
125
|
-
}));
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
229
|
+
}, "STDERR"));
|
|
230
|
+
/** Gracefully terminate: SIGTERM, then SIGKILL after 2 s. */
|
|
231
|
+
const killChild = () => {
|
|
232
|
+
childProcess.kill("SIGTERM");
|
|
233
|
+
setTimeout(() => {
|
|
234
|
+
try {
|
|
235
|
+
childProcess.kill("SIGKILL");
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
/* already gone */
|
|
239
|
+
}
|
|
240
|
+
}, 2_000);
|
|
241
|
+
};
|
|
242
|
+
const timer = setTimeout(killChild, timeoutMs);
|
|
130
243
|
const onAbort = () => {
|
|
131
|
-
|
|
244
|
+
killChild();
|
|
132
245
|
};
|
|
133
|
-
ctx.signal
|
|
246
|
+
if (ctx.signal) {
|
|
247
|
+
ctx.signal.addEventListener("abort", onAbort, { once: true });
|
|
248
|
+
}
|
|
134
249
|
const exitCode = await new Promise((resolveExit) => {
|
|
135
|
-
|
|
136
|
-
|
|
250
|
+
childProcess.once("error", () => resolveExit(-1));
|
|
251
|
+
childProcess.once("close", (code) => resolveExit(code ?? -1));
|
|
137
252
|
});
|
|
138
253
|
clearTimeout(timer);
|
|
139
|
-
ctx.signal
|
|
254
|
+
if (ctx.signal) {
|
|
255
|
+
ctx.signal.removeEventListener("abort", onAbort);
|
|
256
|
+
}
|
|
140
257
|
const stdout = Buffer.concat(stdoutChunks).toString("utf8");
|
|
141
258
|
const stderr = Buffer.concat(stderrChunks).toString("utf8");
|
|
142
259
|
const banner = `exit=${exitCode}${truncated ? " [output truncated]" : ""}`;
|
package/dist/tools/shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/tools/shell.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/tools/shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAU1C,0EAA0E;AAC1E,IAAI,kBAAkB,GAGX,IAAI,CAAC;AAChB,IAAI,mBAAmB,GAGX,IAAI,CAAC;AAEjB,KAAK,UAAU,mBAAmB;IAIhC,IAAI,kBAAkB;QAAE,OAAO,kBAAkB,CAAC;IAClD,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,mBAAmB,GAAG,CAAC,KAAK,IAAI,EAAE;YAChC,KAAK,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;gBACzC,IAAI,CAAC;oBACH,MAAM,aAAa,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE;wBAC1D,OAAO,EAAE,IAAI;qBACd,CAAC,CAAC;oBACH,kBAAkB,GAAG;wBACnB,GAAG,EAAE,GAAG;wBACR,IAAI,EAAE,CAAC,MAAc,EAAY,EAAE,CAAC;4BAClC,SAAS;4BACT,YA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AAC,MAAM,CAAC,CAAC;QACnB,MAAM,MAAM,GAAG,QAAQ,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC3E,MAAM,IAAI,GAAG;YACX,MAAM;YACN,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;YAC7C,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;SAC9C;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,MAAM,CAAC,CAAC;QAEhB,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;YACxC,IAAI,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE;YACvD,OAAO,EAAE,QAAQ,KAAK,CAAC;SACxB,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* transactional_write tool — atomic multi-model write across all four
|
|
3
|
+
* data shapes (relational + FTS + vector + graph).
|
|
4
|
+
*
|
|
5
|
+
* Accepts an optional message, embedding, graph nodes, and graph edges
|
|
6
|
+
* in a single tool call. Everything commits or nothing does — the agent
|
|
7
|
+
* gets a true per-session ACID guarantee.
|
|
8
|
+
*/
|
|
9
|
+
import type { Tool } from "./registry.js";
|
|
10
|
+
export declare const transactionalWriteTool: Tool;
|