@ai-hero/sandcastle 0.4.8 → 0.5.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/README.md +145 -69
- package/dist/AgentProvider.d.ts +9 -0
- package/dist/AgentProvider.d.ts.map +1 -1
- package/dist/AgentProvider.js +14 -2
- package/dist/AgentProvider.js.map +1 -1
- package/dist/ErrorHandler.d.ts.map +1 -1
- package/dist/ErrorHandler.js +4 -0
- package/dist/ErrorHandler.js.map +1 -1
- package/dist/Orchestrator.d.ts +13 -2
- package/dist/Orchestrator.d.ts.map +1 -1
- package/dist/Orchestrator.js +53 -7
- package/dist/Orchestrator.js.map +1 -1
- package/dist/PodmanLifecycle.d.ts +10 -0
- package/dist/PodmanLifecycle.d.ts.map +1 -1
- package/dist/PodmanLifecycle.js +22 -0
- package/dist/PodmanLifecycle.js.map +1 -1
- package/dist/SandboxFactory.d.ts +6 -2
- package/dist/SandboxFactory.d.ts.map +1 -1
- package/dist/SandboxFactory.js +41 -21
- package/dist/SandboxFactory.js.map +1 -1
- package/dist/SandboxLifecycle.d.ts +23 -5
- package/dist/SandboxLifecycle.d.ts.map +1 -1
- package/dist/SandboxLifecycle.js +59 -13
- package/dist/SandboxLifecycle.js.map +1 -1
- package/dist/SandboxProvider.d.ts +4 -0
- package/dist/SandboxProvider.d.ts.map +1 -1
- package/dist/SandboxProvider.js.map +1 -1
- package/dist/SessionPaths.d.ts +26 -0
- package/dist/SessionPaths.d.ts.map +1 -0
- package/dist/SessionPaths.js +20 -0
- package/dist/SessionPaths.js.map +1 -0
- package/dist/SessionStore.d.ts +49 -0
- package/dist/SessionStore.d.ts.map +1 -0
- package/dist/SessionStore.js +119 -0
- package/dist/SessionStore.js.map +1 -0
- package/dist/createSandbox.d.ts +16 -16
- package/dist/createSandbox.d.ts.map +1 -1
- package/dist/createSandbox.js +53 -26
- package/dist/createSandbox.js.map +1 -1
- package/dist/createWorktree.d.ts +18 -13
- package/dist/createWorktree.d.ts.map +1 -1
- package/dist/createWorktree.js +12 -6
- package/dist/createWorktree.js.map +1 -1
- package/dist/errors.d.ts +13 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +5 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/interactive.d.ts +8 -0
- package/dist/interactive.d.ts.map +1 -1
- package/dist/interactive.js +11 -2
- package/dist/interactive.js.map +1 -1
- package/dist/resolveCwd.d.ts +24 -0
- package/dist/resolveCwd.d.ts.map +1 -0
- package/dist/resolveCwd.js +32 -0
- package/dist/resolveCwd.js.map +1 -0
- package/dist/run.d.ts +31 -10
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +28 -5
- package/dist/run.js.map +1 -1
- package/dist/sandboxes/docker.d.ts.map +1 -1
- package/dist/sandboxes/docker.js +20 -0
- package/dist/sandboxes/docker.js.map +1 -1
- package/dist/sandboxes/podman.d.ts.map +1 -1
- package/dist/sandboxes/podman.js +26 -0
- package/dist/sandboxes/podman.js.map +1 -1
- package/dist/sandboxes/test-bind-mount.d.ts +17 -0
- package/dist/sandboxes/test-bind-mount.d.ts.map +1 -0
- package/dist/sandboxes/test-bind-mount.js +91 -0
- package/dist/sandboxes/test-bind-mount.js.map +1 -0
- package/dist/templates/parallel-planner/main.mts +1 -1
- package/dist/templates/parallel-planner-with-review/main.mts +1 -1
- package/dist/templates/sequential-reviewer/main.mts +1 -1
- package/dist/templates/simple-loop/main.mts +7 -5
- package/package.json +1 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem-based test bind-mount sandbox provider.
|
|
3
|
+
*
|
|
4
|
+
* Uses a temp directory on the local filesystem as the "sandbox".
|
|
5
|
+
* Intended for testing the bind-mount provider abstraction without
|
|
6
|
+
* requiring Docker or Podman.
|
|
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 { createBindMountSandboxProvider, } from "../SandboxProvider.js";
|
|
14
|
+
/**
|
|
15
|
+
* Create a filesystem-based test bind-mount sandbox provider.
|
|
16
|
+
*
|
|
17
|
+
* The "sandbox" is a temp directory. `exec` runs shell commands in it,
|
|
18
|
+
* `copyFileIn`/`copyFileOut` copy single files between host and the temp dir,
|
|
19
|
+
* and `close` removes the temp dir.
|
|
20
|
+
*/
|
|
21
|
+
export const testBindMount = () => createBindMountSandboxProvider({
|
|
22
|
+
name: "test-bind-mount",
|
|
23
|
+
create: async () => {
|
|
24
|
+
const sandboxRoot = await mkdtemp(join(tmpdir(), "sandcastle-test-bm-"));
|
|
25
|
+
const worktreePath = join(sandboxRoot, "workspace");
|
|
26
|
+
await mkdir(worktreePath, { recursive: true });
|
|
27
|
+
return {
|
|
28
|
+
worktreePath,
|
|
29
|
+
exec: (command, options) => {
|
|
30
|
+
if (options?.onLine) {
|
|
31
|
+
const onLine = options.onLine;
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const proc = spawn("sh", ["-c", command], {
|
|
34
|
+
cwd: options?.cwd ?? worktreePath,
|
|
35
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
36
|
+
});
|
|
37
|
+
const stdoutChunks = [];
|
|
38
|
+
const stderrChunks = [];
|
|
39
|
+
const rl = createInterface({ input: proc.stdout });
|
|
40
|
+
rl.on("line", (line) => {
|
|
41
|
+
stdoutChunks.push(line);
|
|
42
|
+
onLine(line);
|
|
43
|
+
});
|
|
44
|
+
proc.stderr.on("data", (chunk) => {
|
|
45
|
+
stderrChunks.push(chunk.toString());
|
|
46
|
+
});
|
|
47
|
+
proc.on("error", (error) => {
|
|
48
|
+
reject(new Error(`exec failed: ${error.message}`));
|
|
49
|
+
});
|
|
50
|
+
proc.on("close", (code) => {
|
|
51
|
+
resolve({
|
|
52
|
+
stdout: stdoutChunks.join("\n"),
|
|
53
|
+
stderr: stderrChunks.join(""),
|
|
54
|
+
exitCode: code ?? 0,
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
execFile("sh", ["-c", command], {
|
|
61
|
+
cwd: options?.cwd ?? worktreePath,
|
|
62
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
63
|
+
}, (error, stdout, stderr) => {
|
|
64
|
+
if (error && error.code === undefined) {
|
|
65
|
+
reject(new Error(`exec failed: ${error.message}`));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
resolve({
|
|
69
|
+
stdout: stdout.toString(),
|
|
70
|
+
stderr: stderr.toString(),
|
|
71
|
+
exitCode: typeof error?.code === "number" ? error.code : 0,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
copyFileIn: async (hostPath, sandboxPath) => {
|
|
78
|
+
await mkdir(dirname(sandboxPath), { recursive: true });
|
|
79
|
+
await copyFile(hostPath, sandboxPath);
|
|
80
|
+
},
|
|
81
|
+
copyFileOut: async (sandboxPath, hostPath) => {
|
|
82
|
+
await mkdir(dirname(hostPath), { recursive: true });
|
|
83
|
+
await copyFile(sandboxPath, hostPath);
|
|
84
|
+
},
|
|
85
|
+
close: async () => {
|
|
86
|
+
await rm(sandboxRoot, { recursive: true, force: true });
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=test-bind-mount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-bind-mount.js","sourceRoot":"","sources":["../../src/sandboxes/test-bind-mount.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAA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;
|
|
|
30
30
|
// Hooks run inside the sandbox before the agent starts each iteration.
|
|
31
31
|
// npm install ensures the sandbox always has fresh dependencies.
|
|
32
32
|
const hooks = {
|
|
33
|
-
onSandboxReady: [{ command: "npm install" }],
|
|
33
|
+
sandbox: { onSandboxReady: [{ command: "npm install" }] },
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
// Copy node_modules from the host into the worktree before each sandbox
|
|
@@ -35,7 +35,7 @@ const MAX_ITERATIONS = 10;
|
|
|
35
35
|
// Hooks run inside the sandbox before the agent starts each iteration.
|
|
36
36
|
// npm install ensures the sandbox always has fresh dependencies.
|
|
37
37
|
const hooks = {
|
|
38
|
-
onSandboxReady: [{ command: "npm install" }],
|
|
38
|
+
sandbox: { onSandboxReady: [{ command: "npm install" }] },
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
// Copy node_modules from the host into the worktree before each sandbox
|
|
@@ -30,7 +30,7 @@ const MAX_ITERATIONS = 10;
|
|
|
30
30
|
// Hooks run inside the sandbox before the agent starts each iteration.
|
|
31
31
|
// npm install ensures the sandbox always has fresh dependencies.
|
|
32
32
|
const hooks = {
|
|
33
|
-
onSandboxReady: [{ command: "npm install" }],
|
|
33
|
+
sandbox: { onSandboxReady: [{ command: "npm install" }] },
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
// Copy node_modules from the host into the worktree before each sandbox
|
|
@@ -38,11 +38,13 @@ await run({
|
|
|
38
38
|
// platform-specific binaries and any packages added since the last copy.
|
|
39
39
|
copyToWorktree: ["node_modules"],
|
|
40
40
|
|
|
41
|
-
// Lifecycle hooks — commands
|
|
41
|
+
// Lifecycle hooks — commands grouped by where they run (host or sandbox).
|
|
42
42
|
hooks: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
sandbox: {
|
|
44
|
+
// onSandboxReady runs once after the sandbox is initialised and the repo is
|
|
45
|
+
// synced in, before the agent starts. Use it to install dependencies or run
|
|
46
|
+
// any other setup steps your project needs.
|
|
47
|
+
onSandboxReady: [{ command: "npm install" }],
|
|
48
|
+
},
|
|
47
49
|
},
|
|
48
50
|
});
|