@ai-hero/sandcastle 0.4.8 → 0.5.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 +125 -61
- 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 +2 -0
- package/dist/ErrorHandler.js.map +1 -1
- package/dist/Orchestrator.d.ts +13 -1
- package/dist/Orchestrator.d.ts.map +1 -1
- package/dist/Orchestrator.js +52 -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/SessionStore.d.ts +50 -0
- package/dist/SessionStore.d.ts.map +1 -0
- package/dist/SessionStore.js +120 -0
- package/dist/SessionStore.js.map +1 -0
- package/dist/createSandbox.d.ts +7 -15
- package/dist/createSandbox.d.ts.map +1 -1
- package/dist/createSandbox.js +40 -16
- package/dist/createSandbox.js.map +1 -1
- package/dist/createWorktree.d.ts +9 -9
- package/dist/createWorktree.d.ts.map +1 -1
- package/dist/createWorktree.js +6 -2
- package/dist/createWorktree.js.map +1 -1
- package/dist/errors.d.ts +10 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +3 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interactive.d.ts.map +1 -1
- package/dist/interactive.js +9 -1
- package/dist/interactive.js.map +1 -1
- package/dist/run.d.ts +9 -9
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +18 -1
- 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
package/README.md
CHANGED
|
@@ -113,7 +113,8 @@ const result = await run({
|
|
|
113
113
|
promptFile: ".sandcastle/prompt.md",
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
console.log(result.
|
|
116
|
+
console.log(result.iterations.length); // number of iterations executed
|
|
117
|
+
console.log(result.iterations); // per-iteration results with optional sessionId
|
|
117
118
|
console.log(result.commits); // array of { sha } for commits created
|
|
118
119
|
console.log(result.branch); // target branch name
|
|
119
120
|
```
|
|
@@ -165,10 +166,15 @@ const result = await run({
|
|
|
165
166
|
// Display name for this run, shown as a prefix in log output.
|
|
166
167
|
name: "fix-issue-42",
|
|
167
168
|
|
|
168
|
-
// Lifecycle hooks
|
|
169
|
+
// Lifecycle hooks grouped by where they run: host or sandbox.
|
|
169
170
|
hooks: {
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
host: {
|
|
172
|
+
onWorktreeReady: [{ command: "cp .env.example .env" }],
|
|
173
|
+
onSandboxReady: [{ command: "echo setup done" }],
|
|
174
|
+
},
|
|
175
|
+
sandbox: {
|
|
176
|
+
onSandboxReady: [{ command: "npm install" }],
|
|
177
|
+
},
|
|
172
178
|
},
|
|
173
179
|
|
|
174
180
|
// Host-relative file paths to copy into the sandbox before the container starts.
|
|
@@ -187,7 +193,7 @@ const result = await run({
|
|
|
187
193
|
idleTimeoutSeconds: 600,
|
|
188
194
|
});
|
|
189
195
|
|
|
190
|
-
console.log(result.
|
|
196
|
+
console.log(result.iterations.length); // number of iterations executed
|
|
191
197
|
console.log(result.completionSignal); // matched signal string, or undefined if none fired
|
|
192
198
|
console.log(result.commits); // array of { sha } for commits created
|
|
193
199
|
console.log(result.branch); // target branch name
|
|
@@ -227,7 +233,7 @@ import { docker } from "@ai-hero/sandcastle/sandboxes/docker";
|
|
|
227
233
|
await using sandbox = await createSandbox({
|
|
228
234
|
branch: "agent/fix-42",
|
|
229
235
|
sandbox: docker(),
|
|
230
|
-
hooks: { onSandboxReady: [{ command: "npm install" }] },
|
|
236
|
+
hooks: { sandbox: { onSandboxReady: [{ command: "npm install" }] } },
|
|
231
237
|
});
|
|
232
238
|
|
|
233
239
|
// Step 1: implement
|
|
@@ -270,7 +276,7 @@ if (closeResult.preservedWorktreePath) {
|
|
|
270
276
|
| -------------------------- | --------------- | ------- | ------------------------------------------------------------------------ |
|
|
271
277
|
| `branch` | string | — | **Required.** Explicit branch for the sandbox |
|
|
272
278
|
| `sandbox` | SandboxProvider | — | **Required.** Sandbox provider (e.g. `docker()`, `podman()`) |
|
|
273
|
-
| `hooks` |
|
|
279
|
+
| `hooks` | SandboxHooks | — | Lifecycle hooks (`host.*`, `sandbox.*`) — run once at creation time |
|
|
274
280
|
| `copyToWorktree` | string[] | — | Host-relative file paths to copy into the sandbox at creation time |
|
|
275
281
|
| `throwOnDuplicateWorktree` | boolean | `true` | When `false`, reuse an existing worktree instead of failing on collision |
|
|
276
282
|
|
|
@@ -300,13 +306,13 @@ if (closeResult.preservedWorktreePath) {
|
|
|
300
306
|
|
|
301
307
|
#### `SandboxRunResult`
|
|
302
308
|
|
|
303
|
-
| Field | Type
|
|
304
|
-
| ------------------ |
|
|
305
|
-
| `
|
|
306
|
-
| `completionSignal` | string?
|
|
307
|
-
| `stdout` | string
|
|
308
|
-
| `commits` | `{ sha }[]`
|
|
309
|
-
| `logFilePath` | string?
|
|
309
|
+
| Field | Type | Description |
|
|
310
|
+
| ------------------ | ------------------- | ------------------------------------------------------------------ |
|
|
311
|
+
| `iterations` | `IterationResult[]` | Per-iteration results (use `.length` for the count) |
|
|
312
|
+
| `completionSignal` | string? | The matched completion signal string, or `undefined` if none fired |
|
|
313
|
+
| `stdout` | string | Combined agent output from all iterations |
|
|
314
|
+
| `commits` | `{ sha }[]` | Commits created during the run |
|
|
315
|
+
| `logFilePath` | string? | Path to the log file (only when logging to a file) |
|
|
310
316
|
|
|
311
317
|
#### `CloseResult`
|
|
312
318
|
|
|
@@ -351,7 +357,7 @@ import { docker } from "@ai-hero/sandcastle/sandboxes/docker";
|
|
|
351
357
|
|
|
352
358
|
await using sandbox = await wt.createSandbox({
|
|
353
359
|
sandbox: docker(),
|
|
354
|
-
hooks: { onSandboxReady: [{ command: "npm install" }] },
|
|
360
|
+
hooks: { sandbox: { onSandboxReady: [{ command: "npm install" }] } },
|
|
355
361
|
});
|
|
356
362
|
|
|
357
363
|
// sandbox.close() tears down the container only — the worktree stays
|
|
@@ -392,7 +398,7 @@ await sandbox.close();
|
|
|
392
398
|
| `prompt` | string | — | Inline prompt (mutually exclusive with `promptFile`) |
|
|
393
399
|
| `promptFile` | string | — | Path to prompt file |
|
|
394
400
|
| `name` | string | — | Optional session name |
|
|
395
|
-
| `hooks` | SandboxHooks | — |
|
|
401
|
+
| `hooks` | SandboxHooks | — | Lifecycle hooks (`host.*`, `sandbox.*`) |
|
|
396
402
|
| `promptArgs` | PromptArgs | — | Key-value map for `{{KEY}}` placeholder substitution |
|
|
397
403
|
| `env` | Record<string, string> | — | Environment variables to inject into the sandbox |
|
|
398
404
|
|
|
@@ -409,27 +415,27 @@ await sandbox.close();
|
|
|
409
415
|
| `idleTimeoutSeconds` | number | 600 | Idle timeout in seconds |
|
|
410
416
|
| `name` | string | — | Optional run name |
|
|
411
417
|
| `logging` | LoggingOption | file | Logging mode |
|
|
412
|
-
| `hooks` | SandboxHooks | — |
|
|
418
|
+
| `hooks` | SandboxHooks | — | Lifecycle hooks (`host.*`, `sandbox.*`) |
|
|
413
419
|
| `promptArgs` | PromptArgs | — | Key-value map for `{{KEY}}` placeholder substitution |
|
|
414
420
|
| `env` | Record<string, string> | — | Environment variables to inject into the sandbox |
|
|
415
421
|
|
|
416
422
|
#### `WorktreeRunResult`
|
|
417
423
|
|
|
418
|
-
| Property | Type
|
|
419
|
-
| ------------------ |
|
|
420
|
-
| `
|
|
421
|
-
| `completionSignal` | string
|
|
422
|
-
| `stdout` | string
|
|
423
|
-
| `commits` | { sha: string }[]
|
|
424
|
-
| `branch` | string
|
|
425
|
-
| `logFilePath` | string
|
|
424
|
+
| Property | Type | Description |
|
|
425
|
+
| ------------------ | ------------------- | ------------------------------------------------------ |
|
|
426
|
+
| `iterations` | `IterationResult[]` | Per-iteration results (use `.length` for the count) |
|
|
427
|
+
| `completionSignal` | string | The matched completion signal, or undefined |
|
|
428
|
+
| `stdout` | string | Combined stdout output from all agent iterations |
|
|
429
|
+
| `commits` | { sha: string }[] | List of commits made by the agent during the run |
|
|
430
|
+
| `branch` | string | The branch name the agent worked on |
|
|
431
|
+
| `logFilePath` | string | Path to the log file, if logging was drained to a file |
|
|
426
432
|
|
|
427
433
|
#### `WorktreeCreateSandboxOptions`
|
|
428
434
|
|
|
429
435
|
| Option | Type | Default | Description |
|
|
430
436
|
| ---------------- | --------------- | ------- | ------------------------------------------------------------------- |
|
|
431
437
|
| `sandbox` | SandboxProvider | — | **Required.** Sandbox provider (e.g. `docker()`) |
|
|
432
|
-
| `hooks` | SandboxHooks | — |
|
|
438
|
+
| `hooks` | SandboxHooks | — | Lifecycle hooks (`host.*`, `sandbox.*`) |
|
|
433
439
|
| `copyToWorktree` | string[] | — | Host-relative file paths to copy into the worktree at creation time |
|
|
434
440
|
|
|
435
441
|
## How it works
|
|
@@ -463,7 +469,7 @@ You must provide exactly one of:
|
|
|
463
469
|
|
|
464
470
|
Use `` !`command` `` expressions in your prompt to pull in dynamic context. Each expression is replaced with the command's stdout before the prompt is sent to the agent. All expressions in a prompt run **in parallel** for faster expansion.
|
|
465
471
|
|
|
466
|
-
Commands run **inside the sandbox** after `onSandboxReady` hooks complete, so they see the same repo state the agent sees (including installed dependencies).
|
|
472
|
+
Commands run **inside the sandbox** after `sandbox.onSandboxReady` hooks complete, so they see the same repo state the agent sees (including installed dependencies).
|
|
467
473
|
|
|
468
474
|
```markdown
|
|
469
475
|
# Open issues
|
|
@@ -626,7 +632,7 @@ Removes the Podman image.
|
|
|
626
632
|
| `prompt` | string | — | Inline prompt (mutually exclusive with `promptFile`) |
|
|
627
633
|
| `promptFile` | string | — | Path to prompt file (mutually exclusive with `prompt`) |
|
|
628
634
|
| `maxIterations` | number | `1` | Maximum iterations to run |
|
|
629
|
-
| `hooks` |
|
|
635
|
+
| `hooks` | SandboxHooks | — | Lifecycle hooks (`host.*`, `sandbox.*`) |
|
|
630
636
|
| `name` | string | — | Display name for the run, shown as a prefix in log output |
|
|
631
637
|
| `promptArgs` | PromptArgs | — | Key-value map for `{{KEY}}` placeholder substitution |
|
|
632
638
|
| `branchStrategy` | BranchStrategy | per-provider default | Branch strategy: `{ type: 'head' }`, `{ type: 'merge-to-head' }`, or `{ type: 'branch', branch: '…' }` |
|
|
@@ -635,17 +641,53 @@ Removes the Podman image.
|
|
|
635
641
|
| `completionSignal` | string \| string[] | `<promise>COMPLETE</promise>` | String or array of strings the agent emits to stop the iteration loop early |
|
|
636
642
|
| `idleTimeoutSeconds` | number | `600` | Idle timeout in seconds — resets on each agent output event |
|
|
637
643
|
| `throwOnDuplicateWorktree` | boolean | `true` | When `false`, reuse an existing worktree for the target branch instead of failing on collision |
|
|
644
|
+
| `resumeSession` | string | — | Resume a prior Claude Code session by ID. Incompatible with `maxIterations > 1`. Session file must exist on host. |
|
|
638
645
|
|
|
639
646
|
### `RunResult`
|
|
640
647
|
|
|
641
|
-
| Field | Type
|
|
642
|
-
| ------------------ |
|
|
643
|
-
| `
|
|
644
|
-
| `completionSignal` | string?
|
|
645
|
-
| `stdout` | string
|
|
646
|
-
| `commits` | `{ sha }[]`
|
|
647
|
-
| `branch` | string
|
|
648
|
-
| `logFilePath` | string?
|
|
648
|
+
| Field | Type | Description |
|
|
649
|
+
| ------------------ | ------------------- | ------------------------------------------------------------------ |
|
|
650
|
+
| `iterations` | `IterationResult[]` | Per-iteration results (use `.length` for the count) |
|
|
651
|
+
| `completionSignal` | string? | The matched completion signal string, or `undefined` if none fired |
|
|
652
|
+
| `stdout` | string | Agent output |
|
|
653
|
+
| `commits` | `{ sha }[]` | Commits created during the run |
|
|
654
|
+
| `branch` | string | Target branch name |
|
|
655
|
+
| `logFilePath` | string? | Path to the log file (only when logging to a file) |
|
|
656
|
+
|
|
657
|
+
### `IterationResult`
|
|
658
|
+
|
|
659
|
+
| Field | Type | Description |
|
|
660
|
+
| ----------------- | ------- | ------------------------------------------------------------------------------------ |
|
|
661
|
+
| `sessionId` | string? | Claude Code session ID from the init line, or `undefined` for non-Claude agents |
|
|
662
|
+
| `sessionFilePath` | string? | Absolute host path to the captured session JSONL, or `undefined` when capture is off |
|
|
663
|
+
|
|
664
|
+
### Session capture
|
|
665
|
+
|
|
666
|
+
After each Claude Code iteration, Sandcastle automatically captures the agent's session JSONL from the sandbox to the host at `~/.claude/projects/<encoded-path>/sessions/<session-id>.jsonl`. The `cwd` fields inside each JSONL entry are rewritten to match the host repo root, so `claude --resume` works natively.
|
|
667
|
+
|
|
668
|
+
Session capture is enabled by default for `claudeCode()` and can be opted out via `captureSessions: false`. Non-Claude agent providers never attempt capture. Capture failure fails the run.
|
|
669
|
+
|
|
670
|
+
### Session resume
|
|
671
|
+
|
|
672
|
+
Pass `resumeSession` to `run()` to continue a prior Claude Code conversation inside a new sandbox:
|
|
673
|
+
|
|
674
|
+
```typescript
|
|
675
|
+
const result = await run({
|
|
676
|
+
agent: claudeCode("claude-opus-4-6"),
|
|
677
|
+
sandbox: docker(),
|
|
678
|
+
prompt: "Continue where you left off",
|
|
679
|
+
resumeSession: "abc-123-def",
|
|
680
|
+
});
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
Before the sandbox starts, Sandcastle validates that the session file exists on the host and transfers it into the sandbox with `cwd` fields rewritten to match the sandbox-side path. The Claude Code agent receives `--resume <id>` on its print command for iteration 1.
|
|
684
|
+
|
|
685
|
+
Constraints:
|
|
686
|
+
|
|
687
|
+
- `resumeSession` is incompatible with `maxIterations > 1` (throws before sandbox creation).
|
|
688
|
+
- The session file must exist at `~/.claude/projects/<encoded-path>/sessions/<id>.jsonl` (throws before sandbox creation).
|
|
689
|
+
- Only iteration 1 receives the resume flag; subsequent iterations (if any) start fresh.
|
|
690
|
+
- Non-Claude agent providers ignore `resumeSession`.
|
|
649
691
|
|
|
650
692
|
### `ClaudeCodeOptions`
|
|
651
693
|
|
|
@@ -655,10 +697,11 @@ The `claudeCode()` factory accepts an optional second argument for provider-spec
|
|
|
655
697
|
agent: claudeCode("claude-opus-4-6", { effort: "high" });
|
|
656
698
|
```
|
|
657
699
|
|
|
658
|
-
| Option
|
|
659
|
-
|
|
|
660
|
-
| `effort`
|
|
661
|
-
| `env`
|
|
700
|
+
| Option | Type | Default | Description |
|
|
701
|
+
| ----------------- | -------------------------------------------- | ------- | --------------------------------------------------------- |
|
|
702
|
+
| `effort` | `"low"` \| `"medium"` \| `"high"` \| `"max"` | — | Claude Code reasoning effort level (`max` is Opus only) |
|
|
703
|
+
| `env` | `Record<string, string>` | `{}` | Environment variables injected by this agent provider |
|
|
704
|
+
| `captureSessions` | `boolean` | `true` | Capture agent session JSONL to host for `claude --resume` |
|
|
662
705
|
|
|
663
706
|
### `CodexOptions`
|
|
664
707
|
|
|
@@ -708,13 +751,14 @@ Sandcastle ships with built-in providers for Docker, Podman, and Vercel, but you
|
|
|
708
751
|
|
|
709
752
|
Both provider types return a **sandbox handle** from their `create()` function. The handle exposes:
|
|
710
753
|
|
|
711
|
-
| Method | Required
|
|
712
|
-
| -------------- |
|
|
713
|
-
| `exec` | Both
|
|
714
|
-
| `close` | Both
|
|
715
|
-
| `
|
|
716
|
-
| `
|
|
717
|
-
| `
|
|
754
|
+
| Method | Required | Description |
|
|
755
|
+
| -------------- | ---------- | ---------------------------------------------------------------------------- |
|
|
756
|
+
| `exec` | Both | Run a command, optionally streaming stdout line-by-line via `options.onLine` |
|
|
757
|
+
| `close` | Both | Tear down the sandbox |
|
|
758
|
+
| `copyFileIn` | Bind-mount | Copy a single file from the host into the sandbox |
|
|
759
|
+
| `copyFileOut` | Both | Copy a single file from the sandbox to the host |
|
|
760
|
+
| `copyIn` | Isolated | Copy a file or directory from the host into the sandbox |
|
|
761
|
+
| `worktreePath` | Both | Absolute path to the repo directory inside the sandbox |
|
|
718
762
|
|
|
719
763
|
### `ExecResult`
|
|
720
764
|
|
|
@@ -740,6 +784,8 @@ import {
|
|
|
740
784
|
type ExecResult,
|
|
741
785
|
} from "@ai-hero/sandcastle";
|
|
742
786
|
import { execFile, spawn } from "node:child_process";
|
|
787
|
+
import { copyFile as fsCopyFile, mkdir as fsMkdir } from "node:fs/promises";
|
|
788
|
+
import { dirname } from "node:path";
|
|
743
789
|
import { createInterface } from "node:readline";
|
|
744
790
|
|
|
745
791
|
const localProcess = () =>
|
|
@@ -809,6 +855,16 @@ const localProcess = () =>
|
|
|
809
855
|
});
|
|
810
856
|
},
|
|
811
857
|
|
|
858
|
+
copyFileIn: async (hostPath: string, sandboxPath: string) => {
|
|
859
|
+
await fsMkdir(dirname(sandboxPath), { recursive: true });
|
|
860
|
+
await fsCopyFile(hostPath, sandboxPath);
|
|
861
|
+
},
|
|
862
|
+
|
|
863
|
+
copyFileOut: async (sandboxPath: string, hostPath: string) => {
|
|
864
|
+
await fsMkdir(dirname(hostPath), { recursive: true });
|
|
865
|
+
await fsCopyFile(sandboxPath, hostPath);
|
|
866
|
+
},
|
|
867
|
+
|
|
812
868
|
close: async () => {
|
|
813
869
|
// nothing to tear down for a local process
|
|
814
870
|
},
|
|
@@ -1016,28 +1072,36 @@ Add your project-specific dependencies (e.g., language runtimes, build tools) to
|
|
|
1016
1072
|
|
|
1017
1073
|
### Hooks
|
|
1018
1074
|
|
|
1019
|
-
Hooks are
|
|
1020
|
-
|
|
1021
|
-
| Hook | When it runs | Working directory |
|
|
1022
|
-
| ---------------- | -------------------------- | ---------------------- |
|
|
1023
|
-
| `onSandboxReady` | After the sandbox is ready | Sandbox repo directory |
|
|
1024
|
-
|
|
1025
|
-
**`onSandboxReady`** runs after the sandbox is ready. Use it for dependency installation or build steps (e.g., `npm install`).
|
|
1026
|
-
|
|
1027
|
-
Set `sudo: true` to run a command with elevated privileges inside the sandbox:
|
|
1075
|
+
Hooks are grouped by **where** they run — `host` (on the developer's machine) or `sandbox` (inside the container):
|
|
1028
1076
|
|
|
1029
1077
|
```ts
|
|
1030
|
-
|
|
1031
|
-
|
|
1078
|
+
hooks: {
|
|
1079
|
+
host: {
|
|
1080
|
+
onWorktreeReady: [{ command: "cp .env.example .env" }],
|
|
1081
|
+
onSandboxReady: [{ command: "echo sandbox is up" }],
|
|
1082
|
+
},
|
|
1083
|
+
sandbox: {
|
|
1032
1084
|
onSandboxReady: [
|
|
1033
|
-
{ command: "apt-get install -y ffmpeg", sudo: true },
|
|
1034
1085
|
{ command: "npm install" },
|
|
1086
|
+
{ command: "apt-get install -y ffmpeg", sudo: true },
|
|
1035
1087
|
],
|
|
1036
1088
|
},
|
|
1037
|
-
|
|
1038
|
-
});
|
|
1089
|
+
}
|
|
1039
1090
|
```
|
|
1040
1091
|
|
|
1092
|
+
| Hook | Runs on | When | Working directory |
|
|
1093
|
+
| ------------------------ | ------- | -------------------------------------------- | ------------------------------------------- |
|
|
1094
|
+
| `host.onWorktreeReady` | Host | After `copyToWorktree`, before sandbox start | Worktree path (host repo root under `head`) |
|
|
1095
|
+
| `host.onSandboxReady` | Host | After sandbox is up | Worktree path (host repo root under `head`) |
|
|
1096
|
+
| `sandbox.onSandboxReady` | Sandbox | After sandbox is up | Sandbox repo directory |
|
|
1097
|
+
|
|
1098
|
+
**Ordering:** `copyToWorktree` -> `host.onWorktreeReady` (sequential) -> sandbox created -> `host.onSandboxReady` + `sandbox.onSandboxReady` (parallel).
|
|
1099
|
+
|
|
1100
|
+
- **Host hooks** accept `{ command: string }` — no `sudo`, no `cwd`. Use `cd` or inline env in the command string.
|
|
1101
|
+
- **Sandbox hooks** accept `{ command: string; sudo?: boolean }` — set `sudo: true` for elevated privileges.
|
|
1102
|
+
- Within each hook point, sandbox hooks run in parallel; host hooks within `onSandboxReady` also run in parallel with sandbox hooks. `host.onWorktreeReady` hooks run sequentially in declared order.
|
|
1103
|
+
- If any hook exits non-zero, setup fails fast.
|
|
1104
|
+
|
|
1041
1105
|
## Development
|
|
1042
1106
|
|
|
1043
1107
|
```bash
|
package/dist/AgentProvider.d.ts
CHANGED
|
@@ -8,16 +8,23 @@ export type ParsedStreamEvent = {
|
|
|
8
8
|
type: "tool_call";
|
|
9
9
|
name: string;
|
|
10
10
|
args: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: "session_id";
|
|
13
|
+
sessionId: string;
|
|
11
14
|
};
|
|
12
15
|
/** Options passed to buildPrintCommand and buildInteractiveArgs. */
|
|
13
16
|
export interface AgentCommandOptions {
|
|
14
17
|
readonly prompt: string;
|
|
15
18
|
readonly dangerouslySkipPermissions: boolean;
|
|
19
|
+
/** When set, the agent should resume the given session ID instead of starting fresh. */
|
|
20
|
+
readonly resumeSession?: string;
|
|
16
21
|
}
|
|
17
22
|
export interface AgentProvider {
|
|
18
23
|
readonly name: string;
|
|
19
24
|
/** Environment variables injected by this agent provider. Merged at launch time with env resolver and sandbox provider env. */
|
|
20
25
|
readonly env: Record<string, string>;
|
|
26
|
+
/** When true, session capture is enabled for this provider. Default: true for Claude Code, false for others. */
|
|
27
|
+
readonly captureSessions: boolean;
|
|
21
28
|
buildPrintCommand(options: AgentCommandOptions): string;
|
|
22
29
|
buildInteractiveArgs?(options: AgentCommandOptions): string[];
|
|
23
30
|
parseStreamLine(line: string): ParsedStreamEvent[];
|
|
@@ -46,6 +53,8 @@ export interface ClaudeCodeOptions {
|
|
|
46
53
|
readonly effort?: "low" | "medium" | "high" | "max";
|
|
47
54
|
/** Environment variables injected by this agent provider. */
|
|
48
55
|
readonly env?: Record<string, string>;
|
|
56
|
+
/** When false, session capture is disabled. Default: true. */
|
|
57
|
+
readonly captureSessions?: boolean;
|
|
49
58
|
}
|
|
50
59
|
export declare const claudeCode: (model: string, options?: ClaudeCodeOptions | undefined) => AgentProvider;
|
|
51
60
|
//# sourceMappingURL=AgentProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentProvider.d.ts","sourceRoot":"","sources":["../src/AgentProvider.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"AgentProvider.d.ts","sourceRoot":"","sources":["../src/AgentProvider.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MA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;IACtD,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED,eAAO,MAAM,KAAK,sEAwBhB,CAAC;AAMH,+CAA+C;AAC/C,MAAM,WAAW,eAAe;IAC9B,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED,eAAO,MAAM,QAAQ,yEAqBnB,CAAC;AAMH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;IACpD,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,8DAA8D;IAC9D,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACpC;AAED,eAAO,MAAM,UAAU,2EAsCrB,CAAC"}
|
package/dist/AgentProvider.js
CHANGED
|
@@ -46,6 +46,11 @@ const parseStreamJsonLine = (line) => {
|
|
|
46
46
|
if (obj.type === "result" && typeof obj.result === "string") {
|
|
47
47
|
return [{ type: "result", result: obj.result }];
|
|
48
48
|
}
|
|
49
|
+
if (obj.type === "system" &&
|
|
50
|
+
obj.subtype === "init" &&
|
|
51
|
+
typeof obj.session_id === "string") {
|
|
52
|
+
return [{ type: "session_id", sessionId: obj.session_id }];
|
|
53
|
+
}
|
|
49
54
|
}
|
|
50
55
|
catch {
|
|
51
56
|
// Not valid JSON — skip
|
|
@@ -111,6 +116,7 @@ const parsePiStreamLine = (line) => {
|
|
|
111
116
|
export const pi = (model, options) => ({
|
|
112
117
|
name: "pi",
|
|
113
118
|
env: options?.env ?? {},
|
|
119
|
+
captureSessions: false,
|
|
114
120
|
buildPrintCommand({ prompt }) {
|
|
115
121
|
return `pi -p --mode json --no-session --model ${shellEscape(model)} ${shellEscape(prompt)}`;
|
|
116
122
|
},
|
|
@@ -158,6 +164,7 @@ const parseCodexStreamLine = (line) => {
|
|
|
158
164
|
export const codex = (model, options) => ({
|
|
159
165
|
name: "codex",
|
|
160
166
|
env: options?.env ?? {},
|
|
167
|
+
captureSessions: false,
|
|
161
168
|
buildPrintCommand({ prompt }) {
|
|
162
169
|
const effortFlag = options?.effort
|
|
163
170
|
? ` -c ${shellEscape(`model_reasoning_effort="${options.effort}"`)}`
|
|
@@ -177,6 +184,7 @@ export const codex = (model, options) => ({
|
|
|
177
184
|
export const opencode = (model, options) => ({
|
|
178
185
|
name: "opencode",
|
|
179
186
|
env: options?.env ?? {},
|
|
187
|
+
captureSessions: false,
|
|
180
188
|
buildPrintCommand({ prompt }) {
|
|
181
189
|
return `opencode run --model ${shellEscape(model)} ${shellEscape(prompt)}`;
|
|
182
190
|
},
|
|
@@ -193,12 +201,16 @@ export const opencode = (model, options) => ({
|
|
|
193
201
|
export const claudeCode = (model, options) => ({
|
|
194
202
|
name: "claude-code",
|
|
195
203
|
env: options?.env ?? {},
|
|
196
|
-
|
|
204
|
+
captureSessions: options?.captureSessions ?? true,
|
|
205
|
+
buildPrintCommand({ prompt, dangerouslySkipPermissions, resumeSession, }) {
|
|
197
206
|
const skipPerms = dangerouslySkipPermissions
|
|
198
207
|
? " --dangerously-skip-permissions"
|
|
199
208
|
: "";
|
|
200
209
|
const effortFlag = options?.effort ? ` --effort ${options.effort}` : "";
|
|
201
|
-
|
|
210
|
+
const resumeFlag = resumeSession
|
|
211
|
+
? ` --resume ${shellEscape(resumeSession)}`
|
|
212
|
+
: "";
|
|
213
|
+
return `claude --print --verbose${skipPerms} --output-format stream-json --model ${shellEscape(model)}${effortFlag}${resumeFlag} -p ${shellEscape(prompt)}`;
|
|
202
214
|
},
|
|
203
215
|
buildInteractiveArgs({ prompt, dangerouslySkipPermissions, }) {
|
|
204
216
|
const args = ["claude"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentProvider.js","sourceRoot":"","sources":["../src/AgentProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AgentProvider.js","sourceRoot":"","sources":["../src/AgentProvider.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,GAAG,CAAC;AAEhF,gFAAgF;AAChF,MAAM,eAAe,GAA2B;IAC9C,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,OAAO;IAClB,QAAQ,EAAE,KAAK;IACf,KAAK,EAAE,aAAa;CACrB,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAuB,EAAE;IAChE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;YACpE,MAAM,MAAM,GAAwB,EAAE,CAAC;YACvC,MAAM,KAAK,GAAa,EAAE,CAAC;YAC3B,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,OAK7B,EAAE,CAAC;gBACJ,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC5D,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACzB,CAAC;qBAAM,IACL,KAAK,CAAC,IAAI,KAAK,UAAU;oBACzB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;oBAC9B,KAAK,CAAC,KAAK,KAAK,SAAS,EACzB,CAAC;oBACD,MAAM,QAAQ,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;YAC9B,CAAC,CAAC,aAAa,WAAW,CAAC,aAAa,CAAC,EAAE;YAC3C,CAAC,CAAC,EAAE,CAAC;QACP,OAAO,2BAA2B,SAAS,wCAAwC,WAAW,CAAC,KAAK,CAAC,GAAG,UAAU,GAAG,UAAU,OAAO,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;IAC9J,CAAC;IAED,oBAAoB,CAAC,EACnB,MAAM,EACN,0BAA0B,GACN;QACpB,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QACxB,IAAI,0BAA0B;YAAE,IAAI,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;QAC5E,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC5B,IAAI,OAAO,EAAE,MAAM;YAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3D,IAAI,MAAM;YAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,eAAe,CAAC,IAAY;QAC1B,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorHandler.d.ts","sourceRoot":"","sources":["../src/ErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"ErrorHandler.d.ts","sourceRoot":"","sources":["../src/ErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,iCAqC9B,CAAC;AASF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,4FA2BqB,CAAC"}
|
package/dist/ErrorHandler.js
CHANGED
|
@@ -38,6 +38,7 @@ export const formatErrorMessage = (error) => {
|
|
|
38
38
|
case "PromptExpansionTimeoutError":
|
|
39
39
|
case "CommitCollectionTimeoutError":
|
|
40
40
|
case "MergeToHostTimeoutError":
|
|
41
|
+
case "SessionCaptureError":
|
|
41
42
|
return error.message;
|
|
42
43
|
}
|
|
43
44
|
};
|
|
@@ -75,5 +76,6 @@ Effect.catchTags(effect, {
|
|
|
75
76
|
PromptExpansionTimeoutError: showErrorAndExit,
|
|
76
77
|
CommitCollectionTimeoutError: showErrorAndExit,
|
|
77
78
|
MergeToHostTimeoutError: showErrorAndExit,
|
|
79
|
+
SessionCaptureError: showErrorAndExit,
|
|
78
80
|
});
|
|
79
81
|
//# sourceMappingURL=ErrorHandler.js.map
|
package/dist/ErrorHandler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorHandler.js","sourceRoot":"","sources":["../src/ErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAmB,EAAU,EAAE;IAChE,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,WAAW;YACd,OAAO,8BAA8B,KAAK,CAAC,OAAO,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QAC1E,KAAK,eAAe;YAClB,OAAO,2BAA2B,KAAK,CAAC,OAAO,MAAM,KAAK,C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AAC;IAClB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC;IACzB,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;IACpD,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAU,CAAC,CAAC;AAC5D,CAAC,CAAC,CAAC;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,MAA8B,EAC2B,EAAE;AAC3D,8DAA8D;AAC9D,MAAM,CAAC,SAAS,CAAC,MAA2C,EAAE;IAC5D,SAAS,EAAE,gBAAgB;IAC3B,aAAa,EAAE,gBAAgB;IAC/B,SAAS,EAAE,gBAAgB;IAC3B,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,gBAAgB;IAC7B,SAAS,EAAE,gBAAgB;IAC3B,aAAa,EAAE,gBAAgB;IAC/B,WAAW,EAAE,gBAAgB;IAC7B,UAAU,EAAE,gBAAgB;IAC5B,cAAc,EAAE,gBAAgB;IAChC,SAAS,EAAE,gBAAgB;IAC3B,qBAAqB,EAAE,gBAAgB;IACvC,oBAAoB,EAAE,gBAAgB;IACtC,0BAA0B,EAAE,gBAAgB;IAC5C,0BAA0B,EAAE,gBAAgB;IAC5C,kBAAkB,EAAE,gBAAgB;IACpC,gBAAgB,EAAE,gBAAgB;IAClC,oBAAoB,EAAE,gBAAgB;IACtC,2BAA2B,EAAE,gBAAgB;IAC7C,4BAA4B,EAAE,gBAAgB;IAC9C,uBAAuB,EAAE,gBAAgB;IACzC,mBAAmB,EAAE,gBAAgB;CACtC,CAA4D,CAAC"}
|
package/dist/Orchestrator.d.ts
CHANGED
|
@@ -19,9 +19,21 @@ export interface OrchestrateOptions {
|
|
|
19
19
|
readonly name?: string;
|
|
20
20
|
/** @internal Test-only override for the idle warning interval in milliseconds. Default: 60000 (1 minute). */
|
|
21
21
|
readonly _idleWarningIntervalMs?: number;
|
|
22
|
+
/** @internal Override for the host projects directory (for testing). */
|
|
23
|
+
readonly _hostProjectsDir?: string;
|
|
24
|
+
/** Resume a prior Claude Code session by ID. Applied to iteration 1 only. */
|
|
25
|
+
readonly resumeSession?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Per-iteration result carrying an optional session ID. */
|
|
28
|
+
export interface IterationResult {
|
|
29
|
+
/** Claude Code session ID extracted from the init line, or undefined for non-Claude agents. */
|
|
30
|
+
readonly sessionId?: string;
|
|
31
|
+
/** Absolute host path to the captured session JSONL, or undefined when capture is disabled or provider is non-Claude. */
|
|
32
|
+
readonly sessionFilePath?: string;
|
|
22
33
|
}
|
|
23
34
|
export interface OrchestrateResult {
|
|
24
|
-
|
|
35
|
+
/** Per-iteration results (use `iterations.length` for the count). */
|
|
36
|
+
readonly iterations: IterationResult[];
|
|
25
37
|
/** The matched completion signal string, or undefined if none fired. */
|
|
26
38
|
readonly completionSignal?: string;
|
|
27
39
|
readonly stdout: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Orchestrator.d.ts","sourceRoot":"","sources":["../src/Orchestrator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Orchestrator.d.ts","sourceRoot":"","sources":["../src/Orchestrator.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAOvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAoB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQxD,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAgH5D,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