withruntime 0.11.2 → 0.14.0

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.
Files changed (171) hide show
  1. package/BLAXEL.md +2 -2
  2. package/COMPATIBILITY.md +74 -9
  3. package/DAYTONA.md +33 -5
  4. package/E2B.md +85 -24
  5. package/README.md +11 -10
  6. package/README.src.md +10 -9
  7. package/VERCEL.md +43 -5
  8. package/compatibility-lock.json +58 -49
  9. package/dist/billing-cli.d.ts +1 -1
  10. package/dist/billing-cli.js +85 -5
  11. package/dist/blaxel/errors.d.ts +14 -0
  12. package/dist/blaxel/errors.js +29 -0
  13. package/dist/blaxel/index.d.ts +2 -2
  14. package/dist/blaxel/index.js +4 -4
  15. package/dist/blaxel/interpreter.d.ts +2 -5
  16. package/dist/blaxel/sandbox.d.ts +15 -6
  17. package/dist/blaxel/sandbox.js +64 -8
  18. package/dist/blaxel/snapshot.d.ts +4 -0
  19. package/dist/blaxel/snapshot.js +4 -0
  20. package/dist/cli/logs.d.ts +21 -0
  21. package/dist/cli/logs.js +188 -0
  22. package/dist/cli-extras.d.ts +3 -3
  23. package/dist/cli-extras.js +17 -12
  24. package/dist/cli-words.d.ts +10 -1
  25. package/dist/cli-words.js +18 -0
  26. package/dist/cli.d.ts +22 -3
  27. package/dist/cli.js +647 -273
  28. package/dist/client.d.ts +2 -4
  29. package/dist/client.js +27 -11
  30. package/dist/cloudflare/errors.d.ts +143 -0
  31. package/dist/cloudflare/errors.js +167 -0
  32. package/dist/cloudflare/index.d.ts +175 -6
  33. package/dist/cloudflare/index.js +416 -26
  34. package/dist/cloudflare/interpreter.d.ts +119 -0
  35. package/dist/cloudflare/interpreter.js +223 -0
  36. package/dist/cloudflare/streams.d.ts +38 -0
  37. package/dist/cloudflare/streams.js +145 -0
  38. package/dist/cloudflare/watch.d.ts +9 -0
  39. package/dist/cloudflare/watch.js +24 -0
  40. package/dist/codesandbox/index.d.ts +216 -28
  41. package/dist/codesandbox/index.js +478 -78
  42. package/dist/compat/core.d.ts +18 -0
  43. package/dist/compat/core.js +29 -0
  44. package/dist/compat/files.d.ts +1 -0
  45. package/dist/compat/files.js +25 -5
  46. package/dist/credentials.d.ts +3 -0
  47. package/dist/credentials.js +15 -0
  48. package/dist/daytona/computer-use.d.ts +13 -4
  49. package/dist/daytona/computer-use.js +66 -8
  50. package/dist/daytona/daytona.d.ts +7 -1
  51. package/dist/daytona/daytona.js +31 -4
  52. package/dist/daytona/errors.d.ts +11 -0
  53. package/dist/daytona/errors.js +18 -0
  54. package/dist/daytona/filesystem.js +2 -1
  55. package/dist/daytona/image.d.ts +13 -9
  56. package/dist/daytona/image.js +18 -12
  57. package/dist/daytona/index.d.ts +1 -1
  58. package/dist/daytona/sandbox.d.ts +8 -2
  59. package/dist/daytona/sandbox.js +16 -2
  60. package/dist/domains/index.d.ts +9 -0
  61. package/dist/domains/index.js +10 -0
  62. package/dist/e2b/commands.d.ts +1 -1
  63. package/dist/e2b/commands.js +6 -7
  64. package/dist/e2b/errors.d.ts +17 -0
  65. package/dist/e2b/errors.js +40 -1
  66. package/dist/e2b/index.d.ts +2 -2
  67. package/dist/e2b/index.js +1 -1
  68. package/dist/e2b/sandbox.d.ts +28 -22
  69. package/dist/e2b/sandbox.js +34 -8
  70. package/dist/e2b/unsupported.js +1 -1
  71. package/dist/errors.d.ts +11 -2
  72. package/dist/errors.js +17 -5
  73. package/dist/freestyle/index.d.ts +285 -37
  74. package/dist/freestyle/index.js +656 -144
  75. package/dist/identity.d.ts +3 -0
  76. package/dist/identity.js +27 -0
  77. package/dist/images/index.d.ts +9 -0
  78. package/dist/images/index.js +10 -0
  79. package/dist/index.d.ts +3 -1
  80. package/dist/ips/index.d.ts +9 -0
  81. package/dist/ips/index.js +10 -0
  82. package/dist/jobs/index.d.ts +9 -0
  83. package/dist/jobs/index.js +10 -0
  84. package/dist/keys.js +2 -0
  85. package/dist/login.js +2 -0
  86. package/dist/machine.d.ts +27 -4
  87. package/dist/machine.js +46 -14
  88. package/dist/mcp.js +144 -20
  89. package/dist/modal/index.d.ts +339 -61
  90. package/dist/modal/index.js +781 -121
  91. package/dist/network-cli.d.ts +3 -1
  92. package/dist/network-cli.js +78 -36
  93. package/dist/networks/index.d.ts +11 -0
  94. package/dist/networks/index.js +10 -0
  95. package/dist/ports/index.d.ts +9 -0
  96. package/dist/ports/index.js +10 -0
  97. package/dist/product-names.d.ts +52 -0
  98. package/dist/product-names.js +164 -0
  99. package/dist/product-renames.d.ts +103 -0
  100. package/dist/product-renames.js +189 -0
  101. package/dist/products/api-keys.d.ts +73 -0
  102. package/dist/products/api-keys.js +23 -0
  103. package/dist/products/apps.d.ts +157 -0
  104. package/dist/products/apps.js +60 -0
  105. package/dist/products/balancers.d.ts +87 -0
  106. package/dist/products/balancers.js +8 -0
  107. package/dist/products/billing.d.ts +41 -0
  108. package/dist/products/billing.js +13 -0
  109. package/dist/products/browser.d.ts +10 -0
  110. package/dist/products/browsers.d.ts +71 -0
  111. package/dist/products/browsers.js +102 -0
  112. package/dist/products/builds.d.ts +156 -0
  113. package/dist/products/builds.js +227 -0
  114. package/dist/products/index.d.ts +5 -16
  115. package/dist/products/index.js +5 -14
  116. package/dist/products/jobs.d.ts +19 -2
  117. package/dist/products/jobs.js +28 -11
  118. package/dist/products/logs.d.ts +245 -0
  119. package/dist/products/logs.js +274 -0
  120. package/dist/products/network-products.d.ts +38 -7
  121. package/dist/products/network-products.js +31 -18
  122. package/dist/products/observability.d.ts +8 -2
  123. package/dist/products/private-network.js +1 -1
  124. package/dist/products/queues.d.ts +149 -0
  125. package/dist/products/queues.js +213 -0
  126. package/dist/products/referrals.d.ts +21 -7
  127. package/dist/products/referrals.js +3 -3
  128. package/dist/products/resources.d.ts +54 -0
  129. package/dist/products/resources.js +122 -0
  130. package/dist/products/secrets.d.ts +29 -3
  131. package/dist/products/secrets.js +47 -18
  132. package/dist/products/signed-requests.d.ts +21 -0
  133. package/dist/products/signed-requests.js +11 -0
  134. package/dist/products/streams.d.ts +73 -0
  135. package/dist/products/streams.js +17 -0
  136. package/dist/products/switching.d.ts +35 -7
  137. package/dist/products/switching.js +4 -3
  138. package/dist/products/volumes.d.ts +6 -0
  139. package/dist/record-cli.d.ts +23 -0
  140. package/dist/record-cli.js +308 -0
  141. package/dist/renamed-products.d.ts +38 -0
  142. package/dist/renamed-products.js +34 -0
  143. package/dist/runloop/index.d.ts +9 -2
  144. package/dist/runloop/index.js +29 -8
  145. package/dist/runloop/sdk.d.ts +131 -0
  146. package/dist/runloop/sdk.js +167 -0
  147. package/dist/sandbox.d.ts +7 -2
  148. package/dist/sandbox.js +41 -11
  149. package/dist/sandboxes/index.d.ts +11 -0
  150. package/dist/sandboxes/index.js +12 -0
  151. package/dist/snapshots/index.d.ts +9 -0
  152. package/dist/snapshots/index.js +11 -0
  153. package/dist/snapshots.d.ts +7 -4
  154. package/dist/sprites/index.d.ts +343 -31
  155. package/dist/sprites/index.js +866 -84
  156. package/dist/ssh.d.ts +1 -1
  157. package/dist/ssh.js +11 -11
  158. package/dist/terminal.d.ts +24 -0
  159. package/dist/terminal.js +32 -0
  160. package/dist/transport.d.ts +18 -1
  161. package/dist/transport.js +80 -6
  162. package/dist/tunnel.js +1 -1
  163. package/dist/types.d.ts +71 -4
  164. package/dist/vercel/sandbox.d.ts +1 -1
  165. package/dist/vercel/sandbox.js +6 -4
  166. package/dist/vercel/snapshot.js +10 -2
  167. package/dist/volumes/index.d.ts +9 -0
  168. package/dist/volumes/index.js +10 -0
  169. package/dist/wallet.d.ts +4 -1
  170. package/dist/wallet.js +2 -1
  171. package/package.json +48 -14
