Skip to content

Commit 74edd9e

Browse files
committed
refactor(self_hosted_sandboxes): use published SDK releases; fix worker API usage
Installs: - ant CLI from GitHub releases (v1.9.0 tarball) instead of pinned prerelease build URLs; drop the unzip step in the Dockerfiles. - Python / TypeScript SDKs from PyPI / npm (anthropic, @anthropic-ai/sdk ^0.97.0) instead of prerelease build URLs. - Drop the committed package-lock.json files (regenerated on install) and gitignore them. Layout: - Rename the per-platform demo dirs, dropping the redundant self_hosted_sandbox- prefix: cf, cf-worker, daytona, docker, modal, vercel; update all cross-references. API correctness (validated against the current SDK): - daytona webhook: use AsyncAnthropic with client.beta.environments.work.poller (the sync client has no poller). - Catch WebhookVerificationError from standardwebhooks (anthropic.WebhookVerificationError does not exist). - client.beta.sessions, not client.sessions; beta_agent_toolset_20260401, not default_tools; drop stale tool_dispatcher / toolDispatcher references. - Fix the toolRunner / BetaToolRunContext.toolUseBlock notes in the docs.
1 parent 3c26fa8 commit 74edd9e

43 files changed

Lines changed: 126 additions & 8339 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

managed_agents/self_hosted_sandboxes/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ per-session calls.
1818

1919
| Variant | Compute | Runner |
2020
|---|---|---|
21-
| [`self_hosted_sandbox-docker/`](self_hosted_sandbox-docker/) | Plain Docker on a host you control | `ant beta:worker run` in a per-session container |
22-
| [`self_hosted_sandbox-cf/`](self_hosted_sandbox-cf/) | Cloudflare Containers | `ant beta:worker run` in a per-session Cloudflare Container |
23-
| [`self_hosted_sandbox-cf-worker/`](self_hosted_sandbox-cf-worker/) | Cloudflare Workers (no container) | TS `SessionToolRunner` in a Durable Object with an in-isolate fake filesystem |
24-
| [`self_hosted_sandbox-modal/`](self_hosted_sandbox-modal/) | [Modal](https://modal.com) | Python `sandbox_runner.py` in a Modal Sandbox with a per-session Volume |
25-
| [`self_hosted_sandbox-daytona/`](self_hosted_sandbox-daytona/) | [Daytona](https://www.daytona.io/) | Same `sandbox_runner.py` uploaded to a Daytona sandbox |
26-
| [`self_hosted_sandbox-vercel/`](self_hosted_sandbox-vercel/) | Vercel Functions + Sandbox | Node `runner.mjs` in a Vercel Sandbox |
21+
| [`docker/`](docker/) | Plain Docker on a host you control | `ant beta:worker run` in a per-session container |
22+
| [`cf/`](cf/) | Cloudflare Containers | `ant beta:worker run` in a per-session Cloudflare Container |
23+
| [`cf-worker/`](cf-worker/) | Cloudflare Workers (no container) | TS `SessionToolRunner` in a Durable Object with an in-isolate fake filesystem |
24+
| [`modal/`](modal/) | [Modal](https://modal.com) | Python `sandbox_runner.py` in a Modal Sandbox with a per-session Volume |
25+
| [`daytona/`](daytona/) | [Daytona](https://www.daytona.io/) | Same `sandbox_runner.py` uploaded to a Daytona sandbox |
26+
| [`vercel/`](vercel/) | Vercel Functions + Sandbox | Node `runner.mjs` in a Vercel Sandbox |
2727

2828
## Getting started
2929

managed_agents/self_hosted_sandboxes/self_hosted_sandbox-cf-worker/.gitignore renamed to managed_agents/self_hosted_sandboxes/cf-worker/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules/
2+
package-lock.json
23
.wrangler/
34
dist/
45
.dev.vars

managed_agents/self_hosted_sandboxes/self_hosted_sandbox-cf-worker/.npmrc renamed to managed_agents/self_hosted_sandboxes/cf-worker/.npmrc

File renamed without changes.

managed_agents/self_hosted_sandboxes/self_hosted_sandbox-cf-worker/README.md renamed to managed_agents/self_hosted_sandboxes/cf-worker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Cloudflare demo — CMA Private Sandboxes (pure-Worker variant)
22

3-
Same webhook → drain-queue → per-session runner shape as `../self_hosted_sandbox-cf/`, but the runner is a **Durable Object running the TS `client.beta.sessions.events.toolRunner()`** (`src/runner.ts`) with an **in-isolate fake filesystem** (`src/tools.ts`) instead of a real container. `read`/`write`/`edit`/`glob`/`grep` operate on a `Map<string,string>` held in the DO; `bash` returns a not-available stub.
3+
Same webhook → drain-queue → per-session runner shape as `../cf/`, but the runner is a **Durable Object running the TS `client.beta.sessions.events.toolRunner()`** (`src/runner.ts`) with an **in-isolate fake filesystem** (`src/tools.ts`) instead of a real container. `read`/`write`/`edit`/`glob`/`grep` operate on a `Map<string,string>` held in the DO; `bash` returns a not-available stub.
44

55
Idle policy is the SDK default: the dispatcher exits 60s after `session.status_idle` with `stop_reason: end_turn`; any other event resets the clock.
66

managed_agents/self_hosted_sandboxes/self_hosted_sandbox-cf-worker/package.json renamed to managed_agents/self_hosted_sandboxes/cf-worker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"typecheck": "tsc --noEmit"
99
},
1010
"dependencies": {
11-
"@anthropic-ai/sdk": "https://app.stainless.com/pkg/s/anthropic-typescript/9d2ab62380ef11d23ff45d8dc581659723721b81/dist.tar.gz",
11+
"@anthropic-ai/sdk": "^0.97.0",
1212
"minimatch": "^9.0.5",
1313
"zod": "^4.0.0"
1414
},

managed_agents/self_hosted_sandboxes/self_hosted_sandbox-cf-worker/src/index.ts renamed to managed_agents/self_hosted_sandboxes/cf-worker/src/index.ts

File renamed without changes.

managed_agents/self_hosted_sandboxes/self_hosted_sandbox-cf-worker/src/runner.ts renamed to managed_agents/self_hosted_sandboxes/cf-worker/src/runner.ts

File renamed without changes.

managed_agents/self_hosted_sandboxes/self_hosted_sandbox-cf-worker/src/tools.ts renamed to managed_agents/self_hosted_sandboxes/cf-worker/src/tools.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
* In-isolate "fake sandbox" tools for the pure-Worker variant.
33
*
44
* Backed by a Map<string,string> held in the Durable Object — no real shell or
5-
* filesystem. Demonstrates passing custom tools to ToolDispatcher (same shape
6-
* as client.beta.messages.tool_runner accepts).
5+
* filesystem. Demonstrates passing custom tools to
6+
* client.beta.sessions.events.toolRunner (same shape as
7+
* client.beta.messages.toolRunner accepts).
78
*/
89
import { betaZodTool } from "@anthropic-ai/sdk/helpers/beta/zod";
910
import { z } from "zod";

managed_agents/self_hosted_sandboxes/self_hosted_sandbox-cf-worker/tsconfig.json renamed to managed_agents/self_hosted_sandboxes/cf-worker/tsconfig.json

File renamed without changes.

managed_agents/self_hosted_sandboxes/self_hosted_sandbox-cf-worker/wrangler.toml renamed to managed_agents/self_hosted_sandboxes/cf-worker/wrangler.toml

File renamed without changes.

0 commit comments

Comments
 (0)