@cloudflare/sandbox 0.3.7 → 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.
Files changed (120) hide show
  1. package/.turbo/turbo-build.log +44 -0
  2. package/CHANGELOG.md +6 -14
  3. package/Dockerfile +82 -18
  4. package/README.md +89 -824
  5. package/dist/{chunk-JTKON2SH.js → chunk-BCJ7SF3Q.js} +9 -5
  6. package/dist/chunk-BCJ7SF3Q.js.map +1 -0
  7. package/dist/chunk-BFVUNTP4.js +104 -0
  8. package/dist/chunk-BFVUNTP4.js.map +1 -0
  9. package/dist/{chunk-NNGBXDMY.js → chunk-EKSWCBCA.js} +3 -6
  10. package/dist/chunk-EKSWCBCA.js.map +1 -0
  11. package/dist/chunk-HGF554LH.js +2236 -0
  12. package/dist/chunk-HGF554LH.js.map +1 -0
  13. package/dist/{chunk-6UAWTJ5S.js → chunk-Z532A7QC.js} +13 -20
  14. package/dist/{chunk-6UAWTJ5S.js.map → chunk-Z532A7QC.js.map} +1 -1
  15. package/dist/file-stream.d.ts +16 -38
  16. package/dist/file-stream.js +1 -2
  17. package/dist/index.d.ts +6 -5
  18. package/dist/index.js +35 -39
  19. package/dist/index.js.map +1 -1
  20. package/dist/interpreter.d.ts +3 -3
  21. package/dist/interpreter.js +2 -2
  22. package/dist/request-handler.d.ts +4 -3
  23. package/dist/request-handler.js +4 -7
  24. package/dist/sandbox-D9K2ypln.d.ts +583 -0
  25. package/dist/sandbox.d.ts +3 -3
  26. package/dist/sandbox.js +4 -7
  27. package/dist/security.d.ts +4 -3
  28. package/dist/security.js +3 -3
  29. package/dist/sse-parser.js +1 -1
  30. package/package.json +11 -5
  31. package/src/clients/base-client.ts +280 -0
  32. package/src/clients/command-client.ts +115 -0
  33. package/src/clients/file-client.ts +269 -0
  34. package/src/clients/git-client.ts +92 -0
  35. package/src/clients/index.ts +63 -0
  36. package/src/{interpreter-client.ts → clients/interpreter-client.ts} +148 -171
  37. package/src/clients/port-client.ts +105 -0
  38. package/src/clients/process-client.ts +177 -0
  39. package/src/clients/sandbox-client.ts +41 -0
  40. package/src/clients/types.ts +84 -0
  41. package/src/clients/utility-client.ts +94 -0
  42. package/src/errors/adapter.ts +180 -0
  43. package/src/errors/classes.ts +469 -0
  44. package/src/errors/index.ts +105 -0
  45. package/src/file-stream.ts +119 -117
  46. package/src/index.ts +81 -69
  47. package/src/interpreter.ts +17 -8
  48. package/src/request-handler.ts +69 -43
  49. package/src/sandbox.ts +694 -533
  50. package/src/security.ts +14 -23
  51. package/src/sse-parser.ts +4 -8
  52. package/startup.sh +3 -0
  53. package/tests/base-client.test.ts +328 -0
  54. package/tests/command-client.test.ts +407 -0
  55. package/tests/file-client.test.ts +643 -0
  56. package/tests/file-stream.test.ts +306 -0
  57. package/tests/git-client.test.ts +328 -0
  58. package/tests/port-client.test.ts +301 -0
  59. package/tests/process-client.test.ts +658 -0
  60. package/tests/sandbox.test.ts +465 -0
  61. package/tests/sse-parser.test.ts +290 -0
  62. package/tests/utility-client.test.ts +266 -0
  63. package/tests/wrangler.jsonc +35 -0
  64. package/tsconfig.json +9 -1
  65. package/vitest.config.ts +31 -0
  66. package/container_src/bun.lock +0 -76
  67. package/container_src/circuit-breaker.ts +0 -121
  68. package/container_src/control-process.ts +0 -784
  69. package/container_src/handler/exec.ts +0 -185
  70. package/container_src/handler/file.ts +0 -457
  71. package/container_src/handler/git.ts +0 -130
  72. package/container_src/handler/ports.ts +0 -314
  73. package/container_src/handler/process.ts +0 -568
  74. package/container_src/handler/session.ts +0 -92
  75. package/container_src/index.ts +0 -601
  76. package/container_src/interpreter-service.ts +0 -276
  77. package/container_src/isolation.ts +0 -1213
  78. package/container_src/mime-processor.ts +0 -255
  79. package/container_src/package.json +0 -18
  80. package/container_src/runtime/executors/javascript/node_executor.ts +0 -123
  81. package/container_src/runtime/executors/python/ipython_executor.py +0 -338
  82. package/container_src/runtime/executors/typescript/ts_executor.ts +0 -138
  83. package/container_src/runtime/process-pool.ts +0 -464
  84. package/container_src/shell-escape.ts +0 -42
  85. package/container_src/startup.sh +0 -11
  86. package/container_src/types.ts +0 -131
  87. package/dist/chunk-32UDXUPC.js +0 -671
  88. package/dist/chunk-32UDXUPC.js.map +0 -1
  89. package/dist/chunk-5DILEXGY.js +0 -85
  90. package/dist/chunk-5DILEXGY.js.map +0 -1
  91. package/dist/chunk-D3U63BZP.js +0 -240
  92. package/dist/chunk-D3U63BZP.js.map +0 -1
  93. package/dist/chunk-FXYPFGOZ.js +0 -129
  94. package/dist/chunk-FXYPFGOZ.js.map +0 -1
  95. package/dist/chunk-JTKON2SH.js.map +0 -1
  96. package/dist/chunk-NNGBXDMY.js.map +0 -1
  97. package/dist/chunk-SQLJNZ3K.js +0 -674
  98. package/dist/chunk-SQLJNZ3K.js.map +0 -1
  99. package/dist/chunk-W7TVRPBG.js +0 -108
  100. package/dist/chunk-W7TVRPBG.js.map +0 -1
  101. package/dist/client-B3RUab0s.d.ts +0 -225
  102. package/dist/client.d.ts +0 -4
  103. package/dist/client.js +0 -7
  104. package/dist/client.js.map +0 -1
  105. package/dist/errors.d.ts +0 -95
  106. package/dist/errors.js +0 -27
  107. package/dist/errors.js.map +0 -1
  108. package/dist/interpreter-client.d.ts +0 -4
  109. package/dist/interpreter-client.js +0 -9
  110. package/dist/interpreter-client.js.map +0 -1
  111. package/dist/interpreter-types.d.ts +0 -259
  112. package/dist/interpreter-types.js +0 -9
  113. package/dist/interpreter-types.js.map +0 -1
  114. package/dist/types.d.ts +0 -453
  115. package/dist/types.js +0 -45
  116. package/dist/types.js.map +0 -1
  117. package/src/client.ts +0 -1048
  118. package/src/errors.ts +0 -219
  119. package/src/interpreter-types.ts +0 -390
  120. 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-5DILEXGY.js";
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-SQLJNZ3K.js";
15
- import "./chunk-6UAWTJ5S.js";
16
- import "./chunk-D3U63BZP.js";
17
- import "./chunk-32UDXUPC.js";
16
+ } from "./chunk-HGF554LH.js";
18
17
  import {
19
- CodeExecutionError,
20
- ContainerNotReadyError,
21
- ContextNotFoundError,
22
- InterpreterNotReadyError,
23
- SandboxError,
24
- SandboxNetworkError,
25
- ServiceUnavailableError,
26
- isInterpreterNotReadyError,
27
- isRetryableError,
28
- isSandboxError,
29
- parseErrorResponse
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
- ResultImpl
34
- } from "./chunk-W7TVRPBG.js";
30
+ isExecResult,
31
+ isProcess,
32
+ isProcessStatus
33
+ } from "@repo/shared";
35
34
  export {
36
- CodeExecutionError,
37
- ContainerNotReadyError,
38
- ContextNotFoundError,
39
- InterpreterNotReadyError,
40
- InterpreterNotReadyError as JupyterNotReadyError,
41
- ResultImpl,
35
+ CodeInterpreter,
36
+ CommandClient,
37
+ FileClient,
38
+ GitClient,
39
+ PortClient,
40
+ ProcessClient,
42
41
  Sandbox,
43
- SandboxError,
44
- SandboxNetworkError,
45
- ServiceUnavailableError,
42
+ SandboxClient,
43
+ UtilityClient,
46
44
  asyncIterableToSSEStream,
47
45
  collectFile,
48
46
  getSandbox,
49
- isInterpreterNotReadyError,
50
- isInterpreterNotReadyError as isJupyterNotReadyError,
51
- isRetryableError,
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":[]}
@@ -1,6 +1,6 @@
1
- import { CreateContextOptions, CodeContext, RunCodeOptions, Execution } from './interpreter-types.js';
2
- import { S as Sandbox } from './client-B3RUab0s.js';
3
- import './types.js';
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 {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CodeInterpreter
3
- } from "./chunk-JTKON2SH.js";
4
- import "./chunk-W7TVRPBG.js";
3
+ } from "./chunk-BCJ7SF3Q.js";
4
+ import "./chunk-Z532A7QC.js";
5
5
  export {
6
6
  CodeInterpreter
7
7
  };
@@ -1,6 +1,6 @@
1
- import { S as Sandbox } from './client-B3RUab0s.js';
2
- import './types.js';
3
- import './interpreter-types.js';
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;
@@ -1,13 +1,10 @@
1
1
  import {
2
2
  isLocalhostPattern,
3
3
  proxyToSandbox
4
- } from "./chunk-SQLJNZ3K.js";
5
- import "./chunk-6UAWTJ5S.js";
6
- import "./chunk-D3U63BZP.js";
7
- import "./chunk-32UDXUPC.js";
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