Skip to content

Commit 44b387e

Browse files
authored
Merge branch 'main' into add-api-ref-to-nav
2 parents 48ab662 + 257bdda commit 44b387e

26 files changed

+770
-79
lines changed

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node 24.11.0

docs.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
"docs/agents/amp",
5757
"docs/agents/claude-code",
5858
"docs/agents/codex",
59+
{
60+
"group": "OpenClaw",
61+
"icon": "https://mintlify.s3.us-west-1.amazonaws.com/e2b-openclaw-icon/images/icons/openclaw.svg",
62+
"pages": [
63+
"docs/agents/openclaw/openclaw-gateway",
64+
"docs/agents/openclaw/openclaw-telegram"
65+
]
66+
},
5967
"docs/agents/opencode"
6068
]
6169
},
@@ -99,6 +107,7 @@
99107
"docs/sandbox/lifecycle-events-api",
100108
"docs/sandbox/lifecycle-events-webhooks",
101109
"docs/sandbox/persistence",
110+
"docs/sandbox/snapshots",
102111
"docs/sandbox/git-integration",
103112
"docs/sandbox/metrics",
104113
"docs/sandbox/metadata",

docs.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Quickstart } from '/snippets/Quickstart.jsx';
1010

1111
E2B provides isolated sandboxes that let agents safely execute code, process data, and run tools. Our SDKs make it easy to start and manage these environments.
1212

13-
Spin up a sandbox and run code in a few lines:
13+
Start a sandbox and run code in a few lines:
1414

1515
<CodeGroup>
1616
```bash JavaScript & TypeScript
@@ -50,7 +50,7 @@ A quick overview of the core building blocks you'll interact with when using E2B
5050

5151
The documentation is split into three main sections:
5252

53-
- [**Quickstart**](#quickstart) — Step-by-step tutorials that walk you through spinning up your first E2B sandboxes.
53+
- [**Quickstart**](#quickstart) — Step-by-step tutorials that walk you through creating your first E2B sandboxes.
5454

5555
- [**Examples**](#examples) — In-depth tutorials focused on specific use cases. Pick the topics that match what you're building.
5656

docs/agents/amp.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
---
2-
title: "AMP"
3-
description: "Run AMP in a secure E2B sandbox with full filesystem, terminal, and git access."
2+
title: "Amp"
3+
description: "Run Amp in a secure E2B sandbox with full filesystem, terminal, and git access."
44
icon: "/images/icons/amp.svg"
55
---
66

7-
[AMP](https://ampcode.com) is Sourcegraph's coding agent with multi-model architecture and built-in code intelligence. E2B provides a pre-built `amp` template with AMP already installed.
7+
[Amp](https://ampcode.com) is a coding agent with multi-model architecture and built-in code intelligence. E2B provides a pre-built `amp` template with Amp already installed.
88

99
## CLI
1010

11-
Spin up a sandbox with the [E2B CLI](/docs/cli).
11+
Create a sandbox with the [E2B CLI](/docs/cli).
1212

1313
```bash
1414
e2b sbx create amp
1515
```
1616

17-
Once inside the sandbox, start AMP.
17+
Once inside the sandbox, start Amp.
1818

1919
```bash
2020
amp
2121
```
2222

2323
## Run headless
2424

25-
Use `-x` for non-interactive mode and `--dangerously-allow-all` to auto-approve all tool calls (safe inside E2B sandboxes). AMP uses its own API key from [ampcode.com/settings](https://ampcode.com/settings).
25+
Use `-x` for non-interactive mode and `--dangerously-allow-all` to auto-approve all tool calls (safe inside E2B sandboxes). Amp uses its own API key from [ampcode.com/settings](https://ampcode.com/settings).
2626

2727
<CodeGroup>
2828
```typescript JavaScript & TypeScript
@@ -172,7 +172,7 @@ sandbox.kill()
172172

173173
## Thread management
174174

175-
AMP persists conversations as threads that can be resumed or continued with follow-up tasks.
175+
Amp persists conversations as threads that can be resumed or continued with follow-up tasks.
176176

177177
<CodeGroup>
178178
```typescript JavaScript & TypeScript

docs/agents/claude-code.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ icon: "/images/icons/claude-code.svg"
88

99
## CLI
1010

11-
Spin up a sandbox with the [E2B CLI](/docs/cli).
11+
Create a sandbox with the [E2B CLI](/docs/cli).
1212

1313
```bash
1414
e2b sbx create claude

