withruntime 0.8.4 → 0.9.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 (91) hide show
  1. package/COMPATIBILITY.md +145 -0
  2. package/E2B.md +23 -13
  3. package/README.md +8 -5
  4. package/README.src.md +8 -5
  5. package/compatibility-lock.json +281 -0
  6. package/dist/ai-harness/index.js +2 -2
  7. package/dist/api-defaults.d.ts +17 -0
  8. package/dist/api-defaults.js +22 -0
  9. package/dist/blaxel/preview.d.ts +1 -1
  10. package/dist/blaxel/preview.js +1 -1
  11. package/dist/blaxel/process.d.ts +1 -1
  12. package/dist/blaxel/process.js +11 -2
  13. package/dist/cli-words.d.ts +27 -0
  14. package/dist/cli-words.js +135 -0
  15. package/dist/cli.js +162 -31
  16. package/dist/client.d.ts +4 -1
  17. package/dist/client.js +8 -2
  18. package/dist/cloudflare/index.d.ts +294 -0
  19. package/dist/cloudflare/index.js +554 -0
  20. package/dist/cloudflare/worker.d.ts +415 -0
  21. package/dist/cloudflare/worker.js +297 -0
  22. package/dist/codesandbox/guest-service.d.ts +31 -0
  23. package/dist/codesandbox/guest-service.js +453 -0
  24. package/dist/codesandbox/index.d.ts +386 -0
  25. package/dist/codesandbox/index.js +1313 -0
  26. package/dist/compat/core.d.ts +39 -0
  27. package/dist/compat/core.js +199 -0
  28. package/dist/compat/files.d.ts +26 -0
  29. package/dist/compat/files.js +115 -0
  30. package/dist/compat/shell.d.ts +4 -0
  31. package/dist/compat/shell.js +165 -0
  32. package/dist/daytona/context.js +2 -1
  33. package/dist/daytona/process.d.ts +1 -1
  34. package/dist/daytona/process.js +27 -4
  35. package/dist/e2b/code-interpreter.d.ts +4 -5
  36. package/dist/e2b/code-interpreter.js +54 -56
  37. package/dist/e2b/commands.d.ts +5 -4
  38. package/dist/e2b/commands.js +37 -29
  39. package/dist/e2b/errors.js +1 -1
  40. package/dist/e2b/filesystem.d.ts +8 -6
  41. package/dist/e2b/filesystem.js +127 -28
  42. package/dist/e2b/sandbox.d.ts +4 -3
  43. package/dist/e2b/sandbox.js +10 -10
  44. package/dist/errors.d.ts +8 -0
  45. package/dist/errors.js +15 -2
  46. package/dist/freestyle/index.d.ts +301 -0
  47. package/dist/freestyle/index.js +310 -0
  48. package/dist/index.d.ts +1 -0
  49. package/dist/mcp.js +2 -2
  50. package/dist/modal/index.d.ts +205 -0
  51. package/dist/modal/index.js +485 -0
  52. package/dist/network-cli.js +1 -1
  53. package/dist/openai-agents/index.js +9 -26
  54. package/dist/products/audit.d.ts +3 -0
  55. package/dist/products/index.d.ts +2 -0
  56. package/dist/products/index.js +2 -0
  57. package/dist/products/interpreter.d.ts +11 -4
  58. package/dist/products/interpreter.js +33 -9
  59. package/dist/products/jobs.js +3 -2
  60. package/dist/products/limits.d.ts +10 -0
  61. package/dist/products/previews.d.ts +10 -2
  62. package/dist/products/previews.js +3 -2
  63. package/dist/products/tailscale.d.ts +57 -0
  64. package/dist/products/tailscale.js +17 -0
  65. package/dist/products/watch.d.ts +25 -4
  66. package/dist/products/watch.js +75 -14
  67. package/dist/runloop/index.d.ts +340 -0
  68. package/dist/runloop/index.js +438 -0
  69. package/dist/runloop/pagination.d.ts +46 -0
  70. package/dist/runloop/pagination.js +82 -0
  71. package/dist/runloop/snapshots.d.ts +52 -0
  72. package/dist/runloop/snapshots.js +244 -0
  73. package/dist/sandbox.d.ts +40 -9
  74. package/dist/sandbox.js +273 -76
  75. package/dist/snapshots.d.ts +11 -1
  76. package/dist/snapshots.js +11 -1
  77. package/dist/sprites/index.d.ts +251 -0
  78. package/dist/sprites/index.js +552 -0
  79. package/dist/tar.d.ts +8 -1
  80. package/dist/tar.js +185 -35
  81. package/dist/tools/index.js +2 -1
  82. package/dist/transport.d.ts +20 -2
  83. package/dist/transport.js +48 -11
  84. package/dist/types.d.ts +52 -3
  85. package/dist/vercel/command.js +12 -1
  86. package/dist/vercel/errors.d.ts +2 -2
  87. package/dist/vercel/errors.js +12 -1
  88. package/dist/vercel/filesystem.d.ts +21 -18
  89. package/dist/vercel/filesystem.js +95 -48
  90. package/dist/vercel/sandbox.js +5 -5
  91. package/package.json +45 -3
