Skip to content

Commit 3a5cb38

Browse files
feat(sandbox): add Daytona cloud sandbox backend plugin (#121554)
* feat: @openclaw/daytona-sandbox inital version Signed-off-by: Mislav Ivanda <[email protected]> * feat: plugin config params extended Signed-off-by: Mislav Ivanda <[email protected]> * feat: implement ClawSweeper review notes Signed-off-by: Mislav Ivanda <[email protected]> * fix(daytona): honor abort signals and clean up remote staging on failure Signed-off-by: Mislav Ivanda <[email protected]> * fix(daytona): register launcher as knip entry and refresh manifest schema Signed-off-by: Mislav Ivanda <[email protected]> * fix(daytona): cancellable session transport and auto-stopped sandbox restart Signed-off-by: Mislav Ivanda <[email protected]> * fix(daytona): deny egress by default and arm launcher cleanup before startup Signed-off-by: Mislav Ivanda <[email protected]> * fix(daytona): stop cancelled startup before submission * test(daytona): satisfy deferred race lint * test(release): update plugin publisher inventory * fix(daytona): close provisioning and PTY cleanup gaps * test(daytona): type PTY launcher mock * fix(acpx): avoid promise-returning line handler * fix(daytona): await PTY signal cleanup * fix(daytona): declare ClawHub install route * fix(daytona): forward PTY stdin EOF * fix(daytona): serialize PTY input * docs(daytona): document sandbox backend config --------- Signed-off-by: Mislav Ivanda <[email protected]> Co-authored-by: Patrick Erichsen <[email protected]>
1 parent 3255882 commit 3a5cb38

30 files changed

Lines changed: 4580 additions & 29 deletions

‎.github/labeler.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,11 @@
375375
- changed-files:
376376
- any-glob-to-any-file:
377377
- "extensions/copilot-proxy/**"
378+
"extensions: daytona":
379+
- changed-files:
380+
- any-glob-to-any-file:
381+
- "extensions/daytona/**"
382+
- "docs/gateway/daytona.md"
378383
"extensions: diagnostics-otel":
379384
- changed-files:
380385
- any-glob-to-any-file:

‎config/knip.config.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,10 @@ const config = {
725725
"harness.ts!",
726726
"media-understanding-provider.ts!",
727727
]),
728+
[`${BUNDLED_PLUGIN_ROOT_DIR}/daytona`]: bundledPluginWorkspace([
729+
// Copied to dist and spawned by the Daytona backend for sandbox execs.
730+
"src/daytona-exec-launcher.mjs!",
731+
]),
728732
[`${BUNDLED_PLUGIN_ROOT_DIR}/deepgram`]: bundledPluginWorkspace(),
729733
[`${BUNDLED_PLUGIN_ROOT_DIR}/deepinfra`]: bundledPluginWorkspace(),
730734
[`${BUNDLED_PLUGIN_ROOT_DIR}/discord`]: bundledPluginWorkspace(),

‎docs/docs.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,7 @@
17141714
"gateway/security/rate-limiting",
17151715
"gateway/operator-scopes",
17161716
"gateway/sandboxing",
1717+
"gateway/daytona",
17171718
"gateway/openshell",
17181719
"gateway/sandbox-vs-tool-policy-vs-elevated",
17191720
"gateway/permission-modes"

