@ai-hero/sandcastle 0.14.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{SandboxProvider-Chsi-Zs6.d.ts → SandboxProvider-CwRLxIXZ.d.ts} +2 -39
- package/dist/{chunk-BVZWLFFT.js → chunk-4BB7DNPW.js} +3 -3
- package/dist/chunk-4BB7DNPW.js.map +1 -0
- package/dist/chunk-4GZMUHVO.js +60 -0
- package/dist/chunk-4GZMUHVO.js.map +1 -0
- package/dist/{chunk-S6UHPTRG.js → chunk-7JUTKCHL.js} +4 -4
- package/dist/{chunk-S6UHPTRG.js.map → chunk-7JUTKCHL.js.map} +1 -1
- package/dist/chunk-7PHPLDVS.js +284 -0
- package/dist/chunk-7PHPLDVS.js.map +1 -0
- package/dist/{chunk-HSXPRZKG.js → chunk-BXLS4HRY.js} +15 -6
- package/dist/chunk-BXLS4HRY.js.map +1 -0
- package/dist/{chunk-G2R53CVZ.js → chunk-EM4QNWKF.js} +695 -706
- package/dist/chunk-EM4QNWKF.js.map +1 -0
- package/dist/{chunk-STB2U7BB.js → chunk-JEQ4IVQM.js} +384 -264
- package/dist/chunk-JEQ4IVQM.js.map +1 -0
- package/dist/{chunk-VRXR2T3S.js → chunk-L3BU47F6.js} +3 -3
- package/dist/{chunk-VRXR2T3S.js.map → chunk-L3BU47F6.js.map} +1 -1
- package/dist/{chunk-7N7AMUYA.js → chunk-PTJEKJPQ.js} +7 -5
- package/dist/chunk-PTJEKJPQ.js.map +1 -0
- package/dist/{chunk-H2PEFS4W.js → chunk-SAQXFLO2.js} +30 -6
- package/dist/chunk-SAQXFLO2.js.map +1 -0
- package/dist/{chunk-ATA2V2TC.js → chunk-TBVRAXYF.js} +3 -3
- package/dist/{chunk-ATA2V2TC.js.map → chunk-TBVRAXYF.js.map} +1 -1
- package/dist/{chunk-IBK2XNSS.js → chunk-VUOXFCWO.js} +3 -3
- package/dist/{chunk-IBK2XNSS.js.map → chunk-VUOXFCWO.js.map} +1 -1
- package/dist/{chunk-GCLEXPXG.js → chunk-WYOGXC72.js} +46 -84
- package/dist/chunk-WYOGXC72.js.map +1 -0
- package/dist/{chunk-RDW7FNN6.js → chunk-YDQW5IOY.js} +11 -4
- package/dist/chunk-YDQW5IOY.js.map +1 -0
- package/dist/index.d.ts +47 -4
- package/dist/index.js +536 -445
- package/dist/index.js.map +1 -1
- package/dist/main.js +72 -16
- package/dist/main.js.map +1 -1
- package/dist/sandboxes/bwrap.d.ts +1 -1
- package/dist/sandboxes/bwrap.js +9 -17
- package/dist/sandboxes/bwrap.js.map +1 -1
- package/dist/sandboxes/daytona.d.ts +1 -1
- package/dist/sandboxes/daytona.js +82 -79
- package/dist/sandboxes/daytona.js.map +1 -1
- package/dist/sandboxes/docker.d.ts +23 -1
- package/dist/sandboxes/docker.js +6 -5
- package/dist/sandboxes/e2b.d.ts +1 -1
- package/dist/sandboxes/e2b.js +4 -4
- package/dist/sandboxes/modal.d.ts +1 -1
- package/dist/sandboxes/modal.js +1 -1
- package/dist/sandboxes/no-sandbox.d.ts +1 -1
- package/dist/sandboxes/no-sandbox.js +1 -1
- package/dist/sandboxes/podman.d.ts +27 -4
- package/dist/sandboxes/podman.js +18 -45
- package/dist/sandboxes/podman.js.map +1 -1
- package/dist/sandboxes/seatbelt.d.ts +2 -2
- package/dist/sandboxes/seatbelt.js +10 -10
- package/dist/sandboxes/seatbelt.js.map +1 -1
- package/dist/sandboxes/sprites.d.ts +1 -1
- package/dist/sandboxes/sprites.js +25 -4
- package/dist/sandboxes/sprites.js.map +1 -1
- package/dist/sandboxes/vercel.d.ts +10 -1
- package/dist/sandboxes/vercel.js +74 -46
- package/dist/sandboxes/vercel.js.map +1 -1
- package/dist/templates/parallel-planner/main.mts +43 -21
- package/dist/templates/parallel-planner-with-review/main.mts +55 -27
- package/dist/templates/sequential-reviewer/main.mts +1 -1
- package/package.json +7 -3
- package/dist/chunk-7N7AMUYA.js.map +0 -1
- package/dist/chunk-BIF2X6QB.js +0 -94
- package/dist/chunk-BIF2X6QB.js.map +0 -1
- package/dist/chunk-BVZWLFFT.js.map +0 -1
- package/dist/chunk-G2R53CVZ.js.map +0 -1
- package/dist/chunk-GCLEXPXG.js.map +0 -1
- package/dist/chunk-H2PEFS4W.js.map +0 -1
- package/dist/chunk-HSXPRZKG.js.map +0 -1
- package/dist/chunk-RDW7FNN6.js.map +0 -1
- package/dist/chunk-STB2U7BB.js.map +0 -1
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
// listing unblocked issues with branch names.
|
|
7
7
|
// Phase 2 (Execute + Review): For each issue, a sandbox is created via
|
|
8
8
|
// createSandbox(). The implementer runs first
|
|
9
|
-
// (100 iterations). If
|
|
10
|
-
//
|
|
11
|
-
// branch (1 iteration).
|
|
12
|
-
// concurrently via
|
|
9
|
+
// (100 iterations). If the branch is then ahead
|
|
10
|
+
// of the current branch, a reviewer runs in the
|
|
11
|
+
// same sandbox on the same branch (1 iteration).
|
|
12
|
+
// All issue pipelines run concurrently via
|
|
13
|
+
// Promise.allSettled().
|
|
13
14
|
// Phase 3 (Merge): A single agent merges all completed branches
|
|
14
15
|
// into the current branch.
|
|
15
16
|
//
|
|
@@ -21,6 +22,8 @@
|
|
|
21
22
|
// Or add to package.json:
|
|
22
23
|
// "scripts": { "sandcastle": "npx tsx .sandcastle/main.mts" }
|
|
23
24
|
|
|
25
|
+
import { spawn } from "node:child_process";
|
|
26
|
+
import { once } from "node:events";
|
|
24
27
|
import * as sandcastle from "@ai-hero/sandcastle";
|
|
25
28
|
import { docker } from "@ai-hero/sandcastle/sandboxes/docker";
|
|
26
29
|
import { z } from "zod";
|
|
@@ -35,6 +38,24 @@ const planSchema = z.object({
|
|
|
35
38
|
),
|
|
36
39
|
});
|
|
37
40
|
|
|
41
|
+
// True when `branch` has commits the current branch doesn't. The review and
|
|
42
|
+
// merge phases ask git rather than trusting this cycle's `commits`: a branch
|
|
43
|
+
// an earlier cycle advanced but never merged gets no new commits when its
|
|
44
|
+
// issue comes round again, so gating on `commits.length` would skip its
|
|
45
|
+
// review and strand it forever.
|
|
46
|
+
const isAheadOfHead = async (branch: string): Promise<boolean> => {
|
|
47
|
+
const git = spawn("git", ["rev-list", "--count", `HEAD..${branch}`], {
|
|
48
|
+
stdio: ["ignore", "pipe", "inherit"],
|
|
49
|
+
});
|
|
50
|
+
const closed = once(git, "close");
|
|
51
|
+
let count = "";
|
|
52
|
+
for await (const chunk of git.stdout) {
|
|
53
|
+
count += String(chunk);
|
|
54
|
+
}
|
|
55
|
+
await closed;
|
|
56
|
+
return git.exitCode === 0 && Number(count.trim()) > 0;
|
|
57
|
+
};
|
|
58
|
+
|
|
38
59
|
// ---------------------------------------------------------------------------
|
|
39
60
|
// Configuration
|
|
40
61
|
// ---------------------------------------------------------------------------
|
|
@@ -43,15 +64,18 @@ const planSchema = z.object({
|
|
|
43
64
|
// Raise this if your backlog is large; lower it for a quick smoke-test run.
|
|
44
65
|
const MAX_ITERATIONS = 10;
|
|
45
66
|
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
|
|
67
|
+
// Install hooks only for worktree phases (execute + review). Planner and
|
|
68
|
+
// merger bind-mount the real checkout (no branch), so an `npm install`
|
|
69
|
+
// there would rewrite the host's node_modules — e.g. Linux native binaries
|
|
70
|
+
// on macOS, or packages removed from the host tree.
|
|
71
|
+
const installHooks = {
|
|
49
72
|
sandbox: { onSandboxReady: [{ command: "npm install" }] },
|
|
50
73
|
};
|
|
51
74
|
|
|
52
|
-
// Copy node_modules from the host into the worktree before each
|
|
53
|
-
// starts. Avoids a full npm install from scratch; the hook above
|
|
54
|
-
// platform-specific binaries and any packages added since the last
|
|
75
|
+
// Copy node_modules from the host into the worktree before each execute
|
|
76
|
+
// sandbox starts. Avoids a full npm install from scratch; the hook above
|
|
77
|
+
// handles platform-specific binaries and any packages added since the last
|
|
78
|
+
// copy. Safe only with a worktree — never pair this with a head bind-mount.
|
|
55
79
|
const copyToWorktree = ["node_modules"];
|
|
56
80
|
|
|
57
81
|
// ---------------------------------------------------------------------------
|
|
@@ -71,7 +95,6 @@ for (let iteration = 1; iteration <= MAX_ITERATIONS; iteration++) {
|
|
|
71
95
|
// It outputs a <plan> JSON block — Output.object parses and validates it.
|
|
72
96
|
// -------------------------------------------------------------------------
|
|
73
97
|
const plan = await sandcastle.run({
|
|
74
|
-
hooks,
|
|
75
98
|
sandbox: docker(),
|
|
76
99
|
name: "planner",
|
|
77
100
|
// One iteration is enough: the planner just needs to read and reason,
|
|
@@ -106,7 +129,8 @@ for (let iteration = 1; iteration <= MAX_ITERATIONS; iteration++) {
|
|
|
106
129
|
//
|
|
107
130
|
// For each issue, create a sandbox via createSandbox() so the implementer
|
|
108
131
|
// and reviewer share the same sandbox instance per branch. The implementer
|
|
109
|
-
// runs first; if
|
|
132
|
+
// runs first; if the branch is ahead of the current branch, the reviewer
|
|
133
|
+
// runs in the same sandbox.
|
|
110
134
|
//
|
|
111
135
|
// Promise.allSettled means one failing pipeline doesn't cancel the others.
|
|
112
136
|
// -------------------------------------------------------------------------
|
|
@@ -116,7 +140,7 @@ for (let iteration = 1; iteration <= MAX_ITERATIONS; iteration++) {
|
|
|
116
140
|
const sandbox = await sandcastle.createSandbox({
|
|
117
141
|
branch: issue.branch,
|
|
118
142
|
sandbox: docker(),
|
|
119
|
-
hooks,
|
|
143
|
+
hooks: installHooks,
|
|
120
144
|
copyToWorktree,
|
|
121
145
|
});
|
|
122
146
|
|
|
@@ -134,8 +158,11 @@ for (let iteration = 1; iteration <= MAX_ITERATIONS; iteration++) {
|
|
|
134
158
|
},
|
|
135
159
|
});
|
|
136
160
|
|
|
137
|
-
//
|
|
138
|
-
|
|
161
|
+
// Review whenever the branch has work the current branch lacks, not
|
|
162
|
+
// only when this run committed. An earlier cycle may have committed
|
|
163
|
+
// and then failed before or during its review; the merge phase picks
|
|
164
|
+
// that branch up (see isAheadOfHead), so it must be reviewed here first.
|
|
165
|
+
if (await isAheadOfHead(issue.branch)) {
|
|
139
166
|
const review = await sandbox.run({
|
|
140
167
|
name: "reviewer",
|
|
141
168
|
maxIterations: 1,
|
|
@@ -162,35 +189,37 @@ for (let iteration = 1; iteration <= MAX_ITERATIONS; iteration++) {
|
|
|
162
189
|
);
|
|
163
190
|
|
|
164
191
|
// Log any agents that threw (network error, sandbox crash, etc.), and
|
|
165
|
-
// only pass branches that
|
|
166
|
-
//
|
|
167
|
-
|
|
192
|
+
// only pass branches that are ahead of the current branch to the merge
|
|
193
|
+
// phase, whichever cycle made their commits (see isAheadOfHead). Each one
|
|
194
|
+
// was reviewed in this cycle's Phase 2.
|
|
195
|
+
const finishedIssues: typeof issues = [];
|
|
168
196
|
for (const [i, issue] of issues.entries()) {
|
|
169
197
|
const outcome = settled[i];
|
|
170
198
|
if (outcome?.status === "rejected") {
|
|
171
199
|
console.error(
|
|
172
200
|
` ✗ ${issue.id} (${issue.branch}) failed: ${outcome.reason}`,
|
|
173
201
|
);
|
|
174
|
-
} else if (
|
|
175
|
-
|
|
176
|
-
outcome.value.commits.length > 0
|
|
177
|
-
) {
|
|
178
|
-
completedIssues.push(issue);
|
|
202
|
+
} else if (outcome?.status === "fulfilled") {
|
|
203
|
+
finishedIssues.push(issue);
|
|
179
204
|
}
|
|
180
205
|
}
|
|
206
|
+
const ahead = await Promise.all(
|
|
207
|
+
finishedIssues.map(async (issue) => isAheadOfHead(issue.branch)),
|
|
208
|
+
);
|
|
209
|
+
const completedIssues = finishedIssues.filter((_, i) => ahead[i] === true);
|
|
181
210
|
|
|
182
211
|
const completedBranches = completedIssues.map((i) => i.branch);
|
|
183
212
|
|
|
184
213
|
console.log(
|
|
185
|
-
`\nExecution complete. ${completedBranches.length} branch(es)
|
|
214
|
+
`\nExecution complete. ${completedBranches.length} branch(es) ahead of HEAD:`,
|
|
186
215
|
);
|
|
187
216
|
for (const branch of completedBranches) {
|
|
188
217
|
console.log(` ${branch}`);
|
|
189
218
|
}
|
|
190
219
|
|
|
191
220
|
if (completedBranches.length === 0) {
|
|
192
|
-
//
|
|
193
|
-
console.log("No
|
|
221
|
+
// No branch has work the current branch lacks — nothing to merge.
|
|
222
|
+
console.log("No branches ahead of HEAD. Nothing to merge.");
|
|
194
223
|
continue;
|
|
195
224
|
}
|
|
196
225
|
|
|
@@ -204,7 +233,6 @@ for (let iteration = 1; iteration <= MAX_ITERATIONS; iteration++) {
|
|
|
204
233
|
// uses to know which branches to merge and which issues to close.
|
|
205
234
|
// -------------------------------------------------------------------------
|
|
206
235
|
await sandcastle.run({
|
|
207
|
-
hooks,
|
|
208
236
|
sandbox: docker(),
|
|
209
237
|
name: "merger",
|
|
210
238
|
maxIterations: 1,
|
|
@@ -83,7 +83,7 @@ for (let iteration = 1; iteration <= MAX_ITERATIONS; iteration++) {
|
|
|
83
83
|
promptFile: "./.sandcastle/implement-prompt.md",
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
if (
|
|
86
|
+
if (implement.commits.length === 0) {
|
|
87
87
|
// No commits means the backlog is empty or every remaining issue is
|
|
88
88
|
// blocked — there is nothing left to implement or review, so stop.
|
|
89
89
|
console.log("Implementation agent made no commits. Stopping.");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-hero/sandcastle",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "CLI for orchestrating AI agents in isolated sandbox environments",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "tsup",
|
|
59
|
-
"postbuild": "
|
|
59
|
+
"postbuild": "node scripts/copy-templates.mjs && node scripts/check-public-types-effect-free.mjs",
|
|
60
60
|
"pretest": "tsx scripts/ensure-build.ts",
|
|
61
61
|
"test": "vitest run",
|
|
62
62
|
"test:watch": "vitest",
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
"prelint": "tsx scripts/ensure-build.ts",
|
|
66
66
|
"lint": "tsc --noEmit -p scripts/tsconfig.json && tsx scripts/lint-ratchet.ts",
|
|
67
67
|
"lint:shrink": "tsx scripts/lint-ratchet.ts --shrink",
|
|
68
|
+
"lint:transfer": "tsx scripts/lint-ratchet.ts --transfer",
|
|
69
|
+
"prelint:report": "tsx scripts/ensure-build.ts",
|
|
68
70
|
"lint:report": "tsx scripts/lint-ratchet.ts --report",
|
|
69
71
|
"format": "biome format --write .",
|
|
70
72
|
"format:check": "biome format .",
|
|
@@ -78,6 +80,7 @@
|
|
|
78
80
|
"verify:world": "npm run build >/dev/null && tsx .sandcastle/verify/verify.ts world",
|
|
79
81
|
"coverage:gate": "tsx scripts/coverage-gate.ts",
|
|
80
82
|
"coverage:floor": "tsx scripts/coverage-floor.ts",
|
|
83
|
+
"preapi:report": "tsx scripts/ensure-build.ts",
|
|
81
84
|
"api:report": "tsx scripts/api-report.ts"
|
|
82
85
|
},
|
|
83
86
|
"keywords": [
|
|
@@ -123,7 +126,8 @@
|
|
|
123
126
|
"zod": "^4.4.3"
|
|
124
127
|
},
|
|
125
128
|
"dependencies": {
|
|
126
|
-
"@clack/prompts": "^1.1.0"
|
|
129
|
+
"@clack/prompts": "^1.1.0",
|
|
130
|
+
"@standard-schema/spec": "^1.1.0"
|
|
127
131
|
},
|
|
128
132
|
"peerDependencies": {
|
|
129
133
|
"@daytona/sdk": ">=0.164.0 <1.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sandboxes/posixSimpleCommand.ts","../src/sandboxes/windowsCommand.ts","../src/sandboxes/no-sandbox.ts"],"names":[],"mappings":";;;;;;;;;;AAaA,IAAM,QAAA,GAAW,2BAAA;AAOjB,IAAM,gBAAA,GAAmB,yBAAA;AAGzB,IAAM,UAAA,GAAa,KAAA;AAGnB,IAAM,sBAAA,GAAyB,OAAA;AAQ/B,IAAM,gBAAA,GAAmB,CAAC,CAAA,EAAW,KAAA,K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,GAAA,EAAK,OAAA,EAAS,GAAA,IAAO,EAAC;AAAA,EACtB,MAAA,EAAQ,OAAO,aAAA,KAA4C;AACzD,IAAA,MAAM,EAAE,cAAa,GAAI,aAAA;AACzB,IAAA,MAAM,OAAA,GAAuB;AAAA,MAC3B,YAAA;AAAA,MACA,YAAY,EAAE,GAAG,QAAQ,GAAA,EAAK,GAAG,cAAc,GAAA,EAAI;AAAA,MACnD,kBAAA,EAAoB,SAAS,kBAAA,IAAsB;AAAA,KACrD;AAEA,IAAA,MAAM,MAAA,GAA0B;AAAA,MAC9B,YAAA;AAAA,MACA,MAAM,OAAO,OAAA,EAAiB,SAC5B,OAAA,CAAQ,OAAA,EAAS,MAAM,OAAO,CAAA;AAAA,MAChC,iBAAiB,OACf,IAAA,EACA,SAEA,kBAAA,CAAmB,IAAA,EAAM,MAAM,OAAO,CAAA;AAAA,MACxC,OAAO,YAA2B;AAAA,MAElC;AAAA,KACF;AAEA,IAAA,OAAO,MAAA;AAAA,EACT;AACF,CAAA","file":"chunk-7N7AMUYA.js","sourcesContent":["/**\n * @internal Splits a POSIX shell command back into the argv it stands for,\n * when it is a simple command. noSandbox uses it on Windows (issue #940),\n * where there is no `sh` to do this, so the program can be spawned directly\n * instead of handing POSIX quoting to cmd.exe. See `windowsCommand.ts`.\n */\n\n/** A POSIX simple command: leading `export NAME=value;` statements, then argv. */\nexport interface SimpleCommand {\n readonly env: Record<string, string>;\n readonly argv: readonly string[];\n}\n\nconst ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/u;\n\n/**\n * Characters that make an unquoted word mean something to a POSIX shell\n * (operators, expansions, globs) or look like cmd.exe syntax (`%`, `^`).\n * A command containing one is not simple, and keeps the old cmd.exe path.\n */\nconst UNQUOTED_SPECIAL = \"|&<>()$`*?[]{}~#!%^\\n\\r\";\n\n/** Ends the current word without being part of one. */\nconst SEPARATORS = \" \\t;\";\n\n/** Characters a backslash escapes inside POSIX double quotes. */\nconst DOUBLE_QUOTE_ESCAPABLE = '\"\\\\$`';\n\n/** A run of characters read from the command, and where reading stops. */\ninterface Piece {\n readonly text: string;\n readonly next: number;\n}\n\nconst readSingleQuoted = (s: string, start: number): Piece | undefined => {\n const end = s.indexOf(\"'\", start + 1);\n return end === -1\n ? undefined\n : { text: s.slice(start + 1, end), next: end + 1 };\n};\n\nconst readDoubleQuoted = (s: string, start: number): Piece | undefined => {\n let text = \"\";\n let i = start + 1;\n while (i < s.length) {\n const c = s.charAt(i);\n const next = s.charAt(i + 1);\n if (c === '\"') {\n return { text, next: i + 1 };\n }\n if (c === \"$\" || c === \"`\" || (c === \"\\\\\" && next === \"\\n\")) {\n return undefined;\n }\n if (c === \"\\\\\" && next !== \"\" && DOUBLE_QUOTE_ESCAPABLE.includes(next)) {\n text += next;\n i += 2;\n } else {\n text += c;\n i += 1;\n }\n }\n return undefined;\n};\n\nconst readBare = (s: string, start: number): Piece => {\n let i = start;\n while (\n i < s.length &&\n !SEPARATORS.includes(s.charAt(i)) &&\n !UNQUOTED_SPECIAL.includes(s.charAt(i)) &&\n !\"'\\\"\\\\\".includes(s.charAt(i))\n ) {\n i += 1;\n }\n return { text: s.slice(start, i), next: i };\n};\n\n/** Read the next piece of a word, or undefined if the command isn't simple. */\nconst readPiece = (s: string, start: number): Piece | undefined => {\n const c = s.charAt(start);\n if (c === \"'\") {\n return readSingleQuoted(s, start);\n }\n if (c === '\"') {\n return readDoubleQuoted(s, start);\n }\n if (c === \"\\\\\") {\n // Only the `\\'` that shellEscape emits. Any other bare backslash is more\n // likely a Windows path than a POSIX escape: leave it to cmd.exe.\n return s.charAt(start + 1) === \"'\"\n ? { text: \"'\", next: start + 2 }\n : undefined;\n }\n if (UNQUOTED_SPECIAL.includes(c)) {\n return undefined;\n }\n return readBare(s, start);\n};\n\n/** Split into statements (on `;`), each a list of words. */\nconst splitStatements = (s: string): string[][] | undefined => {\n const statements: string[][] = [[]];\n let word: string | undefined;\n const endWord = () => {\n if (word !== undefined) {\n statements.at(-1)?.push(word);\n }\n word = undefined;\n };\n let i = 0;\n while (i < s.length) {\n const c = s.charAt(i);\n const piece = SEPARATORS.includes(c) ? undefined : readPiece(s, i);\n if (piece !== undefined) {\n word = (word ?? \"\") + piece.text;\n i = piece.next;\n } else if (SEPARATORS.includes(c)) {\n endWord();\n if (c === \";\") {\n statements.push([]);\n }\n i += 1;\n } else {\n return undefined;\n }\n }\n endWord();\n return statements;\n};\n\n/** The env an `export NAME=value …` statement sets, or undefined. */\nconst exportedEnv = (\n statement: readonly string[],\n): Record<string, string> | undefined => {\n const [keyword, ...assignments] = statement;\n if (keyword !== \"export\" || assignments.length === 0) {\n return undefined;\n }\n const env: Record<string, string> = {};\n for (const assignment of assignments) {\n const eq = assignment.indexOf(\"=\");\n const name = assignment.slice(0, eq);\n if (eq === -1 || !ENV_NAME.test(name)) {\n return undefined;\n }\n env[name] = assignment.slice(eq + 1);\n }\n return env;\n};\n\n/**\n * Split a POSIX shell command into argv, when it is a simple command.\n *\n * Understands exactly what Sandcastle produces: bare words, `'single'`\n * quotes, `\"double\"` quotes with POSIX backslash escapes, the `\\'` that\n * `shellEscape` emits between quoted runs, and leading `export NAME=value;`\n * statements (the agent env prefix from `createSandbox`). Returns undefined\n * for anything else.\n */\nexport const parseSimpleCommand = (\n command: string,\n): SimpleCommand | undefined => {\n const statements = splitStatements(command);\n const argv = statements?.pop();\n const [program] = argv ?? [];\n if (\n statements === undefined ||\n argv === undefined ||\n program === undefined ||\n program === \"\" ||\n program.includes(\"=\")\n ) {\n return undefined;\n }\n const env: Record<string, string> = {};\n for (const statement of statements) {\n const exported = exportedEnv(statement);\n if (exported === undefined) {\n return undefined;\n }\n Object.assign(env, exported);\n }\n return { env, argv };\n};\n","/**\n * @internal How noSandbox runs a command on Windows (issue #940).\n *\n * Sandcastle builds every exec command as a POSIX shell string (agent print\n * commands quote their values with `shellEscape`), because docker, podman,\n * vercel and daytona all run it with `sh -c`. Windows has no `sh`, and cmd.exe\n * does not understand POSIX quoting, so handing that string to cmd.exe\n * delivers `'claude-fable-5'`, quotes and all.\n *\n * Instead of re-quoting the string for cmd.exe, noSandbox splits it back into\n * the argv it stands for and launches the program directly:\n *\n * - an `.exe` gets the argv array with no shell at all; Node's own argv\n * quoting handles spaces, quotes, `%`, `^`, `&`, `|` and newlines;\n * - a `.cmd`/`.bat` (how npm installs agent CLIs on Windows) can only run\n * under cmd.exe, so its command line is escaped with the standard rules\n * for a batch file that forwards `%*` (as cross-spawn does);\n * - anything that is not a simple command (pipes, redirects, `$VAR`, cmd.exe\n * builtins, Windows-style `%VAR%`) goes to cmd.exe unchanged, as before.\n */\nimport { stat } from \"node:fs/promises\";\nimport { win32 } from \"node:path\";\nimport { parseSimpleCommand } from \"./posixSimpleCommand.js\";\n\n/** How to spawn a command: `file` with `args`, no shell. */\nexport interface SpawnPlan {\n readonly file: string;\n readonly args: readonly string[];\n readonly windowsVerbatimArguments: boolean;\n}\n\ntype Env = Record<string, string | undefined>;\n\n/**\n * Read an env var the way Windows does: names are case-insensitive, and when\n * an env object holds two spellings (`Path` and `PATH`), Node's spawn uses\n * the lexicographically first, so this does too.\n */\nconst getEnv = (env: Env, name: string): string | undefined => {\n const key = Object.keys(env)\n .filter((k) => k.toUpperCase() === name)\n .reduce<string | undefined>(\n (first, k) => (first === undefined || k < first ? k : first),\n undefined,\n );\n return key === undefined ? undefined : env[key];\n};\n\nconst isFile = async (path: string): Promise<boolean> => {\n try {\n const stats = await stat(path);\n return stats.isFile();\n } catch {\n return false;\n }\n};\n\n/** The paths Windows would try for `program`, in order. */\nconst candidatePaths = (program: string, env: Env, cwd: string): string[] => {\n const pathExt = (getEnv(env, \"PATHEXT\") ?? \".COM;.EXE;.BAT;.CMD\")\n .split(\";\")\n .filter((ext) => ext !== \"\")\n .map((ext) => ext.toLowerCase());\n const hasExt = pathExt.includes(win32.extname(program).toLowerCase());\n const withExts = (base: string) =>\n hasExt ? [base] : pathExt.map((ext) => `${base}${ext}`);\n\n if (/[\\\\/]/u.test(program) || win32.isAbsolute(program)) {\n return withExts(win32.resolve(cwd, program));\n }\n return (getEnv(env, \"PATH\") ?? \"\")\n .split(\";\")\n .map((dir) => dir.replaceAll('\"', \"\").trim())\n .filter((dir) => dir !== \"\")\n .flatMap((dir) => withExts(win32.join(dir, program)));\n};\n\n/**\n * Find the file Windows would run for `program`: an explicit path (relative\n * to `cwd`), or the first PATH directory holding `program` with a PATHEXT\n * extension. Returns undefined when nothing matches (cmd.exe builtins such\n * as `echo`, or a program that isn't installed).\n */\nexport const resolveWindowsProgram = async (\n program: string,\n env: Env,\n cwd: string,\n): Promise<string | undefined> => {\n const candidates = candidatePaths(program, env, cwd);\n const found = await Promise.all(candidates.map(async (p) => isFile(p)));\n return candidates[found.indexOf(true)];\n};\n\n/** cmd.exe metacharacters, escaped with `^` (the set cross-spawn uses). */\nconst CMD_META = /(?<meta>[()\\][%!^\"`<>&|;, *?])/gu;\n\n/** The longest command line cmd.exe accepts. */\nexport const CMD_MAX_COMMAND_LINE = 8191;\n\nconst escapeCmdMeta = (s: string): string => s.replaceAll(CMD_META, \"^$<meta>\");\n\n/**\n * Quote one argument for a batch file run through `cmd.exe /d /s /c`.\n *\n * First quote it for the program the batch file ends up launching (the\n * Windows argv rules: backslashes double only before a quote or the end),\n * then `^`-escape every cmd.exe metacharacter twice: once for cmd.exe\n * reading the `/c` line, and once for the batch file's own `%*` line, which\n * cmd.exe parses again.\n */\nconst escapeBatchArgument = (arg: string): string => {\n const quoted = arg\n .replaceAll(/(?<bs>\\\\*)\"/gu, String.raw`$<bs>$<bs>\\\"`)\n .replace(/(?<bs>\\\\*)$/u, \"$<bs>$<bs>\");\n return escapeCmdMeta(escapeCmdMeta(`\"${quoted}\"`));\n};\n\n/** Plan a batch file run under cmd.exe, refusing what cmd.exe can't carry. */\nconst planBatch = (\n program: string,\n file: string,\n { args, comspec }: { args: readonly string[]; comspec: string },\n): SpawnPlan => {\n const name = win32.basename(file);\n if (args.some((arg) => /[\\r\\n]/u.test(arg))) {\n throw new Error(\n `${program} is a batch file (${name}), which runs under cmd.exe, and cmd.exe cannot pass an argument containing a newline. Pass that text on stdin instead.`,\n );\n }\n const commandLine = [\n escapeCmdMeta(file),\n ...args.map((arg) => escapeBatchArgument(arg)),\n ].join(\" \");\n if (commandLine.length > CMD_MAX_COMMAND_LINE) {\n throw new Error(\n `The command line for ${program} (${name}) is too long for cmd.exe: ${commandLine.length} characters once escaped, over the ${CMD_MAX_COMMAND_LINE}-character limit. Pass long text on stdin instead.`,\n );\n }\n return {\n file: comspec,\n args: [\"/d\", \"/s\", \"/c\", `\"${commandLine}\"`],\n windowsVerbatimArguments: true,\n };\n};\n\n/**\n * Plan how to spawn `argv` on Windows without re-quoting it by hand where\n * that can be avoided. Resolves undefined when the program can't be found\n * on PATH, so the caller keeps its old cmd.exe behaviour.\n *\n * Rejects when a batch file would be handed an argument cmd.exe cannot carry\n * (a newline, or a command line over 8191 characters), rather than letting\n * cmd.exe silently cut the command short.\n */\nexport const planWindowsSpawn = async (\n argv: readonly string[],\n env: Env,\n cwd: string,\n): Promise<SpawnPlan | undefined> => {\n const [program, ...args] = argv;\n if (program === undefined) {\n return undefined;\n }\n const file = await resolveWindowsProgram(program, env, cwd);\n if (file === undefined) {\n return undefined;\n }\n const ext = win32.extname(file).toLowerCase();\n if (ext === \".cmd\" || ext === \".bat\") {\n return planBatch(program, file, {\n args,\n comspec: getEnv(env, \"COMSPEC\") ?? \"cmd.exe\",\n });\n }\n return { file, args, windowsVerbatimArguments: false };\n};\n\n/**\n * Plan how noSandbox's `exec` runs a command string on Windows: as a direct\n * spawn when it is a simple command whose program is on PATH, otherwise\n * through `cmd.exe /d /s /c` unchanged (the behaviour before #940).\n */\nexport const planWindowsExec = async (\n command: string,\n env: Env,\n cwd: string,\n): Promise<SpawnPlan & { readonly env: Env }> => {\n const simple = parseSimpleCommand(command);\n if (simple !== undefined) {\n const commandEnv = { ...env, ...simple.env };\n const plan = await planWindowsSpawn(simple.argv, commandEnv, cwd);\n if (plan !== undefined) {\n return { ...plan, env: commandEnv };\n }\n }\n return {\n file: \"cmd.exe\",\n args: [\"/d\", \"/s\", \"/c\", command],\n windowsVerbatimArguments: true,\n env,\n };\n};\n","/**\n * No-sandbox provider — runs the agent directly on the host with no container isolation.\n *\n * Usage:\n * import { noSandbox } from \"sandcastle/sandboxes/no-sandbox\";\n * await interactive({ agent: claudeCode(\"claude-opus-4-8\"), sandbox: noSandbox() });\n *\n * Accepted by `run()`, `interactive()`, and `createSandbox()`. Skips\n * container isolation entirely — the agent executes on the host. Does not\n * pass `--dangerously-skip-permissions` to the agent — the user manages\n * permissions themselves.\n */\n\nimport { spawn } from \"node:child_process\";\nimport type { ChildProcessByStdio, StdioOptions } from \"node:child_process\";\nimport { createInterface } from \"node:readline\";\nimport type { Readable, Writable } from \"node:stream\";\nimport type {\n NoSandboxProvider,\n NoSandboxHandle,\n ExecResult,\n InteractiveExecOptions,\n} from \"../SandboxProvider.js\";\nimport { BoundedTail, MAX_TAIL_CHARS } from \"../boundedTail.js\";\nimport { planWindowsExec, planWindowsSpawn } from \"./windowsCommand.js\";\nimport type { SpawnPlan } from \"./windowsCommand.js\";\n\nexport interface NoSandboxOptions {\n /** Environment variables injected by this provider. Merged at launch time. */\n readonly env?: Record<string, string>;\n /**\n * Maximum number of characters of streamed `exec` output retained per stream\n * (stdout and stderr) when an `onLine` callback is supplied (default: 64KiB).\n *\n * Output is delivered live to `onLine` regardless; this only bounds the tail\n * returned in `ExecResult`, preventing a long-running agent's output from\n * overflowing V8's max string length and crashing the run.\n */\n readonly maxOutputTailChars?: number;\n}\n\ntype ProcessEnv = Record<string, string | undefined>;\n\n/** A spawn plan for `exec`, with the env the command runs under. */\ntype ExecPlan = SpawnPlan & { readonly env: ProcessEnv };\n\ninterface ExecOptions {\n onLine?: (line: string) => void;\n cwd?: string;\n sudo?: boolean;\n stdin?: string;\n}\n\n/** What a handle's `exec` and `interactiveExec` share. */\ninterface HostContext {\n readonly worktreePath: string;\n readonly processEnv: ProcessEnv;\n readonly maxOutputTailChars: number;\n}\n\n/** A spawned `exec` process: stdout and stderr are always piped. */\ntype ExecProcess = ChildProcessByStdio<Writable | null, Readable, Readable>;\n\n/** Attaches output listeners; call the result on close for the output. */\ntype OutputCollector = (proc: ExecProcess) => () => {\n stdout: string;\n stderr: string;\n};\n\nconst planExec = async (\n command: string,\n env: ProcessEnv,\n cwd: string,\n): Promise<ExecPlan> =>\n // Windows has no `sh`, and cmd.exe doesn't understand the POSIX\n // quoting in Sandcastle's commands (#940): run simple commands as a\n // direct spawn of their argv, and only the rest through cmd.exe.\n process.platform === \"win32\"\n ? planWindowsExec(command, env, cwd)\n : {\n file: \"sh\",\n args: [\"-c\", command],\n windowsVerbatimArguments: false,\n env,\n };\n\nconst spawnExec = (\n plan: ExecPlan,\n cwd: string,\n stdin: string | undefined,\n): ExecProcess => {\n const spawnOptions = {\n cwd,\n env: plan.env,\n windowsVerbatimArguments: plan.windowsVerbatimArguments,\n };\n // Two literal `stdio` tuples, so the types know stdout and stderr\n // are always piped.\n if (stdin === undefined) {\n return spawn(plan.file, plan.args, {\n ...spawnOptions,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n }\n const proc = spawn(plan.file, plan.args, {\n ...spawnOptions,\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n });\n proc.stdin.write(stdin);\n proc.stdin.end();\n return proc;\n};\n\n/** Streams stdout to `onLine` line by line, keeping only a bounded tail. */\nconst streamLines =\n (onLine: (line: string) => void, maxTailChars: number): OutputCollector =>\n (proc) => {\n const stdoutTail = new BoundedTail(maxTailChars, \"\\n\");\n const stderrTail = new BoundedTail(maxTailChars, \"\");\n const rl = createInterface({ input: proc.stdout });\n rl.on(\"line\", (line) => {\n stdoutTail.push(line);\n onLine(line);\n });\n proc.stderr.on(\"data\", (chunk: Buffer) => {\n stderrTail.push(chunk.toString());\n });\n return () => ({\n stdout: stdoutTail.toString(),\n stderr: stderrTail.toString(),\n });\n };\n\n/** Buffers all of stdout and stderr. */\nconst bufferAll: OutputCollector = (proc) => {\n const stdoutChunks: string[] = [];\n const stderrChunks: string[] = [];\n proc.stdout.on(\"data\", (chunk: Buffer) => {\n stdoutChunks.push(chunk.toString());\n });\n proc.stderr.on(\"data\", (chunk: Buffer) => {\n stderrChunks.push(chunk.toString());\n });\n return () => ({\n stdout: stdoutChunks.join(\"\"),\n stderr: stderrChunks.join(\"\"),\n });\n};\n\nconst waitForExec = async (\n proc: ExecProcess,\n collect: OutputCollector,\n): Promise<ExecResult> =>\n new Promise((resolve, reject) => {\n proc.on(\"error\", (error: Error) => {\n reject(new Error(`exec failed: ${error.message}`));\n });\n const output = collect(proc);\n proc.on(\"close\", (code: number | null) => {\n resolve({ ...output(), exitCode: code ?? 0 });\n });\n });\n\nconst runExec = async (\n command: string,\n opts: ExecOptions | undefined,\n context: HostContext,\n): Promise<ExecResult> => {\n // sudo is a no-op for no-sandbox — the user is already on the host\n const cwd = opts?.cwd ?? context.worktreePath;\n const plan = await planExec(command, context.processEnv, cwd);\n const proc = spawnExec(plan, cwd, opts?.stdin);\n const collect = opts?.onLine\n ? streamLines(opts.onLine, context.maxOutputTailChars)\n : bufferAll;\n return waitForExec(proc, collect);\n};\n\nconst runInteractiveExec = async (\n args: string[],\n opts: InteractiveExecOptions,\n context: HostContext,\n): Promise<{ exitCode: number }> => {\n const { processEnv } = context;\n const cwd = opts.cwd ?? context.worktreePath;\n const stdio = [opts.stdin, opts.stdout, opts.stderr] as StdioOptions;\n // On Windows, spawn the resolved program with its argv (escaped for\n // cmd.exe only when it is a `.cmd`/`.bat` npm shim, #940). If it\n // isn't on PATH, fall back to `shell: true` so cmd.exe can try.\n const plan =\n process.platform === \"win32\"\n ? await planWindowsSpawn(args, processEnv, cwd)\n : undefined;\n return new Promise((resolve, reject) => {\n const [cmd, ...rest] = args;\n if (cmd === undefined) {\n reject(new Error(\"interactiveExec needs a command to run\"));\n return;\n }\n const proc = plan\n ? spawn(plan.file, plan.args, {\n cwd,\n env: processEnv,\n stdio,\n windowsVerbatimArguments: plan.windowsVerbatimArguments,\n })\n : spawn(cmd, rest, {\n cwd,\n env: processEnv,\n stdio,\n shell: process.platform === \"win32\",\n });\n\n proc.on(\"error\", (error: Error) => {\n reject(new Error(`exec failed: ${error.message}`));\n });\n\n proc.on(\"close\", (code: number | null) => {\n resolve({ exitCode: code ?? 0 });\n });\n });\n};\n\n/**\n * Create a no-sandbox provider.\n *\n * The returned provider runs the agent directly on the host. All three\n * branch strategies are supported (head, merge-to-head, branch),\n * defaulting to head.\n */\nexport const noSandbox = (options?: NoSandboxOptions): NoSandboxProvider => ({\n tag: \"none\",\n name: \"no-sandbox\",\n env: options?.env ?? {},\n create: async (createOptions): Promise<NoSandboxHandle> => {\n const { worktreePath } = createOptions;\n const context: HostContext = {\n worktreePath,\n processEnv: { ...process.env, ...createOptions.env },\n maxOutputTailChars: options?.maxOutputTailChars ?? MAX_TAIL_CHARS,\n };\n\n const handle: NoSandboxHandle = {\n worktreePath,\n exec: async (command: string, opts?: ExecOptions): Promise<ExecResult> =>\n runExec(command, opts, context),\n interactiveExec: async (\n args: string[],\n opts: InteractiveExecOptions,\n ): Promise<{ exitCode: number }> =>\n runInteractiveExec(args, opts, context),\n close: async (): Promise<void> => {\n // No-op — no container to tear down\n },\n };\n\n return handle;\n },\n});\n"]}
|
package/dist/chunk-BIF2X6QB.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
import { Display } from './chunk-G2R53CVZ.js';
|
|
3
|
-
import { Effect_exports } from './chunk-STB2U7BB.js';
|
|
4
|
-
|
|
5
|
-
createRequire(import.meta.url);
|
|
6
|
-
|
|
7
|
-
// src/ErrorHandler.ts
|
|
8
|
-
var formatErrorMessage = (error) => {
|
|
9
|
-
switch (error._tag) {
|
|
10
|
-
case "ExecError": {
|
|
11
|
-
return `Command failed in sandbox (${error.command}): ${error.message}`;
|
|
12
|
-
}
|
|
13
|
-
case "ExecHostError": {
|
|
14
|
-
return `Command failed on host (${error.command}): ${error.message}`;
|
|
15
|
-
}
|
|
16
|
-
case "CopyError": {
|
|
17
|
-
return `File copy failed: ${error.message}`;
|
|
18
|
-
}
|
|
19
|
-
case "DockerError": {
|
|
20
|
-
return `Docker operation failed: ${error.message}. Is Docker running?`;
|
|
21
|
-
}
|
|
22
|
-
case "PodmanError": {
|
|
23
|
-
return `Podman operation failed: ${error.message}. Is Podman running?`;
|
|
24
|
-
}
|
|
25
|
-
case "SyncError": {
|
|
26
|
-
return `Git sync failed: ${error.message}`;
|
|
27
|
-
}
|
|
28
|
-
case "WorktreeError": {
|
|
29
|
-
return `Git worktree operation failed: ${error.message}`;
|
|
30
|
-
}
|
|
31
|
-
case "PromptError": {
|
|
32
|
-
return `Failed to resolve prompt: ${error.message}`;
|
|
33
|
-
}
|
|
34
|
-
case "AgentError": {
|
|
35
|
-
return `Agent invocation failed: ${error.message}`;
|
|
36
|
-
}
|
|
37
|
-
case "ConfigDirError":
|
|
38
|
-
case "InitError":
|
|
39
|
-
case "AgentIdleTimeoutError":
|
|
40
|
-
case "WorktreeTimeoutError":
|
|
41
|
-
case "ContainerStartTimeoutError":
|
|
42
|
-
case "CopyToWorktreeTimeoutError":
|
|
43
|
-
case "CopyToWorktreeError":
|
|
44
|
-
case "SyncInTimeoutError":
|
|
45
|
-
case "HookTimeoutError":
|
|
46
|
-
case "GitSetupTimeoutError":
|
|
47
|
-
case "PromptExpansionTimeoutError":
|
|
48
|
-
case "CommitCollectionTimeoutError":
|
|
49
|
-
case "MergeToHostTimeoutError":
|
|
50
|
-
case "SessionCaptureError":
|
|
51
|
-
case "SyncOutPathError":
|
|
52
|
-
case "CwdError":
|
|
53
|
-
case "ImageNotFoundError": {
|
|
54
|
-
return error.message;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
var showErrorAndExit = (error) => Effect_exports.gen(function* () {
|
|
59
|
-
const d = yield* Display;
|
|
60
|
-
yield* d.status(formatErrorMessage(error), "error");
|
|
61
|
-
return yield* Effect_exports.sync(() => process.exit(1));
|
|
62
|
-
});
|
|
63
|
-
var withFriendlyErrors = (effect) => Effect_exports.catchTags(effect, {
|
|
64
|
-
ExecError: showErrorAndExit,
|
|
65
|
-
ExecHostError: showErrorAndExit,
|
|
66
|
-
CopyError: showErrorAndExit,
|
|
67
|
-
DockerError: showErrorAndExit,
|
|
68
|
-
PodmanError: showErrorAndExit,
|
|
69
|
-
SyncError: showErrorAndExit,
|
|
70
|
-
SyncOutPathError: showErrorAndExit,
|
|
71
|
-
WorktreeError: showErrorAndExit,
|
|
72
|
-
PromptError: showErrorAndExit,
|
|
73
|
-
AgentError: showErrorAndExit,
|
|
74
|
-
ConfigDirError: showErrorAndExit,
|
|
75
|
-
InitError: showErrorAndExit,
|
|
76
|
-
AgentIdleTimeoutError: showErrorAndExit,
|
|
77
|
-
WorktreeTimeoutError: showErrorAndExit,
|
|
78
|
-
ContainerStartTimeoutError: showErrorAndExit,
|
|
79
|
-
CopyToWorktreeTimeoutError: showErrorAndExit,
|
|
80
|
-
CopyToWorktreeError: showErrorAndExit,
|
|
81
|
-
SyncInTimeoutError: showErrorAndExit,
|
|
82
|
-
HookTimeoutError: showErrorAndExit,
|
|
83
|
-
GitSetupTimeoutError: showErrorAndExit,
|
|
84
|
-
PromptExpansionTimeoutError: showErrorAndExit,
|
|
85
|
-
CommitCollectionTimeoutError: showErrorAndExit,
|
|
86
|
-
MergeToHostTimeoutError: showErrorAndExit,
|
|
87
|
-
SessionCaptureError: showErrorAndExit,
|
|
88
|
-
CwdError: showErrorAndExit,
|
|
89
|
-
ImageNotFoundError: showErrorAndExit
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
export { formatErrorMessage, withFriendlyErrors };
|
|
93
|
-
//# sourceMappingURL=chunk-BIF2X6QB.js.map
|
|
94
|
-
//# sourceMappingURL=chunk-BIF2X6QB.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Error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,0BAAA,EAA4B,gBAAA;AAAA,EAC5B,mBAAA,EAAqB,gBAAA;AAAA,EACrB,kBAAA,EAAoB,gBAAA;AAAA,EACpB,gBAAA,EAAkB,gBAAA;AAAA,EAClB,oBAAA,EAAsB,gBAAA;AAAA,EACtB,2BAAA,EAA6B,gBAAA;AAAA,EAC7B,4BAAA,EAA8B,gBAAA;AAAA,EAC9B,uBAAA,EAAyB,gBAAA;AAAA,EACzB,mBAAA,EAAqB,gBAAA;AAAA,EACrB,QAAA,EAAU,gBAAA;AAAA,EACV,kBAAA,EAAoB;AACtB,CAAC","file":"chunk-BIF2X6QB.js","sourcesContent":["import { Effect } from \"effect\";\nimport { Display } from \"./Display.js\";\nimport type { SandboxError } from \"./errors.js\";\n\n/**\n * Formats a tagged SandboxError into a user-friendly message with\n * context-specific hints about what went wrong and how to recover.\n */\nexport const formatErrorMessage = (error: SandboxError): string => {\n switch (error._tag) {\n case \"ExecError\": {\n return `Command failed in sandbox (${error.command}): ${error.message}`;\n }\n case \"ExecHostError\": {\n return `Command failed on host (${error.command}): ${error.message}`;\n }\n case \"CopyError\": {\n return `File copy failed: ${error.message}`;\n }\n case \"DockerError\": {\n return `Docker operation failed: ${error.message}. Is Docker running?`;\n }\n case \"PodmanError\": {\n return `Podman operation failed: ${error.message}. Is Podman running?`;\n }\n case \"SyncError\": {\n return `Git sync failed: ${error.message}`;\n }\n case \"WorktreeError\": {\n return `Git worktree operation failed: ${error.message}`;\n }\n case \"PromptError\": {\n return `Failed to resolve prompt: ${error.message}`;\n }\n case \"AgentError\": {\n return `Agent invocation failed: ${error.message}`;\n }\n case \"ConfigDirError\":\n case \"InitError\":\n case \"AgentIdleTimeoutError\":\n case \"WorktreeTimeoutError\":\n case \"ContainerStartTimeoutError\":\n case \"CopyToWorktreeTimeoutError\":\n case \"CopyToWorktreeError\":\n case \"SyncInTimeoutError\":\n case \"HookTimeoutError\":\n case \"GitSetupTimeoutError\":\n case \"PromptExpansionTimeoutError\":\n case \"CommitCollectionTimeoutError\":\n case \"MergeToHostTimeoutError\":\n case \"SessionCaptureError\":\n case \"SyncOutPathError\":\n case \"CwdError\":\n case \"ImageNotFoundError\": {\n return error.message;\n }\n }\n};\n\nconst showErrorAndExit = (error: SandboxError) =>\n Effect.gen(function* () {\n const d = yield* Display;\n yield* d.status(formatErrorMessage(error), \"error\");\n return yield* Effect.sync(() => process.exit(1));\n });\n\n/**\n * Wraps an effect so that any SandboxError is caught, displayed via the\n * Display service as an error-severity status message, then exits the process\n * with code 1. Non-SandboxError errors pass through unchanged.\n */\nexport const withFriendlyErrors = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n): Effect.Effect<A, Exclude<E, SandboxError>, R | Display> =>\n Effect.catchTags(effect as Effect.Effect<A, SandboxError, R>, {\n ExecError: showErrorAndExit,\n ExecHostError: showErrorAndExit,\n CopyError: showErrorAndExit,\n DockerError: showErrorAndExit,\n PodmanError: showErrorAndExit,\n SyncError: showErrorAndExit,\n SyncOutPathError: showErrorAndExit,\n WorktreeError: showErrorAndExit,\n PromptError: showErrorAndExit,\n AgentError: showErrorAndExit,\n ConfigDirError: showErrorAndExit,\n InitError: showErrorAndExit,\n AgentIdleTimeoutError: showErrorAndExit,\n WorktreeTimeoutError: showErrorAndExit,\n ContainerStartTimeoutError: showErrorAndExit,\n CopyToWorktreeTimeoutError: showErrorAndExit,\n CopyToWorktreeError: showErrorAndExit,\n SyncInTimeoutError: showErrorAndExit,\n HookTimeoutError: showErrorAndExit,\n GitSetupTimeoutError: showErrorAndExit,\n PromptExpansionTimeoutError: showErrorAndExit,\n CommitCollectionTimeoutError: showErrorAndExit,\n MergeToHostTimeoutError: showErrorAndExit,\n SessionCaptureError: showErrorAndExit,\n CwdError: showErrorAndExit,\n ImageNotFoundError: showErrorAndExit,\n });\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/SandboxProvider.ts"],"names":[],"mappings":";;;;;AAgVO,IAAM,8BAAA,GAAiC,CAC5C,MAAA,MAC8B;AAAA,EAC9B,GAAA,EAAK,YAAA;AAAA,EACL,MAAM,MAAA,CAAO,IAAA;AAAA,EACb,GAAA,EAAK,MAAA,CAAO,GAAA,IAAO,EAAC;AAAA,EACpB,gBAAgB,MAAA,CAAO,cAAA;AAAA,EACvB,QAAQ,MAAA,CAAO;AACjB,CAAA;AAMO,IAAM,6BAAA,GAAgC,CAC3C,MAAA,MAC6B;AAAA,EAC7B,GAAA,EAAK,UAAA;AAAA,EACL,MAAM,MAAA,CAAO,IAAA;AAAA,EACb,GAAA,EAAK,MAAA,CAAO,GAAA,IAAO,EAAC;AAAA,EACpB,QAAQ,MAAA,CAAO;AACjB,CAAA","file":"chunk-BVZWLFFT.js","sourcesContent":["/**\n * Sandbox provider types — the pluggable interface for sandbox runtimes.\n *\n * Provider authors implement a small Promise-based interface. Sandcastle\n * handles worktree creation, git mount resolution, and commit extraction.\n */\n\n/** Result of executing a command inside a sandbox. */\nexport interface ExecResult {\n readonly stdout: string;\n readonly stderr: string;\n readonly exitCode: number;\n}\n\n/** Options for interactiveExec — the streams the provider should wire to the spawned process. */\nexport interface InteractiveExecOptions {\n readonly stdin: NodeJS.ReadableStream;\n readonly stdout: NodeJS.WritableStream;\n readonly stderr: NodeJS.WritableStream;\n readonly cwd?: string;\n}\n\n/** Handle to a running bind-mount sandbox. */\nexport interface BindMountSandboxHandle {\n /** Absolute path to the worktree inside the sandbox. */\n readonly worktreePath: string;\n /**\n * The id a supervisor outside this process can use to address the sandbox\n * with the runtime's own tools, e.g. `docker()` and `podman()` set it to the\n * container name (`docker rm -f <sandboxId>`). Surfaced as\n * `Sandbox.sandboxId`. Omit it when there is nothing outside the process to\n * address, as for the native `bwrap()` and `seatbelt()` sandboxes, whose\n * sandbox is a child process of this one.\n */\n readonly sandboxId?: string;\n /**\n * Absolute path to the agent's home directory, as commands running inside\n * the sandbox see it. Sandcastle runs commands there to find and place agent\n * session files. Omit when it is `/home/agent`, as in the Docker image.\n */\n readonly sandboxHomedir?: string;\n /**\n * Absolute path to a writable temp directory, as commands running inside\n * the sandbox see it. Omit when it is `/tmp`.\n */\n readonly sandboxTmpdir?: string;\n /**\n * Execute a command in the sandbox.\n *\n * Implementations MUST support line-by-line streaming via `onLine`. This is\n * how Sandcastle delivers live feedback to the user and enforces idle timeouts —\n * without a streaming implementation, neither will work. A buffered/batch\n * implementation that only calls `onLine` after the process exits does NOT\n * satisfy this contract.\n *\n * When `stdin` is set, the implementation pipes the string to the child\n * process's stdin and closes it. This avoids the Linux 128 KB per-arg limit.\n */\n exec(\n command: string,\n options?: {\n onLine?: (line: string) => void;\n cwd?: string;\n sudo?: boolean;\n stdin?: string;\n },\n ): Promise<ExecResult>;\n /**\n * Launch an interactive process inside the sandbox.\n * Optional — providers that support interactive sessions implement this.\n * The provider detects TTY mode from the streams (e.g. stdin.isTTY) and\n * allocates a pseudo-terminal accordingly.\n */\n interactiveExec?(\n args: string[],\n options: InteractiveExecOptions,\n ): Promise<{ exitCode: number }>;\n /** Copy a single file from the host into the sandbox. */\n copyFileIn(hostPath: string, sandboxPath: string): Promise<void>;\n /** Copy a single file from the sandbox to the host. */\n copyFileOut(sandboxPath: string, hostPath: string): Promise<void>;\n /** Tear down the sandbox. */\n close(): Promise<void>;\n}\n\n/** Options passed to a bind-mount provider's `create` function. */\nexport interface BindMountCreateOptions {\n /** Host-side path to the worktree directory. */\n readonly worktreePath: string;\n /** Host-side path to the original repo root. */\n readonly hostRepoPath: string;\n /** Volume mounts to apply (host:sandbox pairs). */\n readonly mounts: {\n hostPath: string;\n sandboxPath: string;\n readonly?: boolean;\n }[];\n /** Environment variables to inject into the sandbox. */\n readonly env: Record<string, string>;\n}\n\n/** Configuration for createBindMountSandboxProvider. */\nexport interface BindMountSandboxProviderConfig {\n /** Human-readable name for this provider (e.g. \"docker\", \"podman\"). */\n readonly name: string;\n /** Environment variables injected by this provider. Merged at launch time. */\n readonly env?: Record<string, string>;\n /**\n * Absolute path to the home directory inside the sandbox (e.g. `\"/home/agent\"`).\n * Used to expand `~` in user-provided `sandboxPath` mount configs.\n * Set to `undefined` for providers that do not have a fixed home directory.\n */\n readonly sandboxHomedir?: string;\n /** Create a sandbox handle from the given options. */\n readonly create: (\n options: BindMountCreateOptions,\n ) => Promise<BindMountSandboxHandle>;\n}\n\n/** Handle to a running isolated sandbox (extends bind-mount with file transfer). */\nexport interface IsolatedSandboxHandle {\n /** Absolute path to the worktree inside the sandbox. */\n readonly worktreePath: string;\n /**\n * The vendor's id for the sandbox, so a supervisor outside this process can\n * address it with the vendor's own CLI or API, e.g. `vercel()`,\n * `daytona()` and `modal()` set it to the Vercel, Daytona and Modal sandbox\n * ids. Surfaced as\n * `Sandbox.sandboxId`. Omit it when the provider has no such id.\n */\n readonly sandboxId?: string;\n /**\n * Execute a command in the sandbox.\n *\n * Implementations MUST support line-by-line streaming via `onLine`. This is\n * how Sandcastle delivers live feedback to the user and enforces idle timeouts —\n * without a streaming implementation, neither will work. A buffered/batch\n * implementation that only calls `onLine` after the process exits does NOT\n * satisfy this contract.\n *\n * When `stdin` is set, the implementation pipes the string to the child\n * process's stdin and closes it. This avoids the Linux 128 KB per-arg limit.\n */\n exec(\n command: string,\n options?: {\n onLine?: (line: string) => void;\n cwd?: string;\n sudo?: boolean;\n stdin?: string;\n },\n ): Promise<ExecResult>;\n /**\n * Launch an interactive process inside the sandbox.\n * Optional — providers that support interactive sessions implement this.\n * The provider detects TTY mode from the streams (e.g. stdin.isTTY) and\n * allocates a pseudo-terminal accordingly.\n */\n interactiveExec?(\n args: string[],\n options: InteractiveExecOptions,\n ): Promise<{ exitCode: number }>;\n /** Copy a file or directory from the host into the sandbox. */\n copyIn(hostPath: string, sandboxPath: string): Promise<void>;\n /** Copy a single file from the sandbox to the host. */\n copyFileOut(sandboxPath: string, hostPath: string): Promise<void>;\n /** Tear down the sandbox. */\n close(): Promise<void>;\n}\n\n/** Options passed to an isolated provider's `create` function. */\nexport interface IsolatedCreateOptions {\n /** Environment variables to inject into the sandbox. */\n readonly env: Record<string, string>;\n}\n\n/** Configuration for createIsolatedSandboxProvider. */\nexport interface IsolatedSandboxProviderConfig {\n /** Human-readable name for this provider (e.g. \"daytona\", \"e2b\"). */\n readonly name: string;\n /** Environment variables injected by this provider. Merged at launch time. */\n readonly env?: Record<string, string>;\n /** Create an isolated sandbox handle from the given options. */\n readonly create: (\n options: IsolatedCreateOptions,\n ) => Promise<IsolatedSandboxHandle>;\n}\n\n/** A bind-mount sandbox provider. */\nexport interface BindMountSandboxProvider {\n /** @internal Discriminator for internal dispatch. */\n readonly tag: \"bind-mount\";\n /** Human-readable provider name. */\n readonly name: string;\n /** Environment variables injected by this provider. */\n readonly env: Record<string, string>;\n /**\n * Absolute path to the home directory inside the sandbox (e.g. `\"/home/agent\"`).\n * `undefined` when the provider does not declare a sandbox home directory.\n */\n readonly sandboxHomedir: string | undefined;\n /** @internal Create a sandbox handle. */\n readonly create: (\n options: BindMountCreateOptions,\n ) => Promise<BindMountSandboxHandle>;\n}\n\n/** An isolated sandbox provider. */\nexport interface IsolatedSandboxProvider {\n /** @internal Discriminator for internal dispatch. */\n readonly tag: \"isolated\";\n /** Human-readable provider name. */\n readonly name: string;\n /** Environment variables injected by this provider. */\n readonly env: Record<string, string>;\n /** @internal Create an isolated sandbox handle. */\n readonly create: (\n options: IsolatedCreateOptions,\n ) => Promise<IsolatedSandboxHandle>;\n}\n\n/** Handle to a no-sandbox session — runs commands directly on the host. */\nexport interface NoSandboxHandle {\n /** Absolute path to the worktree on the host. */\n readonly worktreePath: string;\n /**\n * Execute a command on the host.\n *\n * Implementations MUST support line-by-line streaming via `onLine`. This is\n * how Sandcastle delivers live feedback to the user and enforces idle timeouts —\n * without a streaming implementation, neither will work.\n *\n * When `stdin` is set, the implementation pipes the string to the child\n * process's stdin and closes it. This avoids the Linux 128 KB per-arg limit.\n */\n exec(\n command: string,\n options?: {\n onLine?: (line: string) => void;\n cwd?: string;\n sudo?: boolean;\n stdin?: string;\n },\n ): Promise<ExecResult>;\n /**\n * Launch an interactive process on the host with inherited stdio.\n */\n interactiveExec(\n args: string[],\n options: InteractiveExecOptions,\n ): Promise<{ exitCode: number }>;\n /** No-op — no container to tear down. */\n close(): Promise<void>;\n}\n\n/** A no-sandbox provider — runs the agent directly on the host with no container isolation. */\nexport interface NoSandboxProvider {\n /** @internal Discriminator for internal dispatch. */\n readonly tag: \"none\";\n /** Human-readable provider name. */\n readonly name: string;\n /** Environment variables injected by this provider. */\n readonly env: Record<string, string>;\n /** @internal Create a no-sandbox handle. */\n readonly create: (options: {\n readonly worktreePath: string;\n readonly env: Record<string, string>;\n }) => Promise<NoSandboxHandle>;\n}\n\n// ---------- Branch strategy types ----------\n\n/** Head strategy: agent writes directly to host working directory. Bind-mount only. */\nexport interface HeadBranchStrategy {\n readonly type: \"head\";\n}\n\n/** Merge-to-head strategy: temp branch, merge back to HEAD, delete temp branch. */\nexport interface MergeToHeadBranchStrategy {\n readonly type: \"merge-to-head\";\n}\n\n/** Branch strategy: commits land on an explicit named branch. */\nexport interface NamedBranchStrategy {\n readonly type: \"branch\";\n readonly branch: string;\n /**\n * Git ref to use as the starting point when creating a new branch.\n * Only used when the branch doesn't already exist — ignored otherwise.\n * Callers are responsible for ensuring the ref is current (e.g. `git fetch`).\n * Defaults to `HEAD` when omitted.\n */\n readonly baseBranch?: string;\n}\n\n/** Branch strategy for bind-mount providers (all three variants). */\nexport type BindMountBranchStrategy =\n | HeadBranchStrategy\n | MergeToHeadBranchStrategy\n | NamedBranchStrategy;\n\n/** Branch strategy for isolated providers (no head — can't write to host). */\nexport type IsolatedBranchStrategy =\n | MergeToHeadBranchStrategy\n | NamedBranchStrategy;\n\n/** Branch strategy for no-sandbox providers (all three — same as bind-mount). */\nexport type NoSandboxBranchStrategy =\n | HeadBranchStrategy\n | MergeToHeadBranchStrategy\n | NamedBranchStrategy;\n\n/** Union of all branch strategy variants. */\nexport type BranchStrategy =\n | BindMountBranchStrategy\n | IsolatedBranchStrategy\n | NoSandboxBranchStrategy;\n\n/**\n * A sandbox provider — the pluggable unit that `run()`, `interactive()`, and\n * `createSandbox()` accept. Tagged for internal dispatch: \"bind-mount\",\n * \"isolated\", or \"none\". When `NoSandboxProvider` is used, the agent runs\n * directly on the host with no container isolation — opt in at your own risk.\n */\nexport type SandboxProvider =\n | BindMountSandboxProvider\n | IsolatedSandboxProvider\n | NoSandboxProvider;\n\n/** @deprecated Use `SandboxProvider` — it now includes `NoSandboxProvider`. */\nexport type AnySandboxProvider = SandboxProvider;\n\n/**\n * Create a bind-mount sandbox provider from a config object.\n * The returned provider can be passed to `run()` or `createSandbox()`.\n */\nexport const createBindMountSandboxProvider = (\n config: BindMountSandboxProviderConfig,\n): BindMountSandboxProvider => ({\n tag: \"bind-mount\",\n name: config.name,\n env: config.env ?? {},\n sandboxHomedir: config.sandboxHomedir,\n create: config.create,\n});\n\n/**\n * Create an isolated sandbox provider from a config object.\n * The returned provider can be passed to `run()` or `createSandbox()`.\n */\nexport const createIsolatedSandboxProvider = (\n config: IsolatedSandboxProviderConfig,\n): IsolatedSandboxProvider => ({\n tag: \"isolated\",\n name: config.name,\n env: config.env ?? {},\n create: config.create,\n});\n"]}
|