withruntime 0.11.2 → 0.12.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 (164) 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 +9 -8
  6. package/README.src.md +8 -7
  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 +77 -1
  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 +14 -5
  17. package/dist/blaxel/sandbox.js +63 -7
  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/logs.test.d.ts +1 -0
  23. package/dist/cli/logs.test.js +272 -0
  24. package/dist/cli-extras.d.ts +3 -3
  25. package/dist/cli-extras.js +17 -12
  26. package/dist/cli-words.d.ts +10 -1
  27. package/dist/cli-words.js +18 -0
  28. package/dist/cli.d.ts +5 -1
  29. package/dist/cli.js +405 -204
  30. package/dist/client.d.ts +2 -4
  31. package/dist/client.js +27 -11
  32. package/dist/cloudflare/errors.d.ts +143 -0
  33. package/dist/cloudflare/errors.js +167 -0
  34. package/dist/cloudflare/index.d.ts +175 -6
  35. package/dist/cloudflare/index.js +416 -26
  36. package/dist/cloudflare/interpreter.d.ts +119 -0
  37. package/dist/cloudflare/interpreter.js +223 -0
  38. package/dist/cloudflare/streams.d.ts +38 -0
  39. package/dist/cloudflare/streams.js +145 -0
  40. package/dist/cloudflare/watch.d.ts +9 -0
  41. package/dist/cloudflare/watch.js +24 -0
  42. package/dist/codesandbox/index.d.ts +216 -28
  43. package/dist/codesandbox/index.js +478 -78
  44. package/dist/compat/core.d.ts +18 -0
  45. package/dist/compat/core.js +29 -0
  46. package/dist/compat/files.d.ts +1 -0
  47. package/dist/compat/files.js +25 -5
  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 +6 -0
  51. package/dist/daytona/daytona.js +30 -3
  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 +27 -21
  69. package/dist/e2b/sandbox.js +34 -8
  70. package/dist/e2b/unsupported.js +1 -1
  71. package/dist/errors.d.ts +10 -1
  72. package/dist/errors.js +16 -4
  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 +1 -0
  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 +12 -3
  87. package/dist/machine.js +20 -3
  88. package/dist/mcp.js +1 -1
  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/apps.d.ts +176 -0
  102. package/dist/products/apps.js +165 -0
  103. package/dist/products/billing.d.ts +41 -0
  104. package/dist/products/billing.js +13 -0
  105. package/dist/products/browser.d.ts +10 -0
  106. package/dist/products/browsers.d.ts +71 -0
  107. package/dist/products/browsers.js +102 -0
  108. package/dist/products/builds.d.ts +126 -0
  109. package/dist/products/builds.js +221 -0
  110. package/dist/products/index.d.ts +3 -16
  111. package/dist/products/index.js +3 -14
  112. package/dist/products/jobs.d.ts +17 -0
  113. package/dist/products/jobs.js +27 -10
  114. package/dist/products/logs.d.ts +245 -0
  115. package/dist/products/logs.js +274 -0
  116. package/dist/products/logs.test.d.ts +1 -0
  117. package/dist/products/logs.test.js +343 -0
  118. package/dist/products/network-products.d.ts +38 -7
  119. package/dist/products/network-products.js +31 -18
  120. package/dist/products/observability.d.ts +3 -2
  121. package/dist/products/private-network.js +1 -1
  122. package/dist/products/queues.d.ts +149 -0
  123. package/dist/products/queues.js +213 -0
  124. package/dist/products/referrals.d.ts +21 -7
  125. package/dist/products/referrals.js +3 -3
  126. package/dist/products/secrets.d.ts +7 -3
  127. package/dist/products/secrets.js +39 -18
  128. package/dist/products/signed-requests.d.ts +21 -0
  129. package/dist/products/signed-requests.js +11 -0
  130. package/dist/products/streams.d.ts +73 -0
  131. package/dist/products/streams.js +17 -0
  132. package/dist/products/switching.d.ts +35 -7
  133. package/dist/products/switching.js +4 -3
  134. package/dist/products/volumes.d.ts +3 -0
  135. package/dist/record-cli.d.ts +23 -0
  136. package/dist/record-cli.js +308 -0
  137. package/dist/renamed-products.d.ts +38 -0
  138. package/dist/renamed-products.js +34 -0
  139. package/dist/runloop/index.d.ts +9 -2
  140. package/dist/runloop/index.js +29 -8
  141. package/dist/runloop/sdk.d.ts +131 -0
  142. package/dist/runloop/sdk.js +167 -0
  143. package/dist/sandbox.d.ts +3 -2
  144. package/dist/sandbox.js +14 -9
  145. package/dist/sandboxes/index.d.ts +11 -0
  146. package/dist/sandboxes/index.js +12 -0
  147. package/dist/snapshots/index.d.ts +9 -0
  148. package/dist/snapshots/index.js +11 -0
  149. package/dist/snapshots.d.ts +7 -4
  150. package/dist/sprites/index.d.ts +343 -31
  151. package/dist/sprites/index.js +866 -84
  152. package/dist/ssh.d.ts +1 -1
  153. package/dist/ssh.js +11 -11
  154. package/dist/terminal.d.ts +24 -0
  155. package/dist/terminal.js +32 -0
  156. package/dist/transport.d.ts +15 -1
  157. package/dist/transport.js +56 -3
  158. package/dist/tunnel.js +1 -1
  159. package/dist/types.d.ts +63 -0
  160. package/dist/vercel/sandbox.js +5 -3
  161. package/dist/vercel/snapshot.js +10 -2
  162. package/dist/volumes/index.d.ts +9 -0
  163. package/dist/volumes/index.js +10 -0
  164. package/package.json +48 -2