‎docs/gateway/config-agents.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ Optional sandboxing for the embedded agent. See [Sandboxing](/gateway/sandboxing
772772
defaults: {
773773
sandbox: {
774774
mode: "non-main", // off (default) | non-main | all
775-
backend: "docker", // docker (default) | podman | openshell | ssh
775+
backend: "docker", // docker (default) | daytona | openshell | podman | ssh
776776
scope: "agent", // session | agent (default) | shared
777777
workspaceAccess: "none", // none (default) | ro | rw
778778
workspaceRoot: "~/.openclaw/sandboxes",
@@ -866,12 +866,16 @@ Defaults shown above (`off`/`docker`/`agent`/`none`/`bookworm-slim` image/`none`
866866

867867
**Backend:**
868868

869+
- `daytona`: Daytona-managed cloud runtime
869870
- `docker`: local Docker runtime (default)
870-
- `ssh`: generic SSH-backed remote runtime
871871
- `openshell`: OpenShell-managed local or remote runtime
872+
- `podman`: local Podman runtime using Docker-compatible settings
873+
- `ssh`: generic SSH-backed remote runtime
874+
875+
Plugin-managed backends keep runtime-specific settings under their plugin entries:
872876

873-
When `backend: "openshell"` is selected, runtime-specific settings move to
874-
`plugins.entries.openshell.config`.
877+
- Daytona: `plugins.entries.daytona.config`; see [Daytona](/gateway/daytona)
878+
- OpenShell: `plugins.entries.openshell.config`; see [OpenShell](/gateway/openshell)
875879

876880
**SSH backend config:**
877881

‎docs/gateway/daytona.md‎

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
---
2+
summary: "Use Daytona cloud sandboxes as a sandbox backend for OpenClaw agents"
3+
title: Daytona
4+
read_when:
5+
- You want cloud sandboxes instead of local Docker
6+
- You are setting up the Daytona plugin
7+
- You need agent tool execution isolated from the Gateway host
8+
---
9+
10+
Daytona is a cloud sandbox backend: instead of running Docker containers
11+
locally, OpenClaw creates [Daytona](https://www.daytona.io) sandboxes through
12+
the Daytona API and executes commands and file operations over the Daytona
13+
toolbox API (HTTPS). No SSH keys or inbound connectivity are required.
14+
15+
The plugin reuses the same remote filesystem bridge as the generic
16+
[SSH backend](/gateway/sandboxing#ssh-backend) with a remote-canonical
17+
workspace model: the sandbox workspace is seeded once at creation and stays
18+
canonical until you recreate it.
19+
20+
## Prerequisites
21+
22+
- Daytona plugin installed (`openclaw plugins install @openclaw/daytona-sandbox`)
23+
- A Daytona API key (`https://app.daytona.io/dashboard/keys`)
24+
- OpenClaw Gateway running on the host
25+
26+
## Quick start
27+
28+
```bash
29+
openclaw plugins install @openclaw/daytona-sandbox
30+
```
31+
32+
```json5
33+
{
34+
agents: {
35+
defaults: {
36+
sandbox: {
37+
mode: "all",
38+
backend: "daytona",
39+
scope: "session",
40+
workspaceAccess: "rw",
41+
},
42+
},
43+
},
44+
plugins: {
45+
entries: {
46+
daytona: {
47+
enabled: true,
48+
config: {
49+
apiKey: { source: "env", provider: "default", id: "DAYTONA_API_KEY" },
50+
},
51+
},
52+
},
53+
},
54+
}
55+
```
56+
57+
Export `DAYTONA_API_KEY` in the Gateway environment (or store the key with a
58+
SecretRef as above, or as a plaintext string). Restart the Gateway. On the
59+
next agent turn OpenClaw creates a Daytona sandbox and routes tool execution
60+
through it. Verify with:
61+
62+
```bash
63+
openclaw sandbox list
64+
openclaw sandbox explain
65+
```
66+
67+
New sandboxes block all network egress by default, matching the Docker
68+
backend's no-network stance. If your agents need to install packages or reach
69+
the network from inside the sandbox, opt in explicitly with
70+
`networkBlockAll: false`, or grant selective egress with `networkAllowList`
71+
or `domainAllowList`.
72+
73+
## How execution works
74+
75+
- **Sandbox per scope**: one Daytona sandbox per sandbox scope (`agent`,
76+
`session`, or `shared`). Sandboxes are labeled `openclaw.sandbox=1` and
77+
adopted across Gateway restarts through the OpenClaw sandbox registry.
78+
- **Exec**: each `exec` call runs inside the sandbox through a Daytona session
79+
(or a Daytona PTY when the tool requests a TTY). Exit codes, stdout, stderr,
80+
stdin, and terminal resizes all flow through the toolbox API.
81+
- **Files**: `read`, `write`, `edit`, `apply_patch`, and media reads go through
82+
the sandbox filesystem bridge, so file tools operate on the remote workspace
83+
with the same path and writability rules as the SSH backend.
84+
- **Auto-stop**: Daytona stops idle sandboxes automatically (default 15
85+
minutes). OpenClaw restarts a stopped sandbox on the next use, so idle
86+
sandboxes cost nothing while state stays warm.
87+
88+
## Workspace model
89+
90+
The session workspace is uploaded once when the sandbox is created
91+
(remote-canonical, like the SSH backend). Host-local edits made after the seed
92+
are not visible remotely until you recreate the sandbox:
93+
94+
```bash
95+
openclaw sandbox recreate --session <sessionKey>
96+
```
97+
98+
This deletes the Daytona sandbox; the next agent turn provisions a fresh one
99+
and seeds it from the current local workspace.
100+
101+
## Configuration reference
102+
103+
All settings live under `plugins.entries.daytona.config`:
104+
105+
| Key | Type | Default | Description |
106+
| ------------------------- | ----------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
107+
| `apiKey` | string, SecretRef | unset | Daytona API key. Falls back to the `DAYTONA_API_KEY` environment variable. |
108+
| `apiUrl` | string | Daytona cloud | Daytona API base URL. Falls back to `DAYTONA_API_URL`. |
109+
| `target` | string | Daytona default | Target region for new sandboxes. Falls back to `DAYTONA_TARGET`. |
110+
| `snapshot` | string | Daytona default snapshot | Snapshot for new sandboxes. The image needs `sh`, `tar`, `base64`, `stat`, and `python3` on `PATH`. Mutually exclusive with `image`. |
111+
| `image` | string | unset | Docker image for new sandboxes, pulled or built by Daytona on first create. Mutually exclusive with `snapshot`. |
112+
| `resources` | object | unset | `{ cpu, gpu, memory, disk }` for image-based sandboxes (memory and disk in GiB). Omitted fields use the Daytona defaults (1 vCPU, 1 GB, 3 GiB). Snapshot sandboxes size from the snapshot. |
113+
| `user` | string | snapshot default | OS user for the sandbox. Align the remote workspace dirs with that user's writable paths. |
114+
| `volumes` | array | unset | Daytona volumes to mount, as `{ volumeId, mountPath }` entries. Reachable from `exec`; outside the file-tool workspace mounts. |
115+
| `autoStopInterval` | integer (minutes) | `15` (Daytona default) | Minutes of inactivity before Daytona stops the sandbox. `0` keeps it running continuously. |
116+
| `autoPauseInterval` | integer (minutes) | disabled | Minutes of inactivity before Daytona pauses the sandbox (VM-based runners; pause preserves memory state). At most one of auto-stop and auto-pause may be non-zero. |
117+
| `autoArchiveInterval` | integer (minutes) | `7` days (Daytona) | Minutes a stopped sandbox waits before archiving to cold storage. `0` uses the Daytona maximum. |
118+
| `autoDeleteInterval` | integer (minutes) | disabled | Minutes a sandbox may stay stopped before Daytona deletes it. `0` deletes immediately on stop. |
119+
| `networkBlockAll` | boolean | `true` (egress blocked) | Block all sandbox network egress, matching the Docker backend's no-network default. Set `false` for open egress; configuring an allow list implies selective egress. |
120+
| `networkAllowList` | string | unset | Comma-separated CIDR addresses the sandbox may reach. Setting this (with `networkBlockAll` unset) enables selective egress. |
121+
| `domainAllowList` | string | unset | Comma-separated domains the sandbox may reach. Setting this (with `networkBlockAll` unset) enables selective egress. |
122+
| `remoteWorkspaceDir` | string | `/home/daytona/workspace` | Absolute path of the session workspace inside the sandbox. |
123+
| `remoteAgentWorkspaceDir` | string | `/home/daytona/agent` | Absolute path mirroring the real agent workspace when `workspaceAccess` is not `none`. |
124+
| `timeoutSeconds` | number | `120` | Timeout for Daytona API operations (create, upload, filesystem commands). Image-based creates automatically get a higher floor to cover image pulls; raise this when declarative builds need longer. |
125+
126+
## Lifecycle management
127+
128+
```bash
129+
# List all sandbox runtimes (Docker + Daytona)
130+
openclaw sandbox list
131+
132+
# Inspect effective policy
133+
openclaw sandbox explain
134+
135+
# Recreate (deletes the Daytona sandbox, re-seeds on next use)
136+
openclaw sandbox recreate --session <sessionKey>
137+
```
138+
139+
Idle pruning (`agents.defaults.sandbox.prune`) treats Daytona runtimes the same
140+
as Docker runtimes: pruned entries delete the Daytona sandbox.
141+
142+
## Cost controls
143+
144+
- `autoStopInterval` (default 15 minutes) stops idle sandboxes; stopped
145+
sandboxes restart automatically on next use. `autoPauseInterval` pauses
146+
instead, on sandbox classes that support pausing.
147+
- `autoArchiveInterval` moves long-stopped sandboxes to cold storage;
148+
`autoDeleteInterval` deletes sandboxes that stay stopped, if you prefer
149+
Daytona-side cleanup in addition to OpenClaw pruning.
150+
- OpenClaw prune (`sandbox.prune.idleHours` / `maxAgeDays`) deletes registered
151+
sandboxes from the OpenClaw side.
152+
153+
## Current limitations
154+
155+
- Browser sandboxing is not supported on this backend.
156+
- `sandbox.docker.*` settings (image, binds, network) do not apply; use
157+
`snapshot`/`image` and the network allow-list options instead.
158+
`sandbox.docker.binds` is rejected; Daytona `volumes` cover shared storage.
159+
- Volume mount paths are reachable from `exec` commands only; the file tools
160+
stay inside the managed workspace mounts.
161+
- The workspace is seeded once (remote-canonical); there is no mirror mode.
162+
- Exec stdin is line-oriented text (Daytona session input); binary stdin
163+
streams are not preserved byte-for-byte in non-PTY execs.
164+
165+
## Related
166+
167+
- [Sandboxing overview](/gateway/sandboxing)
168+
- [Multi-Agent Sandbox & Tools](/tools/multi-agent-sandbox-tools)
169+
- [Sandbox vs Tool Policy vs Elevated](/gateway/sandbox-vs-tool-policy-vs-elevated)

‎docs/gateway/sandboxing.md‎

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ Not sandboxed:
2626

2727
Three independent settings control sandbox behavior:
2828

29-
| Setting | Key | Values | Default |
30-
| ------- | --------------------------------- | -------------------------------------- | -------- |
31-
| Mode | `agents.defaults.sandbox.mode` | `off`, `non-main`, `all` | `off` |
32-
| Scope | `agents.defaults.sandbox.scope` | `agent`, `session`, `shared` | `agent` |
33-
| Backend | `agents.defaults.sandbox.backend` | `docker`, `podman`, `ssh`, `openshell` | `docker` |
29+
| Setting | Key | Values | Default |
30+
| ------- | --------------------------------- | ------------------------------------------------- | -------- |
31+
| Mode | `agents.defaults.sandbox.mode` | `off`, `non-main`, `all` | `off` |
32+
| Scope | `agents.defaults.sandbox.scope` | `agent`, `session`, `shared` | `agent` |
33+
| Backend | `agents.defaults.sandbox.backend` | `docker`, `podman`, `ssh`, `openshell`, `daytona` | `docker` |
3434

3535
**Mode** controls when sandboxing applies:
3636

@@ -62,7 +62,7 @@ Non-shared runtime identity also includes the resolved agent workspace path. Thi
6262

6363
The first use after upgrading from an older release creates non-shared runtimes and sandbox workspaces under the workspace-qualified identity. Existing non-shared runtimes are not adopted; this is an intentional one-time reset. They can age out through configured prune settings or be removed with `openclaw sandbox recreate`; the next use provisions the current identity.
6464

65-
**Backend** controls which runtime executes sandboxed tools. Docker and Podman share `agents.defaults.sandbox.docker`; SSH-specific config lives under `agents.defaults.sandbox.ssh`; OpenShell-specific config lives under `plugins.entries.openshell.config`.
65+
**Backend** controls which runtime executes sandboxed tools. Docker and Podman share `agents.defaults.sandbox.docker`; SSH-specific config lives under `agents.defaults.sandbox.ssh`; OpenShell-specific config lives under `plugins.entries.openshell.config`; Daytona-specific config lives under `plugins.entries.daytona.config`.
6666

6767
| | Docker or Podman backend | SSH | OpenShell |
6868
| ------------------- | ----------------------------------------- | ------------------------------ | --------------------------------------------------- |
@@ -283,6 +283,39 @@ Use `backend: "openshell"` to sandbox tools in an OpenShell-managed remote envir
283283

284284
For the full prerequisites, configuration reference, workspace-mode comparison, and lifecycle details, see [OpenShell](/gateway/openshell).
285285

286+
## Daytona backend
287+
288+
Use `backend: "daytona"` to sandbox tools in [Daytona](https://www.daytona.io) cloud sandboxes. OpenClaw creates one Daytona sandbox per sandbox scope through the Daytona API and runs exec and file tools over the Daytona toolbox API (HTTPS); no SSH keys or inbound connectivity are required. The workspace model is remote-canonical like the SSH backend: seeded once at creation, re-seeded by `openclaw sandbox recreate`.
289+
290+
```json5
291+
{
292+
agents: {
293+
defaults: {
294+
sandbox: {
295+
mode: "all",
296+
backend: "daytona",
297+
scope: "session",
298+
workspaceAccess: "rw",
299+
},
300+
},
301+
},
302+
plugins: {
303+
entries: {
304+
daytona: {
305+
enabled: true,
306+
config: {
307+
apiKey: { source: "env", provider: "default", id: "DAYTONA_API_KEY" },
308+
},
309+
},
310+
},
311+
},
312+
}
313+
```
314+
315+
New sandboxes block all network egress by default (matching the Docker no-network default); opt in with `networkBlockAll: false` or the allow-list options. Idle sandboxes auto-stop on the Daytona side (default 15 minutes) and restart on next use. Current limitations: sandbox browser is not supported, and `sandbox.docker.*` settings do not apply to this backend.
316+
317+
For the full prerequisites, configuration reference, cost controls, and lifecycle details, see [Daytona](/gateway/daytona).
318+
286319
## Workspace access
287320

288321
`agents.defaults.sandbox.workspaceAccess` controls what the sandbox can see:
@@ -593,6 +626,7 @@ Each agent can override sandbox + tools: `agents.entries.*.sandbox` and `agents.
593626
## Related
594627

595628
- [Multi-Agent Sandbox & Tools](/tools/multi-agent-sandbox-tools) -- per-agent overrides and precedence
629+
- [Daytona](/gateway/daytona) -- cloud sandbox backend setup, cost controls, and config reference
596630
- [OpenShell](/gateway/openshell) -- managed sandbox backend setup, workspace modes, and config reference
597631
- [Sandbox configuration](/gateway/config-agents#agentsdefaultssandbox)
598632
- [Sandbox vs Tool Policy vs Elevated](/gateway/sandbox-vs-tool-policy-vs-elevated) -- debugging "why is this blocked?"

‎docs/plugins/plugin-inventory.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Each entry lists the package, distribution route, and description.
174174

175175
## Official external packages
176176

177-
90 plugins
177+
91 plugins
178178

179179
- **[acpx](/plugins/reference/acpx)** (`@openclaw/acpx`) - npm; ClawHub. OpenClaw ACP runtime backend with plugin-owned session and transport management.
180180

@@ -210,6 +210,8 @@ Each entry lists the package, distribution route, and description.
210210

211211
- **[copilot](/plugins/reference/copilot)** (`@openclaw/copilot`) - npm; ClawHub: `clawhub:@openclaw/copilot`. Registers the GitHub Copilot agent runtime.
212212

213+
- **[daytona](/plugins/reference/daytona)** (`@openclaw/daytona-sandbox`) - npm; ClawHub. OpenClaw sandbox backend that runs agent exec and file tools inside Daytona cloud sandboxes over the Daytona toolbox API.
214+
213215
- **[deepinfra](/plugins/reference/deepinfra)** (`@openclaw/deepinfra-provider`) - npm; ClawHub: `clawhub:@openclaw/deepinfra-provider`. Adds DeepInfra model provider support to OpenClaw.
214216

215217
- **[deepseek](/plugins/reference/deepseek)** (`@openclaw/deepseek-provider`) - npm; ClawHub: `clawhub:@openclaw/deepseek-provider`. Adds DeepSeek model provider support to OpenClaw.

‎docs/plugins/reference/daytona.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
summary: "OpenClaw sandbox backend that runs agent exec and file tools inside Daytona cloud sandboxes over the Daytona toolbox API."
3+
read_when:
4+
- You are installing, configuring, or auditing the daytona plugin
5+
title: "Daytona plugin"
6+
---
7+
8+
# Daytona plugin
9+
10+
OpenClaw sandbox backend that runs agent exec and file tools inside Daytona cloud sandboxes over the Daytona toolbox API.
11+
12+
## Distribution
13+
14+
- Package: `@openclaw/daytona-sandbox`
15+
- Install route: npm; ClawHub
16+
17+
## Surface
18+
19+
plugin

0 commit comments

Comments
 (0)