@cloudflare/sandbox 0.13.0-next.681.1 → 0.13.0-next.709.1
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/Dockerfile +6 -6
- package/README.md +49 -3
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/index.js +1364 -1072
- package/dist/bridge/index.js.map +1 -1
- package/dist/{contexts-DY1LHU1v.d.ts → contexts-1EsLHByO.d.ts} +156 -20
- package/dist/contexts-1EsLHByO.d.ts.map +1 -0
- package/dist/{dist-BStBkGIC.js → dist-Duor5GbS.js} +7 -56
- package/dist/dist-Duor5GbS.js.map +1 -0
- package/dist/errors/index.d.ts +4 -4
- package/dist/errors/index.js +3 -3
- package/dist/{errors-k3B8orjH.js → errors-CXR0xBpw.js} +42 -10
- package/dist/errors-CXR0xBpw.js.map +1 -0
- package/dist/{errors-ewgSNicb.js → errors-QYlSkVGz.js} +402 -250
- package/dist/errors-QYlSkVGz.js.map +1 -0
- package/dist/extensions/index.d.ts +4 -2
- package/dist/extensions/index.js +5 -3
- package/dist/extensions-CFB2xHqY.js +1023 -0
- package/dist/extensions-CFB2xHqY.js.map +1 -0
- package/dist/filesystem-BWAZCZER.d.ts +732 -0
- package/dist/filesystem-BWAZCZER.d.ts.map +1 -0
- package/dist/git/index.d.ts +8 -19
- package/dist/git/index.d.ts.map +1 -1
- package/dist/git/index.js +16 -23
- package/dist/git/index.js.map +1 -1
- package/dist/index-Bs4bqXDR.d.ts +438 -0
- package/dist/index-Bs4bqXDR.d.ts.map +1 -0
- package/dist/{index-Dy6u9r60.d.ts → index-HNYBk-az.d.ts} +233 -179
- package/dist/index-HNYBk-az.d.ts.map +1 -0
- package/dist/index.d.ts +480 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/interpreter/index.d.ts +3 -1
- package/dist/interpreter/index.d.ts.map +1 -1
- package/dist/interpreter/index.js +46 -18
- package/dist/interpreter/index.js.map +1 -1
- package/dist/openai/index.d.ts +5 -5
- package/dist/openai/index.d.ts.map +1 -1
- package/dist/openai/index.js +11 -6
- package/dist/openai/index.js.map +1 -1
- package/dist/opencode/index.d.ts +7 -11
- package/dist/opencode/index.d.ts.map +1 -1
- package/dist/opencode/index.js +56 -85
- package/dist/opencode/index.js.map +1 -1
- package/dist/process-types-GStiZ8f8.d.ts +73 -0
- package/dist/process-types-GStiZ8f8.d.ts.map +1 -0
- package/dist/{sandbox-boKWPIcd.js → sandbox-Auuwfnur.js} +4152 -3359
- package/dist/sandbox-Auuwfnur.js.map +1 -0
- package/dist/sandbox-BbAabq93.d.ts +42 -0
- package/dist/sandbox-BbAabq93.d.ts.map +1 -0
- package/dist/xterm/index.d.ts +5 -1
- package/dist/xterm/index.d.ts.map +1 -1
- package/dist/xterm/index.js +55 -12
- package/dist/xterm/index.js.map +1 -1
- package/package.json +3 -2
- package/dist/codes-y-U76vnQ.d.ts +0 -79
- package/dist/codes-y-U76vnQ.d.ts.map +0 -1
- package/dist/contexts-DY1LHU1v.d.ts.map +0 -1
- package/dist/dist-BStBkGIC.js.map +0 -1
- package/dist/errors-ewgSNicb.js.map +0 -1
- package/dist/errors-k3B8orjH.js.map +0 -1
- package/dist/extensions-CepYdzro.js +0 -191
- package/dist/extensions-CepYdzro.js.map +0 -1
- package/dist/index-B7QgIs0N.d.ts +0 -1841
- package/dist/index-B7QgIs0N.d.ts.map +0 -1
- package/dist/index-Dy6u9r60.d.ts.map +0 -1
- package/dist/sandbox-DHNO89IF.d.ts +0 -828
- package/dist/sandbox-DHNO89IF.d.ts.map +0 -1
- package/dist/sandbox-boKWPIcd.js.map +0 -1
package/Dockerfile
CHANGED
|
@@ -161,7 +161,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
|
161
161
|
rm -rf /var/cache/apt/* /var/lib/apt/lists/* && \
|
|
162
162
|
apt-get update && apt-get install -y --no-install-recommends \
|
|
163
163
|
s3fs fuse3 squashfs-tools squashfuse fuse-overlayfs \
|
|
164
|
-
ca-certificates curl wget procps git unzip zip jq file \
|
|
164
|
+
ca-certificates curl wget procps git unzip zip jq file tini \
|
|
165
165
|
inotify-tools \
|
|
166
166
|
libssl3 zlib1g libbz2-1.0 libreadline8 libsqlite3-0 \
|
|
167
167
|
libncursesw6 libtinfo6 libxml2 libxmlsec1 libffi8 liblzma5 libtk8.6 && \
|
|
@@ -222,7 +222,7 @@ ENV PYTHON_POOL_MIN_SIZE=0
|
|
|
222
222
|
ENV JAVASCRIPT_POOL_MIN_SIZE=3
|
|
223
223
|
ENV TYPESCRIPT_POOL_MIN_SIZE=3
|
|
224
224
|
|
|
225
|
-
ENTRYPOINT ["/container-server/sandbox"]
|
|
225
|
+
ENTRYPOINT ["/usr/bin/tini", "--", "/container-server/sandbox"]
|
|
226
226
|
|
|
227
227
|
# ============================================================================
|
|
228
228
|
# Stage 5b: Python image - full, with Python + data science packages
|
|
@@ -253,7 +253,7 @@ ENV PYTHON_POOL_MIN_SIZE=3
|
|
|
253
253
|
ENV JAVASCRIPT_POOL_MIN_SIZE=3
|
|
254
254
|
ENV TYPESCRIPT_POOL_MIN_SIZE=3
|
|
255
255
|
|
|
256
|
-
ENTRYPOINT ["/container-server/sandbox"]
|
|
256
|
+
ENTRYPOINT ["/usr/bin/tini", "--", "/container-server/sandbox"]
|
|
257
257
|
|
|
258
258
|
# ============================================================================
|
|
259
259
|
# Stage 5c: OpenCode image - with OpenCode CLI for AI coding agent
|
|
@@ -278,7 +278,7 @@ ENV TYPESCRIPT_POOL_MIN_SIZE=3
|
|
|
278
278
|
# Expose OpenCode server port (in addition to 3000 from runtime-base)
|
|
279
279
|
EXPOSE 4096
|
|
280
280
|
|
|
281
|
-
ENTRYPOINT ["/container-server/sandbox"]
|
|
281
|
+
ENTRYPOINT ["/usr/bin/tini", "--", "/container-server/sandbox"]
|
|
282
282
|
|
|
283
283
|
# ============================================================================
|
|
284
284
|
# Stage 5d: Musl image - Alpine-based with musl-linked binary
|
|
@@ -301,7 +301,7 @@ RUN --mount=type=secret,id=wrangler_ca \
|
|
|
301
301
|
apk add --no-cache ca-certificates; \
|
|
302
302
|
fi
|
|
303
303
|
|
|
304
|
-
RUN apk add --no-cache bash file git curl libstdc++ libgcc s3fs-fuse fuse
|
|
304
|
+
RUN apk add --no-cache bash file git curl libstdc++ libgcc s3fs-fuse fuse tini
|
|
305
305
|
|
|
306
306
|
RUN sed -i 's/#user_allow_other/user_allow_other/' /etc/fuse.conf
|
|
307
307
|
|
|
@@ -324,4 +324,4 @@ ENV PYTHON_POOL_MIN_SIZE=0
|
|
|
324
324
|
ENV JAVASCRIPT_POOL_MIN_SIZE=0
|
|
325
325
|
ENV TYPESCRIPT_POOL_MIN_SIZE=0
|
|
326
326
|
|
|
327
|
-
ENTRYPOINT ["/container-server/sandbox"]
|
|
327
|
+
ENTRYPOINT ["/sbin/tini", "--", "/container-server/sandbox"]
|
package/README.md
CHANGED
|
@@ -82,8 +82,12 @@ export default {
|
|
|
82
82
|
|
|
83
83
|
// Execute Python code
|
|
84
84
|
if (url.pathname === '/run') {
|
|
85
|
-
const
|
|
86
|
-
|
|
85
|
+
const process = await sandbox.exec(['python3', '-c', 'print(2 + 2)']);
|
|
86
|
+
const output = await process.output({ encoding: 'utf8' });
|
|
87
|
+
return Response.json({
|
|
88
|
+
output: output.stdout,
|
|
89
|
+
success: output.exitCode === 0
|
|
90
|
+
});
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
// Work with files
|
|
@@ -98,6 +102,48 @@ export default {
|
|
|
98
102
|
};
|
|
99
103
|
```
|
|
100
104
|
|
|
105
|
+
## Process Execution
|
|
106
|
+
|
|
107
|
+
A Sandbox is the long-running computer. `exec()` launches one supervised argv process and returns after the runtime confirms launch; it does not run through a hidden persistent shell.
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
const process = await sandbox.exec(['python3', '-c', 'print(2 + 2)']);
|
|
111
|
+
const output = await process.output({ encoding: 'utf8' });
|
|
112
|
+
|
|
113
|
+
console.log(process.id, process.pid, output.stdout, output.exitCode);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`await sandbox.exec(argv)` waits only for launch; `process.pid` is available once it resolves. `await process.output()` and `await process.waitForExit()` wait for completion. `process.status()` observes the current state, and `process.logs()` streams replayable cursor events incrementally.
|
|
117
|
+
|
|
118
|
+
`output()` is replayable but may return `truncated: true`; use `logs({ since, replay, follow })` for cursor resume and output too large to buffer. `exec(argv, { timeout })` sets a remote process lifetime deadline: the supervisor may terminate and then kill the process internally, and completion is reported with `timedOut: true`. Timeouts and `AbortSignal`s on `logs()`, `output()`, `waitForExit()`, `waitForLog()`, and `waitForPort()` cancel only that local observation—they do not stop the process. Call `process.kill(signal)` with a numeric signal (default `15`) to request termination.
|
|
119
|
+
|
|
120
|
+
Use explicit shell argv when you need shell syntax:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
const proc = await sandbox.exec(['/bin/bash', '-lc', 'cd app && npm test'], {
|
|
124
|
+
cwd: '/workspace',
|
|
125
|
+
env: { CI: '1' }
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
For asynchronous work, keep `proc.id` and recover the live process from a later Worker request:
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
const server = await sandbox.exec([
|
|
133
|
+
'/bin/bash',
|
|
134
|
+
'-lc',
|
|
135
|
+
'npm run dev -- --host 0.0.0.0'
|
|
136
|
+
]);
|
|
137
|
+
await server.waitForPort(3000);
|
|
138
|
+
|
|
139
|
+
const recovered = await sandbox.getProcess(server.id);
|
|
140
|
+
const running = await sandbox.listProcesses();
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`getProcess()` and `listProcesses()` are non-waking discovery calls: with no active runtime they return `null` and `[]` instead of starting a replacement. Handles, IDs, PIDs, statuses, retained logs, and cursors belong to the runtime that launched the process. After sleep, restart, or replacement, discovery cannot recover them and operations on an old handle fail with `STALE_PROCESS_HANDLE` rather than targeting a replacement runtime.
|
|
144
|
+
|
|
145
|
+
Use `createTerminal()` for a persistent interactive PTY shell with input, resize, interrupt, terminate, and reconnect semantics. Terminals remain separate from supervised processes and are also runtime-local.
|
|
146
|
+
|
|
101
147
|
## Quick tunnels
|
|
102
148
|
|
|
103
149
|
`sandbox.tunnels.get(port)` exposes a service running inside the
|
|
@@ -154,7 +200,7 @@ Notes:
|
|
|
154
200
|
- **Edge-Native** - Runs on Cloudflare's global network
|
|
155
201
|
- **Code Interpreter** - Execute Python and JavaScript with rich outputs
|
|
156
202
|
- **File System Access** - Read, write, and manage files
|
|
157
|
-
- **Command Execution** - Run
|
|
203
|
+
- **Command Execution** - Run any command with streaming support
|
|
158
204
|
- **Preview URLs** - Expose services with public URLs
|
|
159
205
|
- **Quick tunnels** - Zero-config `*.trycloudflare.com` URLs via `sandbox.tunnels.get(port)`
|
|
160
206
|
- **Git Integration** - Clone repositories directly
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/bridge/types.ts","../../src/bridge/helpers.ts","../../src/bridge/warm-pool.ts","../../src/bridge/index.ts"],"sourcesContent":[],"mappings":";;;;;;;AA6DgB,UAvCC,YAAA,CAuCD;EAEP;;;AAaT;;;;ICJgB,OAAA,CAAA,EAAU,MAAA;IAyBV;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/bridge/types.ts","../../src/bridge/helpers.ts","../../src/bridge/warm-pool.ts","../../src/bridge/index.ts"],"sourcesContent":[],"mappings":";;;;;;;AA6DgB,UAvCC,YAAA,CAuCD;EAEP;;;AAaT;;;;ICJgB,OAAA,CAAA,EAAU,MAAA;IAyBV;;;;AChFhB;AAOA;AAWC;AA6CD;EAA4C,cAAA,CAAA,EAAA,MAAA;EA2BH;;;;;EAiFf,WAAA,CAAA,EAAA,MAAA;;;;;;;;UFtIT,cAAA;EGgCD,KAAA,EAAA,OAAM,EH9BT,OG8BS,EAAA,GAAA,EAAA,GAAA,EAAA,G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