@cloudflare/sandbox 0.10.1 → 0.10.3
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 +63 -0
- package/README.md +44 -0
- package/dist/bridge/index.d.ts +0 -6
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/index.js +75 -23
- package/dist/bridge/index.js.map +1 -1
- package/dist/{errors-CBi-O-pF.js → errors-8Hvune8K.js} +2 -2
- package/dist/{errors-CBi-O-pF.js.map → errors-8Hvune8K.js.map} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/openai/index.d.ts +1 -1
- package/dist/opencode/index.d.ts +1 -1
- package/dist/opencode/index.d.ts.map +1 -1
- package/dist/opencode/index.js +1 -1
- package/dist/{sandbox-uC1vzWtG.js → sandbox-B-MUmsli.js} +1111 -160
- package/dist/sandbox-B-MUmsli.js.map +1 -0
- package/dist/{sandbox-BVgScWy9.d.ts → sandbox-CwcSm_60.d.ts} +256 -73
- package/dist/sandbox-CwcSm_60.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/sandbox-BVgScWy9.d.ts.map +0 -1
- package/dist/sandbox-uC1vzWtG.js.map +0 -1
|
@@ -24,21 +24,29 @@ interface DesktopProcessHealth {
|
|
|
24
24
|
uptime?: number;
|
|
25
25
|
}
|
|
26
26
|
type DesktopImageFormat = 'png' | 'jpeg' | 'webp';
|
|
27
|
-
interface
|
|
28
|
-
|
|
27
|
+
interface DesktopScreenshotOptions {
|
|
28
|
+
/**
|
|
29
|
+
* How the SDK returns the screenshot payload to the caller.
|
|
30
|
+
* - `'base64'` (default): `data` is a base64-encoded string (also the wire format).
|
|
31
|
+
* - `'bytes'`: client-side convenience that base64-decodes the wire payload
|
|
32
|
+
* into a `Uint8Array` before returning. The wire/server contract is
|
|
33
|
+
* always base64.
|
|
34
|
+
*/
|
|
35
|
+
format?: 'base64' | 'bytes';
|
|
29
36
|
imageFormat?: DesktopImageFormat;
|
|
30
37
|
quality?: number;
|
|
31
38
|
showCursor?: boolean;
|
|
32
39
|
}
|
|
33
|
-
interface DesktopScreenshotRegionRequest extends DesktopScreenshotRequest {
|
|
34
|
-
region: DesktopScreenshotRegion;
|
|
35
|
-
}
|
|
36
40
|
interface DesktopScreenshotRegion {
|
|
37
41
|
x: number;
|
|
38
42
|
y: number;
|
|
39
43
|
width: number;
|
|
40
44
|
height: number;
|
|
41
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Screenshot payload returned to the SDK caller when `format` is `'base64'`
|
|
48
|
+
* (the default). Matches the wire shape sent by the container.
|
|
49
|
+
*/
|
|
42
50
|
interface DesktopScreenshotResult {
|
|
43
51
|
success: boolean;
|
|
44
52
|
data: string;
|
|
@@ -46,6 +54,14 @@ interface DesktopScreenshotResult {
|
|
|
46
54
|
width: number;
|
|
47
55
|
height: number;
|
|
48
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Screenshot payload returned to the SDK caller when `format: 'bytes'` is
|
|
59
|
+
* requested. The SDK client decodes the base64 wire payload into a
|
|
60
|
+
* `Uint8Array`; the server/wire contract is unchanged.
|
|
61
|
+
*/
|
|
62
|
+
interface DesktopScreenshotBytesResult extends Omit<DesktopScreenshotResult, 'data'> {
|
|
63
|
+
data: Uint8Array;
|
|
64
|
+
}
|
|
49
65
|
type DesktopMouseButton = 'left' | 'right' | 'middle';
|
|
50
66
|
type DesktopScrollDirection = 'up' | 'down' | 'left' | 'right';
|
|
51
67
|
interface DesktopCursorPosition {
|
|
@@ -568,6 +584,12 @@ interface PortWatchRequest extends PortCheckRequest {
|
|
|
568
584
|
interval?: number;
|
|
569
585
|
}
|
|
570
586
|
interface ProcessOptions extends BaseExecOptions {
|
|
587
|
+
/**
|
|
588
|
+
* Optional session ID to run the background process in.
|
|
589
|
+
*
|
|
590
|
+
* When omitted, the sandbox's default execution policy applies.
|
|
591
|
+
*/
|
|
592
|
+
sessionId?: string;
|
|
571
593
|
/**
|
|
572
594
|
* Custom process ID for later reference
|
|
573
595
|
* If not provided, a UUID will be generated
|
|
@@ -697,6 +719,12 @@ interface LogEvent {
|
|
|
697
719
|
exitCode?: number;
|
|
698
720
|
}
|
|
699
721
|
interface StreamOptions extends BaseExecOptions {
|
|
722
|
+
/**
|
|
723
|
+
* Optional session ID to run the streaming command in.
|
|
724
|
+
*
|
|
725
|
+
* When omitted, the sandbox's default execution policy applies.
|
|
726
|
+
*/
|
|
727
|
+
sessionId?: string;
|
|
700
728
|
/**
|
|
701
729
|
* Buffer size for streaming output
|
|
702
730
|
*/
|
|
@@ -755,6 +783,16 @@ interface SandboxOptions {
|
|
|
755
783
|
* Default: false
|
|
756
784
|
*/
|
|
757
785
|
keepAlive?: boolean;
|
|
786
|
+
/**
|
|
787
|
+
* When true (the default), implicit operations automatically create and reuse
|
|
788
|
+
* a persistent default shell session. Set to false to run implicit top-level
|
|
789
|
+
* operations sessionlessly, where each command spawns a fresh process with no
|
|
790
|
+
* shared shell state. Explicit per-call session IDs continue to work normally
|
|
791
|
+
* when this is false.
|
|
792
|
+
*
|
|
793
|
+
* Default: true
|
|
794
|
+
*/
|
|
795
|
+
enableDefaultSession?: boolean;
|
|
758
796
|
/**
|
|
759
797
|
* Normalize sandbox ID to lowercase for preview URL compatibility
|
|
760
798
|
*
|
|
@@ -949,6 +987,12 @@ interface FileInfo {
|
|
|
949
987
|
interface ListFilesOptions {
|
|
950
988
|
recursive?: boolean;
|
|
951
989
|
includeHidden?: boolean;
|
|
990
|
+
/**
|
|
991
|
+
* Optional session ID used to resolve relative paths and execution context.
|
|
992
|
+
*
|
|
993
|
+
* When omitted, the sandbox's default execution policy applies.
|
|
994
|
+
*/
|
|
995
|
+
sessionId?: string;
|
|
952
996
|
}
|
|
953
997
|
interface ListFilesResult {
|
|
954
998
|
success: boolean;
|
|
@@ -1146,6 +1190,8 @@ interface ProcessLogsResult {
|
|
|
1146
1190
|
}
|
|
1147
1191
|
interface ProcessCleanupResult {
|
|
1148
1192
|
success: boolean;
|
|
1193
|
+
message?: string;
|
|
1194
|
+
killedCount?: number;
|
|
1149
1195
|
cleanedCount: number;
|
|
1150
1196
|
timestamp: string;
|
|
1151
1197
|
}
|
|
@@ -1180,8 +1226,8 @@ interface ExecutionSession {
|
|
|
1180
1226
|
exec(command: string, options?: ExecOptions): Promise<ExecResult>;
|
|
1181
1227
|
execStream(command: string, options?: StreamOptions): Promise<ReadableStream<Uint8Array>>;
|
|
1182
1228
|
startProcess(command: string, options?: ProcessOptions): Promise<Process>;
|
|
1183
|
-
listProcesses(): Promise<Process[]>;
|
|
1184
|
-
getProcess(id: string): Promise<Process | null>;
|
|
1229
|
+
listProcesses(sessionId?: string): Promise<Process[]>;
|
|
1230
|
+
getProcess(id: string, sessionId?: string): Promise<Process | null>;
|
|
1185
1231
|
killProcess(id: string, signal?: string): Promise<void>;
|
|
1186
1232
|
killAllProcesses(): Promise<number>;
|
|
1187
1233
|
cleanupCompletedProcesses(): Promise<number>;
|
|
@@ -1359,10 +1405,10 @@ interface RemoteMountBucketOptions {
|
|
|
1359
1405
|
/**
|
|
1360
1406
|
* Optional prefix/subdirectory within the bucket to mount.
|
|
1361
1407
|
*
|
|
1362
|
-
* When specified, only the contents under this prefix
|
|
1363
|
-
*
|
|
1408
|
+
* When specified, only the contents under this prefix are visible at the
|
|
1409
|
+
* mount point, scoping the mount to a subdirectory of the bucket.
|
|
1364
1410
|
*
|
|
1365
|
-
* Must start with '/' (e.g., '/
|
|
1411
|
+
* Must start with '/' (e.g., '/workspaces/project123' or '/data/uploads/')
|
|
1366
1412
|
*/
|
|
1367
1413
|
prefix?: string;
|
|
1368
1414
|
}
|
|
@@ -1392,14 +1438,41 @@ interface LocalMountBucketOptions {
|
|
|
1392
1438
|
readOnly?: boolean;
|
|
1393
1439
|
}
|
|
1394
1440
|
/**
|
|
1395
|
-
* Options for mounting
|
|
1441
|
+
* Options for mounting an R2 binding via credential-less egress interception.
|
|
1396
1442
|
*/
|
|
1397
|
-
|
|
1443
|
+
interface R2BindingMountBucketOptions {
|
|
1444
|
+
/**
|
|
1445
|
+
* Must not be set — distinguishes this variant from RemoteMountBucketOptions.
|
|
1446
|
+
*/
|
|
1447
|
+
endpoint?: never;
|
|
1448
|
+
/**
|
|
1449
|
+
* Optional prefix/subdirectory within the bucket to mount.
|
|
1450
|
+
*
|
|
1451
|
+
* When specified, only the contents under this prefix will be visible
|
|
1452
|
+
* at the mount point.
|
|
1453
|
+
*/
|
|
1454
|
+
prefix?: string;
|
|
1455
|
+
/**
|
|
1456
|
+
* Mount filesystem as read-only
|
|
1457
|
+
* Default: false
|
|
1458
|
+
*/
|
|
1459
|
+
readOnly?: boolean;
|
|
1460
|
+
/**
|
|
1461
|
+
* Advanced: Override or extend s3fs options.
|
|
1462
|
+
* Provider defaults for R2 are still applied automatically.
|
|
1463
|
+
*/
|
|
1464
|
+
s3fsOptions?: string[];
|
|
1465
|
+
}
|
|
1466
|
+
/**
|
|
1467
|
+
* Options for mounting a bucket — remote (s3fs-FUSE), local (R2 binding sync),
|
|
1468
|
+
* or R2 egress (credential-less s3fs via egress interception).
|
|
1469
|
+
*/
|
|
1470
|
+
type MountBucketOptions = RemoteMountBucketOptions | LocalMountBucketOptions | R2BindingMountBucketOptions;
|
|
1398
1471
|
interface ISandbox {
|
|
1399
1472
|
exec(command: string, options?: ExecOptions): Promise<ExecResult>;
|
|
1400
1473
|
startProcess(command: string, options?: ProcessOptions): Promise<Process>;
|
|
1401
|
-
listProcesses(): Promise<Process[]>;
|
|
1402
|
-
getProcess(id: string): Promise<Process | null>;
|
|
1474
|
+
listProcesses(sessionId?: string): Promise<Process[]>;
|
|
1475
|
+
getProcess(id: string, sessionId?: string): Promise<Process | null>;
|
|
1403
1476
|
killProcess(id: string, signal?: string): Promise<void>;
|
|
1404
1477
|
killAllProcesses(): Promise<number>;
|
|
1405
1478
|
execStream(command: string, options?: StreamOptions): Promise<ReadableStream<Uint8Array>>;
|
|
@@ -1586,6 +1659,7 @@ interface SandboxCommandsAPI {
|
|
|
1586
1659
|
timeoutMs?: number;
|
|
1587
1660
|
env?: Record<string, string | undefined>;
|
|
1588
1661
|
cwd?: string;
|
|
1662
|
+
origin?: 'user' | 'internal';
|
|
1589
1663
|
}): Promise<{
|
|
1590
1664
|
success: boolean;
|
|
1591
1665
|
exitCode: number;
|
|
@@ -1598,6 +1672,7 @@ interface SandboxCommandsAPI {
|
|
|
1598
1672
|
timeoutMs?: number;
|
|
1599
1673
|
env?: Record<string, string | undefined>;
|
|
1600
1674
|
cwd?: string;
|
|
1675
|
+
origin?: 'user' | 'internal';
|
|
1601
1676
|
}): Promise<ReadableStream<Uint8Array>>;
|
|
1602
1677
|
}
|
|
1603
1678
|
interface SandboxFilesAPI {
|
|
@@ -1714,8 +1789,20 @@ interface SandboxDesktopAPI {
|
|
|
1714
1789
|
}): Promise<DesktopStartResult>;
|
|
1715
1790
|
stop(): Promise<DesktopStopResult>;
|
|
1716
1791
|
status(): Promise<DesktopStatusResult>;
|
|
1717
|
-
screenshot(options?:
|
|
1718
|
-
|
|
1792
|
+
screenshot(options?: DesktopScreenshotOptions & {
|
|
1793
|
+
format?: 'base64';
|
|
1794
|
+
}): Promise<DesktopScreenshotResult>;
|
|
1795
|
+
screenshot(options: DesktopScreenshotOptions & {
|
|
1796
|
+
format: 'bytes';
|
|
1797
|
+
}): Promise<DesktopScreenshotBytesResult>;
|
|
1798
|
+
screenshot(options?: DesktopScreenshotOptions): Promise<DesktopScreenshotResult | DesktopScreenshotBytesResult>;
|
|
1799
|
+
screenshotRegion(region: DesktopScreenshotRegion, options?: DesktopScreenshotOptions & {
|
|
1800
|
+
format?: 'base64';
|
|
1801
|
+
}): Promise<DesktopScreenshotResult>;
|
|
1802
|
+
screenshotRegion(region: DesktopScreenshotRegion, options: DesktopScreenshotOptions & {
|
|
1803
|
+
format: 'bytes';
|
|
1804
|
+
}): Promise<DesktopScreenshotBytesResult>;
|
|
1805
|
+
screenshotRegion(region: DesktopScreenshotRegion, options?: DesktopScreenshotOptions): Promise<DesktopScreenshotResult | DesktopScreenshotBytesResult>;
|
|
1719
1806
|
click(x: number, y: number, options?: {
|
|
1720
1807
|
button?: DesktopMouseButton;
|
|
1721
1808
|
clickCount?: number;
|
|
@@ -1737,18 +1824,47 @@ interface SandboxDesktopAPI {
|
|
|
1737
1824
|
scroll(x: number, y: number, direction: DesktopScrollDirection, amount?: number): Promise<void>;
|
|
1738
1825
|
getCursorPosition(): Promise<DesktopCursorPosition>;
|
|
1739
1826
|
type(text: string, options?: {
|
|
1740
|
-
|
|
1827
|
+
delayMs?: number;
|
|
1741
1828
|
}): Promise<void>;
|
|
1742
1829
|
press(key: string): Promise<void>;
|
|
1743
1830
|
keyDown(key: string): Promise<void>;
|
|
1744
1831
|
keyUp(key: string): Promise<void>;
|
|
1745
1832
|
getScreenSize(): Promise<DesktopScreenSize>;
|
|
1746
|
-
getProcessStatus(name: string): Promise<
|
|
1833
|
+
getProcessStatus(name: string): Promise<DesktopProcessHealth>;
|
|
1747
1834
|
}
|
|
1748
1835
|
interface SandboxWatchAPI {
|
|
1749
1836
|
watch(request: WatchRequest): Promise<ReadableStream<Uint8Array>>;
|
|
1750
1837
|
checkChanges(request: CheckChangesRequest): Promise<CheckChangesResult>;
|
|
1751
1838
|
}
|
|
1839
|
+
/**
|
|
1840
|
+
* Public-facing tunnel record.
|
|
1841
|
+
*
|
|
1842
|
+
* Today only quick tunnels (`*.trycloudflare.com`) are supported. Future
|
|
1843
|
+
* PRs will add named tunnels, which will carry a `name: string` field;
|
|
1844
|
+
* `TunnelInfo` will then become a discriminated union keyed on the
|
|
1845
|
+
* presence of `name`. The quick variant declares `name?: never` so the
|
|
1846
|
+
* narrowing works without a breaking change here.
|
|
1847
|
+
*/
|
|
1848
|
+
interface TunnelInfo {
|
|
1849
|
+
id: string;
|
|
1850
|
+
port: number;
|
|
1851
|
+
url: string;
|
|
1852
|
+
hostname: string;
|
|
1853
|
+
createdAt: string;
|
|
1854
|
+
/** Reserved for the named-tunnel variant in a future PR. */
|
|
1855
|
+
name?: never;
|
|
1856
|
+
}
|
|
1857
|
+
interface SandboxTunnelsAPI {
|
|
1858
|
+
/** Spawn `cloudflared tunnel --url`. No credentials required. */
|
|
1859
|
+
runQuickTunnel(id: string, port: number): Promise<TunnelInfo>;
|
|
1860
|
+
/** Stop the cloudflared process for the given tunnel id. */
|
|
1861
|
+
destroyTunnel(id: string): Promise<{
|
|
1862
|
+
success: true;
|
|
1863
|
+
id: string;
|
|
1864
|
+
}>;
|
|
1865
|
+
/** List tunnels currently running inside the container. */
|
|
1866
|
+
listTunnels(): Promise<TunnelInfo[]>;
|
|
1867
|
+
}
|
|
1752
1868
|
//#endregion
|
|
1753
1869
|
//#region src/clients/types.d.ts
|
|
1754
1870
|
/**
|
|
@@ -1955,7 +2071,7 @@ declare abstract class BaseHttpClient {
|
|
|
1955
2071
|
* The container creates/extracts squashfs archives locally.
|
|
1956
2072
|
* R2 upload/download is handled by the Sandbox DO, not by this client.
|
|
1957
2073
|
*/
|
|
1958
|
-
declare class BackupClient extends BaseHttpClient {
|
|
2074
|
+
declare class BackupClient extends BaseHttpClient implements SandboxBackupAPI {
|
|
1959
2075
|
/**
|
|
1960
2076
|
* Tell the container to create a squashfs archive from a directory.
|
|
1961
2077
|
* @param dir - Directory to back up
|
|
@@ -1990,7 +2106,7 @@ interface ExecuteResponse extends BaseApiResponse {
|
|
|
1990
2106
|
/**
|
|
1991
2107
|
* Client for command execution operations
|
|
1992
2108
|
*/
|
|
1993
|
-
declare class CommandClient extends BaseHttpClient {
|
|
2109
|
+
declare class CommandClient extends BaseHttpClient implements SandboxCommandsAPI {
|
|
1994
2110
|
/**
|
|
1995
2111
|
* Execute a command and return the complete result
|
|
1996
2112
|
* @param command - The command to execute
|
|
@@ -2118,16 +2234,12 @@ interface Desktop {
|
|
|
2118
2234
|
keyDown(key: KeyInput): Promise<void>;
|
|
2119
2235
|
keyUp(key: KeyInput): Promise<void>;
|
|
2120
2236
|
getScreenSize(): Promise<ScreenSizeResponse>;
|
|
2121
|
-
getProcessStatus(name: string): Promise<
|
|
2122
|
-
running: boolean;
|
|
2123
|
-
pid?: number;
|
|
2124
|
-
uptime?: number;
|
|
2125
|
-
}>;
|
|
2237
|
+
getProcessStatus(name: string): Promise<DesktopProcessHealth>;
|
|
2126
2238
|
}
|
|
2127
2239
|
/**
|
|
2128
2240
|
* Client for desktop environment lifecycle, input, and screen operations
|
|
2129
2241
|
*/
|
|
2130
|
-
declare class DesktopClient extends BaseHttpClient {
|
|
2242
|
+
declare class DesktopClient extends BaseHttpClient implements SandboxDesktopAPI {
|
|
2131
2243
|
/**
|
|
2132
2244
|
* Start the desktop environment with optional resolution and DPI.
|
|
2133
2245
|
*/
|
|
@@ -2231,11 +2343,7 @@ declare class DesktopClient extends BaseHttpClient {
|
|
|
2231
2343
|
/**
|
|
2232
2344
|
* Get health status for a specific desktop process.
|
|
2233
2345
|
*/
|
|
2234
|
-
getProcessStatus(name: string): Promise<
|
|
2235
|
-
running: boolean;
|
|
2236
|
-
pid?: number;
|
|
2237
|
-
uptime?: number;
|
|
2238
|
-
}>;
|
|
2346
|
+
getProcessStatus(name: string): Promise<DesktopProcessHealth>;
|
|
2239
2347
|
}
|
|
2240
2348
|
//#endregion
|
|
2241
2349
|
//#region src/clients/file-client.d.ts
|
|
@@ -2271,7 +2379,7 @@ interface FileOperationRequest extends SessionRequest {
|
|
|
2271
2379
|
/**
|
|
2272
2380
|
* Client for file system operations
|
|
2273
2381
|
*/
|
|
2274
|
-
declare class FileClient extends BaseHttpClient {
|
|
2382
|
+
declare class FileClient extends BaseHttpClient implements SandboxFilesAPI {
|
|
2275
2383
|
/**
|
|
2276
2384
|
* Create a directory
|
|
2277
2385
|
* @param path - Directory path to create
|
|
@@ -2376,7 +2484,7 @@ interface GitCheckoutRequest extends SessionRequest {
|
|
|
2376
2484
|
/**
|
|
2377
2485
|
* Client for Git repository operations
|
|
2378
2486
|
*/
|
|
2379
|
-
declare class GitClient extends BaseHttpClient {
|
|
2487
|
+
declare class GitClient extends BaseHttpClient implements SandboxGitAPI {
|
|
2380
2488
|
private static readonly REQUEST_TIMEOUT_BUFFER_MS;
|
|
2381
2489
|
constructor(options?: HttpClientOptions);
|
|
2382
2490
|
/**
|
|
@@ -2402,7 +2510,7 @@ interface ExecutionCallbacks {
|
|
|
2402
2510
|
onResult?: (result: Result) => void | Promise<void>;
|
|
2403
2511
|
onError?: (error: ExecutionError) => void | Promise<void>;
|
|
2404
2512
|
}
|
|
2405
|
-
declare class InterpreterClient extends BaseHttpClient {
|
|
2513
|
+
declare class InterpreterClient extends BaseHttpClient implements SandboxInterpreterAPI {
|
|
2406
2514
|
private readonly maxRetries;
|
|
2407
2515
|
private readonly retryDelayMs;
|
|
2408
2516
|
createCodeContext(options?: CreateContextOptions): Promise<CodeContext>;
|
|
@@ -2434,7 +2542,7 @@ interface UnexposePortRequest {
|
|
|
2434
2542
|
/**
|
|
2435
2543
|
* Client for port management and preview URL operations
|
|
2436
2544
|
*/
|
|
2437
|
-
declare class PortClient extends BaseHttpClient {
|
|
2545
|
+
declare class PortClient extends BaseHttpClient implements SandboxPortsAPI {
|
|
2438
2546
|
/**
|
|
2439
2547
|
* Expose a port and get a preview URL
|
|
2440
2548
|
* @param port - Port number to expose
|
|
@@ -2465,7 +2573,7 @@ declare class PortClient extends BaseHttpClient {
|
|
|
2465
2573
|
/**
|
|
2466
2574
|
* Client for background process management
|
|
2467
2575
|
*/
|
|
2468
|
-
declare class ProcessClient extends BaseHttpClient {
|
|
2576
|
+
declare class ProcessClient extends BaseHttpClient implements SandboxProcessesAPI {
|
|
2469
2577
|
/**
|
|
2470
2578
|
* Start a background process
|
|
2471
2579
|
* @param command - Command to execute as a background process
|
|
@@ -2562,7 +2670,7 @@ interface DeleteSessionResponse extends BaseApiResponse {
|
|
|
2562
2670
|
/**
|
|
2563
2671
|
* Client for health checks and utility operations
|
|
2564
2672
|
*/
|
|
2565
|
-
declare class UtilityClient extends BaseHttpClient {
|
|
2673
|
+
declare class UtilityClient extends BaseHttpClient implements SandboxUtilsAPI {
|
|
2566
2674
|
/**
|
|
2567
2675
|
* Ping the sandbox to check if it's responsive
|
|
2568
2676
|
*/
|
|
@@ -2586,6 +2694,9 @@ declare class UtilityClient extends BaseHttpClient {
|
|
|
2586
2694
|
* Returns the version embedded in the Docker image during build
|
|
2587
2695
|
*/
|
|
2588
2696
|
getVersion(): Promise<string>;
|
|
2697
|
+
listSessions(): Promise<{
|
|
2698
|
+
sessions: string[];
|
|
2699
|
+
}>;
|
|
2589
2700
|
}
|
|
2590
2701
|
//#endregion
|
|
2591
2702
|
//#region src/clients/watch-client.d.ts
|
|
@@ -2596,7 +2707,7 @@ declare class UtilityClient extends BaseHttpClient {
|
|
|
2596
2707
|
* @internal This client is used internally by the SDK.
|
|
2597
2708
|
* Users should use `sandbox.watch()` or `sandbox.checkChanges()` instead.
|
|
2598
2709
|
*/
|
|
2599
|
-
declare class WatchClient extends BaseHttpClient {
|
|
2710
|
+
declare class WatchClient extends BaseHttpClient implements SandboxWatchAPI {
|
|
2600
2711
|
/**
|
|
2601
2712
|
* Check whether a path changed since a previously returned version.
|
|
2602
2713
|
*/
|
|
@@ -2640,6 +2751,13 @@ declare class SandboxClient {
|
|
|
2640
2751
|
readonly utils: UtilityClient;
|
|
2641
2752
|
readonly desktop: DesktopClient;
|
|
2642
2753
|
readonly watch: WatchClient;
|
|
2754
|
+
/**
|
|
2755
|
+
* Tunnels are RPC-only — the route-based transport does not implement them.
|
|
2756
|
+
* This getter exists so the `PublicKeys<SandboxClient> satisfies
|
|
2757
|
+
* PublicKeys<SandboxAPI>` compile-time check holds. Calling any method on
|
|
2758
|
+
* the returned proxy throws a clear `RPC transport required` error.
|
|
2759
|
+
*/
|
|
2760
|
+
readonly tunnels: never;
|
|
2643
2761
|
private transport;
|
|
2644
2762
|
constructor(options: HttpClientOptions);
|
|
2645
2763
|
/**
|
|
@@ -2686,6 +2804,25 @@ interface ContainerControlConnectionOptions {
|
|
|
2686
2804
|
* `WebSocketTransport`. Set to 0 to disable retries.
|
|
2687
2805
|
*/
|
|
2688
2806
|
retryTimeoutMs?: number;
|
|
2807
|
+
/**
|
|
2808
|
+
* Optional `localMain` exposed to the container side of the capnweb
|
|
2809
|
+
* session. The container reaches it via
|
|
2810
|
+
* `session.getRemoteMain()` and uses it for control-plane callbacks
|
|
2811
|
+
* (e.g. notifying the DO when a tunnel's cloudflared process has
|
|
2812
|
+
* exited). When omitted, the container sees an empty remote main.
|
|
2813
|
+
*/
|
|
2814
|
+
localMain?: any;
|
|
2815
|
+
/**
|
|
2816
|
+
* Invoked when an active WebSocket transitions to closed/errored.
|
|
2817
|
+
* Fired at most once per successful connection from the WS event
|
|
2818
|
+
* handlers in `doConnect`. Gives owners a synchronous teardown
|
|
2819
|
+
* signal so recovery doesn't depend on a periodic poller running
|
|
2820
|
+
* inside what may be an idle isolate.
|
|
2821
|
+
*
|
|
2822
|
+
* Not fired for `doConnect` failures (the rejected `connect()`
|
|
2823
|
+
* promise is the signal in that case) nor for `disconnect()`.
|
|
2824
|
+
*/
|
|
2825
|
+
onClose?: () => void;
|
|
2689
2826
|
}
|
|
2690
2827
|
//#endregion
|
|
2691
2828
|
//#region src/container-control/client.d.ts
|
|
@@ -2742,13 +2879,6 @@ declare class ContainerControlClient {
|
|
|
2742
2879
|
private busyPollTimer;
|
|
2743
2880
|
/** Tracks whether we currently believe the session is busy. */
|
|
2744
2881
|
private busy;
|
|
2745
|
-
/**
|
|
2746
|
-
* Set the first time the poller observes `conn.isConnected() === true`,
|
|
2747
|
-
* cleared in `destroyConnection()`. Lets us distinguish "the WebSocket
|
|
2748
|
-
* upgrade is still in progress" (don't tear down) from "we were
|
|
2749
|
-
* connected and the peer went away" (do tear down).
|
|
2750
|
-
*/
|
|
2751
|
-
private wasEverConnected;
|
|
2752
2882
|
constructor(options: ContainerControlClientOptions);
|
|
2753
2883
|
/**
|
|
2754
2884
|
* Return the current connection, creating one when the client is disconnected.
|
|
@@ -2787,6 +2917,7 @@ declare class ContainerControlClient {
|
|
|
2787
2917
|
get backup(): SandboxBackupAPI;
|
|
2788
2918
|
get desktop(): SandboxDesktopAPI;
|
|
2789
2919
|
get watch(): SandboxWatchAPI;
|
|
2920
|
+
get tunnels(): SandboxTunnelsAPI;
|
|
2790
2921
|
get interpreter(): SandboxInterpreterAPI;
|
|
2791
2922
|
/**
|
|
2792
2923
|
* Update the 503 upgrade-retry budget. Applies to the current connection
|
|
@@ -2800,6 +2931,13 @@ declare class ContainerControlClient {
|
|
|
2800
2931
|
disconnect(): void;
|
|
2801
2932
|
}
|
|
2802
2933
|
//#endregion
|
|
2934
|
+
//#region src/tunnels/tunnels-handler.d.ts
|
|
2935
|
+
interface TunnelsHandler {
|
|
2936
|
+
get(port: number): Promise<TunnelInfo>;
|
|
2937
|
+
list(): Promise<TunnelInfo[]>;
|
|
2938
|
+
destroy(portOrInfo: number | TunnelInfo): Promise<void>;
|
|
2939
|
+
}
|
|
2940
|
+
//#endregion
|
|
2803
2941
|
//#region src/sandbox.d.ts
|
|
2804
2942
|
type SandboxConfiguration = {
|
|
2805
2943
|
sandboxName?: {
|
|
@@ -2818,6 +2956,9 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
|
|
|
2818
2956
|
client: SandboxClient | ContainerControlClient;
|
|
2819
2957
|
private codeInterpreter;
|
|
2820
2958
|
private sandboxName;
|
|
2959
|
+
private tunnelsHandler;
|
|
2960
|
+
private tunnelExitHandler;
|
|
2961
|
+
private readonly controlCallback;
|
|
2821
2962
|
private normalizeId;
|
|
2822
2963
|
private defaultSession;
|
|
2823
2964
|
private containerGeneration;
|
|
@@ -2887,9 +3028,16 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
|
|
|
2887
3028
|
* Dispatch method for desktop operations.
|
|
2888
3029
|
* Called by the client-side proxy created in getSandbox() to provide
|
|
2889
3030
|
* the `sandbox.desktop.status()` API without relying on RPC pipelining
|
|
2890
|
-
* through property getters.
|
|
3031
|
+
* through property getters which is broken when using vite-plugin.
|
|
2891
3032
|
*/
|
|
2892
3033
|
callDesktop(method: string, args: unknown[]): Promise<unknown>;
|
|
3034
|
+
/**
|
|
3035
|
+
* Dispatch method for tunnel operations.
|
|
3036
|
+
* Called by the client-side proxy created in getSandbox() to provide
|
|
3037
|
+
* the `sandbox.tunnels` API without relying on RPC pipelining
|
|
3038
|
+
* through property getters which is broken when using vite-plugin.
|
|
3039
|
+
*/
|
|
3040
|
+
callTunnels(method: string, args: unknown[]): Promise<unknown>;
|
|
2893
3041
|
/**
|
|
2894
3042
|
* Compute the transport retry budget from current container timeouts.
|
|
2895
3043
|
*
|
|
@@ -2917,29 +3065,9 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
|
|
|
2917
3065
|
setSleepAfter(sleepAfter: string | number): Promise<void>;
|
|
2918
3066
|
setKeepAlive(keepAlive: boolean): Promise<void>;
|
|
2919
3067
|
setEnvVars(envVars: Record<string, string | undefined>): Promise<void>;
|
|
2920
|
-
/**
|
|
2921
|
-
* RPC method to configure container startup timeouts. Idempotent once
|
|
2922
|
-
* the values have been persisted: re-applying the same timeout set is a
|
|
2923
|
-
* no-op. The transport retry budget is recomputed only when at least
|
|
2924
|
-
* one timeout actually changes. Storage is written before the in-memory
|
|
2925
|
-
* mirror and derived state are updated.
|
|
2926
|
-
*/
|
|
2927
3068
|
setContainerTimeouts(timeouts: NonNullable<SandboxOptions['containerTimeouts']>): Promise<void>;
|
|
2928
|
-
/**
|
|
2929
|
-
* RPC method to set the transport protocol. Idempotent once the value
|
|
2930
|
-
* has been persisted: re-applying the same transport is a no-op.
|
|
2931
|
-
* Storage is written before the in-memory state and client are updated.
|
|
2932
|
-
*/
|
|
2933
3069
|
setTransport(transport: SandboxTransport): Promise<void>;
|
|
2934
|
-
/**
|
|
2935
|
-
* Validate a timeout value is within acceptable range
|
|
2936
|
-
* Throws error if invalid - used for user-provided values
|
|
2937
|
-
*/
|
|
2938
3070
|
private validateTimeout;
|
|
2939
|
-
/**
|
|
2940
|
-
* Get default timeouts with env var fallbacks and validation
|
|
2941
|
-
* Precedence: SDK defaults < Env vars < User config
|
|
2942
|
-
*/
|
|
2943
3071
|
private getDefaultTimeouts;
|
|
2944
3072
|
/**
|
|
2945
3073
|
* Mount an S3-compatible bucket as a local directory.
|
|
@@ -2959,6 +3087,13 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
|
|
|
2959
3087
|
* Local dev mount: bidirectional sync via R2 binding + file/watch APIs
|
|
2960
3088
|
*/
|
|
2961
3089
|
private mountBucketLocal;
|
|
3090
|
+
private getR2EgressParams;
|
|
3091
|
+
private validateR2EgressS3fsOptions;
|
|
3092
|
+
/**
|
|
3093
|
+
* Credential-less R2 mount: egress interception routes s3fs requests to the
|
|
3094
|
+
* R2 binding. No S3 credentials are needed in the container or Worker env.
|
|
3095
|
+
*/
|
|
3096
|
+
private mountBucketR2Egress;
|
|
2962
3097
|
/**
|
|
2963
3098
|
* Production mount: S3FS-FUSE inside the container
|
|
2964
3099
|
*/
|
|
@@ -2971,7 +3106,11 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
|
|
|
2971
3106
|
*/
|
|
2972
3107
|
unmountBucket(mountPath: string): Promise<void>;
|
|
2973
3108
|
/**
|
|
2974
|
-
*
|
|
3109
|
+
* Shared validation for mount path (absolute, not already in use).
|
|
3110
|
+
*/
|
|
3111
|
+
private validateMountPath;
|
|
3112
|
+
/**
|
|
3113
|
+
* Validate mount options for remote (FUSE) mounts
|
|
2975
3114
|
*/
|
|
2976
3115
|
private validateMountOptions;
|
|
2977
3116
|
/**
|
|
@@ -2991,6 +3130,7 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
|
|
|
2991
3130
|
* Execute S3FS mount command
|
|
2992
3131
|
*/
|
|
2993
3132
|
private executeS3FSMount;
|
|
3133
|
+
private unmountTrackedFuseMount;
|
|
2994
3134
|
/**
|
|
2995
3135
|
* In-flight `destroy()` promise. While set, concurrent callers coalesce
|
|
2996
3136
|
* onto the same teardown instead of triggering a second one. Cleared when
|
|
@@ -3116,7 +3256,24 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
|
|
|
3116
3256
|
* yet observed."
|
|
3117
3257
|
*/
|
|
3118
3258
|
private capturePlacementId;
|
|
3259
|
+
private resolveExecution;
|
|
3260
|
+
private validateExplicitSessionId;
|
|
3261
|
+
private serializeExecutionContext;
|
|
3262
|
+
private getPublicExecutionSessionId;
|
|
3263
|
+
/**
|
|
3264
|
+
* Resolves the session ID to annotate returned Process objects.
|
|
3265
|
+
*
|
|
3266
|
+
* Unlike `resolveExecution`, this is synchronous and never creates a
|
|
3267
|
+
* session. When the default session hasn't been established yet, it returns
|
|
3268
|
+
* `undefined` rather than triggering session creation. The resolved value is
|
|
3269
|
+
* only used to populate `Process.sessionId` on the returned object — it is
|
|
3270
|
+
* never sent to the container API.
|
|
3271
|
+
*/
|
|
3272
|
+
private getProcessSessionBinding;
|
|
3273
|
+
private resolveExecutionEnv;
|
|
3274
|
+
private buildExecutionRequestOptions;
|
|
3119
3275
|
exec(command: string, options?: ExecOptions): Promise<ExecResult>;
|
|
3276
|
+
execWithSessionToken(command: string, sessionId: string, options?: ExecOptions): Promise<ExecResult>;
|
|
3120
3277
|
/**
|
|
3121
3278
|
* Execute an infrastructure command (backup, mount, env setup, etc.)
|
|
3122
3279
|
* tagged with origin: 'internal' so logging demotes it to debug level.
|
|
@@ -3181,6 +3338,7 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
|
|
|
3181
3338
|
processId: string;
|
|
3182
3339
|
}>;
|
|
3183
3340
|
execStream(command: string, options?: StreamOptions): Promise<ReadableStream<Uint8Array>>;
|
|
3341
|
+
execStreamWithSessionToken(command: string, sessionId: string, options?: StreamOptions): Promise<ReadableStream<Uint8Array>>;
|
|
3184
3342
|
/**
|
|
3185
3343
|
* Internal session-aware execStream implementation
|
|
3186
3344
|
*/
|
|
@@ -3243,10 +3401,7 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
|
|
|
3243
3401
|
readFileStream(path: string, options?: {
|
|
3244
3402
|
sessionId?: string;
|
|
3245
3403
|
}): Promise<ReadableStream<Uint8Array>>;
|
|
3246
|
-
listFiles(path: string, options?:
|
|
3247
|
-
recursive?: boolean;
|
|
3248
|
-
includeHidden?: boolean;
|
|
3249
|
-
}): Promise<ListFilesResult>;
|
|
3404
|
+
listFiles(path: string, options?: ListFilesOptions): Promise<ListFilesResult>;
|
|
3250
3405
|
exists(path: string, sessionId?: string): Promise<FileExistsResult>;
|
|
3251
3406
|
/**
|
|
3252
3407
|
* Get the noVNC preview URL for browser-based desktop viewing.
|
|
@@ -3335,6 +3490,33 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
|
|
|
3335
3490
|
port: number;
|
|
3336
3491
|
status: "active" | "inactive";
|
|
3337
3492
|
}[]>;
|
|
3493
|
+
/**
|
|
3494
|
+
* Namespaced tunnel API. Quick tunnels are zero-config preview URLs
|
|
3495
|
+
* backed by Cloudflare's trycloudflare service.
|
|
3496
|
+
*
|
|
3497
|
+
* - `tunnels.get(port)` — idempotent. Returns the cached tunnel for
|
|
3498
|
+
* `port` if one exists in DO storage, otherwise spawns a fresh
|
|
3499
|
+
* cloudflared process and persists the record.
|
|
3500
|
+
* - `tunnels.list()` — records currently known to this sandbox, from
|
|
3501
|
+
* DO storage.
|
|
3502
|
+
* - `tunnels.destroy(portOrInfo)` — tear down by port number or by
|
|
3503
|
+
* the record returned from `get()`.
|
|
3504
|
+
*
|
|
3505
|
+
* Storage is cleared on container restart (`onStart`), so URLs do
|
|
3506
|
+
* not survive a container restart — the next `get(port)` call will
|
|
3507
|
+
* spawn a fresh tunnel with a new URL.
|
|
3508
|
+
*
|
|
3509
|
+
* Requires the RPC transport. Calling this on a route-based transport
|
|
3510
|
+
* throws "RPC transport required".
|
|
3511
|
+
*/
|
|
3512
|
+
get tunnels(): TunnelsHandler;
|
|
3513
|
+
/**
|
|
3514
|
+
* Lazily construct both the public tunnels handler and its sibling
|
|
3515
|
+
* exit-handler callback. Called from the `tunnels` getter on first
|
|
3516
|
+
* access and on every access after a transport swap clears both
|
|
3517
|
+
* fields.
|
|
3518
|
+
*/
|
|
3519
|
+
private ensureTunnelsBuilt;
|
|
3338
3520
|
isPortExposed(port: number): Promise<boolean>;
|
|
3339
3521
|
validatePortToken(port: number, token: string): Promise<boolean>;
|
|
3340
3522
|
private validateCustomToken;
|
|
@@ -3527,7 +3709,8 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
|
|
|
3527
3709
|
* unsquashfs for extraction instead of squashfuse + fuse-overlayfs.
|
|
3528
3710
|
*/
|
|
3529
3711
|
private doRestoreBackupLocal;
|
|
3712
|
+
private configureR2EgressOutbound;
|
|
3530
3713
|
}
|
|
3531
3714
|
//#endregion
|
|
3532
|
-
export {
|
|
3533
|
-
//# sourceMappingURL=sandbox-
|
|
3715
|
+
export { StartProcessRequest as $, DesktopStopResponse as A, ProcessOptions as At, ExecuteResponse as B, WaitForPortOptions as Bt, ClickOptions as C, PortListResult as Ct, DesktopStartOptions as D, ProcessKillResult as Dt, DesktopClient as E, ProcessInfoResult as Et, ScreenshotRegion as F, SandboxOptions as Ft, HttpClientOptions as G, PtyOptions as Gt, BaseApiResponse as H, isExecResult as Ht, ScreenshotResponse as I, SandboxTransport as It, SessionRequest as J, Execution as Jt, RequestConfig as K, CodeContext as Kt, ScrollDirection as L, SessionOptions as Lt, ScreenSizeResponse as M, ProcessStatus as Mt, ScreenshotBytesResponse as N, RemoteMountBucketOptions as Nt, DesktopStartResponse as O, ProcessListResult as Ot, ScreenshotOptions as P, RestoreBackupResult as Pt, ExposePortRequest as Q, TypeOptions as R, StreamOptions as Rt, WriteFileRequest as S, PortExposeResult as St, Desktop as T, ProcessCleanupResult as Tt, ContainerStub as U, isProcess as Ut, BackupClient as V, WatchOptions as Vt, ErrorResponse as W, isProcessStatus as Wt, TunnelInfo as X, RunCodeOptions as Xt, SandboxInterpreterAPI as Y, ExecutionResult as Yt, ExecuteRequest as Z, GitClient as _, ListFilesOptions as _t, CreateSessionRequest as a, CheckChangesResult as at, MkdirRequest as b, MountBucketOptions as bt, DeleteSessionResponse as c, ExecOptions as ct, ProcessClient as d, FileChunk as dt, BackupOptions as et, PortClient as f, FileMetadata as ft, GitCheckoutRequest as g, ISandbox as gt, InterpreterClient as h, GitCheckoutResult as ht, CommandsResponse as i, CheckChangesOptions as it, KeyInput as j, ProcessStartResult as jt, DesktopStatusResponse as k, ProcessLogsResult as kt, PingResponse as l, ExecResult as lt, ExecutionCallbacks as m, FileWatchSSEEvent as mt, getSandbox as n, BucketCredentials as nt, CreateSessionResponse as o, DirectoryBackup as ot, UnexposePortRequest as p, FileStreamEvent as pt, ResponseHandler as q, CreateContextOptions as qt, SandboxClient as r, BucketProvider as rt, DeleteSessionRequest as s, ExecEvent as st, Sandbox as t, BaseExecOptions as tt, UtilityClient as u, ExecutionSession as ut, FileClient as v, LocalMountBucketOptions as vt, CursorPositionResponse as w, Process as wt, ReadFileRequest as x, PortCloseResult as xt, FileOperationRequest as y, LogEvent as yt, CommandClient as z, WaitForLogResult as zt };
|
|
3716
|
+
//# sourceMappingURL=sandbox-CwcSm_60.d.ts.map
|