@@ -1,7 +1,13 @@
1
1
  import { Runtime } from "../client.js";
2
2
  import type { Process as NativeProcess, Sandbox as NativeSandbox } from "../sandbox.js";
3
- import { CompatibilityError, type ClientOptions } from "../compat/core.js";
3
+ import { CompatibilityError, type Refused, type RefusedAsync, type ClientOptions } from "../compat/core.js";
4
+ import { type CodeContext, type CreateContextOptions, type RunCodeOptions } from "./interpreter.js";
4
5
  export { CompatibilityError };
6
+ export * from "./errors.js";
7
+ export { CodeInterpreter } from "./interpreter.js";
8
+ export type { CodeContext, CreateContextOptions, ExecutionError, OutputMessage, RunCodeOptions, } from "./interpreter.js";
9
+ export { collectFile, isExecResult, isProcess, isProcessStatus, parseSSEStream, streamFile, } from "./streams.js";
10
+ export type { FileChunk, FileMetadata, FileStreamEvent } from "./streams.js";
5
11
  export declare class SandboxSecurityError extends Error {
6
12
  readonly code: string;
7
13
  constructor(message: string, code: string);
@@ -23,6 +29,56 @@ export interface ExecOptions {
23
29
  onComplete?: (result: ExecResult) => void;
24
30
  onError?: (error: Error) => void;
25
31
  signal?: AbortSignal;
32
+ /** Cloudflare's log level for the command; it changes nothing else. */
33
+ origin?: "user" | "internal";
34
+ }
35
+ export interface StreamOptions extends Omit<ExecOptions, "stream" | "onOutput" | "onComplete" | "onError"> {
36
+ sessionId?: string;
37
+ /** Accepted as Cloudflare accepts it: its SDK does not use it either. */
38
+ bufferSize?: number;
39
+ }
40
+ export interface WatchOptions {
41
+ recursive?: boolean;
42
+ include?: string[];
43
+ exclude?: string[];
44
+ sessionId?: string;
45
+ }
46
+ export interface CheckChangesOptions extends WatchOptions {
47
+ since?: string;
48
+ }
49
+ export type CheckChangesResult = {
50
+ success: true;
51
+ status: "unchanged" | "changed";
52
+ version: string;
53
+ timestamp: string;
54
+ } | {
55
+ success: true;
56
+ status: "resync";
57
+ reason: "expired" | "restarted";
58
+ version: string;
59
+ timestamp: string;
60
+ };
61
+ export interface GitCheckoutResult {
62
+ success: boolean;
63
+ repoUrl: string;
64
+ branch: string;
65
+ targetDir: string;
66
+ timestamp: string;
67
+ exitCode?: number;
68
+ }
69
+ export type BucketProvider = "r2" | "s3" | "gcs";
70
+ export interface MountBucketOptions {
71
+ endpoint?: string;
72
+ provider?: BucketProvider;
73
+ credentials?: {
74
+ accessKeyId: string;
75
+ secretAccessKey: string;
76
+ };
77
+ readOnly?: boolean;
78
+ s3fsOptions?: string[];
79
+ prefix?: string;
80
+ credentialProxy?: boolean;
81
+ localBucket?: boolean;
26
82
  }
27
83
  export interface ExecResult {
28
84
  success: boolean;
@@ -65,6 +121,8 @@ export interface ProcessOptions {
65
121
  cwd?: string;
66
122
  encoding?: string;
67
123
  sessionId?: string;
124
+ processId?: string;
125
+ autoCleanup?: boolean;
68
126
  onOutput?: (stream: "stdout" | "stderr", data: string) => void;
69
127
  onExit?: (code: number | null) => void;
70
128
  onStart?: (process: Process) => void;
@@ -75,12 +133,39 @@ export declare function validateSandboxConfiguration(options: Pick<SandboxOption
75
133
  * through options.runtime in Workers; Node also supports RUNTIME_API_KEY/login. */
76
134
  export declare function getSandbox(namespace: unknown, id: string, options?: SandboxOptions): Sandbox;
77
135
  export declare class Sandbox {
136
+ #private;
78
137
  readonly runtime: Runtime;
79
138
  private readonly options;
80
139
  private pending?;
81
140
  private existing?;
82
141
  readonly id: string;
142
+ /** The port Cloudflare's container serves on; Runtime previews any port. */
143
+ readonly defaultPort = 3000;
144
+ /** What setEnvVars gave this handle; the sandbox keeps them for every command. */
145
+ envVars: Record<string, string>;
146
+ readonly client: Refused;
147
+ readonly tunnels: Refused;
148
+ readonly callTunnels: RefusedAsync;
149
+ readonly setSandboxName: RefusedAsync;
150
+ readonly setContainerTimeouts: RefusedAsync;
151
+ readonly setTransport: RefusedAsync;
152
+ readonly onStart: RefusedAsync;
153
+ readonly onStop: RefusedAsync;
154
+ readonly onError: Refused;
155
+ readonly onActivityExpired: RefusedAsync;
156
+ readonly fetch: RefusedAsync;
157
+ readonly containerFetch: RefusedAsync;
158
+ readonly wsConnect: RefusedAsync;
159
+ readonly getContainerPlacementId: RefusedAsync;
160
+ readonly validatePortToken: RefusedAsync;
161
+ readonly createBackup: RefusedAsync;
162
+ readonly restoreBackup: RefusedAsync;
83
163
  constructor(runtime: Runtime, id: string, options?: SandboxOptions);
164
+ get sleepAfter(): string | number;
165
+ setSleepAfter(sleepAfter: string | number): Promise<void>;
166
+ setKeepAlive(keepAlive: boolean): Promise<void>;
167
+ /** Replaces the sandbox's labels, as Cloudflare's does. */
168
+ setLabels(labels: Record<string, string>): Promise<void>;
84
169
  configure(options: Pick<SandboxOptions, "sleepAfter" | "keepAlive">): Promise<void>;
85
170
  /** Only a successfully initialized native handle can supply a recovery id. */
86
171
  existingNativeId(): string | undefined;
@@ -91,8 +176,13 @@ export declare class Sandbox {
91
176
  }>;
92
177
  native(): Promise<NativeSandbox>;
93
178
  private session;
179
+ /** A session by id: its saved settings, or a fresh session of that id, as
180
+ * Cloudflare starts one again after its shell ended. */
181
+ private sessionFor;
94
182
  exec(command: string, options?: ExecOptions): Promise<ExecResult>;
95
- execStream(command: string, options?: ExecOptions): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
183
+ execWithSessionToken(command: string, sessionId: string, options?: ExecOptions): Promise<ExecResult>;
184
+ execStream(command: string, options?: StreamOptions): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
185
+ execStreamWithSessionToken(command: string, sessionId: string, options?: StreamOptions): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
96
186
  startProcess(command: string, options?: ProcessOptions): Promise<Process>;
97
187
  createSession(options?: SessionOptions): Promise<ExecutionSession>;
98
188
  getSession(id: string): Promise<ExecutionSession>;
@@ -103,8 +193,11 @@ export declare class Sandbox {
103
193
  }>;
104
194
  destroy(): Promise<void>;
105
195
  setEnvVars(env: Record<string, string | undefined>): Promise<void>;
196
+ /** Stops the sandbox; its files stay, and the next call starts it again. */
197
+ stop(signal?: unknown): Promise<void>;
106
198
  writeFile(path: string, content: string | ReadableStream<Uint8Array>, options?: {
107
199
  encoding?: string;
200
+ sessionId?: string;
108
201
  }): Promise<{
109
202
  success: boolean;
110
203
  path: string;
@@ -113,29 +206,38 @@ export declare class Sandbox {
113
206
  }>;
114
207
  readFile(path: string, options: {
115
208
  encoding: "none";
209
+ sessionId?: string;
116
210
  }): Promise<ReadFileStreamResult>;
117
211
  readFile(path: string, options?: {
118
212
  encoding?: "utf8" | "utf-8" | "base64";
213
+ sessionId?: string;
119
214
  }): Promise<ReadFileResult>;
215
+ /** The file as Cloudflare streams it: `data:` lines of a metadata event,
216
+ * chunks (base64 for a binary file) and a complete event; read it with
217
+ * streamFile() or collectFile(). */
218
+ readFileStream(path: string, options?: {
219
+ sessionId?: string;
220
+ }): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
120
221
  mkdir(path: string, options?: {
121
222
  recursive?: boolean;
223
+ sessionId?: string;
122
224
  }): Promise<{
123
225
  success: boolean;
124
226
  path: string;
125
227
  timestamp: string;
126
228
  }>;
127
- deleteFile(path: string): Promise<{
229
+ deleteFile(path: string, sessionId?: string): Promise<{
128
230
  success: boolean;
129
231
  path: string;
130
232
  timestamp: string;
131
233
  }>;
132
- renameFile(from: string, to: string): Promise<{
234
+ renameFile(from: string, to: string, sessionId?: string): Promise<{
133
235
  success: boolean;
134
236
  path: string;
135
237
  newPath: string;
136
238
  timestamp: string;
137
239
  }>;
138
- moveFile(from: string, to: string): Promise<{
240
+ moveFile(from: string, to: string, sessionId?: string): Promise<{
139
241
  success: boolean;
140
242
  path: string;
141
243
  newPath: string;
@@ -144,6 +246,7 @@ export declare class Sandbox {
144
246
  listFiles(path: string, options?: {
145
247
  recursive?: boolean;
146
248
  includeHidden?: boolean;
249
+ sessionId?: string;
147
250
  }): Promise<{
148
251
  success: boolean;
149
252
  path: string;
@@ -170,7 +273,7 @@ export declare class Sandbox {
170
273
  count: number;
171
274
  timestamp: string;
172
275
  }>;
173
- exists(path: string): Promise<{
276
+ exists(path: string, sessionId?: string): Promise<{
174
277
  success: boolean;
175
278
  path: string;
176
279
  exists: boolean;
@@ -195,7 +298,70 @@ export declare class Sandbox {
195
298
  name: string | undefined;
196
299
  }>;
197
300
  unexposePort(port: number): Promise<void>;
301
+ /** Runtime's previews have their own addresses: hostname is not used to build them. */
302
+ getExposedPorts(_hostname: string): Promise<{
303
+ url: string;
304
+ port: number;
305
+ status: "active";
306
+ }[]>;
307
+ isPortExposed(port: number): Promise<boolean>;
308
+ /** Cloudflare's returns 0 too: a process's record outlives it on both. */
309
+ cleanupCompletedProcesses(_sessionId?: string): Promise<number>;
310
+ /** The process's output as `data:` lines of stdout, stderr and exit events. */
311
+ streamProcessLogs(processId: string, options?: {
312
+ signal?: AbortSignal;
313
+ }): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
314
+ /** Clones with git in the sandbox, as Cloudflare's container does. */
315
+ gitCheckout(repoUrl: string, options?: {
316
+ branch?: string;
317
+ targetDir?: string;
318
+ sessionId?: string;
319
+ depth?: number;
320
+ cloneTimeoutMs?: number;
321
+ }): Promise<GitCheckoutResult>;
322
+ /** Changes under a directory as `data:` lines of Cloudflare's watch events,
323
+ * once the watch is established, until the stream is cancelled. */
324
+ watch(path: string, options?: WatchOptions): Promise<ReadableStream<Uint8Array>>;
325
+ /** Whether anything under a path changed since a version this returned:
326
+ * the version is a digest of every entry's path, size, time and mode, tied
327
+ * to this boot of the sandbox. */
328
+ checkChanges(path: string, options?: CheckChangesOptions): Promise<CheckChangesResult>;
329
+ /** Mounts an S3, R2 or Google Cloud Storage bucket with Runtime's mounts. A
330
+ * private bucket needs a Runtime secret: store its keys with
331
+ * runtime.secrets.set and mount with sandbox.mounts.add({ secret }). */
332
+ mountBucket(bucket: string, mountPath: string, options: MountBucketOptions): Promise<void>;
333
+ unmountBucket(mountPath: string): Promise<void>;
334
+ createCodeContext(options?: CreateContextOptions): Promise<CodeContext>;
335
+ runCode(code: string, options?: RunCodeOptions): Promise<{
336
+ code: string;
337
+ logs: {
338
+ stdout: string[];
339
+ stderr: string[];
340
+ };
341
+ error: import("./interpreter.js").ExecutionError | undefined;
342
+ executionCount: number | undefined;
343
+ results: {
344
+ text: string | undefined;
345
+ html: string | undefined;
346
+ png: string | undefined;
347
+ jpeg: string | undefined;
348
+ svg: string | undefined;
349
+ latex: string | undefined;
350
+ markdown: string | undefined;
351
+ javascript: string | undefined;
352
+ json: unknown;
353
+ chart: undefined;
354
+ data: Record<string, unknown> | undefined;
355
+ }[];
356
+ }>;
357
+ runCodeStream(code: string, options?: RunCodeOptions): Promise<ReadableStream<any>>;
358
+ listCodeContexts(): Promise<CodeContext[]>;
359
+ deleteCodeContext(contextId: string): Promise<void>;
198
360
  }
361
+ /** Cloudflare's Worker-side terminal proxy has no Runtime counterpart. */
362
+ export declare function proxyTerminal(..._args: unknown[]): Promise<Response>;
363
+ /** Runtime previews are served by Runtime, not through your Worker. */
364
+ export declare function proxyToSandbox(..._args: unknown[]): Promise<Response | null>;
199
365
  export declare class ExecutionSession {
200
366
  private readonly sandbox;
201
367
  readonly id: string;
@@ -205,6 +371,8 @@ export declare class ExecutionSession {
205
371
  exec(command: string, options?: ExecOptions): Promise<ExecResult>;
206
372
  execStream(command: string, options?: ExecOptions): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
207
373
  startProcess(command: string, options?: ProcessOptions): Promise<Process>;
374
+ /** A path as this session sees it: relative paths from its working directory. */
375
+ resolve(path: string): Promise<string>;
208
376
  private path;
209
377
  writeFile(path: string, content: string | ReadableStream<Uint8Array>, options?: {
210
378
  encoding?: string;
@@ -276,6 +444,7 @@ export declare class ExecutionSession {
276
444
  setEnvVars(env: Record<string, string | undefined>): Promise<void>;
277
445
  }
278
446
  export declare class Process {
447
+ #private;
279
448
  private readonly sandbox;
280
449
  private readonly native;
281
450
  readonly sessionId?: string | undefined;