withruntime 0.8.4 → 0.10.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 (132) hide show
  1. package/BLAXEL.md +4 -4
  2. package/COMPATIBILITY.md +145 -0
  3. package/DAYTONA.md +13 -7
  4. package/E2B.md +34 -20
  5. package/README.md +22 -11
  6. package/README.src.md +22 -11
  7. package/VERCEL.md +13 -3
  8. package/compatibility-lock.json +357 -0
  9. package/dist/ai-harness/index.js +2 -2
  10. package/dist/api-defaults.d.ts +17 -0
  11. package/dist/api-defaults.js +22 -0
  12. package/dist/blaxel/errors.js +1 -1
  13. package/dist/blaxel/lookup.d.ts +3 -2
  14. package/dist/blaxel/lookup.js +3 -2
  15. package/dist/blaxel/pagination.d.ts +2 -2
  16. package/dist/blaxel/pagination.js +45 -17
  17. package/dist/blaxel/preview.d.ts +3 -2
  18. package/dist/blaxel/preview.js +16 -14
  19. package/dist/blaxel/process.d.ts +1 -1
  20. package/dist/blaxel/process.js +66 -11
  21. package/dist/blaxel/sandbox.d.ts +2 -0
  22. package/dist/blaxel/sandbox.js +2 -0
  23. package/dist/blaxel/snapshot.js +3 -5
  24. package/dist/cli-words.d.ts +27 -0
  25. package/dist/cli-words.js +135 -0
  26. package/dist/cli.d.ts +2 -0
  27. package/dist/cli.js +351 -85
  28. package/dist/client.d.ts +33 -4
  29. package/dist/client.js +47 -12
  30. package/dist/cloudflare/identity.d.ts +7 -0
  31. package/dist/cloudflare/identity.js +13 -0
  32. package/dist/cloudflare/index.d.ts +303 -0
  33. package/dist/cloudflare/index.js +592 -0
  34. package/dist/cloudflare/worker.d.ts +419 -0
  35. package/dist/cloudflare/worker.js +447 -0
  36. package/dist/codesandbox/guest-service.d.ts +31 -0
  37. package/dist/codesandbox/guest-service.js +490 -0
  38. package/dist/codesandbox/index.d.ts +386 -0
  39. package/dist/codesandbox/index.js +1347 -0
  40. package/dist/compat/core.d.ts +40 -0
  41. package/dist/compat/core.js +238 -0
  42. package/dist/compat/files.d.ts +26 -0
  43. package/dist/compat/files.js +133 -0
  44. package/dist/compat/shell.d.ts +4 -0
  45. package/dist/compat/shell.js +165 -0
  46. package/dist/credentials.d.ts +6 -1
  47. package/dist/credentials.js +107 -38
  48. package/dist/daytona/context.js +2 -1
  49. package/dist/daytona/daytona.js +11 -4
  50. package/dist/daytona/filesystem.d.ts +17 -4
  51. package/dist/daytona/filesystem.js +121 -38
  52. package/dist/daytona/index.d.ts +1 -1
  53. package/dist/daytona/process.d.ts +1 -1
  54. package/dist/daytona/process.js +27 -4
  55. package/dist/daytona/sandbox.d.ts +1 -1
  56. package/dist/daytona/sandbox.js +16 -7
  57. package/dist/e2b/client.js +1 -1
  58. package/dist/e2b/code-interpreter.d.ts +4 -5
  59. package/dist/e2b/code-interpreter.js +54 -56
  60. package/dist/e2b/commands.d.ts +35 -12
  61. package/dist/e2b/commands.js +169 -73
  62. package/dist/e2b/errors.js +1 -1
  63. package/dist/e2b/filesystem.d.ts +8 -6
  64. package/dist/e2b/filesystem.js +127 -28
  65. package/dist/e2b/index.d.ts +1 -0
  66. package/dist/e2b/index.js +1 -0
  67. package/dist/e2b/pty.d.ts +24 -0
  68. package/dist/e2b/pty.js +80 -0
  69. package/dist/e2b/sandbox.d.ts +6 -4
  70. package/dist/e2b/sandbox.js +59 -25
  71. package/dist/errors.d.ts +8 -0
  72. package/dist/errors.js +15 -2
  73. package/dist/file-source.d.ts +16 -0
  74. package/dist/file-source.js +162 -0
  75. package/dist/freestyle/index.d.ts +309 -0
  76. package/dist/freestyle/index.js +343 -0
  77. package/dist/index.d.ts +3 -1
  78. package/dist/login.js +16 -10
  79. package/dist/mcp.js +2 -2
  80. package/dist/modal/index.d.ts +205 -0
  81. package/dist/modal/index.js +486 -0
  82. package/dist/network-cli.js +112 -44
  83. package/dist/openai-agents/index.js +18 -71
  84. package/dist/page.d.ts +1 -1
  85. package/dist/page.js +2 -2
  86. package/dist/products/audit.d.ts +3 -0
  87. package/dist/products/index.d.ts +14 -0
  88. package/dist/products/index.js +12 -0
  89. package/dist/products/interpreter.d.ts +11 -4
  90. package/dist/products/interpreter.js +33 -9
  91. package/dist/products/jobs.js +3 -2
  92. package/dist/products/limits.d.ts +10 -0
  93. package/dist/products/observability.d.ts +44 -0
  94. package/dist/products/observability.js +6 -0
  95. package/dist/products/previews.d.ts +18 -4
  96. package/dist/products/previews.js +14 -5
  97. package/dist/products/tailscale.d.ts +57 -0
  98. package/dist/products/tailscale.js +17 -0
  99. package/dist/products/volumes.d.ts +42 -0
  100. package/dist/products/volumes.js +36 -0
  101. package/dist/products/watch.d.ts +25 -4
  102. package/dist/products/watch.js +132 -18
  103. package/dist/proxy.js +3 -1
  104. package/dist/runloop/index.d.ts +326 -0
  105. package/dist/runloop/index.js +535 -0
  106. package/dist/runloop/pagination.d.ts +46 -0
  107. package/dist/runloop/pagination.js +82 -0
  108. package/dist/runloop/snapshots.d.ts +52 -0
  109. package/dist/runloop/snapshots.js +244 -0
  110. package/dist/sandbox.d.ts +76 -16
  111. package/dist/sandbox.js +696 -135
  112. package/dist/snapshots.d.ts +20 -5
  113. package/dist/snapshots.js +11 -1
  114. package/dist/sprites/index.d.ts +251 -0
  115. package/dist/sprites/index.js +588 -0
  116. package/dist/tar.d.ts +10 -1
  117. package/dist/tar.js +311 -35
  118. package/dist/tools/index.js +2 -1
  119. package/dist/transport.d.ts +23 -8
  120. package/dist/transport.js +247 -127
  121. package/dist/types.d.ts +52 -3
  122. package/dist/vercel/command.d.ts +1 -1
  123. package/dist/vercel/command.js +15 -3
  124. package/dist/vercel/errors.d.ts +2 -2
  125. package/dist/vercel/errors.js +19 -2
  126. package/dist/vercel/filesystem.d.ts +21 -18
  127. package/dist/vercel/filesystem.js +95 -48
  128. package/dist/vercel/sandbox.d.ts +8 -8
  129. package/dist/vercel/sandbox.js +159 -64
  130. package/dist/vercel/snapshot.d.ts +3 -2
  131. package/dist/vercel/snapshot.js +9 -5
  132. package/package.json +46 -3
