@ai-hero/sandcastle 0.6.4 → 0.6.6

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.
Files changed (227) hide show
  1. package/README.md +125 -54
  2. package/dist/{MountConfig.d.ts → MountConfig-CmXclHA5.d.ts} +3 -2
  3. package/dist/{SandboxProvider.d.ts → SandboxProvider-EkSMuBp8.d.ts} +25 -39
  4. package/dist/chunk-72UVAC7B.js +99 -0
  5. package/dist/chunk-72UVAC7B.js.map +1 -0
  6. package/dist/chunk-BIWNFKGV.js +22 -0
  7. package/dist/chunk-BIWNFKGV.js.map +1 -0
  8. package/dist/chunk-NGBM7T3E.js +76 -0
  9. package/dist/chunk-NGBM7T3E.js.map +1 -0
  10. package/dist/chunk-Q5W3WQVU.js +25569 -0
  11. package/dist/chunk-Q5W3WQVU.js.map +1 -0
  12. package/dist/chunk-UPDEQ2U7.js +362 -0
  13. package/dist/chunk-UPDEQ2U7.js.map +1 -0
  14. package/dist/chunk-Z7O2WNRU.js +26934 -0
  15. package/dist/chunk-Z7O2WNRU.js.map +1 -0
  16. package/dist/index.d.ts +920 -22
  17. package/dist/index.js +3212 -9
  18. package/dist/index.js.map +1 -1
  19. package/dist/main.d.ts +0 -2
  20. package/dist/main.js +19256 -13
  21. package/dist/main.js.map +1 -1
  22. package/dist/mountUtils-CCA-bbpK.d.ts +25 -0
  23. package/dist/sandboxes/daytona.d.ts +8 -5
  24. package/dist/sandboxes/daytona.js +118 -124
  25. package/dist/sandboxes/daytona.js.map +1 -1
  26. package/dist/sandboxes/docker.d.ts +10 -8
  27. package/dist/sandboxes/docker.js +8 -255
  28. package/dist/sandboxes/docker.js.map +1 -1
  29. package/dist/sandboxes/no-sandbox.d.ts +7 -4
  30. package/dist/sandboxes/no-sandbox.js +6 -114
  31. package/dist/sandboxes/no-sandbox.js.map +1 -1
  32. package/dist/sandboxes/podman.d.ts +10 -8
  33. package/dist/sandboxes/podman.js +287 -297
  34. package/dist/sandboxes/podman.js.map +1 -1
  35. package/dist/sandboxes/vercel.d.ts +7 -4
  36. package/dist/sandboxes/vercel.js +144 -165
  37. package/dist/sandboxes/vercel.js.map +1 -1
  38. package/package.json +15 -14
  39. package/dist/AgentProvider.d.ts +0 -134
  40. package/dist/AgentProvider.d.ts.map +0 -1
  41. package/dist/AgentProvider.js +0 -647
  42. package/dist/AgentProvider.js.map +0 -1
  43. package/dist/AgentStreamEmitter.d.ts +0 -36
  44. package/dist/AgentStreamEmitter.d.ts.map +0 -1
  45. package/dist/AgentStreamEmitter.js +0 -21
  46. package/dist/AgentStreamEmitter.js.map +0 -1
  47. package/dist/CopyToWorktree.d.ts +0 -15
  48. package/dist/CopyToWorktree.d.ts.map +0 -1
  49. package/dist/CopyToWorktree.js +0 -60
  50. package/dist/CopyToWorktree.js.map +0 -1
  51. package/dist/Display.d.ts +0 -58
  52. package/dist/Display.d.ts.map +0 -1
  53. package/dist/Display.js +0 -142
  54. package/dist/Display.js.map +0 -1
  55. package/dist/DockerLifecycle.d.ts +0 -54
  56. package/dist/DockerLifecycle.d.ts.map +0 -1
  57. package/dist/DockerLifecycle.js +0 -123
  58. package/dist/DockerLifecycle.js.map +0 -1
  59. package/dist/EnvResolver.d.ts +0 -11
  60. package/dist/EnvResolver.d.ts.map +0 -1
  61. package/dist/EnvResolver.js +0 -63
  62. package/dist/EnvResolver.js.map +0 -1
  63. package/dist/ErrorHandler.d.ts +0 -15
  64. package/dist/ErrorHandler.d.ts.map +0 -1
  65. package/dist/ErrorHandler.js +0 -85
  66. package/dist/ErrorHandler.js.map +0 -1
  67. package/dist/InitService.d.ts +0 -63
  68. package/dist/InitService.d.ts.map +0 -1
  69. package/dist/InitService.js +0 -733
  70. package/dist/InitService.js.map +0 -1
  71. package/dist/MountConfig.d.ts.map +0 -1
  72. package/dist/MountConfig.js +0 -7
  73. package/dist/MountConfig.js.map +0 -1
  74. package/dist/Orchestrator.d.ts +0 -56
  75. package/dist/Orchestrator.d.ts.map +0 -1
  76. package/dist/Orchestrator.js +0 -293
  77. package/dist/Orchestrator.js.map +0 -1
  78. package/dist/Output.d.ts +0 -107
  79. package/dist/Output.d.ts.map +0 -1
  80. package/dist/Output.js +0 -95
  81. package/dist/Output.js.map +0 -1
  82. package/dist/PodmanLifecycle.d.ts +0 -17
  83. package/dist/PodmanLifecycle.d.ts.map +0 -1
  84. package/dist/PodmanLifecycle.js +0 -45
  85. package/dist/PodmanLifecycle.js.map +0 -1
  86. package/dist/PromptArgumentSubstitution.d.ts +0 -32
  87. package/dist/PromptArgumentSubstitution.d.ts.map +0 -1
  88. package/dist/PromptArgumentSubstitution.js +0 -104
  89. package/dist/PromptArgumentSubstitution.js.map +0 -1
  90. package/dist/PromptPreprocessor.d.ts +0 -15
  91. package/dist/PromptPreprocessor.d.ts.map +0 -1
  92. package/dist/PromptPreprocessor.js +0 -55
  93. package/dist/PromptPreprocessor.js.map +0 -1
  94. package/dist/PromptResolver.d.ts +0 -21
  95. package/dist/PromptResolver.d.ts.map +0 -1
  96. package/dist/PromptResolver.js +0 -27
  97. package/dist/PromptResolver.js.map +0 -1
  98. package/dist/RecoveryMessage.d.ts +0 -15
  99. package/dist/RecoveryMessage.d.ts.map +0 -1
  100. package/dist/RecoveryMessage.js +0 -81
  101. package/dist/RecoveryMessage.js.map +0 -1
  102. package/dist/SandboxFactory.d.ts +0 -90
  103. package/dist/SandboxFactory.d.ts.map +0 -1
  104. package/dist/SandboxFactory.js +0 -324
  105. package/dist/SandboxFactory.js.map +0 -1
  106. package/dist/SandboxLifecycle.d.ts +0 -65
  107. package/dist/SandboxLifecycle.d.ts.map +0 -1
  108. package/dist/SandboxLifecycle.js +0 -296
  109. package/dist/SandboxLifecycle.js.map +0 -1
  110. package/dist/SandboxProvider.d.ts.map +0 -1
  111. package/dist/SandboxProvider.js +0 -28
  112. package/dist/SandboxProvider.js.map +0 -1
  113. package/dist/SessionStore.d.ts +0 -110
  114. package/dist/SessionStore.d.ts.map +0 -1
  115. package/dist/SessionStore.js +0 -330
  116. package/dist/SessionStore.js.map +0 -1
  117. package/dist/TextDeltaBuffer.d.ts +0 -24
  118. package/dist/TextDeltaBuffer.d.ts.map +0 -1
  119. package/dist/TextDeltaBuffer.js +0 -68
  120. package/dist/TextDeltaBuffer.js.map +0 -1
  121. package/dist/WorktreeManager.d.ts +0 -79
  122. package/dist/WorktreeManager.d.ts.map +0 -1
  123. package/dist/WorktreeManager.js +0 -283
  124. package/dist/WorktreeManager.js.map +0 -1
  125. package/dist/boundedTail.d.ts +0 -48
  126. package/dist/boundedTail.d.ts.map +0 -1
  127. package/dist/boundedTail.js +0 -64
  128. package/dist/boundedTail.js.map +0 -1
  129. package/dist/cli.d.ts +0 -30
  130. package/dist/cli.d.ts.map +0 -1
  131. package/dist/cli.js +0 -309
  132. package/dist/cli.js.map +0 -1
  133. package/dist/createSandbox.d.ts +0 -154
  134. package/dist/createSandbox.d.ts.map +0 -1
  135. package/dist/createSandbox.js +0 -476
  136. package/dist/createSandbox.js.map +0 -1
  137. package/dist/createWorktree.d.ts +0 -154
  138. package/dist/createWorktree.d.ts.map +0 -1
  139. package/dist/createWorktree.js +0 -391
  140. package/dist/createWorktree.js.map +0 -1
  141. package/dist/errors.d.ts +0 -227
  142. package/dist/errors.d.ts.map +0 -1
  143. package/dist/errors.js +0 -81
  144. package/dist/errors.js.map +0 -1
  145. package/dist/extractStructuredOutput.d.ts +0 -23
  146. package/dist/extractStructuredOutput.d.ts.map +0 -1
  147. package/dist/extractStructuredOutput.js +0 -102
  148. package/dist/extractStructuredOutput.js.map +0 -1
  149. package/dist/index.d.ts.map +0 -1
  150. package/dist/interactive.d.ts +0 -74
  151. package/dist/interactive.d.ts.map +0 -1
  152. package/dist/interactive.js +0 -279
  153. package/dist/interactive.js.map +0 -1
  154. package/dist/main.d.ts.map +0 -1
  155. package/dist/mergeProviderEnv.d.ts +0 -13
  156. package/dist/mergeProviderEnv.d.ts.map +0 -1
  157. package/dist/mergeProviderEnv.js +0 -23
  158. package/dist/mergeProviderEnv.js.map +0 -1
  159. package/dist/mountUtils.d.ts +0 -146
  160. package/dist/mountUtils.d.ts.map +0 -1
  161. package/dist/mountUtils.js +0 -301
  162. package/dist/mountUtils.js.map +0 -1
  163. package/dist/raceAbortSignal.d.ts +0 -18
  164. package/dist/raceAbortSignal.d.ts.map +0 -1
  165. package/dist/raceAbortSignal.js +0 -32
  166. package/dist/raceAbortSignal.js.map +0 -1
  167. package/dist/resolveCwd.d.ts +0 -24
  168. package/dist/resolveCwd.d.ts.map +0 -1
  169. package/dist/resolveCwd.js +0 -32
  170. package/dist/resolveCwd.js.map +0 -1
  171. package/dist/resumePrecheck.d.ts +0 -26
  172. package/dist/resumePrecheck.d.ts.map +0 -1
  173. package/dist/resumePrecheck.js +0 -40
  174. package/dist/resumePrecheck.js.map +0 -1
  175. package/dist/run.d.ts +0 -216
  176. package/dist/run.d.ts.map +0 -1
  177. package/dist/run.js +0 -313
  178. package/dist/run.js.map +0 -1
  179. package/dist/sandboxExec.d.ts +0 -12
  180. package/dist/sandboxExec.d.ts.map +0 -1
  181. package/dist/sandboxExec.js +0 -26
  182. package/dist/sandboxExec.js.map +0 -1
  183. package/dist/sandboxes/daytona.d.ts.map +0 -1
  184. package/dist/sandboxes/docker.d.ts.map +0 -1
  185. package/dist/sandboxes/no-sandbox.d.ts.map +0 -1
  186. package/dist/sandboxes/podman.d.ts.map +0 -1
  187. package/dist/sandboxes/test-bind-mount.d.ts +0 -17
  188. package/dist/sandboxes/test-bind-mount.d.ts.map +0 -1
  189. package/dist/sandboxes/test-bind-mount.js +0 -92
  190. package/dist/sandboxes/test-bind-mount.js.map +0 -1
  191. package/dist/sandboxes/test-isolated.d.ts +0 -17
  192. package/dist/sandboxes/test-isolated.d.ts.map +0 -1
  193. package/dist/sandboxes/test-isolated.js +0 -98
  194. package/dist/sandboxes/test-isolated.js.map +0 -1
  195. package/dist/sandboxes/vercel.d.ts.map +0 -1
  196. package/dist/shutdownRegistry.d.ts +0 -30
  197. package/dist/shutdownRegistry.d.ts.map +0 -1
  198. package/dist/shutdownRegistry.js +0 -73
  199. package/dist/shutdownRegistry.js.map +0 -1
  200. package/dist/startSandbox.d.ts +0 -50
  201. package/dist/startSandbox.d.ts.map +0 -1
  202. package/dist/startSandbox.js +0 -117
  203. package/dist/startSandbox.js.map +0 -1
  204. package/dist/syncIn.d.ts +0 -24
  205. package/dist/syncIn.d.ts.map +0 -1
  206. package/dist/syncIn.js +0 -107
  207. package/dist/syncIn.js.map +0 -1
  208. package/dist/syncOut.d.ts +0 -27
  209. package/dist/syncOut.d.ts.map +0 -1
  210. package/dist/syncOut.js +0 -271
  211. package/dist/syncOut.js.map +0 -1
  212. package/dist/templates.d.ts +0 -2
  213. package/dist/templates.d.ts.map +0 -1
  214. package/dist/templates.js +0 -26
  215. package/dist/templates.js.map +0 -1
  216. package/dist/terminalCleanup.d.ts +0 -30
  217. package/dist/terminalCleanup.d.ts.map +0 -1
  218. package/dist/terminalCleanup.js +0 -37
  219. package/dist/terminalCleanup.js.map +0 -1
  220. package/dist/testSandbox.d.ts +0 -8
  221. package/dist/testSandbox.d.ts.map +0 -1
  222. package/dist/testSandbox.js +0 -109
  223. package/dist/testSandbox.js.map +0 -1
  224. package/dist/testSetup.d.ts +0 -2
  225. package/dist/testSetup.d.ts.map +0 -1
  226. package/dist/testSetup.js +0 -29
  227. package/dist/testSetup.js.map +0 -1
