@cloudflare/sandbox 0.13.0-next.769.1 → 0.13.0-next.788.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 +52 -11
- package/dist/bridge/index.js +24 -8
- package/dist/bridge/index.js.map +1 -1
- package/dist/{dist-Duor5GbS.js → dist-n_eniPAR.js} +8 -46
- package/dist/dist-n_eniPAR.js.map +1 -0
- package/dist/extensions/index.d.ts +2 -2
- package/dist/extensions/index.js +2 -2
- package/dist/{extensions-CFB2xHqY.js → extensions-Be5HnDGt.js} +2 -2
- package/dist/{extensions-CFB2xHqY.js.map → extensions-Be5HnDGt.js.map} +1 -1
- package/dist/{filesystem-BWAZCZER.d.ts → filesystem-Y5aF3nmJ.d.ts} +7 -3
- package/dist/filesystem-Y5aF3nmJ.d.ts.map +1 -0
- package/dist/git/index.d.ts +2 -2
- package/dist/git/index.js +2 -2
- package/dist/{index-Bs4bqXDR.d.ts → index-DfXx3uZL.d.ts} +2 -2
- package/dist/{index-Bs4bqXDR.d.ts.map → index-DfXx3uZL.d.ts.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/interpreter/index.d.ts +2 -2
- package/dist/interpreter/index.js +2 -2
- package/dist/openai/index.d.ts +2 -2
- package/dist/openai/index.d.ts.map +1 -1
- package/dist/openai/index.js +10 -34
- package/dist/openai/index.js.map +1 -1
- package/dist/opencode/index.d.ts +2 -2
- package/dist/opencode/index.js +2 -2
- package/dist/{sandbox-BbAabq93.d.ts → sandbox-CBkS3tGv.d.ts} +2 -2
- package/dist/{sandbox-BbAabq93.d.ts.map → sandbox-CBkS3tGv.d.ts.map} +1 -1
- package/dist/{sandbox-cmlgGVYX.js → sandbox-pJ4JSnDx.js} +101 -43
- package/dist/sandbox-pJ4JSnDx.js.map +1 -0
- package/package.json +1 -1
- package/dist/dist-Duor5GbS.js.map +0 -1
- package/dist/filesystem-BWAZCZER.d.ts.map +0 -1
- package/dist/sandbox-cmlgGVYX.js.map +0 -1
package/Dockerfile
CHANGED
|
@@ -5,20 +5,20 @@ ARG NODE_VERSION=24
|
|
|
5
5
|
# cloudflared release — shared across glibc and musl image variants.
|
|
6
6
|
# Bump this together with the architecture-specific checksums below.
|
|
7
7
|
ARG CLOUDFLARED_VERSION=2026.3.0
|
|
8
|
+
# fuse-overlayfs release — backs the copy-on-write layer of restored backups.
|
|
9
|
+
# Pinned upstream because Ubuntu 22.04 ships 1.7.1, which returns EEXIST when
|
|
10
|
+
# a restored directory is deleted, recreated and listed before files are
|
|
11
|
+
# created in it (fixed in 1.15). Switch back to the distro package once the
|
|
12
|
+
# base image ships 1.15 or newer.
|
|
13
|
+
# Bump this together with the architecture-specific checksums below.
|
|
14
|
+
ARG FUSE_OVERLAYFS_VERSION=1.18
|
|
8
15
|
FROM oven/bun:${BUN_VERSION} AS bun-binary
|
|
9
16
|
FROM node:${NODE_VERSION}-slim AS node-runtime
|
|
10
17
|
|
|
11
18
|
# ============================================================================
|
|
12
|
-
#
|
|
13
|
-
# Version pin lives at the top of this Dockerfile as a global ARG, shared
|
|
14
|
-
# by every image variant so they ship the same release.
|
|
19
|
+
# Release downloader — shared base for fetching pinned upstream binaries
|
|
15
20
|
# ============================================================================
|
|
16
|
-
FROM alpine:3.21 AS
|
|
17
|
-
|
|
18
|
-
ARG TARGETARCH
|
|
19
|
-
ARG CLOUDFLARED_VERSION
|
|
20
|
-
ARG CLOUDFLARED_SHA256_AMD64=4a9e50e6d6d798e90fcd01933151a90bf7edd99a0a55c28ad18f2e16263a5c30
|
|
21
|
-
ARG CLOUDFLARED_SHA256_ARM64=0755ba4cbab59980e6148367fcf53a8f3ec85a97deefd63c2420cf7850769bee
|
|
21
|
+
FROM alpine:3.21 AS release-downloader
|
|
22
22
|
|
|
23
23
|
# Inject the host's extra CA bundle when downloading behind a TLS-intercepting
|
|
24
24
|
# proxy (e.g. Cloudflare WARP / Zero Trust). No-op when the secret isn't passed.
|
|
@@ -33,6 +33,18 @@ RUN --mount=type=secret,id=wrangler_ca \
|
|
|
33
33
|
update-ca-certificates; \
|
|
34
34
|
fi
|
|
35
35
|
|
|
36
|
+
# ============================================================================
|
|
37
|
+
# cloudflared (Cloudflare Tunnel daemon) — enables sandbox.tunnels.*
|
|
38
|
+
# Version pin lives at the top of this Dockerfile as a global ARG, shared
|
|
39
|
+
# by every image variant so they ship the same release.
|
|
40
|
+
# ============================================================================
|
|
41
|
+
FROM release-downloader AS cloudflared-binary
|
|
42
|
+
|
|
43
|
+
ARG TARGETARCH
|
|
44
|
+
ARG CLOUDFLARED_VERSION
|
|
45
|
+
ARG CLOUDFLARED_SHA256_AMD64=4a9e50e6d6d798e90fcd01933151a90bf7edd99a0a55c28ad18f2e16263a5c30
|
|
46
|
+
ARG CLOUDFLARED_SHA256_ARM64=0755ba4cbab59980e6148367fcf53a8f3ec85a97deefd63c2420cf7850769bee
|
|
47
|
+
|
|
36
48
|
RUN set -eux; \
|
|
37
49
|
arch="${TARGETARCH:-}"; \
|
|
38
50
|
if [ -z "$arch" ]; then \
|
|
@@ -49,6 +61,32 @@ RUN set -eux; \
|
|
|
49
61
|
chmod +x /cloudflared; \
|
|
50
62
|
/cloudflared --version
|
|
51
63
|
|
|
64
|
+
# ============================================================================
|
|
65
|
+
# fuse-overlayfs — statically linked upstream release for the glibc images
|
|
66
|
+
# ============================================================================
|
|
67
|
+
FROM release-downloader AS fuse-overlayfs-binary
|
|
68
|
+
|
|
69
|
+
ARG TARGETARCH
|
|
70
|
+
ARG FUSE_OVERLAYFS_VERSION
|
|
71
|
+
ARG FUSE_OVERLAYFS_SHA256_AMD64=56b0ae0aeb8abb308b068af2f137ed8d1bd239f4f27e21672ff0def861eea1e8
|
|
72
|
+
ARG FUSE_OVERLAYFS_SHA256_ARM64=82fed736197b2a881a822e5357b488796f654e8371ce8573a1592331510a0133
|
|
73
|
+
|
|
74
|
+
RUN set -eux; \
|
|
75
|
+
arch="${TARGETARCH:-}"; \
|
|
76
|
+
if [ -z "$arch" ]; then \
|
|
77
|
+
arch="$(apk --print-arch)"; \
|
|
78
|
+
fi; \
|
|
79
|
+
case "$arch" in \
|
|
80
|
+
amd64|x86_64) suffix=x86_64; sha="${FUSE_OVERLAYFS_SHA256_AMD64}" ;; \
|
|
81
|
+
arm64|aarch64) suffix=aarch64; sha="${FUSE_OVERLAYFS_SHA256_ARM64}" ;; \
|
|
82
|
+
*) echo "Unsupported arch for fuse-overlayfs: $arch" >&2; exit 1 ;; \
|
|
83
|
+
esac; \
|
|
84
|
+
url="https://github.com/containers/fuse-overlayfs/releases/download/v${FUSE_OVERLAYFS_VERSION}/fuse-overlayfs-${suffix}"; \
|
|
85
|
+
curl -fsSL -o /fuse-overlayfs "$url"; \
|
|
86
|
+
echo "$sha /fuse-overlayfs" | sha256sum -c -; \
|
|
87
|
+
chmod +x /fuse-overlayfs; \
|
|
88
|
+
/fuse-overlayfs --version
|
|
89
|
+
|
|
52
90
|
# Sandbox container images (default and python variants)
|
|
53
91
|
# Multi-stage build optimized for Turborepo monorepo
|
|
54
92
|
|
|
@@ -152,7 +190,6 @@ ENV SANDBOX_VERSION=${SANDBOX_VERSION}
|
|
|
152
190
|
# - fuse3: FUSE filesystem support (replaces legacy fuse, needed by s3fs/squashfuse/fuse-overlayfs)
|
|
153
191
|
# - squashfs-tools: create squashfs archives (mksquashfs)
|
|
154
192
|
# - squashfuse: mount squashfs in userspace (FUSE)
|
|
155
|
-
# - fuse-overlayfs: userspace overlayfs for copy-on-write snapshots
|
|
156
193
|
# Cache-bust: 2 - Clear apt cache to force fresh package list
|
|
157
194
|
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
158
195
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
|
@@ -160,7 +197,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
|
160
197
|
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache && \
|
|
161
198
|
rm -rf /var/cache/apt/* /var/lib/apt/lists/* && \
|
|
162
199
|
apt-get update && apt-get install -y --no-install-recommends \
|
|
163
|
-
s3fs fuse3 squashfs-tools squashfuse
|
|
200
|
+
s3fs fuse3 squashfs-tools squashfuse \
|
|
164
201
|
ca-certificates curl wget procps git unzip zip jq file tini \
|
|
165
202
|
inotify-tools \
|
|
166
203
|
libssl3 zlib1g libbz2-1.0 libreadline8 libsqlite3-0 \
|
|
@@ -173,6 +210,10 @@ RUN sed -i 's/#user_allow_other/user_allow_other/' /etc/fuse.conf
|
|
|
173
210
|
# fusermount requires /etc/mtab to locate active mounts
|
|
174
211
|
RUN ln -sf /proc/mounts /etc/mtab
|
|
175
212
|
|
|
213
|
+
# Userspace overlayfs for copy-on-write backup restores
|
|
214
|
+
COPY --from=fuse-overlayfs-binary /fuse-overlayfs /usr/bin/fuse-overlayfs
|
|
215
|
+
RUN fuse-overlayfs --version
|
|
216
|
+
|
|
176
217
|
# Install Node.js from official Node image (defaults to 24 LTS,
|
|
177
218
|
# override via --build-arg NODE_VERSION=<version>)
|
|
178
219
|
COPY --from=node-runtime /usr/local/bin/node /usr/local/bin/node
|
package/dist/bridge/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "../errors-CXR0xBpw.js";
|
|
2
2
|
import "../errors-QYlSkVGz.js";
|
|
3
|
-
import "../dist-
|
|
4
|
-
import { g as validateTunnelName, h as validatePort, m as SandboxSecurityError, n as getSandbox$1, x as streamFile } from "../sandbox-
|
|
5
|
-
import "../extensions-
|
|
3
|
+
import "../dist-n_eniPAR.js";
|
|
4
|
+
import { g as validateTunnelName, h as validatePort, m as SandboxSecurityError, n as getSandbox$1, x as streamFile } from "../sandbox-pJ4JSnDx.js";
|
|
5
|
+
import "../extensions-Be5HnDGt.js";
|
|
6
6
|
import { DurableObject, env } from "cloudflare:workers";
|
|
7
7
|
import { Hono } from "hono";
|
|
8
8
|
|
|
@@ -97,10 +97,23 @@ function validateTerminalId(id) {
|
|
|
97
97
|
/**
|
|
98
98
|
* Convert an SSE stream from readFileStream() into a raw byte stream.
|
|
99
99
|
* Decodes base64 chunks for binary files and UTF-8-encodes text chunks.
|
|
100
|
+
* Reads nothing from the source until the returned stream is pulled.
|
|
100
101
|
*/
|
|
101
102
|
function sseToByteStream(sse) {
|
|
102
|
-
|
|
103
|
+
return chunksToByteStream(streamFile(sse)[Symbol.asyncIterator]());
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Like sseToByteStream(), but reads up to the first chunk before returning.
|
|
107
|
+
* A missing file arrives as an error event inside a successful stream, so it
|
|
108
|
+
* rejects here, while the caller can still choose the HTTP status.
|
|
109
|
+
*/
|
|
110
|
+
async function openSSEByteStream(sse) {
|
|
103
111
|
const iterator = streamFile(sse)[Symbol.asyncIterator]();
|
|
112
|
+
return chunksToByteStream(iterator, await iterator.next());
|
|
113
|
+
}
|
|
114
|
+
function chunksToByteStream(iterator, first) {
|
|
115
|
+
const encoder = new TextEncoder();
|
|
116
|
+
let pending = first;
|
|
104
117
|
let finished = false;
|
|
105
118
|
async function finish(cancelSource) {
|
|
106
119
|
if (finished) return;
|
|
@@ -111,7 +124,8 @@ function sseToByteStream(sse) {
|
|
|
111
124
|
return new ReadableStream({
|
|
112
125
|
async pull(controller) {
|
|
113
126
|
try {
|
|
114
|
-
const result = await iterator.next();
|
|
127
|
+
const result = pending ?? await iterator.next();
|
|
128
|
+
pending = void 0;
|
|
115
129
|
if (result.done) {
|
|
116
130
|
await finish(false);
|
|
117
131
|
controller.close();
|
|
@@ -1993,13 +2007,15 @@ function registerFileRoutes(app, apiPrefix, sandboxBinding) {
|
|
|
1993
2007
|
const sandbox = getSandbox(getSandboxNs(c.env, sandboxBinding), c.get("containerUUID"));
|
|
1994
2008
|
try {
|
|
1995
2009
|
const stream = await sandbox.readFileStream(resolvedPath);
|
|
1996
|
-
return new Response(
|
|
2010
|
+
return new Response(await openSSEByteStream(stream), {
|
|
1997
2011
|
status: 200,
|
|
1998
2012
|
headers: { "Content-Type": "application/octet-stream" }
|
|
1999
2013
|
});
|
|
2000
2014
|
} catch (err) {
|
|
2001
|
-
|
|
2002
|
-
|
|
2015
|
+
const code = err.code;
|
|
2016
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2017
|
+
if (code === "FILE_NOT_FOUND" || msg.startsWith("File streaming error: File not found: ")) return errorJson(`File not found: ${resolvedPath}`, "workspace_read_not_found", 404);
|
|
2018
|
+
return errorJson(`read failed: ${msg}`, "exec_transport_error", 502);
|
|
2003
2019
|
}
|
|
2004
2020
|
});
|
|
2005
2021
|
app.put(`${apiPrefix}/sandbox/:id/file/*`, async (c) => {
|