@@ -1,11 +1,12 @@
1
1
  import { Page } from "./page.js";
2
2
  import type { RequestOptions, Transport } from "./transport.js";
3
- /** A sandbox's whole machine (files, memory, running processes), kept on its
4
- * host to start new sandboxes from, and copied off the host so it survives
5
- * losing that host. */
3
+ /** A sandbox's saved machine or disk, used to start new sandboxes. A verified
4
+ * off-host copy protects it from host loss once `backedUp` is true. */
6
5
  export type Snapshot = {
7
6
  id: string;
8
7
  kind: "snapshot";
8
+ /** Absent on older servers means memory. */
9
+ mode?: "memory" | "disk";
9
10
  status: string;
10
11
  state: "capturing" | "ready" | "failed" | "deleting" | "deleted";
11
12
  name: string | null;
@@ -17,13 +18,19 @@ export type Snapshot = {
17
18
  memoryGuarantee: string;
18
19
  };
19
20
  retentionDays: number;
21
+ /** True while raw fork memory awaits verified compression. The snapshot
22
+ * remains ready for starts on its current host, with no storage charge or
23
+ * off-host copy until final publication. Absent on older servers. */
24
+ compressionPending?: boolean;
20
25
  /** What it stores, and what storage is metered for: the bytes it alone holds. */
21
26
  storedBytes: number | null;
27
+ /** Zero while compression is pending; final bytes once verified. */
22
28
  meteredBytes: number | null;
23
29
  /** Whether its copy off the host is made and checked. */
24
30
  backedUp: boolean;
25
31
  /** Where that copy stands. `restoring`: its host was lost and it is being
26
- * restored onto another; forks answer `snapshot_restoring` until it is. */
32
+ * restored onto another; forks answer `snapshot_restoring` until it is.
33
+ * `none` also covers temporary fork snapshots and pending compression. */
27
34
  durability: {
28
35
  state: "none" | "pending" | "durable" | "failed" | "restoring";
29
36
  durableAt: string | null;
@@ -36,6 +43,8 @@ export type Snapshot = {
36
43
  [key: string]: unknown;
37
44
  };
38
45
  export type SnapshotOptions = {
46
+ /** Save files for a fresh boot, or the whole machine (default). */
47
+ mode?: "memory" | "disk";
39
48
  name?: string;
40
49
  labels?: Record<string, string>;
41
50
  retentionDays?: number;
@@ -54,7 +63,13 @@ export declare class Snapshots {
54
63
  name?: string;
55
64
  state?: "capturing" | "ready" | "failed" | "deleting";
56
65
  limit?: number;
57
- }): Promise<Page<Snapshot>>;
66
+ }, options?: RequestOptions): Promise<Page<Snapshot>>;
67
+ /** Replace supplied labels or name; omitted fields are preserved. Null clears the name. */
68
+ update(id: string, input: {
69
+ name?: string | null;
70
+ labels?: Record<string, string>;
71
+ ifLabels?: Record<string, string>;
72
+ }, options?: RequestOptions): Promise<Snapshot>;
58
73
  delete(id: string, options?: RequestOptions): Promise<void>;
