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
package/dist/client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type ClientExtensions } from "./products/index.js";
2
+ import { type RenamedProducts } from "./renamed-products.js";
2
3
  import { usageExport as makeUsageExport } from "./products/observability.js";
3
4
  import { Machines } from "./machine.js";
4
5
  import { Sandbox } from "./sandbox.js";
@@ -34,14 +35,11 @@ export type RuntimeOptions = {
34
35
  };
35
36
  /** One client for every Runtime Cloud product. Create it once and reuse it:
36
37
  * it keeps its connections open. */
37
- export interface Runtime extends ClientExtensions {
38
+ export interface Runtime extends ClientExtensions, RenamedProducts {
38
39
  }
39
40
  export declare class Runtime {
40
41
  readonly transport: Transport;
41
- /** The sandbox product; `sandboxes` remains the same client for compatibility. */
42
- readonly sandbox: Sandboxes;
43
42
  readonly sandboxes: Sandboxes;
44
- readonly snapshot: Snapshots;
45
43
  readonly snapshots: Snapshots;
46
44
  readonly feedback: FeedbackApi;
47
45
  readonly support: SupportApi;
package/dist/client.js CHANGED
@@ -1,9 +1,12 @@
1
- import { clientFactories, clientProductAliases } from "./products/index.js";
1
+ import { clientFactories } from "./products/index.js";
2
+ import { installRenamedProducts } from "./renamed-products.js";
2
3
  import { usageExport as makeUsageExport } from "./products/observability.js";
3
4
  import { Machines } from "./machine.js";
4
5
  import { SANDBOXES, Sandbox } from "./sandbox.js";
5
6
  import { Snapshots } from "./snapshots.js";
6
- import { DEFAULT_BASE_URL, Transport, missingKey } from "./transport.js";
7
+ import { DEFAULT_BASE_URL, Transport, missingKey, sayRenamed, } from "./transport.js";
8
+ import { RuntimeError } from "./errors.js";
9
+ import { RENAMED_FIELDS, fieldUse } from "./product-renames.js";
7
10
  /** The key `runtime login` saved for this machine and this API origin, found
8
11
  * on first use. A constructor override must never receive another API's key. */
9
12
  const savedKey = async (apiOrigin) => {
@@ -18,10 +21,7 @@ const env = (name) => typeof process === "undefined"
18
21
  // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
19
22
  export class Runtime {
20
23
  transport;
21
- /** The sandbox product; `sandboxes` remains the same client for compatibility. */
22
- sandbox;
23
24
  sandboxes;
24
- snapshot;
25
25
  snapshots;
26
26
  feedback;
27
27
  support;
@@ -48,17 +48,14 @@ export class Runtime {
48
48
  : {}),
49
49
  });
50
50
  this.sandboxes = new Sandboxes(this.transport);
51
- this.sandbox = this.sandboxes;
52
51
  this.snapshots = new Snapshots(this.transport);
53
- this.snapshot = this.snapshots;
54
52
  this.feedback = new FeedbackApi(this.transport);
55
53
  this.support = new SupportApi(this.transport);
56
54
  this.account = new AccountApi(this.transport);
57
55
  this.usageExport = makeUsageExport(this.transport);
58
56
  for (const [name, make] of clientFactories())
59
57
  Object.defineProperty(this, name, { value: make(this.transport), enumerable: true });
60
- for (const [alias, name] of Object.entries(clientProductAliases))
61
- Object.defineProperty(this, alias, { value: this[name], enumerable: true });
58
+ installRenamedProducts(this);
62
59
  }
63
60
  /** Who this key is: organization, agent and credential. */
64
61
  me(options = {}) {
@@ -70,12 +67,31 @@ export class Runtime {
70
67
  }
71
68
  /** Balance, holds, free time and per-resource charges, in integer microdollars. */
72
69
  /** Credit, holds, free time and per-resource charges. */
73
- usage(options = {}) {
74
- return this.transport.json({
70
+ async usage(options = {}) {
71
+ const value = await this.transport.json({
75
72
  method: "GET",
76
73
  path: "/v1/usage",
77
74
  ...options,
78
75
  });
76
+ const fields = value;
77
+ for (const field of RENAMED_FIELDS) {
78
+ // An older server only sends the old name. Preserve its value before
79
+ // replacing that property with the warning getter.
80
+ if (!(field.now in fields) && field.name in fields)
81
+ fields[field.now] = fields[field.name];
82
+ Object.defineProperty(value, field.name, {
83
+ configurable: true,
84
+ enumerable: false,
85
+ get() {
86
+ const use = fieldUse(field.name);
87
+ if (use.kind === "retired")
88
+ throw new RuntimeError({ ...use.error });
89
+ sayRenamed(`299 runtime "${use.warning.replaceAll('"', "'")}"`);
90
+ return fields[field.now];
91
+ },
92
+ });
93
+ }
94
+ return value;
79
95
  }
80
96
  /** This account's authenticated API answers, in hourly windows. Counts are
81
97
  * exact decimal strings, and an empty window has a null error percentage.
@@ -0,0 +1,143 @@
1
+ /** Cloudflare's exported error classes, with its fields, so a caller's
2
+ * `instanceof` and `error.code` keep working. The adapter throws them where
3
+ * Cloudflare would: a process that never becomes ready, a bucket that will
4
+ * not mount or unmount. */
5
+ export type ErrorResponse<TContext = Record<string, unknown>> = {
6
+ code: string;
7
+ message: string;
8
+ operation?: string;
9
+ context: TContext;
10
+ httpStatus: number;
11
+ timestamp: string;
12
+ suggestion?: string;
13
+ documentation?: string;
14
+ };
15
+ declare class SandboxError<TContext = Record<string, unknown>> extends Error {
16
+ readonly errorResponse: ErrorResponse<TContext>;
17
+ constructor(errorResponse: ErrorResponse<TContext>, options?: {
18
+ cause?: unknown;
19
+ });
20
+ get code(): string;
21
+ get context(): TContext;
22
+ get httpStatus(): number;
23
+ get operation(): string | undefined;
24
+ get suggestion(): string | undefined;
25
+ get timestamp(): string;
26
+ get documentation(): string | undefined;
27
+ toJSON(): {
28
+ name: string;
29
+ message: string;
30
+ code: string;
31
+ context: TContext;
32
+ httpStatus: number;
33
+ operation: string | undefined;
34
+ suggestion: string | undefined;
35
+ timestamp: string;
36
+ documentation: string | undefined;
37
+ stack: string | undefined;
38
+ };
39
+ }
40
+ export { SandboxError };
41
+ export declare class SessionTerminatedError extends SandboxError<{
42
+ sessionId: string;
43
+ exitCode: number | null;
44
+ }> {
45
+ get sessionId(): string;
46
+ get exitCode(): number | null;
47
+ }
48
+ type ReadyContext = {
49
+ processId: string;
50
+ command: string;
51
+ condition: string;
52
+ };
53
+ export declare class ProcessReadyTimeoutError extends SandboxError<ReadyContext & {
54
+ timeout: number;
55
+ }> {
56
+ get processId(): string;
57
+ get command(): string;
58
+ get condition(): string;
59
+ get timeout(): number;
60
+ }
61
+ export declare class ProcessExitedBeforeReadyError extends SandboxError<ReadyContext & {
62
+ exitCode: number;
63
+ }> {
64
+ get processId(): string;
65
+ get command(): string;
66
+ get condition(): string;
67
+ get exitCode(): number;
68
+ }
69
+ export declare class BackupNotFoundError extends SandboxError<{
70
+ backupId: string;
71
+ }> {
72
+ get backupId(): string;
73
+ }
74
+ export declare class BackupExpiredError extends SandboxError<{
75
+ backupId: string;
76
+ expiredAt?: string;
77
+ }> {
78
+ get backupId(): string;
79
+ get expiredAt(): string | undefined;
80
+ }
81
+ export declare class InvalidBackupConfigError extends SandboxError<{
82
+ reason: string;
83
+ }> {
84
+ get reason(): string;
85
+ }
86
+ export declare class BackupCreateError extends SandboxError<{
87
+ dir: string;
88
+ backupId?: string;
89
+ stderr?: string;
90
+ exitCode?: number;
91
+ }> {
92
+ get dir(): string;
93
+ get backupId(): string | undefined;
94
+ }
95
+ export declare class BackupRestoreError extends SandboxError<{
96
+ dir: string;
97
+ backupId: string;
98
+ stderr?: string;
99
+ exitCode?: number;
100
+ }> {
101
+ get dir(): string;
102
+ get backupId(): string;
103
+ }
104
+ export declare class ContainerUnavailableError extends SandboxError<{
105
+ reason: string;
106
+ retryable: true;
107
+ retryAfterMs?: number;
108
+ originalMessage?: string;
109
+ }> {
110
+ get reason(): string;
111
+ get retryAfterMs(): number | undefined;
112
+ }
113
+ export declare class OperationInterruptedError extends SandboxError<{
114
+ reason: string;
115
+ operation: string;
116
+ phase: string;
117
+ admitted: boolean | "unknown";
118
+ retryable: boolean;
119
+ }> {
120
+ get reason(): string;
121
+ }
122
+ export declare class BucketMountError extends Error {
123
+ readonly code: string;
124
+ constructor(message: string, code?: string);
125
+ }
126
+ export declare class S3FSMountError extends BucketMountError {
127
+ constructor(message: string);
128
+ }
129
+ export declare class BucketUnmountError extends BucketMountError {
130
+ constructor(message: string);
131
+ }
132
+ export declare class MissingCredentialsError extends BucketMountError {
133
+ constructor(message: string);
134
+ }
135
+ export declare class InvalidMountConfigError extends BucketMountError {
136
+ constructor(message: string);
137
+ }
138
+ /** An ErrorResponse as the container would send it. */
139
+ export declare function response<TContext>(code: string, message: string, context: TContext, extra?: {
140
+ httpStatus?: number;
141
+ operation?: string;
142
+ suggestion?: string;
143
+ }): ErrorResponse<TContext>;
@@ -0,0 +1,167 @@
1
+ class SandboxError extends Error {
2
+ errorResponse;
3
+ constructor(errorResponse, options) {
4
+ super(errorResponse.message, options);
5
+ this.name = new.target.name;
6
+ this.errorResponse = errorResponse;
7
+ }
8
+ get code() {
9
+ return this.errorResponse.code;
10
+ }
11
+ get context() {
12
+ return this.errorResponse.context;
13
+ }
14
+ get httpStatus() {
15
+ return this.errorResponse.httpStatus;
16
+ }
17
+ get operation() {
18
+ return this.errorResponse.operation;
19
+ }
20
+ get suggestion() {
21
+ return this.errorResponse.suggestion;
22
+ }
23
+ get timestamp() {
24
+ return this.errorResponse.timestamp;
25
+ }
26
+ get documentation() {
27
+ return this.errorResponse.documentation;
28
+ }
29
+ toJSON() {
30
+ return {
31
+ name: this.name,
32
+ message: this.message,
33
+ code: this.code,
34
+ context: this.context,
35
+ httpStatus: this.httpStatus,
36
+ operation: this.operation,
37
+ suggestion: this.suggestion,
38
+ timestamp: this.timestamp,
39
+ documentation: this.documentation,
40
+ stack: this.stack,
41
+ };
42
+ }
43
+ }
44
+ export { SandboxError };
45
+ export class SessionTerminatedError extends SandboxError {
46
+ get sessionId() {
47
+ return this.context.sessionId;
48
+ }
49
+ get exitCode() {
50
+ return this.context.exitCode;
51
+ }
52
+ }
53
+ export class ProcessReadyTimeoutError extends SandboxError {
54
+ get processId() {
55
+ return this.context.processId;
56
+ }
57
+ get command() {
58
+ return this.context.command;
59
+ }
60
+ get condition() {
61
+ return this.context.condition;
62
+ }
63
+ get timeout() {
64
+ return this.context.timeout;
65
+ }
66
+ }
67
+ export class ProcessExitedBeforeReadyError extends SandboxError {
68
+ get processId() {
69
+ return this.context.processId;
70
+ }
71
+ get command() {
72
+ return this.context.command;
73
+ }
74
+ get condition() {
75
+ return this.context.condition;
76
+ }
77
+ get exitCode() {
78
+ return this.context.exitCode;
79
+ }
80
+ }
81
+ export class BackupNotFoundError extends SandboxError {
82
+ get backupId() {
83
+ return this.context.backupId;
84
+ }
85
+ }
86
+ export class BackupExpiredError extends SandboxError {
87
+ get backupId() {
88
+ return this.context.backupId;
89
+ }
90
+ get expiredAt() {
91
+ return this.context.expiredAt;
92
+ }
93
+ }
94
+ export class InvalidBackupConfigError extends SandboxError {
95
+ get reason() {
96
+ return this.context.reason;
97
+ }
98
+ }
99
+ export class BackupCreateError extends SandboxError {
100
+ get dir() {
101
+ return this.context.dir;
102
+ }
103
+ get backupId() {
104
+ return this.context.backupId;
105
+ }
106
+ }
107
+ export class BackupRestoreError extends SandboxError {
108
+ get dir() {
109
+ return this.context.dir;
110
+ }
111
+ get backupId() {
112
+ return this.context.backupId;
113
+ }
114
+ }
115
+ export class ContainerUnavailableError extends SandboxError {
116
+ get reason() {
117
+ return this.context.reason;
118
+ }
119
+ get retryAfterMs() {
120
+ return this.context.retryAfterMs;
121
+ }
122
+ }
123
+ export class OperationInterruptedError extends SandboxError {
124
+ get reason() {
125
+ return this.context.reason;
126
+ }
127
+ }
128
+ export class BucketMountError extends Error {
129
+ code;
130
+ constructor(message, code = "BUCKET_MOUNT_ERROR") {
131
+ super(message);
132
+ this.name = new.target.name;
133
+ this.code = code;
134
+ }
135
+ }
136
+ export class S3FSMountError extends BucketMountError {
137
+ constructor(message) {
138
+ super(message, "S3FS_MOUNT_ERROR");
139
+ }
140
+ }
141
+ export class BucketUnmountError extends BucketMountError {
142
+ constructor(message) {
143
+ super(message, "BUCKET_UNMOUNT_ERROR");
144
+ }
145
+ }
146
+ export class MissingCredentialsError extends BucketMountError {
147
+ constructor(message) {
148
+ super(message, "MISSING_CREDENTIALS");
149
+ }
150
+ }
151
+ export class InvalidMountConfigError extends BucketMountError {
152
+ constructor(message) {
153
+ super(message, "INVALID_MOUNT_CONFIG");
154
+ }
155
+ }
156
+ /** An ErrorResponse as the container would send it. */
157
+ export function response(code, message, context, extra = {}) {
158
+ return {
159
+ code,
160
+ message,
161
+ context,
162
+ httpStatus: extra.httpStatus ?? 500,
163
+ timestamp: new Date().toISOString(),
164
+ ...(extra.operation ? { operation: extra.operation } : {}),
165
+ ...(extra.suggestion ? { suggestion: extra.suggestion } : {}),
166
+ };
167
+ }