agent-neckbeard 1.1.20 → 1.1.22

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.
@@ -66,6 +66,10 @@ function buildRequestHeaders(options) {
66
66
  if (options.provider === "e2b" && options.trafficToken) {
67
67
  headers["e2b-traffic-access-token"] = options.trafficToken;
68
68
  }
69
+ if (options.provider === "modal") {
70
+ if (!options.trafficToken) throw new Error("Modal HTTP requests require a Connect Token.");
71
+ headers.authorization = `Bearer ${options.trafficToken}`;
72
+ }
69
73
  return headers;
70
74
  }
71
75
  function validateHarnessEvent(rawEvent, invocationId) {
@@ -264,7 +264,7 @@ var RELEASED_PATTERN = new RegExp(
264
264
  "u"
265
265
  );
266
266
  var HANDLE_PATTERN = new RegExp(
267
- `^(daytona|e2b)-process-v2:(\\d+):(\\d+):(\\d+):(${HASH_PATTERN}):(${HASH_PATTERN})$`,
267
+ `^(daytona|e2b|modal|docker)-process-v2:(\\d+):(\\d+):(\\d+):(${HASH_PATTERN}):(${HASH_PATTERN})$`,
268
268
  "u"
269
269
  );
270
270
  var DETACHED_PROCESS_LAUNCH_CANCELLED_MARKER = /* @__PURE__ */ Symbol.for(
@@ -483,7 +483,7 @@ function parseDetachedCommand(sessionId) {
483
483
  const match = HANDLE_PATTERN.exec(sessionId);
484
484
  if (!match) return null;
485
485
  const [, provider, pid, startTicks, processSessionId, launchKey, descriptorKey] = match;
486
- if (provider !== "daytona" && provider !== "e2b" || !pid || !startTicks || !processSessionId || !launchKey || !descriptorKey || pid !== processSessionId) {
486
+ if (provider !== "daytona" && provider !== "e2b" && provider !== "modal" && provider !== "docker" || !pid || !startTicks || !processSessionId || !launchKey || !descriptorKey || pid !== processSessionId) {
487
487
  return null;
488
488
  }
489
489
  return {
@@ -496,10 +496,16 @@ function parseDetachedCommand(sessionId) {
496
496
  };
497
497
  }
498
498
  function hasDetachedProcessV2Prefix(sessionId) {
499
- return /^(?:daytona|e2b)-process-v2/u.test(sessionId);
499
+ return /^(?:daytona|e2b|modal|docker)-process-v2/u.test(sessionId);
500
500
  }
501
+ var DETACHED_PROCESS_PROVIDER_NAMES = {
502
+ daytona: "Daytona",
503
+ e2b: "E2B",
504
+ modal: "Modal",
505
+ docker: "Docker"
506
+ };
501
507
  function detachedProcessProviderName(provider) {
502
- return provider === "daytona" ? "Daytona" : "E2B";
508
+ return DETACHED_PROCESS_PROVIDER_NAMES[provider];
503
509
  }
504
510
  function resolveDetachedCommandForProvider(sessionId, expectedProvider, failure, commandId) {
505
511
  const identity = parseDetachedCommand(sessionId);
@@ -1332,6 +1338,35 @@ function buildEnvironmentFdLaunch(paths, child, environmentMode) {
1332
1338
  "exec 7<&-"
1333
1339
  ];
1334
1340
  }
1341
+ var SANDBOX_NETWORK_ENVIRONMENT_KEYS = [
1342
+ "HTTP_PROXY",
1343
+ "HTTPS_PROXY",
1344
+ "ALL_PROXY",
1345
+ "NO_PROXY",
1346
+ "http_proxy",
1347
+ "https_proxy",
1348
+ "all_proxy",
1349
+ "no_proxy",
1350
+ "NODE_EXTRA_CA_CERTS",
1351
+ "SSL_CERT_FILE",
1352
+ "SSL_CERT_DIR",
1353
+ "REQUESTS_CA_BUNDLE",
1354
+ "CURL_CA_BUNDLE"
1355
+ ];
1356
+ function inheritSandboxNetworkEnvironment() {
1357
+ const script = [
1358
+ "import json, os",
1359
+ `payload = json.loads(os.environ[${JSON.stringify(SUPERVISOR_ENVIRONMENT_PAYLOAD_ENV)}])`,
1360
+ `for name in ${JSON.stringify(SANDBOX_NETWORK_ENVIRONMENT_KEYS)}:`,
1361
+ " if name in os.environ:",
1362
+ ' payload["environment"].setdefault(name, os.environ[name])',
1363
+ 'encoded = json.dumps(payload, ensure_ascii=False, separators=(",", ":"))',
1364
+ `if len(encoded.encode("utf-8")) > ${SUPERVISOR_ENVIRONMENT_MAX_BYTES} or len(payload["environment"]) > ${SUPERVISOR_ENVIRONMENT_MAX_ENTRIES}:`,
1365
+ " raise SystemExit(1)",
1366
+ "print(encoded)"
1367
+ ].join("\n");
1368
+ return `${SUPERVISOR_ENVIRONMENT_PAYLOAD_ENV}=$(${SUPERVISOR_ENVIRONMENT_PAYLOAD_ENV}="$${SUPERVISOR_ENVIRONMENT_PAYLOAD_ENV}" python3 -I -S -c ${shellQuote(script)}) || exit 1`;
1369
+ }
1335
1370
  function cleanLifecycleShell(script, environmentMode) {
1336
1371
  let suffix = 0;
1337
1372
  let delimiter = "NECKBEARD_DETACHED_LIFECYCLE";
@@ -1346,7 +1381,8 @@ function cleanLifecycleShell(script, environmentMode) {
1346
1381
  return [
1347
1382
  `export PATH=${shellQuote(DETACHED_PROCESS_TRUSTED_PATH)}`,
1348
1383
  ...environmentMode === "exec" ? [
1349
- `if [ -z "\${${SUPERVISOR_ENVIRONMENT_PAYLOAD_ENV}+present}" ]; then ${SUPERVISOR_ENVIRONMENT_PAYLOAD_ENV}=${shellQuote('{"version":1,"environment":{}}')}; fi`
1384
+ `if [ -z "\${${SUPERVISOR_ENVIRONMENT_PAYLOAD_ENV}+present}" ]; then ${SUPERVISOR_ENVIRONMENT_PAYLOAD_ENV}=${shellQuote('{"version":1,"environment":{}}')}; fi`,
1385
+ inheritSandboxNetworkEnvironment()
1350
1386
  ] : [],
1351
1387
  `exec env -i ${fixedEnvironment} ${SUPERVISOR_ENVIRONMENT_PAYLOAD_ENV}="$${SUPERVISOR_ENVIRONMENT_PAYLOAD_ENV}" sh -s <<'${delimiter}'`,
1352
1388
  script,
@@ -9,7 +9,7 @@ import {
9
9
  serializeSupervisorEnvironmentHandoff,
10
10
  shellQuote,
11
11
  uploadDaytonaFile
12
- } from "./chunk-3EB4CT5S.js";
12
+ } from "./chunk-6P5I7ZCH.js";
13
13
  import {
14
14
  serializeError
15
15
  } from "./chunk-33IXN6MM.js";
package/docs/DOCKER.md ADDED
@@ -0,0 +1,94 @@
1
+ # Docker Provider
2
+
3
+ The Docker provider runs the same agent runtime in a container on a local Docker daemon. It is supported by both `Agent` and `SandboxClient` and needs only the `docker` CLI on the host `PATH`; there is no SDK dependency and no credential.
4
+
5
+ **It is a development and evaluation provider, not an isolation boundary.** E2B, Daytona, and Modal place untrusted agent tool calls inside a provider-operated microVM or gVisor sandbox. A Docker container shares the host kernel and runs here as root. Use it to iterate locally, to run evals next to local services on a compose network, and in CI. Do not use it to contain untrusted input in production, and note that the primary serverless consumers (Vercel Functions, Trigger.dev) have no Docker daemon at all.
6
+
7
+ ## Configuration
8
+
9
+ ```typescript
10
+ import { SandboxClient } from 'agent-neckbeard';
11
+
12
+ const sandbox = await SandboxClient.create({
13
+ provider: 'docker',
14
+ template: 'node:22-bookworm',
15
+ network: 'my-eval_default',
16
+ timeoutMs: 60 * 60 * 1000,
17
+ envs: { APP_SETTING: 'value' },
18
+ });
19
+ try {
20
+ const result = await sandbox.runCommand('curl -s http://crm:3000/health', {
21
+ cwd: '/root', timeoutMs: 30_000,
22
+ });
23
+ if (result.exitCode !== 0) throw new Error('Sandbox command failed');
24
+ } finally {
25
+ await sandbox.destroy();
26
+ }
27
+ ```
28
+
29
+ All settings except `provider` are optional:
30
+
31
+ | Setting | Default | Meaning |
32
+ | --- | --- | --- |
33
+ | `template` | `node:22-bookworm` | Debian-compatible image. `Agent` requires Node.js and npm in it |
34
+ | `network` | Docker default bridge | Existing Docker network to join, such as a compose project network, so the agent can reach sibling services by name |
35
+ | `platform` | Daemon native | Image platform such as `linux/amd64` |
36
+ | `timeoutMs` | `3600000` | Fixed container lifetime in multiples of `1000` milliseconds, up to `86400000` (24 hours). The container exits and removes itself afterwards |
37
+ | `cpu` | Unlimited | Positive finite `--cpus` limit |
38
+ | `memoryMiB` | Unlimited | Positive integer `--memory` limit |
39
+
40
+ Use the same settings in an Agent. Switching an existing agent between a cloud provider and Docker is a change to `sandbox` only:
41
+
42
+ ```typescript
43
+ const agent = new Agent({
44
+ sandbox: { provider: 'docker', network: 'my-eval_default' },
45
+ // sourceFile, inputSchema, session, dependencies, localDirectories, etc.
46
+ });
47
+ ```
48
+
49
+ Commands run as root with `/root` as home and working directory; runtime files live in `/root/agent`. Images that lack Bash, Python 3, util-linux (`flock`/`setsid`), coreutils, or curl get them installed with `apt-get` on create and connect; images that already have them, including the default, skip that step and need no network. Because commands already run as root, an image without `sudo` gets a pass-through `/usr/local/bin/sudo` shim that drops leading flags and executes the rest. Containers this provider creates also get an `/etc/pip.conf` with `break-system-packages = true` unless the image ships its own, so `sudo pip install` setup commands written for cloud sandbox images work on PEP 668 Debian images; attached containers are not modified this way. Claude Agent SDK consumers using `bypassPermissions` under root need the same explicit `IS_SANDBOX: '1'` opt-in described in [the Modal guide](MODAL.md#claude-permissions-under-root).
50
+
51
+ ### Platform and native packages
52
+
53
+ On Apple Silicon the default container is `linux/arm64`, while Neckbeard filters CPU-restricted external packages for `x64` unless told otherwise. If your agent has native externals, either set `NECKBEARD_SANDBOX_ARCH=arm64` on the host or run the container with `platform: 'linux/amd64'`.
54
+
55
+ ## Attaching to an existing container
56
+
57
+ `SandboxClient.connect` accepts a container ID or name (kept verbatim as the handle `id`, so `Agent.run(..., { sandboxId })` and `createSession({ sandboxId })` accept names and short IDs too), including containers this provider did not create, such as a service an eval harness or compose file already started:
58
+
59
+ ```typescript
60
+ const sandbox = await SandboxClient.connect({ provider: 'docker', sandboxId: 'my-eval-main-1' });
61
+ ```
62
+
63
+ Containers created by this provider carry the label `agent-neckbeard.managed=true`. **`destroy()` and `Agent.kill()` remove only labeled containers.** For any other container they are a no-op: the container and its host tunnel are left in place for its owner and for other handles in the process. An attached container must be running, Debian-compatible, and able to run commands as root.
64
+
65
+ `Agent.deploy()` always creates its own container; deploying an agent into a container owned by another tool is not supported yet. `Agent.run(..., { sandboxId })` and `createSession({ sandboxId })` reconnect to a container that an earlier `deploy()` prepared. To put a deployed agent next to compose services, pass the compose network as `network` instead.
66
+
67
+ ## HTTP access
68
+
69
+ No ports are published. For each container port the host opens one loopback listener on `127.0.0.1` with an ephemeral port and relays every connection through `docker exec` and a small Python pump to `127.0.0.1:<port>` inside the container. Ports are not published with `-p` because published ports are fixed at creation and could serve neither an attached container nor a session port chosen later. This works identically for created and attached containers, on any Docker network, with remote daemons (`DOCKER_HOST`), and for non-default session ports. Listeners are shared per process and unreferenced so they never keep the host alive. `destroy()` closes them together with a container this provider created; listeners for an attached container stay open for other handles in the process.
70
+
71
+ There is no traffic token: the listener is reachable by other processes of the same host, and the runtime server itself performs no authentication. That is consistent with this provider's local trust model and is another reason not to run it on shared hosts.
72
+
73
+ ## Environment and secrets
74
+
75
+ Sandbox-level `envs` are written to `/root/.neckbeard-env` inside the container (via stdin) and sourced by every command. Commands, their working directory, and per-command `envs` also travel over stdin. Consequently secrets never appear in host process arguments or in `docker inspect`, values may contain newlines and quotes, and command length is not bounded by argv limits. Anyone with access to the Docker daemon can still read the file from the container.
76
+
77
+ ## Commands and lifecycle
78
+
79
+ - Foreground commands execute through Bash, stream stdout and stderr through callbacks as chunks arrive, and return nonzero exit codes as results rather than failures.
80
+ - A command timeout rejects with remote completion unknown, as on Modal. Additionally the in-container command is wrapped in `timeout` two seconds beyond the host deadline, so an abandoned command does not keep running.
81
+ - Detached commands use the shared `DetachedProcessController` with the `docker-process-v2:` ownership prefix. Prepare/release fencing, stable `launchId` adoption, process-tree stop confirmation, bounded logs, and artifact disposal are unchanged. Containers start with `--init` so exited process trees are reaped.
82
+ - Containers are started with `--rm` and a fixed lifetime, so a host that crashes before cleanup leaks a container for at most `timeoutMs`. `destroy()` tolerates an already-removed container.
83
+ - `setTimeout()` is unsupported: choose the lifetime at creation.
84
+ - Unknown options are rejected rather than dropped, including `apiKey`, published ports, volumes, privileged mode, and Daytona network policies.
85
+ - The durable Pi supervisor target remains Daytona-specific.
86
+
87
+ ## Tests
88
+
89
+ ```bash
90
+ npm test -- tests/unit/docker.test.ts
91
+ npm run test:e2e:docker
92
+ ```
93
+
94
+ Unit tests inject the CLI transport and need no daemon. The live suite skips unless `docker info` succeeds and covers deploy/run with setup commands, forwarded envs and local-directory uploads, reconnect by container ID, and sequential attached-session prompts. Override the image with `NECKBEARD_DOCKER_TEMPLATE`. A skipped live suite is not evidence of a successful live run.
package/docs/MODAL.md ADDED
@@ -0,0 +1,163 @@
1
+ # Modal Provider
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.
4
+
5
+ ## Configuration
6
+
7
+ Set `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET` in the host environment. The SDK also supports its standard active `~/.modal.toml` profile. Never forward these provider credentials in sandbox `envs`.
8
+
9
+ ```typescript
10
+ import { SandboxClient } from 'agent-neckbeard';
11
+
12
+ const sandbox = await SandboxClient.create({
13
+ provider: 'modal',
14
+ appName: 'agent-neckbeard',
15
+ template: 'node:22-bookworm',
16
+ timeoutMs: 60 * 60 * 1000,
17
+ cpu: 2,
18
+ memoryMiB: 2048,
19
+ envs: { APP_SETTING: 'value' },
20
+ });
21
+ try {
22
+ await sandbox.writeFile('/root/input.txt', 'hello');
23
+ const result = await sandbox.runCommand('cat input.txt', {
24
+ cwd: '/root', timeoutMs: 30_000,
25
+ });
26
+ if (result.exitCode !== 0) throw new Error('Sandbox command failed');
27
+ } finally {
28
+ await sandbox.destroy();
29
+ }
30
+ ```
31
+
32
+ All settings except `provider` are optional:
33
+
34
+ | Setting | Default | Meaning |
35
+ | --- | --- | --- |
36
+ | `appName` | `agent-neckbeard` | Modal App name, created if missing |
37
+ | `template` | `node:22-bookworm` | Public Debian-compatible container registry image, not an E2B template, Daytona snapshot, or Modal image ID |
38
+ | `environment` | SDK profile/environment default | Modal environment used for resource lookup |
39
+ | `timeoutMs` | `3600000` | Fixed sandbox lifetime, multiples of `1000` milliseconds from `1000` through `86400000` (24 hours); e.g. `1001` is rejected before SDK I/O |
40
+ | `cpu` | Modal default | Positive finite CPU reservation, fractional values accepted |
41
+ | `memoryMiB` | Modal default | Positive integer memory reservation |
42
+
43
+ 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`. Home and work directories are `/root`; runtime files live in `/root/agent`. The first image build can add latency; Modal caches image layers.
44
+
45
+ Use the same sandbox settings in an Agent:
46
+
47
+ ```typescript
48
+ const agent = new Agent({
49
+ sandbox: { provider: 'modal', appName: 'my-agents', timeoutMs: 3_600_000 },
50
+ // sourceFile, inputSchema, outputSchema, run, etc.
51
+ });
52
+ ```
53
+
54
+ `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.
55
+
56
+ Reconnect from a different host using only the persisted sandbox ID and credentials for the same workspace:
57
+
58
+ ```typescript
59
+ const sandbox = await SandboxClient.connect({
60
+ provider: 'modal',
61
+ sandboxId: persistedSandboxId,
62
+ // environment, tokenId, tokenSecret are optional.
63
+ });
64
+ ```
65
+
66
+ 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.
67
+
68
+ ## Claude Permissions Under Root
69
+
70
+ 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.
71
+
72
+ ```typescript
73
+ import { fileURLToPath } from 'node:url';
74
+ import { Agent } from 'agent-neckbeard';
75
+ import { query } from '@anthropic-ai/claude-agent-sdk';
76
+ import { z } from 'zod';
77
+
78
+ export const claudeAgent = new Agent({
79
+ sourceFile: fileURLToPath(import.meta.url),
80
+ sandbox: { provider: 'modal', timeoutMs: 600_000 },
81
+ envs: {
82
+ ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY,
83
+ IS_SANDBOX: '1', // Consumer opt-in for Claude's root-user check.
84
+ },
85
+ inputSchema: z.object({ prompt: z.string() }),
86
+ outputSchema: z.object({ result: z.string() }),
87
+ run: async ({ prompt }) => {
88
+ for await (const message of query({
89
+ prompt,
90
+ options: {
91
+ permissionMode: 'bypassPermissions',
92
+ allowDangerouslySkipPermissions: true,
93
+ maxTurns: 3,
94
+ },
95
+ })) {
96
+ if (message.type === 'result' && message.subtype === 'success') {
97
+ return { result: message.result };
98
+ }
99
+ }
100
+ throw new Error('Claude did not return a successful result');
101
+ },
102
+ });
103
+ ```
104
+
105
+ 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`.
106
+
107
+ 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.
108
+
109
+ Package tests verify explicit environment forwarding into the managed runtime/payload (and absence from provider defaults), including on live Modal. They do not invoke Claude or establish compatibility for every Claude SDK/CLI version and workload; those model-provider acceptance tests remain consumer-owned.
110
+
111
+ ## HTTP Security
112
+
113
+ No encrypted or unencrypted public tunnels are created. The adapter obtains a port-scoped Modal Sandbox Connect Token and uses its HTTPS URL. Both `/health` and `/invoke` send `Authorization: Bearer <token>`. Missing or invalid endpoint credentials fail closed; tokens are not appended to URLs. A fresh runtime connection mints fresh endpoint credentials, so consumers persist sandbox IDs rather than HTTP tokens. Do not log SDK credentials, endpoint tokens, or raw diagnostic output.
114
+
115
+ ## Commands and Durability
116
+
117
+ - Text and binary file APIs use Modal's filesystem API. Byte views retain their offsets and lengths.
118
+ - Foreground commands execute through Bash, forward absolute cwd/environment, drain stdout and stderr concurrently, invoke callbacks as chunks arrive, and return nonzero exit codes without treating them as transport failures.
119
+ - Command timeouts bound host waiting, including SDK sandbox lookup. The remote exec timeout is rounded up to whole seconds. A host timeout or transport failure throws and means remote completion is unknown, not that the process has been confirmed stopped. An SDK lookup that resolves after the host timeout cannot start a new command.
120
+ - Sandbox objects are operation-scoped and detached on success or failure. SDK 0.10 `ModalClient.close()` does not close the control-plane gRPC channel, so clients are reused in a bounded cache instead of creating/leaking one channel per operation. Up to 16 distinct credential/configuration keys are retained per loaded module instance, including failed construction entries; further configurations are rejected before construction. Keys hash a copy of explicit constructor settings and sorted host `MODAL_*` settings. Lazy SDK loading, configuration capture, cache lookup, and SDK construction happen synchronously before yielding to another caller: token credentials, selected profile, endpoint, environment, image-builder settings, and throttle settings cannot be captured under one key but constructed from a later caller's environment. The SDK is loaded through its CJS entrypoint because SDK 0.10 has no constructor overrides for every ambient profile setting. Concurrent operations share the same client promise; created/reconnected handles retain that selected client for subsequent operations, even if host environment variables later change. The SDK reads its profile file at SDK module load, not per client, so restart the worker after editing a profile file or changing its path. There is no eviction: evicting/closing would still retain the SDK channel. Use separate workers for more than 16 configurations or restart after repeated credential rotation. Closing the host does not terminate remote payloads; sandbox lifetime remains bounded by its fixed creation timeout.
121
+ - 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.
122
+ - 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.
123
+ - 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.
124
+ - `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.
125
+
126
+ ## Unsupported Options
127
+
128
+ Modal config uses a strict allowlist. Unknown options are rejected rather than silently dropped, including `apiKey`, `allowPublicTraffic` (even `false`), public tunnel ports, `requestTimeoutMs`, Daytona network policies, auto-stop/auto-delete settings, idle timeout, GPUs, volumes, private registry credentials, custom working directories, snapshots, and experimental SDK features. Network policy passthrough is not part of this adapter. Modal's default outbound network policy applies.
129
+
130
+ `setTimeout()` is unsupported: choose the lifetime at creation. Foreground command options support only `cwd`, `envs`, `timeoutMs`, `onStdout`, and `onStderr`; do not pass a provider-native `background` option. Use `startDetachedCommand()` instead.
131
+
132
+ The separate public durable Pi supervisor target remains Daytona-specific. This provider adds generic managed detached commands and HTTP/SSE agents; it does not add a Modal supervisor target or promise memory persistence after termination/snapshot restore.
133
+
134
+ ## Next.js and Live Tests
135
+
136
+ 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.
137
+
138
+ ```bash
139
+ npm test -- --runInBand tests/unit/modal.test.ts tests/unit/modal-resources.test.ts tests/unit/modal-config.test.ts
140
+ npm run test:e2e:modal
141
+ npm run check
142
+ ```
143
+
144
+ The live suite skips unless both `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET` are present (dotenv is loaded). Optional overrides: `NECKBEARD_MODAL_APP_NAME`, `NECKBEARD_MODAL_TEMPLATE`, and `NECKBEARD_E2E_TIMEOUT_MS`. Allow extra time for the first image build. Tests create billable sandboxes with ten-minute lifetimes and explicit cleanup. The App and cached image layers are retained.
145
+
146
+ Live coverage includes deploy/run/setup/local-directory uploads, reconnect, sequential attached prompts, binary file round trips, streaming command output and nonzero exits, managed launch from a host process that exits naturally, reattachment/stop/log/disposal, rejection of unauthenticated HTTP, authenticated private HTTP, and termination. Missing credentials are a skip, not evidence of a successful live acceptance run. Downstream Tupelo acceptance tests remain consumer-owned.
147
+
148
+ Resource regressions inspect the real gRPC channelz registry, not a mocked `close()` call. The unit test uses real ModalClient/Sandbox/gRPC construction with only remote operations stubbed, verifies stable channel counts after repeated/concurrent/failed reconnect-destroy cycles, and checks the 16-configuration cap. The live suite also checks that ten reconnect/file/command cycles retain no additional channels after warmup.
149
+
150
+ The real-SDK configuration regression interleaves two callers without an intervening await, verifies their complete actual SDK profiles (including empty-environment fallbacks and explicit overrides), revisits the original cache entry, and verifies that already-returned handles keep their original client after host environment changes.
151
+
152
+ ## Vendor References
153
+
154
+ Reviewed against current docs and `modal@0.10.0` on 2026-09-08:
155
+
156
+ - [JavaScript SDK](https://modal.com/docs/sdk/js)
157
+ - [ModalClient](https://modal.com/docs/sdk/js/latest/ModalClient)
158
+ - [Sandbox and filesystem APIs](https://modal.com/docs/sdk/js/latest/Sandbox)
159
+ - [ContainerProcess](https://modal.com/docs/sdk/js/latest/ContainerProcess)
160
+ - [Image](https://modal.com/docs/sdk/js/latest/Image)
161
+ - [Sandbox networking and Connect Tokens](https://modal.com/docs/guide/sandbox-networking)
162
+ - [Next.js serverExternalPackages](https://nextjs.org/docs/app/api-reference/config/next-config-js/serverExternalPackages)
163
+ - [Claude Agent SDK permissions](https://platform.claude.com/docs/en/agent-sdk/permissions)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-neckbeard",
3
- "version": "1.1.20",
4
- "description": "Deploy AI agents to E2B and Daytona sandboxes",
3
+ "version": "1.1.22",
4
+ "description": "Deploy AI agents to E2B, Daytona, and Modal sandboxes, or local Docker containers",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
@@ -32,7 +32,9 @@
32
32
  "files": [
33
33
  "dist",
34
34
  "CHANGELOG.md",
35
- "docs/SUPERVISOR.md"
35
+ "docs/SUPERVISOR.md",
36
+ "docs/MODAL.md",
37
+ "docs/DOCKER.md"
36
38
  ],
37
39
  "engines": {
38
40
  "node": ">=20.18.1 <21 || >=22"
@@ -52,6 +54,8 @@
52
54
  "test:e2e": "npm run build && node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config jest.e2e.config.mjs --runInBand",
53
55
  "test:e2e:e2b": "npm run build && node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config jest.e2e.config.mjs --runInBand --testNamePattern=\"live E2B smoke tests\"",
54
56
  "test:e2e:daytona": "npm run build && node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config jest.e2e.config.mjs --runInBand --testNamePattern=\"live Daytona smoke tests\"",
57
+ "test:e2e:modal": "npm run build && node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config jest.e2e.config.mjs --runInBand --testNamePattern=\"live Modal smoke tests\"",
58
+ "test:e2e:docker": "npm run build && node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config jest.e2e.config.mjs --runInBand --testNamePattern=\"live Docker smoke tests\"",
55
59
  "test:compat:next": "npm run build && node scripts/run-next-compat-test.mjs",
56
60
  "test:cjs": "npm run build && node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config jest.build.config.mjs",
57
61
  "typecheck": "tsc --noEmit -p tsconfig.test.json",
@@ -60,7 +64,8 @@
60
64
  "dependencies": {
61
65
  "@daytona/sdk": "^0.204.1",
62
66
  "e2b": "^2.39.0",
63
- "esbuild": "^0.28.2"
67
+ "esbuild": "^0.28.2",
68
+ "modal": "^0.10.0"
64
69
  },
65
70
  "peerDependencies": {
66
71
  "zod": "^3.0.0 || ^4.0.0"
@@ -71,6 +76,7 @@
71
76
  }
72
77
  },
73
78
  "devDependencies": {
79
+ "@grpc/grpc-js": "^1.14.4",
74
80
  "@types/jest": "^30.0.0",
75
81
  "@types/node": "^22.0.0",
76
82
  "dotenv": "^17.3.1",