@@ -0,0 +1,415 @@
1
+ /** Workers conditional entry. The Durable Object coordinates requests and stores
2
+ * configuration; Runtime owns compute. Existing Container/Wrangler declarations
3
+ * still need removal during infrastructure migration. */
4
+ import { DurableObject } from "cloudflare:workers";
5
+ import type { DurableObjectState, DurableObjectNamespace, Request as WorkerRequest, Response as WorkerResponse } from "@cloudflare/workers-types/index.ts";
6
+ import { Sandbox as RuntimeSandbox, type SandboxOptions, type SessionOptions, type ExecOptions, type ProcessOptions, type ReadFileResult, type ReadFileStreamResult } from "./index.js";
7
+ export * from "./index.js";
8
+ export interface RuntimeWorkerEnv {
9
+ RUNTIME_API_KEY: string;
10
+ RUNTIME_API_URL?: string;
11
+ }
12
+ type Configuration = {
13
+ sandboxName?: {
14
+ name: string;
15
+ normalizeId?: boolean;
16
+ };
17
+ sleepAfter?: string | number;
18
+ keepAlive?: boolean;
19
+ };
20
+ export declare class Sandbox<Env extends RuntimeWorkerEnv = RuntimeWorkerEnv> extends DurableObject<Env> {
21
+ private configuration;
22
+ private facade?;
23
+ private previewTail;
24
+ private previewOperation;
25
+ private readonly initialized;
26
+ constructor(ctx: DurableObjectState, env: Env);
27
+ private sandbox;
28
+ configure(configuration: Configuration): Promise<void>;
29
+ setSandboxName(name: string, normalizeId?: boolean): Promise<void>;
30
+ setSleepAfter(sleepAfter: string | number): Promise<void>;
31
+ setKeepAlive(keepAlive: boolean): Promise<void>;
32
+ exec(command: string, options?: ExecOptions): Promise<import("./index.js").ExecResult>;
33
+ execStream(command: string, options?: ExecOptions): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
34
+ startProcess(command: string, options?: ProcessOptions): Promise<{
35
+ id: string;
36
+ command: string;
37
+ status: string;
38
+ startTime: Date;
39
+ endTime: Date | undefined;
40
+ exitCode: number | undefined;
41
+ sessionId: string | undefined;
42
+ kill: (signal?: string) => Promise<void>;
43
+ getStatus: () => Promise<"running" | "killed" | "unknown" | "failed" | "completed">;
44
+ getLogs: () => Promise<{
45
+ stdout: string;
46
+ stderr: string;
47
+ processId: string;
48
+ }>;
49
+ waitForExit: (timeout?: number) => Promise<{
50
+ exitCode: number;
51
+ }>;
52
+ waitForLog: (pattern: string | RegExp, timeout?: number) => Promise<{
53
+ match?: true | RegExpMatchArray | undefined;
54
+ line: string;
55
+ }>;
56
+ }>;
57
+ listProcesses(): Promise<{
58
+ id: string;
59
+ command: string;
60
+ status: string;
61
+ startTime: Date;
62
+ endTime: Date | undefined;
63
+ exitCode: number | undefined;
64
+ sessionId: string | undefined;
65
+ kill: (signal?: string) => Promise<void>;
66
+ getStatus: () => Promise<"running" | "killed" | "unknown" | "failed" | "completed">;
67
+ getLogs: () => Promise<{
68
+ stdout: string;
69
+ stderr: string;
70
+ processId: string;
71
+ }>;
72
+ waitForExit: (timeout?: number) => Promise<{
73
+ exitCode: number;
74
+ }>;
75
+ waitForLog: (pattern: string | RegExp, timeout?: number) => Promise<{
76
+ match?: true | RegExpMatchArray | undefined;
77
+ line: string;
78
+ }>;
79
+ }[]>;
80
+ getProcess(id: string): Promise<{
81
+ id: string;
82
+ command: string;
83
+ status: string;
84
+ startTime: Date;
85
+ endTime: Date | undefined;
86
+ exitCode: number | undefined;
87
+ sessionId: string | undefined;
88
+ kill: (signal?: string) => Promise<void>;
89
+ getStatus: () => Promise<"running" | "killed" | "unknown" | "failed" | "completed">;
90
+ getLogs: () => Promise<{
91
+ stdout: string;
92
+ stderr: string;
93
+ processId: string;
94
+ }>;
95
+ waitForExit: (timeout?: number) => Promise<{
96
+ exitCode: number;
97
+ }>;
98
+ waitForLog: (pattern: string | RegExp, timeout?: number) => Promise<{
99
+ match?: true | RegExpMatchArray | undefined;
100
+ line: string;
101
+ }>;
102
+ } | null>;
103
+ getProcessLogs(id: string): Promise<{
104
+ stdout: string;
105
+ stderr: string;
106
+ processId: string;
107
+ }>;
108
+ killProcess(id: string, signal?: string): Promise<void>;
109
+ killAllProcesses(): Promise<number>;
110
+ createSession(options?: SessionOptions): Promise<{
111
+ id: string;
112
+ exec: (command: string, options?: ExecOptions) => Promise<import("./index.js").ExecResult>;
113
+ execStream: (command: string, options?: ExecOptions) => Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
114
+ startProcess: (command: string, options?: ProcessOptions) => Promise<{
115
+ id: string;
116
+ command: string;
117
+ status: string;
118
+ startTime: Date;
119
+ endTime: Date | undefined;
120
+ exitCode: number | undefined;
121
+ sessionId: string | undefined;
122
+ kill: (signal?: string) => Promise<void>;
123
+ getStatus: () => Promise<"running" | "killed" | "unknown" | "failed" | "completed">;
124
+ getLogs: () => Promise<{
125
+ stdout: string;
126
+ stderr: string;
127
+ processId: string;
128
+ }>;
129
+ waitForExit: (timeout?: number) => Promise<{
130
+ exitCode: number;
131
+ }>;
132
+ waitForLog: (pattern: string | RegExp, timeout?: number) => Promise<{
133
+ match?: true | RegExpMatchArray | undefined;
134
+ line: string;
135
+ }>;
136
+ }>;
137
+ writeFile: (path: string, content: string | ReadableStream<Uint8Array<ArrayBufferLike>>, options?: {
138
+ encoding?: string;
139
+ } | undefined) => Promise<{
140
+ success: boolean;
141
+ path: string;
142
+ bytesWritten: number;
143
+ timestamp: string;
144
+ }>;
145
+ readFile: {
146
+ (path: string, options: {
147
+ encoding: "none";
148
+ }): Promise<ReadFileStreamResult>;
149
+ (path: string, options?: {
150
+ encoding?: "utf8" | "utf-8" | "base64";
151
+ }): Promise<ReadFileResult>;
152
+ };
153
+ mkdir: (path: string, options?: {
154
+ recursive?: boolean;
155
+ } | undefined) => Promise<{
156
+ success: boolean;
157
+ path: string;
158
+ timestamp: string;
159
+ }>;
160
+ deleteFile: (path: string) => Promise<{
161
+ success: boolean;
162
+ path: string;
163
+ timestamp: string;
164
+ }>;
165
+ renameFile: (path: string, to: string) => Promise<{
166
+ success: boolean;
167
+ path: string;
168
+ newPath: string;
169
+ timestamp: string;
170
+ }>;
171
+ moveFile: (path: string, to: string) => Promise<{
172
+ success: boolean;
173
+ path: string;
174
+ newPath: string;
175
+ timestamp: string;
176
+ }>;
177
+ exists: (path: string) => Promise<{
178
+ success: boolean;
179
+ path: string;
180
+ exists: boolean;
181
+ timestamp: string;
182
+ }>;
183
+ listFiles: (path: string, options?: {
184
+ recursive?: boolean;
185
+ includeHidden?: boolean;
186
+ } | undefined) => Promise<{
187
+ success: boolean;
188
+ path: string;
189
+ files: {
190
+ absolutePath: string;
191
+ relativePath: string;
192
+ permissions: {
193
+ readable: boolean;
194
+ writable: boolean;
195
+ executable: boolean;
196
+ };
197
+ name: string;
198
+ path: string;
199
+ type: "file" | "directory" | "symlink" | "other";
200
+ size: number;
201
+ mode: string;
202
+ modifiedAt: string;
203
+ uid?: number;
204
+ gid?: number;
205
+ owner?: string;
206
+ group?: string;
207
+ symlinkTarget?: string;
208
+ }[];
209
+ count: number;
210
+ timestamp: string;
211
+ }>;
212
+ setEnvVars: (env: Record<string, string | undefined>) => Promise<void>;
213
+ }>;
214
+ getSession(id: string): Promise<{
215
+ id: string;
216
+ exec: (command: string, options?: ExecOptions) => Promise<import("./index.js").ExecResult>;
217
+ execStream: (command: string, options?: ExecOptions) => Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
218
+ startProcess: (command: string, options?: ProcessOptions) => Promise<{
219
+ id: string;
220
+ command: string;
221
+ status: string;
222
+ startTime: Date;
223
+ endTime: Date | undefined;
224
+ exitCode: number | undefined;
225
+ sessionId: string | undefined;
226
+ kill: (signal?: string) => Promise<void>;
227
+ getStatus: () => Promise<"running" | "killed" | "unknown" | "failed" | "completed">;
228
+ getLogs: () => Promise<{
229
+ stdout: string;
230
+ stderr: string;
231
+ processId: string;
232
+ }>;
233
+ waitForExit: (timeout?: number) => Promise<{
234
+ exitCode: number;
235
+ }>;
236
+ waitForLog: (pattern: string | RegExp, timeout?: number) => Promise<{
237
+ match?: true | RegExpMatchArray | undefined;
238
+ line: string;
239
+ }>;
240
+ }>;
241
+ writeFile: (path: string, content: string | ReadableStream<Uint8Array<ArrayBufferLike>>, options?: {
242
+ encoding?: string;
243
+ } | undefined) => Promise<{
244
+ success: boolean;
245
+ path: string;
246
+ bytesWritten: number;
247
+ timestamp: string;
248
+ }>;
249
+ readFile: {
250
+ (path: string, options: {
251
+ encoding: "none";
252
+ }): Promise<ReadFileStreamResult>;
253
+ (path: string, options?: {
254
+ encoding?: "utf8" | "utf-8" | "base64";
255
+ }): Promise<ReadFileResult>;
256
+ };
257
+ mkdir: (path: string, options?: {
258
+ recursive?: boolean;
259
+ } | undefined) => Promise<{
260
+ success: boolean;
261
+ path: string;
262
+ timestamp: string;
263
+ }>;
264
+ deleteFile: (path: string) => Promise<{
265
+ success: boolean;
266
+ path: string;
267
+ timestamp: string;
268
+ }>;
269
+ renameFile: (path: string, to: string) => Promise<{
270
+ success: boolean;
271
+ path: string;
272
+ newPath: string;
273
+ timestamp: string;
274
+ }>;
275
+ moveFile: (path: string, to: string) => Promise<{
276
+ success: boolean;
277
+ path: string;
278
+ newPath: string;
279
+ timestamp: string;
280
+ }>;
281
+ exists: (path: string) => Promise<{
282
+ success: boolean;
283
+ path: string;
284
+ exists: boolean;
285
+ timestamp: string;
286
+ }>;
287
+ listFiles: (path: string, options?: {
288
+ recursive?: boolean;
289
+ includeHidden?: boolean;
290
+ } | undefined) => Promise<{
291
+ success: boolean;
292
+ path: string;
293
+ files: {
294
+ absolutePath: string;
295
+ relativePath: string;
296
+ permissions: {
297
+ readable: boolean;
298
+ writable: boolean;
299
+ executable: boolean;
300
+ };
301
+ name: string;
302
+ path: string;
303
+ type: "file" | "directory" | "symlink" | "other";
304
+ size: number;
305
+ mode: string;
306
+ modifiedAt: string;
307
+ uid?: number;
308
+ gid?: number;
309
+ owner?: string;
310
+ group?: string;
311
+ symlinkTarget?: string;
312
+ }[];
313
+ count: number;
314
+ timestamp: string;
315
+ }>;
316
+ setEnvVars: (env: Record<string, string | undefined>) => Promise<void>;
317
+ }>;
318
+ deleteSession(id: string): Promise<{
319
+ success: boolean;
320
+ sessionId: string;
321
+ timestamp: string;
322
+ }>;
323
+ writeFile(...args: Parameters<RuntimeSandbox["writeFile"]>): Promise<{
324
+ success: boolean;
325
+ path: string;
326
+ bytesWritten: number;
327
+ timestamp: string;
328
+ }>;
329
+ readFile(path: string, options: {
330
+ encoding: "none";
331
+ }): Promise<ReadFileStreamResult>;
332
+ readFile(path: string, options?: {
333
+ encoding?: "utf8" | "utf-8" | "base64";
334
+ }): Promise<ReadFileResult>;
335
+ mkdir(...args: Parameters<RuntimeSandbox["mkdir"]>): Promise<{
336
+ success: boolean;
337
+ path: string;
338
+ timestamp: string;
339
+ }>;
340
+ deleteFile(path: string): Promise<{
341
+ success: boolean;
342
+ path: string;
343
+ timestamp: string;
344
+ }>;
345
+ renameFile(path: string, to: string): Promise<{
346
+ success: boolean;
347
+ path: string;
348
+ newPath: string;
349
+ timestamp: string;
350
+ }>;
351
+ moveFile(path: string, to: string): Promise<{
352
+ success: boolean;
353
+ path: string;
354
+ newPath: string;
355
+ timestamp: string;
356
+ }>;
357
+ listFiles(...args: Parameters<RuntimeSandbox["listFiles"]>): Promise<{
358
+ success: boolean;
359
+ path: string;
360
+ files: {
361
+ absolutePath: string;
362
+ relativePath: string;
363
+ permissions: {
364
+ readable: boolean;
365
+ writable: boolean;
366
+ executable: boolean;
367
+ };
368
+ name: string;
369
+ path: string;
370
+ type: "file" | "directory" | "symlink" | "other";
371
+ size: number;
372
+ mode: string;
373
+ modifiedAt: string;
374
+ uid?: number;
375
+ gid?: number;
376
+ owner?: string;
377
+ group?: string;
378
+ symlinkTarget?: string;
379
+ }[];
380
+ count: number;
381
+ timestamp: string;
382
+ }>;
383
+ exists(path: string): Promise<{
384
+ success: boolean;
385
+ path: string;
386
+ exists: boolean;
387
+ timestamp: string;
388
+ }>;
389
+ setEnvVars(...args: Parameters<RuntimeSandbox["setEnvVars"]>): Promise<void>;
390
+ exposePort(port: number, options: {
391
+ name?: string;
392
+ hostname: string;
393
+ token?: string;
394
+ }): Promise<{
395
+ url: string;
396
+ port: number;
397
+ name: string | undefined;
398
+ }>;
399
+ private expose;
400
+ unexposePort(port: number): Promise<void>;
401
+ isPortExposed(port: number): Promise<boolean>;
402
+ validatePortToken(port: number, token: string): Promise<boolean>;
403
+ getExposedPorts(hostname: string): Promise<{
404
+ url: string;
405
+ port: number;
406
+ status: "active";
407
+ }[]>;
408
+ fetch(request: WorkerRequest): Promise<WorkerResponse>;
409
+ private forwardPreview;
410
+ destroy(): Promise<void>;
411
+ }
412
+ export declare function getSandbox<T extends Sandbox>(namespace: DurableObjectNamespace<T>, id: string, options?: SandboxOptions): T;
413
+ export declare function proxyToSandbox(request: Request, env: {
414
+ Sandbox: DurableObjectNamespace<Sandbox>;
415
+ }): Promise<Response | null>;