@cloudflare/sandbox 0.0.0-c5bd973 → 0.0.0-cecde0a
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/CHANGELOG.md +24 -0
- package/Dockerfile +73 -9
- package/README.md +312 -12
- package/container_src/handler/exec.ts +337 -0
- package/container_src/handler/file.ts +844 -0
- package/container_src/handler/git.ts +182 -0
- package/container_src/handler/ports.ts +314 -0
- package/container_src/handler/process.ts +640 -0
- package/container_src/index.ts +102 -2647
- package/container_src/types.ts +103 -0
- package/package.json +2 -7
- package/src/client.ts +335 -1247
- package/src/index.ts +20 -129
- package/src/request-handler.ts +144 -0
- package/src/sandbox.ts +645 -0
- package/src/security.ts +113 -0
- package/src/sse-parser.ts +147 -0
- package/src/types.ts +386 -0
- package/tests/client.example.ts +0 -308
- package/tests/connection-test.ts +0 -81
- package/tests/simple-test.ts +0 -81
- package/tests/test1.ts +0 -281
- package/tests/test2.ts +0 -929
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ChildProcess } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
// Process management types
|
|
4
|
+
export type ProcessStatus =
|
|
5
|
+
| 'starting'
|
|
6
|
+
| 'running'
|
|
7
|
+
| 'completed'
|
|
8
|
+
| 'failed'
|
|
9
|
+
| 'killed'
|
|
10
|
+
| 'error';
|
|
11
|
+
|
|
12
|
+
export interface ProcessRecord {
|
|
13
|
+
id: string;
|
|
14
|
+
pid?: number;
|
|
15
|
+
command: string;
|
|
16
|
+
status: ProcessStatus;
|
|
17
|
+
startTime: Date;
|
|
18
|
+
endTime?: Date;
|
|
19
|
+
exitCode?: number;
|
|
20
|
+
sessionId?: string;
|
|
21
|
+
childProcess?: ChildProcess;
|
|
22
|
+
stdout: string;
|
|
23
|
+
stderr: string;
|
|
24
|
+
outputListeners: Set<(stream: 'stdout' | 'stderr', data: string) => void>;
|
|
25
|
+
statusListeners: Set<(status: ProcessStatus) => void>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface StartProcessRequest {
|
|
29
|
+
command: string;
|
|
30
|
+
options?: {
|
|
31
|
+
processId?: string;
|
|
32
|
+
sessionId?: string;
|
|
33
|
+
timeout?: number;
|
|
34
|
+
env?: Record<string, string>;
|
|
35
|
+
cwd?: string;
|
|
36
|
+
encoding?: string;
|
|
37
|
+
autoCleanup?: boolean;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ExecuteRequest {
|
|
42
|
+
command: string;
|
|
43
|
+
sessionId?: string;
|
|
44
|
+
background?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface GitCheckoutRequest {
|
|
48
|
+
repoUrl: string;
|
|
49
|
+
branch?: string;
|
|
50
|
+
targetDir?: string;
|
|
51
|
+
sessionId?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface MkdirRequest {
|
|
55
|
+
path: string;
|
|
56
|
+
recursive?: boolean;
|
|
57
|
+
sessionId?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface WriteFileRequest {
|
|
61
|
+
path: string;
|
|
62
|
+
content: string;
|
|
63
|
+
encoding?: string;
|
|
64
|
+
sessionId?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ReadFileRequest {
|
|
68
|
+
path: string;
|
|
69
|
+
encoding?: string;
|
|
70
|
+
sessionId?: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface DeleteFileRequest {
|
|
74
|
+
path: string;
|
|
75
|
+
sessionId?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface RenameFileRequest {
|
|
79
|
+
oldPath: string;
|
|
80
|
+
newPath: string;
|
|
81
|
+
sessionId?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface MoveFileRequest {
|
|
85
|
+
sourcePath: string;
|
|
86
|
+
destinationPath: string;
|
|
87
|
+
sessionId?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface ExposePortRequest {
|
|
91
|
+
port: number;
|
|
92
|
+
name?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface UnexposePortRequest {
|
|
96
|
+
port: number;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface SessionData {
|
|
100
|
+
sessionId: string;
|
|
101
|
+
activeProcess: ChildProcess | null;
|
|
102
|
+
createdAt: Date;
|
|
103
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/sandbox",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-cecde0a",
|
|
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.
|
|
10
|
+
"@cloudflare/containers": "^0.0.24"
|
|
11
11
|
},
|
|
12
12
|
"tags": [
|
|
13
13
|
"sandbox",
|
|
@@ -26,11 +26,6 @@
|
|
|
26
26
|
"types": "./dist/index.d.ts",
|
|
27
27
|
"import": "./dist/index.js",
|
|
28
28
|
"require": "./dist/index.js"
|
|
29
|
-
},
|
|
30
|
-
"./client": {
|
|
31
|
-
"types": "./dist/client.d.ts",
|
|
32
|
-
"import": "./dist/client.js",
|
|
33
|
-
"require": "./dist/client.js"
|
|
34
29
|
}
|
|
35
30
|
},
|
|
36
31
|
"keywords": [],
|