agent-neckbeard 1.1.27 → 1.1.29

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/docs/LEGACY.md ADDED
@@ -0,0 +1,335 @@
1
+ # Legacy API (deprecated)
2
+
3
+ > **Deprecated.** Everything on this page is deprecated: `LegacyBundledAgent`, its structured tasks and attached sessions, `dependencies`, `files`, `localDirectories`, `claudeDir`, the `mode` property, the Next.js helpers, and the durable-session supervisor. It will be deleted once Tupelo's `cim-agent`, `valuation-agent`, and `deal-qualification-agent` have moved to the image-based `Agent` (see the [README](../README.md) and [AGENT.md](AGENT.md)). It still works, and it receives fixes but no new features.
4
+
5
+ `LegacyBundledAgent` bundles your agent's code on the host and, at every deploy, uploads it with the embedded runtime server, installs its dependencies, and copies its local directories into the sandbox. Its usage patterns:
6
+
7
+ - Structured tasks: an agent runs once per background task and returns one validated output (Structured Tasks below).
8
+ - Attached sessions: a caller-owned session emits typed progress frames while work runs (Attached Sessions below).
9
+ - Durable sessions: an opt-in generated supervisor owns Pi inside Daytona and reconnects outward to a long-lived gateway (Durable Sessions below).
10
+
11
+ `SandboxClient`, which these also use, is not deprecated; see the README.
12
+
13
+ `LegacyBundledAgent.kind` reports `"task"` or `"session"`. The older `mode: "run" | "stream"` property remains as a deprecated compatibility surface.
14
+
15
+ ## Legacy Bundled Agents
16
+
17
+ You write an agent:
18
+
19
+ ```typescript
20
+ import { LegacyBundledAgent } from "agent-neckbeard";
21
+ import { query } from "@anthropic-ai/claude-agent-sdk";
22
+ import { z } from "zod";
23
+
24
+ const agent = new LegacyBundledAgent({
25
+ sandbox: {
26
+ provider: "e2b",
27
+ template: "code-interpreter-v1",
28
+ },
29
+ inputSchema: z.object({ topic: z.string() }),
30
+ outputSchema: z.object({
31
+ title: z.string(),
32
+ summary: z.string(),
33
+ keyPoints: z.array(z.string()),
34
+ }),
35
+ envs: {
36
+ ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY,
37
+ },
38
+ run: async (input) => {
39
+ for await (const message of query({
40
+ prompt: `Research "${input.topic}" and return JSON`,
41
+ options: { maxTurns: 10 },
42
+ })) {
43
+ if (message.type === "result") {
44
+ return JSON.parse(message.result ?? "{}");
45
+ }
46
+ }
47
+ throw new Error("Claude did not return a result");
48
+ },
49
+ });
50
+
51
+ const sandboxId = await agent.deploy();
52
+ const result = await agent.run({ topic: "TypeScript generics" }, { sandboxId });
53
+ ```
54
+
55
+ `deploy()` bundles your agent, uploads `agent.mjs` and the embedded runtime server to the sandbox, starts `node server.mjs`, waits for `/health`, and returns the sandbox ID.
56
+
57
+ `run()` validates input locally, POSTs it to the sandbox server, reads SSE harness events, validates the final output, and returns the existing `{ ok, executionId, output | error }` result shape.
58
+
59
+ By default, the package infers the file to bundle from the `new LegacyBundledAgent(...)` call stack. In frameworks that bundle server code before runtime, set `sourceFile` to the real agent module so `deploy()` does not rebundle a framework output chunk:
60
+
61
+ ```typescript
62
+ new LegacyBundledAgent({
63
+ sourceFile: path.resolve(process.cwd(), "packages/my-agent/src/agent.ts"),
64
+ // ...
65
+ });
66
+ ```
67
+
68
+ When the right path differs between environments (for example a monorepo dev server versus a deployed worker), `resolveAgentSourceFile(candidates, { errorMessage })` returns the first candidate path that exists and falls back to the bundled agent module when running inside the sandbox.
69
+
70
+ For Next.js/Vercel-style deployments, keep `agent-neckbeard` external to the server bundle and make sure the referenced source file is included in the production artifact:
71
+
72
+ ```typescript
73
+ // next.config.ts
74
+ import { withNeckbeardNextConfig } from "agent-neckbeard";
75
+
76
+ const nextConfig = withNeckbeardNextConfig(
77
+ {
78
+ // your existing Next config
79
+ outputFileTracingIncludes: {
80
+ // Include every localDirectories source tree used by deploy().
81
+ "/api/my-agent": ["./packages/my-agent/.agents/**/*"],
82
+ },
83
+ },
84
+ {
85
+ routeGlob: "/api/my-agent",
86
+ sourceFiles: ["./packages/my-agent/src/agent.ts"],
87
+ },
88
+ );
89
+
90
+ export default nextConfig;
91
+ ```
92
+
93
+ The helper traces files imported by those source entries by default, including package entry metadata that `deploy()` needs when it rebundles the agent at runtime. It preserves and merges existing `outputFileTracingIncludes`, such as the `.agents/**/*` entry above. A `localDirectories.source` is read by the deployed process, so its complete tree must be included in the production function artifact. Set `outputFileTracingRoot` when the agent source or local directory is outside the app root.
94
+
95
+ This repo tests that shape locally with `npm run test:compat:next`, which builds and runs a Dockerized Next App Router fixture without pushing to Vercel. The fixture also checks the runtime env contract, Node major, and traced standalone files so source-level tests do not mask deployment artifact problems.
96
+
97
+ ## Setup
98
+
99
+ ```bash
100
+ npm install agent-neckbeard
101
+ ```
102
+
103
+ ```bash
104
+ export E2B_API_KEY=your-key
105
+ export DAYTONA_API_KEY=your-key
106
+ export ANTHROPIC_API_KEY=your-key
107
+ ```
108
+
109
+ Pick the sandbox backend explicitly with `sandbox.provider`. The public `sandbox.template` field maps to an E2B template or a Daytona snapshot.
110
+
111
+ Daytona network policy (`networkBlockAll`, `networkAllowList`, `domainAllowList`) and lifecycle (`autoStopInterval`, `autoDeleteInterval`) settings go in `sandbox` as described in [DAYTONA.md](DAYTONA.md):
112
+
113
+ ```typescript
114
+ new LegacyBundledAgent({
115
+ sandbox: {
116
+ provider: "daytona",
117
+ template: "daytona-small",
118
+ domainAllowList: "*.example.com",
119
+ },
120
+ // ...
121
+ });
122
+ ```
123
+
124
+ Modal sandboxes accept the same network options in the same shape; see [Modal network policy](MODAL.md#network-policy).
125
+
126
+ ## Structured Tasks
127
+
128
+ Use `run` when each invocation should produce one validated output:
129
+
130
+ ```typescript
131
+ new LegacyBundledAgent({
132
+ sandbox: {
133
+ provider: "e2b",
134
+ template: "code-interpreter-v1",
135
+ },
136
+ inputSchema: z.object({ prompt: z.string() }),
137
+ outputSchema: z.object({ answer: z.string() }),
138
+ run: async (input, ctx) => {
139
+ ctx.logger.info(`Handling ${ctx.executionId}`);
140
+ return { answer: input.prompt.toUpperCase() };
141
+ },
142
+ });
143
+ ```
144
+
145
+ The `run` handler receives a context object with `executionId`, `AbortSignal`, environment variables, sandbox paths, and a logger:
146
+
147
+ ```typescript
148
+ run: async (input, ctx) => {
149
+ const notesPath = `${ctx.sandbox.homeDir}/data/notes.txt`;
150
+ const cwd = ctx.sandbox.agentDir;
151
+ // ...
152
+ };
153
+ ```
154
+
155
+ Use `ctx.sandbox.homeDir` and `ctx.sandbox.agentDir` instead of hardcoding `/home/user` if you want the same agent code to work on both providers.
156
+
157
+ Structured-task agents fit background workflows (Hatchet tasks, Trigger.dev jobs, queue workers). The usual shape is one sandbox per task:
158
+
159
+ ```typescript
160
+ const sandboxId = await agent.deploy({ fresh: true });
161
+
162
+ try {
163
+ const result = await agent.run(input, { sandboxId });
164
+ if (!result.ok) throw result.error;
165
+ return result.output;
166
+ } finally {
167
+ await agent.kill(sandboxId);
168
+ }
169
+ ```
170
+
171
+ `deploy({ fresh: true })` keeps concurrent tasks from sharing one cached sandbox; see Reusing Sandboxes for the caching behavior.
172
+
173
+ The current 1.x structured-task configuration intentionally remains flat: top-level `outputSchema` and `run` define the task, and `agent.run()` executes it. Neither use of `run` is deprecated. A future API revision may introduce a noun-oriented `task: { outputSchema, handler }` configuration to parallel `session`, with a compatibility period for the current shape; no such change is scheduled.
174
+
175
+ ## Attached Sessions
176
+
177
+ Use `session.handler` when you want progress frames while the sandbox work is still running, such as relaying tool calls and assistant text to a UI or event log:
178
+
179
+ ```typescript
180
+ const agent = new LegacyBundledAgent({
181
+ sandbox: {
182
+ provider: "daytona",
183
+ template: "daytona-small",
184
+ },
185
+ inputSchema: z.object({ prompt: z.string() }),
186
+ session: {
187
+ frameSchema: z.object({
188
+ type: z.enum(["status", "token", "done"]),
189
+ text: z.string().optional(),
190
+ }),
191
+ handler: async ({ input, emit }) => {
192
+ await emit({ type: "status", text: `Starting ${input.prompt}` });
193
+ await emit({ type: "token", text: "hello" });
194
+ await emit({ type: "done" });
195
+ },
196
+ },
197
+ });
198
+
199
+ const sandboxId = await agent.deploy();
200
+ try {
201
+ const session = await agent.createSession({ sandboxId });
202
+ try {
203
+ for await (const frame of session.prompt({ prompt: "hi" })) {
204
+ console.log(frame);
205
+ }
206
+ } finally {
207
+ await session.close();
208
+ }
209
+ } finally {
210
+ await agent.kill(sandboxId);
211
+ }
212
+ ```
213
+
214
+ An attached session is a local handle over the sandbox HTTP/SSE runtime. It supports sequential `prompt()` calls, one active turn at a time, `stop()` for the active turn, and `close()` for the local handle. Closing it does not destroy the reusable sandbox. Pass `{ signal }` to `createSession()` to bind the complete local session lifetime to an external abort signal. A turn's iterator completes only after the runtime reports that the handler finished; a stream that ends early throws `ExecutionError`, and a turn cancelled by `stop()`, `close()`, or the session signal rejects with that cancellation reason. The runtime runs one handler at a time, so starting a turn while an earlier handler is still running throws `RuntimeBusyError`. A cancelled turn rejects at once while its handler may keep running in the sandbox until it notices the cancellation; call `agent.waitForIdle({ sandboxId })` before reading what the handler writes, such as a transcript, or starting the next turn.
215
+
216
+ The previous `server: { frameSchema, handler }` configuration remains as a deprecated alias for `session`. Likewise, `invoke(input, options)` remains as a deprecated compatibility wrapper: it creates one attached session, streams one prompt, and closes the local handle afterward.
217
+
218
+ ## Reusing Sandboxes
219
+
220
+ Persist the sandbox ID if another process needs to call the same running sandbox server:
221
+
222
+ ```typescript
223
+ const sandboxId = await agent.deploy();
224
+ await saveSandboxId(sandboxId);
225
+
226
+ // Later:
227
+ const savedSandboxId = await loadSandboxId();
228
+ const result = await agent.run(
229
+ { topic: "hello" },
230
+ { sandboxId: savedSandboxId },
231
+ );
232
+ ```
233
+
234
+ Neckbeard rehydrates the sandbox endpoint and provider traffic token from the sandbox ID using the configured provider SDK. E2B traffic tokens are sent as the `e2b-traffic-access-token` header. Daytona preview tokens are sent as the `DAYTONA_SANDBOX_AUTH_KEY` query parameter. Consumers only need to store the sandbox ID and configure the same provider/API key in the process that reconnects.
235
+
236
+ `deploy()` caches the sandbox on the agent instance and returns the cached ID on later calls. Use `deploy({ fresh: true })` to provision a new sandbox without touching the instance cache, which is useful when one agent instance serves concurrent runs that each need their own sandbox. The caller owns the returned sandbox ID: pass it to `run()`/`createSession()` and `kill()` it explicitly.
237
+
238
+ ### Environment Changes with Reused Sandboxes
239
+
240
+ `envs` are applied when Neckbeard creates the sandbox and starts the sandbox server. If the host app was missing a required value such as `ANTHROPIC_API_KEY` when the sandbox was created, the sandbox can remain healthy but unauthenticated even after you fix the host environment and redeploy the app.
241
+
242
+ Updating Vercel, Render, or 1Password environment variables does not mutate already-running sandboxes. Kill the old sandbox or deploy a fresh one and replace the persisted sandbox ID. Consumers that keep long-lived sandbox IDs should treat authentication failures such as `Not logged in` or `Please run /login` as a signal to discard the sandbox after verifying the host environment is now correct.
243
+
244
+
245
+ ## Configuration
246
+
247
+ The configuration types are exported: `AgentConfig` (a union of `RunAgentConfig` for structured tasks and `SessionAgentConfig` for sessions), `SandboxConfig` (`E2BSandboxConfig`, `DaytonaSandboxConfig`, `ModalSandboxConfig`, `DockerSandboxConfig`), `OsDependencies`, `BuildOptions`, `FileDownload`, and `LocalDirectoryUpload`, all in [`src/index.ts`](../src/index.ts). Their fields:
248
+
249
+ - `sandbox`: the provider and its options. `template` is an E2B template or a Daytona snapshot.
250
+ - `inputSchema`, plus `outputSchema` and `run` for a structured task, or `session: { frameSchema, handler, port? }` for a session agent. `session.port` is the in-sandbox HTTP server's port, 3000 by default.
251
+ - `maxDuration`: seconds an invocation may run, 300 by default.
252
+ - `sourceFile`: the module to bundle, described above.
253
+ - `dependencies`: `{ apt?: string[], commands?: string[] }`, APT packages to install and shell commands to run in the sandbox during `deploy()`. None by default.
254
+ - `files` (`{ url, path }[]`), `localDirectories`, `claudeDir` (deprecated), `envs`, and `build` (`{ external?: string[], autoDetectExternal?: boolean }`), described below.
255
+
256
+ The `files` option downloads files into the sandbox before the server starts. Relative paths resolve from the sandbox home directory: `/home/user` on E2B and the sandbox user's home on Daytona (`/home/daytona` on default snapshots).
257
+
258
+ `LocalDirectoryUpload` is exported by the package and has this shape:
259
+
260
+ ```typescript
261
+ interface LocalDirectoryUpload {
262
+ source: string;
263
+ destination: string;
264
+ }
265
+ ```
266
+
267
+ `localDirectories` recursively copies consumer-selected local directories beneath `ctx.sandbox.agentDir` during `deploy()`. Relative sources resolve from the deploying process's current working directory; absolute sources are also supported. Nested paths and dotfiles are included, text and binary files retain their exact bytes, and parent directories are created as needed. Empty directories are not preserved. The files go up as one gzipped tar archive that the sandbox extracts with `tar`, so the image needs `tar` and `gzip`; files land with mode 0644.
268
+
269
+ Each `destination` is relative to the sandbox agent directory. For example, this Pi-oriented configuration produces `<sandbox agentDir>/.agents/skills/...` on both E2B and Daytona:
270
+
271
+ ```typescript
272
+ const agent = new LegacyBundledAgent({
273
+ localDirectories: [
274
+ {
275
+ source: "./packages/my-agent/.agents",
276
+ destination: ".agents",
277
+ },
278
+ ],
279
+ // ...structured-task or session-agent configuration
280
+ });
281
+ ```
282
+
283
+ Copying skills to `.agents/skills` does not guarantee that Pi or another harness will discover them automatically. If the harness working directory is elsewhere, pass `${ctx.sandbox.agentDir}/.agents/skills` to it as an explicit skill path. Neckbeard does not detect harnesses or change their discovery and trust settings.
284
+
285
+ Before creating a sandbox, Neckbeard validates and enumerates every local upload. A source must exist and be a directory. `localDirectories` rejects symbolic links anywhere in a source tree, with the local path in the error. Empty destinations, `.`, absolute destinations, traversal outside the agent directory, and duplicate sandbox targets are rejected with `ConfigurationError`; this includes collisions with another entry or with `claudeDir`.
286
+
287
+ For Next.js/Vercel and other bundled deployment environments, ensure each source tree is present in the runtime artifact. Include it with `withNeckbeardNextConfig` as shown above, with raw `outputFileTracingIncludes`, or with the equivalent artifact-inclusion setting for the host framework.
288
+
289
+ `claudeDir` is deprecated but remains functional for backward compatibility. It uploads the contents of a local `.claude` directory to `<sandbox agentDir>/.claude`, preserving existing Claude Agent SDK behavior. Replace it with an explicit `localDirectories` mapping:
290
+
291
+ ```typescript
292
+ const agent = new LegacyBundledAgent({
293
+ localDirectories: [
294
+ {
295
+ source: "./my-project/.claude",
296
+ destination: ".claude",
297
+ },
298
+ ],
299
+ // ...agent configuration
300
+ });
301
+ ```
302
+
303
+ The `envs` option passes environment variables to the sandbox. Undefined values are filtered out:
304
+
305
+ ```typescript
306
+ const agent = new LegacyBundledAgent({
307
+ sandbox: {
308
+ provider: "e2b",
309
+ template: "code-interpreter-v1",
310
+ },
311
+ envs: {
312
+ ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY,
313
+ MY_API_KEY: process.env.MY_API_KEY,
314
+ },
315
+ // ...
316
+ });
317
+ ```
318
+
319
+ Some packages cannot be bundled because they spawn child processes or have native modules. The Claude Agent SDK is like this. These packages are automatically marked external and installed with npm in the sandbox. The `build` option tunes this: `build.external` adds package globs to mark external, and `build.autoDetectExternal: false` disables the native-module auto-detection.
320
+
321
+ ## Cleanup
322
+
323
+ A successfully deployed sandbox remains caller-owned and runs until you kill it or the provider's lifetime settings expire it. If `deploy()` creates a sandbox but fails before returning its ID, Neckbeard reclaims that incomplete deployment so it does not leak an unreachable provider resource. Kill every successfully deployed sandbox, as in the workflow example above. `kill()` accepts a sandbox ID. If omitted, it kills the sandbox cached on the agent instance.
324
+
325
+ ## Errors
326
+
327
+ All errors extend `NeckbeardError`. `ConfigurationError` covers invalid agent config, missing provider API keys, and provider features a sandbox does not support. `DeploymentError` covers sandbox creation, dependency install, and runtime server startup failures. After a runtime-server health-check failure, the two built-in startup paths include bounded best-effort captured logs when available, redact credential-named configured environment values and configured values of at least eight characters (including a possible tail-boundary fragment), and preserve the original health error if the diagnostic read fails or exceeds its local deadline. `ValidationError` wraps input/output schema failures with the parser error as `cause`. `ExecutionError` represents agent handler failures.
328
+
329
+ `run()` never throws; it returns `{ ok: false, error }`. Attached `session.prompt()` throws. The deprecated `invoke()` wrapper preserves that throwing behavior.
330
+
331
+ ## Durable Sessions
332
+
333
+ > **Deprecated.** The durable-session supervisor is no longer maintained and will be removed in a future major release. Attached sessions (`LegacyBundledAgent.createSession()`) remain supported, but they are not durable: a turn stops when its caller disconnects, and nothing is replayed.
334
+
335
+ `agent-neckbeard/supervisor` runs a persistent sandbox process that owns Pi while a separate gateway and lifecycle worker may restart independently. `createDurableSessionArtifact()` builds it and `deployDurableSessionArtifact()` boots it in a Daytona sandbox. [SUPERVISOR.md](SUPERVISOR.md) documents it completely: the launch contract and an example, the attempt credential, `beforeRelease`, cancellation and unavailable-generation errors, the Daytona target and terminal helpers, the 64 MiB session history ceiling, the gateway protocol, and the deprecated `createPiSupervisorArtifact()` and `deploySupervisorArtifact()` aliases.
package/docs/MODAL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Modal Provider
2
2
 
3
- Modal is supported by both `Agent` and `SandboxClient`. It requires **Node.js 22 or later on the host** and uses the `modal` JavaScript SDK, pinned to the 0.10 release line. E2B and Daytona retain the package's existing host Node.js support.
3
+ Modal is supported by both `LegacyBundledAgent` and `SandboxClient`. It requires **Node.js 22 or later on the host** and uses the `modal` JavaScript SDK, pinned to the 0.10 release line. E2B and Daytona retain the package's existing host Node.js support.
4
4
 
5
5
  ## Configuration
6
6
 
@@ -43,19 +43,21 @@ All settings except `provider` are optional:
43
43
  | `networkBlockAll` | `false` | Block all outbound traffic; cannot be combined with non-empty allow lists |
44
44
  | `networkAllowList` | unset | Comma-separated CIDR ranges the sandbox may reach, any protocol |
45
45
  | `domainAllowList` | unset | Comma-separated domains the sandbox may reach over HTTPS; `*.` wildcards match the domain and its subdomains |
46
+ | `command` | unset | `SandboxClient.create()` only: runs as the sandbox's main process and uses `template` as-is, without the setup layer below. `Agent` uses it for prebuilt images |
47
+ | `registrySecret` | unset | `SandboxClient.create()` only: name of a Modal Secret with `REGISTRY_USERNAME` and `REGISTRY_PASSWORD`, to pull a private `template` |
46
48
 
47
- The adapter extends the registry image with `USER root`, Bash, Python 3, util-linux (`flock`/`setsid`), coreutils, sudo, curl, and CA certificates. **It forces root for both setup and payload execution, even if your custom image declares a non-root user.** There is currently no user override. Custom images must support `apt-get` and provide a compatible Node.js/npm installation for `Agent`. The runtime starts with a fixed `PATH`, so when the image's `node`, `npm`, or `npx` resolve elsewhere, such as an nvm install, the adapter links them into `/usr/local/bin`. Home and work directories are `/root`; runtime files live in `/root/agent`. The first image build can add latency; Modal caches image layers.
49
+ The adapter extends the registry image with `USER root`, Bash, Python 3, util-linux (`flock`/`setsid`), coreutils, sudo, curl, and CA certificates. **It forces root for both setup and payload execution, even if your custom image declares a non-root user.** There is currently no user override. Custom images must support `apt-get` and provide a compatible Node.js/npm installation for `LegacyBundledAgent`. The runtime starts with a fixed `PATH`, so when the image's `node`, `npm`, or `npx` resolve elsewhere, such as an nvm install, the adapter links them into `/usr/local/bin`. Home and work directories are `/root`; runtime files live in `/root/agent`. The first image build can add latency; Modal caches image layers.
48
50
 
49
- Use the same sandbox settings in an Agent:
51
+ Use the same sandbox settings in a `LegacyBundledAgent`:
50
52
 
51
53
  ```typescript
52
- const agent = new Agent({
54
+ const agent = new LegacyBundledAgent({
53
55
  sandbox: { provider: 'modal', appName: 'my-agents', timeoutMs: 3_600_000 },
54
56
  // sourceFile, inputSchema, outputSchema, run, etc.
55
57
  });
56
58
  ```
57
59
 
58
- `SandboxClient.create()` additionally accepts `envs` and an explicit `tokenId` / `tokenSecret` pair. Both credentials must be supplied together. `Agent` deliberately uses host SDK credentials rather than storing them in agent config.
60
+ `SandboxClient.create()` additionally accepts `envs` and an explicit `tokenId` / `tokenSecret` pair. Both credentials must be supplied together. `LegacyBundledAgent` deliberately uses host SDK credentials rather than storing them in agent config.
59
61
 
60
62
  Reconnect from a different host using only the persisted sandbox ID and credentials for the same workspace:
61
63
 
@@ -67,19 +69,19 @@ const sandbox = await SandboxClient.connect({
67
69
  });
68
70
  ```
69
71
 
70
- Reconnect does not create a replacement sandbox, restart a terminated sandbox, or extend its lifetime. Creation-only options are rejected on connect. `Agent.run(..., { sandboxId })` and attached sessions reconnect and recover the HTTP runtime using the existing shared lifecycle.
72
+ Reconnect does not create a replacement sandbox, restart a terminated sandbox, or extend its lifetime. Creation-only options are rejected on connect. `LegacyBundledAgent.run(..., { sandboxId })` and attached sessions reconnect and recover the HTTP runtime using the existing shared lifecycle.
71
73
 
72
74
  ## Claude Permissions Under Root
73
75
 
74
- For a consumer using Claude Agent SDK with `permissionMode: 'bypassPermissions'` in this root-based Modal image, explicitly set **`Agent.envs: { IS_SANDBOX: '1' }`** in addition to the SDK's permission options. Otherwise Claude's root-user check can reject `--dangerously-skip-permissions`. Consumer direct-agent acceptance succeeded after this explicit workaround; it is not something the provider enables automatically.
76
+ For a consumer using Claude Agent SDK with `permissionMode: 'bypassPermissions'` in this root-based Modal image, explicitly set **`LegacyBundledAgent.envs: { IS_SANDBOX: '1' }`** in addition to the SDK's permission options. Otherwise Claude's root-user check can reject `--dangerously-skip-permissions`. Consumer direct-agent acceptance succeeded after this explicit workaround; it is not something the provider enables automatically.
75
77
 
76
78
  ```typescript
77
79
  import { fileURLToPath } from 'node:url';
78
- import { Agent } from 'agent-neckbeard';
80
+ import { LegacyBundledAgent } from 'agent-neckbeard';
79
81
  import { query } from '@anthropic-ai/claude-agent-sdk';
80
82
  import { z } from 'zod';
81
83
 
82
- export const claudeAgent = new Agent({
84
+ export const claudeAgent = new LegacyBundledAgent({
83
85
  sourceFile: fileURLToPath(import.meta.url),
84
86
  sandbox: { provider: 'modal', timeoutMs: 600_000 },
85
87
  envs: {
@@ -106,7 +108,7 @@ export const claudeAgent = new Agent({
106
108
  });
107
109
  ```
108
110
 
109
- From your host caller, deploy/run inside `try/finally` and call `await claudeAgent.kill()` in `finally`. Install and pin your supported Claude Agent SDK and schema dependency in that consumer. Do not put Modal provider credentials in `Agent.envs`.
111
+ From your host caller, deploy/run inside `try/finally` and call `await claudeAgent.kill()` in `finally`. Install and pin your supported Claude Agent SDK and schema dependency in that consumer. Do not put Modal provider credentials in `LegacyBundledAgent.envs`.
110
112
 
111
113
  Bypassing permissions allows agent tool execution without interactive approval, as root inside this image. Opt in only when that matches your application's trust and isolation policy. `IS_SANDBOX` is a CLI compatibility hint, not an isolation mechanism: it does not drop root privileges or replace tool restrictions, network policy, or private HTTP authentication. For permission-restricted agents, configure the appropriate Claude permission mode instead; the provider does not add bypass settings or `IS_SANDBOX` by default.
112
114
 
@@ -125,7 +127,7 @@ No encrypted or unencrypted public tunnels are created. The adapter obtains a po
125
127
  - Detached commands use the existing `DetachedProcessController`, not a bare background exec/PID handle. Prepare/release fencing, `beforeRelease`, stable `launchId` adoption, clean lifecycle environment, descriptor-based payload environment handoff, process-tree stop confirmation, bounded diagnostic logs, and exact-generation artifact disposal are unchanged.
126
128
  - Persist the complete `SandboxDetachedCommand` returned by `startDetachedCommand()`. Modal handles use the `modal-process-v2:` ownership prefix and the existing on-disk V3 lifecycle protocol. Foreign, malformed, and legacy/native handles are rejected before provider I/O.
127
129
  - Stop first, optionally read final diagnostics, then dispose artifacts. Disposal is irreversible and does not replace exact stop confirmation. Do not call stop after disposal; the proof required to stop has intentionally been removed.
128
- - `destroy()` waits for Modal termination and tolerates a provider not-found response. Other provider failures still reject. Failed `Agent.deploy()` attempts retain the shared best-effort stop/destroy cleanup and preserve the original error.
130
+ - `destroy()` waits for Modal termination and tolerates a provider not-found response. Other provider failures still reject. Failed `LegacyBundledAgent.deploy()` attempts retain the shared best-effort stop/destroy cleanup and preserve the original error.
129
131
 
130
132
  ## Region Selection
131
133
 
@@ -147,7 +149,7 @@ The separate public durable Pi supervisor target remains Daytona-specific. This
147
149
 
148
150
  ## Next.js and Live Tests
149
151
 
150
- Use `withNeckbeardNextConfig(...)` and an explicit Agent `sourceFile` as usual. The helper externalizes both `agent-neckbeard` and `modal`; package builds also leave the Modal SDK external. No SDK client is created merely by importing Neckbeard. Use Node.js 22+ for Modal routes/workers.
152
+ Use `withNeckbeardNextConfig(...)` and an explicit `LegacyBundledAgent` `sourceFile` as usual. The helper externalizes both `agent-neckbeard` and `modal`; package builds also leave the Modal SDK external. No SDK client is created merely by importing Neckbeard. Use Node.js 22+ for Modal routes/workers.
151
153
 
152
154
  ```bash
153
155
  npm test -- --runInBand tests/unit/modal.test.ts tests/unit/modal-resources.test.ts tests/unit/modal-config.test.ts
@@ -1,8 +1,8 @@
1
1
  # Durable Sessions (Sandbox Supervisor)
2
2
 
3
- > **Deprecated.** The durable-session supervisor is no longer maintained and will be removed in a future major release. Attached sessions (`Agent.createSession()`) remain supported, but they are not durable: a turn stops when its caller disconnects, and nothing is replayed.
3
+ > **Deprecated.** The durable-session supervisor is no longer maintained and will be removed in a future major release. Attached sessions (`LegacyBundledAgent.createSession()`) remain supported, but they are not durable: a turn stops when its caller disconnects, and nothing is replayed.
4
4
 
5
- The sandbox supervisor is the implementation of Neckbeard's opt-in durable-session runtime. It is separate from the attached HTTP/SSE session transport: importing `agent-neckbeard/supervisor` does not change `Agent.deploy()`, `run()`, `createSession()`, the deprecated `invoke()` wrapper, or `kill()`.
5
+ The sandbox supervisor is the implementation of Neckbeard's opt-in durable-session runtime. It is separate from the attached HTTP/SSE session transport: importing `agent-neckbeard/supervisor` does not change `LegacyBundledAgent.deploy()`, `run()`, `createSession()`, the deprecated `invoke()` wrapper, or `kill()`.
6
6
 
7
7
  The v1 adapter embeds Pi through `@earendil-works/pi-coding-agent`'s structured SDK. The generated Node runtime connects outward from a Daytona sandbox to a WebSocket gateway, journals durable events before sending them, and lets an accepted Pi turn continue when the gateway or Hatchet worker disconnects.
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-neckbeard",
3
- "version": "1.1.27",
3
+ "version": "1.1.29",
4
4
  "description": "Deploy AI agents to E2B, Daytona, and Modal sandboxes, or local Docker containers",
5
5
  "type": "module",
6
6
  "exports": {
@@ -23,8 +23,31 @@
23
23
  "types": "./dist/supervisor.d.cts",
24
24
  "default": "./dist/supervisor.cjs"
25
25
  }
26
+ },
27
+ "./serve": {
28
+ "import": {
29
+ "types": "./dist/serve.d.ts",
30
+ "default": "./dist/serve.js"
31
+ },
32
+ "require": {
33
+ "types": "./dist/serve.d.cts",
34
+ "default": "./dist/serve.cjs"
35
+ }
36
+ },
37
+ "./build": {
38
+ "import": {
39
+ "types": "./dist/build.d.ts",
40
+ "default": "./dist/build.js"
41
+ },
42
+ "require": {
43
+ "types": "./dist/build.d.cts",
44
+ "default": "./dist/build.cjs"
45
+ }
26
46
  }
27
47
  },
48
+ "bin": {
49
+ "neckbeard": "./dist/cli.js"
50
+ },
28
51
  "main": "./dist/index.cjs",
29
52
  "module": "./dist/index.js",
30
53
  "types": "./dist/index.d.cts",
@@ -34,7 +57,11 @@
34
57
  "CHANGELOG.md",
35
58
  "docs/SUPERVISOR.md",
36
59
  "docs/MODAL.md",
37
- "docs/DOCKER.md"
60
+ "docs/DOCKER.md",
61
+ "docs/AGENT.md",
62
+ "docs/DAYTONA.md",
63
+ "docs/E2B.md",
64
+ "docs/LEGACY.md"
38
65
  ],
39
66
  "engines": {
40
67
  "node": ">=20.18.1 <21 || >=22"
@@ -67,18 +94,31 @@
67
94
  "esbuild": "^0.28.2",
68
95
  "modal": "^0.10.0"
69
96
  },
97
+ "optionalDependencies": {
98
+ "skills": "1.8.1"
99
+ },
70
100
  "peerDependencies": {
71
- "zod": "^3.0.0 || ^4.0.0"
101
+ "zod": "^3.0.0 || ^4.0.0",
102
+ "@earendil-works/pi-coding-agent": ">=1.3.0 <2.0.0",
103
+ "braintrust": ">=3.44.0 <4.0.0"
72
104
  },
73
105
  "peerDependenciesMeta": {
74
106
  "zod": {
75
107
  "optional": true
108
+ },
109
+ "@earendil-works/pi-coding-agent": {
110
+ "optional": true
111
+ },
112
+ "braintrust": {
113
+ "optional": true
76
114
  }
77
115
  },
78
116
  "devDependencies": {
117
+ "@earendil-works/pi-coding-agent": "1.5.2",
79
118
  "@grpc/grpc-js": "^1.14.4",
80
119
  "@types/jest": "^30.0.0",
81
120
  "@types/node": "^22.0.0",
121
+ "braintrust": "3.44.0",
82
122
  "dotenv": "^17.3.1",
83
123
  "jest": "^30.3.0",
84
124
  "ts-jest": "^29.4.6",
@@ -1,48 +0,0 @@
1
- import {
2
- isSerializedError
3
- } from "./chunk-33IXN6MM.js";
4
-
5
- // src/runtime/protocol.ts
6
- var RUNTIME_PROTOCOL_VERSION = 1;
7
- var RUNTIME_ABORT_GRACE_MS = 1e4;
8
- function isHarnessEvent(value) {
9
- if (!value || typeof value !== "object") return false;
10
- const candidate = value;
11
- if (typeof candidate.kind !== "string") return false;
12
- if (typeof candidate.invocationId !== "string") return false;
13
- if (!hasValidMetadata(candidate)) return false;
14
- switch (candidate.kind) {
15
- case "started":
16
- case "done":
17
- return true;
18
- case "frame":
19
- return Object.hasOwn(candidate, "data");
20
- case "output":
21
- return Object.hasOwn(candidate, "output");
22
- case "error":
23
- return isSerializedError(candidate.error);
24
- default:
25
- return false;
26
- }
27
- }
28
- function hasValidMetadata(candidate) {
29
- if (candidate.protocolVersion !== void 0 && candidate.protocolVersion !== RUNTIME_PROTOCOL_VERSION) {
30
- return false;
31
- }
32
- if (candidate.sequence !== void 0 && typeof candidate.sequence !== "number") {
33
- return false;
34
- }
35
- if (candidate.timestamp !== void 0 && typeof candidate.timestamp !== "string") {
36
- return false;
37
- }
38
- if (candidate.elapsedMs !== void 0 && typeof candidate.elapsedMs !== "number") {
39
- return false;
40
- }
41
- return true;
42
- }
43
-
44
- export {
45
- RUNTIME_PROTOCOL_VERSION,
46
- RUNTIME_ABORT_GRACE_MS,
47
- isHarnessEvent
48
- };