@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
|
@@ -0,0 +1,732 @@
|
|
|
1
|
+
import { c as WaitForLogResult, i as ProcessLogEvent, n as ProcessFailure, o as ProcessStatus, r as ProcessLogCursor, s as SandboxCommand, t as ProcessExit } from "./process-types-GStiZ8f8.js";
|
|
2
|
+
|
|
3
|
+
//#region ../shared/dist/types/core.d.ts
|
|
4
|
+
|
|
5
|
+
interface ExecOptions {
|
|
6
|
+
cwd?: string;
|
|
7
|
+
env?: Record<string, string>;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
}
|
|
10
|
+
interface ProcessLogsOptions {
|
|
11
|
+
since?: ProcessLogCursor;
|
|
12
|
+
replay?: boolean;
|
|
13
|
+
follow?: boolean;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
interface WaitForExitOptions {
|
|
17
|
+
timeout?: number;
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
}
|
|
20
|
+
interface WaitForLogOptions extends WaitForExitOptions {
|
|
21
|
+
stream?: 'stdout' | 'stderr' | 'both';
|
|
22
|
+
}
|
|
23
|
+
interface ProcessOutput<T> {
|
|
24
|
+
stdout: T;
|
|
25
|
+
stderr: T;
|
|
26
|
+
exitCode: number;
|
|
27
|
+
signal?: number;
|
|
28
|
+
timedOut: boolean;
|
|
29
|
+
truncated: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface ProcessOutputOptions extends WaitForExitOptions {
|
|
32
|
+
maxBytes?: number;
|
|
33
|
+
}
|
|
34
|
+
interface ProcessTextOutputOptions extends ProcessOutputOptions {
|
|
35
|
+
encoding: 'utf8';
|
|
36
|
+
}
|
|
37
|
+
interface SandboxProcess {
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly pid: number;
|
|
40
|
+
readonly exitCode: Promise<number>;
|
|
41
|
+
status(): Promise<ProcessStatus>;
|
|
42
|
+
logs(options?: ProcessLogsOptions): Promise<ReadableStream<ProcessLogEvent>>;
|
|
43
|
+
waitForLog(pattern: string | RegExp, options?: WaitForLogOptions): Promise<WaitForLogResult>;
|
|
44
|
+
waitForExit(options?: WaitForExitOptions): Promise<ProcessExit>;
|
|
45
|
+
output(options: ProcessTextOutputOptions): Promise<ProcessOutput<string>>;
|
|
46
|
+
output(options?: ProcessOutputOptions): Promise<ProcessOutput<Uint8Array>>;
|
|
47
|
+
waitForPort(port: number, options?: WaitForPortOptions): Promise<void>;
|
|
48
|
+
kill(signal?: number): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Options for waiting for a port to become ready
|
|
52
|
+
*/
|
|
53
|
+
interface WaitForPortOptions {
|
|
54
|
+
/**
|
|
55
|
+
* Check mode
|
|
56
|
+
* - 'http': Make an HTTP request and check for success status
|
|
57
|
+
* - 'tcp': Just check if TCP connection succeeds (default)
|
|
58
|
+
* @default 'tcp'
|
|
59
|
+
*/
|
|
60
|
+
mode?: 'http' | 'tcp';
|
|
61
|
+
/**
|
|
62
|
+
* HTTP path to check (only used when mode is 'http')
|
|
63
|
+
* @default '/'
|
|
64
|
+
*/
|
|
65
|
+
path?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Expected HTTP status code or range (only used when mode is 'http')
|
|
68
|
+
* - Single number: exact match (e.g., 200)
|
|
69
|
+
* - Object with min/max: range match (e.g., { min: 200, max: 399 })
|
|
70
|
+
* @default { min: 200, max: 399 }
|
|
71
|
+
*/
|
|
72
|
+
status?: number | {
|
|
73
|
+
min: number;
|
|
74
|
+
max: number;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Maximum time to wait in milliseconds
|
|
78
|
+
* @default no timeout
|
|
79
|
+
*/
|
|
80
|
+
timeout?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Signal used to cancel waiting locally.
|
|
83
|
+
*/
|
|
84
|
+
signal?: AbortSignal;
|
|
85
|
+
/**
|
|
86
|
+
* Interval between checks in milliseconds
|
|
87
|
+
* @default 500
|
|
88
|
+
*/
|
|
89
|
+
interval?: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* SSE event emitted by port watch stream
|
|
93
|
+
*/
|
|
94
|
+
type PortWatchEvent = {
|
|
95
|
+
type: 'watching';
|
|
96
|
+
port: number;
|
|
97
|
+
} | {
|
|
98
|
+
type: 'ready';
|
|
99
|
+
port: number;
|
|
100
|
+
statusCode?: number;
|
|
101
|
+
} | {
|
|
102
|
+
type: 'error';
|
|
103
|
+
port: number;
|
|
104
|
+
error: string;
|
|
105
|
+
};
|
|
106
|
+
interface PortWatchRPCOptions {
|
|
107
|
+
mode?: 'http' | 'tcp';
|
|
108
|
+
path?: string;
|
|
109
|
+
status?: number | {
|
|
110
|
+
min: number;
|
|
111
|
+
max: number;
|
|
112
|
+
};
|
|
113
|
+
interval?: number;
|
|
114
|
+
}
|
|
115
|
+
interface PortWatchSubscriptionAPI {
|
|
116
|
+
stream(): Promise<ReadableStream<PortWatchEvent>>;
|
|
117
|
+
cancel(): Promise<void>;
|
|
118
|
+
[Symbol.dispose](): void;
|
|
119
|
+
}
|
|
120
|
+
interface SandboxOptions {
|
|
121
|
+
/**
|
|
122
|
+
* Duration after which the sandbox instance will sleep if no requests are received
|
|
123
|
+
* Can be:
|
|
124
|
+
* - A string like "30s", "3m", "5m", "1h" (seconds, minutes, or hours)
|
|
125
|
+
* - A number representing seconds (e.g., 180 for 3 minutes)
|
|
126
|
+
* Default: "10m" (10 minutes)
|
|
127
|
+
*
|
|
128
|
+
* Note: Ignored when keepAlive is true
|
|
129
|
+
*/
|
|
130
|
+
sleepAfter?: string | number;
|
|
131
|
+
/**
|
|
132
|
+
* Keep the container alive indefinitely by preventing automatic shutdown
|
|
133
|
+
* When true, the container will never auto-timeout and must be explicitly destroyed
|
|
134
|
+
* - Any scenario where activity can't be automatically detected
|
|
135
|
+
*
|
|
136
|
+
* Important: You MUST call sandbox.destroy() when done to avoid resource leaks
|
|
137
|
+
*
|
|
138
|
+
* Default: false
|
|
139
|
+
*/
|
|
140
|
+
keepAlive?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Normalize sandbox ID to lowercase for preview URL compatibility
|
|
143
|
+
*
|
|
144
|
+
* Required for preview URLs because hostnames are case-insensitive (RFC 3986), which
|
|
145
|
+
* would route requests to a different Durable Object instance with IDs containing uppercase letters.
|
|
146
|
+
*
|
|
147
|
+
* **Important:** Different normalizeId values create different Durable Object instances:
|
|
148
|
+
* - `getSandbox(ns, "MyProject")` → DO key: "MyProject"
|
|
149
|
+
* - `getSandbox(ns, "MyProject", {normalizeId: true})` → DO key: "myproject"
|
|
150
|
+
*
|
|
151
|
+
* **Future change:** In a future version, this will default to `true` (automatically lowercase all IDs).
|
|
152
|
+
* IDs with uppercase letters will trigger a warning. To prepare, use lowercase IDs or explicitly
|
|
153
|
+
* pass `normalizeId: true`.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* getSandbox(ns, "my-project") // Works with preview URLs (lowercase)
|
|
157
|
+
* getSandbox(ns, "MyProject", {normalizeId: true}) // Normalized to "myproject"
|
|
158
|
+
*
|
|
159
|
+
* @default false
|
|
160
|
+
*/
|
|
161
|
+
normalizeId?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Container startup timeout configuration
|
|
164
|
+
*
|
|
165
|
+
* Tune timeouts based on your container's characteristics. SDK defaults (30s instance, 90s ports)
|
|
166
|
+
* work for most use cases. Adjust for heavy containers or fail-fast applications.
|
|
167
|
+
*
|
|
168
|
+
* Can also be configured via environment variables:
|
|
169
|
+
* - SANDBOX_INSTANCE_TIMEOUT_MS
|
|
170
|
+
* - SANDBOX_PORT_TIMEOUT_MS
|
|
171
|
+
* - SANDBOX_POLL_INTERVAL_MS
|
|
172
|
+
*
|
|
173
|
+
* Precedence: options > env vars > SDK defaults
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* // Heavy containers (ML models, large apps)
|
|
177
|
+
* getSandbox(ns, id, {
|
|
178
|
+
* containerTimeouts: { portReadyTimeoutMS: 180_000 }
|
|
179
|
+
* })
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* // Fail-fast for latency-sensitive apps
|
|
183
|
+
* getSandbox(ns, id, {
|
|
184
|
+
* containerTimeouts: {
|
|
185
|
+
* instanceGetTimeoutMS: 15_000,
|
|
186
|
+
* portReadyTimeoutMS: 30_000
|
|
187
|
+
* }
|
|
188
|
+
* })
|
|
189
|
+
*/
|
|
190
|
+
containerTimeouts?: {
|
|
191
|
+
/**
|
|
192
|
+
* Time to wait for container instance provisioning
|
|
193
|
+
* @default 30000 (30s) - or SANDBOX_INSTANCE_TIMEOUT_MS env var
|
|
194
|
+
*/
|
|
195
|
+
instanceGetTimeoutMS?: number;
|
|
196
|
+
/**
|
|
197
|
+
* Time to wait for application startup and ports to be ready
|
|
198
|
+
* @default 90000 (90s) - or SANDBOX_PORT_TIMEOUT_MS env var
|
|
199
|
+
*/
|
|
200
|
+
portReadyTimeoutMS?: number;
|
|
201
|
+
/**
|
|
202
|
+
* How often to poll for container readiness
|
|
203
|
+
* @default 300 (300ms) - or SANDBOX_POLL_INTERVAL_MS env var
|
|
204
|
+
*/
|
|
205
|
+
waitIntervalMS?: number;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region ../shared/dist/pty-types.d.ts
|
|
210
|
+
interface CreateTerminalOptions {
|
|
211
|
+
command: SandboxCommand;
|
|
212
|
+
cwd?: string;
|
|
213
|
+
env?: Record<string, string>;
|
|
214
|
+
cols?: number;
|
|
215
|
+
rows?: number;
|
|
216
|
+
bufferSize?: number;
|
|
217
|
+
}
|
|
218
|
+
interface TerminalSnapshot {
|
|
219
|
+
id: string;
|
|
220
|
+
pid?: number;
|
|
221
|
+
command: SandboxCommand;
|
|
222
|
+
cwd?: string;
|
|
223
|
+
status: 'running' | 'exited' | 'error';
|
|
224
|
+
exit?: ProcessExit;
|
|
225
|
+
error?: ProcessFailure;
|
|
226
|
+
}
|
|
227
|
+
type TerminalOutputCursor = string;
|
|
228
|
+
interface TerminalOutputOptions {
|
|
229
|
+
since?: TerminalOutputCursor;
|
|
230
|
+
replay?: boolean;
|
|
231
|
+
follow?: boolean;
|
|
232
|
+
signal?: AbortSignal;
|
|
233
|
+
}
|
|
234
|
+
type TerminalOutputEvent = {
|
|
235
|
+
type: 'data';
|
|
236
|
+
terminalId: string;
|
|
237
|
+
cursor: TerminalOutputCursor;
|
|
238
|
+
timestamp: string;
|
|
239
|
+
data: Uint8Array;
|
|
240
|
+
} | {
|
|
241
|
+
type: 'terminal';
|
|
242
|
+
terminalId: string;
|
|
243
|
+
cursor: TerminalOutputCursor;
|
|
244
|
+
timestamp: string;
|
|
245
|
+
state: 'exited';
|
|
246
|
+
exit: ProcessExit;
|
|
247
|
+
} | {
|
|
248
|
+
type: 'terminal';
|
|
249
|
+
terminalId: string;
|
|
250
|
+
cursor: TerminalOutputCursor;
|
|
251
|
+
timestamp: string;
|
|
252
|
+
state: 'error';
|
|
253
|
+
error: ProcessFailure;
|
|
254
|
+
} | {
|
|
255
|
+
type: 'truncated';
|
|
256
|
+
terminalId: string;
|
|
257
|
+
cursor?: TerminalOutputCursor;
|
|
258
|
+
timestamp: string;
|
|
259
|
+
};
|
|
260
|
+
interface TerminalOutputSubscriptionAPI {
|
|
261
|
+
stream(): Promise<ReadableStream<TerminalOutputEvent>>;
|
|
262
|
+
cancel(): Promise<void>;
|
|
263
|
+
[Symbol.dispose](): void;
|
|
264
|
+
}
|
|
265
|
+
interface Terminal {
|
|
266
|
+
readonly id: string;
|
|
267
|
+
getSnapshot(): Promise<TerminalSnapshot>;
|
|
268
|
+
write(data: Uint8Array): Promise<void>;
|
|
269
|
+
resize(cols: number, rows: number): Promise<void>;
|
|
270
|
+
output(options?: TerminalOutputOptions): Promise<ReadableStream<TerminalOutputEvent>>;
|
|
271
|
+
waitForExit(options?: WaitForExitOptions): Promise<ProcessExit>;
|
|
272
|
+
interrupt(): Promise<void>;
|
|
273
|
+
terminate(): Promise<void>;
|
|
274
|
+
connect(request: Request, options?: {
|
|
275
|
+
cursor?: TerminalOutputCursor;
|
|
276
|
+
cols?: number;
|
|
277
|
+
rows?: number;
|
|
278
|
+
}): Promise<Response>;
|
|
279
|
+
}
|
|
280
|
+
interface SandboxTerminalsAPI {
|
|
281
|
+
create(options: CreateTerminalOptions): Promise<TerminalSnapshot>;
|
|
282
|
+
get(id: string): Promise<TerminalSnapshot | null>;
|
|
283
|
+
list(): Promise<TerminalSnapshot[]>;
|
|
284
|
+
output(id: string, options?: Omit<TerminalOutputOptions, 'signal'>): Promise<TerminalOutputSubscriptionAPI>;
|
|
285
|
+
write(id: string, data: Uint8Array): Promise<void>;
|
|
286
|
+
resize(id: string, cols: number, rows: number): Promise<void>;
|
|
287
|
+
interrupt(id: string): Promise<void>;
|
|
288
|
+
terminate(id: string): Promise<void>;
|
|
289
|
+
hasActive(): Promise<boolean>;
|
|
290
|
+
}
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region ../shared/dist/types/backup-mounts.d.ts
|
|
293
|
+
/**
|
|
294
|
+
* Options for creating a directory backup
|
|
295
|
+
*/
|
|
296
|
+
interface BackupCompressionOptions {
|
|
297
|
+
format?: 'gzip' | 'lz4' | 'zstd';
|
|
298
|
+
threads?: number;
|
|
299
|
+
}
|
|
300
|
+
interface BackupOptions {
|
|
301
|
+
/** Directory to back up. Must be absolute and under `/workspace`, `/home`, `/tmp`, `/var/tmp`, or `/app`. */
|
|
302
|
+
dir: string;
|
|
303
|
+
/** Human-readable name for this backup. Optional. */
|
|
304
|
+
name?: string;
|
|
305
|
+
/** Seconds until automatic garbage collection. Default: 259200 (3 days). No upper limit. */
|
|
306
|
+
ttl?: number;
|
|
307
|
+
/**
|
|
308
|
+
* Respect git ignore rules for the backup directory when it is inside a git repository.
|
|
309
|
+
*
|
|
310
|
+
* Default: false.
|
|
311
|
+
* If the directory is not inside a git repository, no git-based exclusions are applied.
|
|
312
|
+
* If git is not installed in the container, a warning is logged and gitignore rules are skipped.
|
|
313
|
+
*/
|
|
314
|
+
gitignore?: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Glob patterns to exclude from the backup.
|
|
317
|
+
* These are passed directly to mksquashfs as wildcard exclude patterns.
|
|
318
|
+
*
|
|
319
|
+
* @example ['node_modules', '*.log', '.cache']
|
|
320
|
+
*/
|
|
321
|
+
excludes?: string[];
|
|
322
|
+
/**
|
|
323
|
+
* Use local R2 binding for backup storage instead of presigned URLs.
|
|
324
|
+
* Required for local development where presigned URLs and FUSE are unavailable.
|
|
325
|
+
* When true, the DO resolves BACKUP_BUCKET from its own env as an R2 binding.
|
|
326
|
+
*/
|
|
327
|
+
localBucket?: boolean;
|
|
328
|
+
compression?: BackupCompressionOptions;
|
|
329
|
+
/**
|
|
330
|
+
* Use parallel multipart upload to R2 for large archives.
|
|
331
|
+
* Significantly speeds up uploads for archives over 10 MiB.
|
|
332
|
+
* Default: true.
|
|
333
|
+
*/
|
|
334
|
+
multipart?: boolean;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Handle representing a stored directory backup.
|
|
338
|
+
* Serializable metadata returned by createBackup().
|
|
339
|
+
* Store it anywhere and later pass it to restoreBackup().
|
|
340
|
+
*/
|
|
341
|
+
interface DirectoryBackup {
|
|
342
|
+
/** Unique backup identifier */
|
|
343
|
+
readonly id: string;
|
|
344
|
+
/** Directory to restore into. Must be under `/workspace`, `/home`, `/tmp`, `/var/tmp`, or `/app`. */
|
|
345
|
+
readonly dir: string;
|
|
346
|
+
/** Whether this backup was created with local R2 binding mode. */
|
|
347
|
+
readonly localBucket?: boolean;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Result returned from a successful restoreBackup() call
|
|
351
|
+
*/
|
|
352
|
+
interface RestoreBackupResult {
|
|
353
|
+
success: boolean;
|
|
354
|
+
/** The directory that was restored */
|
|
355
|
+
dir: string;
|
|
356
|
+
/** Backup ID that was restored */
|
|
357
|
+
id: string;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Supported S3-compatible storage providers
|
|
361
|
+
*/
|
|
362
|
+
type BucketProvider = 'r2' | 's3' | 'gcs';
|
|
363
|
+
/**
|
|
364
|
+
* Credentials for S3-compatible storage
|
|
365
|
+
*/
|
|
366
|
+
interface BucketCredentials {
|
|
367
|
+
accessKeyId: string;
|
|
368
|
+
secretAccessKey: string;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Options for mounting an S3-compatible bucket via s3fs-FUSE (production)
|
|
372
|
+
*/
|
|
373
|
+
interface RemoteMountBucketOptions {
|
|
374
|
+
/**
|
|
375
|
+
* S3-compatible endpoint URL
|
|
376
|
+
*
|
|
377
|
+
* Examples:
|
|
378
|
+
* - R2: 'https://abc123.r2.cloudflarestorage.com'
|
|
379
|
+
* - AWS S3: 'https://s3.us-west-2.amazonaws.com'
|
|
380
|
+
* - GCS: 'https://storage.googleapis.com'
|
|
381
|
+
*/
|
|
382
|
+
endpoint: string;
|
|
383
|
+
/**
|
|
384
|
+
* Optional provider hint for automatic s3fs flag configuration
|
|
385
|
+
* If not specified, will attempt to detect from endpoint URL.
|
|
386
|
+
*
|
|
387
|
+
* Examples:
|
|
388
|
+
* - 'r2' - Cloudflare R2 (adds nomixupload)
|
|
389
|
+
* - 's3' - Amazon S3 (standard configuration)
|
|
390
|
+
* - 'gcs' - Google Cloud Storage (no special flags needed)
|
|
391
|
+
*/
|
|
392
|
+
provider?: BucketProvider;
|
|
393
|
+
/**
|
|
394
|
+
* Explicit credentials (overrides env var auto-detection)
|
|
395
|
+
*/
|
|
396
|
+
credentials?: BucketCredentials;
|
|
397
|
+
/**
|
|
398
|
+
* Mount filesystem as read-only
|
|
399
|
+
* Default: false
|
|
400
|
+
*/
|
|
401
|
+
readOnly?: boolean;
|
|
402
|
+
/**
|
|
403
|
+
* Advanced: Override or extend s3fs options
|
|
404
|
+
*
|
|
405
|
+
* These will be merged with provider-specific defaults.
|
|
406
|
+
* To override defaults completely, specify all options here.
|
|
407
|
+
*
|
|
408
|
+
* Common options:
|
|
409
|
+
* - 'use_path_request_style' - Use path-style URLs (bucket/path vs bucket.host/path)
|
|
410
|
+
* - 'nomixupload' - Disable mixed multipart uploads (needed for some providers)
|
|
411
|
+
* - 'nomultipart' - Disable all multipart operations
|
|
412
|
+
* - 'sigv2' - Use signature version 2 instead of v4
|
|
413
|
+
* - 'no_check_certificate' - Skip SSL certificate validation (dev/testing only)
|
|
414
|
+
*/
|
|
415
|
+
s3fsOptions?: string[];
|
|
416
|
+
/**
|
|
417
|
+
* Optional prefix/subdirectory within the bucket to mount.
|
|
418
|
+
*
|
|
419
|
+
* When specified, only the contents under this prefix are visible at the
|
|
420
|
+
* mount point, scoping the mount to a subdirectory of the bucket.
|
|
421
|
+
*
|
|
422
|
+
* Must start with '/' (e.g., '/workspaces/project123' or '/data/uploads/')
|
|
423
|
+
*/
|
|
424
|
+
prefix?: string;
|
|
425
|
+
/**
|
|
426
|
+
* Keep real credentials in the Durable Object; write dummy credentials into
|
|
427
|
+
* the container-side s3fs password file. Outbound s3fs requests are
|
|
428
|
+
* intercepted by the DO, signed with real credentials, and forwarded to the
|
|
429
|
+
* configured endpoint.
|
|
430
|
+
*
|
|
431
|
+
* Default: false (real credentials are written into the container)
|
|
432
|
+
*/
|
|
433
|
+
credentialProxy?: boolean;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Options for mounting a local R2 binding via bidirectional sync (local dev)
|
|
437
|
+
*
|
|
438
|
+
* Used during local development with `wrangler dev`. The Durable Object
|
|
439
|
+
* resolves the R2 binding from its own env using the `bucket` parameter
|
|
440
|
+
* and syncs files via polling instead of s3fs-FUSE.
|
|
441
|
+
*/
|
|
442
|
+
interface LocalMountBucketOptions {
|
|
443
|
+
/**
|
|
444
|
+
* Must be true to indicate local R2 binding mode.
|
|
445
|
+
*/
|
|
446
|
+
localBucket: true;
|
|
447
|
+
/**
|
|
448
|
+
* Optional prefix/subdirectory within the bucket to sync.
|
|
449
|
+
*
|
|
450
|
+
* When specified, only the contents under this prefix will be visible
|
|
451
|
+
* at the mount point.
|
|
452
|
+
*/
|
|
453
|
+
prefix?: string;
|
|
454
|
+
/**
|
|
455
|
+
* Mount filesystem as read-only
|
|
456
|
+
* Default: false
|
|
457
|
+
*/
|
|
458
|
+
readOnly?: boolean;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Options for mounting an R2 binding via credential-less egress interception.
|
|
462
|
+
*/
|
|
463
|
+
interface R2BindingMountBucketOptions {
|
|
464
|
+
/**
|
|
465
|
+
* Must not be set — distinguishes this variant from RemoteMountBucketOptions.
|
|
466
|
+
*/
|
|
467
|
+
endpoint?: never;
|
|
468
|
+
/**
|
|
469
|
+
* Optional prefix/subdirectory within the bucket to mount.
|
|
470
|
+
*
|
|
471
|
+
* When specified, only the contents under this prefix will be visible
|
|
472
|
+
* at the mount point.
|
|
473
|
+
*/
|
|
474
|
+
prefix?: string;
|
|
475
|
+
/**
|
|
476
|
+
* Mount filesystem as read-only
|
|
477
|
+
* Default: false
|
|
478
|
+
*/
|
|
479
|
+
readOnly?: boolean;
|
|
480
|
+
/**
|
|
481
|
+
* Advanced: Override or extend s3fs options.
|
|
482
|
+
* Provider defaults for R2 are still applied automatically.
|
|
483
|
+
*/
|
|
484
|
+
s3fsOptions?: string[];
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Options for mounting a bucket — remote (s3fs-FUSE), local (R2 binding sync),
|
|
488
|
+
* or R2 egress (credential-less s3fs via egress interception).
|
|
489
|
+
*/
|
|
490
|
+
type MountBucketOptions = RemoteMountBucketOptions | LocalMountBucketOptions | R2BindingMountBucketOptions;
|
|
491
|
+
//#endregion
|
|
492
|
+
//#region ../shared/dist/types/filesystem.d.ts
|
|
493
|
+
interface MkdirResult {
|
|
494
|
+
success: boolean;
|
|
495
|
+
path: string;
|
|
496
|
+
recursive: boolean;
|
|
497
|
+
timestamp: string;
|
|
498
|
+
exitCode?: number;
|
|
499
|
+
}
|
|
500
|
+
interface WriteFileResult {
|
|
501
|
+
success: boolean;
|
|
502
|
+
path: string;
|
|
503
|
+
timestamp: string;
|
|
504
|
+
exitCode?: number;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Valid `encoding` values accepted by `readFile` / `writeFile` options.
|
|
508
|
+
*
|
|
509
|
+
* - `'utf-8'` / `'utf8'` — treat content as text.
|
|
510
|
+
* - `'base64'` — treat content as base64-encoded binary.
|
|
511
|
+
* - `'none'` — streaming variant of `readFile`, returns a
|
|
512
|
+
* `ReadableStream<Uint8Array>` of raw bytes (see `ReadFileStreamResult`).
|
|
513
|
+
*/
|
|
514
|
+
type FileEncoding = 'utf-8' | 'utf8' | 'base64' | 'none';
|
|
515
|
+
interface ReadFileResult {
|
|
516
|
+
success: boolean;
|
|
517
|
+
path: string;
|
|
518
|
+
content: string;
|
|
519
|
+
timestamp: string;
|
|
520
|
+
exitCode?: number;
|
|
521
|
+
/**
|
|
522
|
+
* Encoding used for content (utf-8 for text, base64 for binary)
|
|
523
|
+
*/
|
|
524
|
+
encoding?: 'utf-8' | 'base64';
|
|
525
|
+
/**
|
|
526
|
+
* Whether the file is detected as binary
|
|
527
|
+
*/
|
|
528
|
+
isBinary?: boolean;
|
|
529
|
+
/**
|
|
530
|
+
* MIME type of the file (e.g., 'image/png', 'text/plain')
|
|
531
|
+
*/
|
|
532
|
+
mimeType?: string;
|
|
533
|
+
/**
|
|
534
|
+
* File size in bytes
|
|
535
|
+
*/
|
|
536
|
+
size?: number;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Result of `readFile()` with `encoding: 'none'`.
|
|
540
|
+
*
|
|
541
|
+
* `content` is a raw binary `ReadableStream<Uint8Array>` delivered directly
|
|
542
|
+
* over the capnp channel — no base64 encoding, no SSE framing, no buffering.
|
|
543
|
+
*/
|
|
544
|
+
interface ReadFileStreamResult {
|
|
545
|
+
success: true;
|
|
546
|
+
path: string;
|
|
547
|
+
content: ReadableStream<Uint8Array>;
|
|
548
|
+
size: number;
|
|
549
|
+
mimeType: string;
|
|
550
|
+
timestamp: string;
|
|
551
|
+
}
|
|
552
|
+
interface DeleteFileResult {
|
|
553
|
+
success: boolean;
|
|
554
|
+
path: string;
|
|
555
|
+
timestamp: string;
|
|
556
|
+
exitCode?: number;
|
|
557
|
+
}
|
|
558
|
+
interface RenameFileResult {
|
|
559
|
+
success: boolean;
|
|
560
|
+
path: string;
|
|
561
|
+
newPath: string;
|
|
562
|
+
timestamp: string;
|
|
563
|
+
exitCode?: number;
|
|
564
|
+
}
|
|
565
|
+
interface MoveFileResult {
|
|
566
|
+
success: boolean;
|
|
567
|
+
path: string;
|
|
568
|
+
newPath: string;
|
|
569
|
+
timestamp: string;
|
|
570
|
+
exitCode?: number;
|
|
571
|
+
}
|
|
572
|
+
interface FileExistsResult {
|
|
573
|
+
success: boolean;
|
|
574
|
+
path: string;
|
|
575
|
+
exists: boolean;
|
|
576
|
+
timestamp: string;
|
|
577
|
+
}
|
|
578
|
+
interface FileInfo {
|
|
579
|
+
name: string;
|
|
580
|
+
absolutePath: string;
|
|
581
|
+
relativePath: string;
|
|
582
|
+
type: 'file' | 'directory' | 'symlink' | 'other';
|
|
583
|
+
size: number;
|
|
584
|
+
modifiedAt: string;
|
|
585
|
+
mode: string;
|
|
586
|
+
permissions: {
|
|
587
|
+
readable: boolean;
|
|
588
|
+
writable: boolean;
|
|
589
|
+
executable: boolean;
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
interface ListFilesOptions {
|
|
593
|
+
recursive?: boolean;
|
|
594
|
+
includeHidden?: boolean;
|
|
595
|
+
}
|
|
596
|
+
interface ListFilesResult {
|
|
597
|
+
success: boolean;
|
|
598
|
+
path: string;
|
|
599
|
+
files: FileInfo[];
|
|
600
|
+
count: number;
|
|
601
|
+
timestamp: string;
|
|
602
|
+
exitCode?: number;
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* SSE events for file streaming
|
|
606
|
+
*/
|
|
607
|
+
type FileStreamEvent = {
|
|
608
|
+
type: 'metadata';
|
|
609
|
+
mimeType: string;
|
|
610
|
+
size: number;
|
|
611
|
+
isBinary: boolean;
|
|
612
|
+
encoding: 'utf-8' | 'base64';
|
|
613
|
+
} | {
|
|
614
|
+
type: 'chunk';
|
|
615
|
+
data: string;
|
|
616
|
+
} | {
|
|
617
|
+
type: 'complete';
|
|
618
|
+
bytesRead: number;
|
|
619
|
+
} | {
|
|
620
|
+
type: 'error';
|
|
621
|
+
error: string;
|
|
622
|
+
};
|
|
623
|
+
/**
|
|
624
|
+
* File metadata from streaming
|
|
625
|
+
*/
|
|
626
|
+
interface FileMetadata {
|
|
627
|
+
mimeType: string;
|
|
628
|
+
size: number;
|
|
629
|
+
isBinary: boolean;
|
|
630
|
+
encoding: 'utf-8' | 'base64';
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* File stream chunk - either string (text) or Uint8Array (binary, auto-decoded)
|
|
634
|
+
*/
|
|
635
|
+
type FileChunk = string | Uint8Array;
|
|
636
|
+
/**
|
|
637
|
+
* Options for watching a directory.
|
|
638
|
+
*
|
|
639
|
+
* `watch()` resolves only after the watcher is established on the filesystem.
|
|
640
|
+
* The returned SSE stream can be consumed with `parseSSEStream()`.
|
|
641
|
+
*/
|
|
642
|
+
interface WatchOptions {
|
|
643
|
+
/**
|
|
644
|
+
* Watch subdirectories recursively
|
|
645
|
+
* @default true
|
|
646
|
+
*/
|
|
647
|
+
recursive?: boolean;
|
|
648
|
+
/**
|
|
649
|
+
* Glob patterns to include (e.g., '*.ts', '*.js').
|
|
650
|
+
* If not specified, all files are included.
|
|
651
|
+
* Cannot be used together with `exclude`.
|
|
652
|
+
*/
|
|
653
|
+
include?: string[];
|
|
654
|
+
/**
|
|
655
|
+
* Glob patterns to exclude (e.g., 'node_modules', '.git').
|
|
656
|
+
* Cannot be used together with `include`.
|
|
657
|
+
* @default ['.git', 'node_modules', '.DS_Store']
|
|
658
|
+
*/
|
|
659
|
+
exclude?: string[];
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Options for checking whether a path changed while disconnected.
|
|
663
|
+
*
|
|
664
|
+
* Pass the `version` returned from a previous `checkChanges()` call to learn
|
|
665
|
+
* whether the path is unchanged, changed, or needs a full resync because the
|
|
666
|
+
* retained change state was reset. Change state lives only for the current
|
|
667
|
+
* container lifetime and may expire while idle.
|
|
668
|
+
*/
|
|
669
|
+
interface CheckChangesOptions extends WatchOptions {
|
|
670
|
+
/**
|
|
671
|
+
* Version returned by a previous `checkChanges()` call.
|
|
672
|
+
*/
|
|
673
|
+
since?: string;
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* @internal SSE event types for container communication
|
|
677
|
+
*/
|
|
678
|
+
type FileWatchEventType = 'create' | 'modify' | 'delete' | 'move_from' | 'move_to' | 'attrib';
|
|
679
|
+
/**
|
|
680
|
+
* @internal Request body for starting a file watch
|
|
681
|
+
*/
|
|
682
|
+
interface WatchRequest {
|
|
683
|
+
path: string;
|
|
684
|
+
recursive?: boolean;
|
|
685
|
+
events?: FileWatchEventType[];
|
|
686
|
+
include?: string[];
|
|
687
|
+
exclude?: string[];
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* @internal Request body for checking retained change state.
|
|
691
|
+
*/
|
|
692
|
+
interface CheckChangesRequest extends WatchRequest {
|
|
693
|
+
since?: string;
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* SSE events emitted by `sandbox.watch()`.
|
|
697
|
+
*/
|
|
698
|
+
type FileWatchSSEEvent = {
|
|
699
|
+
type: 'watching';
|
|
700
|
+
path: string;
|
|
701
|
+
watchId: string;
|
|
702
|
+
} | {
|
|
703
|
+
type: 'event';
|
|
704
|
+
eventType: FileWatchEventType;
|
|
705
|
+
path: string;
|
|
706
|
+
isDirectory: boolean;
|
|
707
|
+
timestamp: string;
|
|
708
|
+
} | {
|
|
709
|
+
type: 'error';
|
|
710
|
+
error: string;
|
|
711
|
+
} | {
|
|
712
|
+
type: 'stopped';
|
|
713
|
+
reason: string;
|
|
714
|
+
};
|
|
715
|
+
/**
|
|
716
|
+
* Result returned by `checkChanges()`.
|
|
717
|
+
*/
|
|
718
|
+
type CheckChangesResult = {
|
|
719
|
+
success: true;
|
|
720
|
+
status: 'unchanged' | 'changed';
|
|
721
|
+
version: string;
|
|
722
|
+
timestamp: string;
|
|
723
|
+
} | {
|
|
724
|
+
success: true;
|
|
725
|
+
status: 'resync';
|
|
726
|
+
reason: 'expired' | 'restarted';
|
|
727
|
+
version: string;
|
|
728
|
+
timestamp: string;
|
|
729
|
+
};
|
|
730
|
+
//#endregion
|
|
731
|
+
export { CreateTerminalOptions as A, PortWatchRPCOptions as B, BucketCredentials as C, MountBucketOptions as D, LocalMountBucketOptions as E, TerminalOutputOptions as F, ProcessTextOutputOptions as G, ProcessLogsOptions as H, TerminalOutputSubscriptionAPI as I, WaitForExitOptions as J, SandboxOptions as K, TerminalSnapshot as L, Terminal as M, TerminalOutputCursor as N, RemoteMountBucketOptions as O, TerminalOutputEvent as P, ExecOptions as R, BackupOptions as S, DirectoryBackup as T, ProcessOutput as U, PortWatchSubscriptionAPI as V, ProcessOutputOptions as W, WaitForPortOptions as X, WaitForLogOptions as Y, RenameFileResult as _, FileChunk as a, WriteFileResult as b, FileMetadata as c, ListFilesOptions as d, ListFilesResult as f, ReadFileStreamResult as g, ReadFileResult as h, DeleteFileResult as i, SandboxTerminalsAPI as j, RestoreBackupResult as k, FileStreamEvent as l, MoveFileResult as m, CheckChangesRequest as n, FileEncoding as o, MkdirResult as p, SandboxProcess as q, CheckChangesResult as r, FileExistsResult as s, CheckChangesOptions as t, FileWatchSSEEvent as u, WatchOptions as v, BucketProvider as w, BackupCompressionOptions as x, WatchRequest as y, PortWatchEvent as z };
|
|
732
|
+
//# sourceMappingURL=filesystem-BWAZCZER.d.ts.map
|