@cloudflare/sandbox 0.2.0 → 0.2.2
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 +12 -0
- package/Dockerfile +31 -7
- package/README.md +226 -2
- package/container_src/bun.lock +122 -0
- package/container_src/circuit-breaker.ts +121 -0
- package/container_src/index.ts +305 -10
- package/container_src/jupyter-server.ts +579 -0
- package/container_src/jupyter-service.ts +448 -0
- package/container_src/mime-processor.ts +255 -0
- package/container_src/package.json +9 -0
- package/container_src/startup.sh +83 -0
- package/dist/{chunk-YVZ3K26G.js → chunk-CUHYLCMT.js} +9 -21
- package/dist/chunk-CUHYLCMT.js.map +1 -0
- package/dist/chunk-EGC5IYXA.js +108 -0
- package/dist/chunk-EGC5IYXA.js.map +1 -0
- package/dist/chunk-FKBV7CZS.js +113 -0
- package/dist/chunk-FKBV7CZS.js.map +1 -0
- package/dist/chunk-LALY4SFU.js +129 -0
- package/dist/chunk-LALY4SFU.js.map +1 -0
- package/dist/{chunk-6THNBO4S.js → chunk-S5FFBU4Y.js} +1 -1
- package/dist/{chunk-6THNBO4S.js.map → chunk-S5FFBU4Y.js.map} +1 -1
- package/dist/chunk-VTKZL632.js +237 -0
- package/dist/chunk-VTKZL632.js.map +1 -0
- package/dist/{chunk-ZJN2PQOS.js → chunk-ZMPO44U4.js} +171 -72
- package/dist/chunk-ZMPO44U4.js.map +1 -0
- package/dist/{client-BXYlxy-j.d.ts → client-bzEV222a.d.ts} +52 -4
- package/dist/client.d.ts +2 -1
- package/dist/client.js +1 -1
- package/dist/errors.d.ts +95 -0
- package/dist/errors.js +27 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +33 -3
- package/dist/interpreter-types.d.ts +259 -0
- package/dist/interpreter-types.js +9 -0
- package/dist/interpreter-types.js.map +1 -0
- package/dist/interpreter.d.ts +33 -0
- package/dist/interpreter.js +8 -0
- package/dist/interpreter.js.map +1 -0
- package/dist/jupyter-client.d.ts +4 -0
- package/dist/jupyter-client.js +9 -0
- package/dist/jupyter-client.js.map +1 -0
- package/dist/request-handler.d.ts +2 -1
- package/dist/request-handler.js +8 -3
- package/dist/sandbox.d.ts +2 -1
- package/dist/sandbox.js +8 -3
- package/dist/types.d.ts +8 -0
- package/dist/types.js +1 -1
- package/package.json +1 -1
- package/src/client.ts +37 -54
- package/src/errors.ts +218 -0
- package/src/index.ts +44 -10
- package/src/interpreter-types.ts +383 -0
- package/src/interpreter.ts +150 -0
- package/src/jupyter-client.ts +349 -0
- package/src/sandbox.ts +281 -153
- package/src/types.ts +15 -0
- package/dist/chunk-YVZ3K26G.js.map +0 -1
- package/dist/chunk-ZJN2PQOS.js.map +0 -1
package/dist/errors.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CodeExecutionError,
|
|
3
|
+
ContainerNotReadyError,
|
|
4
|
+
ContextNotFoundError,
|
|
5
|
+
JupyterNotReadyError,
|
|
6
|
+
SandboxError,
|
|
7
|
+
SandboxNetworkError,
|
|
8
|
+
ServiceUnavailableError,
|
|
9
|
+
isJupyterNotReadyError,
|
|
10
|
+
isRetryableError,
|
|
11
|
+
isSandboxError,
|
|
12
|
+
parseErrorResponse
|
|
13
|
+
} from "./chunk-LALY4SFU.js";
|
|
14
|
+
export {
|
|
15
|
+
CodeExecutionError,
|
|
16
|
+
ContainerNotReadyError,
|
|
17
|
+
ContextNotFoundError,
|
|
18
|
+
JupyterNotReadyError,
|
|
19
|
+
SandboxError,
|
|
20
|
+
SandboxNetworkError,
|
|
21
|
+
ServiceUnavailableError,
|
|
22
|
+
isJupyterNotReadyError,
|
|
23
|
+
isRetryableError,
|
|
24
|
+
isSandboxError,
|
|
25
|
+
parseErrorResponse
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export { D as DeleteFileResponse, E as ExecuteResponse, G as GitCheckoutResponse, M as MkdirResponse, a as MoveFileResponse, R as ReadFileResponse, b as RenameFileResponse, S as Sandbox, W as WriteFileResponse, g as getSandbox } from './client-
|
|
1
|
+
export { D as DeleteFileResponse, E as ExecuteResponse, G as GitCheckoutResponse, M as MkdirResponse, a as MoveFileResponse, R as ReadFileResponse, b as RenameFileResponse, S as Sandbox, W as WriteFileResponse, g as getSandbox } from './client-bzEV222a.js';
|
|
2
|
+
export { CodeExecutionError, ContainerNotReadyError, ContextNotFoundError, JupyterNotReadyError, SandboxError, SandboxErrorResponse, SandboxNetworkError, ServiceUnavailableError, isJupyterNotReadyError, isRetryableError, isSandboxError, parseErrorResponse } from './errors.js';
|
|
3
|
+
export { ChartData, CodeContext, CreateContextOptions, Execution, ExecutionError, OutputMessage, Result, ResultImpl, RunCodeOptions } from './interpreter-types.js';
|
|
2
4
|
export { RouteInfo, SandboxEnv, proxyToSandbox } from './request-handler.js';
|
|
3
5
|
export { asyncIterableToSSEStream, parseSSEStream, responseToAsyncIterable } from './sse-parser.js';
|
|
4
6
|
export { ExecEvent, LogEvent } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -2,19 +2,49 @@ import {
|
|
|
2
2
|
Sandbox,
|
|
3
3
|
getSandbox,
|
|
4
4
|
proxyToSandbox
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-YVZ3K26G.js";
|
|
5
|
+
} from "./chunk-ZMPO44U4.js";
|
|
7
6
|
import "./chunk-6UAWTJ5S.js";
|
|
8
7
|
import {
|
|
9
8
|
asyncIterableToSSEStream,
|
|
10
9
|
parseSSEStream,
|
|
11
10
|
responseToAsyncIterable
|
|
12
11
|
} from "./chunk-NNGBXDMY.js";
|
|
13
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-S5FFBU4Y.js";
|
|
13
|
+
import "./chunk-FKBV7CZS.js";
|
|
14
|
+
import {
|
|
15
|
+
ResultImpl
|
|
16
|
+
} from "./chunk-EGC5IYXA.js";
|
|
17
|
+
import "./chunk-VTKZL632.js";
|
|
18
|
+
import "./chunk-CUHYLCMT.js";
|
|
19
|
+
import {
|
|
20
|
+
CodeExecutionError,
|
|
21
|
+
ContainerNotReadyError,
|
|
22
|
+
ContextNotFoundError,
|
|
23
|
+
JupyterNotReadyError,
|
|
24
|
+
SandboxError,
|
|
25
|
+
SandboxNetworkError,
|
|
26
|
+
ServiceUnavailableError,
|
|
27
|
+
isJupyterNotReadyError,
|
|
28
|
+
isRetryableError,
|
|
29
|
+
isSandboxError,
|
|
30
|
+
parseErrorResponse
|
|
31
|
+
} from "./chunk-LALY4SFU.js";
|
|
14
32
|
export {
|
|
33
|
+
CodeExecutionError,
|
|
34
|
+
ContainerNotReadyError,
|
|
35
|
+
ContextNotFoundError,
|
|
36
|
+
JupyterNotReadyError,
|
|
37
|
+
ResultImpl,
|
|
15
38
|
Sandbox,
|
|
39
|
+
SandboxError,
|
|
40
|
+
SandboxNetworkError,
|
|
41
|
+
ServiceUnavailableError,
|
|
16
42
|
asyncIterableToSSEStream,
|
|
17
43
|
getSandbox,
|
|
44
|
+
isJupyterNotReadyError,
|
|
45
|
+
isRetryableError,
|
|
46
|
+
isSandboxError,
|
|
47
|
+
parseErrorResponse,
|
|
18
48
|
parseSSEStream,
|
|
19
49
|
proxyToSandbox,
|
|
20
50
|
responseToAsyncIterable
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
interface CreateContextOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Programming language for the context
|
|
4
|
+
* @default 'python'
|
|
5
|
+
*/
|
|
6
|
+
language?: 'python' | 'javascript' | 'typescript';
|
|
7
|
+
/**
|
|
8
|
+
* Working directory for the context
|
|
9
|
+
* @default '/workspace'
|
|
10
|
+
*/
|
|
11
|
+
cwd?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Environment variables for the context
|
|
14
|
+
*/
|
|
15
|
+
envVars?: Record<string, string>;
|
|
16
|
+
/**
|
|
17
|
+
* Request timeout in milliseconds
|
|
18
|
+
* @default 30000
|
|
19
|
+
*/
|
|
20
|
+
timeout?: number;
|
|
21
|
+
}
|
|
22
|
+
interface CodeContext {
|
|
23
|
+
/**
|
|
24
|
+
* Unique identifier for the context
|
|
25
|
+
*/
|
|
26
|
+
readonly id: string;
|
|
27
|
+
/**
|
|
28
|
+
* Programming language of the context
|
|
29
|
+
*/
|
|
30
|
+
readonly language: string;
|
|
31
|
+
/**
|
|
32
|
+
* Current working directory
|
|
33
|
+
*/
|
|
34
|
+
readonly cwd: string;
|
|
35
|
+
/**
|
|
36
|
+
* When the context was created
|
|
37
|
+
*/
|
|
38
|
+
readonly createdAt: Date;
|
|
39
|
+
/**
|
|
40
|
+
* When the context was last used
|
|
41
|
+
*/
|
|
42
|
+
readonly lastUsed: Date;
|
|
43
|
+
}
|
|
44
|
+
interface RunCodeOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Context to run the code in. If not provided, uses default context for the language
|
|
47
|
+
*/
|
|
48
|
+
context?: CodeContext;
|
|
49
|
+
/**
|
|
50
|
+
* Language to use if context is not provided
|
|
51
|
+
* @default 'python'
|
|
52
|
+
*/
|
|
53
|
+
language?: 'python' | 'javascript' | 'typescript';
|
|
54
|
+
/**
|
|
55
|
+
* Environment variables for this execution
|
|
56
|
+
*/
|
|
57
|
+
envVars?: Record<string, string>;
|
|
58
|
+
/**
|
|
59
|
+
* Execution timeout in milliseconds
|
|
60
|
+
* @default 60000
|
|
61
|
+
*/
|
|
62
|
+
timeout?: number;
|
|
63
|
+
/**
|
|
64
|
+
* AbortSignal for cancelling execution
|
|
65
|
+
*/
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
/**
|
|
68
|
+
* Callback for stdout output
|
|
69
|
+
*/
|
|
70
|
+
onStdout?: (output: OutputMessage) => void | Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Callback for stderr output
|
|
73
|
+
*/
|
|
74
|
+
onStderr?: (output: OutputMessage) => void | Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Callback for execution results (charts, tables, etc)
|
|
77
|
+
*/
|
|
78
|
+
onResult?: (result: Result) => void | Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Callback for execution errors
|
|
81
|
+
*/
|
|
82
|
+
onError?: (error: ExecutionError) => void | Promise<void>;
|
|
83
|
+
}
|
|
84
|
+
interface OutputMessage {
|
|
85
|
+
/**
|
|
86
|
+
* The output text
|
|
87
|
+
*/
|
|
88
|
+
text: string;
|
|
89
|
+
/**
|
|
90
|
+
* Timestamp of the output
|
|
91
|
+
*/
|
|
92
|
+
timestamp: number;
|
|
93
|
+
}
|
|
94
|
+
interface Result {
|
|
95
|
+
/**
|
|
96
|
+
* Plain text representation
|
|
97
|
+
*/
|
|
98
|
+
text?: string;
|
|
99
|
+
/**
|
|
100
|
+
* HTML representation (tables, formatted output)
|
|
101
|
+
*/
|
|
102
|
+
html?: string;
|
|
103
|
+
/**
|
|
104
|
+
* PNG image data (base64 encoded)
|
|
105
|
+
*/
|
|
106
|
+
png?: string;
|
|
107
|
+
/**
|
|
108
|
+
* JPEG image data (base64 encoded)
|
|
109
|
+
*/
|
|
110
|
+
jpeg?: string;
|
|
111
|
+
/**
|
|
112
|
+
* SVG image data
|
|
113
|
+
*/
|
|
114
|
+
svg?: string;
|
|
115
|
+
/**
|
|
116
|
+
* LaTeX representation
|
|
117
|
+
*/
|
|
118
|
+
latex?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Markdown representation
|
|
121
|
+
*/
|
|
122
|
+
markdown?: string;
|
|
123
|
+
/**
|
|
124
|
+
* JavaScript code to execute
|
|
125
|
+
*/
|
|
126
|
+
javascript?: string;
|
|
127
|
+
/**
|
|
128
|
+
* JSON data
|
|
129
|
+
*/
|
|
130
|
+
json?: any;
|
|
131
|
+
/**
|
|
132
|
+
* Chart data if the result is a visualization
|
|
133
|
+
*/
|
|
134
|
+
chart?: ChartData;
|
|
135
|
+
/**
|
|
136
|
+
* Raw data object
|
|
137
|
+
*/
|
|
138
|
+
data?: any;
|
|
139
|
+
/**
|
|
140
|
+
* Available output formats
|
|
141
|
+
*/
|
|
142
|
+
formats(): string[];
|
|
143
|
+
}
|
|
144
|
+
interface ChartData {
|
|
145
|
+
/**
|
|
146
|
+
* Type of chart
|
|
147
|
+
*/
|
|
148
|
+
type: 'line' | 'bar' | 'scatter' | 'pie' | 'histogram' | 'heatmap' | 'unknown';
|
|
149
|
+
/**
|
|
150
|
+
* Chart title
|
|
151
|
+
*/
|
|
152
|
+
title?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Chart data (format depends on library)
|
|
155
|
+
*/
|
|
156
|
+
data: any;
|
|
157
|
+
/**
|
|
158
|
+
* Chart layout/configuration
|
|
159
|
+
*/
|
|
160
|
+
layout?: any;
|
|
161
|
+
/**
|
|
162
|
+
* Additional configuration
|
|
163
|
+
*/
|
|
164
|
+
config?: any;
|
|
165
|
+
/**
|
|
166
|
+
* Library that generated the chart
|
|
167
|
+
*/
|
|
168
|
+
library?: 'matplotlib' | 'plotly' | 'altair' | 'seaborn' | 'unknown';
|
|
169
|
+
/**
|
|
170
|
+
* Base64 encoded image if available
|
|
171
|
+
*/
|
|
172
|
+
image?: string;
|
|
173
|
+
}
|
|
174
|
+
interface ExecutionError {
|
|
175
|
+
/**
|
|
176
|
+
* Error name/type (e.g., 'NameError', 'SyntaxError')
|
|
177
|
+
*/
|
|
178
|
+
name: string;
|
|
179
|
+
/**
|
|
180
|
+
* Error message
|
|
181
|
+
*/
|
|
182
|
+
value: string;
|
|
183
|
+
/**
|
|
184
|
+
* Stack trace
|
|
185
|
+
*/
|
|
186
|
+
traceback: string[];
|
|
187
|
+
/**
|
|
188
|
+
* Line number where error occurred
|
|
189
|
+
*/
|
|
190
|
+
lineNumber?: number;
|
|
191
|
+
}
|
|
192
|
+
interface ExecutionResult {
|
|
193
|
+
code: string;
|
|
194
|
+
logs: {
|
|
195
|
+
stdout: string[];
|
|
196
|
+
stderr: string[];
|
|
197
|
+
};
|
|
198
|
+
error?: ExecutionError;
|
|
199
|
+
executionCount?: number;
|
|
200
|
+
results: Array<{
|
|
201
|
+
text?: string;
|
|
202
|
+
html?: string;
|
|
203
|
+
png?: string;
|
|
204
|
+
jpeg?: string;
|
|
205
|
+
svg?: string;
|
|
206
|
+
latex?: string;
|
|
207
|
+
markdown?: string;
|
|
208
|
+
javascript?: string;
|
|
209
|
+
json?: any;
|
|
210
|
+
chart?: ChartData;
|
|
211
|
+
data?: any;
|
|
212
|
+
}>;
|
|
213
|
+
}
|
|
214
|
+
declare class Execution {
|
|
215
|
+
readonly code: string;
|
|
216
|
+
readonly context: CodeContext;
|
|
217
|
+
/**
|
|
218
|
+
* All results from the execution
|
|
219
|
+
*/
|
|
220
|
+
results: Result[];
|
|
221
|
+
/**
|
|
222
|
+
* Accumulated stdout and stderr
|
|
223
|
+
*/
|
|
224
|
+
logs: {
|
|
225
|
+
stdout: string[];
|
|
226
|
+
stderr: string[];
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Execution error if any
|
|
230
|
+
*/
|
|
231
|
+
error?: ExecutionError;
|
|
232
|
+
/**
|
|
233
|
+
* Execution count (for Jupyter)
|
|
234
|
+
*/
|
|
235
|
+
executionCount?: number;
|
|
236
|
+
constructor(code: string, context: CodeContext);
|
|
237
|
+
/**
|
|
238
|
+
* Convert to a plain object for serialization
|
|
239
|
+
*/
|
|
240
|
+
toJSON(): ExecutionResult;
|
|
241
|
+
}
|
|
242
|
+
declare class ResultImpl implements Result {
|
|
243
|
+
private raw;
|
|
244
|
+
constructor(raw: any);
|
|
245
|
+
get text(): string | undefined;
|
|
246
|
+
get html(): string | undefined;
|
|
247
|
+
get png(): string | undefined;
|
|
248
|
+
get jpeg(): string | undefined;
|
|
249
|
+
get svg(): string | undefined;
|
|
250
|
+
get latex(): string | undefined;
|
|
251
|
+
get markdown(): string | undefined;
|
|
252
|
+
get javascript(): string | undefined;
|
|
253
|
+
get json(): any;
|
|
254
|
+
get chart(): ChartData | undefined;
|
|
255
|
+
get data(): any;
|
|
256
|
+
formats(): string[];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export { type ChartData, type CodeContext, type CreateContextOptions, Execution, type ExecutionError, type ExecutionResult, type OutputMessage, type Result, ResultImpl, type RunCodeOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CreateContextOptions, CodeContext, RunCodeOptions, Execution } from './interpreter-types.js';
|
|
2
|
+
import { S as Sandbox } from './client-bzEV222a.js';
|
|
3
|
+
import '@cloudflare/containers';
|
|
4
|
+
import './types.js';
|
|
5
|
+
|
|
6
|
+
declare class CodeInterpreter {
|
|
7
|
+
private jupyterClient;
|
|
8
|
+
private contexts;
|
|
9
|
+
constructor(sandbox: Sandbox);
|
|
10
|
+
/**
|
|
11
|
+
* Create a new code execution context
|
|
12
|
+
*/
|
|
13
|
+
createCodeContext(options?: CreateContextOptions): Promise<CodeContext>;
|
|
14
|
+
/**
|
|
15
|
+
* Run code with optional context
|
|
16
|
+
*/
|
|
17
|
+
runCode(code: string, options?: RunCodeOptions): Promise<Execution>;
|
|
18
|
+
/**
|
|
19
|
+
* Run code and return a streaming response
|
|
20
|
+
*/
|
|
21
|
+
runCodeStream(code: string, options?: RunCodeOptions): Promise<ReadableStream>;
|
|
22
|
+
/**
|
|
23
|
+
* List all code contexts
|
|
24
|
+
*/
|
|
25
|
+
listCodeContexts(): Promise<CodeContext[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Delete a code context
|
|
28
|
+
*/
|
|
29
|
+
deleteCodeContext(contextId: string): Promise<void>;
|
|
30
|
+
private getOrCreateDefaultContext;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { CodeInterpreter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/request-handler.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isLocalhostPattern,
|
|
3
3
|
proxyToSandbox
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-YVZ3K26G.js";
|
|
4
|
+
} from "./chunk-ZMPO44U4.js";
|
|
6
5
|
import "./chunk-6UAWTJ5S.js";
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-NNGBXDMY.js";
|
|
7
|
+
import "./chunk-S5FFBU4Y.js";
|
|
8
|
+
import "./chunk-FKBV7CZS.js";
|
|
9
|
+
import "./chunk-EGC5IYXA.js";
|
|
10
|
+
import "./chunk-VTKZL632.js";
|
|
11
|
+
import "./chunk-CUHYLCMT.js";
|
|
12
|
+
import "./chunk-LALY4SFU.js";
|
|
8
13
|
export {
|
|
9
14
|
isLocalhostPattern,
|
|
10
15
|
proxyToSandbox
|
package/dist/sandbox.d.ts
CHANGED
package/dist/sandbox.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Sandbox,
|
|
3
3
|
getSandbox
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-YVZ3K26G.js";
|
|
4
|
+
} from "./chunk-ZMPO44U4.js";
|
|
6
5
|
import "./chunk-6UAWTJ5S.js";
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-NNGBXDMY.js";
|
|
7
|
+
import "./chunk-S5FFBU4Y.js";
|
|
8
|
+
import "./chunk-FKBV7CZS.js";
|
|
9
|
+
import "./chunk-EGC5IYXA.js";
|
|
10
|
+
import "./chunk-VTKZL632.js";
|
|
11
|
+
import "./chunk-CUHYLCMT.js";
|
|
12
|
+
import "./chunk-LALY4SFU.js";
|
|
8
13
|
export {
|
|
9
14
|
Sandbox,
|
|
10
15
|
getSandbox
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CreateContextOptions, CodeContext, RunCodeOptions, ExecutionResult } from './interpreter-types.js';
|
|
2
|
+
|
|
1
3
|
interface BaseExecOptions {
|
|
2
4
|
/**
|
|
3
5
|
* Session ID for grouping related commands
|
|
@@ -260,6 +262,7 @@ interface GetProcessLogsResponse {
|
|
|
260
262
|
stderr: string;
|
|
261
263
|
processId: string;
|
|
262
264
|
}
|
|
265
|
+
|
|
263
266
|
interface ISandbox {
|
|
264
267
|
exec(command: string, options?: ExecOptions): Promise<ExecResult>;
|
|
265
268
|
startProcess(command: string, options?: ProcessOptions): Promise<Process>;
|
|
@@ -276,6 +279,11 @@ interface ISandbox {
|
|
|
276
279
|
stdout: string;
|
|
277
280
|
stderr: string;
|
|
278
281
|
}>;
|
|
282
|
+
createCodeContext(options?: CreateContextOptions): Promise<CodeContext>;
|
|
283
|
+
runCode(code: string, options?: RunCodeOptions): Promise<ExecutionResult>;
|
|
284
|
+
runCodeStream(code: string, options?: RunCodeOptions): Promise<ReadableStream>;
|
|
285
|
+
listCodeContexts(): Promise<CodeContext[]>;
|
|
286
|
+
deleteCodeContext(contextId: string): Promise<void>;
|
|
279
287
|
}
|
|
280
288
|
declare function isExecResult(value: any): value is ExecResult;
|
|
281
289
|
declare function isProcess(value: any): value is Process;
|
package/dist/types.js
CHANGED