@ai-hero/sandcastle 0.4.2 → 0.4.4
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 +54 -12
- package/dist/Display.d.ts.map +1 -1
- package/dist/Display.js +4 -1
- package/dist/Display.js.map +1 -1
- package/dist/EnvResolver.d.ts.map +1 -1
- package/dist/EnvResolver.js +6 -1
- package/dist/EnvResolver.js.map +1 -1
- package/dist/Orchestrator.d.ts.map +1 -1
- package/dist/Orchestrator.js +2 -1
- package/dist/Orchestrator.js.map +1 -1
- package/dist/PromptArgumentSubstitution.js +1 -1
- package/dist/PromptArgumentSubstitution.js.map +1 -1
- package/dist/PromptPreprocessor.d.ts.map +1 -1
- package/dist/PromptPreprocessor.js +17 -11
- package/dist/PromptPreprocessor.js.map +1 -1
- package/dist/SandboxFactory.d.ts +4 -0
- package/dist/SandboxFactory.d.ts.map +1 -1
- package/dist/SandboxFactory.js +103 -127
- package/dist/SandboxFactory.js.map +1 -1
- package/dist/SandboxLifecycle.d.ts +6 -1
- package/dist/SandboxLifecycle.d.ts.map +1 -1
- package/dist/SandboxLifecycle.js +22 -9
- package/dist/SandboxLifecycle.js.map +1 -1
- package/dist/SandboxProvider.d.ts +2 -0
- package/dist/SandboxProvider.d.ts.map +1 -1
- package/dist/createSandbox.d.ts +1 -0
- package/dist/createSandbox.d.ts.map +1 -1
- package/dist/createSandbox.js +45 -24
- package/dist/createSandbox.js.map +1 -1
- package/dist/run.d.ts +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +13 -2
- package/dist/run.js.map +1 -1
- package/dist/sandboxes/daytona.d.ts.map +1 -1
- package/dist/sandboxes/daytona.js +3 -2
- package/dist/sandboxes/daytona.js.map +1 -1
- package/dist/sandboxes/docker.d.ts.map +1 -1
- package/dist/sandboxes/docker.js +2 -1
- package/dist/sandboxes/docker.js.map +1 -1
- package/dist/sandboxes/podman.d.ts.map +1 -1
- package/dist/sandboxes/podman.js +2 -1
- package/dist/sandboxes/podman.js.map +1 -1
- package/dist/sandboxes/test-isolated.d.ts.map +1 -1
- package/dist/sandboxes/test-isolated.js.map +1 -1
- package/dist/sandboxes/vercel.d.ts.map +1 -1
- package/dist/sandboxes/vercel.js +2 -0
- package/dist/sandboxes/vercel.js.map +1 -1
- package/dist/startSandbox.d.ts +39 -0
- package/dist/startSandbox.d.ts.map +1 -0
- package/dist/startSandbox.js +75 -0
- package/dist/startSandbox.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { WorktreeError } from "./errors.js";
|
|
5
|
+
import { makeSandboxLayerFromHandle, } from "./SandboxFactory.js";
|
|
6
|
+
import { syncIn } from "./syncIn.js";
|
|
7
|
+
/**
|
|
8
|
+
* Start a sandbox by dispatching on `provider.tag`.
|
|
9
|
+
*
|
|
10
|
+
* - `"bind-mount"`: creates mounts and delegates to the provider's `create()`.
|
|
11
|
+
* - `"isolated"`: creates handle, syncs host repo via git bundle, then copies
|
|
12
|
+
* optional `copyPaths` via `handle.copyIn()`.
|
|
13
|
+
*
|
|
14
|
+
* Returns the handle, a `SandboxService` layer, and the workspace path.
|
|
15
|
+
*/
|
|
16
|
+
export const startSandbox = (options) => {
|
|
17
|
+
if (options.provider.tag === "bind-mount") {
|
|
18
|
+
return startBindMountSandbox(options);
|
|
19
|
+
}
|
|
20
|
+
return startIsolatedSandbox(options);
|
|
21
|
+
};
|
|
22
|
+
const startBindMountSandbox = (options) => Effect.tryPromise({
|
|
23
|
+
try: () => {
|
|
24
|
+
const mounts = [
|
|
25
|
+
{
|
|
26
|
+
hostPath: options.worktreeOrRepoPath,
|
|
27
|
+
sandboxPath: options.workspaceDir,
|
|
28
|
+
},
|
|
29
|
+
...options.gitMounts,
|
|
30
|
+
];
|
|
31
|
+
return options.provider.create({
|
|
32
|
+
worktreePath: options.worktreeOrRepoPath,
|
|
33
|
+
hostRepoPath: options.hostRepoDir,
|
|
34
|
+
mounts,
|
|
35
|
+
env: options.env,
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
catch: (e) => new WorktreeError({
|
|
39
|
+
message: `Provider '${options.provider.name}' create failed: ${e instanceof Error ? e.message : String(e)}`,
|
|
40
|
+
}),
|
|
41
|
+
}).pipe(Effect.map((handle) => ({
|
|
42
|
+
handle,
|
|
43
|
+
sandboxLayer: makeSandboxLayerFromHandle(handle),
|
|
44
|
+
workspacePath: handle.workspacePath,
|
|
45
|
+
})));
|
|
46
|
+
const startIsolatedSandbox = (options) => Effect.gen(function* () {
|
|
47
|
+
const handle = yield* Effect.tryPromise({
|
|
48
|
+
try: () => options.provider.create({ env: options.env }),
|
|
49
|
+
catch: (e) => new WorktreeError({
|
|
50
|
+
message: `Isolated provider '${options.provider.name}' setup failed: ${e instanceof Error ? e.message : String(e)}`,
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
yield* syncIn(options.hostRepoDir, handle);
|
|
54
|
+
if (options.copyPaths && options.copyPaths.length > 0) {
|
|
55
|
+
for (const relativePath of options.copyPaths) {
|
|
56
|
+
const hostPath = join(options.hostRepoDir, relativePath);
|
|
57
|
+
if (!existsSync(hostPath)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const sandboxPath = join(handle.workspacePath, relativePath);
|
|
61
|
+
yield* Effect.tryPromise({
|
|
62
|
+
try: () => handle.copyIn(hostPath, sandboxPath),
|
|
63
|
+
catch: (e) => new WorktreeError({
|
|
64
|
+
message: `Failed to copy ${relativePath} into sandbox: ${e instanceof Error ? e.message : String(e)}`,
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
handle,
|
|
71
|
+
sandboxLayer: makeSandboxLayerFromHandle(handle),
|
|
72
|
+
workspacePath: handle.workspacePath,
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=startSandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startSandbox.js","sourceRoot":"","sources":["../src/startSandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAS,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAa,aAAa,EAAoB,MAAM,aAAa,CAAC;AAQzE,OAAO,EAGL,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAgCrC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAA4B,EAI5B,EAAE;IACF,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,YAAY,EAAE,CAAC;QAC1C,OAAO,qBAAqB,CAAC,OAAuC,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,oBAAoB,CAAC,OAAsC,CAAC,CAAC;AACtE,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAC5B,OAAqC,EAC2B,EAAE,CAClE,MAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,GAAG,EAAE;QACR,MAAM,MAAM,GAAG;YACb;gBACE,QAAQ,EAAE,OAAO,CAAC,kBAAkB;gBACpC,WAAW,EAAE,OAAO,CAAC,YAAY;aAClC;YACD,GAAG,OAAO,CAAC,SAAS;SACrB,CAAC;QACF,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC7B,YAAY,EAAE,OAAO,CAAC,kBAAkB;YACxC,YAAY,EAAE,OAAO,CAAC,WAAW;YACjC,MAAM;YACN,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB,CAAC,CAAC;IACL,CAAC;IACD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAC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CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;YACzD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC1B,SAAS;YACX,CAAC;YACD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;YAC7D,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;gBACvB,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC;gBAC/C,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CACX,IAAI,aAAa,CAAC;oBAChB,OAAO,EAAE,kBAAkB,YAAY,kBAAkB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;iBACtG,CAAC;aACL,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM;QACN,YAAY,EAAE,0BAA0B,CAAC,MAAM,CAAC;QAChD,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-hero/sandcastle",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "CLI for orchestrating AI agents in isolated sandbox environments",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"format:check": "prettier --check .",
|
|
41
41
|
"prepare": "husky",
|
|
42
42
|
"release": "changeset publish",
|
|
43
|
-
"sandcastle": "npm run build && tsx .sandcastle/run.ts"
|
|
43
|
+
"sandcastle": "npm run build && tsx .sandcastle/run.ts",
|
|
44
|
+
"test-vercel": "npm run build && tsx --env-file=.sandcastle/.env .sandcastle/test-vercel.ts"
|
|
44
45
|
},
|
|
45
46
|
"keywords": [
|
|
46
47
|
"cli",
|