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,14 +1,105 @@
1
1
  import type { Runtime } from "../client.js";
2
- import type { Sandbox } from "../sandbox.js";
3
- import { CompatibilityError, type ClientOptions } from "../compat/core.js";
2
+ import type { Sandbox, Terminal } from "../sandbox.js";
3
+ import type { Snapshot } from "../snapshots.js";
4
+ import { CompatibilityError, type ClientOptions, type Refused, type RefusedAsync } from "../compat/core.js";
4
5
  export { CompatibilityError };
5
6
  export type VmState = "starting" | "running" | "pausing" | "paused" | "stopped";
7
+ export interface FreestyleErrorBody {
8
+ code: string;
9
+ message: string;
10
+ }
11
+ /** What every failed Runtime call becomes, as Freestyle throws it for a
12
+ * non-2xx response: `code` is Runtime's error code in upper case
13
+ * (`NOT_FOUND`), `status` its HTTP status, and `cause` the RuntimeError. */
14
+ export declare class FreestyleApiError extends Error {
15
+ readonly code: string;
16
+ readonly status: number;
17
+ readonly path?: string;
18
+ constructor(status: number, body: FreestyleErrorBody, path?: string);
19
+ }
20
+ export interface FreestyleConnectionError {
21
+ name?: string;
22
+ message?: string;
23
+ code?: string;
24
+ errno?: string | number;
25
+ syscall?: string;
26
+ address?: string;
27
+ port?: number;
28
+ }
29
+ /** What a call that got no answer from Runtime becomes, as Freestyle 0.2.17
30
+ * throws a failed fetch: a TypeError whose `cause` is the RuntimeError
31
+ * ConnectionError and whose `errors` carry it as one entry. */
32
+ export declare class FreestyleTransportError extends TypeError {
33
+ readonly errors: FreestyleConnectionError[];
34
+ constructor(cause: unknown, errors: FreestyleConnectionError[]);
35
+ toJSON(): {
36
+ name: string;
37
+ message: string;
38
+ errors: FreestyleConnectionError[];
39
+ };
40
+ }
41
+ export declare class FirewallRuleValidationError extends Error {
42
+ readonly path: string;
43
+ constructor(path: string, message: string);
44
+ }
45
+ export declare class TlsRuleValidationError extends Error {
46
+ readonly path: string;
47
+ constructor(path: string, message: string);
48
+ }
49
+ export declare class TlsForwardAuthValidationError extends Error {
50
+ readonly path: string;
51
+ constructor(path: string, message: string);
52
+ }
53
+ export declare const FirewallNamespace: Refused;
54
+ export declare const FirewallRulesNamespace: Refused;
55
+ export declare const validateFirewallEndpoint: Refused;
56
+ export declare const validateFirewallRule: Refused;
57
+ export declare const validateFirewallSpec: Refused;
58
+ export declare const TlsNamespace: Refused;
59
+ export declare const TlsRulesNamespace: Refused;
60
+ export declare const TlsForwardAuthNamespace: Refused;
61
+ export declare const hasTlsIdentity: Refused;
62
+ export declare const resolveTlsProtocol: Refused;
63
+ export declare const validateTlsDomain: Refused;
64
+ export declare const validateTlsEndpoint: Refused;
65
+ export declare const validateTlsForwardAuth: Refused;
66
+ export declare const validateTlsMailRoute: Refused;
67
+ export declare const validateTlsRule: Refused;
68
+ export declare const validateTlsSpec: Refused;
69
+ export declare const TunnelsNamespace: Refused;
70
+ export declare const VpcNamespace: Refused;
71
+ export declare const Vpc: Refused;
72
+ export declare const VpcTunnelNamespace: Refused;
73
+ export type FirewallProtocol = "tcp" | "udp" | "icmp";
74
+ export interface FirewallEndpoint {
75
+ vmId?: string;
76
+ vpcId?: string;
77
+ tunnelId?: string;
78
+ cidr?: string;
79
+ public?: true;
80
+ port?: number;
81
+ protocol?: FirewallProtocol;
82
+ }
6
83
  export interface FirewallRule {
7
84
  action: "allow";
8
- source: Record<string, never>;
9
- destination: {
10
- public: true;
11
- };
85
+ source: FirewallEndpoint;
86
+ destination: FirewallEndpoint;
87
+ description?: string;
88
+ }
89
+ export interface FirewallRuleData {
90
+ id: string;
91
+ action: "allow";
92
+ source: FirewallEndpoint;
93
+ destination: FirewallEndpoint;
94
+ description?: string | null;
95
+ dependencies: {
96
+ kind: string;
97
+ id: string;
98
+ slug?: string | null;
99
+ displayName?: string | null;
100
+ }[];
101
+ createdAt: string;
102
+ updatedAt: string;
12
103
  }