@@ -1,324 +0,0 @@
1
- import { Context, Effect, Exit, Layer } from "effect";
2
- import { FileSystem } from "@effect/platform";
3
- import { join, resolve } from "node:path";
4
- import { AgentError, AgentIdleTimeoutError, CopyError, ExecError, WorktreeError, } from "./errors.js";
5
- import * as WorktreeManager from "./WorktreeManager.js";
6
- import { copyToWorktree } from "./CopyToWorktree.js";
7
- import { Display } from "./Display.js";
8
- import { runHostHooks } from "./SandboxLifecycle.js";
9
- import { startSandbox } from "./startSandbox.js";
10
- import { syncOut } from "./syncOut.js";
11
- import { patchGitMountsForWindows } from "./mountUtils.js";
12
- export class Sandbox extends Context.Tag("Sandbox")() {
13
- }
14
- const getCopyIn = (handle) => {
15
- if ("copyIn" in handle) {
16
- return (hostPath, sandboxPath) => Effect.tryPromise({
17
- try: () => handle.copyIn(hostPath, sandboxPath),
18
- catch: (e) => new CopyError({
19
- message: `copyIn failed: ${e instanceof Error ? e.message : String(e)}`,
20
- }),
21
- });
22
- }
23
- if ("copyFileIn" in handle) {
24
- return (hostPath, sandboxPath) => Effect.tryPromise({
25
- try: () => handle.copyFileIn(hostPath, sandboxPath),
26
- catch: (e) => new CopyError({
27
- message: `copyFileIn failed: ${e instanceof Error ? e.message : String(e)}`,
28
- }),
29
- });
30
- }
31
- return () => Effect.fail(new CopyError({
32
- message: "copyIn is not supported for this sandbox provider",
33
- }));
34
- };
35
- /**
36
- * Wrap a Promise-based sandbox handle into an Effect-based SandboxService layer.
37
- * Delegates copyIn/copyFileOut to the handle when available.
38
- */
39
- export const makeSandboxLayerFromHandle = (handle) => Layer.succeed(Sandbox, {
40
- exec: (command, options) => Effect.tryPromise({
41
- try: () => handle.exec(command, options),
42
- catch: (e) => new ExecError({
43
- command,
44
- message: `exec failed: ${e instanceof Error ? e.message : String(e)}`,
45
- }),
46
- }),
47
- copyIn: getCopyIn(handle),
48
- copyFileOut: "copyFileOut" in handle
49
- ? (sandboxPath, hostPath) => Effect.tryPromise({
50
- try: () => handle.copyFileOut(sandboxPath, hostPath),
51
- catch: (e) => new CopyError({
52
- message: `copyFileOut failed: ${e instanceof Error ? e.message : String(e)}`,
53
- }),
54
- })
55
- : () => Effect.fail(new CopyError({
56
- message: "copyFileOut is not supported for this sandbox provider",
57
- })),
58
- });
59
- /** The mount point inside the sandbox where the project worktree is bound. */
60
- export const SANDBOX_REPO_DIR = "/home/agent/workspace";
61
- export class SandboxFactory extends Context.Tag("SandboxFactory")() {
62
- }
63
- export class SandboxConfig extends Context.Tag("SandboxConfig")() {
64
- }
65
- /**
66
- * Print a message to stderr about a preserved worktree, with review and cleanup instructions.
67
- */
68
- const printWorktreePreservedMessage = (worktreePath, reason) => {
69
- console.error(`\n${reason}`);
70
- console.error(` To review: cd ${worktreePath}`);
71
- console.error(` To clean up: git worktree remove --force ${worktreePath}`);
72
- };
73
- /**
74
- * Check for uncommitted changes and either preserve or remove the worktree.
75
- * Returns the preserved path if preserved, undefined if removed.
76
- */
77
- const cleanupWorktree = (worktreePath, exit) => WorktreeManager.hasUncommittedChanges(worktreePath).pipe(Effect.catchAll(() => Effect.succeed(false)), Effect.flatMap((isDirty) => {
78
- if (isDirty) {
79
- printWorktreePreservedMessage(worktreePath, Exit.isSuccess(exit)
80
- ? `Run succeeded but worktree has uncommitted changes at ${worktreePath}`
81
- : `Worktree preserved at ${worktreePath}`);
82
- return Effect.succeed(worktreePath);
83
- }
84
- if (!Exit.isSuccess(exit)) {
85
- console.error(`\nWorktree removed (no uncommitted changes)`);
86
- }
87
- return WorktreeManager.remove(worktreePath).pipe(Effect.map(() => undefined));
88
- }));
89
- /**
90
- * Attach the preserved worktree path to AgentIdleTimeoutError and AgentError so
91
- * programmatic callers can build on top of the preserved worktree.
92
- */
93
- const attachPreservedPath = (path, e) => {
94
- if (path !== undefined) {
95
- if (e instanceof AgentIdleTimeoutError) {
96
- return new AgentIdleTimeoutError({
97
- message: e.message,
98
- timeoutMs: e.timeoutMs,
99
- preservedWorktreePath: path,
100
- });
101
- }
102
- if (e instanceof AgentError) {
103
- return new AgentError({
104
- message: e.message,
105
- preservedWorktreePath: path,
106
- });
107
- }
108
- }
109
- return e;
110
- };
111
- /**
112
- * Resolves the git-related mounts needed for the sandbox.
113
- * Handles both normal repos (where .git is a directory) and worktrees
114
- * (where .git is a file pointing to the parent repo's .git/worktrees/<name>).
115
- */
116
- export const resolveGitMounts = (gitPath) => Effect.gen(function* () {
117
- const fs = yield* FileSystem.FileSystem;
118
- const stat = yield* fs.stat(gitPath);
119
- if (stat.type === "Directory") {
120
- return [{ hostPath: gitPath, sandboxPath: gitPath }];
121
- }
122
- // Worktree: .git is a file with "gitdir: <path>"
123
- const content = (yield* fs.readFileString(gitPath)).trim();
124
- const match = content.match(/^gitdir:\s*(.+)$/);
125
- if (!match) {
126
- // Unrecognized format — fall back to mounting the file as-is
127
- return [{ hostPath: gitPath, sandboxPath: gitPath }];
128
- }
129
- const gitdirPath = match[1];
130
- // gitdirPath is like /path/to/repo/.git/worktrees/<name>
131
- // Mount both the .git file and the parent .git directory
132
- const parentGitDir = resolve(gitdirPath, "..", "..");
133
- return [
134
- { hostPath: gitPath, sandboxPath: gitPath },
135
- { hostPath: parentGitDir, sandboxPath: parentGitDir },
136
- ];
137
- });
138
- export const WorktreeDockerSandboxFactory = {
139
- layer: Layer.effect(SandboxFactory, Effect.gen(function* () {
140
- const { env, hostRepoDir, copyToWorktree: copyPaths, name, sandboxProvider, branchStrategy, hooks, signal, timeouts, } = yield* SandboxConfig;
141
- const isHeadMode = branchStrategy.type === "head";
142
- const branch = branchStrategy.type === "branch" ? branchStrategy.branch : undefined;
143
- const baseBranch = branchStrategy.type === "branch"
144
- ? branchStrategy.baseBranch
145
- : undefined;
146
- const fileSystem = yield* FileSystem.FileSystem;
147
- const display = yield* Display;
148
- /** Prune stale worktrees (best-effort), then create a fresh one. */
149
- const pruneAndCreate = () => WorktreeManager.pruneStale(hostRepoDir).pipe(Effect.catchAll((e) => Effect.sync(() => {
150
- console.error("[sandcastle] Warning: failed to prune stale worktrees:", e.message);
151
- })), Effect.andThen(branch
152
- ? WorktreeManager.create(hostRepoDir, { branch, baseBranch })
153
- : WorktreeManager.create(hostRepoDir, { name })), Effect.provideService(FileSystem.FileSystem, fileSystem));
154
- return {
155
- withSandbox: (makeEffect) => {
156
- // No-sandbox providers: run directly on the host, no container or mounts.
157
- if (sandboxProvider.tag === "none") {
158
- let preservedPath;
159
- // Head mode: use hostRepoDir directly, no worktree.
160
- if (isHeadMode) {
161
- return (hooks?.host?.onWorktreeReady?.length
162
- ? runHostHooks(hooks.host.onWorktreeReady, hostRepoDir, signal)
163
- : Effect.void).pipe(Effect.andThen(Effect.acquireUseRelease(startSandbox({
164
- provider: sandboxProvider,
165
- hostRepoDir,
166
- env,
167
- worktreeOrRepoPath: hostRepoDir,
168
- }), ({ sandboxLayer, worktreePath, handle }) => makeEffect({
169
- hostWorktreePath: hostRepoDir,
170
- sandboxRepoPath: worktreePath,
171
- }).pipe(Effect.provide(sandboxLayer)), ({ handle }) => Effect.tryPromise({
172
- try: () => handle.close(),
173
- catch: () => undefined,
174
- }).pipe(Effect.orDie)).pipe(Effect.map((value) => ({
175
- value,
176
- preservedWorktreePath: undefined,
177
- })))));
178
- }
179
- // Worktree mode (merge-to-head or explicit branch).
180
- // Nested so the worktree is always cleaned up (outer release) even
181
- // when copying, hooks, or sandbox start fail. The provider handle is
182
- // closed by the inner release, which only runs once it exists.
183
- return Effect.acquireUseRelease(pruneAndCreate(), (worktreeInfo) => (copyPaths && copyPaths.length > 0
184
- ? display.spinner("Copying to worktree", copyToWorktree(copyPaths, hostRepoDir, worktreeInfo.path, timeouts?.copyToWorktreeMs))
185
- : Effect.succeed(undefined)).pipe(Effect.andThen(hooks?.host?.onWorktreeReady?.length
186
- ? runHostHooks(hooks.host.onWorktreeReady, worktreeInfo.path, signal)
187
- : Effect.void), Effect.andThen(Effect.acquireUseRelease(startSandbox({
188
- provider: sandboxProvider,
189
- hostRepoDir,
190
- env,
191
- worktreeOrRepoPath: worktreeInfo.path,
192
- }), ({ sandboxLayer, worktreePath }) => makeEffect({
193
- hostWorktreePath: worktreeInfo.path,
194
- sandboxRepoPath: worktreePath,
195
- }).pipe(Effect.provide(sandboxLayer)), ({ handle }) => Effect.tryPromise({
196
- try: () => handle.close(),
197
- catch: () => undefined,
198
- }).pipe(Effect.orDie)))), (worktreeInfo, exit) => cleanupWorktree(worktreeInfo.path, exit).pipe(Effect.tap((p) => {
199
- preservedPath = p;
200
- }), Effect.asVoid, Effect.orDie)).pipe(Effect.map((value) => ({
201
- value,
202
- preservedWorktreePath: preservedPath,
203
- })), Effect.mapError((e) => attachPreservedPath(preservedPath, e)));
204
- }
205
- // Isolated providers: create worktree, sync via git bundle
206
- if (sandboxProvider.tag === "isolated") {
207
- let preservedPath;
208
- // Nested so the worktree is always cleaned up (outer release) even
209
- // when hooks or sandbox start fail. The provider handle is closed by
210
- // the inner release, which only runs once it exists.
211
- return Effect.acquireUseRelease(pruneAndCreate(), (worktreeInfo) => (hooks?.host?.onWorktreeReady?.length
212
- ? runHostHooks(hooks.host.onWorktreeReady, worktreeInfo.path, signal)
213
- : Effect.void).pipe(Effect.andThen(Effect.acquireUseRelease(startSandbox({
214
- provider: sandboxProvider,
215
- hostRepoDir: worktreeInfo.path,
216
- env,
217
- copyPaths,
218
- }), ({ sandboxLayer, worktreePath, handle }) => makeEffect({
219
- hostWorktreePath: worktreeInfo.path,
220
- sandboxRepoPath: worktreePath,
221
- applyToHost: () => syncOut(worktreeInfo.path, handle),
222
- }).pipe(Effect.provide(sandboxLayer)), ({ handle }) => Effect.tryPromise({
223
- try: () => handle.close(),
224
- catch: () => undefined,
225
- }).pipe(Effect.orDie)))), (worktreeInfo, exit) => cleanupWorktree(worktreeInfo.path, exit).pipe(Effect.tap((p) => {
226
- preservedPath = p;
227
- }), Effect.asVoid, Effect.orDie)).pipe(Effect.map((value) => ({
228
- value,
229
- preservedWorktreePath: preservedPath,
230
- })), Effect.mapError((e) => attachPreservedPath(preservedPath, e)));
231
- }
232
- if (isHeadMode) {
233
- // Head mode: bind-mount host directory directly, no worktree
234
- const gitPath = join(hostRepoDir, ".git");
235
- return (hooks?.host?.onWorktreeReady?.length
236
- ? runHostHooks(hooks.host.onWorktreeReady, hostRepoDir, signal)
237
- : Effect.void).pipe(Effect.andThen(resolveGitMounts(gitPath)), Effect.provideService(FileSystem.FileSystem, fileSystem), Effect.mapError((e) => new WorktreeError({
238
- message: `Failed to resolve git mounts: ${e}`,
239
- })), Effect.flatMap((gitMounts) =>
240
- // Patch git mounts for Windows worktree compatibility (ADR-0006)
241
- Effect.tryPromise({
242
- try: () => patchGitMountsForWindows(gitMounts, hostRepoDir, SANDBOX_REPO_DIR),
243
- catch: (e) => new WorktreeError({
244
- message: `Failed to patch git mounts: ${e instanceof Error ? e.message : String(e)}`,
245
- }),
246
- })), Effect.flatMap((gitMounts) => Effect.acquireUseRelease(startSandbox({
247
- provider: sandboxProvider,
248
- hostRepoDir,
249
- env,
250
- worktreeOrRepoPath: hostRepoDir,
251
- gitMounts,
252
- repoDir: SANDBOX_REPO_DIR,
253
- }),
254
- // Use
255
- ({ sandboxLayer, worktreePath, handle }) => makeEffect({
256
- hostWorktreePath: hostRepoDir,
257
- sandboxRepoPath: worktreePath,
258
- bindMountHandle: handle,
259
- }).pipe(Effect.provide(sandboxLayer)),
260
- // Release
261
- ({ handle }) => Effect.tryPromise({
262
- try: () => handle.close(),
263
- catch: () => undefined,
264
- }).pipe(Effect.orDie)).pipe(Effect.map((value) => ({
265
- value,
266
- preservedWorktreePath: undefined,
267
- })))));
268
- }
269
- // Worktree mode (merge-to-head or explicit branch)
270
- // Populated by the release phase when a worktree is preserved on failure,
271
- // so we can attach the path to recognized error types before they propagate.
272
- let preservedWorktreePath;
273
- // Worktree creation and sandbox start are nested so the worktree is
274
- // always cleaned up (outer release) even when a later step — copying,
275
- // hooks, or sandbox start — fails. The provider handle is closed by the
276
- // inner release, which only runs once the handle exists.
277
- return Effect.acquireUseRelease(
278
- // Acquire: prune stale worktrees (best-effort), then create the worktree.
279
- pruneAndCreate(),
280
- // Use: copy files, run host hooks, resolve+patch git mounts, then start
281
- // the sandbox under a nested acquireUseRelease.
282
- (worktreeInfo) => (copyPaths && copyPaths.length > 0
283
- ? display.spinner("Copying to worktree", copyToWorktree(copyPaths, hostRepoDir, worktreeInfo.path, timeouts?.copyToWorktreeMs))
284
- : Effect.succeed(undefined)).pipe(Effect.andThen(hooks?.host?.onWorktreeReady?.length
285
- ? runHostHooks(hooks.host.onWorktreeReady, worktreeInfo.path, signal)
286
- : Effect.void), Effect.andThen(resolveGitMounts(join(hostRepoDir, ".git")).pipe(Effect.provideService(FileSystem.FileSystem, fileSystem), Effect.mapError((e) => new WorktreeError({
287
- message: `Failed to resolve git mounts: ${e}`,
288
- })))),
289
- // Patch git mounts for Windows worktree compatibility (ADR-0006)
290
- Effect.flatMap((gitMounts) => Effect.tryPromise({
291
- try: () => patchGitMountsForWindows(gitMounts, worktreeInfo.path, SANDBOX_REPO_DIR),
292
- catch: (e) => new WorktreeError({
293
- message: `Failed to patch git mounts: ${e instanceof Error ? e.message : String(e)}`,
294
- }),
295
- })), Effect.flatMap((gitMounts) => Effect.acquireUseRelease(
296
- // sandboxProvider is guaranteed bind-mount here
297
- // (isolated providers return early above)
298
- startSandbox({
299
- provider: sandboxProvider,
300
- hostRepoDir,
301
- env,
302
- worktreeOrRepoPath: worktreeInfo.path,
303
- gitMounts,
304
- repoDir: SANDBOX_REPO_DIR,
305
- }), ({ sandboxLayer, worktreePath, handle }) => makeEffect({
306
- hostWorktreePath: worktreeInfo.path,
307
- sandboxRepoPath: worktreePath,
308
- bindMountHandle: handle,
309
- }).pipe(Effect.provide(sandboxLayer)), ({ handle }) => Effect.tryPromise({
310
- try: () => handle.close(),
311
- catch: () => undefined,
312
- }).pipe(Effect.orDie)))),
313
- // Release: remove or preserve the worktree based on dirty state.
314
- (worktreeInfo, exit) => cleanupWorktree(worktreeInfo.path, exit).pipe(Effect.tap((p) => {
315
- preservedWorktreePath = p;
316
- }), Effect.asVoid, Effect.orDie)).pipe(Effect.map((value) => ({
317
- value,
318
- preservedWorktreePath,
319
- })), Effect.mapError((e) => attachPreservedPath(preservedWorktreePath, e)));
320
- },
321
- };
322
- })),
323
- };
324
- //# sourceMappingURL=SandboxFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SandboxFactory.js","sourceRoot":"","sources":["../src/SandboxFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,UA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AE,IAAI,EAAE,EAAE,CACrB,eAAe,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,CAC3C,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;oBACf,qBAAqB,GAAG,CAAC,CAAC;gBAC5B,CAAC,CAAC,EACF,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,KAAK,CACb,CACJ,CAAC,IAAI,CACJ,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBACrB,KAAK;oBACL,qBAAqB;iBACtB,CAAC,CAAC,EACH,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAmB,EAAE,EAAE,CACtC,mBAAmB,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAC9C,CACF,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC,CAAC,CACH;CACF,CAAC"}
@@ -1,65 +0,0 @@
1
- import { Effect } from "effect";
2
- import { Display } from "./Display.js";
3
- import { ExecError, HookTimeoutError, SyncError, type SandboxError } from "./errors.js";
4
- import { Sandbox, type SandboxService } from "./SandboxFactory.js";
5
- import type { Timeouts } from "./run.js";
6
- export type SandboxHooks = {
7
- readonly host?: {
8
- readonly onWorktreeReady?: ReadonlyArray<{
9
- readonly command: string;
10
- readonly timeoutMs?: number;
11
- }>;
12
- readonly onSandboxReady?: ReadonlyArray<{
13
- readonly command: string;
14
- readonly timeoutMs?: number;
15
- }>;
16
- };
17
- readonly sandbox?: {
18
- readonly onSandboxReady?: ReadonlyArray<{
19
- readonly command: string;
20
- readonly sudo?: boolean;
21
- readonly timeoutMs?: number;
22
- }>;
23
- };
24
- };
25
- /**
26
- * Runs an array of host-side hook commands sequentially.
27
- * Each command runs on the host with the given cwd.
28
- * Fails fast on non-zero exit.
29
- */
30
- export declare const runHostHooks: (hooks: readonly {
31
- readonly command: string;
32
- readonly timeoutMs?: number | undefined;
33
- }[], cwd: string, signal?: AbortSignal | undefined) => Effect.Effect<void, ExecError | HookTimeoutError, never>;
34
- export interface SandboxLifecycleOptions {
35
- readonly hostRepoDir: string;
36
- readonly sandboxRepoDir: string;
37
- readonly hooks?: SandboxHooks;
38
- readonly branch?: string;
39
- /** Host-side path to the worktree directory. Required when sandboxRepoDir
40
- * is a sandbox path that doesn't exist on the host (e.g. /home/agent/workspace). */
41
- readonly hostWorktreePath?: string;
42
- /** Called after agent work completes but before host-side git operations (merge, commit collection).
43
- * For isolated providers, this syncs changes from the sandbox to the host worktree.
44
- * For bind-mount providers, this is a no-op (filesystem is already shared). */
45
- readonly applyToHost?: () => Effect.Effect<void, SyncError>;
46
- /** AbortSignal passed through to lifecycle hooks so they can cooperatively cancel.
47
- * When omitted, hooks receive a never-aborted signal. */
48
- readonly signal?: AbortSignal;
49
- /** Override default timeouts for built-in lifecycle steps. Unset keys keep their defaults. */
50
- readonly timeouts?: Timeouts;
51
- }
52
- export interface SandboxContext {
53
- readonly sandbox: SandboxService;
54
- readonly sandboxRepoDir: string;
55
- readonly baseHead: string;
56
- }
57
- export interface SandboxLifecycleResult<A> {
58
- readonly result: A;
59
- readonly branch: string;
60
- readonly commits: {
61
- sha: string;
62
- }[];
63
- }
64
- export declare const withSandboxLifecycle: <A>(options: SandboxLifecycleOptions, work: (ctx: SandboxContext) => Effect.Effect<A, SandboxError, Display | Sandbox>) => Effect.Effect<SandboxLifecycleResult<A>, SandboxError, Display | Sandbox>;
65
- //# sourceMappingURL=SandboxLifecycle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SandboxLifecycle.d.ts","sourceRoot":"","sources":["../src/SandboxLifecycle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,MAAM,EAAY,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAEL,SAAS,EAET,gBAAgB,EAEhB,SAAS,EAET,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,OAAO,EAEP,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