docs/agents/codex.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ icon: "/images/icons/codex.svg"
88

99
## CLI
1010

11-
Spin up a sandbox with the [E2B CLI](/docs/cli).
11+
Create a sandbox with the [E2B CLI](/docs/cli).
1212

1313
```bash
1414
e2b sbx create codex

docs/agents/openclaw.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
title: "OpenClaw"
33
description: "Run OpenClaw in a secure E2B sandbox with full filesystem, terminal, and git access."
4-
icon: "/images/icons/openclaw.svg"
4+
icon: "/images/icons/openclaw-v2.svg"
55
---
66

77
[OpenClaw](https://openclaw.ai) is an open-source personal AI assistant that supports multiple LLM providers and messaging channels. E2B provides a pre-built `openclaw` template with OpenClaw already installed.
88

99
## CLI
1010

11-
Spin up a sandbox with the [E2B CLI](/docs/cli).
11+
Create a sandbox with the [E2B CLI](/docs/cli).
1212

1313
```bash
1414
e2b sbx create openclaw
Lines changed: 277 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
---
2+
title: "Deploy OpenClaw"
3+
description: "Start the OpenClaw gateway in an E2B sandbox and connect your browser."
4+
icon: "globe"
5+
---
6+
7+
## Quick start
8+
9+
This launches your OpenClaw [gateway](https://docs.openclaw.ai/gateway) site (web UI for chatting with agents).
10+
11+
<CodeGroup>
12+
```typescript JavaScript & TypeScript
13+
import { Sandbox } from 'e2b'
14+
15+
const TOKEN = process.env.OPENCLAW_APP_TOKEN || 'my-gateway-token'
16+
const PORT = 18789
17+
18+
// 1. Create sandbox
19+
const sandbox = await Sandbox.create('openclaw', {
20+
envs: { OPENAI_API_KEY: process.env.OPENAI_API_KEY },
21+
timeoutMs: 3600_000,
22+
})
23+
24+
// 2. Set the default model
25+
await sandbox.commands.run('openclaw config set agents.defaults.model.primary openai/gpt-5.2')
26+
27+
// 3. Set insecure control UI flags and start the gateway with token auth
28+
await sandbox.commands.run(
29+
`bash -lc 'openclaw config set gateway.controlUi.allowInsecureAuth true && ` +
30+
`openclaw config set gateway.controlUi.dangerouslyDisableDeviceAuth true && ` +
31+
`openclaw gateway --allow-unconfigured --bind lan --auth token --token ${TOKEN} --port ${PORT}'`,
32+
{ background: true }
33+
)
34+
35+
// 4. Wait for the gateway to start listening
36+
for (let i = 0; i < 45; i++) {
37+
const probe = await sandbox.commands.run(
38+
`bash -lc 'ss -ltn | grep -q ":${PORT} " && echo ready || echo waiting'`
39+
)
40+
if (probe.stdout.trim() === 'ready') break
41+
await new Promise((r) => setTimeout(r, 1000))
42+
}
43+
44+
const url = `https://${sandbox.getHost(PORT)}/?token=${TOKEN}`
45+
console.log(`Gateway: ${url}`)
46+
```
47+
```python Python
48+
import os, time
49+
from e2b import Sandbox
50+
51+
TOKEN = os.environ.get("OPENCLAW_APP_TOKEN", "my-gateway-token")
52+
PORT = 18789
53+
54+
# 1. Create sandbox
55+
sandbox = Sandbox.create("openclaw", envs={
56+
"OPENAI_API_KEY": os.environ["OPENAI_API_KEY"],
57+
}, timeout=3600)
58+
59+
# 2. Set the default model
60+
sandbox.commands.run("openclaw config set agents.defaults.model.primary openai/gpt-5.2")
61+
62+
# 3. Set insecure control UI flags and start the gateway with token auth
63+
sandbox.commands.run(
64+
f"bash -lc 'openclaw config set gateway.controlUi.allowInsecureAuth true && "
65+
f"openclaw config set gateway.controlUi.dangerouslyDisableDeviceAuth true && "
66+
f"openclaw gateway --allow-unconfigured --bind lan --auth token --token {TOKEN} --port {PORT}'",
67+
background=True,
68+
)
69+
70+
# 4. Wait for the gateway to start listening
71+
for _ in range(45):
72+
probe = sandbox.commands.run(
73+
f'bash -lc \'ss -ltn | grep -q ":{PORT} " && echo ready || echo waiting\''
74+
)
75+
if probe.stdout.strip() == "ready":
76+
break
77+
time.sleep(1)
78+
79+
url = f"https://{sandbox.get_host(PORT)}/?token={TOKEN}"
80+
print(f"Gateway: {url}")
81+
```
82+
</CodeGroup>
83+
84+
Visit the printed `Gateway` URL in your browser.
85+
86+
If you run in secure mode (set `gateway.controlUi.dangerouslyDisableDeviceAuth false`), run this after opening the URL to poll pending pairing requests and approve the first one.
87+
88+
<CodeGroup>
89+
```typescript JavaScript & TypeScript
90+
// 5. Poll for the browser's pending device request and approve it
91+
for (let i = 0; i < 30; i++) {
92+
try {
93+
const res = await sandbox.commands.run(
94+
`openclaw devices list --json --url ws://127.0.0.1:${PORT} --token ${TOKEN}`
95+
)
96+
const data = JSON.parse(res.stdout)
97+
if (data.pending?.length) {
98+
const rid = data.pending[0].requestId
99+
await sandbox.commands.run(
100+
`openclaw devices approve ${rid} --token ${TOKEN} --url ws://127.0.0.1:${PORT}`
101+
)
102+
console.log(`Device approved: ${rid}`)
103+
break
104+
}
105+
} catch {}
106+
await new Promise((r) => setTimeout(r, 2000))
107+
}
108+
```
109+
```python Python
110+
import json
111+
112+
# 5. Poll for the browser's pending device request and approve it
113+
for _ in range(30):
114+
try:
115+
res = sandbox.commands.run(
116+
f"openclaw devices list --json --url ws://127.0.0.1:{PORT} --token {TOKEN}"
117+
)
118+
data = json.loads(res.stdout)
119+
if data.get("pending"):
120+
rid = data["pending"][0]["requestId"]
121+
sandbox.commands.run(
122+
f"openclaw devices approve {rid} --token {TOKEN} --url ws://127.0.0.1:{PORT}"
123+
)
124+
print(f"Device approved: {rid}")
125+
break
126+
except Exception:
127+
pass
128+
time.sleep(2)
129+
```
130+
</CodeGroup>
131+
132+
Once approved, the browser connects and the gateway UI loads.
133+
134+
## How it works
135+
136+
| Step | What happens |
137+
|------|-------------|
138+
| `--bind lan` | Gateway listens on `0.0.0.0` so E2B can proxy it |
139+
| `--auth token` | Requires `?token=` on the URL for HTTP and WebSocket auth |
140+
| Browser opens URL | Gateway serves the UI, browser opens a WebSocket |
141+
| `code=1008 pairing required` | Gateway closes the WebSocket until the device is approved (secure mode only) |
142+
| `devices approve` | Approves the browser's device fingerprint (secure mode only) |
143+
| Browser reconnects | WebSocket connects successfully, UI is live |
144+
145+
## Gateway flags reference
146+
147+
| Flag | Purpose |
148+
|------|---------|
149+
| `--allow-unconfigured` | Start without a full config file |
150+
| `--bind lan` | Bind to `0.0.0.0` (required for E2B port proxying) |
151+
| `--auth token` | Enable token-based authentication |
152+
| `--token <value>` | The auth token (passed as `?token=` in the URL) |
153+
| `--port <number>` | Gateway listen port (default: `18789`) |
154+
155+
## How to restart the gateway
156+
157+
Use this when the gateway is already running and you want a clean restart (for example, after changing model or env settings).
158+
159+
<Info>
160+
We can't use the `openclaw gateway restart` command here. Some SDK environments cannot target a specific Unix user in `commands.run`. The commands below use the default command user context.
161+
</Info>
162+
163+
<CodeGroup>
164+
```typescript JavaScript & TypeScript
165+
const TOKEN = process.env.OPENCLAW_APP_TOKEN || 'my-gateway-token'
166+
const PORT = 18789
167+
168+
// 1) Kill existing gateway processes if present
169+
await sandbox.commands.run(
170+
`bash -lc 'for p in "[o]penclaw gateway" "[o]penclaw-gateway"; do for pid in $(pgrep -f "$p" || true); do kill "$pid" >/dev/null 2>&1 || true; done; done'`
171+
)
172+
await new Promise((r) => setTimeout(r, 1000))
173+
174+
// 2) Start gateway again
175+
await sandbox.commands.run(
176+
`openclaw gateway --allow-unconfigured --bind lan --auth token --token ${TOKEN} --port ${PORT}`,
177+
{ background: true }
178+
)
179+
180+
// 3) Wait for listening socket
181+
for (let i = 0; i < 45; i++) {
182+
const probe = await sandbox.commands.run(
183+
`bash -lc 'ss -ltn | grep -q ":${PORT} " && echo ready || echo waiting'`
184+
)
185+
if (probe.stdout.trim() === 'ready') break
186+
await new Promise((r) => setTimeout(r, 1000))
187+
}
188+
```
189+
```python Python
190+
import os, time
191+
192+
TOKEN = os.environ.get("OPENCLAW_APP_TOKEN", "my-gateway-token")
193+
PORT = 18789
194+
195+
# 1) Kill existing gateway processes if present
196+
sandbox.commands.run(
197+
"""bash -lc 'for p in "[o]penclaw gateway" "[o]penclaw-gateway"; do
198+
for pid in $(pgrep -f "$p" || true); do
199+
kill "$pid" >/dev/null 2>&1 || true
200+
done
201+
done'"""
202+
)
203+
time.sleep(1)
204+
205+
# 2) Start gateway again
206+
sandbox.commands.run(
207+
f"openclaw gateway --allow-unconfigured --bind lan --auth token --token {TOKEN} --port {PORT}",
208+
background=True,
209+
)
210+
211+
# 3) Wait for listening socket
212+
for _ in range(45):
213+
probe = sandbox.commands.run(
214+
f'bash -lc \'ss -ltn | grep -q ":{PORT} " && echo ready || echo waiting\''
215+
)
216+
if probe.stdout.strip() == "ready":
217+
break
218+
time.sleep(1)
219+
```
220+
</CodeGroup>
221+
222+
## Turn insecure flags off (recommended after testing)
223+
224+
Use this to restore secure device authentication after initial testing.
225+
226+
<CodeGroup>
227+
```typescript JavaScript & TypeScript
228+
const TOKEN = process.env.OPENCLAW_APP_TOKEN || 'my-gateway-token'
229+
const PORT = 18789
230+
231+
await sandbox.commands.run(
232+
`bash -lc 'openclaw config set gateway.controlUi.allowInsecureAuth false && ` +
233+
`openclaw config set gateway.controlUi.dangerouslyDisableDeviceAuth false'`
234+
)
235+
236+
await sandbox.commands.run(
237+
`bash -lc 'for p in "[o]penclaw gateway" "[o]penclaw-gateway"; do for pid in $(pgrep -f "$p" || true); do kill "$pid" >/dev/null 2>&1 || true; done; done'`
238+
)
239+
240+
await sandbox.commands.run(
241+
`openclaw gateway --allow-unconfigured --bind lan --auth token --token ${TOKEN} --port ${PORT}`,
242+
{ background: true }
243+
)
244+
```
245+
```python Python
246+
import os
247+
248+
TOKEN = os.environ.get("OPENCLAW_APP_TOKEN", "my-gateway-token")
249+
PORT = 18789
250+
251+
sandbox.commands.run(
252+
"bash -lc 'openclaw config set gateway.controlUi.allowInsecureAuth false && "
253+
"openclaw config set gateway.controlUi.dangerouslyDisableDeviceAuth false'"
254+
)
255+
256+
sandbox.commands.run(
257+
"""bash -lc 'for p in "[o]penclaw gateway" "[o]penclaw-gateway"; do
258+
for pid in $(pgrep -f "$p" || true); do
259+
kill "$pid" >/dev/null 2>&1 || true
260+
done
261+
done'"""
262+
)
263+
264+
sandbox.commands.run(
265+
f"openclaw gateway --allow-unconfigured --bind lan --auth token --token {TOKEN} --port {PORT}",
266+
background=True,
267+
)
268+
```
269+
</CodeGroup>
270+
271+
## Related
272+
273+
<CardGroup cols={1}>
274+
<Card title="OpenClaw Telegram" icon="message-circle" href="/docs/agents/openclaw/openclaw-telegram">
275+
Connect OpenClaw to Telegram and approve pairing
276+
</Card>
277+
</CardGroup>

0 commit comments

Comments
 (0)