13
104
  export interface CreateVmOptions {
14
105
  snapshotId?: string | null;
@@ -27,14 +118,42 @@ export interface ExecOptions {
27
118
  env?: Record<string, string>;
28
119
  stdin?: string;
29
120
  }
121
+ export interface FreestyleOptions extends ClientOptions {
122
+ teamId?: string;
123
+ stackAccessToken?: string;
124
+ identityAccessToken?: string;
125
+ }
30
126
  export declare class Freestyle {
31
127
  readonly vms: VmsNamespace;
32
- constructor(options?: ClientOptions);
128
+ readonly fetch: RefusedAsync;
129
+ constructor(options?: FreestyleOptions);
130
+ get firewall(): never;
131
+ get tls(): never;
132
+ get tunnels(): never;
133
+ get vpc(): never;
33
134
  }
34
- export declare class VmsNamespace {
135
+ export declare class VmSnapshotsNamespace {
35
136
  private readonly runtime;
36
- readonly snapshots: {
37
- get: (id: string) => Promise<{
137
+ constructor(runtime: Runtime);
138
+ /** A snapshot by id or by its slug (Runtime's snapshot name). */
139
+ resolve(id: string): Promise<Snapshot>;
140
+ get(snapshotId: string): Promise<{
141
+ id: string;
142
+ sourceVmId: string;
143
+ slug: string | null;
144
+ displayName: string | null;
145
+ public: boolean;
146
+ createdAt: string;
147
+ updatedAt: string;
148
+ ttlSeconds: number | null;
149
+ }>;
150
+ delete(snapshotId: string): Promise<void>;
151
+ list(options?: {
152
+ sourceVmId?: string;
153
+ limit?: number;
154
+ offset?: number;
155
+ }): Promise<{
156
+ snapshots: {
38
157
  id: string;
39
158
  sourceVmId: string;
40
159
  slug: string | null;
@@ -42,29 +161,31 @@ export declare class VmsNamespace {
42
161
  public: boolean;
43
162
  createdAt: string;
44
163
  updatedAt: string;
45
- ttlSeconds: number;
46
- }>;
47
- delete: (id: string) => Promise<void>;
48
- list: (options?: {
49
- sourceVmId?: string;
50
- limit?: number;
51
- offset?: number;
52
- }) => Promise<{
53
- snapshots: {
54
- id: string;
55
- sourceVmId: string;
56
- slug: string | null;
57
- displayName: string | null;
58
- public: boolean;
59
- createdAt: string;
60
- updatedAt: string;
61
- ttlSeconds: number;
62
- }[];
63
- totalCount: number;
64
- }>;
65
- };
164
+ ttlSeconds: number | null;
165
+ }[];
166
+ totalCount: number;
167
+ }>;
168
+ /** Renames, relabels and re-times a snapshot: slug is its Runtime name,
169
+ * ttlSeconds whole days from now. */
170
+ update(snapshotId: string, options: {
171
+ slug?: string;
172
+ displayName?: string;
173
+ ttlSeconds?: number;
174
+ }): Promise<{
175
+ id: string;
176
+ sourceVmId: string;
177
+ slug: string | null;
178
+ displayName: string | null;
179
+ public: boolean;
180
+ createdAt: string;
181
+ updatedAt: string;
182
+ ttlSeconds: number | null;
183
+ }>;
184
+ }
185
+ export declare class VmsNamespace {
186
+ private readonly runtime;
187
+ readonly snapshots: VmSnapshotsNamespace;
66
188
  constructor(runtime: Runtime);
67
- private resolveSnapshot;
68
189
  create(options: CreateVmOptions): Promise<{
69
190
  vm: Vm;
70
191
  vmId: string;
@@ -89,13 +210,15 @@ export declare class VmsNamespace {
89
210
  };
90
211
  firewallRules: {
91
212
  id: string;
213
+ action: "allow";
92
214
  source: {
93
215
  vmId: string;
94
216
  };
95
- action: "allow";
96
- destination: {
97
- public: true;
98
- };
217
+ destination: FirewallEndpoint;
218
+ description: null;
219
+ dependencies: never[];
220
+ createdAt: string;
221
+ updatedAt: string;
99
222
  }[];
100
223
  tlsRules: never[];
101
224
  }>;
@@ -196,10 +319,118 @@ export declare class VmFilesystem {
196
319
  modified: string;
197
320
  }>;
198
321
  }
322
+ export interface PtySessionInfo {
323
+ sessionId: number;
324
+ state: string;
325
+ createdUnix: number;
326
+ cols: number;
327
+ rows: number;
328
+ exitCode?: number | null;
329
+ linuxUser?: string | null;
330
+ slug?: string | null;
331
+ }
332
+ export interface PtyOpenOptions {
333
+ exec?: string;
334
+ cols?: number;
335
+ rows?: number;
336
+ linuxUser?: string;
337
+ slug?: string;
338
+ }
339
+ export type PtySessionSelector = number | string;
340
+ export interface PtyAttachOptions {
341
+ session: PtySessionSelector;
342
+ linuxUser?: string;
343
+ }
344
+ export interface PtySessionEvents {
345
+ onData?: (data: Uint8Array) => void;
346
+ onExit?: (exitCode: number) => void;
347
+ onClose?: (info: {
348
+ wasClean: boolean;
349
+ code: number;
350
+ reason: string;
351
+ }) => void;
352
+ onError?: (err: unknown) => void;
353
+ }
354
+ /** A session's number: FNV-1a of its process id, 31 bits, never 0. */
355
+ export declare function sessionNumber(processId: string): number;
356
+ export declare class PtySession {
357
+ #private;
358
+ private readonly terminal;
359
+ private readonly sandbox;
360
+ private readonly processId;
361
+ readonly sessionId: number;
362
+ readonly slug: string | undefined;
363
+ readonly created: boolean;
364
+ constructor(terminal: Terminal, sandbox: Sandbox, processId: string, sessionId: number, slug: string | undefined, created: boolean, events: PtySessionEvents);
365
+ private readonly onError;
366
+ write(data: Uint8Array | string): void;
367
+ resize(options: {
368
+ cols: number;
369
+ rows: number;
370
+ }): void;
371
+ signal(sig: "sigint" | "sigkill"): void;
372
+ /** Closes the connection; the shell keeps running and attach() finds it. */
373
+ detach(): void;
374
+ get readyState(): number;
375
+ }
376
+ export declare class VmPty {
377
+ private readonly get;
378
+ constructor(get: () => Promise<Sandbox>);
379
+ private sessions;
380
+ private find;
381
+ private connect;
382
+ open(options?: PtyOpenOptions & PtySessionEvents): Promise<PtySession>;
383
+ attach(options: PtyAttachOptions & PtySessionEvents): Promise<PtySession>;
384
+ list(options?: {
385
+ linuxUser?: string;
386
+ }): Promise<{
387
+ sessions: PtySessionInfo[];
388
+ }>;
389
+ /** Ends a session's shell. An exited session stays in the list. */
390
+ close(session: PtySessionSelector, options?: {
391
+ linuxUser?: string;
392
+ }): Promise<{
393
+ sessionId: number;
394
+ exitCode: number | null | undefined;
395
+ } | {
396
+ sessionId: number;
397
+ exitCode?: undefined;
398
+ }>;
399
+ }
400
+ export declare class VmLinuxUserPty {
401
+ private readonly pty;
402
+ private readonly linuxUser;
403
+ constructor(pty: VmPty, linuxUser: string);
404
+ open(options?: Omit<PtyOpenOptions, "linuxUser"> & PtySessionEvents): Promise<PtySession>;
405
+ attach(options: Omit<PtyAttachOptions, "linuxUser"> & PtySessionEvents): Promise<PtySession>;
406
+ list(): Promise<{
407
+ sessions: PtySessionInfo[];
408
+ }>;
409
+ close(session: PtySessionSelector): Promise<{
410
+ sessionId: number;
411
+ exitCode: number | null | undefined;
412
+ } | {
413
+ sessionId: number;
414
+ exitCode?: undefined;
415
+ }>;
416
+ }
417
+ export declare class VmLinuxUser {
418
+ private readonly vm;
419
+ private readonly linuxUser;
420
+ readonly pty: VmLinuxUserPty;
421
+ constructor(vm: Vm, linuxUser: string);
422
+ exec(options: string | Omit<ExecOptions, "linuxUser">): Promise<{
423
+ stdout: string;
424
+ stderr: string;
425
+ statusCode: number | null;
426
+ }>;
427
+ }
199
428
  export declare class Vm {
200
429
  private readonly runtime;
201
430
  readonly id: string;
202
431
  readonly fs: VmFilesystem;
432
+ readonly pty: VmPty;
433
+ readonly resize: RefusedAsync;
203
434
  constructor(runtime: Runtime, id: string);
204
435
  data(): Promise<{
205
436
  id: string;
@@ -259,6 +490,23 @@ export declare class Vm {
259
490
  updatedAt: string;
260
491
  }>;
261
492
  delete(): Promise<void>;
493
+ /** The VM's outbound rules, read back from its network settings. */
494
+ firewallRules(): Promise<{
495
+ rules: {
496
+ id: string;
497
+ action: "allow";
498
+ source: {
499
+ vmId: string;
500
+ };
501
+ destination: FirewallEndpoint;
502
+ description: null;
503
+ dependencies: never[];
504
+ createdAt: string;
505
+ updatedAt: string;
506
+ }[];
507
+ totalCount: number;
508
+ }>;
509
+ linuxUser(linuxUser: string): VmLinuxUser;
262
510
  update(options: {
263
511
  slug?: string;
264
512
  displayName?: string;
@@ -303,7 +551,7 @@ export declare class Vm {
303
551
  public: boolean;
304
552
  createdAt: string;
305
553
  updatedAt: string;
306
- ttlSeconds: number;
554
+ ttlSeconds: number | null;
307
555
  };
308
556
  }>;
309
557
  }