@cloudflare/sandbox 0.0.0-dc66e8e → 0.0.0-e1fa354

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.
package/src/types.ts CHANGED
@@ -1,11 +1,6 @@
1
1
  // Core Types
2
2
 
3
3
  export interface BaseExecOptions {
4
- /**
5
- * Session ID for grouping related commands
6
- */
7
- sessionId?: string;
8
-
9
4
  /**
10
5
  * Maximum execution time in milliseconds
11
6
  */
@@ -90,11 +85,6 @@ export interface ExecResult {
90
85
  * ISO timestamp when command started
91
86
  */
92
87
  timestamp: string;
93
-
94
- /**
95
- * Session ID if provided
96
- */
97
- sessionId?: string;
98
88
  }
99
89
 
100
90
  // Background Process Types
@@ -177,11 +167,6 @@ export interface Process {
177
167
  */
178
168
  readonly exitCode?: number;
179
169
 
180
- /**
181
- * Session ID if provided
182
- */
183
- readonly sessionId?: string;
184
-
185
170
  /**
186
171
  * Kill the process
187
172
  */
@@ -208,7 +193,6 @@ export interface ExecEvent {
208
193
  exitCode?: number;
209
194
  result?: ExecResult;
210
195
  error?: string; // Changed to string for serialization
211
- sessionId?: string;
212
196
  }
213
197
 
214
198
  export interface LogEvent {
@@ -216,7 +200,6 @@ export interface LogEvent {
216
200
  timestamp: string;
217
201
  data: string;
218
202
  processId: string;
219
- sessionId?: string;
220
203
  exitCode?: number; // For 'exit' events
221
204
  }
222
205
 
@@ -272,10 +255,8 @@ export interface ProcessRecord {
272
255
  startTime: Date;
273
256
  endTime?: Date;
274
257
  exitCode?: number;
275
- sessionId?: string;
276
258
 
277
259
  // Internal fields
278
- childProcess?: any; // Node.js ChildProcess
279
260
  stdout: string; // Accumulated output (ephemeral)
280
261
  stderr: string; // Accumulated output (ephemeral)
281
262
 
@@ -290,7 +271,6 @@ export interface StartProcessRequest {
290
271
  command: string;
291
272
  options?: {
292
273
  processId?: string;
293
- sessionId?: string;
294
274
  timeout?: number;
295
275
  env?: Record<string, string>;
296
276
  cwd?: string;
@@ -304,9 +284,11 @@ export interface StartProcessResponse {
304
284
  id: string;
305
285
  pid?: number;
306
286
  command: string;
307
- status: ProcessStatus;
287
+ status: ProcessStatus;
308
288
  startTime: string;
309
- sessionId?: string;
289
+ endTime?: string | null;
290
+ exitCode?: number | null;
291
+ sessionId: string;
310
292
  };
311
293
  }
312
294
 
@@ -319,7 +301,6 @@ export interface ListProcessesResponse {
319
301
  startTime: string;
320
302
  endTime?: string;
321
303
  exitCode?: number;
322
- sessionId?: string;
323
304
  }>;
324
305
  }
325
306
 
@@ -332,7 +313,6 @@ export interface GetProcessResponse {
332
313
  startTime: string;
333
314
  endTime?: string;
334
315
  exitCode?: number;
335
- sessionId?: string;
336
316
  } | null;
337
317
  }
338
318
 
@@ -342,6 +322,14 @@ export interface GetProcessLogsResponse {
342
322
  processId: string;
343
323
  }
344
324
 
325
+ // Import code interpreter types
326
+ import type {
327
+ CodeContext,
328
+ CreateContextOptions,
329
+ ExecutionResult,
330
+ RunCodeOptions
331
+ } from './interpreter-types';
332
+
345
333
  // Main Sandbox Interface
346
334
 
347
335
  export interface ISandbox {
@@ -362,6 +350,134 @@ export interface ISandbox {
362
350
  // Utility methods
363
351
  cleanupCompletedProcesses(): Promise<number>;
364
352
  getProcessLogs(id: string): Promise<{ stdout: string; stderr: string }>;
353
+
354
+ // File operations
355
+ gitCheckout(repoUrl: string, options: { branch?: string; targetDir?: string }): Promise<GitCheckoutResponse>;
356
+ mkdir(path: string, options?: { recursive?: boolean }): Promise<MkdirResponse>;
357
+ writeFile(path: string, content: string, options?: { encoding?: string }): Promise<WriteFileResponse>;
358
+ deleteFile(path: string): Promise<DeleteFileResponse>;
359
+ renameFile(oldPath: string, newPath: string): Promise<RenameFileResponse>;
360
+ moveFile(sourcePath: string, destinationPath: string): Promise<MoveFileResponse>;
361
+ readFile(path: string, options?: { encoding?: string }): Promise<ReadFileResponse>;
362
+ listFiles(path: string, options?: { recursive?: boolean; includeHidden?: boolean }): Promise<ListFilesResponse>;
363
+
364
+ // Port management
365
+ exposePort(port: number, options: { name?: string; hostname: string }): Promise<{ url: string; port: number; name?: string }>;
366
+ unexposePort(port: number): Promise<void>;
367
+ getExposedPorts(hostname: string): Promise<Array<{ url: string; port: number; name?: string; exposedAt: string }>>;
368
+
369
+ // Environment management
370
+ setEnvVars(envVars: Record<string, string>): Promise<void>;
371
+ setSandboxName(name: string): Promise<void>;
372
+
373
+ // Code Interpreter API
374
+ createCodeContext(options?: CreateContextOptions): Promise<CodeContext>;
375
+ runCode(code: string, options?: RunCodeOptions): Promise<ExecutionResult>;
376
+ runCodeStream(code: string, options?: RunCodeOptions): Promise<ReadableStream>;
377
+ listCodeContexts(): Promise<CodeContext[]>;
378
+ deleteCodeContext(contextId: string): Promise<void>;
379
+ }
380
+
381
+ // Execution session returned by createSession()
382
+ // Sessions are full-featured sandbox objects with scoped execution context
383
+ // Inherits all ISandbox methods except createSession (sessions can't create sub-sessions),
384
+ // and setSandboxName (sessions inherit sandbox name).
385
+ export interface ExecutionSession extends Omit<ISandbox, 'createSession' | 'setSandboxName'> {
386
+ /**
387
+ * Session ID
388
+ */
389
+ id: string;
390
+ }
391
+
392
+ // API Response Types
393
+
394
+ export interface ExecuteResponse {
395
+ success: boolean;
396
+ stdout: string;
397
+ stderr: string;
398
+ exitCode: number;
399
+ command: string;
400
+ timestamp: string;
401
+ }
402
+
403
+ export interface GitCheckoutResponse {
404
+ success: boolean;
405
+ stdout: string;
406
+ stderr: string;
407
+ exitCode: number;
408
+ repoUrl: string;
409
+ branch: string;
410
+ targetDir: string;
411
+ timestamp: string;
412
+ }
413
+
414
+ export interface MkdirResponse {
415
+ success: boolean;
416
+ stdout: string;
417
+ stderr: string;
418
+ exitCode: number;
419
+ path: string;
420
+ recursive: boolean;
421
+ timestamp: string;
422
+ }
423
+
424
+ export interface WriteFileResponse {
425
+ success: boolean;
426
+ exitCode: number;
427
+ path: string;
428
+ timestamp: string;
429
+ }
430
+
431
+ export interface ReadFileResponse {
432
+ success: boolean;
433
+ exitCode: number;
434
+ path: string;
435
+ content: string;
436
+ timestamp: string;
437
+ }
438
+
439
+ export interface DeleteFileResponse {
440
+ success: boolean;
441
+ exitCode: number;
442
+ path: string;
443
+ timestamp: string;
444
+ }
445
+
446
+ export interface RenameFileResponse {
447
+ success: boolean;
448
+ exitCode: number;
449
+ oldPath: string;
450
+ newPath: string;
451
+ timestamp: string;
452
+ }
453
+
454
+ export interface MoveFileResponse {
455
+ success: boolean;
456
+ exitCode: number;
457
+ sourcePath: string;
458
+ destinationPath: string;
459
+ timestamp: string;
460
+ }
461
+
462
+ export interface ListFilesResponse {
463
+ success: boolean;
464
+ exitCode: number;
465
+ path: string;
466
+ files: Array<{
467
+ name: string;
468
+ absolutePath: string;
469
+ relativePath: string;
470
+ type: 'file' | 'directory' | 'symlink' | 'other';
471
+ size: number;
472
+ modifiedAt: string;
473
+ mode: string;
474
+ permissions: {
475
+ readable: boolean;
476
+ writable: boolean;
477
+ executable: boolean;
478
+ };
479
+ }>;
480
+ timestamp: string;
365
481
  }
366
482
 
367
483
  // Type Guards
package/tsconfig.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "extends": "../../tsconfig.json"
2
+ "extends": "../../tsconfig.base.json"
3
3
  }