@cloudflare/sandbox 0.4.1 → 0.4.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @cloudflare/sandbox@0.4.1 build
2
+ > @cloudflare/sandbox@0.4.2 build
3
3
  > rm -rf dist && tsup src/*.ts --outDir dist --dts --sourcemap --format esm
4
4
 
5
5
  CLI Building entry: src/file-stream.ts, src/index.ts, src/interpreter.ts, src/request-handler.ts, src/sandbox.ts, src/security.ts, src/sse-parser.ts
@@ -8,32 +8,32 @@
8
8
  CLI Target: es2022
9
9
  ESM Build start
10
10
  ESM dist/file-stream.js 146.00 B
11
- ESM dist/index.js 946.00 B
12
- ESM dist/chunk-BFVUNTP4.js 2.76 KB
13
11
  ESM dist/interpreter.js 156.00 B
14
- ESM dist/request-handler.js 262.00 B
12
+ ESM dist/chunk-BFVUNTP4.js 2.76 KB
15
13
  ESM dist/sandbox.js 224.00 B
16
- ESM dist/chunk-HGF554LH.js 67.41 KB
17
- ESM dist/chunk-BCJ7SF3Q.js 3.26 KB
14
+ ESM dist/chunk-53JFOF7F.js 71.29 KB
15
+ ESM dist/chunk-JXZMAU2C.js 14.43 KB
18
16
  ESM dist/security.js 233.00 B
19
17
  ESM dist/chunk-Z532A7QC.js 1.75 KB
20
- ESM dist/sse-parser.js 233.00 B
21
18
  ESM dist/chunk-EKSWCBCA.js 2.28 KB
19
+ ESM dist/sse-parser.js 233.00 B
20
+ ESM dist/index.js 1.10 KB
21
+ ESM dist/request-handler.js 262.00 B
22
22
  ESM dist/file-stream.js.map 71.00 B
23
- ESM dist/index.js.map 2.45 KB
24
- ESM dist/chunk-BFVUNTP4.js.map 6.71 KB
25
23
  ESM dist/interpreter.js.map 71.00 B
26
- ESM dist/request-handler.js.map 71.00 B
24
+ ESM dist/chunk-BFVUNTP4.js.map 6.71 KB
27
25
  ESM dist/sandbox.js.map 71.00 B
28
- ESM dist/chunk-HGF554LH.js.map 142.71 KB
29
- ESM dist/chunk-BCJ7SF3Q.js.map 6.88 KB
30
26
  ESM dist/security.js.map 71.00 B
31
27
  ESM dist/chunk-Z532A7QC.js.map 3.96 KB
32
- ESM dist/sse-parser.js.map 71.00 B
28
+ ESM dist/chunk-JXZMAU2C.js.map 33.44 KB
33
29
  ESM dist/chunk-EKSWCBCA.js.map 5.61 KB
34
- ESM ⚡️ Build success in 96ms
30
+ ESM dist/sse-parser.js.map 71.00 B
31
+ ESM dist/index.js.map 71.00 B
32
+ ESM dist/chunk-53JFOF7F.js.map 146.99 KB
33
+ ESM dist/request-handler.js.map 71.00 B
34
+ ESM ⚡️ Build success in 85ms
35
35
  DTS Build start
36
- DTS ⚡️ Build success in 2620ms
36
+ DTS ⚡️ Build success in 2233ms
37
37
  DTS dist/index.d.ts 1.46 KB
38
38
  DTS dist/file-stream.d.ts 1.34 KB
39
39
  DTS dist/interpreter.d.ts 1007.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @cloudflare/sandbox
2
2
 
3
+ ## 0.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e53d7e7`](https://github.com/cloudflare/sandbox-sdk/commit/e53d7e7ce185f79bdd899029bb532e9651ae7ba5) Thanks [@threepointone](https://github.com/threepointone)! - fix build by inlining repo/shared
8
+
3
9
  ## 0.4.1
4
10
 
5
11
  ### Patch Changes
@@ -1,6 +1,11 @@
1
1
  import {
2
- CodeInterpreter
3
- } from "./chunk-BCJ7SF3Q.js";
2
+ CodeInterpreter,
3
+ ResultImpl,
4
+ TraceContext,
5
+ createLogger,
6
+ createNoOpLogger,
7
+ runWithLogger
8
+ } from "./chunk-JXZMAU2C.js";
4
9
  import {
5
10
  SecurityError,
6
11
  sanitizeSandboxId,
@@ -10,21 +15,135 @@ import {
10
15
  parseSSEStream
11
16
  } from "./chunk-EKSWCBCA.js";
12
17
 
13
- // src/request-handler.ts
14
- import { createLogger as createLogger2, TraceContext as TraceContext2 } from "@repo/shared";
15
-
16
18
  // src/sandbox.ts
17
19
  import { Container, getContainer } from "@cloudflare/containers";
18
- import { createLogger, runWithLogger, TraceContext } from "@repo/shared";
19
-
20
- // src/clients/base-client.ts
21
- import { createNoOpLogger } from "@repo/shared";
22
20
 
23
- // src/errors/index.ts
24
- import { ErrorCode as ErrorCode2, Operation } from "@repo/shared/errors";
21
+ // ../shared/dist/errors/codes.js
22
+ var ErrorCode = {
23
+ // File System Errors (404)
24
+ FILE_NOT_FOUND: "FILE_NOT_FOUND",
25
+ // Permission Errors (403)
26
+ PERMISSION_DENIED: "PERMISSION_DENIED",
27
+ // File System Errors (409)
28
+ FILE_EXISTS: "FILE_EXISTS",
29
+ // File System Errors (400)
30
+ IS_DIRECTORY: "IS_DIRECTORY",
31
+ NOT_DIRECTORY: "NOT_DIRECTORY",
32
+ // File System Errors (500)
33
+ NO_SPACE: "NO_SPACE",
34
+ TOO_MANY_FILES: "TOO_MANY_FILES",
35
+ RESOURCE_BUSY: "RESOURCE_BUSY",
36
+ READ_ONLY: "READ_ONLY",
37
+ NAME_TOO_LONG: "NAME_TOO_LONG",
38
+ TOO_MANY_LINKS: "TOO_MANY_LINKS",
39
+ FILESYSTEM_ERROR: "FILESYSTEM_ERROR",
40
+ // Command Errors (404)
41
+ COMMAND_NOT_FOUND: "COMMAND_NOT_FOUND",
42
+ // Command Errors (403/400)
43
+ COMMAND_PERMISSION_DENIED: "COMMAND_PERMISSION_DENIED",
44
+ INVALID_COMMAND: "INVALID_COMMAND",
45
+ // Command Errors (500)
46
+ COMMAND_EXECUTION_ERROR: "COMMAND_EXECUTION_ERROR",
47
+ STREAM_START_ERROR: "STREAM_START_ERROR",
48
+ // Process Errors (404)
49
+ PROCESS_NOT_FOUND: "PROCESS_NOT_FOUND",
50
+ // Process Errors (403/500)
51
+ PROCESS_PERMISSION_DENIED: "PROCESS_PERMISSION_DENIED",
52
+ PROCESS_ERROR: "PROCESS_ERROR",
53
+ // Port Errors (409)
54
+ PORT_ALREADY_EXPOSED: "PORT_ALREADY_EXPOSED",
55
+ PORT_IN_USE: "PORT_IN_USE",
56
+ // Port Errors (404)
57
+ PORT_NOT_EXPOSED: "PORT_NOT_EXPOSED",
58
+ // Port Errors (400)
59
+ INVALID_PORT_NUMBER: "INVALID_PORT_NUMBER",
60
+ INVALID_PORT: "INVALID_PORT",
61
+ // Port Errors (502/500)
62
+ SERVICE_NOT_RESPONDING: "SERVICE_NOT_RESPONDING",
63
+ PORT_OPERATION_ERROR: "PORT_OPERATION_ERROR",
64
+ // Port Errors (400)
65
+ CUSTOM_DOMAIN_REQUIRED: "CUSTOM_DOMAIN_REQUIRED",
66
+ // Git Errors (404)
67
+ GIT_REPOSITORY_NOT_FOUND: "GIT_REPOSITORY_NOT_FOUND",
68
+ GIT_BRANCH_NOT_FOUND: "GIT_BRANCH_NOT_FOUND",
69
+ // Git Errors (401)
70
+ GIT_AUTH_FAILED: "GIT_AUTH_FAILED",
71
+ // Git Errors (502)
72
+ GIT_NETWORK_ERROR: "GIT_NETWORK_ERROR",
73
+ // Git Errors (400)
74
+ INVALID_GIT_URL: "INVALID_GIT_URL",
75
+ // Git Errors (500)
76
+ GIT_CLONE_FAILED: "GIT_CLONE_FAILED",
77
+ GIT_CHECKOUT_FAILED: "GIT_CHECKOUT_FAILED",
78
+ GIT_OPERATION_FAILED: "GIT_OPERATION_FAILED",
79
+ // Code Interpreter Errors (503)
80
+ INTERPRETER_NOT_READY: "INTERPRETER_NOT_READY",
81
+ // Code Interpreter Errors (404)
82
+ CONTEXT_NOT_FOUND: "CONTEXT_NOT_FOUND",
83
+ // Code Interpreter Errors (500)
84
+ CODE_EXECUTION_ERROR: "CODE_EXECUTION_ERROR",
85
+ // Validation Errors (400)
86
+ VALIDATION_FAILED: "VALIDATION_FAILED",
87
+ // Generic Errors (400/500)
88
+ INVALID_JSON_RESPONSE: "INVALID_JSON_RESPONSE",
89
+ UNKNOWN_ERROR: "UNKNOWN_ERROR",
90
+ INTERNAL_ERROR: "INTERNAL_ERROR"
91
+ };
25
92
 
26
- // src/errors/adapter.ts
27
- import { ErrorCode } from "@repo/shared/errors";
93
+ // ../shared/dist/errors/status-map.js
94
+ var ERROR_STATUS_MAP = {
95
+ // 404 Not Found
96
+ [ErrorCode.FILE_NOT_FOUND]: 404,
97
+ [ErrorCode.COMMAND_NOT_FOUND]: 404,
98
+ [ErrorCode.PROCESS_NOT_FOUND]: 404,
99
+ [ErrorCode.PORT_NOT_EXPOSED]: 404,
100
+ [ErrorCode.GIT_REPOSITORY_NOT_FOUND]: 404,
101
+ [ErrorCode.GIT_BRANCH_NOT_FOUND]: 404,
102
+ [ErrorCode.CONTEXT_NOT_FOUND]: 404,
103
+ // 400 Bad Request
104
+ [ErrorCode.IS_DIRECTORY]: 400,
105
+ [ErrorCode.NOT_DIRECTORY]: 400,
106
+ [ErrorCode.INVALID_COMMAND]: 400,
107
+ [ErrorCode.INVALID_PORT_NUMBER]: 400,
108
+ [ErrorCode.INVALID_PORT]: 400,
109
+ [ErrorCode.INVALID_GIT_URL]: 400,
110
+ [ErrorCode.CUSTOM_DOMAIN_REQUIRED]: 400,
111
+ [ErrorCode.INVALID_JSON_RESPONSE]: 400,
112
+ [ErrorCode.NAME_TOO_LONG]: 400,
113
+ [ErrorCode.VALIDATION_FAILED]: 400,
114
+ // 401 Unauthorized
115
+ [ErrorCode.GIT_AUTH_FAILED]: 401,
116
+ // 403 Forbidden
117
+ [ErrorCode.PERMISSION_DENIED]: 403,
118
+ [ErrorCode.COMMAND_PERMISSION_DENIED]: 403,
119
+ [ErrorCode.PROCESS_PERMISSION_DENIED]: 403,
120
+ [ErrorCode.READ_ONLY]: 403,
121
+ // 409 Conflict
122
+ [ErrorCode.FILE_EXISTS]: 409,
123
+ [ErrorCode.PORT_ALREADY_EXPOSED]: 409,
124
+ [ErrorCode.PORT_IN_USE]: 409,
125
+ [ErrorCode.RESOURCE_BUSY]: 409,
126
+ // 502 Bad Gateway
127
+ [ErrorCode.SERVICE_NOT_RESPONDING]: 502,
128
+ [ErrorCode.GIT_NETWORK_ERROR]: 502,
129
+ // 503 Service Unavailable
130
+ [ErrorCode.INTERPRETER_NOT_READY]: 503,
131
+ // 500 Internal Server Error
132
+ [ErrorCode.NO_SPACE]: 500,
133
+ [ErrorCode.TOO_MANY_FILES]: 500,
134
+ [ErrorCode.TOO_MANY_LINKS]: 500,
135
+ [ErrorCode.FILESYSTEM_ERROR]: 500,
136
+ [ErrorCode.COMMAND_EXECUTION_ERROR]: 500,
137
+ [ErrorCode.STREAM_START_ERROR]: 500,
138
+ [ErrorCode.PROCESS_ERROR]: 500,
139
+ [ErrorCode.PORT_OPERATION_ERROR]: 500,
140
+ [ErrorCode.GIT_CLONE_FAILED]: 500,
141
+ [ErrorCode.GIT_CHECKOUT_FAILED]: 500,
142
+ [ErrorCode.GIT_OPERATION_FAILED]: 500,
143
+ [ErrorCode.CODE_EXECUTION_ERROR]: 500,
144
+ [ErrorCode.UNKNOWN_ERROR]: 500,
145
+ [ErrorCode.INTERNAL_ERROR]: 500
146
+ };
28
147
 
29
148
  // src/errors/classes.ts
30
149
  var SandboxError = class extends Error {
@@ -600,7 +719,7 @@ var BaseHttpClient = class {
600
719
  return await response.json();
601
720
  } catch (error) {
602
721
  const errorResponse = {
603
- code: ErrorCode2.INVALID_JSON_RESPONSE,
722
+ code: ErrorCode.INVALID_JSON_RESPONSE,
604
723
  message: `Invalid JSON response: ${error instanceof Error ? error.message : "Unknown parsing error"}`,
605
724
  context: {},
606
725
  httpStatus: response.status,
@@ -618,7 +737,7 @@ var BaseHttpClient = class {
618
737
  errorData = await response.json();
619
738
  } catch {
620
739
  errorData = {
621
- code: ErrorCode2.INTERNAL_ERROR,
740
+ code: ErrorCode.INTERNAL_ERROR,
622
741
  message: `HTTP error! status: ${response.status}`,
623
742
  context: { statusText: response.statusText },
624
743
  httpStatus: response.status,
@@ -995,9 +1114,6 @@ var GitClient = class extends BaseHttpClient {
995
1114
  };
996
1115
 
997
1116
  // src/clients/interpreter-client.ts
998
- import {
999
- ResultImpl
1000
- } from "@repo/shared";
1001
1117
  var InterpreterClient = class extends BaseHttpClient {
1002
1118
  maxRetries = 3;
1003
1119
  retryDelayMs = 1e3;
@@ -1129,7 +1245,7 @@ var InterpreterClient = class extends BaseHttpClient {
1129
1245
  return createErrorFromResponse(errorData);
1130
1246
  } catch {
1131
1247
  const errorResponse = {
1132
- code: ErrorCode2.INTERNAL_ERROR,
1248
+ code: ErrorCode.INTERNAL_ERROR,
1133
1249
  message: `HTTP ${response.status}: ${response.statusText}`,
1134
1250
  context: {},
1135
1251
  httpStatus: response.status,
@@ -1885,7 +2001,7 @@ var Sandbox = class extends Container {
1885
2001
  async exposePort(port, options) {
1886
2002
  if (options.hostname.endsWith(".workers.dev")) {
1887
2003
  const errorResponse = {
1888
- code: ErrorCode2.CUSTOM_DOMAIN_REQUIRED,
2004
+ code: ErrorCode.CUSTOM_DOMAIN_REQUIRED,
1889
2005
  message: `Port exposure requires a custom domain. .workers.dev domains do not support wildcard subdomains required for port proxying.`,
1890
2006
  context: { originalError: options.hostname },
1891
2007
  httpStatus: 400,
@@ -2109,8 +2225,8 @@ var Sandbox = class extends Container {
2109
2225
 
2110
2226
  // src/request-handler.ts
2111
2227
  async function proxyToSandbox(request, env) {
2112
- const traceId = TraceContext2.fromHeaders(request.headers) || TraceContext2.generate();
2113
- const logger = createLogger2({
2228
+ const traceId = TraceContext.fromHeaders(request.headers) || TraceContext.generate();
2229
+ const logger = createLogger({
2114
2230
  component: "sandbox-do",
2115
2231
  traceId,
2116
2232
  operation: "proxy"
@@ -2233,4 +2349,4 @@ export {
2233
2349
  getSandbox,
2234
2350
  Sandbox
2235
2351
  };
2236
- //# sourceMappingURL=chunk-HGF554LH.js.map
2352
+ //# sourceMappingURL=chunk-53JFOF7F.js.map