@ai-hero/sandcastle 0.5.0 → 0.5.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 +104 -61
- package/dist/AgentProvider.d.ts +17 -1
- package/dist/AgentProvider.d.ts.map +1 -1
- package/dist/AgentProvider.js +75 -6
- package/dist/AgentProvider.js.map +1 -1
- package/dist/AgentStreamEmitter.d.ts +36 -0
- package/dist/AgentStreamEmitter.d.ts.map +1 -0
- package/dist/AgentStreamEmitter.js +21 -0
- package/dist/AgentStreamEmitter.js.map +1 -0
- package/dist/Display.js +1 -1
- package/dist/Display.js.map +1 -1
- package/dist/DockerLifecycle.d.ts +0 -10
- package/dist/DockerLifecycle.d.ts.map +1 -1
- package/dist/DockerLifecycle.js +0 -22
- package/dist/DockerLifecycle.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/InitService.d.ts.map +1 -1
- package/dist/InitService.js +3 -1
- package/dist/InitService.js.map +1 -1
- package/dist/MountConfig.d.ts +1 -2
- package/dist/MountConfig.d.ts.map +1 -1
- package/dist/Orchestrator.d.ts +11 -5
- package/dist/Orchestrator.d.ts.map +1 -1
- package/dist/Orchestrator.js +81 -13
- package/dist/Orchestrator.js.map +1 -1
- package/dist/PodmanLifecycle.d.ts +0 -10
- package/dist/PodmanLifecycle.d.ts.map +1 -1
- package/dist/PodmanLifecycle.js +0 -22
- package/dist/PodmanLifecycle.js.map +1 -1
- package/dist/PromptArgumentSubstitution.d.ts +6 -0
- package/dist/PromptArgumentSubstitution.d.ts.map +1 -1
- package/dist/PromptArgumentSubstitution.js +32 -6
- package/dist/PromptArgumentSubstitution.js.map +1 -1
- package/dist/PromptPreprocessor.d.ts +8 -0
- package/dist/PromptPreprocessor.d.ts.map +1 -1
- package/dist/PromptPreprocessor.js +13 -9
- package/dist/PromptPreprocessor.js.map +1 -1
- package/dist/PromptResolver.d.ts +13 -1
- package/dist/PromptResolver.d.ts.map +1 -1
- package/dist/PromptResolver.js +3 -2
- package/dist/PromptResolver.js.map +1 -1
- package/dist/SandboxFactory.d.ts +5 -5
- package/dist/SandboxFactory.d.ts.map +1 -1
- package/dist/SandboxFactory.js +20 -10
- package/dist/SandboxFactory.js.map +1 -1
- package/dist/SandboxLifecycle.d.ts +4 -1
- package/dist/SandboxLifecycle.d.ts.map +1 -1
- package/dist/SandboxLifecycle.js +40 -12
- package/dist/SandboxLifecycle.js.map +1 -1
- package/dist/SandboxProvider.d.ts +30 -0
- package/dist/SandboxProvider.d.ts.map +1 -1
- package/dist/SandboxProvider.js +1 -0
- 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 +2 -3
- package/dist/SessionStore.d.ts.map +1 -1
- package/dist/SessionStore.js +17 -15
- package/dist/SessionStore.js.map +1 -1
- package/dist/WorktreeManager.d.ts +6 -3
- package/dist/WorktreeManager.d.ts.map +1 -1
- package/dist/WorktreeManager.js +47 -5
- package/dist/WorktreeManager.js.map +1 -1
- package/dist/createSandbox.d.ts +32 -3
- package/dist/createSandbox.d.ts.map +1 -1
- package/dist/createSandbox.js +125 -58
- package/dist/createSandbox.js.map +1 -1
- package/dist/createWorktree.d.ts +32 -4
- package/dist/createWorktree.d.ts.map +1 -1
- package/dist/createWorktree.js +88 -27
- package/dist/createWorktree.js.map +1 -1
- package/dist/errors.d.ts +4 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interactive.d.ts +19 -0
- package/dist/interactive.d.ts.map +1 -1
- package/dist/interactive.js +34 -14
- package/dist/interactive.js.map +1 -1
- package/dist/mountUtils.d.ts +104 -0
- package/dist/mountUtils.d.ts.map +1 -0
- package/dist/mountUtils.js +245 -0
- package/dist/mountUtils.js.map +1 -0
- package/dist/raceAbortSignal.d.ts +18 -0
- package/dist/raceAbortSignal.d.ts.map +1 -0
- package/dist/raceAbortSignal.js +32 -0
- package/dist/raceAbortSignal.js.map +1 -0
- 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 +56 -5
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +72 -21
- package/dist/run.js.map +1 -1
- package/dist/sandboxes/docker.d.ts +2 -6
- package/dist/sandboxes/docker.d.ts.map +1 -1
- package/dist/sandboxes/docker.js +44 -78
- package/dist/sandboxes/docker.js.map +1 -1
- package/dist/sandboxes/no-sandbox.d.ts.map +1 -1
- package/dist/sandboxes/no-sandbox.js +9 -1
- package/dist/sandboxes/no-sandbox.js.map +1 -1
- package/dist/sandboxes/podman.d.ts +19 -8
- package/dist/sandboxes/podman.d.ts.map +1 -1
- package/dist/sandboxes/podman.js +49 -87
- package/dist/sandboxes/podman.js.map +1 -1
- package/dist/startSandbox.d.ts.map +1 -1
- package/dist/startSandbox.js +8 -3
- package/dist/startSandbox.js.map +1 -1
- package/dist/templates/parallel-planner/implement-prompt.md +1 -1
- package/dist/templates/parallel-planner-with-review/implement-prompt.md +1 -1
- package/dist/templates/parallel-planner-with-review/main.mts +8 -1
- package/dist/templates/parallel-planner-with-review/review-prompt.md +2 -2
- package/dist/templates/sequential-reviewer/review-prompt.md +2 -2
- package/dist/testSandbox.d.ts.map +1 -1
- package/dist/testSandbox.js +38 -48
- package/dist/testSandbox.js.map +1 -1
- package/dist/testSetup.d.ts +2 -0
- package/dist/testSetup.d.ts.map +1 -0
- package/dist/testSetup.js +29 -0
- package/dist/testSetup.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,6 +94,7 @@ await interactive({
|
|
|
94
94
|
agent: claudeCode("claude-opus-4-6"),
|
|
95
95
|
sandbox: noSandbox(),
|
|
96
96
|
prompt: "...", // optional — omit to launch the TUI with no initial prompt
|
|
97
|
+
cwd: "/path/to/other-repo", // optional — defaults to process.cwd()
|
|
97
98
|
});
|
|
98
99
|
```
|
|
99
100
|
|
|
@@ -147,11 +148,17 @@ const result = await run({
|
|
|
147
148
|
network: "my-network",
|
|
148
149
|
}),
|
|
149
150
|
|
|
151
|
+
// Host repo directory — replaces process.cwd() as the anchor for
|
|
152
|
+
// .sandcastle/ artifacts (worktrees, logs, env, patches) and git operations.
|
|
153
|
+
// Relative paths resolve against process.cwd(). Defaults to process.cwd().
|
|
154
|
+
cwd: "../other-repo",
|
|
155
|
+
|
|
150
156
|
// Branch strategy — controls how the agent's changes relate to branches.
|
|
151
157
|
// Defaults to { type: "head" } for bind-mount and { type: "merge-to-head" } for isolated providers.
|
|
152
158
|
branchStrategy: { type: "branch", branch: "agent/fix-42" },
|
|
153
159
|
|
|
154
|
-
// Prompt source — provide one of these, not both
|
|
160
|
+
// Prompt source — provide one of these, not both.
|
|
161
|
+
// Note: promptFile resolves against process.cwd(), NOT cwd.
|
|
155
162
|
promptFile: ".sandcastle/prompt.md", // path to a prompt file
|
|
156
163
|
// prompt: "Fix issue #42 in this repo", // OR an inline prompt string
|
|
157
164
|
|
|
@@ -182,7 +189,17 @@ const result = await run({
|
|
|
182
189
|
copyToWorktree: [".env"],
|
|
183
190
|
|
|
184
191
|
// How to record progress. Default: write to a file under .sandcastle/logs/
|
|
185
|
-
logging: {
|
|
192
|
+
logging: {
|
|
193
|
+
type: "file",
|
|
194
|
+
path: ".sandcastle/logs/my-run.log",
|
|
195
|
+
// Optional: forward the agent's output stream to your own observability system.
|
|
196
|
+
// Fires for each text chunk and tool call the agent produces. Errors thrown
|
|
197
|
+
// by the callback are swallowed so a broken forwarder cannot kill the run.
|
|
198
|
+
onAgentStreamEvent: (event) => {
|
|
199
|
+
// event is { type: "text" | "toolCall", iteration, timestamp, ... }
|
|
200
|
+
myLogger.info(event);
|
|
201
|
+
},
|
|
202
|
+
},
|
|
186
203
|
// logging: { type: "stdout" }, // OR render an interactive UI in the terminal
|
|
187
204
|
|
|
188
205
|
// String (or array of strings) the agent emits to end the iteration loop early.
|
|
@@ -272,23 +289,24 @@ if (closeResult.preservedWorktreePath) {
|
|
|
272
289
|
|
|
273
290
|
#### `CreateSandboxOptions`
|
|
274
291
|
|
|
275
|
-
| Option
|
|
276
|
-
|
|
|
277
|
-
| `branch`
|
|
278
|
-
| `sandbox`
|
|
279
|
-
| `
|
|
280
|
-
| `
|
|
281
|
-
| `
|
|
292
|
+
| Option | Type | Default | Description |
|
|
293
|
+
| ---------------- | --------------- | --------------- | -------------------------------------------------------------------- |
|
|
294
|
+
| `branch` | string | — | **Required.** Explicit branch for the sandbox |
|
|
295
|
+
| `sandbox` | SandboxProvider | — | **Required.** Sandbox provider (e.g. `docker()`, `podman()`) |
|
|
296
|
+
| `cwd` | string | `process.cwd()` | Host repo directory — relative paths resolve against `process.cwd()` |
|
|
297
|
+
| `hooks` | SandboxHooks | — | Lifecycle hooks (`host.*`, `sandbox.*`) — run once at creation time |
|
|
298
|
+
| `copyToWorktree` | string[] | — | Host-relative file paths to copy into the sandbox at creation time |
|
|
282
299
|
|
|
283
300
|
#### `Sandbox`
|
|
284
301
|
|
|
285
|
-
| Property / Method | Type
|
|
286
|
-
| ----------------------- |
|
|
287
|
-
| `branch` | string
|
|
288
|
-
| `worktreePath` | string
|
|
289
|
-
| `run(options)` | `(SandboxRunOptions) => Promise<SandboxRunResult>`
|
|
290
|
-
| `
|
|
291
|
-
| `
|
|
302
|
+
| Property / Method | Type | Description |
|
|
303
|
+
| ----------------------- | ------------------------------------------------------------------ | -------------------------------------------- |
|
|
304
|
+
| `branch` | string | The branch the sandbox is on |
|
|
305
|
+
| `worktreePath` | string | Host path to the worktree |
|
|
306
|
+
| `run(options)` | `(SandboxRunOptions) => Promise<SandboxRunResult>` | Invoke an agent inside the existing sandbox |
|
|
307
|
+
| `interactive(options)` | `(SandboxInteractiveOptions) => Promise<SandboxInteractiveResult>` | Launch an interactive session in the sandbox |
|
|
308
|
+
| `close()` | `() => Promise<CloseResult>` | Tear down the container and sandbox |
|
|
309
|
+
| `[Symbol.asyncDispose]` | `() => Promise<void>` | Auto teardown via `await using` |
|
|
292
310
|
|
|
293
311
|
#### `SandboxRunOptions`
|
|
294
312
|
|
|
@@ -303,6 +321,7 @@ if (closeResult.preservedWorktreePath) {
|
|
|
303
321
|
| `idleTimeoutSeconds` | number | `600` | Idle timeout in seconds — resets on each agent output event |
|
|
304
322
|
| `name` | string | — | Display name for the run |
|
|
305
323
|
| `logging` | object | file (auto-generated) | `{ type: 'file', path }` or `{ type: 'stdout' }` |
|
|
324
|
+
| `signal` | AbortSignal | — | Cancels the run when aborted; handle stays usable afterward |
|
|
306
325
|
|
|
307
326
|
#### `SandboxRunResult`
|
|
308
327
|
|
|
@@ -326,12 +345,15 @@ Use `createWorktree()` when you need a worktree (git worktree) as an independent
|
|
|
326
345
|
|
|
327
346
|
Only `branch` and `merge-to-head` strategies are accepted; `head` is a compile-time type error since it means no worktree.
|
|
328
347
|
|
|
348
|
+
Pass `cwd` to target a repo other than `process.cwd()`. Relative paths resolve against `process.cwd()`; absolute paths pass through. A `CwdError` is thrown if the path does not exist or is not a directory.
|
|
349
|
+
|
|
329
350
|
```typescript
|
|
330
351
|
import { createWorktree } from "@ai-hero/sandcastle";
|
|
331
352
|
|
|
332
353
|
await using wt = await createWorktree({
|
|
333
354
|
branchStrategy: { type: "branch", branch: "agent/fix-42" },
|
|
334
355
|
copyToWorktree: ["node_modules"],
|
|
356
|
+
cwd: "/path/to/other-repo", // optional — defaults to process.cwd()
|
|
335
357
|
});
|
|
336
358
|
|
|
337
359
|
console.log(wt.worktreePath); // host path to the worktree
|
|
@@ -391,33 +413,36 @@ await sandbox.close();
|
|
|
391
413
|
|
|
392
414
|
#### `WorktreeInteractiveOptions`
|
|
393
415
|
|
|
394
|
-
| Option | Type | Default | Description
|
|
395
|
-
| ------------ | ---------------------- | ------------- |
|
|
396
|
-
| `agent` | AgentProvider | — | **Required.** Agent provider
|
|
397
|
-
| `sandbox` | AnySandboxProvider | `noSandbox()` | Sandbox provider (defaults to no sandbox)
|
|
398
|
-
| `prompt` | string | — | Inline prompt (mutually exclusive with `promptFile`)
|
|
399
|
-
| `promptFile` | string | — | Path to prompt file
|
|
400
|
-
| `name` | string | — | Optional session name
|
|
401
|
-
| `hooks` | SandboxHooks | — | Lifecycle hooks (`host.*`, `sandbox.*`)
|
|
402
|
-
| `promptArgs` | PromptArgs | — | Key-value map for `{{KEY}}` placeholder substitution
|
|
403
|
-
| `env` | Record<string, string> | — | Environment variables to inject into the sandbox
|
|
416
|
+
| Option | Type | Default | Description |
|
|
417
|
+
| ------------ | ---------------------- | ------------- | ------------------------------------------------------------------------------------------------- |
|
|
418
|
+
| `agent` | AgentProvider | — | **Required.** Agent provider |
|
|
419
|
+
| `sandbox` | AnySandboxProvider | `noSandbox()` | Sandbox provider (defaults to no sandbox) |
|
|
420
|
+
| `prompt` | string | — | Inline prompt (mutually exclusive with `promptFile`) |
|
|
421
|
+
| `promptFile` | string | — | Path to prompt file |
|
|
422
|
+
| `name` | string | — | Optional session name |
|
|
423
|
+
| `hooks` | SandboxHooks | — | Lifecycle hooks (`host.*`, `sandbox.*`) |
|
|
424
|
+
| `promptArgs` | PromptArgs | — | Key-value map for `{{KEY}}` placeholder substitution |
|
|
425
|
+
| `env` | Record<string, string> | — | Environment variables to inject into the sandbox |
|
|
426
|
+
| `signal` | AbortSignal | — | Cancel the session when aborted. The worktree is preserved on disk. Rejects with `signal.reason`. |
|
|
404
427
|
|
|
405
428
|
#### `WorktreeRunOptions`
|
|
406
429
|
|
|
407
|
-
| Option | Type | Default | Description
|
|
408
|
-
| -------------------- | ---------------------- | ------- |
|
|
409
|
-
| `agent` | AgentProvider | — | **Required.** Agent provider
|
|
410
|
-
| `sandbox` | SandboxProvider | — | **Required.** Sandbox provider (AFK agents must be sandboxed)
|
|
411
|
-
| `prompt` | string | — | Inline prompt (mutually exclusive with `promptFile`)
|
|
412
|
-
| `promptFile` | string | — | Path to prompt file
|
|
413
|
-
| `maxIterations` | number | 1 | Maximum iterations to run
|
|
414
|
-
| `completionSignal` | string \| string[] | — | Substring(s) to stop the iteration loop early
|
|
415
|
-
| `idleTimeoutSeconds` | number | 600 | Idle timeout in seconds
|
|
416
|
-
| `name` | string | — | Optional run name
|
|
417
|
-
| `logging` | LoggingOption | file | Logging mode
|
|
418
|
-
| `hooks` | SandboxHooks | — | Lifecycle hooks (`host.*`, `sandbox.*`)
|
|
419
|
-
| `promptArgs` | PromptArgs | — | Key-value map for `{{KEY}}` placeholder substitution
|
|
420
|
-
| `env` | Record<string, string> | — | Environment variables to inject into the sandbox
|
|
430
|
+
| Option | Type | Default | Description |
|
|
431
|
+
| -------------------- | ---------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
432
|
+
| `agent` | AgentProvider | — | **Required.** Agent provider |
|
|
433
|
+
| `sandbox` | SandboxProvider | — | **Required.** Sandbox provider (AFK agents must be sandboxed) |
|
|
434
|
+
| `prompt` | string | — | Inline prompt (mutually exclusive with `promptFile`) |
|
|
435
|
+
| `promptFile` | string | — | Path to prompt file |
|
|
436
|
+
| `maxIterations` | number | 1 | Maximum iterations to run |
|
|
437
|
+
| `completionSignal` | string \| string[] | — | Substring(s) to stop the iteration loop early |
|
|
438
|
+
| `idleTimeoutSeconds` | number | 600 | Idle timeout in seconds |
|
|
439
|
+
| `name` | string | — | Optional run name |
|
|
440
|
+
| `logging` | LoggingOption | file | Logging mode |
|
|
441
|
+
| `hooks` | SandboxHooks | — | Lifecycle hooks (`host.*`, `sandbox.*`) |
|
|
442
|
+
| `promptArgs` | PromptArgs | — | Key-value map for `{{KEY}}` placeholder substitution |
|
|
443
|
+
| `env` | Record<string, string> | — | Environment variables to inject into the sandbox |
|
|
444
|
+
| `resumeSession` | string | — | Resume a prior Claude Code session by ID. Incompatible with `maxIterations > 1`. Session file must exist on host. |
|
|
445
|
+
| `signal` | AbortSignal | — | Cancel the run when aborted. Kills the in-flight agent subprocess; the worktree is preserved on disk. Rejects with `signal.reason`. |
|
|
421
446
|
|
|
422
447
|
#### `WorktreeRunResult`
|
|
423
448
|
|
|
@@ -463,6 +488,10 @@ You must provide exactly one of:
|
|
|
463
488
|
|
|
464
489
|
`prompt` and `promptFile` are mutually exclusive — providing both is an error. If neither is provided, `run()` throws an error asking you to supply one.
|
|
465
490
|
|
|
491
|
+
**Inline prompts (`prompt: "..."`) are passed to the agent literally.** No `{{KEY}}` substitution, no `` !`command` `` expansion, no built-in `{{SOURCE_BRANCH}}` / `{{TARGET_BRANCH}}` injection. If you need values interpolated into an inline prompt, build the string in JavaScript (`` `Work on ${branch}…` ``). Passing `promptArgs` alongside an inline prompt is an error — switch to `promptFile` to use substitution.
|
|
492
|
+
|
|
493
|
+
The substitution and expansion features below apply **only** to prompts sourced from `promptFile`.
|
|
494
|
+
|
|
466
495
|
> **Convention**: `sandcastle init` scaffolds `.sandcastle/prompt.md` and all templates explicitly reference it via `promptFile: ".sandcastle/prompt.md"`. This is a convention, not an automatic fallback — Sandcastle does not read `.sandcastle/prompt.md` unless you pass it as `promptFile`.
|
|
467
496
|
|
|
468
497
|
### Dynamic context with `` !`command` ``
|
|
@@ -510,6 +539,8 @@ Prompt argument substitution runs on the host before shell expression expansion,
|
|
|
510
539
|
|
|
511
540
|
A `{{KEY}}` placeholder with no matching prompt argument is an error. Unused prompt arguments produce a warning.
|
|
512
541
|
|
|
542
|
+
`` !`command` `` expansion only runs on shell blocks written in the prompt file itself. Any `` !`…` `` pattern that appears inside an argument value is treated as inert text — it won't be executed against the host shell. This makes it safe to pass user-authored content (issue titles, PR descriptions, docs excerpts) through `promptArgs`.
|
|
543
|
+
|
|
513
544
|
### Built-in prompt arguments
|
|
514
545
|
|
|
515
546
|
Sandcastle automatically injects two built-in prompt arguments into every prompt:
|
|
@@ -625,23 +656,24 @@ Removes the Podman image.
|
|
|
625
656
|
|
|
626
657
|
### `RunOptions`
|
|
627
658
|
|
|
628
|
-
| Option
|
|
629
|
-
|
|
|
630
|
-
| `agent`
|
|
631
|
-
| `sandbox`
|
|
632
|
-
| `
|
|
633
|
-
| `
|
|
634
|
-
| `
|
|
635
|
-
| `
|
|
636
|
-
| `
|
|
637
|
-
| `
|
|
638
|
-
| `
|
|
639
|
-
| `
|
|
640
|
-
| `
|
|
641
|
-
| `
|
|
642
|
-
| `
|
|
643
|
-
| `
|
|
644
|
-
| `resumeSession`
|
|
659
|
+
| Option | Type | Default | Description |
|
|
660
|
+
| -------------------- | ------------------ | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
661
|
+
| `agent` | AgentProvider | — | **Required.** Agent provider (e.g. `claudeCode("claude-opus-4-6")`, `pi("claude-sonnet-4-6")`, `codex("gpt-5.4-mini")`, `opencode("opencode/big-pickle")`) |
|
|
662
|
+
| `sandbox` | SandboxProvider | — | **Required.** Sandbox provider (e.g. `docker()`, `podman()`, `docker({ imageName: "sandcastle:local" })`) |
|
|
663
|
+
| `cwd` | string | `process.cwd()` | Host repo directory — anchor for `.sandcastle/` artifacts and git operations. Relative paths resolve against `process.cwd()`. |
|
|
664
|
+
| `prompt` | string | — | Inline prompt (mutually exclusive with `promptFile`) |
|
|
665
|
+
| `promptFile` | string | — | Path to prompt file (mutually exclusive with `prompt`). Resolves against `process.cwd()`, **not** `cwd`. |
|
|
666
|
+
| `maxIterations` | number | `1` | Maximum iterations to run |
|
|
667
|
+
| `hooks` | SandboxHooks | — | Lifecycle hooks (`host.*`, `sandbox.*`) |
|
|
668
|
+
| `name` | string | — | Display name for the run, shown as a prefix in log output |
|
|
669
|
+
| `promptArgs` | PromptArgs | — | Key-value map for `{{KEY}}` placeholder substitution |
|
|
670
|
+
| `branchStrategy` | BranchStrategy | per-provider default | Branch strategy: `{ type: 'head' }`, `{ type: 'merge-to-head' }`, or `{ type: 'branch', branch: '…' }` |
|
|
671
|
+
| `copyToWorktree` | string[] | — | Host-relative file paths to copy into the sandbox before start (not supported with `branchStrategy: { type: 'head' }`) |
|
|
672
|
+
| `logging` | object | file (auto-generated) | `{ type: 'file', path }` or `{ type: 'stdout' }` |
|
|
673
|
+
| `completionSignal` | string \| string[] | `<promise>COMPLETE</promise>` | String or array of strings the agent emits to stop the iteration loop early |
|
|
674
|
+
| `idleTimeoutSeconds` | number | `600` | Idle timeout in seconds — resets on each agent output event |
|
|
675
|
+
| `resumeSession` | string | — | Resume a prior Claude Code session by ID. Incompatible with `maxIterations > 1`. Session file must exist on host. |
|
|
676
|
+
| `signal` | AbortSignal | — | Cancel the run when aborted. Kills the in-flight agent subprocess and cancels lifecycle hooks; the worktree is preserved on disk. Rejects with `signal.reason`. |
|
|
645
677
|
|
|
646
678
|
### `RunResult`
|
|
647
679
|
|
|
@@ -656,10 +688,20 @@ Removes the Podman image.
|
|
|
656
688
|
|
|
657
689
|
### `IterationResult`
|
|
658
690
|
|
|
659
|
-
| Field | Type
|
|
660
|
-
| ----------------- |
|
|
661
|
-
| `sessionId` | string?
|
|
662
|
-
| `sessionFilePath` | string?
|
|
691
|
+
| Field | Type | Description |
|
|
692
|
+
| ----------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
693
|
+
| `sessionId` | string? | Claude Code session ID from the init line, or `undefined` for non-Claude agents |
|
|
694
|
+
| `sessionFilePath` | string? | Absolute host path to the captured session JSONL, or `undefined` when capture is off |
|
|
695
|
+
| `usage` | `IterationUsage`? | Token usage snapshot from the last assistant message, or `undefined` when capture is off or provider does not support usage parsing |
|
|
696
|
+
|
|
697
|
+
### `IterationUsage`
|
|
698
|
+
|
|
699
|
+
| Field | Type | Description |
|
|
700
|
+
| -------------------------- | ------ | ------------------------------------------ |
|
|
701
|
+
| `inputTokens` | number | Input tokens consumed |
|
|
702
|
+
| `cacheCreationInputTokens` | number | Tokens used to create prompt cache entries |
|
|
703
|
+
| `cacheReadInputTokens` | number | Tokens read from prompt cache |
|
|
704
|
+
| `outputTokens` | number | Output tokens generated |
|
|
663
705
|
|
|
664
706
|
### Session capture
|
|
665
707
|
|
|
@@ -1101,6 +1143,7 @@ hooks: {
|
|
|
1101
1143
|
- **Sandbox hooks** accept `{ command: string; sudo?: boolean }` — set `sudo: true` for elevated privileges.
|
|
1102
1144
|
- 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
1145
|
- If any hook exits non-zero, setup fails fast.
|
|
1146
|
+
- When a `signal` is passed to `run()`, it is threaded to all hooks — aborting the signal cancels any in-flight hook commands.
|
|
1104
1147
|
|
|
1105
1148
|
## Development
|
|
1106
1149
|
|
package/dist/AgentProvider.d.ts
CHANGED
|
@@ -19,15 +19,31 @@ export interface AgentCommandOptions {
|
|
|
19
19
|
/** When set, the agent should resume the given session ID instead of starting fresh. */
|
|
20
20
|
readonly resumeSession?: string;
|
|
21
21
|
}
|
|
22
|
+
/** Return type of buildPrintCommand — command string plus optional stdin content.
|
|
23
|
+
* When `stdin` is set, the sandbox pipes it to the child process's stdin
|
|
24
|
+
* instead of inlining the prompt in argv, avoiding the Linux 128 KB per-arg limit. */
|
|
25
|
+
export interface PrintCommand {
|
|
26
|
+
readonly command: string;
|
|
27
|
+
readonly stdin?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Per-iteration token usage snapshot extracted from the agent session. */
|
|
30
|
+
export interface IterationUsage {
|
|
31
|
+
readonly inputTokens: number;
|
|
32
|
+
readonly cacheCreationInputTokens: number;
|
|
33
|
+
readonly cacheReadInputTokens: number;
|
|
34
|
+
readonly outputTokens: number;
|
|
35
|
+
}
|
|
22
36
|
export interface AgentProvider {
|
|
23
37
|
readonly name: string;
|
|
24
38
|
/** Environment variables injected by this agent provider. Merged at launch time with env resolver and sandbox provider env. */
|
|
25
39
|
readonly env: Record<string, string>;
|
|
26
40
|
/** When true, session capture is enabled for this provider. Default: true for Claude Code, false for others. */
|
|
27
41
|
readonly captureSessions: boolean;
|
|
28
|
-
buildPrintCommand(options: AgentCommandOptions):
|
|
42
|
+
buildPrintCommand(options: AgentCommandOptions): PrintCommand;
|
|
29
43
|
buildInteractiveArgs?(options: AgentCommandOptions): string[];
|
|
30
44
|
parseStreamLine(line: string): ParsedStreamEvent[];
|
|
45
|
+
/** Parse token usage from the captured session JSONL content. Only implemented by Claude Code. */
|
|
46
|
+
parseSessionUsage?(content: string): IterationUsage | undefined;
|
|
31
47
|
}
|
|
32
48
|
export declare const DEFAULT_MODEL = "claude-opus-4-6";
|
|
33
49
|
/** Options for the pi agent provider. */
|
|
@@ -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,GACjD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,SAAS,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,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,WAAW,CAAC;IA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aAAa,oBAAoB,CAAC;AAkE/C,yCAAyC;AACzC,MAAM,WAAW,SAAS;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED,eAAO,MAAM,EAAE,mEAqBb,CAAC;AAgDH,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IACtD,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED,eAAO,MAAM,KAAK,sEA2BhB,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,yEAuBnB,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,2EAuErB,CAAC"}
|
package/dist/AgentProvider.js
CHANGED
|
@@ -6,6 +6,21 @@ const TOOL_ARG_FIELDS = {
|
|
|
6
6
|
WebFetch: "url",
|
|
7
7
|
Agent: "description",
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Extract an error message from a parsed JSON error event.
|
|
11
|
+
* Handles { error: "string" }, { error: { message: "string" } }, and { message: "string" }.
|
|
12
|
+
*/
|
|
13
|
+
const extractErrorMessage = (obj) => {
|
|
14
|
+
const err = obj.error;
|
|
15
|
+
if (typeof err === "string")
|
|
16
|
+
return err;
|
|
17
|
+
if (typeof err === "object" && err !== null && typeof err.message === "string") {
|
|
18
|
+
return err.message;
|
|
19
|
+
}
|
|
20
|
+
if (typeof obj.message === "string")
|
|
21
|
+
return obj.message;
|
|
22
|
+
return undefined;
|
|
23
|
+
};
|
|
9
24
|
const parseStreamJsonLine = (line) => {
|
|
10
25
|
if (!line.startsWith("{"))
|
|
11
26
|
return [];
|
|
@@ -88,6 +103,13 @@ const parsePiStreamLine = (line) => {
|
|
|
88
103
|
return [];
|
|
89
104
|
return [{ type: "tool_call", name: toolName, args: argValue }];
|
|
90
105
|
}
|
|
106
|
+
// Pi emits agent_error / error events on stdout (not stderr) for auth
|
|
107
|
+
// failures, rate limits, and API errors. Capture them as result events so
|
|
108
|
+
// the Orchestrator's stderr-empty fallback can surface them to the user.
|
|
109
|
+
if (obj.type === "agent_error" || obj.type === "error") {
|
|
110
|
+
const msg = extractErrorMessage(obj);
|
|
111
|
+
return msg ? [{ type: "result", result: msg }] : [];
|
|
112
|
+
}
|
|
91
113
|
if (obj.type === "agent_end" && Array.isArray(obj.messages)) {
|
|
92
114
|
const messages = obj.messages;
|
|
93
115
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
@@ -118,7 +140,10 @@ export const pi = (model, options) => ({
|
|
|
118
140
|
env: options?.env ?? {},
|
|
119
141
|
captureSessions: false,
|
|
120
142
|
buildPrintCommand({ prompt }) {
|
|
121
|
-
return
|
|
143
|
+
return {
|
|
144
|
+
command: `pi -p --mode json --no-session --model ${shellEscape(model)}`,
|
|
145
|
+
stdin: prompt,
|
|
146
|
+
};
|
|
122
147
|
},
|
|
123
148
|
buildInteractiveArgs({ prompt }) {
|
|
124
149
|
const args = ["pi", "--model", model];
|
|
@@ -141,8 +166,8 @@ const parseCodexStreamLine = (line) => {
|
|
|
141
166
|
// item.completed with agent_message → text + result
|
|
142
167
|
if (obj.type === "item.completed" &&
|
|
143
168
|
obj.item?.type === "agent_message" &&
|
|
144
|
-
typeof obj.item.
|
|
145
|
-
const text = obj.item.
|
|
169
|
+
typeof obj.item.text === "string") {
|
|
170
|
+
const text = obj.item.text;
|
|
146
171
|
return [
|
|
147
172
|
{ type: "text", text },
|
|
148
173
|
{ type: "result", result: text },
|
|
@@ -154,6 +179,13 @@ const parseCodexStreamLine = (line) => {
|
|
|
154
179
|
typeof obj.item.command === "string") {
|
|
155
180
|
return [{ type: "tool_call", name: "Bash", args: obj.item.command }];
|
|
156
181
|
}
|
|
182
|
+
// Codex emits error events on stdout (not stderr) for auth failures,
|
|
183
|
+
// rate limits, and API errors. Capture them as result events so the
|
|
184
|
+
// Orchestrator's stderr-empty fallback can surface them to the user.
|
|
185
|
+
if (obj.type === "error") {
|
|
186
|
+
const msg = extractErrorMessage(obj);
|
|
187
|
+
return msg ? [{ type: "result", result: msg }] : [];
|
|
188
|
+
}
|
|
157
189
|
// turn.completed → skip
|
|
158
190
|
}
|
|
159
191
|
catch {
|
|
@@ -169,7 +201,10 @@ export const codex = (model, options) => ({
|
|
|
169
201
|
const effortFlag = options?.effort
|
|
170
202
|
? ` -c ${shellEscape(`model_reasoning_effort="${options.effort}"`)}`
|
|
171
203
|
: "";
|
|
172
|
-
return
|
|
204
|
+
return {
|
|
205
|
+
command: `codex exec --json --dangerously-bypass-approvals-and-sandbox -m ${shellEscape(model)}${effortFlag}`,
|
|
206
|
+
stdin: prompt,
|
|
207
|
+
};
|
|
173
208
|
},
|
|
174
209
|
buildInteractiveArgs({ prompt }) {
|
|
175
210
|
const args = ["codex", "--model", model];
|
|
@@ -186,7 +221,9 @@ export const opencode = (model, options) => ({
|
|
|
186
221
|
env: options?.env ?? {},
|
|
187
222
|
captureSessions: false,
|
|
188
223
|
buildPrintCommand({ prompt }) {
|
|
189
|
-
return
|
|
224
|
+
return {
|
|
225
|
+
command: `opencode run --model ${shellEscape(model)} ${shellEscape(prompt)}`,
|
|
226
|
+
};
|
|
190
227
|
},
|
|
191
228
|
buildInteractiveArgs({ prompt }) {
|
|
192
229
|
const args = ["opencode", "--model", model];
|
|
@@ -210,7 +247,10 @@ export const claudeCode = (model, options) => ({
|
|
|
210
247
|
const resumeFlag = resumeSession
|
|
211
248
|
? ` --resume ${shellEscape(resumeSession)}`
|
|
212
249
|
: "";
|
|
213
|
-
return
|
|
250
|
+
return {
|
|
251
|
+
command: `claude --print --verbose${skipPerms} --output-format stream-json --model ${shellEscape(model)}${effortFlag}${resumeFlag} -p -`,
|
|
252
|
+
stdin: prompt,
|
|
253
|
+
};
|
|
214
254
|
},
|
|
215
255
|
buildInteractiveArgs({ prompt, dangerouslySkipPermissions, }) {
|
|
216
256
|
const args = ["claude"];
|
|
@@ -226,5 +266,34 @@ export const claudeCode = (model, options) => ({
|
|
|
226
266
|
parseStreamLine(line) {
|
|
227
267
|
return parseStreamJsonLine(line);
|
|
228
268
|
},
|
|
269
|
+
parseSessionUsage(content) {
|
|
270
|
+
const lines = content.split("\n");
|
|
271
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
272
|
+
const line = lines[i];
|
|
273
|
+
if (!line.startsWith("{"))
|
|
274
|
+
continue;
|
|
275
|
+
try {
|
|
276
|
+
const obj = JSON.parse(line);
|
|
277
|
+
if (obj.type === "assistant" && obj.message?.usage) {
|
|
278
|
+
const u = obj.message.usage;
|
|
279
|
+
if (typeof u.input_tokens === "number" &&
|
|
280
|
+
typeof u.cache_creation_input_tokens === "number" &&
|
|
281
|
+
typeof u.cache_read_input_tokens === "number" &&
|
|
282
|
+
typeof u.output_tokens === "number") {
|
|
283
|
+
return {
|
|
284
|
+
inputTokens: u.input_tokens,
|
|
285
|
+
cacheCreationInputTokens: u.cache_creation_input_tokens,
|
|
286
|
+
cacheReadInputTokens: u.cache_read_input_tokens,
|
|
287
|
+
outputTokens: u.output_tokens,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
// Not valid JSON — skip
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return undefined;
|
|
297
|
+
},
|
|
229
298
|
});
|
|
230
299
|
//# sourceMappingURL=AgentProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
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;o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AAG,CAAC;gBAAE,SAAS;YACpC,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC7B,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;oBACnD,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC;oBAC5B,IACE,OAAO,CAAC,CAAC,YAAY,KAAK,QAAQ;wBAClC,OAAO,CAAC,CAAC,2BAA2B,KAAK,QAAQ;wBACjD,OAAO,CAAC,CAAC,uBAAuB,KAAK,QAAQ;wBAC7C,OAAO,CAAC,CAAC,aAAa,KAAK,QAAQ,EACnC,CAAC;wBACD,OAAO;4BACL,WAAW,EAAE,CAAC,CAAC,YAAY;4BAC3B,wBAAwB,EAAE,CAAC,CAAC,2BAA2B;4BACvD,oBAAoB,EAAE,CAAC,CAAC,uBAAuB;4BAC/C,YAAY,EAAE,CAAC,CAAC,aAAa;yBAC9B,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,wBAAwB;YAC1B,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* A single event in the agent's output stream, surfaced to callers of `run()`
|
|
4
|
+
* so they can forward it to their own observability system.
|
|
5
|
+
*
|
|
6
|
+
* Emitted only in log-to-file mode when an `onAgentStreamEvent` callback is
|
|
7
|
+
* provided via `logging`. See `run()`.
|
|
8
|
+
*/
|
|
9
|
+
export type AgentStreamEvent = {
|
|
10
|
+
readonly type: "text";
|
|
11
|
+
readonly message: string;
|
|
12
|
+
readonly iteration: number;
|
|
13
|
+
readonly timestamp: Date;
|
|
14
|
+
} | {
|
|
15
|
+
readonly type: "toolCall";
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly formattedArgs: string;
|
|
18
|
+
readonly iteration: number;
|
|
19
|
+
readonly timestamp: Date;
|
|
20
|
+
};
|
|
21
|
+
export interface AgentStreamEmitterService {
|
|
22
|
+
readonly emit: (event: AgentStreamEvent) => Effect.Effect<void>;
|
|
23
|
+
}
|
|
24
|
+
declare const AgentStreamEmitter_base: Context.TagClass<AgentStreamEmitter, "AgentStreamEmitter", AgentStreamEmitterService>;
|
|
25
|
+
export declare class AgentStreamEmitter extends AgentStreamEmitter_base {
|
|
26
|
+
}
|
|
27
|
+
export declare const noopAgentStreamEmitterLayer: Layer.Layer<AgentStreamEmitter>;
|
|
28
|
+
/**
|
|
29
|
+
* Build a layer that forwards each event to the provided callback.
|
|
30
|
+
* The callback is invoked synchronously inside an `Effect.sync`; any error
|
|
31
|
+
* thrown by the callback is caught and discarded so observability failures
|
|
32
|
+
* cannot kill the run.
|
|
33
|
+
*/
|
|
34
|
+
export declare const callbackAgentStreamEmitterLayer: (onEvent: (event: AgentStreamEvent) => void) => Layer.Layer<AgentStreamEmitter, never, never>;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=AgentStreamEmitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentStreamEmitter.d.ts","sourceRoot":"","sources":["../src/AgentStreamEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GACxB;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;CAC1B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;CAC1B,CAAC;AAEN,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CACjE;;AAED,qBAAa,kBAAmB,SAAQ,uBAGrC;CAAG;AAEN,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,KAAK,CAAC,kBAAkB,CACR,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,+FAYxC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
export class AgentStreamEmitter extends Context.Tag("AgentStreamEmitter")() {
|
|
3
|
+
}
|
|
4
|
+
export const noopAgentStreamEmitterLayer = Layer.succeed(AgentStreamEmitter, { emit: () => Effect.void });
|
|
5
|
+
/**
|
|
6
|
+
* Build a layer that forwards each event to the provided callback.
|
|
7
|
+
* The callback is invoked synchronously inside an `Effect.sync`; any error
|
|
8
|
+
* thrown by the callback is caught and discarded so observability failures
|
|
9
|
+
* cannot kill the run.
|
|
10
|
+
*/
|
|
11
|
+
export const callbackAgentStreamEmitterLayer = (onEvent) => Layer.succeed(AgentStreamEmitter, {
|
|
12
|
+
emit: (event) => Effect.sync(() => {
|
|
13
|
+
try {
|
|
14
|
+
onEvent(event);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// Swallow callback errors — a broken forwarder must not kill the run.
|
|
18
|
+
}
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=AgentStreamEmitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentStreamEmitter.js","sourceRoot":"","sources":["../src/AgentStreamEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AA4BhD,MAAM,OAAO,kBAAmB,SAAQ,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAGtE;CAAG;AAEN,MAAM,CAAC,MAAM,2BAA2B,GACtC,KAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,OAA0C,EACT,EAAE,CACnC,KAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE;IAChC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CACd,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;QACf,IAAI,CAAC;YACH,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;QAAC,MAAM,CAAC;YACP,sEAAsE;QACxE,CAAC;IACH,CAAC,CAAC;CACL,CAAC,CAAC"}
|
package/dist/Display.js
CHANGED
|
@@ -56,7 +56,7 @@ export const FileDisplay = {
|
|
|
56
56
|
.pipe(Effect.orDie);
|
|
57
57
|
const appendToLog = (line) => fs
|
|
58
58
|
.writeFileString(filePath, line + "\n", { flag: "a" })
|
|
59
|
-
.pipe(Effect.
|
|
59
|
+
.pipe(Effect.ignore);
|
|
60
60
|
return {
|
|
61
61
|
intro: () => Effect.void,
|
|
62
62
|
status: (message, _severity) => appendToLog(message.replace(/^\[[^\]]+\] /, "")),
|