@cloudflare/sandbox 0.3.6 → 0.4.1
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/.turbo/turbo-build.log +44 -0
- package/CHANGELOG.md +6 -8
- package/Dockerfile +88 -18
- package/README.md +89 -824
- package/dist/{chunk-JTKON2SH.js → chunk-BCJ7SF3Q.js} +9 -5
- package/dist/chunk-BCJ7SF3Q.js.map +1 -0
- package/dist/chunk-BFVUNTP4.js +104 -0
- package/dist/chunk-BFVUNTP4.js.map +1 -0
- package/dist/{chunk-NNGBXDMY.js → chunk-EKSWCBCA.js} +3 -6
- package/dist/chunk-EKSWCBCA.js.map +1 -0
- package/dist/chunk-HGF554LH.js +2236 -0
- package/dist/chunk-HGF554LH.js.map +1 -0
- package/dist/{chunk-6UAWTJ5S.js → chunk-Z532A7QC.js} +13 -20
- package/dist/{chunk-6UAWTJ5S.js.map → chunk-Z532A7QC.js.map} +1 -1
- package/dist/file-stream.d.ts +16 -38
- package/dist/file-stream.js +1 -2
- package/dist/index.d.ts +6 -5
- package/dist/index.js +35 -39
- package/dist/index.js.map +1 -1
- package/dist/interpreter.d.ts +3 -3
- package/dist/interpreter.js +2 -2
- package/dist/request-handler.d.ts +4 -3
- package/dist/request-handler.js +4 -7
- package/dist/sandbox-D9K2ypln.d.ts +583 -0
- package/dist/sandbox.d.ts +3 -3
- package/dist/sandbox.js +4 -7
- package/dist/security.d.ts +4 -3
- package/dist/security.js +3 -3
- package/dist/sse-parser.js +1 -1
- package/package.json +11 -5
- package/src/clients/base-client.ts +280 -0
- package/src/clients/command-client.ts +115 -0
- package/src/clients/file-client.ts +269 -0
- package/src/clients/git-client.ts +92 -0
- package/src/clients/index.ts +63 -0
- package/src/{interpreter-client.ts → clients/interpreter-client.ts} +148 -171
- package/src/clients/port-client.ts +105 -0
- package/src/clients/process-client.ts +177 -0
- package/src/clients/sandbox-client.ts +41 -0
- package/src/clients/types.ts +84 -0
- package/src/clients/utility-client.ts +94 -0
- package/src/errors/adapter.ts +180 -0
- package/src/errors/classes.ts +469 -0
- package/src/errors/index.ts +105 -0
- package/src/file-stream.ts +119 -117
- package/src/index.ts +81 -69
- package/src/interpreter.ts +17 -8
- package/src/request-handler.ts +69 -43
- package/src/sandbox.ts +694 -533
- package/src/security.ts +14 -23
- package/src/sse-parser.ts +4 -8
- package/startup.sh +3 -0
- package/tests/base-client.test.ts +328 -0
- package/tests/command-client.test.ts +407 -0
- package/tests/file-client.test.ts +643 -0
- package/tests/file-stream.test.ts +306 -0
- package/tests/git-client.test.ts +328 -0
- package/tests/port-client.test.ts +301 -0
- package/tests/process-client.test.ts +658 -0
- package/tests/sandbox.test.ts +465 -0
- package/tests/sse-parser.test.ts +290 -0
- package/tests/utility-client.test.ts +266 -0
- package/tests/wrangler.jsonc +35 -0
- package/tsconfig.json +9 -1
- package/vitest.config.ts +31 -0
- package/container_src/bun.lock +0 -76
- package/container_src/circuit-breaker.ts +0 -121
- package/container_src/control-process.ts +0 -784
- package/container_src/handler/exec.ts +0 -185
- package/container_src/handler/file.ts +0 -457
- package/container_src/handler/git.ts +0 -130
- package/container_src/handler/ports.ts +0 -314
- package/container_src/handler/process.ts +0 -568
- package/container_src/handler/session.ts +0 -92
- package/container_src/index.ts +0 -601
- package/container_src/interpreter-service.ts +0 -276
- package/container_src/isolation.ts +0 -1213
- package/container_src/mime-processor.ts +0 -255
- package/container_src/package.json +0 -18
- package/container_src/runtime/executors/javascript/node_executor.ts +0 -123
- package/container_src/runtime/executors/python/ipython_executor.py +0 -338
- package/container_src/runtime/executors/typescript/ts_executor.ts +0 -138
- package/container_src/runtime/process-pool.ts +0 -464
- package/container_src/shell-escape.ts +0 -42
- package/container_src/startup.sh +0 -11
- package/container_src/types.ts +0 -131
- package/dist/chunk-32UDXUPC.js +0 -671
- package/dist/chunk-32UDXUPC.js.map +0 -1
- package/dist/chunk-5DILEXGY.js +0 -85
- package/dist/chunk-5DILEXGY.js.map +0 -1
- package/dist/chunk-D3U63BZP.js +0 -240
- package/dist/chunk-D3U63BZP.js.map +0 -1
- package/dist/chunk-FXYPFGOZ.js +0 -129
- package/dist/chunk-FXYPFGOZ.js.map +0 -1
- package/dist/chunk-JTKON2SH.js.map +0 -1
- package/dist/chunk-NNGBXDMY.js.map +0 -1
- package/dist/chunk-SQLJNZ3K.js +0 -674
- package/dist/chunk-SQLJNZ3K.js.map +0 -1
- package/dist/chunk-W7TVRPBG.js +0 -108
- package/dist/chunk-W7TVRPBG.js.map +0 -1
- package/dist/client-B3RUab0s.d.ts +0 -225
- package/dist/client.d.ts +0 -4
- package/dist/client.js +0 -7
- package/dist/client.js.map +0 -1
- package/dist/errors.d.ts +0 -95
- package/dist/errors.js +0 -27
- package/dist/errors.js.map +0 -1
- package/dist/interpreter-client.d.ts +0 -4
- package/dist/interpreter-client.js +0 -9
- package/dist/interpreter-client.js.map +0 -1
- package/dist/interpreter-types.d.ts +0 -259
- package/dist/interpreter-types.js +0 -9
- package/dist/interpreter-types.js.map +0 -1
- package/dist/types.d.ts +0 -453
- package/dist/types.js +0 -45
- package/dist/types.js.map +0 -1
- package/src/client.ts +0 -1048
- package/src/errors.ts +0 -219
- package/src/interpreter-types.ts +0 -390
- package/src/types.ts +0 -571
package/dist/index.js
CHANGED
|
@@ -1,56 +1,52 @@
|
|
|
1
1
|
import {
|
|
2
2
|
collectFile,
|
|
3
3
|
streamFile
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
asyncIterableToSSEStream,
|
|
7
|
-
parseSSEStream,
|
|
8
|
-
responseToAsyncIterable
|
|
9
|
-
} from "./chunk-NNGBXDMY.js";
|
|
4
|
+
} from "./chunk-BFVUNTP4.js";
|
|
10
5
|
import {
|
|
6
|
+
CommandClient,
|
|
7
|
+
FileClient,
|
|
8
|
+
GitClient,
|
|
9
|
+
PortClient,
|
|
10
|
+
ProcessClient,
|
|
11
11
|
Sandbox,
|
|
12
|
+
SandboxClient,
|
|
13
|
+
UtilityClient,
|
|
12
14
|
getSandbox,
|
|
13
15
|
proxyToSandbox
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-6UAWTJ5S.js";
|
|
16
|
-
import "./chunk-D3U63BZP.js";
|
|
17
|
-
import "./chunk-32UDXUPC.js";
|
|
16
|
+
} from "./chunk-HGF554LH.js";
|
|
18
17
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} from "./chunk-FXYPFGOZ.js";
|
|
31
|
-
import "./chunk-JTKON2SH.js";
|
|
18
|
+
CodeInterpreter
|
|
19
|
+
} from "./chunk-BCJ7SF3Q.js";
|
|
20
|
+
import "./chunk-Z532A7QC.js";
|
|
21
|
+
import {
|
|
22
|
+
asyncIterableToSSEStream,
|
|
23
|
+
parseSSEStream,
|
|
24
|
+
responseToAsyncIterable
|
|
25
|
+
} from "./chunk-EKSWCBCA.js";
|
|
26
|
+
|
|
27
|
+
// src/index.ts
|
|
28
|
+
export * from "@repo/shared";
|
|
32
29
|
import {
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
isExecResult,
|
|
31
|
+
isProcess,
|
|
32
|
+
isProcessStatus
|
|
33
|
+
} from "@repo/shared";
|
|
35
34
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
CodeInterpreter,
|
|
36
|
+
CommandClient,
|
|
37
|
+
FileClient,
|
|
38
|
+
GitClient,
|
|
39
|
+
PortClient,
|
|
40
|
+
ProcessClient,
|
|
42
41
|
Sandbox,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
ServiceUnavailableError,
|
|
42
|
+
SandboxClient,
|
|
43
|
+
UtilityClient,
|
|
46
44
|
asyncIterableToSSEStream,
|
|
47
45
|
collectFile,
|
|
48
46
|
getSandbox,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
isSandboxError,
|
|
53
|
-
parseErrorResponse,
|
|
47
|
+
isExecResult,
|
|
48
|
+
isProcess,
|
|
49
|
+
isProcessStatus,
|
|
54
50
|
parseSSEStream,
|
|
55
51
|
proxyToSandbox,
|
|
56
52
|
responseToAsyncIterable,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Export the main Sandbox class and utilities\n\n\n// Export the new client architecture\nexport {\n CommandClient,\n FileClient,\n GitClient,\n PortClient,\n ProcessClient,\n SandboxClient,\n UtilityClient\n} from \"./clients\";\nexport { getSandbox, Sandbox } from \"./sandbox\";\n\n// Legacy types are now imported from the new client architecture\n\n// Export core SDK types for consumers\nexport type {\n BaseExecOptions,\n ExecEvent,\n ExecOptions,\n ExecResult,FileChunk, FileMetadata, FileStreamEvent, \n ISandbox,\n LogEvent,\n Process,\n ProcessOptions,\n ProcessStatus,\n StreamOptions \n} from \"@repo/shared\";\nexport * from '@repo/shared';\n// Export type guards for runtime validation\nexport {\n isExecResult,\n isProcess,\n isProcessStatus\n} from \"@repo/shared\";\n// Export all client types from new architecture\nexport type {\n BaseApiResponse,\n CommandsResponse,\n ContainerStub,\n ErrorResponse,\n\n // Command client types\n ExecuteRequest,\n ExecuteResponse as CommandExecuteResponse,\n\n // Port client types\n ExposePortRequest,\n FileOperationRequest,\n\n // Git client types\n GitCheckoutRequest,\n GitCheckoutResult,\n // Base client types\n HttpClientOptions as SandboxClientOptions,\n\n // File client types\n MkdirRequest,\n\n // Utility client types\n PingResponse,\n PortCloseResult,\n PortExposeResult,\n PortListResult,\n ProcessCleanupResult,\n ProcessInfoResult,\n ProcessKillResult,\n ProcessListResult,\n ProcessLogsResult,\n ProcessStartResult,\n ReadFileRequest,\n RequestConfig,\n ResponseHandler,\n SessionRequest,\n\n // Process client types\n StartProcessRequest,\n UnexposePortRequest,\n WriteFileRequest\n} from \"./clients\";\nexport type { ExecutionCallbacks, InterpreterClient } from './clients/interpreter-client.js';\n// Export file streaming utilities for binary file support\nexport { collectFile, streamFile } from './file-stream';\n// Export interpreter functionality\nexport { CodeInterpreter } from './interpreter.js';\n// Re-export request handler utilities\nexport {\n proxyToSandbox, type RouteInfo, type SandboxEnv\n} from './request-handler';\n// Export SSE parser for converting ReadableStream to AsyncIterable\nexport { asyncIterableToSSEStream, parseSSEStream, responseToAsyncIterable } from \"./sse-parser\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
|
package/dist/interpreter.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CreateContextOptions, CodeContext, RunCodeOptions, Execution } from '
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
1
|
+
import { CreateContextOptions, CodeContext, RunCodeOptions, Execution } from '@repo/shared';
|
|
2
|
+
import { b as Sandbox } from './sandbox-D9K2ypln.js';
|
|
3
|
+
import 'cloudflare:workers';
|
|
4
4
|
import '@cloudflare/containers';
|
|
5
5
|
|
|
6
6
|
declare class CodeInterpreter {
|
package/dist/interpreter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
1
|
+
import { b as Sandbox } from './sandbox-D9K2ypln.js';
|
|
2
|
+
import '@repo/shared';
|
|
3
|
+
import 'cloudflare:workers';
|
|
4
4
|
import '@cloudflare/containers';
|
|
5
5
|
|
|
6
6
|
interface SandboxEnv {
|
|
@@ -10,6 +10,7 @@ interface RouteInfo {
|
|
|
10
10
|
port: number;
|
|
11
11
|
sandboxId: string;
|
|
12
12
|
path: string;
|
|
13
|
+
token: string;
|
|
13
14
|
}
|
|
14
15
|
declare function proxyToSandbox<E extends SandboxEnv>(request: Request, env: E): Promise<Response | null>;
|
|
15
16
|
declare function isLocalhostPattern(hostname: string): boolean;
|
package/dist/request-handler.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isLocalhostPattern,
|
|
3
3
|
proxyToSandbox
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-FXYPFGOZ.js";
|
|
9
|
-
import "./chunk-JTKON2SH.js";
|
|
10
|
-
import "./chunk-W7TVRPBG.js";
|
|
4
|
+
} from "./chunk-HGF554LH.js";
|
|
5
|
+
import "./chunk-BCJ7SF3Q.js";
|
|
6
|
+
import "./chunk-Z532A7QC.js";
|
|
7
|
+
import "./chunk-EKSWCBCA.js";
|
|
11
8
|
export {
|
|
12
9
|
isLocalhostPattern,
|
|
13
10
|
proxyToSandbox
|