@cloudflare/sandbox 0.13.0-next.651.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 +12 -17
- package/README.md +48 -2
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/index.js +1365 -1054
- package/dist/bridge/index.js.map +1 -1
- package/dist/{contexts-BS0Bs6IU.d.ts → contexts-1EsLHByO.d.ts} +240 -15
- package/dist/contexts-1EsLHByO.d.ts.map +1 -0
- package/dist/{dist-DF8sudAg.js → dist-Duor5GbS.js} +38 -147
- package/dist/dist-Duor5GbS.js.map +1 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.js +4 -0
- package/dist/{errors-BG6NZiPD.js → errors-CXR0xBpw.js} +82 -13
- package/dist/errors-CXR0xBpw.js.map +1 -0
- package/dist/errors-QYlSkVGz.js +893 -0
- package/dist/errors-QYlSkVGz.js.map +1 -0
- package/dist/extensions/index.d.ts +4 -74
- package/dist/extensions/index.js +5 -152
- 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 +63 -0
- package/dist/git/index.d.ts.map +1 -0
- package/dist/git/index.js +338 -0
- package/dist/git/index.js.map +1 -0
- package/dist/index-Bs4bqXDR.d.ts +438 -0
- package/dist/index-Bs4bqXDR.d.ts.map +1 -0
- package/dist/index-HNYBk-az.d.ts +444 -0
- package/dist/index-HNYBk-az.d.ts.map +1 -0
- package/dist/index.d.ts +487 -181
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -43
- package/dist/index.js.map +1 -1
- package/dist/interpreter/index.d.ts +311 -0
- package/dist/interpreter/index.d.ts.map +1 -0
- package/dist/interpreter/index.js +292 -0
- package/dist/interpreter/index.js.map +1 -0
- package/dist/openai/index.d.ts +5 -4
- 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 +133 -161
- package/dist/opencode/index.d.ts.map +1 -1
- package/dist/opencode/index.js +284 -203
- 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-Auuwfnur.js +10010 -0
- 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 +11 -7
- package/dist/xterm/index.d.ts.map +1 -1
- package/dist/xterm/index.js +61 -18
- package/dist/xterm/index.js.map +1 -1
- package/package.json +28 -4
- package/dist/contexts-BS0Bs6IU.d.ts.map +0 -1
- package/dist/dist-DF8sudAg.js.map +0 -1
- package/dist/errors-BG6NZiPD.js.map +0 -1
- package/dist/extensions/index.d.ts.map +0 -1
- package/dist/extensions/index.js.map +0 -1
- package/dist/rpc-types-PBUY-xXM.d.ts +0 -1679
- package/dist/rpc-types-PBUY-xXM.d.ts.map +0 -1
- package/dist/sandbox-BgwMBQ7S.js +0 -8273
- package/dist/sandbox-BgwMBQ7S.js.map +0 -1
- package/dist/sandbox-D_MMqExx.d.ts +0 -1077
- package/dist/sandbox-D_MMqExx.d.ts.map +0 -1
package/Dockerfile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Bun version — override via --build-arg BUN_VERSION=$(cat .bun-version)
|
|
2
|
-
ARG BUN_VERSION=1
|
|
2
|
+
ARG BUN_VERSION=1.3.14
|
|
3
3
|
# Node version — override via --build-arg NODE_VERSION=24
|
|
4
4
|
ARG NODE_VERSION=24
|
|
5
5
|
# cloudflared release — shared across glibc and musl image variants.
|
|
@@ -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 && \
|
|
@@ -186,12 +186,9 @@ COPY --from=bun-binary /usr/local/bin/bun /usr/local/bin/bun
|
|
|
186
186
|
# Copy standalone binary
|
|
187
187
|
COPY --from=builder /app/packages/sandbox-container/dist/sandbox /container-server/sandbox
|
|
188
188
|
|
|
189
|
-
# Set up container server directory
|
|
189
|
+
# Set up container server directory
|
|
190
190
|
WORKDIR /container-server
|
|
191
191
|
|
|
192
|
-
# Copy bundled JavaScript executor (runs on Node or Bun for code interpreter)
|
|
193
|
-
COPY --from=builder /app/packages/sandbox-container/dist/runtime/executors/javascript/node_executor.js ./dist/runtime/executors/javascript/
|
|
194
|
-
|
|
195
192
|
# Copy legacy JS bundle for backwards compatibility
|
|
196
193
|
# Users with custom startup scripts that call `bun /container-server/dist/index.js` need this
|
|
197
194
|
COPY --from=builder /app/packages/sandbox-container/dist/index.js ./dist/
|
|
@@ -225,7 +222,7 @@ ENV PYTHON_POOL_MIN_SIZE=0
|
|
|
225
222
|
ENV JAVASCRIPT_POOL_MIN_SIZE=3
|
|
226
223
|
ENV TYPESCRIPT_POOL_MIN_SIZE=3
|
|
227
224
|
|
|
228
|
-
ENTRYPOINT ["/container-server/sandbox"]
|
|
225
|
+
ENTRYPOINT ["/usr/bin/tini", "--", "/container-server/sandbox"]
|
|
229
226
|
|
|
230
227
|
# ============================================================================
|
|
231
228
|
# Stage 5b: Python image - full, with Python + data science packages
|
|
@@ -245,19 +242,18 @@ RUN ln -s /usr/local/python/bin/python3.11 /usr/local/bin/python3.11 && \
|
|
|
245
242
|
# Set Python 3.11 as default python3
|
|
246
243
|
RUN update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.11 1
|
|
247
244
|
|
|
248
|
-
# Install Python packages for data science and code interpreter
|
|
245
|
+
# Install Python packages for data science and the code interpreter extension.
|
|
246
|
+
# The interpreter runtime itself is provisioned by the @cloudflare/sandbox/interpreter
|
|
247
|
+
# extension; this image only provides the Python toolchain it relies on.
|
|
249
248
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
250
249
|
pip3 install --no-cache-dir matplotlib numpy pandas ipython
|
|
251
250
|
|
|
252
|
-
#
|
|
253
|
-
COPY --from=builder /app/packages/sandbox-container/src/runtime/executors/python/ipython_executor.py ./dist/runtime/executors/python/
|
|
254
|
-
|
|
255
|
-
# Enable all interpreter pools
|
|
251
|
+
# Pre-warm pool sizes consumed by the interpreter extension sidecar
|
|
256
252
|
ENV PYTHON_POOL_MIN_SIZE=3
|
|
257
253
|
ENV JAVASCRIPT_POOL_MIN_SIZE=3
|
|
258
254
|
ENV TYPESCRIPT_POOL_MIN_SIZE=3
|
|
259
255
|
|
|
260
|
-
ENTRYPOINT ["/container-server/sandbox"]
|
|
256
|
+
ENTRYPOINT ["/usr/bin/tini", "--", "/container-server/sandbox"]
|
|
261
257
|
|
|
262
258
|
# ============================================================================
|
|
263
259
|
# Stage 5c: OpenCode image - with OpenCode CLI for AI coding agent
|
|
@@ -282,7 +278,7 @@ ENV TYPESCRIPT_POOL_MIN_SIZE=3
|
|
|
282
278
|
# Expose OpenCode server port (in addition to 3000 from runtime-base)
|
|
283
279
|
EXPOSE 4096
|
|
284
280
|
|
|
285
|
-
ENTRYPOINT ["/container-server/sandbox"]
|
|
281
|
+
ENTRYPOINT ["/usr/bin/tini", "--", "/container-server/sandbox"]
|
|
286
282
|
|
|
287
283
|
# ============================================================================
|
|
288
284
|
# Stage 5d: Musl image - Alpine-based with musl-linked binary
|
|
@@ -305,7 +301,7 @@ RUN --mount=type=secret,id=wrangler_ca \
|
|
|
305
301
|
apk add --no-cache ca-certificates; \
|
|
306
302
|
fi
|
|
307
303
|
|
|
308
|
-
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
|
|
309
305
|
|
|
310
306
|
RUN sed -i 's/#user_allow_other/user_allow_other/' /etc/fuse.conf
|
|
311
307
|
|
|
@@ -318,7 +314,6 @@ COPY --from=builder /app/packages/sandbox-container/dist/sandbox-musl /container
|
|
|
318
314
|
|
|
319
315
|
WORKDIR /container-server
|
|
320
316
|
|
|
321
|
-
COPY --from=builder /app/packages/sandbox-container/dist/runtime/executors/javascript/node_executor.js ./dist/runtime/executors/javascript/
|
|
322
317
|
COPY --from=builder /app/packages/sandbox-container/dist/index.js ./dist/
|
|
323
318
|
|
|
324
319
|
RUN mkdir -p /workspace
|
|
@@ -329,4 +324,4 @@ ENV PYTHON_POOL_MIN_SIZE=0
|
|
|
329
324
|
ENV JAVASCRIPT_POOL_MIN_SIZE=0
|
|
330
325
|
ENV TYPESCRIPT_POOL_MIN_SIZE=0
|
|
331
326
|
|
|
332
|
-
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
|
|
@@ -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,GAAA,EH5Bb,gBG4Ba,CAAA,EH3BjB,QG2BiB,GH3B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