@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.
- package/.turbo/turbo-build.log +15 -15
- package/CHANGELOG.md +6 -0
- package/dist/{chunk-HGF554LH.js → chunk-53JFOF7F.js} +139 -23
- package/dist/chunk-53JFOF7F.js.map +1 -0
- package/dist/chunk-JXZMAU2C.js +559 -0
- package/dist/chunk-JXZMAU2C.js.map +1 -0
- package/dist/index.js +22 -11
- package/dist/index.js.map +1 -1
- package/dist/interpreter.js +1 -1
- package/dist/request-handler.js +2 -2
- package/dist/sandbox.js +2 -2
- package/package.json +4 -2
- package/dist/chunk-BCJ7SF3Q.js +0 -117
- package/dist/chunk-BCJ7SF3Q.js.map +0 -1
- package/dist/chunk-HGF554LH.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @cloudflare/sandbox@0.4.
|
|
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
|
[34mCLI[39m 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
|
[34mCLI[39m Target: es2022
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[32mESM[39m [1mdist/file-stream.js [22m[32m146.00 B[39m
|
|
11
|
-
[32mESM[39m [1mdist/index.js [22m[32m946.00 B[39m
|
|
12
|
-
[32mESM[39m [1mdist/chunk-BFVUNTP4.js [22m[32m2.76 KB[39m
|
|
13
11
|
[32mESM[39m [1mdist/interpreter.js [22m[32m156.00 B[39m
|
|
14
|
-
[32mESM[39m [1mdist/
|
|
12
|
+
[32mESM[39m [1mdist/chunk-BFVUNTP4.js [22m[32m2.76 KB[39m
|
|
15
13
|
[32mESM[39m [1mdist/sandbox.js [22m[32m224.00 B[39m
|
|
16
|
-
[32mESM[39m [1mdist/chunk-
|
|
17
|
-
[32mESM[39m [1mdist/chunk-
|
|
14
|
+
[32mESM[39m [1mdist/chunk-53JFOF7F.js [22m[32m71.29 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/chunk-JXZMAU2C.js [22m[32m14.43 KB[39m
|
|
18
16
|
[32mESM[39m [1mdist/security.js [22m[32m233.00 B[39m
|
|
19
17
|
[32mESM[39m [1mdist/chunk-Z532A7QC.js [22m[32m1.75 KB[39m
|
|
20
|
-
[32mESM[39m [1mdist/sse-parser.js [22m[32m233.00 B[39m
|
|
21
18
|
[32mESM[39m [1mdist/chunk-EKSWCBCA.js [22m[32m2.28 KB[39m
|
|
19
|
+
[32mESM[39m [1mdist/sse-parser.js [22m[32m233.00 B[39m
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m1.10 KB[39m
|
|
21
|
+
[32mESM[39m [1mdist/request-handler.js [22m[32m262.00 B[39m
|
|
22
22
|
[32mESM[39m [1mdist/file-stream.js.map [22m[32m71.00 B[39m
|
|
23
|
-
[32mESM[39m [1mdist/index.js.map [22m[32m2.45 KB[39m
|
|
24
|
-
[32mESM[39m [1mdist/chunk-BFVUNTP4.js.map [22m[32m6.71 KB[39m
|
|
25
23
|
[32mESM[39m [1mdist/interpreter.js.map [22m[32m71.00 B[39m
|
|
26
|
-
[32mESM[39m [1mdist/
|
|
24
|
+
[32mESM[39m [1mdist/chunk-BFVUNTP4.js.map [22m[32m6.71 KB[39m
|
|
27
25
|
[32mESM[39m [1mdist/sandbox.js.map [22m[32m71.00 B[39m
|
|
28
|
-
[32mESM[39m [1mdist/chunk-HGF554LH.js.map [22m[32m142.71 KB[39m
|
|
29
|
-
[32mESM[39m [1mdist/chunk-BCJ7SF3Q.js.map [22m[32m6.88 KB[39m
|
|
30
26
|
[32mESM[39m [1mdist/security.js.map [22m[32m71.00 B[39m
|
|
31
27
|
[32mESM[39m [1mdist/chunk-Z532A7QC.js.map [22m[32m3.96 KB[39m
|
|
32
|
-
[32mESM[39m [1mdist/
|
|
28
|
+
[32mESM[39m [1mdist/chunk-JXZMAU2C.js.map [22m[32m33.44 KB[39m
|
|
33
29
|
[32mESM[39m [1mdist/chunk-EKSWCBCA.js.map [22m[32m5.61 KB[39m
|
|
34
|
-
[32mESM[39m
|
|
30
|
+
[32mESM[39m [1mdist/sse-parser.js.map [22m[32m71.00 B[39m
|
|
31
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m71.00 B[39m
|
|
32
|
+
[32mESM[39m [1mdist/chunk-53JFOF7F.js.map [22m[32m146.99 KB[39m
|
|
33
|
+
[32mESM[39m [1mdist/request-handler.js.map [22m[32m71.00 B[39m
|
|
34
|
+
[32mESM[39m ⚡️ Build success in 85ms
|
|
35
35
|
[34mDTS[39m Build start
|
|
36
|
-
[32mDTS[39m ⚡️ Build success in
|
|
36
|
+
[32mDTS[39m ⚡️ Build success in 2233ms
|
|
37
37
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m1.46 KB[39m
|
|
38
38
|
[32mDTS[39m [1mdist/file-stream.d.ts [22m[32m1.34 KB[39m
|
|
39
39
|
[32mDTS[39m [1mdist/interpreter.d.ts [22m[32m1007.00 B[39m
|
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
|
-
|
|
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
|
-
//
|
|
24
|
-
|
|
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
|
-
//
|
|
27
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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 =
|
|
2113
|
-
const logger =
|
|
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-
|
|
2352
|
+
//# sourceMappingURL=chunk-53JFOF7F.js.map
|