@cloudflare/sandbox 0.0.0-c87db11 → 0.0.0-cdb8197

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 (35) hide show
  1. package/CHANGELOG.md +117 -0
  2. package/Dockerfile +32 -29
  3. package/README.md +127 -12
  4. package/container_src/bun.lock +31 -77
  5. package/container_src/control-process.ts +784 -0
  6. package/container_src/handler/exec.ts +99 -254
  7. package/container_src/handler/file.ts +253 -640
  8. package/container_src/handler/git.ts +28 -80
  9. package/container_src/handler/process.ts +443 -515
  10. package/container_src/handler/session.ts +92 -0
  11. package/container_src/index.ts +108 -163
  12. package/container_src/interpreter-service.ts +276 -0
  13. package/container_src/isolation.ts +1213 -0
  14. package/container_src/mime-processor.ts +1 -1
  15. package/container_src/package.json +4 -4
  16. package/container_src/runtime/executors/javascript/node_executor.ts +123 -0
  17. package/container_src/runtime/executors/python/ipython_executor.py +338 -0
  18. package/container_src/runtime/executors/typescript/ts_executor.ts +138 -0
  19. package/container_src/runtime/process-pool.ts +464 -0
  20. package/container_src/shell-escape.ts +42 -0
  21. package/container_src/startup.sh +6 -79
  22. package/container_src/types.ts +35 -12
  23. package/package.json +2 -2
  24. package/src/client.ts +214 -187
  25. package/src/errors.ts +15 -14
  26. package/src/file-stream.ts +162 -0
  27. package/src/index.ts +43 -16
  28. package/src/{jupyter-client.ts → interpreter-client.ts} +6 -3
  29. package/src/interpreter-types.ts +102 -95
  30. package/src/interpreter.ts +8 -8
  31. package/src/sandbox.ts +314 -336
  32. package/src/types.ts +194 -24
  33. package/container_src/jupyter-server.ts +0 -579
  34. package/container_src/jupyter-service.ts +0 -458
  35. package/container_src/jupyter_config.py +0 -48
@@ -17,19 +17,20 @@ export interface ProcessRecord {
17
17
  startTime: Date;
18
18
  endTime?: Date;
19
19
  exitCode?: number;
20
- sessionId?: string;
21
- childProcess?: ChildProcess;
20
+ stdoutFile?: string; // Path to temp file containing stdout
21
+ stderrFile?: string; // Path to temp file containing stderr
22
22
  stdout: string;
23
23
  stderr: string;
24
24
  outputListeners: Set<(stream: 'stdout' | 'stderr', data: string) => void>;
25
25
  statusListeners: Set<(status: ProcessStatus) => void>;
26
+ monitoringInterval?: NodeJS.Timeout; // For polling temp files when streaming
26
27
  }
27
28
 
28
29
  export interface StartProcessRequest {
29
30
  command: string;
31
+ sessionId: string;
30
32
  options?: {
31
33
  processId?: string;
32
- sessionId?: string;
33
34
  timeout?: number;
34
35
  env?: Record<string, string>;
35
36
  cwd?: string;
@@ -39,7 +40,6 @@ export interface StartProcessRequest {
39
40
  }
40
41
 
41
42
  export interface ExecuteOptions {
42
- sessionId?: string | null;
43
43
  background?: boolean;
44
44
  cwd?: string | URL;
45
45
  env?: Record<string, string>;
@@ -47,49 +47,59 @@ export interface ExecuteOptions {
47
47
 
48
48
  export interface ExecuteRequest extends ExecuteOptions {
49
49
  command: string;
50
+ sessionId: string;
50
51
  }
51
52
 
52
53
  export interface GitCheckoutRequest {
53
54
  repoUrl: string;
54
55
  branch?: string;
55
56
  targetDir?: string;
56
- sessionId?: string;
57
+ sessionId: string;
57
58
  }
58
59
 
59
60
  export interface MkdirRequest {
60
61
  path: string;
61
62
  recursive?: boolean;
62
- sessionId?: string;
63
+ sessionId: string;
63
64
  }
64
65
 
65
66
  export interface WriteFileRequest {
66
67
  path: string;
67
68
  content: string;
68
69
  encoding?: string;
69
- sessionId?: string;
70
+ sessionId: string;
70
71
  }
71
72
 
72
73
  export interface ReadFileRequest {
73
74
  path: string;
74
75
  encoding?: string;
75
- sessionId?: string;
76
+ sessionId: string;
76
77
  }
77
78
 
78
79
  export interface DeleteFileRequest {
79
80
  path: string;
80
- sessionId?: string;
81
+ sessionId: string;
81
82
  }
82
83
 
83
84
  export interface RenameFileRequest {
84
85
  oldPath: string;
85
86
  newPath: string;
86
- sessionId?: string;
87
+ sessionId: string;
87
88
  }
88
89
 
89
90
  export interface MoveFileRequest {
90
91
  sourcePath: string;
91
92
  destinationPath: string;
92
- sessionId?: string;
93
+ sessionId: string;
94
+ }
95
+
96
+ export interface ListFilesRequest {
97
+ path: string;
98
+ options?: {
99
+ recursive?: boolean;
100
+ includeHidden?: boolean;
101
+ };
102
+ sessionId: string;
93
103
  }
94
104
 
95
105
  export interface ExposePortRequest {
@@ -102,7 +112,20 @@ export interface UnexposePortRequest {
102
112
  }
103
113
 
104
114
  export interface SessionData {
105
- sessionId: string;
115
+ id: string;
106
116
  activeProcess: ChildProcess | null;
107
117
  createdAt: Date;
108
118
  }
119
+
120
+ // Session management API types
121
+ export interface CreateSessionRequest {
122
+ id: string;
123
+ env?: Record<string, string>;
124
+ cwd?: string;
125
+ isolation?: boolean;
126
+ }
127
+
128
+ export interface SessionExecRequest {
129
+ id: string;
130
+ command: string;
131
+ }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@cloudflare/sandbox",
3
- "version": "0.0.0-c87db11",
3
+ "version": "0.0.0-cdb8197",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cloudflare/sandbox-sdk"
7
7
  },
8
8
  "description": "A sandboxed environment for running commands",
9
9
  "dependencies": {
10
- "@cloudflare/containers": "^0.0.25"
10
+ "@cloudflare/containers": "^0.0.28"
11
11
  },
12
12
  "tags": [
13
13
  "sandbox",