@anvia/sandbox 0.6.0 → 1.0.0-rc.10
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/README.md +56 -0
- package/dist/{chunk-FTNNCT6S.js → chunk-4D2GWLEH.js} +34 -51
- package/dist/chunk-4D2GWLEH.js.map +1 -0
- package/dist/cli.js +35 -28
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +229 -251
- package/dist/index.js +1735 -1100
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-FTNNCT6S.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,307 +1,285 @@
|
|
|
1
1
|
import { AnyTool } from '@anvia/core/tool';
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
type
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
idleTimeoutMs?: number;
|
|
15
|
-
autoDestroy?: boolean;
|
|
16
|
-
}
|
|
17
|
-
interface Sandbox {
|
|
18
|
-
readonly provider: string;
|
|
19
|
-
createSession(options?: SandboxCreateSessionOptions): Promise<SandboxSession>;
|
|
20
|
-
}
|
|
21
|
-
interface SandboxSession {
|
|
22
|
-
readonly id: string;
|
|
23
|
-
readonly provider: string;
|
|
24
|
-
readonly workdir: string;
|
|
25
|
-
exec(options: SandboxExecOptions): Promise<SandboxExecResult>;
|
|
26
|
-
execStream(options: SandboxExecOptions): AsyncIterable<SandboxExecStreamEvent>;
|
|
27
|
-
readFile(path: string): Promise<Uint8Array>;
|
|
28
|
-
readTextFile(path: string): Promise<string>;
|
|
29
|
-
readTextFilePage?(path: string, options?: SandboxTextFileReadOptions): Promise<SandboxTextFileReadResult>;
|
|
30
|
-
writeFile(path: string, data: string | Uint8Array): Promise<void>;
|
|
31
|
-
writeTextFile(path: string, content: string): Promise<void>;
|
|
32
|
-
listFiles(path?: string): Promise<SandboxFileEntry[]>;
|
|
33
|
-
destroy(): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
interface SandboxTextFileReadOptions {
|
|
36
|
-
startLine?: number;
|
|
37
|
-
lineCount?: number;
|
|
38
|
-
maxBytes?: number;
|
|
39
|
-
}
|
|
40
|
-
interface SandboxTextFileReadResult {
|
|
41
|
-
content: string;
|
|
42
|
-
startLine: number;
|
|
43
|
-
endLine: number | null;
|
|
44
|
-
nextStartLine: number | null;
|
|
45
|
-
truncated: boolean;
|
|
46
|
-
truncatedBy: "lines" | "bytes" | null;
|
|
47
|
-
}
|
|
48
|
-
interface SandboxPortSession extends SandboxSession {
|
|
49
|
-
readonly publishedPorts: readonly SandboxPublishedPort[];
|
|
50
|
-
waitForPort(containerPort: number, options?: SandboxWaitForPortOptions): Promise<SandboxPublishedPort>;
|
|
51
|
-
}
|
|
52
|
-
interface SandboxProcessSession extends SandboxSession {
|
|
53
|
-
startProcess(options: SandboxProcessStartOptions): Promise<SandboxProcessInfo>;
|
|
54
|
-
listProcesses(): Promise<SandboxProcessInfo[]>;
|
|
55
|
-
readProcessLogs(processId: string, options?: SandboxProcessLogsOptions): Promise<SandboxProcessLogs>;
|
|
56
|
-
stopProcess(processId: string, options?: SandboxProcessStopOptions): Promise<SandboxProcessInfo>;
|
|
57
|
-
}
|
|
58
|
-
interface DockerSandboxSession extends SandboxPortSession, SandboxProcessSession {
|
|
59
|
-
readTextFilePage(path: string, options?: SandboxTextFileReadOptions): Promise<SandboxTextFileReadResult>;
|
|
60
|
-
}
|
|
61
|
-
interface SandboxCreateSessionOptions {
|
|
62
|
-
id?: string;
|
|
63
|
-
workspace?: SandboxWorkspaceOptions;
|
|
64
|
-
manifest?: SandboxManifest;
|
|
65
|
-
metadata?: Record<string, string>;
|
|
66
|
-
}
|
|
67
|
-
interface DockerSandboxCreateSessionOptions extends SandboxCreateSessionOptions {
|
|
3
|
+
type DockerSandboxFileType = "file" | "directory" | "symlink" | "other";
|
|
4
|
+
type DockerSandboxWorkspace = Readonly<{
|
|
5
|
+
type: "ephemeral";
|
|
6
|
+
}> | Readonly<{
|
|
7
|
+
type: "docker-volume";
|
|
8
|
+
name: string;
|
|
9
|
+
}>;
|
|
10
|
+
type DockerSandboxNetwork = Readonly<{
|
|
11
|
+
mode: "none";
|
|
12
|
+
}> | Readonly<{
|
|
13
|
+
mode: "bridge";
|
|
68
14
|
ports?: readonly number[];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
directories?: string[];
|
|
73
|
-
env?: Record<string, string>;
|
|
74
|
-
}
|
|
75
|
-
interface SandboxLimits {
|
|
76
|
-
timeoutMs?: number;
|
|
77
|
-
maxOutputBytes?: number;
|
|
78
|
-
maxFileBytes?: number;
|
|
15
|
+
}>;
|
|
16
|
+
type DockerSandboxState = "running" | "stopping" | "stopped" | "destroying" | "destroyed" | "error";
|
|
17
|
+
type DockerSandboxResources = Readonly<{
|
|
79
18
|
memoryMb?: number;
|
|
80
19
|
cpus?: number;
|
|
81
20
|
pidsLimit?: number;
|
|
21
|
+
sharedMemoryMb?: number;
|
|
22
|
+
}>;
|
|
23
|
+
type DockerSandboxRuntimeLimits = Readonly<{
|
|
24
|
+
commandTimeoutMs?: number;
|
|
25
|
+
maxOutputBytes?: number;
|
|
26
|
+
maxFileBytes?: number;
|
|
82
27
|
maxProcesses?: number;
|
|
83
|
-
}
|
|
84
|
-
|
|
28
|
+
}>;
|
|
29
|
+
type DockerSandboxSecurity = Readonly<{
|
|
30
|
+
readonlyRootfs?: boolean;
|
|
31
|
+
noNewPrivileges?: boolean;
|
|
32
|
+
dropCapabilities?: readonly string[];
|
|
33
|
+
addCapabilities?: readonly string[];
|
|
34
|
+
seccompProfile?: Readonly<{
|
|
35
|
+
type: "path";
|
|
36
|
+
path: string;
|
|
37
|
+
}>;
|
|
38
|
+
}>;
|
|
39
|
+
type CreateDockerSandboxOptions = Readonly<{
|
|
40
|
+
id?: string;
|
|
41
|
+
image: string;
|
|
42
|
+
workdir?: string;
|
|
43
|
+
workspace: DockerSandboxWorkspace;
|
|
44
|
+
network: DockerSandboxNetwork;
|
|
45
|
+
files?: Readonly<Record<string, string | Uint8Array>>;
|
|
46
|
+
directories?: readonly string[];
|
|
47
|
+
env?: Readonly<Record<string, string>>;
|
|
48
|
+
user?: string;
|
|
49
|
+
labels?: Readonly<Record<string, string>>;
|
|
50
|
+
resources?: DockerSandboxResources;
|
|
51
|
+
runtime?: DockerSandboxRuntimeLimits;
|
|
52
|
+
security?: DockerSandboxSecurity;
|
|
53
|
+
abortSignal?: AbortSignal;
|
|
54
|
+
}>;
|
|
55
|
+
type ResumeDockerSandboxOptions = Readonly<{
|
|
56
|
+
id: string;
|
|
57
|
+
abortSignal?: AbortSignal;
|
|
58
|
+
}>;
|
|
59
|
+
type DockerSandboxClientOptions = Readonly<{
|
|
60
|
+
dockerPath?: string;
|
|
61
|
+
}>;
|
|
62
|
+
type PullDockerImageOptions = Readonly<{
|
|
63
|
+
image: string;
|
|
64
|
+
abortSignal?: AbortSignal;
|
|
65
|
+
}>;
|
|
66
|
+
type DockerSandboxExecOptions = Readonly<{
|
|
85
67
|
command: string;
|
|
86
|
-
args?: string[];
|
|
68
|
+
args?: readonly string[];
|
|
87
69
|
cwd?: string;
|
|
88
|
-
env?: Record<string, string
|
|
70
|
+
env?: Readonly<Record<string, string>>;
|
|
89
71
|
timeoutMs?: number;
|
|
90
72
|
input?: string | Uint8Array;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
stdout: string;
|
|
97
|
-
stderr: string;
|
|
98
|
-
exitCode: number;
|
|
73
|
+
abortSignal?: AbortSignal;
|
|
74
|
+
}>;
|
|
75
|
+
type DockerSandboxExecResultBase = Readonly<{
|
|
76
|
+
stdout: Uint8Array;
|
|
77
|
+
stderr: Uint8Array;
|
|
99
78
|
durationMs: number;
|
|
100
|
-
timedOut: boolean;
|
|
101
|
-
aborted: boolean;
|
|
102
79
|
stdoutTruncated: boolean;
|
|
103
80
|
stderrTruncated: boolean;
|
|
104
|
-
}
|
|
105
|
-
type
|
|
81
|
+
}>;
|
|
82
|
+
type DockerSandboxExecResult = (DockerSandboxExecResultBase & Readonly<{
|
|
83
|
+
status: "exited";
|
|
84
|
+
exitCode: number;
|
|
85
|
+
}>) | (DockerSandboxExecResultBase & Readonly<{
|
|
86
|
+
status: "timed_out";
|
|
87
|
+
}>);
|
|
88
|
+
type DockerSandboxExecStreamEvent = Readonly<{
|
|
106
89
|
type: "stdout";
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
} | {
|
|
90
|
+
data: Uint8Array;
|
|
91
|
+
}> | Readonly<{
|
|
110
92
|
type: "stderr";
|
|
111
|
-
|
|
93
|
+
data: Uint8Array;
|
|
94
|
+
}> | Readonly<{
|
|
95
|
+
type: "result";
|
|
96
|
+
result: DockerSandboxExecResult;
|
|
97
|
+
}>;
|
|
98
|
+
type DockerSandboxReadFileOptions = Readonly<{
|
|
99
|
+
path: string;
|
|
100
|
+
abortSignal?: AbortSignal;
|
|
101
|
+
}>;
|
|
102
|
+
type DockerSandboxReadTextFilePageOptions = DockerSandboxReadFileOptions & Readonly<{
|
|
103
|
+
startLine?: number;
|
|
104
|
+
lineCount?: number;
|
|
105
|
+
maxBytes?: number;
|
|
106
|
+
}>;
|
|
107
|
+
type DockerSandboxTextFilePage = Readonly<{
|
|
108
|
+
content: string;
|
|
109
|
+
startLine: number;
|
|
110
|
+
endLine: number | null;
|
|
111
|
+
nextStartLine: number | null;
|
|
112
|
+
truncated: boolean;
|
|
113
|
+
truncatedBy: "lines" | "bytes" | null;
|
|
114
|
+
}>;
|
|
115
|
+
type DockerSandboxWriteFileOptions = Readonly<{
|
|
116
|
+
path: string;
|
|
117
|
+
data: Uint8Array;
|
|
118
|
+
abortSignal?: AbortSignal;
|
|
119
|
+
}>;
|
|
120
|
+
type DockerSandboxWriteTextFileOptions = Readonly<{
|
|
121
|
+
path: string;
|
|
112
122
|
text: string;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
123
|
+
abortSignal?: AbortSignal;
|
|
124
|
+
}>;
|
|
125
|
+
type DockerSandboxListFilesOptions = Readonly<{
|
|
126
|
+
path?: string;
|
|
127
|
+
abortSignal?: AbortSignal;
|
|
128
|
+
}>;
|
|
129
|
+
type DockerSandboxFileEntry = Readonly<{
|
|
118
130
|
path: string;
|
|
119
|
-
type:
|
|
131
|
+
type: DockerSandboxFileType;
|
|
120
132
|
size?: number;
|
|
121
|
-
}
|
|
122
|
-
|
|
133
|
+
}>;
|
|
134
|
+
type DockerSandboxPublishedPort = Readonly<{
|
|
123
135
|
containerPort: number;
|
|
124
136
|
host: "127.0.0.1";
|
|
125
137
|
hostPort: number;
|
|
126
138
|
protocol: "tcp";
|
|
127
|
-
}
|
|
128
|
-
|
|
139
|
+
}>;
|
|
140
|
+
type DockerSandboxWaitForPortOptions = Readonly<{
|
|
141
|
+
containerPort: number;
|
|
129
142
|
timeoutMs?: number;
|
|
130
143
|
intervalMs?: number;
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
144
|
+
abortSignal?: AbortSignal;
|
|
145
|
+
}>;
|
|
146
|
+
type DockerSandboxProcessStartOptions = Readonly<{
|
|
134
147
|
command: string;
|
|
135
|
-
args?: string[];
|
|
148
|
+
args?: readonly string[];
|
|
136
149
|
cwd?: string;
|
|
137
|
-
env?: Record<string, string
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
env?: Readonly<Record<string, string>>;
|
|
151
|
+
abortSignal?: AbortSignal;
|
|
152
|
+
}>;
|
|
153
|
+
type DockerSandboxProcessStatus = "running" | "exited" | "stopped";
|
|
154
|
+
type DockerSandboxProcessInfo = Readonly<{
|
|
141
155
|
id: string;
|
|
142
156
|
command: string;
|
|
143
|
-
args: string[];
|
|
157
|
+
args: readonly string[];
|
|
144
158
|
cwd?: string;
|
|
145
|
-
status:
|
|
159
|
+
status: DockerSandboxProcessStatus;
|
|
146
160
|
exitCode?: number;
|
|
147
161
|
startedAt: string;
|
|
148
162
|
endedAt?: string;
|
|
149
|
-
}
|
|
150
|
-
|
|
163
|
+
}>;
|
|
164
|
+
type DockerSandboxListProcessesOptions = Readonly<{
|
|
165
|
+
abortSignal?: AbortSignal;
|
|
166
|
+
}>;
|
|
167
|
+
type DockerSandboxReadProcessLogsOptions = Readonly<{
|
|
168
|
+
processId: string;
|
|
151
169
|
tailBytes?: number;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
170
|
+
abortSignal?: AbortSignal;
|
|
171
|
+
}>;
|
|
172
|
+
type DockerSandboxProcessLogs = Readonly<{
|
|
173
|
+
stdout: Uint8Array;
|
|
174
|
+
stderr: Uint8Array;
|
|
156
175
|
stdoutTruncated: boolean;
|
|
157
176
|
stderrTruncated: boolean;
|
|
158
|
-
}
|
|
159
|
-
|
|
177
|
+
}>;
|
|
178
|
+
type DockerSandboxStopProcessOptions = Readonly<{
|
|
179
|
+
processId: string;
|
|
160
180
|
gracePeriodMs?: number;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
181
|
+
abortSignal?: AbortSignal;
|
|
182
|
+
}>;
|
|
183
|
+
interface DockerSandboxRuntime {
|
|
184
|
+
readonly id: string;
|
|
185
|
+
readonly provider: "docker";
|
|
186
|
+
readonly workdir: string;
|
|
187
|
+
readonly publishedPorts: readonly DockerSandboxPublishedPort[];
|
|
188
|
+
exec(options: DockerSandboxExecOptions): Promise<DockerSandboxExecResult>;
|
|
189
|
+
execStream(options: DockerSandboxExecOptions): AsyncIterable<DockerSandboxExecStreamEvent>;
|
|
190
|
+
readFile(options: DockerSandboxReadFileOptions): Promise<Uint8Array>;
|
|
191
|
+
readTextFile(options: DockerSandboxReadFileOptions): Promise<string>;
|
|
192
|
+
readTextFilePage(options: DockerSandboxReadTextFilePageOptions): Promise<DockerSandboxTextFilePage>;
|
|
193
|
+
writeFile(options: DockerSandboxWriteFileOptions): Promise<void>;
|
|
194
|
+
writeTextFile(options: DockerSandboxWriteTextFileOptions): Promise<void>;
|
|
195
|
+
listFiles(options?: DockerSandboxListFilesOptions): Promise<readonly DockerSandboxFileEntry[]>;
|
|
196
|
+
startProcess(options: DockerSandboxProcessStartOptions): Promise<DockerSandboxProcessInfo>;
|
|
197
|
+
listProcesses(options?: DockerSandboxListProcessesOptions): Promise<readonly DockerSandboxProcessInfo[]>;
|
|
198
|
+
readProcessLogs(options: DockerSandboxReadProcessLogsOptions): Promise<DockerSandboxProcessLogs>;
|
|
199
|
+
stopProcess(options: DockerSandboxStopProcessOptions): Promise<DockerSandboxProcessInfo>;
|
|
200
|
+
waitForPort(options: DockerSandboxWaitForPortOptions): Promise<DockerSandboxPublishedPort>;
|
|
201
|
+
}
|
|
202
|
+
type DockerSandboxInspectionOptions = Readonly<{
|
|
203
|
+
files?: boolean;
|
|
204
|
+
ports?: boolean;
|
|
205
|
+
processes?: boolean;
|
|
206
|
+
}>;
|
|
207
|
+
type DockerSandboxInspector = Readonly<{
|
|
208
|
+
id: string;
|
|
209
|
+
provider: "docker";
|
|
173
210
|
workdir: string;
|
|
211
|
+
listFiles?: DockerSandboxRuntime["listFiles"];
|
|
212
|
+
readFile?: DockerSandboxRuntime["readFile"];
|
|
213
|
+
publishedPorts?: readonly DockerSandboxPublishedPort[];
|
|
214
|
+
listProcesses?: DockerSandboxRuntime["listProcesses"];
|
|
215
|
+
readProcessLogs?: DockerSandboxRuntime["readProcessLogs"];
|
|
216
|
+
}>;
|
|
217
|
+
type StopDockerSandboxOptions = Readonly<{
|
|
218
|
+
abortSignal?: AbortSignal;
|
|
219
|
+
}>;
|
|
220
|
+
interface DockerSandbox extends AsyncDisposable {
|
|
221
|
+
readonly id: string;
|
|
222
|
+
readonly state: DockerSandboxState;
|
|
223
|
+
readonly runtime: DockerSandboxRuntime;
|
|
224
|
+
inspector(options: DockerSandboxInspectionOptions): DockerSandboxInspector;
|
|
225
|
+
stop(options?: StopDockerSandboxOptions): Promise<void>;
|
|
226
|
+
destroy(): Promise<void>;
|
|
174
227
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
size: number;
|
|
186
|
-
}
|
|
187
|
-
interface SandboxHooks {
|
|
188
|
-
onSessionCreate?: (event: SandboxSessionEvent) => void | Promise<void>;
|
|
189
|
-
onExecStart?: (event: SandboxExecEvent) => void | Promise<void>;
|
|
190
|
-
onExecEnd?: (event: SandboxExecEndEvent) => void | Promise<void>;
|
|
191
|
-
onFileWrite?: (event: SandboxFileWriteEvent) => void | Promise<void>;
|
|
192
|
-
onDestroy?: (event: SandboxSessionEvent) => void | Promise<void>;
|
|
193
|
-
}
|
|
194
|
-
interface DockerSandboxOptions {
|
|
195
|
-
image?: string;
|
|
196
|
-
pull?: "missing" | "always" | "never";
|
|
197
|
-
workdir?: string;
|
|
198
|
-
workspace?: SandboxWorkspaceOptions;
|
|
199
|
-
lifecycle?: SandboxLifecycleOptions;
|
|
200
|
-
network?: SandboxNetworkMode | DockerSandboxNetworkOptions;
|
|
201
|
-
user?: string;
|
|
202
|
-
dockerPath?: string;
|
|
203
|
-
labels?: Record<string, string>;
|
|
204
|
-
limits?: SandboxLimits;
|
|
205
|
-
security?: DockerSandboxSecurityOptions;
|
|
206
|
-
hooks?: SandboxHooks;
|
|
207
|
-
}
|
|
208
|
-
interface SandboxToolsOptions {
|
|
209
|
-
allow?: SandboxToolName[];
|
|
210
|
-
include?: SandboxToolName[];
|
|
211
|
-
execTimeoutMs?: number;
|
|
212
|
-
exec?: SandboxExecToolPolicy;
|
|
213
|
-
readFile?: SandboxReadFileToolPolicy;
|
|
214
|
-
writeFile?: SandboxFileToolPolicy;
|
|
215
|
-
process?: SandboxProcessToolPolicy;
|
|
216
|
-
}
|
|
217
|
-
type SandboxToolName = "exec_command" | "read_file" | "write_file" | "list_files" | "list_ports" | "start_process" | "list_processes" | "read_process_logs" | "stop_process" | "wait_for_port";
|
|
218
|
-
interface SandboxExecToolPolicy {
|
|
219
|
-
allowedCommands?: string[];
|
|
220
|
-
blockedCommands?: string[];
|
|
228
|
+
type DockerSandboxToolName = "exec_command" | "read_file" | "write_file" | "list_files" | "list_ports" | "start_process" | "list_processes" | "read_process_logs" | "stop_process" | "wait_for_port";
|
|
229
|
+
type DockerSandboxCommandPolicy = Readonly<{
|
|
230
|
+
mode: "allow";
|
|
231
|
+
values: readonly string[];
|
|
232
|
+
}> | Readonly<{
|
|
233
|
+
mode: "block";
|
|
234
|
+
values: readonly string[];
|
|
235
|
+
}>;
|
|
236
|
+
type DockerSandboxExecToolPolicy = Readonly<{
|
|
237
|
+
commands?: DockerSandboxCommandPolicy;
|
|
221
238
|
defaultTimeoutMs?: number;
|
|
222
239
|
maxTimeoutMs?: number;
|
|
223
|
-
}
|
|
224
|
-
|
|
240
|
+
}>;
|
|
241
|
+
type DockerSandboxFileToolPolicy = Readonly<{
|
|
225
242
|
maxBytes?: number;
|
|
226
|
-
}
|
|
227
|
-
|
|
243
|
+
}>;
|
|
244
|
+
type DockerSandboxReadFileToolPolicy = DockerSandboxFileToolPolicy & Readonly<{
|
|
228
245
|
defaultLineCount?: number;
|
|
229
246
|
maxLineCount?: number;
|
|
230
|
-
}
|
|
231
|
-
|
|
247
|
+
}>;
|
|
248
|
+
type DockerSandboxProcessToolPolicy = Readonly<{
|
|
232
249
|
maxLogBytes?: number;
|
|
233
250
|
defaultWaitTimeoutMs?: number;
|
|
234
251
|
maxWaitTimeoutMs?: number;
|
|
235
252
|
stopGracePeriodMs?: number;
|
|
236
|
-
}
|
|
237
|
-
type
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
253
|
+
}>;
|
|
254
|
+
type CreateDockerSandboxToolsOptions = Readonly<{
|
|
255
|
+
sandbox: DockerSandboxRuntime;
|
|
256
|
+
tools: readonly [DockerSandboxToolName, ...DockerSandboxToolName[]];
|
|
257
|
+
exec?: DockerSandboxExecToolPolicy;
|
|
258
|
+
readFile?: DockerSandboxReadFileToolPolicy;
|
|
259
|
+
writeFile?: DockerSandboxFileToolPolicy;
|
|
260
|
+
process?: DockerSandboxProcessToolPolicy;
|
|
261
|
+
}>;
|
|
241
262
|
|
|
242
|
-
declare class
|
|
243
|
-
readonly provider = "docker";
|
|
244
|
-
private readonly image;
|
|
245
|
-
private readonly pull;
|
|
246
|
-
private readonly workdir;
|
|
247
|
-
private readonly workspace;
|
|
248
|
-
private readonly lifecycle;
|
|
249
|
-
private readonly network;
|
|
263
|
+
declare class DockerSandboxClient {
|
|
250
264
|
private readonly dockerPath;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
private
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
static deno(options?: DockerSandboxOptions): DockerSandbox;
|
|
260
|
-
createSession(options?: DockerSandboxCreateSessionOptions): Promise<DockerSandboxSession>;
|
|
261
|
-
private ensureImage;
|
|
262
|
-
private createRunArgs;
|
|
263
|
-
private appendNetworkArgs;
|
|
264
|
-
private assertPortNetworkCompatible;
|
|
265
|
-
private inspectPublishedPorts;
|
|
266
|
-
private appendLimitArgs;
|
|
267
|
-
private appendSecurityArgs;
|
|
265
|
+
constructor(options?: DockerSandboxClientOptions);
|
|
266
|
+
pullImage(options: PullDockerImageOptions): Promise<void>;
|
|
267
|
+
createSandbox(options: CreateDockerSandboxOptions): Promise<DockerSandbox>;
|
|
268
|
+
resumeSandbox(options: ResumeDockerSandboxOptions): Promise<DockerSandbox>;
|
|
269
|
+
private createHandle;
|
|
270
|
+
private assertImageExists;
|
|
271
|
+
private assertContainerDoesNotExist;
|
|
272
|
+
private assertVolumeExists;
|
|
268
273
|
private cliOptions;
|
|
269
|
-
private cleanup;
|
|
270
274
|
}
|
|
271
275
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
declare class SandboxDockerCommandError extends SandboxError {
|
|
279
|
-
readonly result: {
|
|
280
|
-
stdout: string;
|
|
281
|
-
stderr: string;
|
|
282
|
-
exitCode: number;
|
|
283
|
-
};
|
|
284
|
-
constructor(message: string, result: {
|
|
285
|
-
stdout: string;
|
|
286
|
-
stderr: string;
|
|
287
|
-
exitCode: number;
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
declare class SandboxSessionDestroyedError extends SandboxError {
|
|
291
|
-
}
|
|
292
|
-
declare class SandboxPathError extends SandboxError {
|
|
293
|
-
}
|
|
294
|
-
declare class SandboxTimeoutError extends SandboxError {
|
|
295
|
-
}
|
|
296
|
-
declare class SandboxFileSizeError extends SandboxError {
|
|
297
|
-
}
|
|
298
|
-
declare class SandboxToolPolicyError extends SandboxError {
|
|
299
|
-
}
|
|
300
|
-
declare class SandboxPortError extends SandboxError {
|
|
301
|
-
}
|
|
302
|
-
declare class SandboxProcessError extends SandboxError {
|
|
276
|
+
type DockerSandboxErrorCode = "docker_unavailable" | "docker_command_failed" | "image_not_found" | "volume_not_found" | "sandbox_not_found" | "invalid_state" | "invalid_path" | "timeout" | "file_too_large" | "tool_policy" | "port" | "process";
|
|
277
|
+
declare class DockerSandboxError extends Error {
|
|
278
|
+
readonly code: DockerSandboxErrorCode;
|
|
279
|
+
readonly details?: unknown | undefined;
|
|
280
|
+
constructor(message: string, code: DockerSandboxErrorCode, details?: unknown | undefined, options?: ErrorOptions);
|
|
303
281
|
}
|
|
304
282
|
|
|
305
|
-
declare function
|
|
283
|
+
declare function createDockerSandboxTools(options: CreateDockerSandboxToolsOptions): readonly AnyTool[];
|
|
306
284
|
|
|
307
|
-
export {
|
|
285
|
+
export { type CreateDockerSandboxOptions, type CreateDockerSandboxToolsOptions, type DockerSandbox, DockerSandboxClient, type DockerSandboxClientOptions, type DockerSandboxCommandPolicy, DockerSandboxError, type DockerSandboxErrorCode, type DockerSandboxExecOptions, type DockerSandboxExecResult, type DockerSandboxExecStreamEvent, type DockerSandboxExecToolPolicy, type DockerSandboxFileEntry, type DockerSandboxFileToolPolicy, type DockerSandboxFileType, type DockerSandboxInspectionOptions, type DockerSandboxInspector, type DockerSandboxListFilesOptions, type DockerSandboxListProcessesOptions, type DockerSandboxNetwork, type DockerSandboxProcessInfo, type DockerSandboxProcessLogs, type DockerSandboxProcessStartOptions, type DockerSandboxProcessStatus, type DockerSandboxProcessToolPolicy, type DockerSandboxPublishedPort, type DockerSandboxReadFileOptions, type DockerSandboxReadFileToolPolicy, type DockerSandboxReadProcessLogsOptions, type DockerSandboxReadTextFilePageOptions, type DockerSandboxResources, type DockerSandboxRuntime, type DockerSandboxRuntimeLimits, type DockerSandboxSecurity, type DockerSandboxState, type DockerSandboxStopProcessOptions, type DockerSandboxTextFilePage, type DockerSandboxToolName, type DockerSandboxWaitForPortOptions, type DockerSandboxWorkspace, type DockerSandboxWriteFileOptions, type DockerSandboxWriteTextFileOptions, type PullDockerImageOptions, type ResumeDockerSandboxOptions, type StopDockerSandboxOptions, createDockerSandboxTools };
|