@ai-hero/sandcastle 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -13
- package/dist/SandboxFactory.d.ts +15 -4
- package/dist/SandboxFactory.d.ts.map +1 -1
- package/dist/SandboxFactory.js +156 -203
- package/dist/SandboxFactory.js.map +1 -1
- package/dist/SandboxProvider.d.ts +114 -0
- package/dist/SandboxProvider.d.ts.map +1 -0
- package/dist/SandboxProvider.js +25 -0
- package/dist/SandboxProvider.js.map +1 -0
- package/dist/cli.d.ts +7 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +10 -9
- package/dist/cli.js.map +1 -1
- package/dist/createSandbox.d.ts +3 -2
- package/dist/createSandbox.d.ts.map +1 -1
- package/dist/createSandbox.js +19 -32
- package/dist/createSandbox.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/run.d.ts +4 -9
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +3 -15
- package/dist/run.js.map +1 -1
- package/dist/sandboxExec.d.ts +12 -0
- package/dist/sandboxExec.d.ts.map +1 -0
- package/dist/sandboxExec.js +26 -0
- package/dist/sandboxExec.js.map +1 -0
- package/dist/sandboxes/docker.d.ts +26 -0
- package/dist/sandboxes/docker.d.ts.map +1 -0
- package/dist/sandboxes/docker.js +133 -0
- package/dist/sandboxes/docker.js.map +1 -0
- package/dist/sandboxes/test-isolated.d.ts +17 -0
- package/dist/sandboxes/test-isolated.d.ts.map +1 -0
- package/dist/sandboxes/test-isolated.js +86 -0
- package/dist/sandboxes/test-isolated.js.map +1 -0
- package/dist/syncIn.d.ts +22 -0
- package/dist/syncIn.d.ts.map +1 -0
- package/dist/syncIn.js +57 -0
- package/dist/syncIn.js.map +1 -0
- package/dist/syncOut.d.ts +25 -0
- package/dist/syncOut.d.ts.map +1 -0
- package/dist/syncOut.js +192 -0
- package/dist/syncOut.js.map +1 -0
- package/dist/templates/blank/main.mts +2 -0
- package/dist/templates/parallel-planner/main.mts +4 -0
- package/dist/templates/sequential-reviewer/main.mts +3 -0
- package/dist/templates/simple-loop/main.mts +4 -0
- package/package.json +5 -1
package/dist/run.js
CHANGED
|
@@ -25,16 +25,6 @@ export const printFileDisplayStartup = (options) => {
|
|
|
25
25
|
console.log(`${label} Started${branchPart}`);
|
|
26
26
|
console.log(styleText("dim", ` tail -f ${relativeLogPath}`));
|
|
27
27
|
};
|
|
28
|
-
/**
|
|
29
|
-
* Derive the default Docker image name from the repo directory.
|
|
30
|
-
* Returns `sandcastle:<dir-name>` where dir-name is the last path segment,
|
|
31
|
-
* lowercased and sanitized for Docker image tag rules.
|
|
32
|
-
*/
|
|
33
|
-
export const defaultImageName = (repoDir) => {
|
|
34
|
-
const dirName = repoDir.replace(/\/+$/, "").split("/").pop() ?? "local";
|
|
35
|
-
const sanitized = dirName.toLowerCase().replace(/[^a-z0-9_.-]/g, "-");
|
|
36
|
-
return `sandcastle:${sanitized}`;
|
|
37
|
-
};
|
|
38
28
|
/**
|
|
39
29
|
* Build the log filename for a run.
|
|
40
30
|
* When a targetBranch is provided (temp branch mode), prefixes the filename
|
|
@@ -60,7 +50,7 @@ export const buildLogFilename = (resolvedBranch, targetBranch, name) => {
|
|
|
60
50
|
*/
|
|
61
51
|
export const buildRunSummaryRows = (options) => ({
|
|
62
52
|
Agent: options.name ?? options.agentName,
|
|
63
|
-
|
|
53
|
+
Sandbox: options.sandboxName,
|
|
64
54
|
"Max iterations": String(options.maxIterations),
|
|
65
55
|
Branch: options.branch,
|
|
66
56
|
});
|
|
@@ -99,8 +89,6 @@ export const run = async (options) => {
|
|
|
99
89
|
// Resolve prompt
|
|
100
90
|
const rawPrompt = await Effect.runPromise(resolvePrompt({ prompt, promptFile }).pipe(Effect.provide(NodeContext.layer)));
|
|
101
91
|
const agentName = provider.name;
|
|
102
|
-
// Resolve image name: explicit option > default
|
|
103
|
-
const resolvedImageName = options.imageName ?? defaultImageName(hostRepoDir);
|
|
104
92
|
// Resolve env vars
|
|
105
93
|
const env = await Effect.runPromise(resolveEnv(hostRepoDir).pipe(Effect.provide(NodeContext.layer)));
|
|
106
94
|
// Always capture the host's current branch for the TARGET_BRANCH built-in
|
|
@@ -130,12 +118,12 @@ export const run = async (options) => {
|
|
|
130
118
|
})()
|
|
131
119
|
: ClackDisplay.layer;
|
|
132
120
|
const factoryLayer = Layer.provide(WorktreeDockerSandboxFactory.layer, Layer.mergeAll(Layer.succeed(WorktreeSandboxConfig, {
|
|
133
|
-
imageName: resolvedImageName,
|
|
134
121
|
env,
|
|
135
122
|
hostRepoDir,
|
|
136
123
|
worktree: worktreeMode,
|
|
137
124
|
copyToSandbox: options.copyToSandbox,
|
|
138
125
|
name: options.name,
|
|
126
|
+
sandboxProvider: options.sandbox,
|
|
139
127
|
}), NodeFileSystem.layer, displayLayer));
|
|
140
128
|
const runLayer = Layer.merge(factoryLayer, displayLayer);
|
|
141
129
|
const result = await Effect.runPromise(Effect.gen(function* () {
|
|
@@ -144,7 +132,7 @@ export const run = async (options) => {
|
|
|
144
132
|
const rows = buildRunSummaryRows({
|
|
145
133
|
name: options.name,
|
|
146
134
|
agentName,
|
|
147
|
-
|
|
135
|
+
sandboxName: options.sandbox.name,
|
|
148
136
|
maxIterations,
|
|
149
137
|
branch: resolvedBranch,
|
|
150
138
|
});
|
package/dist/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;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O,CAAC,QAAQ,CAAC,CAAC,CAClC,CAAC;IAEF,OAAO;QACL,GAAG,MAAM;QACT,WAAW,EACT,eAAe,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;KACrE,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IsolatedSandboxHandle } from "./SandboxProvider.js";
|
|
2
|
+
/** Execute a command on the host side, returning stdout. Throws on non-zero exit. */
|
|
3
|
+
export declare const execHost: (command: string, cwd: string) => Promise<string>;
|
|
4
|
+
/** Execute a command in the sandbox, throwing if it fails. */
|
|
5
|
+
export declare const execOk: (handle: IsolatedSandboxHandle, command: string, options?: {
|
|
6
|
+
cwd?: string | undefined;
|
|
7
|
+
} | undefined) => Promise<{
|
|
8
|
+
stdout: string;
|
|
9
|
+
stderr: string;
|
|
10
|
+
exitCode: number;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=sandboxExec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandboxExec.d.ts","sourceRoot":"","sources":["../src/sandboxExec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAIlE,qFAAqF;AACrF,eAAO,MAAM,QAAQ,mDAcpB,CAAC;AAEF,8DAA8D;AAC9D,eAAO,MAAM,MAAM;;;;;;EAYlB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { exec } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
const execAsync = promisify(exec);
|
|
4
|
+
/** Execute a command on the host side, returning stdout. Throws on non-zero exit. */
|
|
5
|
+
export const execHost = async (command, cwd) => {
|
|
6
|
+
try {
|
|
7
|
+
const { stdout } = await execAsync(command, {
|
|
8
|
+
cwd,
|
|
9
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
10
|
+
});
|
|
11
|
+
return stdout;
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
15
|
+
throw new Error(`Host command failed: ${command}\n${message}`);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
/** Execute a command in the sandbox, throwing if it fails. */
|
|
19
|
+
export const execOk = async (handle, command, options) => {
|
|
20
|
+
const result = await handle.exec(command, options);
|
|
21
|
+
if (result.exitCode !== 0) {
|
|
22
|
+
throw new Error(`Sandbox command failed (exit ${result.exitCode}): ${command}\n${result.stderr}`);
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=sandboxExec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandboxExec.js","sourceRoot":"","sources":["../src/sandboxExec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC,qFAAqF;AACrF,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B,OAAe,EACf,GAAW,EACM,EAAE;IACnB,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE;YAC1C,GAAG;YACH,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;SAC5B,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,KAAK,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;AACH,CAAC,CAAC;AAEF,8DAA8D;AAC9D,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EACzB,MAA6B,EAC7B,OAAe,EACf,OAA0B,EACqC,EAAE;IACjE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACnD,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,gCAAgC,MAAM,CAAC,QAAQ,MAAM,OAAO,KAAK,MAAM,CAAC,MAAM,EAAE,CACjF,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Docker sandbox provider — wraps DockerLifecycle into a SandboxProvider.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { docker } from "sandcastle/sandboxes/docker";
|
|
6
|
+
* await run({ agent: claudeCode("claude-opus-4-6"), sandbox: docker() });
|
|
7
|
+
*/
|
|
8
|
+
import { type SandboxProvider } from "../SandboxProvider.js";
|
|
9
|
+
export interface DockerOptions {
|
|
10
|
+
/** Docker image name (default: derived from repo directory name). */
|
|
11
|
+
readonly imageName?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a Docker sandbox provider.
|
|
15
|
+
*
|
|
16
|
+
* The returned provider creates Docker containers with bind-mounts
|
|
17
|
+
* for the worktree and git directories.
|
|
18
|
+
*/
|
|
19
|
+
export declare const docker: (options?: DockerOptions | undefined) => SandboxProvider;
|
|
20
|
+
/**
|
|
21
|
+
* Derive the default Docker image name from the repo directory.
|
|
22
|
+
* Returns `sandcastle:<dir-name>` where dir-name is the last path segment,
|
|
23
|
+
* lowercased and sanitized for Docker image tag rules.
|
|
24
|
+
*/
|
|
25
|
+
export declare const defaultImageName: (repoDir: string) => string;
|
|
26
|
+
//# sourceMappingURL=docker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../../src/sandboxes/docker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,OAAO,EAEL,KAAK,eAAe,EAIrB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,eAAO,MAAM,MAAM,0DAuJlB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,6BAI5B,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Docker sandbox provider — wraps DockerLifecycle into a SandboxProvider.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { docker } from "sandcastle/sandboxes/docker";
|
|
6
|
+
* await run({ agent: claudeCode("claude-opus-4-6"), sandbox: docker() });
|
|
7
|
+
*/
|
|
8
|
+
import { execFile, execFileSync, spawn } from "node:child_process";
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
|
+
import { createInterface } from "node:readline";
|
|
11
|
+
import { Effect } from "effect";
|
|
12
|
+
import { startContainer, removeContainer, chownInContainer, } from "../DockerLifecycle.js";
|
|
13
|
+
import { createBindMountSandboxProvider, } from "../SandboxProvider.js";
|
|
14
|
+
/**
|
|
15
|
+
* Create a Docker sandbox provider.
|
|
16
|
+
*
|
|
17
|
+
* The returned provider creates Docker containers with bind-mounts
|
|
18
|
+
* for the worktree and git directories.
|
|
19
|
+
*/
|
|
20
|
+
export const docker = (options) => {
|
|
21
|
+
const configuredImageName = options?.imageName;
|
|
22
|
+
return createBindMountSandboxProvider({
|
|
23
|
+
name: "docker",
|
|
24
|
+
create: async (createOptions) => {
|
|
25
|
+
const containerName = `sandcastle-${randomUUID()}`;
|
|
26
|
+
const workspacePath = createOptions.mounts.find((m) => m.hostPath === createOptions.worktreePath)?.sandboxPath ?? "/home/agent/workspace";
|
|
27
|
+
// Build volume mount strings
|
|
28
|
+
const volumeMounts = createOptions.mounts.map((m) => {
|
|
29
|
+
const base = `${m.hostPath}:${m.sandboxPath}`;
|
|
30
|
+
return m.readonly ? `${base}:ro` : base;
|
|
31
|
+
});
|
|
32
|
+
// Resolve image name
|
|
33
|
+
const imageName = configuredImageName ?? defaultImageName(createOptions.hostRepoPath);
|
|
34
|
+
const hostUid = process.getuid?.() ?? 1000;
|
|
35
|
+
const hostGid = process.getgid?.() ?? 1000;
|
|
36
|
+
// Start container
|
|
37
|
+
await Effect.runPromise(startContainer(containerName, imageName, {
|
|
38
|
+
...createOptions.env,
|
|
39
|
+
HOME: "/home/agent",
|
|
40
|
+
}, {
|
|
41
|
+
volumeMounts,
|
|
42
|
+
workdir: workspacePath,
|
|
43
|
+
user: `${hostUid}:${hostGid}`,
|
|
44
|
+
}).pipe(Effect.andThen(chownInContainer(containerName, `${hostUid}:${hostGid}`, "/home/agent"))));
|
|
45
|
+
// Set up signal handlers for cleanup
|
|
46
|
+
const onExit = () => {
|
|
47
|
+
try {
|
|
48
|
+
execFileSync("docker", ["rm", "-f", containerName], {
|
|
49
|
+
stdio: "ignore",
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
/* best-effort */
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const onSignal = () => {
|
|
57
|
+
onExit();
|
|
58
|
+
process.exit(1);
|
|
59
|
+
};
|
|
60
|
+
process.on("exit", onExit);
|
|
61
|
+
process.on("SIGINT", onSignal);
|
|
62
|
+
process.on("SIGTERM", onSignal);
|
|
63
|
+
const handle = {
|
|
64
|
+
workspacePath,
|
|
65
|
+
exec: (command, opts) => new Promise((resolve, reject) => {
|
|
66
|
+
const args = ["exec"];
|
|
67
|
+
if (opts?.cwd)
|
|
68
|
+
args.push("-w", opts.cwd);
|
|
69
|
+
args.push(containerName, "sh", "-c", command);
|
|
70
|
+
execFile("docker", args, { maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => {
|
|
71
|
+
if (error && error.code === undefined) {
|
|
72
|
+
reject(new Error(`docker exec failed: ${error.message}`));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
resolve({
|
|
76
|
+
stdout: stdout.toString(),
|
|
77
|
+
stderr: stderr.toString(),
|
|
78
|
+
exitCode: typeof error?.code === "number" ? error.code : 0,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}),
|
|
83
|
+
execStreaming: (command, onLine, opts) => new Promise((resolve, reject) => {
|
|
84
|
+
const args = ["exec"];
|
|
85
|
+
if (opts?.cwd)
|
|
86
|
+
args.push("-w", opts.cwd);
|
|
87
|
+
args.push(containerName, "sh", "-c", command);
|
|
88
|
+
const proc = spawn("docker", args, {
|
|
89
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
90
|
+
});
|
|
91
|
+
const stdoutChunks = [];
|
|
92
|
+
const stderrChunks = [];
|
|
93
|
+
const rl = createInterface({ input: proc.stdout });
|
|
94
|
+
rl.on("line", (line) => {
|
|
95
|
+
stdoutChunks.push(line);
|
|
96
|
+
onLine(line);
|
|
97
|
+
});
|
|
98
|
+
proc.stderr.on("data", (chunk) => {
|
|
99
|
+
stderrChunks.push(chunk.toString());
|
|
100
|
+
});
|
|
101
|
+
proc.on("error", (error) => {
|
|
102
|
+
reject(new Error(`docker exec streaming failed: ${error.message}`));
|
|
103
|
+
});
|
|
104
|
+
proc.on("close", (code) => {
|
|
105
|
+
resolve({
|
|
106
|
+
stdout: stdoutChunks.join("\n"),
|
|
107
|
+
stderr: stderrChunks.join(""),
|
|
108
|
+
exitCode: code ?? 0,
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}),
|
|
112
|
+
close: async () => {
|
|
113
|
+
process.removeListener("exit", onExit);
|
|
114
|
+
process.removeListener("SIGINT", onSignal);
|
|
115
|
+
process.removeListener("SIGTERM", onSignal);
|
|
116
|
+
await Effect.runPromise(removeContainer(containerName));
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
return handle;
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Derive the default Docker image name from the repo directory.
|
|
125
|
+
* Returns `sandcastle:<dir-name>` where dir-name is the last path segment,
|
|
126
|
+
* lowercased and sanitized for Docker image tag rules.
|
|
127
|
+
*/
|
|
128
|
+
export const defaultImageName = (repoDir) => {
|
|
129
|
+
const dirName = repoDir.replace(/\/+$/, "").split("/").pop() ?? "local";
|
|
130
|
+
const sanitized = dirName.toLowerCase().replace(/[^a-z0-9_.-]/g, "-");
|
|
131
|
+
return `sandcastle:${sanitized}`;
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=docker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../../src/sandboxes/docker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,8BAA8B,GAK/B,MAAM,uBAAuB,CAAC;AAO/B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAuB,EAAmB,EAAE;IACjE,MAAM,mBAAmB,GAAG,OAAO,EAAE,SAAS,CAAC;IAE/C,OAAO,8BAA8B,CAAC;QACpC,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,KAAK,EACX,aAAqC,EACJ,EAAE;YACnC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AG,OAAO,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;IACtE,OAAO,cAAc,SAAS,EAAE,CAAC;AACnC,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem-based test isolated sandbox provider.
|
|
3
|
+
*
|
|
4
|
+
* Uses a temp directory on the local filesystem as the "sandbox".
|
|
5
|
+
* Intended for testing the isolated provider abstraction without
|
|
6
|
+
* requiring a real remote environment.
|
|
7
|
+
*/
|
|
8
|
+
import { type IsolatedSandboxProvider } from "../SandboxProvider.js";
|
|
9
|
+
/**
|
|
10
|
+
* Create a filesystem-based test isolated sandbox provider.
|
|
11
|
+
*
|
|
12
|
+
* The "sandbox" is a temp directory. `exec` runs shell commands in it,
|
|
13
|
+
* `copyIn`/`copyOut` copy files between host and the temp dir,
|
|
14
|
+
* and `close` removes the temp dir.
|
|
15
|
+
*/
|
|
16
|
+
export declare const testIsolated: () => IsolatedSandboxProvider;
|
|
17
|
+
//# sourceMappingURL=test-isolated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-isolated.d.ts","sourceRoot":"","sources":["../../src/sandboxes/test-isolated.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAE/B;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,+BA+FrB,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem-based test isolated sandbox provider.
|
|
3
|
+
*
|
|
4
|
+
* Uses a temp directory on the local filesystem as the "sandbox".
|
|
5
|
+
* Intended for testing the isolated provider abstraction without
|
|
6
|
+
* requiring a real remote environment.
|
|
7
|
+
*/
|
|
8
|
+
import { execFile, spawn } from "node:child_process";
|
|
9
|
+
import { copyFile, mkdir, mkdtemp, rm } from "node:fs/promises";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { dirname, join } from "node:path";
|
|
12
|
+
import { createInterface } from "node:readline";
|
|
13
|
+
import { createIsolatedSandboxProvider, } from "../SandboxProvider.js";
|
|
14
|
+
/**
|
|
15
|
+
* Create a filesystem-based test isolated sandbox provider.
|
|
16
|
+
*
|
|
17
|
+
* The "sandbox" is a temp directory. `exec` runs shell commands in it,
|
|
18
|
+
* `copyIn`/`copyOut` copy files between host and the temp dir,
|
|
19
|
+
* and `close` removes the temp dir.
|
|
20
|
+
*/
|
|
21
|
+
export const testIsolated = () => createIsolatedSandboxProvider({
|
|
22
|
+
name: "test-isolated",
|
|
23
|
+
create: async () => {
|
|
24
|
+
const sandboxRoot = await mkdtemp(join(tmpdir(), "sandcastle-test-"));
|
|
25
|
+
const workspacePath = join(sandboxRoot, "workspace");
|
|
26
|
+
await mkdir(workspacePath, { recursive: true });
|
|
27
|
+
return {
|
|
28
|
+
workspacePath,
|
|
29
|
+
exec: (command, options) => new Promise((resolve, reject) => {
|
|
30
|
+
execFile("sh", ["-c", command], {
|
|
31
|
+
cwd: options?.cwd ?? workspacePath,
|
|
32
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
33
|
+
}, (error, stdout, stderr) => {
|
|
34
|
+
if (error && error.code === undefined) {
|
|
35
|
+
reject(new Error(`exec failed: ${error.message}`));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
resolve({
|
|
39
|
+
stdout: stdout.toString(),
|
|
40
|
+
stderr: stderr.toString(),
|
|
41
|
+
exitCode: typeof error?.code === "number" ? error.code : 0,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}),
|
|
46
|
+
execStreaming: (command, onLine, options) => new Promise((resolve, reject) => {
|
|
47
|
+
const proc = spawn("sh", ["-c", command], {
|
|
48
|
+
cwd: options?.cwd ?? workspacePath,
|
|
49
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
50
|
+
});
|
|
51
|
+
const stdoutChunks = [];
|
|
52
|
+
const stderrChunks = [];
|
|
53
|
+
const rl = createInterface({ input: proc.stdout });
|
|
54
|
+
rl.on("line", (line) => {
|
|
55
|
+
stdoutChunks.push(line);
|
|
56
|
+
onLine(line);
|
|
57
|
+
});
|
|
58
|
+
proc.stderr.on("data", (chunk) => {
|
|
59
|
+
stderrChunks.push(chunk.toString());
|
|
60
|
+
});
|
|
61
|
+
proc.on("error", (error) => {
|
|
62
|
+
reject(new Error(`exec streaming failed: ${error.message}`));
|
|
63
|
+
});
|
|
64
|
+
proc.on("close", (code) => {
|
|
65
|
+
resolve({
|
|
66
|
+
stdout: stdoutChunks.join("\n"),
|
|
67
|
+
stderr: stderrChunks.join(""),
|
|
68
|
+
exitCode: code ?? 0,
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}),
|
|
72
|
+
copyIn: async (hostPath, sandboxPath) => {
|
|
73
|
+
await mkdir(dirname(sandboxPath), { recursive: true });
|
|
74
|
+
await copyFile(hostPath, sandboxPath);
|
|
75
|
+
},
|
|
76
|
+
copyOut: async (sandboxPath, hostPath) => {
|
|
77
|
+
await mkdir(dirname(hostPath), { recursive: true });
|
|
78
|
+
await copyFile(sandboxPath, hostPath);
|
|
79
|
+
},
|
|
80
|
+
close: async () => {
|
|
81
|
+
await rm(sandboxRoot, { recursive: true, force: true });
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=test-isolated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-isolated.js","sourceRoot":"","sources":["../../src/sandboxes/test-isolated.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE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AC,CAAC;gBAEH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;oBACxB,OAAO,CAAC;wBACN,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;wBAC/B,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;wBAC7B,QAAQ,EAAE,IAAI,IAAI,CAAC;qBACpB,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC,CAAC;YAEJ,MAAM,EAAE,KAAK,EACX,QAAgB,EAChB,WAAmB,EACJ,EAAE;gBACjB,MAAM,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBACvD,MAAM,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YACxC,CAAC;YAED,OAAO,EAAE,KAAK,EACZ,WAAmB,EACnB,QAAgB,EACD,EAAE;gBACjB,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBACpD,MAAM,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;YACxC,CAAC;YAED,KAAK,EAAE,KAAK,IAAmB,EAAE;gBAC/B,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1D,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/dist/syncIn.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync-in: transfer a host git repo into an isolated sandbox via git bundle.
|
|
3
|
+
*
|
|
4
|
+
* Creates a git bundle capturing all refs from the host repo,
|
|
5
|
+
* copies it into the sandbox via the provider's copyIn, and
|
|
6
|
+
* clones from the bundle inside the sandbox.
|
|
7
|
+
*/
|
|
8
|
+
import type { IsolatedSandboxHandle } from "./SandboxProvider.js";
|
|
9
|
+
/**
|
|
10
|
+
* Sync a host git repo into an isolated sandbox.
|
|
11
|
+
*
|
|
12
|
+
* 1. `git bundle create --all` on the host
|
|
13
|
+
* 2. `copyIn` the bundle to the sandbox
|
|
14
|
+
* 3. `git clone` from the bundle inside the sandbox
|
|
15
|
+
* 4. Verify HEAD matches
|
|
16
|
+
*
|
|
17
|
+
* @returns The branch name that was checked out
|
|
18
|
+
*/
|
|
19
|
+
export declare const syncIn: (hostRepoDir: string, handle: IsolatedSandboxHandle) => Promise<{
|
|
20
|
+
branch: string;
|
|
21
|
+
}>;
|
|
22
|
+
//# sourceMappingURL=syncIn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncIn.d.ts","sourceRoot":"","sources":["../src/syncIn.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAGlE;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM;;EA0DlB,CAAC"}
|
package/dist/syncIn.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync-in: transfer a host git repo into an isolated sandbox via git bundle.
|
|
3
|
+
*
|
|
4
|
+
* Creates a git bundle capturing all refs from the host repo,
|
|
5
|
+
* copies it into the sandbox via the provider's copyIn, and
|
|
6
|
+
* clones from the bundle inside the sandbox.
|
|
7
|
+
*/
|
|
8
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
9
|
+
import { tmpdir } from "node:os";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { execHost, execOk } from "./sandboxExec.js";
|
|
12
|
+
/**
|
|
13
|
+
* Sync a host git repo into an isolated sandbox.
|
|
14
|
+
*
|
|
15
|
+
* 1. `git bundle create --all` on the host
|
|
16
|
+
* 2. `copyIn` the bundle to the sandbox
|
|
17
|
+
* 3. `git clone` from the bundle inside the sandbox
|
|
18
|
+
* 4. Verify HEAD matches
|
|
19
|
+
*
|
|
20
|
+
* @returns The branch name that was checked out
|
|
21
|
+
*/
|
|
22
|
+
export const syncIn = async (hostRepoDir, handle) => {
|
|
23
|
+
// Get current branch from host
|
|
24
|
+
const branch = (await execHost("git rev-parse --abbrev-ref HEAD", hostRepoDir)).trim();
|
|
25
|
+
// Create git bundle on host capturing all refs
|
|
26
|
+
const bundleDir = await mkdtemp(join(tmpdir(), "sandcastle-bundle-"));
|
|
27
|
+
const bundleHostPath = join(bundleDir, "repo.bundle");
|
|
28
|
+
try {
|
|
29
|
+
await execHost(`git bundle create "${bundleHostPath}" --all`, hostRepoDir);
|
|
30
|
+
// Create temp dir in sandbox and copy bundle in
|
|
31
|
+
const mkTempResult = await execOk(handle, "mktemp -d -t sandcastle-XXXXXX");
|
|
32
|
+
const sandboxTmpDir = mkTempResult.stdout.trim();
|
|
33
|
+
const bundleSandboxPath = `${sandboxTmpDir}/repo.bundle`;
|
|
34
|
+
await handle.copyIn(bundleHostPath, bundleSandboxPath);
|
|
35
|
+
// Clone from bundle into the workspace
|
|
36
|
+
const workspacePath = handle.workspacePath;
|
|
37
|
+
await execOk(handle, `git clone "${bundleSandboxPath}" "${workspacePath}_clone"`);
|
|
38
|
+
// Move contents from clone into workspace (git clone requires empty target)
|
|
39
|
+
await execOk(handle, `rm -rf "${workspacePath}" && mv "${workspacePath}_clone" "${workspacePath}"`);
|
|
40
|
+
// Checkout the correct branch
|
|
41
|
+
await execOk(handle, `git checkout "${branch}"`, { cwd: workspacePath });
|
|
42
|
+
// Clean up sandbox temp files
|
|
43
|
+
await handle.exec(`rm -rf "${sandboxTmpDir}"`);
|
|
44
|
+
// Verify sync succeeded
|
|
45
|
+
const hostHead = (await execHost("git rev-parse HEAD", hostRepoDir)).trim();
|
|
46
|
+
const sandboxHead = (await execOk(handle, "git rev-parse HEAD", { cwd: workspacePath })).stdout.trim();
|
|
47
|
+
if (hostHead !== sandboxHead) {
|
|
48
|
+
throw new Error(`HEAD mismatch after sync-in: host=${hostHead} sandbox=${sandboxHead}`);
|
|
49
|
+
}
|
|
50
|
+
return { branch };
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
// Clean up host-side bundle temp dir
|
|
54
|
+
await rm(bundleDir, { recursive: true, force: true });
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=syncIn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncIn.js","sourceRoot":"","sources":["../src/syncIn.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EACzB,WAAmB,EACnB,MAA6B,EACA,EAAE;IAC/B,+BAA+B;IAC/B,MAAM,MAAM,GAAG,CACb,MAAM,QAAQ,CAAC,iCAAiC,EAAE,WAAW,CAAC,CAC/D,CAAC,IAAI,EAAE,CAAC;IAET,+CAA+C;IAC/C,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC;IACtE,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACtD,IAAI,CAAC;QACH,MAAM,QAAQ,CAAC,sBAAsB,cAAc,SAAS,EAAE,WAAW,CAAC,CAAC;QAE3E,gDAAgD;QAChD,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,gCAAgC,CAAC,CAAC;QAC5E,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,CAAC,I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
|
1
|
+
/**
|
|
2
|
+
* Sync-out: extract changes from an isolated sandbox back to the host.
|
|
3
|
+
*
|
|
4
|
+
* Two-phase approach:
|
|
5
|
+
* 1. Save phase: eagerly save all artifacts (patches, diff, untracked files)
|
|
6
|
+
* to `.sandcastle/patches/<timestamp>/` before attempting to apply.
|
|
7
|
+
* 2. Apply phase: apply from the saved directory.
|
|
8
|
+
* - On success: clean up the patch directory.
|
|
9
|
+
* - On failure: preserve the patch directory and print recovery commands.
|
|
10
|
+
*
|
|
11
|
+
* Three-prong extraction within each phase:
|
|
12
|
+
* 1. Committed changes: `git format-patch` + `git am --3way`
|
|
13
|
+
* 2. Uncommitted changes (staged + unstaged): `git diff HEAD` + `git apply`
|
|
14
|
+
* 3. Untracked files: `git ls-files --others` + `copyOut` each file
|
|
15
|
+
*/
|
|
16
|
+
import type { IsolatedSandboxHandle } from "./SandboxProvider.js";
|
|
17
|
+
/**
|
|
18
|
+
* Sync changes from an isolated sandbox back to the host repo.
|
|
19
|
+
*
|
|
20
|
+
* Two-phase extraction with artifact persistence:
|
|
21
|
+
* 1. Save all artifacts to `.sandcastle/patches/<timestamp>/`
|
|
22
|
+
* 2. Apply from saved directory; on failure, preserve artifacts and print recovery
|
|
23
|
+
*/
|
|
24
|
+
export declare const syncOut: (hostRepoDir: string, handle: IsolatedSandboxHandle) => Promise<void>;
|
|
25
|
+
//# sourceMappingURL=syncOut.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncOut.d.ts","sourceRoot":"","sources":["../src/syncOut.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAYH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAyClE;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,uEAkKnB,CAAC"}
|