@@ -1,6 +1,6 @@
1
1
  import type { Runtime } from "../client.js";
2
2
  import type { Sandbox as NativeSandbox, Process } from "../sandbox.js";
3
- import { CompatibilityError, type ClientOptions } from "../compat/core.js";
3
+ import { CompatibilityError, type ClientOptions, type Refused, type RefusedAsync } from "../compat/core.js";
4
4
  import { ManagedTasks } from "./guest-service.js";
5
5
  export { CompatibilityError };
6
6
  export declare class VMTier {
@@ -24,19 +24,39 @@ export declare class VMTier {
24
24
  diskGB?: number;
25
25
  }): VMTier | undefined;
26
26
  }
27
- export type CreateSandboxOpts = {
27
+ export type StartSandboxOpts = {
28
+ vmTier?: VMTier;
29
+ hibernationTimeoutSeconds?: number;
30
+ /** Runtime wakes a paused sandbox on any request, preview visit, command or
31
+ * file call: both true or both false. */
32
+ automaticWakeupConfig?: {
33
+ http: boolean;
34
+ websocket: boolean;
35
+ };
36
+ ipcountry?: string;
37
+ };
38
+ export type CreateSandboxOpts = StartSandboxOpts & {
28
39
  id?: string;
29
40
  title?: string;
30
41
  description?: string;
31
42
  tags?: string[];
32
43
  privacy?: "private" | "public" | "public-hosts" | "unlisted";
33
- vmTier?: VMTier;
34
- hibernationTimeoutSeconds?: number;
35
44
  };
36
45
  export type SessionCreateOptions = {
37
46
  id?: string;
38
47
  env?: Record<string, string>;
39
48
  permission?: "read" | "write";
49
+ git?: {
50
+ provider: string;
51
+ username?: string;
52
+ accessToken?: string;
53
+ email: string;
54
+ name?: string;
55
+ };
56
+ hostToken?: {
57
+ token: string;
58
+ sandboxId: string;
59
+ };
40
60
  };
41
61
  export type ShellRunOpts = {
42
62
  env?: Record<string, string>;
@@ -50,11 +70,28 @@ export type ShellRunOpts = {
50
70
  };
51
71
  export declare class CodeSandbox {
52
72
  readonly sandboxes: Sandboxes;
53
- constructor(apiToken?: string, options?: ClientOptions);
73
+ readonly hosts: HostTokens;
74
+ constructor(apiToken?: string, options?: ClientOptions & {
75
+ headers?: Record<string, string>;
76
+ tracer?: unknown;
77
+ });
78
+ }
79
+ /** CodeSandbox's host tokens open private previews. Runtime's private
80
+ * previews carry their own signed token: `sandbox.previews.create(port)`. */
81
+ export declare class HostTokens {
82
+ readonly createToken: RefusedAsync;
83
+ readonly listTokens: RefusedAsync;
84
+ readonly revokeToken: RefusedAsync;
85
+ readonly revokeAllTokens: RefusedAsync;
86
+ readonly updateToken: RefusedAsync;
87
+ readonly getUrl: Refused;
88
+ readonly getHeaders: Refused;
89
+ readonly getCookies: Refused;
54
90
  }
55
91
  export declare class Sandboxes {
56
92
  private readonly runtime;
57
93
  constructor(runtime: Runtime);
94
+ get defaultTemplateId(): string;
58
95
  create(options?: CreateSandboxOpts): Promise<Sandbox>;
59
96
  resume(id: string): Promise<Sandbox>;
60
97
  hibernate(id: string): Promise<void>;
@@ -63,7 +100,24 @@ export declare class Sandboxes {
63
100
  restart(id: string, options?: {
64
101
  hibernationTimeoutSeconds?: number;
65
102
  }): Promise<Sandbox>;
66
- fork(id: string, options?: Omit<CreateSandboxOpts, "id">): Promise<Sandbox>;
103
+ fork(id: string, options?: StartSandboxOpts & Pick<CreateSandboxOpts, "title" | "description" | "tags" | "privacy">): Promise<Sandbox>;
104
+ /** The account's running CodeSandbox-adapter sandboxes. Runtime has no
105
+ * per-account count of running machines, so the limit is null. */
106
+ listRunning(): Promise<{
107
+ concurrentVmCount: number;
108
+ concurrentVmLimit: number | null;
109
+ vms: {
110
+ id: string;
111
+ creditBasis: string | undefined;
112
+ lastActiveAt: Date | undefined;
113
+ sessionStartedAt: Date | undefined;
114
+ specs: {
115
+ cpu: number;
116
+ memory: number;
117
+ storage: number;
118
+ };
119
+ }[];
120
+ }>;
67
121
  get(id: string): Promise<{
68
122
  id: string;
69
123
  createdAt: Date;
@@ -108,6 +162,12 @@ export declare class Sandbox {
108
162
  constructor(native: NativeSandbox, bootupType: "RUNNING" | "CLEAN" | "RESUME" | "FORK");
109
163
  get id(): string;
110
164
  get cluster(): string;
165
+ /** Runtime's guest agent is updated with the host: always current. */
166
+ get isUpToDate(): boolean;
167
+ /** Resizes to the tier's CPUs and memory; a running sandbox restarts, as CodeSandbox's does. */
168
+ updateTier(tier: VMTier): Promise<void>;
169
+ readonly createSession: RefusedAsync;
170
+ readonly createBrowserSession: RefusedAsync;
111
171
  updateHibernationTimeout(timeoutSeconds: number): Promise<void>;
112
172
  connect(options?: SessionCreateOptions): Promise<SandboxClient>;
113
173
  }
@@ -183,6 +243,20 @@ export declare class FileSystem {
183
243
  type: string;
184
244
  isSymlink: boolean;
185
245
  }[]>;
246
+ /** Changes under a path, as CodeSandbox's add, change and remove events. */
247
+ watch(path: string, options?: {
248
+ recursive?: boolean;
249
+ excludes?: readonly string[];
250
+ }): Promise<{
251
+ onEvent: (listener: (value: {
252
+ paths: string[];
253
+ type: "add" | "change" | "remove";
254
+ }) => void) => {
255
+ dispose: () => boolean;
256
+ };
257
+ dispose: () => void;
258
+ }>;
259
+ readonly download: RefusedAsync;
186
260
  stat(path: string): Promise<{
187
261
  type: string;
188
262
  isSymlink: boolean;
@@ -192,46 +266,160 @@ export declare class FileSystem {
192
266
  ctime: number;
193
267
  }>;
194
268
  }
269
+ type SavedCommand = {
270
+ version: 1;
271
+ /** A terminal from terminals.create; absent for a command. */
272
+ kind?: "terminal";
273
+ command: string;
274
+ name?: string;
275
+ options: Parameters<NativeSandbox["spawn"]>[1];
276
+ taskId?: string;
277
+ };
278
+ type ShellSize = {
279
+ cols: number;
280
+ rows: number;
281
+ };
282
+ /** A shell CodeSandbox lists: a command's name is JSON whose type is "command". */
283
+ export declare function isCommandShell(shell: {
284
+ shellId?: string;
285
+ name: string;
286
+ status?: string;
287
+ exitCode?: number;
288
+ shellType?: string;
289
+ startCommand?: string;
290
+ ownerUsername?: string;
291
+ isSystemShell?: boolean;
292
+ }): boolean;
293
+ /** What the client's commands, terminals and ports share with it. */
294
+ type Session = {
295
+ native: NativeSandbox;
296
+ env: Record<string, string>;
297
+ workspacePath: string;
298
+ assertConnected(): void;
299
+ start(saved: SavedCommand): Promise<Process>;
300
+ attach(process: Process, saved: SavedCommand): Command;
301
+ previewURLs: Map<number, string>;
302
+ };
303
+ export declare class SandboxCommands {
304
+ private readonly session;
305
+ constructor(session: Session);
306
+ runBackground(command: string | string[], options?: ShellRunOpts): Promise<Command>;
307
+ run(command: string | string[], options?: ShellRunOpts): Promise<string>;
308
+ getAll(): Promise<Command[]>;
309
+ }
310
+ export declare class Ports {
311
+ private readonly session;
312
+ private readonly opened;
313
+ private readonly closed;
314
+ private watching?;
315
+ private known?;
316
+ private polling;
317
+ constructor(session: Session);
318
+ /** A port's events start a watch of the sandbox's listening ports, once a second. */
319
+ get onDidPortOpen(): (listener: (port: {
320
+ port: number;
321
+ host: string;
322
+ }) => void) => {
323
+ dispose: () => void;
324
+ };
325
+ get onDidPortClose(): (listener: (port: number) => void) => {
326
+ dispose: () => void;
327
+ };
328
+ private subscribe;
329
+ /** The ports listening now. */
330
+ listening(): Promise<number[]>;
331
+ private poll;
332
+ dispose(): void;
333
+ get(port: number): Promise<{
334
+ port: number;
335
+ host: string;
336
+ }>;
337
+ getAll(): Promise<{
338
+ port: number;
339
+ host: string;
340
+ }[]>;
341
+ waitForPort(port: number, options?: {
342
+ timeoutMs?: number;
343
+ }): Promise<{
344
+ port: number;
345
+ host: string;
346
+ }>;
347
+ }
348
+ /** URLs of the ports this client exposed with ports.get or listed with ports.getAll. */
349
+ export declare class Hosts {
350
+ private readonly session;
351
+ constructor(session: Session);
352
+ getUrl(port: number, protocol?: string): string;
353
+ /** Public previews need no token: nothing to send. */
354
+ getHeaders(): Record<string, string>;
355
+ getCookies(): Record<string, string>;
356
+ }
357
+ /** Interactive shells, each a process with a terminal of its own. */
358
+ export declare class Terminals {
359
+ private readonly session;
360
+ constructor(session: Session);
361
+ create(command?: "bash" | "zsh" | "fish" | "ksh" | "dash", options?: ShellRunOpts): Promise<Terminal>;
362
+ get(shellId: string): Promise<Terminal | undefined>;
363
+ getAll(): Promise<Terminal[]>;
364
+ }
365
+ export declare class Terminal {
366
+ private readonly process;
367
+ readonly name: string;
368
+ private readonly outputEvent;
369
+ readonly onOutput: (listener: (value: string) => void) => {
370
+ dispose: () => boolean;
371
+ };
372
+ private output;
373
+ private following?;
374
+ constructor(process: Process, name: string);
375
+ get id(): string;
376
+ /** Its output so far, and what it prints from now on through onOutput. */
377
+ open(dimensions?: ShellSize): Promise<string>;
378
+ write(input: string, dimensions?: ShellSize): Promise<void>;
379
+ run(input: string, dimensions?: ShellSize): Promise<void>;
380
+ kill(): Promise<void>;
381
+ }
382
+ /** One-off JavaScript and Python snippets, run as CodeSandbox runs them: the
383
+ * last line's value is printed. */
384
+ export declare class Interpreters {
385
+ private readonly commands;
386
+ constructor(commands: SandboxCommands);
387
+ javascript(code: string): Promise<string>;
388
+ python(code: string): Promise<string>;
389
+ }
195
390
  export declare class SandboxClient {
196
391
  private readonly native;
197
392
  private readonly env;
198
393
  readonly fs: FileSystem;
199
- readonly commands: {
200
- runBackground: (command: string | string[], options?: ShellRunOpts) => Promise<Command>;
201
- run: (command: string | string[], options?: ShellRunOpts) => Promise<string>;
202
- getAll: () => Promise<Command[]>;
203
- };
204
- readonly ports: {
205
- get: (port: number) => Promise<{
206
- port: number;
207
- host: string;
208
- }>;
209
- getAll: () => Promise<{
210
- port: number;
211
- host: string;
212
- }[]>;
213
- waitForPort: (port: number, options?: {
214
- timeoutMs?: number;
215
- }) => Promise<{
216
- port: number;
217
- host: string;
218
- }>;
219
- };
394
+ readonly commands: SandboxCommands;
395
+ readonly ports: Ports;
396
+ readonly terminals: Terminals;
397
+ readonly interpreters: Interpreters;
398
+ readonly hosts: Hosts;
220
399
  readonly tasks: Tasks;
221
400
  readonly setup: Setup;
222
401
  readonly workspacePath = "/project/sandbox";
402
+ static readonly create: RefusedAsync;
223
403
  private disconnected;
224
404
  private readonly attached;
225
405
  private readonly previewURLs;
406
+ private readonly stateEvent;
226
407
  private stopKeepAlive?;
227
408
  constructor(native: NativeSandbox, env: Record<string, string>);
409
+ /** Runtime's guest agent is updated with the host: always current. */
410
+ get isUpToDate(): boolean;
411
+ /** The sandbox's page in Runtime's console. */
412
+ get editorUrl(): string;
413
+ get onStateChange(): (listener: (value: "CONNECTED" | "DISCONNECTED") => void) => {
414
+ dispose: () => boolean;
415
+ };
228
416
  initialize(): Promise<void>;
229
417
  previewURL(port: number): string;
230
418
  private assertConnected;
231
419
  private start;
232
420
  private attach;
233
421
  get id(): string;
234
- get state(): "DISCONNECTED" | "CONNECTED";
422
+ get state(): "CONNECTED" | "DISCONNECTED";
235
423
  disconnect(): Promise<void>;
236
424
  reconnect(): Promise<void>;
237
425
  keepActiveWhileConnected(enabled: boolean): void;