59
74
  extend(id: string, retentionDays: number, options?: RequestOptions): Promise<Snapshot>;
60
75
  }
package/dist/snapshots.js CHANGED
@@ -19,7 +19,7 @@ export class Snapshots {
19
19
  get(id, options = {}) {
20
20
  return this.t.json({ method: "GET", path: `/v1/snapshots/${enc(id)}`, ...options });
21
21
  }
22
- async list(filter = {}) {
22
+ async list(filter = {}, options = {}) {
23
23
  const query = {
24
24
  sandboxId: filter.sandboxId,
25
25
  name: filter.name,
@@ -31,11 +31,21 @@ export class Snapshots {
31
31
  method: "GET",
32
32
  path: "/v1/snapshots",
33
33
  query: { ...query, cursor },
34
+ ...options,
34
35
  });
35
36
  return new Page(body.data, body.nextCursor, (next) => fetchPage(next));
36
37
  };
37
38
  return fetchPage();
38
39
  }
40
+ /** Replace supplied labels or name; omitted fields are preserved. Null clears the name. */
41
+ update(id, input, options = {}) {
42
+ return this.t.json({
43
+ method: "POST",
44
+ path: `/v1/snapshots/${enc(id)}:update`,
45
+ body: input,
46
+ ...options,
47
+ });
48
+ }
39
49
  async delete(id, options = {}) {
40
50
  await this.t.json({
41
51
  method: "POST",
@@ -0,0 +1,251 @@
1
+ import { EventEmitter } from "node:events";
2
+ import { PassThrough, Writable } from "node:stream";
3
+ import type { Runtime } from "../client.js";
4
+ import type { Sandbox } from "../sandbox.js";
5
+ import { CompatibilityError, type ClientOptions as RuntimeClientOptions } from "../compat/core.js";
6
+ export { CompatibilityError };
7
+ export interface ClientOptions extends RuntimeClientOptions {
8
+ baseURL?: string;
9
+ timeout?: number;
10
+ controlMode?: boolean;
11
+ }
12
+ export interface SpriteConfig {
13
+ ramMB?: number;
14
+ cpus?: number;
15
+ region?: string;
16
+ storageGB?: number;
17
+ }
18
+ export interface CreateSpriteOptions {
19
+ config?: SpriteConfig;
20
+ environment?: Record<string, string>;
21
+ labels?: string[];
22
+ urlSettings?: {
23
+ auth?: string;
24
+ privateAccess?: string;
25
+ };
26
+ runtime?: "default" | "dev";
27
+ waitForCapacity?: boolean;
28
+ }
29
+ export interface SpawnOptions {
30
+ cwd?: string;
31
+ env?: Record<string, string>;
32
+ tty?: boolean;
33
+ rows?: number;
34
+ cols?: number;
35
+ detachable?: boolean;
36
+ sessionId?: string;
37
+ controlMode?: boolean;
38
+ }
39
+ export interface ExecOptions extends SpawnOptions {
40
+ encoding?: BufferEncoding;
41
+ maxBuffer?: number;
42
+ signal?: AbortSignal;
43
+ timeout?: number;
44
+ }
45
+ export interface ExecResult {
46
+ stdout: string | Buffer;
47
+ stderr: string | Buffer;
48
+ exitCode: number;
49
+ }
50
+ export type FilesystemErrorCode = "ENOENT" | "EEXIST" | "ENOTDIR" | "EISDIR" | "EACCES" | "EPERM" | "ENOTEMPTY" | "EINVAL" | "EIO" | "UNKNOWN";
51
+ export declare class FilesystemError extends Error {
52
+ readonly code: FilesystemErrorCode;
53
+ readonly path: string;
54
+ readonly syscall?: string | undefined;
55
+ constructor(message: string, code: FilesystemErrorCode, path: string, syscall?: string | undefined);
56
+ }
57
+ export interface Dirent {
58
+ name: string;
59
+ parentPath: string;
60
+ isDirectory(): boolean;
61
+ isFile(): boolean;
62
+ isSymbolicLink(): boolean;
63
+ }
64
+ export interface ReaddirOptions {
65
+ withFileTypes?: boolean;
66
+ recursive?: boolean;
67
+ pattern?: string;
68
+ encoding?: BufferEncoding;
69
+ }
70
+ export declare class ExecError extends Error {
71
+ readonly exitCode: number;
72
+ readonly stdout: string | Buffer;
73
+ readonly stderr: string | Buffer;
74
+ constructor(message: string, exitCode: number, stdout: string | Buffer, stderr: string | Buffer);
75
+ }
76
+ export declare class SpritesClient {
77
+ readonly runtime: Runtime;
78
+ constructor(token?: string, options?: ClientOptions);
79
+ sprite(name: string): Sprite;
80
+ createSprite(name: string, input?: SpriteConfig | CreateSpriteOptions, extra?: Omit<CreateSpriteOptions, "config">): Promise<Sprite>;
81
+ getSprite(name: string): Promise<Sprite>;
82
+ deleteSprite(name: string): Promise<void>;
83
+ listSprites(options?: {
84
+ prefix?: string;
85
+ maxResults?: number;
86
+ continuationToken?: string;
87
+ bulkLoad?: boolean;
88
+ }): Promise<{
89
+ sprites: {
90
+ id: string;
91
+ name: string;
92
+ status: "paused" | "stopped" | "stopping" | "starting" | "running" | "pausing" | "resuming";
93
+ createdAt: Date;
94
+ updatedAt: Date;
95
+ config: {
96
+ cpus: number;
97
+ ramMB: number;
98
+ storageGB: number;
99
+ region: string;
100
+ };
101
+ }[];
102
+ hasMore: boolean;
103
+ nextContinuationToken: string | undefined;
104
+ }>;
105
+ listAllSprites(prefix?: string): Promise<Sprite[]>;
106
+ restartSprite(name: string): Promise<{
107
+ spriteName: string;
108
+ machineId: string;
109
+ message: string;
110
+ }>;
111
+ updateURLSettings(name: string, settings: {
112
+ auth?: string;
113
+ privateAccess?: string;
114
+ }): Promise<void>;
115
+ }
116
+ export declare class Sprite {
117
+ readonly name: string;
118
+ readonly client: SpritesClient;
119
+ id?: string;
120
+ status?: string;
121
+ config?: SpriteConfig;
122
+ createdAt?: Date;
123
+ updatedAt?: Date;
124
+ url?: string;
125
+ labels: string[];
126
+ constructor(name: string, client: SpritesClient);
127
+ hydrate(s: Sandbox): void;
128
+ native(): Promise<Sandbox>;
129
+ spawn(command: string, args?: string[], options?: SpawnOptions): SpriteCommand;
130
+ exec(command: string, options?: ExecOptions): Promise<ExecResult>;
131
+ execFile(file: string, args?: string[], options?: ExecOptions): Promise<ExecResult>;
132
+ execFileHTTP(file: string, args?: string[], options?: ExecOptions): Promise<ExecResult>;
133
+ createSession(command: string, args?: string[], options?: SpawnOptions): SpriteCommand;
134
+ attachSession(sessionId: string, options?: SpawnOptions): SpriteCommand;
135
+ listSessions(): Promise<{
136
+ id: string;
137
+ command: string;
138
+ created: Date;
139
+ workdir: string;
140
+ isActive: boolean;
141
+ tty: boolean;
142
+ }[]>;
143
+ delete(): Promise<void>;
144
+ destroy(): Promise<void>;
145
+ restart(): Promise<{
146
+ spriteName: string;
147
+ machineId: string;
148
+ message: string;
149
+ }>;
150
+ filesystem(workingDir?: string): SpriteFilesystem;
151
+ createCheckpoint(_comment?: string): Promise<never>;
152
+ listCheckpoints(): Promise<never>;
153
+ getCheckpoint(_id: string): Promise<never>;
154
+ updateURLSettings(settings: {
155
+ auth?: string;
156
+ privateAccess?: string;
157
+ }): Promise<void>;
158
+ update(options: {
159
+ labels?: string[];
160
+ urlSettings?: {
161
+ auth?: string;
162
+ privateAccess?: string;
163
+ };
164
+ }): Promise<this>;
165
+ }
166
+ export declare class SpriteCommand extends EventEmitter {
167
+ readonly stdout: PassThrough;
168
+ readonly stderr: PassThrough;
169
+ readonly stdin: Writable;
170
+ private readonly process;
171
+ private readonly completion;
172
+ private code;
173
+ private readonly controller;
174
+ constructor(sprite: Sprite, command: string, args?: string[], options?: SpawnOptions);
175
+ private follow;
176
+ start(): Promise<void>;
177
+ wait(): Promise<number>;
178
+ kill(signal?: string): void;
179
+ signal(signal: string): void;
180
+ resize(cols: number, rows: number): void;
181
+ close(): void;
182
+ exitCode(): number;
183
+ }
184
+ export declare class SpriteFilesystem {
185
+ private readonly get;
186
+ private readonly files;
187
+ constructor(get: () => Promise<Sandbox>, cwd?: string);
188
+ readFile(path: string, encoding: "utf8"): Promise<string>;
189
+ readFile(path: string, encoding?: null): Promise<Buffer>;
190
+ writeFile(path: string, data: string | Uint8Array, options?: {
191
+ mode?: number;
192
+ }): Promise<void>;
193
+ readdir(path: string, options?: ReaddirOptions & {
194
+ withFileTypes?: false;
195
+ }): Promise<string[]>;
196
+ readdir(path: string, options: ReaddirOptions & {
197
+ withFileTypes: true;
198
+ }): Promise<Dirent[]>;
199
+ mkdir(path: string, options?: {
200
+ recursive?: boolean;
201
+ mode?: number;
202
+ }): Promise<void>;
203
+ rm(path: string, options?: {
204
+ recursive?: boolean;
205
+ force?: boolean;
206
+ }): Promise<void>;
207
+ stat(path: string): Promise<{
208
+ size: number;
209
+ mode: number;
210
+ mtime: Date;
211
+ atime: Date;
212
+ birthtime: Date;
213
+ isDirectory: () => boolean;
214
+ isFile: () => boolean;
215
+ isSymbolicLink: () => boolean;
216
+ }>;
217
+ rename(from: string, to: string): Promise<void>;
218
+ copyFile(from: string, to: string, options?: {
219
+ recursive?: boolean;
220
+ }): Promise<void>;
221
+ chmod(path: string, mode: number, options?: {
222
+ recursive?: boolean;
223
+ }): Promise<void>;
224
+ exists(path: string): Promise<boolean>;
225
+ appendFile(path: string, data: string | Uint8Array): Promise<void>;
226
+ readJSON<T = unknown>(path: string): Promise<T>;
227
+ writeJSON(path: string, data: unknown, options?: {
228
+ spaces?: number;
229
+ }): Promise<void>;
230
+ }
231
+ export declare class CheckpointStream {
232
+ private readonly messages;
233
+ private index;
234
+ constructor(messages: {
235
+ type: "complete" | "error" | "info";
236
+ data?: string;
237
+ error?: string;
238
+ }[]);
239
+ next(): Promise<{
240
+ type: "complete" | "error" | "info";
241
+ data?: string;
242
+ error?: string;
243
+ } | null>;
244
+ processAll(handler: (message: (typeof this.messages)[number]) => void | Promise<void>): Promise<void>;
245
+ close(): void;
246
+ [Symbol.asyncIterator](): AsyncGenerator<{
247
+ type: "complete" | "error" | "info";
248
+ data?: string;
249
+ error?: string;
250
+ }, void, unknown>;
251
+ }