maestro-agent-sdk 0.1.8 → 0.1.11
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/core/is-abort-error.d.ts +8 -0
- package/dist/core/is-abort-error.d.ts.map +1 -0
- package/dist/core/is-abort-error.js +17 -0
- package/dist/core/is-abort-error.js.map +1 -0
- package/dist/core/loop.d.ts.map +1 -1
- package/dist/core/loop.js +37 -1
- package/dist/core/loop.js.map +1 -1
- package/dist/platform/version.d.ts +1 -1
- package/dist/platform/version.d.ts.map +1 -1
- package/dist/platform/version.js +1 -1
- package/dist/platform/version.js.map +1 -1
- package/dist/provider.d.ts +2 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +7 -10
- package/dist/provider.js.map +1 -1
- package/dist/registry.js +6 -6
- package/dist/registry.js.map +1 -1
- package/dist/sub-agent/runner.d.ts +1 -1
- package/dist/sub-agent/runner.d.ts.map +1 -1
- package/dist/sub-agent/runner.js +34 -23
- package/dist/sub-agent/runner.js.map +1 -1
- package/dist/tools/builtin/agent.d.ts +19 -7
- package/dist/tools/builtin/agent.d.ts.map +1 -1
- package/dist/tools/builtin/agent.js +13 -4
- package/dist/tools/builtin/agent.js.map +1 -1
- package/dist/tools/builtin/bash.d.ts +68 -3
- package/dist/tools/builtin/bash.d.ts.map +1 -1
- package/dist/tools/builtin/bash.js +224 -94
- package/dist/tools/builtin/bash.js.map +1 -1
- package/dist/tools/builtin/edit.d.ts.map +1 -1
- package/dist/tools/builtin/edit.js +8 -2
- package/dist/tools/builtin/edit.js.map +1 -1
- package/dist/tools/builtin/glob.d.ts +8 -4
- package/dist/tools/builtin/glob.d.ts.map +1 -1
- package/dist/tools/builtin/glob.js +105 -17
- package/dist/tools/builtin/glob.js.map +1 -1
- package/dist/tools/builtin/multi_edit.d.ts +16 -0
- package/dist/tools/builtin/multi_edit.d.ts.map +1 -0
- package/dist/tools/builtin/multi_edit.js +292 -0
- package/dist/tools/builtin/multi_edit.js.map +1 -0
- package/dist/tools/builtin/write.d.ts.map +1 -1
- package/dist/tools/builtin/write.js +8 -2
- package/dist/tools/builtin/write.js.map +1 -1
- package/dist/tools/file-state.d.ts +1 -1
- package/dist/tools/file-state.d.ts.map +1 -1
- package/dist/tools/file-state.js.map +1 -1
- package/dist/tools/path-guard.d.ts +23 -0
- package/dist/tools/path-guard.d.ts.map +1 -0
- package/dist/tools/path-guard.js +52 -0
- package/dist/tools/path-guard.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,18 +1,83 @@
|
|
|
1
1
|
import type { ToolHandler } from "../../tools/registry.js";
|
|
2
|
+
export declare function createBashTool(opts?: {
|
|
3
|
+
signal?: AbortSignal;
|
|
4
|
+
}): ToolHandler;
|
|
2
5
|
/**
|
|
3
6
|
* Bash tool — built-in subprocess executor.
|
|
4
7
|
*
|
|
5
8
|
* Minimal: shell out, capture stdout/stderr, enforce a wall-clock timeout
|
|
6
|
-
* (30s default, model-overridable up to 10min) and
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
+
* (30s default, model-overridable up to 10min) and an output cap per stream
|
|
10
|
+
* (50KB default, model-overridable up to 100KB). Not a permission-gated
|
|
11
|
+
* execution layer — hosts that need one should register an MCP terminal
|
|
12
|
+
* tool (or replace this with their own adapter via
|
|
9
13
|
* `ToolRegistry.register`) so subprocess calls flow through the host's
|
|
10
14
|
* existing permission system instead of an unguarded `spawn`.
|
|
11
15
|
*
|
|
16
|
+
* Truncation policy (NEW in v0.1.9):
|
|
17
|
+
* When a stream exceeds the cap we keep BOTH the head (first half) AND the
|
|
18
|
+
* tail (last half), with a `[truncated N bytes]` marker between them.
|
|
19
|
+
* Previous behaviour kept only the head and destroyed the stream — which
|
|
20
|
+
* lost the bottom of `bun install` / `pytest` / `cargo build` output where
|
|
21
|
+
* the actual error message lives. The ring buffer below keeps the cap
|
|
22
|
+
* bounded (head_cap + tail_cap = max) while letting unlimited bytes flow
|
|
23
|
+
* through.
|
|
24
|
+
*
|
|
12
25
|
* The `description` input field is accepted for claude-SDK parity. We don't
|
|
13
26
|
* store it anywhere — its presence in the schema is what matters: the model's
|
|
14
27
|
* pretrained instinct to emit a short rationale per Bash call survives the
|
|
15
28
|
* agent switch, which is what permission UIs / audit logs want to render.
|
|
16
29
|
*/
|
|
17
30
|
export declare const bashTool: ToolHandler;
|
|
31
|
+
/** Named schema export so the provider can reference it
|
|
32
|
+
* without instantiating a full tool registry. */
|
|
33
|
+
export declare const bashToolSchema: {
|
|
34
|
+
readonly name: "Bash";
|
|
35
|
+
readonly description: string;
|
|
36
|
+
readonly input_schema: {
|
|
37
|
+
readonly type: "object";
|
|
38
|
+
readonly properties: {
|
|
39
|
+
readonly command: {
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
readonly description: "Bash command to execute.";
|
|
42
|
+
};
|
|
43
|
+
readonly description: {
|
|
44
|
+
readonly type: "string";
|
|
45
|
+
readonly description: string;
|
|
46
|
+
};
|
|
47
|
+
readonly timeout: {
|
|
48
|
+
readonly type: "number";
|
|
49
|
+
readonly description: string;
|
|
50
|
+
};
|
|
51
|
+
readonly max_output_bytes: {
|
|
52
|
+
readonly type: "number";
|
|
53
|
+
readonly description: string;
|
|
54
|
+
};
|
|
55
|
+
readonly cwd: {
|
|
56
|
+
readonly type: "string";
|
|
57
|
+
readonly description: "Working directory (optional).";
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
readonly required: readonly ["command"];
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Two-ended output buffer that keeps the first `headCap` bytes and the last
|
|
65
|
+
* `tailCap` bytes of an unbounded stream. Bytes between those two windows
|
|
66
|
+
* are counted (so we can report `truncated N bytes`) but not stored.
|
|
67
|
+
*
|
|
68
|
+
* Total bytes resident in memory are bounded by `cap` regardless of how
|
|
69
|
+
* much stream data flows through. The buffer accepts incremental `append`
|
|
70
|
+
* calls (matching the `data` event shape of a Node readable stream).
|
|
71
|
+
*/
|
|
72
|
+
interface OutputRing {
|
|
73
|
+
append(text: string): void;
|
|
74
|
+
render(): string;
|
|
75
|
+
truncated(): boolean;
|
|
76
|
+
}
|
|
77
|
+
export declare function createOutputRing(cap: number): OutputRing;
|
|
78
|
+
export declare const __BASH_MAX_OUTPUT_DEFAULT = 50000;
|
|
79
|
+
export declare const __BASH_MAX_OUTPUT_HARD = 100000;
|
|
80
|
+
export declare const __BASH_TIMEOUT_MS = 30000;
|
|
81
|
+
export declare const __BASH_TIMEOUT_MAX_MS: number;
|
|
82
|
+
export {};
|
|
18
83
|
//# sourceMappingURL=bash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/tools/builtin/bash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/tools/builtin/bash.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA4DpD,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GAAG,WAAW,CAW3E;AAwGD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,QAAQ,EAAE,WAA8B,CAAC;AAEtD;kDACkD;AAClD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAa,CAAC;AAEzC;;;;;;;;GAQG;AACH,UAAU,UAAU;IAClB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,IAAI,MAAM,CAAC;IACjB,SAAS,IAAI,OAAO,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CA8DxD;AAQD,eAAO,MAAM,yBAAyB,QAA0B,CAAC;AACjE,eAAO,MAAM,sBAAsB,SAAuB,CAAC;AAC3D,eAAO,MAAM,iBAAiB,QAAkB,CAAC;AACjD,eAAO,MAAM,qBAAqB,QAAsB,CAAC"}
|
|
@@ -1,124 +1,254 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
timeout: {
|
|
45
|
-
type: "number",
|
|
46
|
-
description: "Wall-clock timeout in milliseconds. Defaults to 30000 (30s). " +
|
|
47
|
-
"Clamped to a hard ceiling of 600000 (10min). Use a higher value " +
|
|
48
|
-
"for slow tests, installs, or builds.",
|
|
49
|
-
},
|
|
50
|
-
cwd: {
|
|
51
|
-
type: "string",
|
|
52
|
-
description: "Working directory (optional).",
|
|
53
|
-
},
|
|
2
|
+
import { isAbsolute, normalize } from "node:path";
|
|
3
|
+
/** Shared Bash schema — extracted as a named constant so both the bare
|
|
4
|
+
* export (`bashTool`) and the factory (`createBashTool`) reference the
|
|
5
|
+
* same object without a forward-reference problem. */
|
|
6
|
+
const bashSchema = {
|
|
7
|
+
name: "Bash",
|
|
8
|
+
description: "Execute a bash command and return stdout/stderr. Default 30s timeout " +
|
|
9
|
+
"(override via `timeout`, max 10min). 50KB output cap per stream by default " +
|
|
10
|
+
"(override via `max_output_bytes`, max 100KB). When a stream exceeds the " +
|
|
11
|
+
"cap both head and tail are preserved with a `[truncated N bytes]` marker " +
|
|
12
|
+
"between them — keeps the trailing error/summary visible. Optional " +
|
|
13
|
+
"`description` is recorded for audit/UI and otherwise ignored.",
|
|
14
|
+
input_schema: {
|
|
15
|
+
type: "object",
|
|
16
|
+
properties: {
|
|
17
|
+
command: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "Bash command to execute.",
|
|
20
|
+
},
|
|
21
|
+
description: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Short human-readable rationale for the command (~5-10 words). " +
|
|
24
|
+
"Accepted for claude-SDK parity — surfaces in permission UIs / " +
|
|
25
|
+
"audit logs. Ignored by execution.",
|
|
26
|
+
},
|
|
27
|
+
timeout: {
|
|
28
|
+
type: "number",
|
|
29
|
+
description: "Wall-clock timeout in milliseconds. Defaults to 30000 (30s). " +
|
|
30
|
+
"Clamped to a hard ceiling of 600000 (10min). Use a higher value " +
|
|
31
|
+
"for slow tests, installs, or builds.",
|
|
32
|
+
},
|
|
33
|
+
max_output_bytes: {
|
|
34
|
+
type: "number",
|
|
35
|
+
description: "Per-stream output cap in bytes. Defaults to 50000 (50KB). Clamped " +
|
|
36
|
+
"to a hard ceiling of 100000 (100KB). Exceeding bytes are dropped " +
|
|
37
|
+
"from the middle — head and tail are preserved with a " +
|
|
38
|
+
"`[truncated N bytes]` marker between them.",
|
|
39
|
+
},
|
|
40
|
+
cwd: {
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "Working directory (optional).",
|
|
54
43
|
},
|
|
55
|
-
required: ["command"],
|
|
56
44
|
},
|
|
45
|
+
required: ["command"],
|
|
57
46
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
};
|
|
48
|
+
// ───────────────────────────────────────────────
|
|
49
|
+
// Factory — wraps the shared shell-out logic with
|
|
50
|
+
// an AbortSignal so the sub-agent runner can wire
|
|
51
|
+
// parent abort through to `spawn({ signal })`.
|
|
52
|
+
//
|
|
53
|
+
// Usage in runner.ts:
|
|
54
|
+
// tools.register(createBashTool({ signal: abortSignal }));
|
|
55
|
+
// ───────────────────────────────────────────────
|
|
56
|
+
export function createBashTool(opts) {
|
|
57
|
+
const parentSignal = opts?.signal;
|
|
58
|
+
return {
|
|
59
|
+
schema: bashSchema,
|
|
60
|
+
async execute(input) {
|
|
61
|
+
if (parentSignal?.aborted) {
|
|
62
|
+
return JSON.stringify({ error: "aborted" });
|
|
63
|
+
}
|
|
64
|
+
return executeBash(input, parentSignal);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** Shared execute logic — used by both the factory wrapper and the bare export. */
|
|
69
|
+
async function executeBash(input, abortSignal) {
|
|
70
|
+
const command = String(input.command ?? "");
|
|
71
|
+
if (!command.trim()) {
|
|
72
|
+
return JSON.stringify({ error: "empty command" });
|
|
73
|
+
}
|
|
74
|
+
let cwd = typeof input.cwd === "string" ? input.cwd : undefined;
|
|
75
|
+
if (cwd !== undefined) {
|
|
76
|
+
cwd = normalize(cwd);
|
|
77
|
+
if (!isAbsolute(cwd)) {
|
|
78
|
+
return JSON.stringify({
|
|
79
|
+
error: `Bash: 'cwd' must be an absolute path, got '${cwd}'`,
|
|
80
|
+
});
|
|
62
81
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
82
|
+
}
|
|
83
|
+
const rawTimeout = input.timeout;
|
|
84
|
+
const timeoutMs = typeof rawTimeout === "number" && Number.isFinite(rawTimeout) && rawTimeout > 0
|
|
85
|
+
? Math.min(Math.floor(rawTimeout), BASH_TIMEOUT_MAX_MS)
|
|
86
|
+
: BASH_TIMEOUT_MS;
|
|
87
|
+
const rawMaxOutput = input.max_output_bytes;
|
|
88
|
+
const maxOutputBytes = typeof rawMaxOutput === "number" && Number.isFinite(rawMaxOutput) && rawMaxOutput > 0
|
|
89
|
+
? Math.min(Math.floor(rawMaxOutput), BASH_MAX_OUTPUT_HARD)
|
|
90
|
+
: BASH_MAX_OUTPUT_DEFAULT;
|
|
91
|
+
const stdoutRing = createOutputRing(maxOutputBytes);
|
|
92
|
+
const stderrRing = createOutputRing(maxOutputBytes);
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
try {
|
|
71
95
|
const child = spawn("bash", ["-c", command], {
|
|
72
96
|
...(cwd ? { cwd } : {}),
|
|
97
|
+
...(abortSignal ? { signal: abortSignal } : {}),
|
|
73
98
|
env: process.env,
|
|
74
99
|
});
|
|
75
|
-
let stdout = "";
|
|
76
|
-
let stderr = "";
|
|
77
|
-
let truncated = false;
|
|
78
100
|
const timer = setTimeout(() => {
|
|
79
101
|
child.kill("SIGKILL");
|
|
80
102
|
resolve(JSON.stringify({
|
|
81
103
|
error: `timeout after ${timeoutMs}ms`,
|
|
82
|
-
stdout,
|
|
83
|
-
stderr,
|
|
104
|
+
stdout: stdoutRing.render(),
|
|
105
|
+
stderr: stderrRing.render(),
|
|
106
|
+
...truncatedFlag(stdoutRing, stderrRing),
|
|
84
107
|
}));
|
|
85
108
|
}, timeoutMs);
|
|
86
109
|
child.stdout?.on("data", (chunk) => {
|
|
87
|
-
|
|
88
|
-
if (stdout.length + text.length > BASH_MAX_OUTPUT) {
|
|
89
|
-
stdout += text.slice(0, BASH_MAX_OUTPUT - stdout.length);
|
|
90
|
-
truncated = true;
|
|
91
|
-
child.stdout?.destroy();
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
stdout += text;
|
|
95
|
-
}
|
|
110
|
+
stdoutRing.append(chunk.toString("utf-8"));
|
|
96
111
|
});
|
|
97
112
|
child.stderr?.on("data", (chunk) => {
|
|
98
|
-
|
|
99
|
-
if (stderr.length + text.length > BASH_MAX_OUTPUT) {
|
|
100
|
-
stderr += text.slice(0, BASH_MAX_OUTPUT - stderr.length);
|
|
101
|
-
truncated = true;
|
|
102
|
-
child.stderr?.destroy();
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
stderr += text;
|
|
106
|
-
}
|
|
113
|
+
stderrRing.append(chunk.toString("utf-8"));
|
|
107
114
|
});
|
|
108
115
|
child.on("close", (code) => {
|
|
109
116
|
clearTimeout(timer);
|
|
110
117
|
resolve(JSON.stringify({
|
|
111
118
|
exitCode: code,
|
|
112
|
-
stdout,
|
|
113
|
-
stderr,
|
|
114
|
-
...(
|
|
119
|
+
stdout: stdoutRing.render(),
|
|
120
|
+
stderr: stderrRing.render(),
|
|
121
|
+
...truncatedFlag(stdoutRing, stderrRing),
|
|
115
122
|
}));
|
|
116
123
|
});
|
|
117
124
|
child.on("error", (err) => {
|
|
118
125
|
clearTimeout(timer);
|
|
119
126
|
resolve(JSON.stringify({ error: err.message }));
|
|
120
127
|
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
// Synchronous throw from spawn (e.g. invalid options) — reject
|
|
131
|
+
// rather than letting the Promise hang unresolved.
|
|
132
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/** Default wall-clock cap. The model can override via the `timeout` input
|
|
137
|
+
* field — useful for slow tests, builds, installs — capped at `BASH_TIMEOUT_MAX_MS`
|
|
138
|
+
* so a runaway can't pin the runtime indefinitely. */
|
|
139
|
+
const BASH_TIMEOUT_MS = 30_000;
|
|
140
|
+
/** Hard ceiling on caller-supplied `timeout`. 10 minutes matches claude SDK's
|
|
141
|
+
* documented cap and is plenty for `npm install` / `bun install` / test runs. */
|
|
142
|
+
const BASH_TIMEOUT_MAX_MS = 10 * 60_000;
|
|
143
|
+
/** Default output cap per stream (stdout & stderr each). Up from v0.1.8's
|
|
144
|
+
* 16KB so ordinary `npm install` / build logs fit in one shot. Most real
|
|
145
|
+
* installs land between 20–35KB, so 50KB covers ~90% of cases without
|
|
146
|
+
* truncation. */
|
|
147
|
+
const BASH_MAX_OUTPUT_DEFAULT = 50_000;
|
|
148
|
+
/** Absolute ceiling on caller-supplied `max_output_bytes`. 100KB is enough
|
|
149
|
+
* for any reasonable build log; pathological output past this point should
|
|
150
|
+
* be redirected to a file and Read'd in slices anyway. */
|
|
151
|
+
const BASH_MAX_OUTPUT_HARD = 100_000;
|
|
152
|
+
/**
|
|
153
|
+
* Bash tool — built-in subprocess executor.
|
|
154
|
+
*
|
|
155
|
+
* Minimal: shell out, capture stdout/stderr, enforce a wall-clock timeout
|
|
156
|
+
* (30s default, model-overridable up to 10min) and an output cap per stream
|
|
157
|
+
* (50KB default, model-overridable up to 100KB). Not a permission-gated
|
|
158
|
+
* execution layer — hosts that need one should register an MCP terminal
|
|
159
|
+
* tool (or replace this with their own adapter via
|
|
160
|
+
* `ToolRegistry.register`) so subprocess calls flow through the host's
|
|
161
|
+
* existing permission system instead of an unguarded `spawn`.
|
|
162
|
+
*
|
|
163
|
+
* Truncation policy (NEW in v0.1.9):
|
|
164
|
+
* When a stream exceeds the cap we keep BOTH the head (first half) AND the
|
|
165
|
+
* tail (last half), with a `[truncated N bytes]` marker between them.
|
|
166
|
+
* Previous behaviour kept only the head and destroyed the stream — which
|
|
167
|
+
* lost the bottom of `bun install` / `pytest` / `cargo build` output where
|
|
168
|
+
* the actual error message lives. The ring buffer below keeps the cap
|
|
169
|
+
* bounded (head_cap + tail_cap = max) while letting unlimited bytes flow
|
|
170
|
+
* through.
|
|
171
|
+
*
|
|
172
|
+
* The `description` input field is accepted for claude-SDK parity. We don't
|
|
173
|
+
* store it anywhere — its presence in the schema is what matters: the model's
|
|
174
|
+
* pretrained instinct to emit a short rationale per Bash call survives the
|
|
175
|
+
* agent switch, which is what permission UIs / audit logs want to render.
|
|
176
|
+
*/
|
|
177
|
+
export const bashTool = createBashTool();
|
|
178
|
+
/** Named schema export so the provider can reference it
|
|
179
|
+
* without instantiating a full tool registry. */
|
|
180
|
+
export const bashToolSchema = bashSchema;
|
|
181
|
+
export function createOutputRing(cap) {
|
|
182
|
+
if (cap <= 0) {
|
|
183
|
+
return {
|
|
184
|
+
append() { },
|
|
185
|
+
render: () => "",
|
|
186
|
+
truncated: () => false,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
// Split the cap roughly in half. With an odd cap the head gets the extra
|
|
190
|
+
// byte — head context (command echo, startup banner) tends to be slightly
|
|
191
|
+
// more diagnostic than the tail of "Done." messages.
|
|
192
|
+
const headCap = Math.ceil(cap / 2);
|
|
193
|
+
const tailCap = cap - headCap;
|
|
194
|
+
let head = "";
|
|
195
|
+
// The tail is maintained as a sliding window — we keep at most `tailCap`
|
|
196
|
+
// bytes of the most-recent output regardless of how many bytes streamed
|
|
197
|
+
// past. `dropped` tracks the count of middle bytes we ejected so the
|
|
198
|
+
// truncation marker can quote a real number.
|
|
199
|
+
let tail = "";
|
|
200
|
+
let dropped = 0;
|
|
201
|
+
// total bytes observed — sum of head, tail, and dropped. Useful for
|
|
202
|
+
// future telemetry; not exposed yet.
|
|
203
|
+
let total = 0;
|
|
204
|
+
return {
|
|
205
|
+
append(text) {
|
|
206
|
+
if (text.length === 0)
|
|
207
|
+
return;
|
|
208
|
+
total += text.length;
|
|
209
|
+
// Phase 1: while the head buffer has room, fill it first.
|
|
210
|
+
if (head.length < headCap) {
|
|
211
|
+
const take = Math.min(text.length, headCap - head.length);
|
|
212
|
+
head += text.slice(0, take);
|
|
213
|
+
text = text.slice(take);
|
|
214
|
+
if (text.length === 0)
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
// Phase 2: tail-only path. Append, then evict the oldest bytes if
|
|
218
|
+
// we exceed `tailCap`. Bytes evicted from the tail count toward
|
|
219
|
+
// `dropped` because they passed through but are no longer visible.
|
|
220
|
+
if (tailCap === 0) {
|
|
221
|
+
// Degenerate: head took the whole cap. Drop everything after.
|
|
222
|
+
dropped += text.length;
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
tail += text;
|
|
226
|
+
if (tail.length > tailCap) {
|
|
227
|
+
const over = tail.length - tailCap;
|
|
228
|
+
dropped += over;
|
|
229
|
+
tail = tail.slice(over);
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
render() {
|
|
233
|
+
if (dropped === 0)
|
|
234
|
+
return head + tail;
|
|
235
|
+
// The middle marker is emitted on its own line so the model — and any
|
|
236
|
+
// human reading the trace — can see where the gap is. We keep the
|
|
237
|
+
// marker terse (no ANSI, no decoration) so it survives downstream
|
|
238
|
+
// serialisation.
|
|
239
|
+
return `${head}\n...[truncated ${dropped} bytes]...\n${tail}`;
|
|
240
|
+
},
|
|
241
|
+
truncated: () => dropped > 0,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function truncatedFlag(stdout, stderr) {
|
|
245
|
+
if (stdout.truncated() || stderr.truncated())
|
|
246
|
+
return { truncated: true };
|
|
247
|
+
return {};
|
|
248
|
+
}
|
|
249
|
+
// Internal exports for tests.
|
|
250
|
+
export const __BASH_MAX_OUTPUT_DEFAULT = BASH_MAX_OUTPUT_DEFAULT;
|
|
251
|
+
export const __BASH_MAX_OUTPUT_HARD = BASH_MAX_OUTPUT_HARD;
|
|
252
|
+
export const __BASH_TIMEOUT_MS = BASH_TIMEOUT_MS;
|
|
253
|
+
export const __BASH_TIMEOUT_MAX_MS = BASH_TIMEOUT_MAX_MS;
|
|
124
254
|
//# sourceMappingURL=bash.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash.js","sourceRoot":"","sources":["../../../src/tools/builtin/bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"bash.js","sourceRoot":"","sources":["../../../src/tools/builtin/bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAIlD;;uDAEuD;AAC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../../src/tools/builtin/edit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../src/tools/builtin/edit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAgCpD,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAED,wBAAgB,cAAc,CAAC,IAAI,GAAE,eAAoB,GAAG,WAAW,CAgKtE;AAED,+EAA+E;AAC/E,eAAO,MAAM,QAAQ,EAAE,WAA8B,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAUzE;AAqCD,eAAO,MAAM,gBAAgB,QAAiB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { isAbsolute } from "node:path";
|
|
2
|
+
import { isAbsolute, normalize } from "node:path";
|
|
3
|
+
import { checkBlockedPath } from "../../tools/path-guard.js";
|
|
3
4
|
/**
|
|
4
5
|
* Edit builtin — claude SDK `Edit` tool parity for maestro.
|
|
5
6
|
*
|
|
@@ -62,7 +63,9 @@ export function createEditTool(opts = {}) {
|
|
|
62
63
|
},
|
|
63
64
|
},
|
|
64
65
|
async execute(input) {
|
|
65
|
-
|
|
66
|
+
// normalize() collapses `..` segments (e.g. /safe/../etc → /etc) so
|
|
67
|
+
// that the isAbsolute check cannot be bypassed by path traversal.
|
|
68
|
+
const filePath = normalize(typeof input.file_path === "string" ? input.file_path : "");
|
|
66
69
|
if (!filePath) {
|
|
67
70
|
return JSON.stringify({ error: "Edit: missing 'file_path' argument" });
|
|
68
71
|
}
|
|
@@ -71,6 +74,9 @@ export function createEditTool(opts = {}) {
|
|
|
71
74
|
error: `Edit: file_path must be absolute, got '${filePath}'`,
|
|
72
75
|
});
|
|
73
76
|
}
|
|
77
|
+
const blockErr = checkBlockedPath("Edit", filePath);
|
|
78
|
+
if (blockErr)
|
|
79
|
+
return JSON.stringify({ error: blockErr });
|
|
74
80
|
// Read-before-Edit gate. No-op when no tracker is wired (standalone use).
|
|
75
81
|
if (tracker) {
|
|
76
82
|
const gateErr = tracker.checkBeforeMutate(filePath, "Edit");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/tools/builtin/edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAc,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/tools/builtin/edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAc,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,0BAA0B;AACnE,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAW/B,MAAM,UAAU,cAAc,CAAC,OAAwB,EAAE;IACvD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACzB,OAAO;QACL,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,WAAW,EACT,yCAAyC;gBACzC,6DAA6D;gBAC7D,yEAAyE;gBACzE,uEAAuE;gBACvE,yEAAyE;YAC3E,YAAY,EAAE;gBAC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CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,wBAAwB;QACnE,IAAI,IAAI,GAAG,GAAG,EAAE,CAAC;YACf,WAAW,GAAG,CAAC,CAAC;YAChB,MAAM;QACR,CAAC;QACD,GAAG,GAAG,IAAI,CAAC;IACb,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,GAAG,oBAAoB,CAAC,CAAC;IAC9D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,oBAAoB,GAAG,CAAC,CAAC,CAAC;IAC9E,OAAO,QAAQ;SACZ,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC;SACjB,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;SACtE,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,8BAA8B;AAC9B,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC"}
|
|
@@ -5,10 +5,14 @@ export declare const globTool: ToolHandler;
|
|
|
5
5
|
* path (anchored at both ends).
|
|
6
6
|
*
|
|
7
7
|
* Handled tokens:
|
|
8
|
-
* `**\/`
|
|
9
|
-
* `**`
|
|
10
|
-
* `*`
|
|
11
|
-
* `?`
|
|
8
|
+
* `**\/` → `(?:.*\/)?` — zero or more path segments (greedy across `/`)
|
|
9
|
+
* `**` → `.*` — anything including `/`
|
|
10
|
+
* `*` → `[^/]*` — anything except `/` within one segment
|
|
11
|
+
* `?` → `[^/]` — single char within one segment
|
|
12
|
+
* `[abc]` → `[abc]` — character class (POSIX `[!abc]` → `[^abc]`)
|
|
13
|
+
* `{a,b}` → `(?:a|b)` — brace expansion (nestable, body recursively
|
|
14
|
+
* compiled so wildcards / classes inside each
|
|
15
|
+
* alternative still work)
|
|
12
16
|
*
|
|
13
17
|
* Other regex metacharacters are escaped so literals like `.` in `foo.ts`
|
|
14
18
|
* don't accidentally turn into "any char".
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../../src/tools/builtin/glob.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAuCpD,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../../src/tools/builtin/glob.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAuCpD,eAAO,MAAM,QAAQ,EAAE,WAwKtB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AA2GD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAsBjF"}
|