@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
|
@@ -1,828 +0,0 @@
|
|
|
1
|
-
import { $ as ReadFileStreamResult, B as ISandbox, D as CheckChangesResult, E as CheckChangesOptions, F as FileEncoding, G as MkdirResult, H as ListFilesResult, I as FileExistsResult, K as MountBucketOptions, M as ExecResult, N as ExecutionSession, O as DeleteFileResult, Q as ReadFileResult, S as BackupOptions, V as ListFilesOptions, X as ProcessQueryOptions, _ as SandboxTunnelsAPI, at as SandboxOptions, b as TunnelInfo, bt as TerminalCreateOptions, ct as SessionDeleteResult, d as SandboxControlCallback, f as SandboxExtensionsAPI, ft as WatchOptions, g as SandboxTerminalsAPI, h as SandboxProcessesAPI, j as ExecOptions, k as DirectoryBackup, l as SandboxBackupAPI, lt as SessionOptions, m as SandboxPortsAPI, n as HTTPAuthInterceptorParams, nt as RestoreBackupResult, ot as SandboxProcess, p as SandboxFilesAPI, pt as WriteFileResult, q as MoveFileResult, rt as SandboxExecOptions, st as SandboxProcessPromise, tt as RenameFileResult, u as SandboxCommandsAPI, v as SandboxUtilsAPI, vt as SandboxTerminal, x as TunnelOptions, xt as TerminalOptions, y as SandboxWatchAPI } from "./index-B7QgIs0N.js";
|
|
2
|
-
import { t as ErrorCode } from "./codes-y-U76vnQ.js";
|
|
3
|
-
import { Container, ContainerProxy } from "@cloudflare/containers";
|
|
4
|
-
import { RpcTarget, RpcTransport } from "capnweb";
|
|
5
|
-
|
|
6
|
-
//#region ../shared/dist/logger/types.d.ts
|
|
7
|
-
|
|
8
|
-
type LogComponent = 'container' | 'sandbox-do' | 'executor';
|
|
9
|
-
/**
|
|
10
|
-
* Context metadata included in every log entry
|
|
11
|
-
*/
|
|
12
|
-
interface LogContext {
|
|
13
|
-
/**
|
|
14
|
-
* Unique trace ID for request correlation across distributed components
|
|
15
|
-
* Format: "tr_" + 16 hex chars (e.g., "tr_7f3a9b2c4e5d6f1a")
|
|
16
|
-
*/
|
|
17
|
-
traceId: string;
|
|
18
|
-
/**
|
|
19
|
-
* Component that generated the log
|
|
20
|
-
*/
|
|
21
|
-
component: LogComponent;
|
|
22
|
-
/**
|
|
23
|
-
* Sandbox identifier (which sandbox instance)
|
|
24
|
-
*/
|
|
25
|
-
sandboxId?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Session identifier (which session within sandbox)
|
|
28
|
-
*/
|
|
29
|
-
sessionId?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Process identifier (which background process)
|
|
32
|
-
*/
|
|
33
|
-
processId?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Command identifier (which command execution)
|
|
36
|
-
*/
|
|
37
|
-
commandId?: string;
|
|
38
|
-
/**
|
|
39
|
-
* Duration in milliseconds
|
|
40
|
-
*/
|
|
41
|
-
durationMs?: number;
|
|
42
|
-
/**
|
|
43
|
-
* Service version (from SANDBOX_VERSION env var)
|
|
44
|
-
*/
|
|
45
|
-
serviceVersion?: string;
|
|
46
|
-
/**
|
|
47
|
-
* Instance identifier (hostname or container ID)
|
|
48
|
-
*/
|
|
49
|
-
instanceId?: string;
|
|
50
|
-
/**
|
|
51
|
-
* Extensible for additional metadata
|
|
52
|
-
*/
|
|
53
|
-
[key: string]: unknown;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Logger interface for structured logging
|
|
57
|
-
*
|
|
58
|
-
* All methods accept optional context that gets merged with the logger's base context.
|
|
59
|
-
*/
|
|
60
|
-
interface Logger {
|
|
61
|
-
/**
|
|
62
|
-
* Log debug-level message (most verbose, typically disabled in production)
|
|
63
|
-
*
|
|
64
|
-
* @param message Human-readable message
|
|
65
|
-
* @param context Optional additional context
|
|
66
|
-
*/
|
|
67
|
-
debug(message: string, context?: Partial<LogContext>): void;
|
|
68
|
-
/**
|
|
69
|
-
* Log info-level message (normal operational events)
|
|
70
|
-
*
|
|
71
|
-
* @param message Human-readable message
|
|
72
|
-
* @param context Optional additional context
|
|
73
|
-
*/
|
|
74
|
-
info(message: string, context?: Partial<LogContext>): void;
|
|
75
|
-
/**
|
|
76
|
-
* Log warning-level message (recoverable issues, degraded state)
|
|
77
|
-
*
|
|
78
|
-
* @param message Human-readable message
|
|
79
|
-
* @param context Optional additional context
|
|
80
|
-
*/
|
|
81
|
-
warn(message: string, context?: Partial<LogContext>): void;
|
|
82
|
-
/**
|
|
83
|
-
* Log error-level message (failures, exceptions)
|
|
84
|
-
*
|
|
85
|
-
* @param message Human-readable message
|
|
86
|
-
* @param error Optional Error object to include
|
|
87
|
-
* @param context Optional additional context
|
|
88
|
-
*/
|
|
89
|
-
error(message: string, error?: Error, context?: Partial<LogContext>): void;
|
|
90
|
-
/**
|
|
91
|
-
* Create a child logger with additional context
|
|
92
|
-
*
|
|
93
|
-
* The child logger inherits all context from the parent and adds new context.
|
|
94
|
-
* This is useful for adding request-specific context without passing through parameters.
|
|
95
|
-
*
|
|
96
|
-
* @param context Additional context to merge
|
|
97
|
-
* @returns New logger instance with merged context
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* const logger = createLogger({ component: 'sandbox-do', traceId: 'tr_abc123' });
|
|
101
|
-
* const execLogger = logger.child({ commandId: 'cmd-456' });
|
|
102
|
-
* execLogger.info('Command started'); // Includes all context: component, traceId, commandId
|
|
103
|
-
*/
|
|
104
|
-
child(context: Partial<LogContext>): Logger;
|
|
105
|
-
}
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region src/container-control/connection.d.ts
|
|
108
|
-
/** Stub that can issue a WebSocket-upgrade fetch through the DO's Container base class. */
|
|
109
|
-
interface ContainerFetchStub {
|
|
110
|
-
fetch(request: Request): Promise<Response>;
|
|
111
|
-
}
|
|
112
|
-
interface ContainerControlConnectionOptions {
|
|
113
|
-
stub: ContainerFetchStub;
|
|
114
|
-
port?: number;
|
|
115
|
-
logger?: Logger;
|
|
116
|
-
/**
|
|
117
|
-
* Total retry budget (ms) for retryable upgrade responses while the
|
|
118
|
-
* container is unavailable. Defaults to 120 000 (2 minutes). Set to 0 to
|
|
119
|
-
* disable retries.
|
|
120
|
-
*/
|
|
121
|
-
retryTimeoutMs?: number;
|
|
122
|
-
/**
|
|
123
|
-
* Optional `localMain` exposed to the container side of the capnweb
|
|
124
|
-
* session. The container reaches it via
|
|
125
|
-
* `session.getRemoteMain()` and uses it for control-plane callbacks
|
|
126
|
-
* (e.g. notifying the DO when a tunnel's cloudflared process has
|
|
127
|
-
* exited). When omitted, the container sees an empty remote main.
|
|
128
|
-
*/
|
|
129
|
-
localMain?: SandboxControlCallback & RpcTarget;
|
|
130
|
-
/**
|
|
131
|
-
* Invoked when an active WebSocket transitions to closed/errored.
|
|
132
|
-
* Fired at most once per successful connection from the WS event
|
|
133
|
-
* handlers in `doConnect`. Gives owners a synchronous teardown
|
|
134
|
-
* signal so recovery doesn't depend on a periodic poller running
|
|
135
|
-
* inside what may be an idle isolate.
|
|
136
|
-
*
|
|
137
|
-
* Also fired for `doConnect` failures after the deferred transport is
|
|
138
|
-
* aborted. A failed upgrade poisons the transport, so owners must discard
|
|
139
|
-
* the connection and create a fresh one for subsequent calls. Not fired for
|
|
140
|
-
* `disconnect()`.
|
|
141
|
-
*/
|
|
142
|
-
onClose?: () => void;
|
|
143
|
-
}
|
|
144
|
-
//#endregion
|
|
145
|
-
//#region src/container-control/client.d.ts
|
|
146
|
-
|
|
147
|
-
interface ContainerControlClientOptions extends ContainerControlConnectionOptions {
|
|
148
|
-
/** Idle timeout before disconnecting the WebSocket (ms). Defaults to 1 000. */
|
|
149
|
-
idleDisconnectMs?: number;
|
|
150
|
-
/** Busy/idle poll interval (ms). Defaults to 1 000. */
|
|
151
|
-
busyPollIntervalMs?: number;
|
|
152
|
-
/**
|
|
153
|
-
* Renew the DO's activity timeout. Fires at the start of every RPC call
|
|
154
|
-
* and on every busy-poll tick while the session has work in flight.
|
|
155
|
-
* Mirrors what `containerFetch()` does at the top of each HTTP request.
|
|
156
|
-
*/
|
|
157
|
-
onActivity?: () => void;
|
|
158
|
-
/**
|
|
159
|
-
* Fires once when the capnweb session transitions from idle to busy
|
|
160
|
-
* (an RPC call was started or a stream return is now in flight). The
|
|
161
|
-
* Sandbox DO wires this to increment the Container base class's
|
|
162
|
-
* in-flight request counter, which makes `isActivityExpired()` skip the
|
|
163
|
-
* sleepAfter comparison.
|
|
164
|
-
*/
|
|
165
|
-
onSessionBusy?: () => void;
|
|
166
|
-
/**
|
|
167
|
-
* Fires once when the session transitions from busy back to idle
|
|
168
|
-
* (all RPC promises settled and all stream exports released). The
|
|
169
|
-
* Sandbox DO wires this to `inflightRequests = max(0, n-1)` and a
|
|
170
|
-
* final `renewActivityTimeout()`, matching containerFetch's finally
|
|
171
|
-
* block.
|
|
172
|
-
*/
|
|
173
|
-
onSessionIdle?: () => void;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Sandbox control facade backed by direct capnweb RPC.
|
|
177
|
-
*
|
|
178
|
-
* All operations call the container's SandboxAPI control interface directly
|
|
179
|
-
* over capnweb, bypassing the HTTP handler/router layer entirely.
|
|
180
|
-
*
|
|
181
|
-
* Manages its own WebSocket lifecycle: a fresh `ContainerControlConnection` is
|
|
182
|
-
* created on demand and torn down after `idleDisconnectMs` of inactivity.
|
|
183
|
-
* Busy/idle detection relies on `RpcSession.getStats()` which tracks all
|
|
184
|
-
* in-flight RPC calls and stream exports — including long-lived streaming
|
|
185
|
-
* RPCs that would be invisible to a simple per-call request counter (see
|
|
186
|
-
* the file-level comment for the full rationale).
|
|
187
|
-
*/
|
|
188
|
-
declare class ContainerControlClient {
|
|
189
|
-
private readonly connOptions;
|
|
190
|
-
private readonly idleDisconnectMs;
|
|
191
|
-
private readonly busyPollIntervalMs;
|
|
192
|
-
private readonly logger;
|
|
193
|
-
private readonly onActivity;
|
|
194
|
-
private readonly onSessionBusy;
|
|
195
|
-
private readonly onSessionIdle;
|
|
196
|
-
private conn;
|
|
197
|
-
private idleTimer;
|
|
198
|
-
private busyPollTimer;
|
|
199
|
-
/** Tracks whether we currently believe the session is busy. */
|
|
200
|
-
private busy;
|
|
201
|
-
constructor(options: ContainerControlClientOptions);
|
|
202
|
-
/**
|
|
203
|
-
* Return the current connection, creating one when the client is disconnected.
|
|
204
|
-
* Starts the busy-poll timer the first time a connection is materialized.
|
|
205
|
-
*/
|
|
206
|
-
private getConnection;
|
|
207
|
-
/**
|
|
208
|
-
* Called synchronously at the start of each RPC method invocation.
|
|
209
|
-
* Renews the DO activity timeout so the sleepAfter alarm is pushed
|
|
210
|
-
* forward before the container processes the call.
|
|
211
|
-
*/
|
|
212
|
-
private renewActivity;
|
|
213
|
-
/**
|
|
214
|
-
* Sample `getStats()` and update busy/idle state. While busy, renews the
|
|
215
|
-
* activity timeout each tick so an in-flight stream keeps pushing the
|
|
216
|
-
* sleepAfter deadline forward. On the busy → idle edge, fires
|
|
217
|
-
* `onSessionIdle` and schedules the WebSocket disconnect.
|
|
218
|
-
*
|
|
219
|
-
* If the WebSocket has dropped underneath us (container crash, network
|
|
220
|
-
* blip) we tear the connection down here. `destroyConnection()` fires
|
|
221
|
-
* `onSessionIdle` if we were busy, so the DO's inflight counter doesn't
|
|
222
|
-
* stay pinned forever waiting for a peer that's never going to reply.
|
|
223
|
-
*/
|
|
224
|
-
private pollBusyState;
|
|
225
|
-
private startBusyPoll;
|
|
226
|
-
private stopBusyPoll;
|
|
227
|
-
private scheduleIdleDisconnect;
|
|
228
|
-
private clearIdleTimer;
|
|
229
|
-
private destroyConnection;
|
|
230
|
-
get commands(): SandboxCommandsAPI;
|
|
231
|
-
get files(): SandboxFilesAPI;
|
|
232
|
-
get processes(): SandboxProcessesAPI;
|
|
233
|
-
get ports(): SandboxPortsAPI;
|
|
234
|
-
get utils(): SandboxUtilsAPI;
|
|
235
|
-
get backup(): SandboxBackupAPI;
|
|
236
|
-
get watch(): SandboxWatchAPI;
|
|
237
|
-
get tunnels(): SandboxTunnelsAPI;
|
|
238
|
-
get terminals(): SandboxTerminalsAPI;
|
|
239
|
-
get extensions(): SandboxExtensionsAPI;
|
|
240
|
-
/**
|
|
241
|
-
* Update the upgrade retry budget. Applies to the current connection
|
|
242
|
-
* (if any) and is remembered for any future connections created after the
|
|
243
|
-
* client is torn down and reconnected.
|
|
244
|
-
*/
|
|
245
|
-
setRetryTimeoutMs(ms: number): void;
|
|
246
|
-
isWebSocketConnected(): boolean;
|
|
247
|
-
connect(): Promise<void>;
|
|
248
|
-
disconnect(): void;
|
|
249
|
-
}
|
|
250
|
-
//#endregion
|
|
251
|
-
//#region src/backup/restore-fault-injection.d.ts
|
|
252
|
-
type BackupRestoreFaultPhase = 'after_archive_ready';
|
|
253
|
-
type BackupRestoreTestFault = {
|
|
254
|
-
phase: BackupRestoreFaultPhase;
|
|
255
|
-
mode: 'transport_disposed';
|
|
256
|
-
times: number;
|
|
257
|
-
};
|
|
258
|
-
//#endregion
|
|
259
|
-
//#region src/storage-mount/errors.d.ts
|
|
260
|
-
/**
|
|
261
|
-
* Base error for bucket mounting operations
|
|
262
|
-
*/
|
|
263
|
-
declare class BucketMountError extends Error {
|
|
264
|
-
readonly code: ErrorCode;
|
|
265
|
-
constructor(message: string, code?: ErrorCode);
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Thrown when S3FS mount command fails
|
|
269
|
-
*/
|
|
270
|
-
declare class S3FSMountError extends BucketMountError {
|
|
271
|
-
constructor(message: string);
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Thrown when fusermount -u fails to unmount a FUSE filesystem
|
|
275
|
-
*/
|
|
276
|
-
declare class BucketUnmountError extends BucketMountError {
|
|
277
|
-
constructor(message: string);
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Thrown when no credentials found in environment
|
|
281
|
-
*/
|
|
282
|
-
declare class MissingCredentialsError extends BucketMountError {
|
|
283
|
-
constructor(message: string);
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Thrown when bucket name, mount path, or options are invalid
|
|
287
|
-
*/
|
|
288
|
-
declare class InvalidMountConfigError extends BucketMountError {
|
|
289
|
-
constructor(message: string);
|
|
290
|
-
}
|
|
291
|
-
//#endregion
|
|
292
|
-
//#region src/storage-mount/outbound/container-proxy.d.ts
|
|
293
|
-
declare class ContainerProxy$1 extends ContainerProxy {
|
|
294
|
-
fetch(request: Request): Promise<Response>;
|
|
295
|
-
}
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region src/tunnels/tunnel-service.d.ts
|
|
298
|
-
interface TunnelsHandler {
|
|
299
|
-
get(port: number, options?: TunnelOptions): Promise<TunnelInfo>;
|
|
300
|
-
list(): Promise<TunnelInfo[]>;
|
|
301
|
-
destroy(portOrInfo: number | TunnelInfo): Promise<void>;
|
|
302
|
-
}
|
|
303
|
-
//#endregion
|
|
304
|
-
//#region src/sandbox.d.ts
|
|
305
|
-
type SandboxConfiguration = {
|
|
306
|
-
sandboxName?: {
|
|
307
|
-
name: string;
|
|
308
|
-
normalizeId?: boolean;
|
|
309
|
-
};
|
|
310
|
-
sleepAfter?: string | number;
|
|
311
|
-
keepAlive?: boolean;
|
|
312
|
-
containerTimeouts?: NonNullable<SandboxOptions['containerTimeouts']>;
|
|
313
|
-
};
|
|
314
|
-
declare function getSandbox<T extends Sandbox<any>>(ns: DurableObjectNamespace<T>, id: string, options?: SandboxOptions): T;
|
|
315
|
-
declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox {
|
|
316
|
-
defaultPort: number;
|
|
317
|
-
sleepAfter: string | number;
|
|
318
|
-
client: ContainerControlClient;
|
|
319
|
-
private sandboxName;
|
|
320
|
-
private tunnelServiceHandle;
|
|
321
|
-
private tunnelsHandler;
|
|
322
|
-
private tunnelExitHandler;
|
|
323
|
-
private readonly controlCallback;
|
|
324
|
-
private normalizeId;
|
|
325
|
-
envVars: Record<string, string>;
|
|
326
|
-
private logger;
|
|
327
|
-
private keepAliveEnabled;
|
|
328
|
-
private bucketMounts;
|
|
329
|
-
private currentRuntime;
|
|
330
|
-
private currentLifetime;
|
|
331
|
-
private backupService;
|
|
332
|
-
private previewService;
|
|
333
|
-
private r2AccessKeyId;
|
|
334
|
-
private r2SecretAccessKey;
|
|
335
|
-
private namedTunnelConfigResolver;
|
|
336
|
-
/**
|
|
337
|
-
* Default container startup timeouts (conservative for production)
|
|
338
|
-
* Based on Cloudflare docs: "Containers take several minutes to provision"
|
|
339
|
-
*/
|
|
340
|
-
private readonly DEFAULT_CONTAINER_TIMEOUTS;
|
|
341
|
-
/**
|
|
342
|
-
* Active container timeout configuration
|
|
343
|
-
* Can be set via options, env vars, or defaults
|
|
344
|
-
*/
|
|
345
|
-
private containerTimeouts;
|
|
346
|
-
/**
|
|
347
|
-
* True once containerTimeouts has been written to storage at least once
|
|
348
|
-
* (either via setContainerTimeouts or restored on cold start). Gates the
|
|
349
|
-
* idempotency check in setContainerTimeouts so a first explicit call
|
|
350
|
-
* persists even when the requested values already equal the in-memory
|
|
351
|
-
* defaults, distinguishing "user intent recorded" from "running on
|
|
352
|
-
* env/SDK defaults".
|
|
353
|
-
*/
|
|
354
|
-
private hasStoredContainerTimeouts;
|
|
355
|
-
/**
|
|
356
|
-
* Dispatch method for tunnel operations.
|
|
357
|
-
* Called by the client-side proxy created in getSandbox() to provide
|
|
358
|
-
* the `sandbox.tunnels` API without relying on RPC pipelining through
|
|
359
|
-
* property getters, which vite-plugin does not currently support. This
|
|
360
|
-
* local method dispatch uses standard function application, so new
|
|
361
|
-
* Workers RPC pipelining traits on `TunnelsRpcTarget` also need an
|
|
362
|
-
* explicit path here before the proxy can expose them.
|
|
363
|
-
*/
|
|
364
|
-
callTunnels(method: string, args: unknown[]): Promise<unknown>;
|
|
365
|
-
callExtension(extensionName: string, method: string, args: unknown[]): Promise<unknown>;
|
|
366
|
-
/**
|
|
367
|
-
* Compute the control-channel upgrade retry budget from current container
|
|
368
|
-
* timeouts.
|
|
369
|
-
*
|
|
370
|
-
* The budget covers the full container startup window (instance provisioning
|
|
371
|
-
* + port readiness) plus a 30s margin for the maximum single backoff delay.
|
|
372
|
-
* The 120s floor preserves the default for short timeout configurations.
|
|
373
|
-
*/
|
|
374
|
-
private computeRetryTimeoutMs;
|
|
375
|
-
/**
|
|
376
|
-
* Create the single control-plane client used for all SDK operations.
|
|
377
|
-
*/
|
|
378
|
-
private createClient;
|
|
379
|
-
constructor(ctx: DurableObjectState<{}>, env: Env);
|
|
380
|
-
setSandboxName(name: string, normalizeId?: boolean): Promise<void>;
|
|
381
|
-
configure(configuration: SandboxConfiguration): Promise<void>;
|
|
382
|
-
setSleepAfter(sleepAfter: string | number): Promise<void>;
|
|
383
|
-
setKeepAlive(keepAlive: boolean): Promise<void>;
|
|
384
|
-
setEnvVars(envVars: Record<string, string | undefined>): Promise<void>;
|
|
385
|
-
setContainerTimeouts(timeouts: NonNullable<SandboxOptions['containerTimeouts']>): Promise<void>;
|
|
386
|
-
private validateTimeout;
|
|
387
|
-
private getDefaultTimeouts;
|
|
388
|
-
/**
|
|
389
|
-
* Mount an S3-compatible bucket as a local directory.
|
|
390
|
-
*/
|
|
391
|
-
mountBucket(bucket: string, mountPath: string, options: MountBucketOptions): Promise<void>;
|
|
392
|
-
/**
|
|
393
|
-
* Manually unmount a bucket filesystem.
|
|
394
|
-
*/
|
|
395
|
-
unmountBucket(mountPath: string): Promise<void>;
|
|
396
|
-
/**
|
|
397
|
-
* In-flight `destroy()` promise. While set, concurrent callers coalesce
|
|
398
|
-
* onto the same teardown instead of triggering a second one. Cleared when
|
|
399
|
-
* the underlying work settles, so a later call that genuinely needs to
|
|
400
|
-
* recreate a destroyed sandbox still runs.
|
|
401
|
-
*
|
|
402
|
-
* If the underlying teardown hangs (e.g. `super.destroy()` never resolves
|
|
403
|
-
* because the Containers control plane is unresponsive), every coalesced
|
|
404
|
-
* caller hangs on the same promise until the Durable Object is evicted.
|
|
405
|
-
* This is deliberate: a second concurrent teardown would not make a stuck
|
|
406
|
-
* control plane unstuck, and spawning one would defeat the point of
|
|
407
|
-
* coalescing. Callers that need bounded waits must apply their own
|
|
408
|
-
* timeout around `destroy()`.
|
|
409
|
-
*/
|
|
410
|
-
private inflightDestroy;
|
|
411
|
-
/**
|
|
412
|
-
* Cleanup and destroy the sandbox container.
|
|
413
|
-
*
|
|
414
|
-
* Concurrent calls coalesce: if a previous `destroy()` is still in flight,
|
|
415
|
-
* subsequent calls await the same underlying work instead of starting a
|
|
416
|
-
* second teardown. A canonical `sandbox.destroy.coalesced` event is logged
|
|
417
|
-
* per coalesced call so repeated destroy traffic is observable.
|
|
418
|
-
*/
|
|
419
|
-
destroy(): Promise<void>;
|
|
420
|
-
private doDestroy;
|
|
421
|
-
onStart(): Promise<void>;
|
|
422
|
-
stop(signal?: Parameters<Container<Env>['stop']>[0]): Promise<void>;
|
|
423
|
-
/**
|
|
424
|
-
* Check if the container version matches the SDK version
|
|
425
|
-
* Logs a warning if there's a mismatch
|
|
426
|
-
*/
|
|
427
|
-
private checkVersionCompatibility;
|
|
428
|
-
onStop(): Promise<void>;
|
|
429
|
-
onError(error: unknown): void;
|
|
430
|
-
/**
|
|
431
|
-
* Override Container.containerFetch to use production-friendly timeouts
|
|
432
|
-
* Automatically starts container with longer timeouts if not running
|
|
433
|
-
*/
|
|
434
|
-
containerFetch(requestOrUrl: Request | string | URL, portOrInit?: number | RequestInit, portParam?: number): Promise<Response>;
|
|
435
|
-
/**
|
|
436
|
-
* Helper: Check if error is "no container instance available"
|
|
437
|
-
* This indicates the container VM is still being provisioned.
|
|
438
|
-
*/
|
|
439
|
-
private isNoInstanceError;
|
|
440
|
-
/**
|
|
441
|
-
* Helper: Check if error is a transient startup error that should trigger retry
|
|
442
|
-
*
|
|
443
|
-
* These errors occur during normal container startup and are recoverable:
|
|
444
|
-
* - Port not yet mapped (container starting, app not listening yet)
|
|
445
|
-
* - Connection refused (port mapped but app not ready)
|
|
446
|
-
* - Timeouts during startup (recoverable with retry)
|
|
447
|
-
* - Network transients (temporary connectivity issues)
|
|
448
|
-
*
|
|
449
|
-
* Errors NOT included (permanent failures):
|
|
450
|
-
* - "no such image" - missing Docker image
|
|
451
|
-
* - "container already exists" - name collision
|
|
452
|
-
* - Configuration errors
|
|
453
|
-
*/
|
|
454
|
-
private isTransientStartupError;
|
|
455
|
-
/**
|
|
456
|
-
* Helper: Check if error is a permanent startup failure that will never recover
|
|
457
|
-
*
|
|
458
|
-
* These errors indicate resource exhaustion, misconfiguration, or missing images.
|
|
459
|
-
* Retrying will never succeed, so the SDK should fail fast with HTTP 500.
|
|
460
|
-
*
|
|
461
|
-
* Error sources (traced from platform internals):
|
|
462
|
-
* - Container runtime: OOM, PID limit
|
|
463
|
-
* - Scheduling/provisioning: no matching app, no namespace configured
|
|
464
|
-
* - workerd container-client.c++: no such image
|
|
465
|
-
* - @cloudflare/containers: did not call start
|
|
466
|
-
*/
|
|
467
|
-
private isPermanentStartupError;
|
|
468
|
-
/**
|
|
469
|
-
* Helper: Parse containerFetch arguments (supports multiple signatures)
|
|
470
|
-
*/
|
|
471
|
-
private parseContainerFetchArgs;
|
|
472
|
-
/**
|
|
473
|
-
* Override onActivityExpired to prevent automatic shutdown when keepAlive is enabled
|
|
474
|
-
* When keepAlive is disabled, calls parent implementation which stops the container
|
|
475
|
-
*/
|
|
476
|
-
onActivityExpired(): Promise<void>;
|
|
477
|
-
private getPreviewForwardingContainer;
|
|
478
|
-
private beginPreviewForward;
|
|
479
|
-
fetch(request: Request): Promise<Response>;
|
|
480
|
-
wsConnect(request: Request, port: number): Promise<Response>;
|
|
481
|
-
terminal(_options?: TerminalOptions): SandboxTerminal;
|
|
482
|
-
createTerminal(options: TerminalCreateOptions): Promise<void>;
|
|
483
|
-
destroyTerminal(id: string): Promise<void>;
|
|
484
|
-
private determinePort;
|
|
485
|
-
/**
|
|
486
|
-
|
|
487
|
-
* Persist the container's placement ID in DO storage.
|
|
488
|
-
*
|
|
489
|
-
* Called from the session-create handshake so subsequent reads via
|
|
490
|
-
* `getContainerPlacementId()` do not require a round-trip to the container. The value
|
|
491
|
-
* is overwritten on every handshake so that container replacements (which
|
|
492
|
-
* assign a new placement ID) are reflected on the next session-create.
|
|
493
|
-
*
|
|
494
|
-
* A value of `undefined` means the handshake response omitted the field
|
|
495
|
-
* (older container, unexpected error shape) and the stored value is left
|
|
496
|
-
* untouched. `null` means the env var is not set in the container and is
|
|
497
|
-
* stored as-is so callers can distinguish "observed and absent" from "not
|
|
498
|
-
* yet observed."
|
|
499
|
-
*/
|
|
500
|
-
private capturePlacementId;
|
|
501
|
-
private validateExplicitSessionId;
|
|
502
|
-
/**
|
|
503
|
-
* Validate an optional explicit session id without creating a session.
|
|
504
|
-
*
|
|
505
|
-
* Top-level process reads are sandbox-scoped, so they only carry a public
|
|
506
|
-
* session annotation when the caller provides an explicit session id. The
|
|
507
|
-
* resolved value is only used to populate `Process.sessionId` on the returned
|
|
508
|
-
* object — it is never sent to the container API.
|
|
509
|
-
*/
|
|
510
|
-
private validateOptionalSessionId;
|
|
511
|
-
private resolveExecutionEnv;
|
|
512
|
-
private buildExecutionRequestOptions;
|
|
513
|
-
exec(command: string | string[], options?: SandboxExecOptions): SandboxProcessPromise;
|
|
514
|
-
/**
|
|
515
|
-
* Buffered, session-state-preserving execution helper. Uses the foreground
|
|
516
|
-
* session command path, preserving shell state such as cwd, aliases,
|
|
517
|
-
* functions, and exported variables.
|
|
518
|
-
*/
|
|
519
|
-
run(command: string, options?: ExecOptions & {
|
|
520
|
-
sessionId?: string;
|
|
521
|
-
}): Promise<ExecResult>;
|
|
522
|
-
runWithSessionToken(command: string, sessionId: string, options?: ExecOptions): Promise<ExecResult>;
|
|
523
|
-
/**
|
|
524
|
-
* Internal: start a process via `client.processes.startProcess` and
|
|
525
|
-
* construct a `SandboxProcess` handle that demultiplexes the log stream
|
|
526
|
-
* into `stdout` / `stderr` and resolves `exitCode` on the `exit` event.
|
|
527
|
-
*/
|
|
528
|
-
private spawnSandboxProcess;
|
|
529
|
-
private buildSandboxProcessDeps;
|
|
530
|
-
/**
|
|
531
|
-
* Execute an infrastructure command (backup, mount, env setup, etc.)
|
|
532
|
-
* tagged with origin: 'internal' so logging demotes it to debug level.
|
|
533
|
-
*/
|
|
534
|
-
private execInternal;
|
|
535
|
-
private execWithSession;
|
|
536
|
-
/**
|
|
537
|
-
* Internal command execution implementation used by public exec() and
|
|
538
|
-
* explicit session wrappers.
|
|
539
|
-
*/
|
|
540
|
-
private executeCommand;
|
|
541
|
-
private mapExecuteResponseToExecResult;
|
|
542
|
-
/**
|
|
543
|
-
* Wait for a log pattern to appear in process output
|
|
544
|
-
*/
|
|
545
|
-
private waitForLogPattern;
|
|
546
|
-
/**
|
|
547
|
-
* Wait for a port to become available (for process readiness checking)
|
|
548
|
-
*/
|
|
549
|
-
private waitForPortReady;
|
|
550
|
-
/**
|
|
551
|
-
* Wait for a process to exit
|
|
552
|
-
* Returns the exit code
|
|
553
|
-
*/
|
|
554
|
-
private waitForProcessExit;
|
|
555
|
-
/**
|
|
556
|
-
* Match a pattern against text
|
|
557
|
-
*/
|
|
558
|
-
private matchPattern;
|
|
559
|
-
/**
|
|
560
|
-
* Convert a log pattern to a human-readable string
|
|
561
|
-
*/
|
|
562
|
-
private conditionToString;
|
|
563
|
-
/**
|
|
564
|
-
* Create a ProcessReadyTimeoutError
|
|
565
|
-
*/
|
|
566
|
-
private createReadyTimeoutError;
|
|
567
|
-
/**
|
|
568
|
-
* Create a ProcessExitedBeforeReadyError
|
|
569
|
-
*/
|
|
570
|
-
private createExitedBeforeReadyError;
|
|
571
|
-
/** Re-attach to an existing process by id. */
|
|
572
|
-
getProcess(id: string, options?: ProcessQueryOptions): Promise<SandboxProcess | null>;
|
|
573
|
-
/** Return lightweight process snapshots. */
|
|
574
|
-
listProcesses(options?: ProcessQueryOptions): Promise<SandboxProcess[]>;
|
|
575
|
-
killAllProcesses(): Promise<number>;
|
|
576
|
-
cleanupCompletedProcesses(): Promise<number>;
|
|
577
|
-
getProcessLogs(id: string): Promise<{
|
|
578
|
-
stdout: string;
|
|
579
|
-
stderr: string;
|
|
580
|
-
processId: string;
|
|
581
|
-
}>;
|
|
582
|
-
/**
|
|
583
|
-
* Stream logs from a background process as a ReadableStream.
|
|
584
|
-
*/
|
|
585
|
-
streamProcessLogs(processId: string, options?: {
|
|
586
|
-
signal?: AbortSignal;
|
|
587
|
-
}): Promise<ReadableStream<Uint8Array>>;
|
|
588
|
-
mkdir(path: string, options?: {
|
|
589
|
-
recursive?: boolean;
|
|
590
|
-
sessionId?: string;
|
|
591
|
-
}): Promise<MkdirResult>;
|
|
592
|
-
writeFile(path: string, content: string | ReadableStream<Uint8Array>, options?: {
|
|
593
|
-
encoding?: string;
|
|
594
|
-
sessionId?: string;
|
|
595
|
-
}): Promise<{
|
|
596
|
-
success: boolean;
|
|
597
|
-
path: string;
|
|
598
|
-
bytesWritten: number;
|
|
599
|
-
timestamp: string;
|
|
600
|
-
} | WriteFileResult>;
|
|
601
|
-
deleteFile(path: string, options?: {
|
|
602
|
-
sessionId?: string;
|
|
603
|
-
}): Promise<DeleteFileResult>;
|
|
604
|
-
renameFile(oldPath: string, newPath: string, options?: {
|
|
605
|
-
sessionId?: string;
|
|
606
|
-
}): Promise<RenameFileResult>;
|
|
607
|
-
moveFile(sourcePath: string, destinationPath: string, options?: {
|
|
608
|
-
sessionId?: string;
|
|
609
|
-
}): Promise<MoveFileResult>;
|
|
610
|
-
/**
|
|
611
|
-
* Read a file from the sandbox.
|
|
612
|
-
*
|
|
613
|
-
* @param encoding - How to encode the returned content:
|
|
614
|
-
* - `undefined` (default): auto-detect from MIME type (text → UTF-8 string, binary → base64 string)
|
|
615
|
-
* - `'utf-8'` / `'utf8'`: always return as UTF-8 string
|
|
616
|
-
* - `'base64'`: always return as base64-encoded string
|
|
617
|
-
* - `'none'`: return a result whose `content` is a raw binary `ReadableStream<Uint8Array>`
|
|
618
|
-
* with no encoding overhead.
|
|
619
|
-
*/
|
|
620
|
-
readFile(path: string, options: {
|
|
621
|
-
encoding: 'none';
|
|
622
|
-
sessionId?: string;
|
|
623
|
-
}): Promise<ReadFileStreamResult>;
|
|
624
|
-
readFile(path: string, options?: {
|
|
625
|
-
encoding?: Exclude<FileEncoding, 'none'>;
|
|
626
|
-
sessionId?: string;
|
|
627
|
-
}): Promise<ReadFileResult>;
|
|
628
|
-
/**
|
|
629
|
-
* Stream a file from the sandbox using Server-Sent Events
|
|
630
|
-
* Returns a ReadableStream that can be consumed with streamFile() or collectFile() utilities
|
|
631
|
-
* @param path - Path to the file to stream
|
|
632
|
-
* @param options - Optional session ID
|
|
633
|
-
*/
|
|
634
|
-
readFileStream(path: string, options?: {
|
|
635
|
-
sessionId?: string;
|
|
636
|
-
}): Promise<ReadableStream<Uint8Array>>;
|
|
637
|
-
listFiles(path: string, options?: ListFilesOptions): Promise<ListFilesResult>;
|
|
638
|
-
exists(path: string, options?: {
|
|
639
|
-
sessionId?: string;
|
|
640
|
-
}): Promise<FileExistsResult>;
|
|
641
|
-
/**
|
|
642
|
-
* Watch a directory for file system changes using native inotify.
|
|
643
|
-
*
|
|
644
|
-
* The returned promise resolves only after the watcher is established on the
|
|
645
|
-
* filesystem, so callers can immediately perform actions that depend on the
|
|
646
|
-
* watch being active. The returned stream contains the full event sequence
|
|
647
|
-
* starting with the `watching` event.
|
|
648
|
-
*
|
|
649
|
-
* Consume the stream with `parseSSEStream<FileWatchSSEEvent>(stream)`.
|
|
650
|
-
*
|
|
651
|
-
* @param path - Path to watch (absolute or relative to /workspace)
|
|
652
|
-
* @param options - Watch options
|
|
653
|
-
*/
|
|
654
|
-
watch(path: string, options?: WatchOptions): Promise<ReadableStream<Uint8Array>>;
|
|
655
|
-
/**
|
|
656
|
-
* Check whether a path changed while this caller was disconnected.
|
|
657
|
-
*
|
|
658
|
-
* Pass the `version` returned from a prior call in `options.since` to learn
|
|
659
|
-
* whether the path is unchanged, changed, or needs a full resync because the
|
|
660
|
-
* retained change state was reset.
|
|
661
|
-
*
|
|
662
|
-
* @param path - Path to check (absolute or relative to /workspace)
|
|
663
|
-
* @param options - Change-check options
|
|
664
|
-
*/
|
|
665
|
-
checkChanges(path: string, options?: CheckChangesOptions): Promise<CheckChangesResult>;
|
|
666
|
-
private ensureRuntimeActiveForPreview;
|
|
667
|
-
/**
|
|
668
|
-
* Expose a port and get a preview URL for accessing services running in the sandbox
|
|
669
|
-
*
|
|
670
|
-
* Preview URL authorization survives transient container restarts, but
|
|
671
|
-
* forwarding is active only for the runtime where `exposePort()` was last
|
|
672
|
-
* called. Call `exposePort()` again after a restart to reactivate an
|
|
673
|
-
* existing URL for the current runtime.
|
|
674
|
-
*
|
|
675
|
-
* @param port - Port number to expose (1024-65535)
|
|
676
|
-
* @param options - Configuration options
|
|
677
|
-
* @param options.hostname - Your Worker's domain name (required for preview URL construction)
|
|
678
|
-
* @param options.name - Optional friendly name for the port
|
|
679
|
-
* @param options.token - Optional custom token for the preview URL (1-16 characters: lowercase letters, numbers, underscores)
|
|
680
|
-
* If not provided, a random 16-character token will be generated automatically
|
|
681
|
-
* @returns Preview URL information including the full URL, port number, and optional name
|
|
682
|
-
*
|
|
683
|
-
* @example
|
|
684
|
-
* // With auto-generated token
|
|
685
|
-
* const { url } = await sandbox.exposePort(8080, { hostname: 'example.com' });
|
|
686
|
-
* // url: https://8080-sandbox-id-abc123random4567.example.com
|
|
687
|
-
*
|
|
688
|
-
* @example
|
|
689
|
-
* // With custom token for stable URLs across deployments
|
|
690
|
-
* const { url } = await sandbox.exposePort(8080, {
|
|
691
|
-
* hostname: 'example.com',
|
|
692
|
-
* token: 'my_token_v1'
|
|
693
|
-
* });
|
|
694
|
-
* // url: https://8080-sandbox-id-my_token_v1.example.com
|
|
695
|
-
*/
|
|
696
|
-
exposePort(port: number, options: {
|
|
697
|
-
name?: string;
|
|
698
|
-
hostname: string;
|
|
699
|
-
token?: string;
|
|
700
|
-
}): Promise<{
|
|
701
|
-
url: string;
|
|
702
|
-
port: number;
|
|
703
|
-
name?: string;
|
|
704
|
-
}>;
|
|
705
|
-
/**
|
|
706
|
-
* Revoke preview URL authorization and current-runtime activation for a port.
|
|
707
|
-
*
|
|
708
|
-
* Revocation is idempotent: calling this for a port with no preview state is
|
|
709
|
-
* still successful. The operation clears Durable Object-owned preview state
|
|
710
|
-
* only and does not contact, probe, wake, or clean up the container runtime.
|
|
711
|
-
*/
|
|
712
|
-
unexposePort(port: number): Promise<void>;
|
|
713
|
-
/**
|
|
714
|
-
* Returns preview URLs that are currently forwardable in the active runtime.
|
|
715
|
-
* Durable authorization without current-runtime activation is omitted.
|
|
716
|
-
*/
|
|
717
|
-
getExposedPorts(hostname: string): Promise<{
|
|
718
|
-
url: string;
|
|
719
|
-
port: number;
|
|
720
|
-
status: "active";
|
|
721
|
-
}[]>;
|
|
722
|
-
/**
|
|
723
|
-
* Returns whether a port is currently preview-forwardable.
|
|
724
|
-
* This checks Durable Object-owned auth and runtime activation without
|
|
725
|
-
* contacting or waking the container.
|
|
726
|
-
*/
|
|
727
|
-
isPortExposed(port: number): Promise<boolean>;
|
|
728
|
-
/**
|
|
729
|
-
* Checks durable preview URL authorization for a port/token pair.
|
|
730
|
-
*
|
|
731
|
-
* This does not check whether the port is activated for the current runtime
|
|
732
|
-
* and is not sufficient to decide whether preview traffic may forward.
|
|
733
|
-
*/
|
|
734
|
-
validatePortToken(port: number, token: string): Promise<boolean>;
|
|
735
|
-
/**
|
|
736
|
-
* Namespaced tunnel API. Quick tunnels are zero-config preview URLs
|
|
737
|
-
* backed by Cloudflare's trycloudflare service. Named tunnels bind a
|
|
738
|
-
* stable hostname under the configured Cloudflare zone.
|
|
739
|
-
*
|
|
740
|
-
* - `tunnels.get(port)` — idempotent. Returns the cached tunnel for
|
|
741
|
-
* `port` if one exists in DO storage, otherwise spawns a fresh
|
|
742
|
-
* cloudflared process and persists the record.
|
|
743
|
-
* - `tunnels.list()` — returns tunnels currently usable through this
|
|
744
|
-
* sandbox runtime.
|
|
745
|
-
* - `tunnels.destroy(portOrInfo)` — tear down by port number or by
|
|
746
|
-
* the record returned from `get()`.
|
|
747
|
-
*
|
|
748
|
-
* Container restarts drop quick-tunnel records because their
|
|
749
|
-
* `*.trycloudflare.com` URLs are tied to the dead cloudflared process.
|
|
750
|
-
* Named-tunnel records stay in storage and are marked for respawn so the
|
|
751
|
-
* next `get(port, { name })` call reuses the Cloudflare tunnel and DNS
|
|
752
|
-
* record while starting a fresh cloudflared process.
|
|
753
|
-
*/
|
|
754
|
-
get tunnels(): TunnelsHandler;
|
|
755
|
-
/**
|
|
756
|
-
* Lazily construct the tunnel subsystem handle. Called from the
|
|
757
|
-
* `tunnels` getter on first access and from sandbox lifecycle hooks
|
|
758
|
-
* when tunnel reconciliation or cleanup is needed.
|
|
759
|
-
*/
|
|
760
|
-
private ensureTunnelsBuilt;
|
|
761
|
-
/**
|
|
762
|
-
* Create isolated execution session for advanced use cases
|
|
763
|
-
* Returns ExecutionSession with full sandbox API bound to specific session
|
|
764
|
-
*/
|
|
765
|
-
createSession(options?: SessionOptions): Promise<ExecutionSession>;
|
|
766
|
-
/**
|
|
767
|
-
* Get an existing session by ID
|
|
768
|
-
* Returns ExecutionSession wrapper bound to the specified session
|
|
769
|
-
*
|
|
770
|
-
* This is useful for retrieving sessions across different requests/contexts
|
|
771
|
-
* without storing the ExecutionSession object (which has RPC lifecycle limitations)
|
|
772
|
-
*
|
|
773
|
-
* @param sessionId - The ID of an existing session
|
|
774
|
-
* @returns ExecutionSession wrapper bound to the session
|
|
775
|
-
*/
|
|
776
|
-
getSession(sessionId: string): Promise<ExecutionSession>;
|
|
777
|
-
/**
|
|
778
|
-
* Delete an execution session.
|
|
779
|
-
*
|
|
780
|
-
* Cleans up explicit session resources and removes them from the container.
|
|
781
|
-
*
|
|
782
|
-
* @param sessionId - The ID of the session to delete
|
|
783
|
-
* @returns Result with success status, sessionId, and timestamp
|
|
784
|
-
*/
|
|
785
|
-
deleteSession(sessionId: string): Promise<SessionDeleteResult>;
|
|
786
|
-
/**
|
|
787
|
-
* Get the Cloudflare placement ID observed for the underlying container.
|
|
788
|
-
*
|
|
789
|
-
* The placement ID is captured during the first session-create handshake
|
|
790
|
-
* after a container start and stored in Durable Object storage, so this
|
|
791
|
-
* method returns the cached value without contacting the container. A new
|
|
792
|
-
* placement ID is captured on each subsequent session-create handshake,
|
|
793
|
-
* which occurs whenever the container has been replaced.
|
|
794
|
-
*
|
|
795
|
-
* Returns `null` when a handshake has completed but the container's
|
|
796
|
-
* `CLOUDFLARE_PLACEMENT_ID` environment variable is not set (for example,
|
|
797
|
-
* in local development).
|
|
798
|
-
*
|
|
799
|
-
* Returns `undefined` when no explicit session-create handshake has been
|
|
800
|
-
* observed yet on this sandbox. Call `createSession()` to populate the value.
|
|
801
|
-
*/
|
|
802
|
-
getContainerPlacementId(): Promise<string | null | undefined>;
|
|
803
|
-
private getSessionWrapper;
|
|
804
|
-
/**
|
|
805
|
-
* Create a backup of a directory and upload it to R2.
|
|
806
|
-
*
|
|
807
|
-
* The returned DirectoryBackup handle is serializable. Store it anywhere
|
|
808
|
-
* (KV, D1, DO storage) and pass it to restoreBackup() later.
|
|
809
|
-
*
|
|
810
|
-
* Concurrent backup/restore calls on the same sandbox are serialized.
|
|
811
|
-
*/
|
|
812
|
-
createBackup(options: BackupOptions): Promise<DirectoryBackup>;
|
|
813
|
-
/**
|
|
814
|
-
* Restore a backup from R2 into a directory.
|
|
815
|
-
*
|
|
816
|
-
* Production restores use a FUSE overlay mount. Local-bucket restores stream
|
|
817
|
-
* the archive through the R2 binding and extract it with unsquashfs.
|
|
818
|
-
*
|
|
819
|
-
* Concurrent backup/restore calls on the same sandbox are serialized.
|
|
820
|
-
*/
|
|
821
|
-
restoreBackup(backup: DirectoryBackup): Promise<RestoreBackupResult>;
|
|
822
|
-
__setBackupRestoreFaultForTesting(fault: BackupRestoreTestFault | null): Promise<void>;
|
|
823
|
-
registerGitAuthInterceptor(params: HTTPAuthInterceptorParams): Promise<void>;
|
|
824
|
-
private getMountOutboundHost;
|
|
825
|
-
}
|
|
826
|
-
//#endregion
|
|
827
|
-
export { BucketUnmountError as a, S3FSMountError as c, BucketMountError as i, getSandbox as n, InvalidMountConfigError as o, ContainerProxy$1 as r, MissingCredentialsError as s, Sandbox as t };
|
|
828
|
-
//# sourceMappingURL=sandbox-DHNO89IF.d.ts.map
|