@cloudflare/sandbox 0.6.3 → 0.6.5
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/Dockerfile +43 -24
- package/README.md +6 -2
- package/dist/contexts-CdrlvHWK.d.ts +162 -0
- package/dist/contexts-CdrlvHWK.d.ts.map +1 -0
- package/dist/{dist-D0sZt0AD.js → dist-2SF6oOaz.js} +1 -1
- package/dist/{dist-D0sZt0AD.js.map → dist-2SF6oOaz.js.map} +1 -1
- package/dist/errors-BCXUmJUn.js +126 -0
- package/dist/errors-BCXUmJUn.js.map +1 -0
- package/dist/index.d.ts +2 -150
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -140
- package/dist/index.js.map +1 -1
- package/dist/openai/index.d.ts +1 -1
- package/dist/openai/index.js +1 -1
- package/dist/opencode/index.d.ts +149 -0
- package/dist/opencode/index.d.ts.map +1 -0
- package/dist/opencode/index.js +297 -0
- package/dist/opencode/index.js.map +1 -0
- package/dist/{sandbox-bAj-cB2H.d.ts → sandbox-C9WRqWBO.d.ts} +2 -2
- package/dist/{sandbox-bAj-cB2H.d.ts.map → sandbox-C9WRqWBO.d.ts.map} +1 -1
- package/package.json +14 -4
- package/startup.sh +0 -3
package/Dockerfile
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
# Sandbox container
|
|
1
|
+
# Sandbox container images (default and python variants)
|
|
2
2
|
# Multi-stage build optimized for Turborepo monorepo
|
|
3
3
|
|
|
4
4
|
# ============================================================================
|
|
5
5
|
# Stage 1: Prune monorepo to only include necessary packages
|
|
6
6
|
# ============================================================================
|
|
7
|
-
FROM node:20-
|
|
7
|
+
FROM node:20-slim AS pruner
|
|
8
8
|
|
|
9
9
|
WORKDIR /app
|
|
10
10
|
|
|
11
|
-
# Install Turborepo globally
|
|
12
11
|
RUN npm install -g turbo
|
|
13
12
|
|
|
14
|
-
# Copy entire monorepo
|
|
15
13
|
COPY . .
|
|
16
14
|
|
|
17
15
|
# Prune to only @repo/sandbox-container and its dependencies (@repo/shared)
|
|
@@ -20,13 +18,15 @@ RUN turbo prune @repo/sandbox-container --docker
|
|
|
20
18
|
|
|
21
19
|
# ============================================================================
|
|
22
20
|
# Stage 2: Install dependencies and build packages
|
|
21
|
+
# Using glibc-based images (not Alpine) so the standalone binary works on
|
|
22
|
+
# standard Linux distributions (Debian, Ubuntu, RHEL, etc.)
|
|
23
23
|
# ============================================================================
|
|
24
|
-
FROM node:20-
|
|
24
|
+
FROM node:20-slim AS builder
|
|
25
25
|
|
|
26
26
|
WORKDIR /app
|
|
27
27
|
|
|
28
|
-
# Install Bun runtime (
|
|
29
|
-
COPY --from=oven/bun:1
|
|
28
|
+
# Install Bun runtime (glibc version for glibc-compatible standalone binary)
|
|
29
|
+
COPY --from=oven/bun:1 /usr/local/bin/bun /usr/local/bin/bun
|
|
30
30
|
|
|
31
31
|
# Copy pruned lockfile and package.json files (for Docker layer caching)
|
|
32
32
|
COPY --from=pruner /app/out/json/ .
|
|
@@ -36,11 +36,10 @@ COPY --from=pruner /app/out/package-lock.json ./package-lock.json
|
|
|
36
36
|
RUN --mount=type=cache,target=/root/.npm \
|
|
37
37
|
CI=true npm ci
|
|
38
38
|
|
|
39
|
-
# Copy pruned source code
|
|
40
39
|
COPY --from=pruner /app/out/full/ .
|
|
41
40
|
|
|
42
41
|
# Build all packages (Turborepo handles dependency order automatically)
|
|
43
|
-
# This builds @repo/shared first, then @repo/sandbox-container
|
|
42
|
+
# This builds @repo/shared first, then @repo/sandbox-container (including standalone binary)
|
|
44
43
|
RUN npx turbo run build
|
|
45
44
|
|
|
46
45
|
# ============================================================================
|
|
@@ -96,7 +95,6 @@ ARG SANDBOX_VERSION=unknown
|
|
|
96
95
|
# Prevent interactive prompts during package installation
|
|
97
96
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
98
97
|
|
|
99
|
-
# Set the sandbox version as an environment variable for version checking
|
|
100
98
|
ENV SANDBOX_VERSION=${SANDBOX_VERSION}
|
|
101
99
|
|
|
102
100
|
# Install runtime packages and S3FS-FUSE for bucket mounting
|
|
@@ -123,27 +121,24 @@ RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
|
|
123
121
|
# Install Bun runtime from official image
|
|
124
122
|
COPY --from=oven/bun:1 /usr/local/bin/bun /usr/local/bin/bun
|
|
125
123
|
|
|
126
|
-
#
|
|
127
|
-
|
|
124
|
+
# Copy standalone binary
|
|
125
|
+
COPY --from=builder /app/packages/sandbox-container/dist/sandbox /container-server/sandbox
|
|
128
126
|
|
|
129
|
-
#
|
|
130
|
-
|
|
131
|
-
COPY --from=builder /app/packages/sandbox-container/dist/index.js.map ./dist/
|
|
127
|
+
# Set up container server directory for executors
|
|
128
|
+
WORKDIR /container-server
|
|
132
129
|
|
|
133
|
-
# Copy bundled JavaScript executor
|
|
130
|
+
# Copy bundled JavaScript executor (runs on Node or Bun for code interpreter)
|
|
134
131
|
COPY --from=builder /app/packages/sandbox-container/dist/runtime/executors/javascript/node_executor.js ./dist/runtime/executors/javascript/
|
|
135
|
-
COPY --from=builder /app/packages/sandbox-container/dist/runtime/executors/javascript/node_executor.js.map ./dist/runtime/executors/javascript/
|
|
136
132
|
|
|
137
|
-
#
|
|
133
|
+
# Copy legacy JS bundle for backwards compatibility
|
|
134
|
+
# Users with custom startup scripts that call `bun /container-server/dist/index.js` need this
|
|
135
|
+
COPY --from=builder /app/packages/sandbox-container/dist/index.js ./dist/
|
|
136
|
+
|
|
138
137
|
RUN mkdir -p /workspace
|
|
139
138
|
|
|
140
139
|
# Expose the application port (3000 for control)
|
|
141
140
|
EXPOSE 3000
|
|
142
141
|
|
|
143
|
-
# Copy and make startup script executable
|
|
144
|
-
COPY packages/sandbox/startup.sh ./
|
|
145
|
-
RUN chmod +x startup.sh
|
|
146
|
-
|
|
147
142
|
# ============================================================================
|
|
148
143
|
# Stage 5a: Default image - lean, no Python
|
|
149
144
|
# ============================================================================
|
|
@@ -154,7 +149,7 @@ ENV PYTHON_POOL_MIN_SIZE=0
|
|
|
154
149
|
ENV JAVASCRIPT_POOL_MIN_SIZE=3
|
|
155
150
|
ENV TYPESCRIPT_POOL_MIN_SIZE=3
|
|
156
151
|
|
|
157
|
-
|
|
152
|
+
ENTRYPOINT ["/container-server/sandbox"]
|
|
158
153
|
|
|
159
154
|
# ============================================================================
|
|
160
155
|
# Stage 5b: Python image - full, with Python + data science packages
|
|
@@ -186,4 +181,28 @@ ENV PYTHON_POOL_MIN_SIZE=3
|
|
|
186
181
|
ENV JAVASCRIPT_POOL_MIN_SIZE=3
|
|
187
182
|
ENV TYPESCRIPT_POOL_MIN_SIZE=3
|
|
188
183
|
|
|
189
|
-
|
|
184
|
+
ENTRYPOINT ["/container-server/sandbox"]
|
|
185
|
+
|
|
186
|
+
# ============================================================================
|
|
187
|
+
# Stage 5c: OpenCode image - with OpenCode CLI for AI coding agent
|
|
188
|
+
# ============================================================================
|
|
189
|
+
FROM runtime-base AS opencode
|
|
190
|
+
|
|
191
|
+
# Add opencode to PATH
|
|
192
|
+
ENV PATH="/root/.opencode/bin:${PATH}"
|
|
193
|
+
|
|
194
|
+
# Install OpenCode CLI
|
|
195
|
+
RUN curl -fsSL https://opencode.ai/install -o /tmp/install-opencode.sh \
|
|
196
|
+
&& bash /tmp/install-opencode.sh \
|
|
197
|
+
&& rm /tmp/install-opencode.sh \
|
|
198
|
+
&& opencode --version
|
|
199
|
+
|
|
200
|
+
# Disable Python pool (Python not available in this image)
|
|
201
|
+
ENV PYTHON_POOL_MIN_SIZE=0
|
|
202
|
+
ENV JAVASCRIPT_POOL_MIN_SIZE=3
|
|
203
|
+
ENV TYPESCRIPT_POOL_MIN_SIZE=3
|
|
204
|
+
|
|
205
|
+
# Expose OpenCode server port (in addition to 3000 from runtime-base)
|
|
206
|
+
EXPOSE 4096
|
|
207
|
+
|
|
208
|
+
ENTRYPOINT ["/container-server/sandbox"]
|
package/README.md
CHANGED
|
@@ -150,8 +150,12 @@ npm run check
|
|
|
150
150
|
|
|
151
151
|
See the [examples directory](./examples) for complete working examples:
|
|
152
152
|
|
|
153
|
-
- [Minimal](./examples/minimal) -
|
|
154
|
-
- [Code Interpreter](./examples/code-interpreter) -
|
|
153
|
+
- [Minimal](./examples/minimal) - Start here: exec commands, read/write files
|
|
154
|
+
- [Code Interpreter](./examples/code-interpreter) - Give [gpt-oss](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/) on Workers AI a Python REPL
|
|
155
|
+
- [Claude Code](./examples/claude-code) - Run [Claude Code](https://claude.ai/code) headless on any repo
|
|
156
|
+
- [OpenAI Agents](./examples/openai-agents) - `Shell` and `Editor` tools for [OpenAI Agents SDK](https://openai.github.io/openai-agents-js/)
|
|
157
|
+
- [OpenCode](./examples/opencode) - [OpenCode](https://github.com/sst/opencode) web UI or [SDK](https://opencode.ai/docs/sdk/) in a sandbox
|
|
158
|
+
- [TypeScript Validator](./examples/typescript-validator) - Build with npm in sandbox, execute in [isolates](https://developers.cloudflare.com/workers/runtime-apis/bindings/worker-loader/)
|
|
155
159
|
|
|
156
160
|
## Status
|
|
157
161
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
//#region ../shared/dist/errors/codes.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Centralized error code registry
|
|
4
|
+
* Each code maps to a specific error type with consistent semantics
|
|
5
|
+
*/
|
|
6
|
+
declare const ErrorCode: {
|
|
7
|
+
readonly FILE_NOT_FOUND: "FILE_NOT_FOUND";
|
|
8
|
+
readonly PERMISSION_DENIED: "PERMISSION_DENIED";
|
|
9
|
+
readonly FILE_EXISTS: "FILE_EXISTS";
|
|
10
|
+
readonly IS_DIRECTORY: "IS_DIRECTORY";
|
|
11
|
+
readonly NOT_DIRECTORY: "NOT_DIRECTORY";
|
|
12
|
+
readonly NO_SPACE: "NO_SPACE";
|
|
13
|
+
readonly TOO_MANY_FILES: "TOO_MANY_FILES";
|
|
14
|
+
readonly RESOURCE_BUSY: "RESOURCE_BUSY";
|
|
15
|
+
readonly READ_ONLY: "READ_ONLY";
|
|
16
|
+
readonly NAME_TOO_LONG: "NAME_TOO_LONG";
|
|
17
|
+
readonly TOO_MANY_LINKS: "TOO_MANY_LINKS";
|
|
18
|
+
readonly FILESYSTEM_ERROR: "FILESYSTEM_ERROR";
|
|
19
|
+
readonly COMMAND_NOT_FOUND: "COMMAND_NOT_FOUND";
|
|
20
|
+
readonly COMMAND_PERMISSION_DENIED: "COMMAND_PERMISSION_DENIED";
|
|
21
|
+
readonly INVALID_COMMAND: "INVALID_COMMAND";
|
|
22
|
+
readonly COMMAND_EXECUTION_ERROR: "COMMAND_EXECUTION_ERROR";
|
|
23
|
+
readonly STREAM_START_ERROR: "STREAM_START_ERROR";
|
|
24
|
+
readonly PROCESS_NOT_FOUND: "PROCESS_NOT_FOUND";
|
|
25
|
+
readonly PROCESS_PERMISSION_DENIED: "PROCESS_PERMISSION_DENIED";
|
|
26
|
+
readonly PROCESS_ERROR: "PROCESS_ERROR";
|
|
27
|
+
readonly SESSION_ALREADY_EXISTS: "SESSION_ALREADY_EXISTS";
|
|
28
|
+
readonly PORT_ALREADY_EXPOSED: "PORT_ALREADY_EXPOSED";
|
|
29
|
+
readonly PORT_IN_USE: "PORT_IN_USE";
|
|
30
|
+
readonly PORT_NOT_EXPOSED: "PORT_NOT_EXPOSED";
|
|
31
|
+
readonly INVALID_PORT_NUMBER: "INVALID_PORT_NUMBER";
|
|
32
|
+
readonly INVALID_PORT: "INVALID_PORT";
|
|
33
|
+
readonly SERVICE_NOT_RESPONDING: "SERVICE_NOT_RESPONDING";
|
|
34
|
+
readonly PORT_OPERATION_ERROR: "PORT_OPERATION_ERROR";
|
|
35
|
+
readonly CUSTOM_DOMAIN_REQUIRED: "CUSTOM_DOMAIN_REQUIRED";
|
|
36
|
+
readonly GIT_REPOSITORY_NOT_FOUND: "GIT_REPOSITORY_NOT_FOUND";
|
|
37
|
+
readonly GIT_BRANCH_NOT_FOUND: "GIT_BRANCH_NOT_FOUND";
|
|
38
|
+
readonly GIT_AUTH_FAILED: "GIT_AUTH_FAILED";
|
|
39
|
+
readonly GIT_NETWORK_ERROR: "GIT_NETWORK_ERROR";
|
|
40
|
+
readonly INVALID_GIT_URL: "INVALID_GIT_URL";
|
|
41
|
+
readonly GIT_CLONE_FAILED: "GIT_CLONE_FAILED";
|
|
42
|
+
readonly GIT_CHECKOUT_FAILED: "GIT_CHECKOUT_FAILED";
|
|
43
|
+
readonly GIT_OPERATION_FAILED: "GIT_OPERATION_FAILED";
|
|
44
|
+
readonly BUCKET_MOUNT_ERROR: "BUCKET_MOUNT_ERROR";
|
|
45
|
+
readonly S3FS_MOUNT_ERROR: "S3FS_MOUNT_ERROR";
|
|
46
|
+
readonly MISSING_CREDENTIALS: "MISSING_CREDENTIALS";
|
|
47
|
+
readonly INVALID_MOUNT_CONFIG: "INVALID_MOUNT_CONFIG";
|
|
48
|
+
readonly INTERPRETER_NOT_READY: "INTERPRETER_NOT_READY";
|
|
49
|
+
readonly CONTEXT_NOT_FOUND: "CONTEXT_NOT_FOUND";
|
|
50
|
+
readonly CODE_EXECUTION_ERROR: "CODE_EXECUTION_ERROR";
|
|
51
|
+
readonly PYTHON_NOT_AVAILABLE: "PYTHON_NOT_AVAILABLE";
|
|
52
|
+
readonly JAVASCRIPT_NOT_AVAILABLE: "JAVASCRIPT_NOT_AVAILABLE";
|
|
53
|
+
readonly OPENCODE_STARTUP_FAILED: "OPENCODE_STARTUP_FAILED";
|
|
54
|
+
readonly PROCESS_READY_TIMEOUT: "PROCESS_READY_TIMEOUT";
|
|
55
|
+
readonly PROCESS_EXITED_BEFORE_READY: "PROCESS_EXITED_BEFORE_READY";
|
|
56
|
+
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
57
|
+
readonly INVALID_JSON_RESPONSE: "INVALID_JSON_RESPONSE";
|
|
58
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
59
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
60
|
+
};
|
|
61
|
+
type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region ../shared/dist/errors/types.d.ts
|
|
64
|
+
/**
|
|
65
|
+
* Standard operation types
|
|
66
|
+
*/
|
|
67
|
+
declare const Operation: {
|
|
68
|
+
readonly FILE_READ: "file.read";
|
|
69
|
+
readonly FILE_WRITE: "file.write";
|
|
70
|
+
readonly FILE_DELETE: "file.delete";
|
|
71
|
+
readonly FILE_MOVE: "file.move";
|
|
72
|
+
readonly FILE_RENAME: "file.rename";
|
|
73
|
+
readonly FILE_STAT: "file.stat";
|
|
74
|
+
readonly DIRECTORY_CREATE: "directory.create";
|
|
75
|
+
readonly DIRECTORY_LIST: "directory.list";
|
|
76
|
+
readonly COMMAND_EXECUTE: "command.execute";
|
|
77
|
+
readonly COMMAND_STREAM: "command.stream";
|
|
78
|
+
readonly PROCESS_START: "process.start";
|
|
79
|
+
readonly PROCESS_KILL: "process.kill";
|
|
80
|
+
readonly PROCESS_LIST: "process.list";
|
|
81
|
+
readonly PROCESS_GET: "process.get";
|
|
82
|
+
readonly PROCESS_LOGS: "process.logs";
|
|
83
|
+
readonly PORT_EXPOSE: "port.expose";
|
|
84
|
+
readonly PORT_UNEXPOSE: "port.unexpose";
|
|
85
|
+
readonly PORT_LIST: "port.list";
|
|
86
|
+
readonly PORT_PROXY: "port.proxy";
|
|
87
|
+
readonly GIT_CLONE: "git.clone";
|
|
88
|
+
readonly GIT_CHECKOUT: "git.checkout";
|
|
89
|
+
readonly GIT_OPERATION: "git.operation";
|
|
90
|
+
readonly CODE_EXECUTE: "code.execute";
|
|
91
|
+
readonly CODE_CONTEXT_CREATE: "code.context.create";
|
|
92
|
+
readonly CODE_CONTEXT_DELETE: "code.context.delete";
|
|
93
|
+
};
|
|
94
|
+
type OperationType = (typeof Operation)[keyof typeof Operation];
|
|
95
|
+
/**
|
|
96
|
+
* Standard error response format with generic context type
|
|
97
|
+
* TContext allows type-safe access to error-specific context
|
|
98
|
+
*/
|
|
99
|
+
interface ErrorResponse<TContext = Record<string, unknown>> {
|
|
100
|
+
/**
|
|
101
|
+
* Error type code (machine-readable)
|
|
102
|
+
*/
|
|
103
|
+
code: ErrorCode;
|
|
104
|
+
/**
|
|
105
|
+
* Human-readable error message
|
|
106
|
+
*/
|
|
107
|
+
message: string;
|
|
108
|
+
/**
|
|
109
|
+
* Operation that was attempted (useful for debugging and logging)
|
|
110
|
+
*/
|
|
111
|
+
operation?: OperationType;
|
|
112
|
+
/**
|
|
113
|
+
* Structured error context with relevant details
|
|
114
|
+
* Type varies based on error code
|
|
115
|
+
*/
|
|
116
|
+
context: TContext;
|
|
117
|
+
/**
|
|
118
|
+
* HTTP status code (for client SDK)
|
|
119
|
+
*/
|
|
120
|
+
httpStatus: number;
|
|
121
|
+
/**
|
|
122
|
+
* Timestamp when error occurred
|
|
123
|
+
*/
|
|
124
|
+
timestamp: string;
|
|
125
|
+
/**
|
|
126
|
+
* Actionable suggestion for fixing the error
|
|
127
|
+
*/
|
|
128
|
+
suggestion?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Link to documentation
|
|
131
|
+
*/
|
|
132
|
+
documentation?: string;
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region ../shared/dist/errors/contexts.d.ts
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Process readiness error contexts
|
|
139
|
+
*/
|
|
140
|
+
interface ProcessReadyTimeoutContext {
|
|
141
|
+
processId: string;
|
|
142
|
+
command: string;
|
|
143
|
+
condition: string;
|
|
144
|
+
timeout: number;
|
|
145
|
+
}
|
|
146
|
+
interface ProcessExitedBeforeReadyContext {
|
|
147
|
+
processId: string;
|
|
148
|
+
command: string;
|
|
149
|
+
condition: string;
|
|
150
|
+
exitCode: number;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* OpenCode error contexts
|
|
154
|
+
*/
|
|
155
|
+
interface OpencodeStartupContext {
|
|
156
|
+
port: number;
|
|
157
|
+
stderr?: string;
|
|
158
|
+
command?: string;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
export { OperationType as a, ErrorResponse as i, ProcessExitedBeforeReadyContext as n, ErrorCode as o, ProcessReadyTimeoutContext as r, OpencodeStartupContext as t };
|
|
162
|
+
//# sourceMappingURL=contexts-CdrlvHWK.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts-CdrlvHWK.d.ts","names":["ErrorCode","ErrorCode","Operation","OperationType","ErrorResponse","TContext","Record","ServiceError","ServiceResult","T","OperationType","FileNotFoundContext","FileExistsContext","FileSystemContext","CommandNotFoundContext","CommandErrorContext","ProcessNotFoundContext","ProcessErrorContext","SessionAlreadyExistsContext","ProcessReadyTimeoutContext","ProcessExitedBeforeReadyContext","PortAlreadyExposedContext","PortNotExposedContext","InvalidPortContext","PortErrorContext","GitRepositoryNotFoundContext","GitAuthFailedContext","GitBranchNotFoundContext","GitErrorContext","InterpreterNotReadyContext","ContextNotFoundContext","CodeExecutionContext","ValidationFailedContext","Array","BucketMountContext","MissingCredentialsContext","InvalidMountConfigContext","OpencodeStartupContext","InternalErrorContext"],"sources":["../../shared/dist/errors/codes.d.ts","../../shared/dist/errors/types.d.ts","../../shared/dist/errors/contexts.d.ts"],"sourcesContent":["/**\n * Centralized error code registry\n * Each code maps to a specific error type with consistent semantics\n */\nexport declare const ErrorCode: {\n readonly FILE_NOT_FOUND: \"FILE_NOT_FOUND\";\n readonly PERMISSION_DENIED: \"PERMISSION_DENIED\";\n readonly FILE_EXISTS: \"FILE_EXISTS\";\n readonly IS_DIRECTORY: \"IS_DIRECTORY\";\n readonly NOT_DIRECTORY: \"NOT_DIRECTORY\";\n readonly NO_SPACE: \"NO_SPACE\";\n readonly TOO_MANY_FILES: \"TOO_MANY_FILES\";\n readonly RESOURCE_BUSY: \"RESOURCE_BUSY\";\n readonly READ_ONLY: \"READ_ONLY\";\n readonly NAME_TOO_LONG: \"NAME_TOO_LONG\";\n readonly TOO_MANY_LINKS: \"TOO_MANY_LINKS\";\n readonly FILESYSTEM_ERROR: \"FILESYSTEM_ERROR\";\n readonly COMMAND_NOT_FOUND: \"COMMAND_NOT_FOUND\";\n readonly COMMAND_PERMISSION_DENIED: \"COMMAND_PERMISSION_DENIED\";\n readonly INVALID_COMMAND: \"INVALID_COMMAND\";\n readonly COMMAND_EXECUTION_ERROR: \"COMMAND_EXECUTION_ERROR\";\n readonly STREAM_START_ERROR: \"STREAM_START_ERROR\";\n readonly PROCESS_NOT_FOUND: \"PROCESS_NOT_FOUND\";\n readonly PROCESS_PERMISSION_DENIED: \"PROCESS_PERMISSION_DENIED\";\n readonly PROCESS_ERROR: \"PROCESS_ERROR\";\n readonly SESSION_ALREADY_EXISTS: \"SESSION_ALREADY_EXISTS\";\n readonly PORT_ALREADY_EXPOSED: \"PORT_ALREADY_EXPOSED\";\n readonly PORT_IN_USE: \"PORT_IN_USE\";\n readonly PORT_NOT_EXPOSED: \"PORT_NOT_EXPOSED\";\n readonly INVALID_PORT_NUMBER: \"INVALID_PORT_NUMBER\";\n readonly INVALID_PORT: \"INVALID_PORT\";\n readonly SERVICE_NOT_RESPONDING: \"SERVICE_NOT_RESPONDING\";\n readonly PORT_OPERATION_ERROR: \"PORT_OPERATION_ERROR\";\n readonly CUSTOM_DOMAIN_REQUIRED: \"CUSTOM_DOMAIN_REQUIRED\";\n readonly GIT_REPOSITORY_NOT_FOUND: \"GIT_REPOSITORY_NOT_FOUND\";\n readonly GIT_BRANCH_NOT_FOUND: \"GIT_BRANCH_NOT_FOUND\";\n readonly GIT_AUTH_FAILED: \"GIT_AUTH_FAILED\";\n readonly GIT_NETWORK_ERROR: \"GIT_NETWORK_ERROR\";\n readonly INVALID_GIT_URL: \"INVALID_GIT_URL\";\n readonly GIT_CLONE_FAILED: \"GIT_CLONE_FAILED\";\n readonly GIT_CHECKOUT_FAILED: \"GIT_CHECKOUT_FAILED\";\n readonly GIT_OPERATION_FAILED: \"GIT_OPERATION_FAILED\";\n readonly BUCKET_MOUNT_ERROR: \"BUCKET_MOUNT_ERROR\";\n readonly S3FS_MOUNT_ERROR: \"S3FS_MOUNT_ERROR\";\n readonly MISSING_CREDENTIALS: \"MISSING_CREDENTIALS\";\n readonly INVALID_MOUNT_CONFIG: \"INVALID_MOUNT_CONFIG\";\n readonly INTERPRETER_NOT_READY: \"INTERPRETER_NOT_READY\";\n readonly CONTEXT_NOT_FOUND: \"CONTEXT_NOT_FOUND\";\n readonly CODE_EXECUTION_ERROR: \"CODE_EXECUTION_ERROR\";\n readonly PYTHON_NOT_AVAILABLE: \"PYTHON_NOT_AVAILABLE\";\n readonly JAVASCRIPT_NOT_AVAILABLE: \"JAVASCRIPT_NOT_AVAILABLE\";\n readonly OPENCODE_STARTUP_FAILED: \"OPENCODE_STARTUP_FAILED\";\n readonly PROCESS_READY_TIMEOUT: \"PROCESS_READY_TIMEOUT\";\n readonly PROCESS_EXITED_BEFORE_READY: \"PROCESS_EXITED_BEFORE_READY\";\n readonly VALIDATION_FAILED: \"VALIDATION_FAILED\";\n readonly INVALID_JSON_RESPONSE: \"INVALID_JSON_RESPONSE\";\n readonly UNKNOWN_ERROR: \"UNKNOWN_ERROR\";\n readonly INTERNAL_ERROR: \"INTERNAL_ERROR\";\n};\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n//# sourceMappingURL=codes.d.ts.map","import type { ErrorCode } from './codes';\n/**\n * Standard operation types\n */\nexport declare const Operation: {\n readonly FILE_READ: \"file.read\";\n readonly FILE_WRITE: \"file.write\";\n readonly FILE_DELETE: \"file.delete\";\n readonly FILE_MOVE: \"file.move\";\n readonly FILE_RENAME: \"file.rename\";\n readonly FILE_STAT: \"file.stat\";\n readonly DIRECTORY_CREATE: \"directory.create\";\n readonly DIRECTORY_LIST: \"directory.list\";\n readonly COMMAND_EXECUTE: \"command.execute\";\n readonly COMMAND_STREAM: \"command.stream\";\n readonly PROCESS_START: \"process.start\";\n readonly PROCESS_KILL: \"process.kill\";\n readonly PROCESS_LIST: \"process.list\";\n readonly PROCESS_GET: \"process.get\";\n readonly PROCESS_LOGS: \"process.logs\";\n readonly PORT_EXPOSE: \"port.expose\";\n readonly PORT_UNEXPOSE: \"port.unexpose\";\n readonly PORT_LIST: \"port.list\";\n readonly PORT_PROXY: \"port.proxy\";\n readonly GIT_CLONE: \"git.clone\";\n readonly GIT_CHECKOUT: \"git.checkout\";\n readonly GIT_OPERATION: \"git.operation\";\n readonly CODE_EXECUTE: \"code.execute\";\n readonly CODE_CONTEXT_CREATE: \"code.context.create\";\n readonly CODE_CONTEXT_DELETE: \"code.context.delete\";\n};\nexport type OperationType = (typeof Operation)[keyof typeof Operation];\n/**\n * Standard error response format with generic context type\n * TContext allows type-safe access to error-specific context\n */\nexport interface ErrorResponse<TContext = Record<string, unknown>> {\n /**\n * Error type code (machine-readable)\n */\n code: ErrorCode;\n /**\n * Human-readable error message\n */\n message: string;\n /**\n * Operation that was attempted (useful for debugging and logging)\n */\n operation?: OperationType;\n /**\n * Structured error context with relevant details\n * Type varies based on error code\n */\n context: TContext;\n /**\n * HTTP status code (for client SDK)\n */\n httpStatus: number;\n /**\n * Timestamp when error occurred\n */\n timestamp: string;\n /**\n * Actionable suggestion for fixing the error\n */\n suggestion?: string;\n /**\n * Link to documentation\n */\n documentation?: string;\n}\n/**\n * Container ServiceError (lightweight, enriched by handlers)\n */\nexport interface ServiceError {\n message: string;\n code: ErrorCode;\n details?: Record<string, unknown>;\n}\n/**\n * ServiceResult type for container services\n */\nexport type ServiceResult<T> = {\n success: true;\n data: T;\n} | {\n success: false;\n error: ServiceError;\n};\n//# sourceMappingURL=types.d.ts.map","import type { OperationType } from './types';\n/**\n * File system error contexts\n */\nexport interface FileNotFoundContext {\n path: string;\n operation: OperationType;\n}\nexport interface FileExistsContext {\n path: string;\n operation: OperationType;\n}\nexport interface FileSystemContext {\n path: string;\n operation: OperationType;\n stderr?: string;\n exitCode?: number;\n}\n/**\n * Command error contexts\n */\nexport interface CommandNotFoundContext {\n command: string;\n}\nexport interface CommandErrorContext {\n command: string;\n exitCode?: number;\n stdout?: string;\n stderr?: string;\n}\n/**\n * Process error contexts\n */\nexport interface ProcessNotFoundContext {\n processId: string;\n}\nexport interface ProcessErrorContext {\n processId: string;\n pid?: number;\n exitCode?: number;\n stderr?: string;\n}\nexport interface SessionAlreadyExistsContext {\n sessionId: string;\n}\n/**\n * Process readiness error contexts\n */\nexport interface ProcessReadyTimeoutContext {\n processId: string;\n command: string;\n condition: string;\n timeout: number;\n}\nexport interface ProcessExitedBeforeReadyContext {\n processId: string;\n command: string;\n condition: string;\n exitCode: number;\n}\n/**\n * Port error contexts\n */\nexport interface PortAlreadyExposedContext {\n port: number;\n portName?: string;\n}\nexport interface PortNotExposedContext {\n port: number;\n}\nexport interface InvalidPortContext {\n port: number;\n reason: string;\n}\nexport interface PortErrorContext {\n port: number;\n portName?: string;\n stderr?: string;\n}\n/**\n * Git error contexts\n */\nexport interface GitRepositoryNotFoundContext {\n repository: string;\n}\nexport interface GitAuthFailedContext {\n repository: string;\n}\nexport interface GitBranchNotFoundContext {\n branch: string;\n repository?: string;\n}\nexport interface GitErrorContext {\n repository?: string;\n branch?: string;\n targetDir?: string;\n stderr?: string;\n exitCode?: number;\n}\n/**\n * Code interpreter error contexts\n */\nexport interface InterpreterNotReadyContext {\n retryAfter?: number;\n progress?: number;\n}\nexport interface ContextNotFoundContext {\n contextId: string;\n}\nexport interface CodeExecutionContext {\n contextId?: string;\n ename?: string;\n evalue?: string;\n traceback?: string[];\n}\n/**\n * Validation error contexts\n */\nexport interface ValidationFailedContext {\n validationErrors: Array<{\n field: string;\n message: string;\n code?: string;\n }>;\n}\n/**\n * Bucket mounting error contexts\n */\nexport interface BucketMountContext {\n bucket: string;\n mountPath: string;\n endpoint: string;\n stderr?: string;\n exitCode?: number;\n}\nexport interface MissingCredentialsContext {\n bucket: string;\n endpoint: string;\n}\nexport interface InvalidMountConfigContext {\n bucket?: string;\n mountPath?: string;\n endpoint?: string;\n reason?: string;\n}\n/**\n * OpenCode error contexts\n */\nexport interface OpencodeStartupContext {\n port: number;\n stderr?: string;\n command?: string;\n}\n/**\n * Generic error contexts\n */\nexport interface InternalErrorContext {\n originalError?: string;\n stack?: string;\n [key: string]: unknown;\n}\n//# sourceMappingURL=contexts.d.ts.map"],"mappings":";;AAIA;AAuDA;;cAvDqBA;;ECAAE,SAAAA,iBA0BpB,EAAA,mBAAA;EACWC,SAAAA,WAAa,EAAA,aAAWD;EAKnBE,SAAAA,YAAa,EAAAC,cAAA;EAAYC,SAAAA,aAAAA,EAAAA,eAAAA;EAIhCL,SAAAA,QAAAA,EAAAA,UAAAA;EAQME,SAAAA,cAAAA,EAAAA,gBAAAA;EAKHE,SAAAA,aAAAA,EAAAA,eAAAA;EAAQ,SAAA,SAAA,EAAA,WAAA;;;;ECLJc,SAAAA,iBAAAA,EAAAA,mBAA0B;EAM1BC,SAAAA,yBAA+B,EAAA,2BAAA;EA8F/BiB,SAAAA,eAAAA,EAAsB,iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KFzF3BrC,SAAAA,WAAoBA,wBAAwBA;;;AAvDxD;AAuDA;;cCvDqBE;;EAAAA,SAAAA,UA0BpB,EAAA,YAAA;EACWC,SAAAA,WAAa,EAAA,aAAWD;EAKnBE,SAAAA,SAAa,EAAA,WAAAC;EAAYC,SAAAA,WAAAA,EAAAA,aAAAA;EAIhCL,SAAAA,SAAAA,EAAAA,WAAAA;EAQME,SAAAA,gBAAAA,EAAAA,kBAAAA;EAKHE,SAAAA,cAAAA,EAAAA,gBAAAA;EAAQ,SAAA,eAAA,EAAA,iBAAA;;;;ECLJc,SAAAA,YAAAA,EAAAA,cAA0B;EAM1BC,SAAAA,WAAAA,EAAAA,aAA+B;EA8F/BiB,SAAAA,YAAAA,EAAAA,cAAsB;;;;;;;;;;;;KDrH3BlC,aAAAA,WAAwBD,wBAAwBA;;;;;UAK3CE,yBAAyBE;;;;QAIhCL;;;;;;;;cAQME;;;;;WAKHE;;;;;;;;;;;;;;;;;;;;;;;;UCLIc,0BAAAA;;;;;;UAMAC,+BAAAA;;;;;;;;;UA8FAiB,sBAAAA"}
|
|
@@ -615,4 +615,4 @@ function isProcessStatus(value) {
|
|
|
615
615
|
|
|
616
616
|
//#endregion
|
|
617
617
|
export { shellEscape as a, TraceContext as c, GitLogger as d, getEnvString as f, isTerminalStatus as i, Execution as l, isProcess as n, createLogger as o, isProcessStatus as r, createNoOpLogger as s, isExecResult as t, ResultImpl as u };
|
|
618
|
-
//# sourceMappingURL=dist-
|
|
618
|
+
//# sourceMappingURL=dist-2SF6oOaz.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dist-D0sZt0AD.js","names":["LogLevelEnum","LogLevelEnum"],"sources":["../../shared/dist/env.js","../../shared/dist/git.js","../../shared/dist/interpreter-types.js","../../shared/dist/logger/types.js","../../shared/dist/logger/logger.js","../../shared/dist/logger/trace-context.js","../../shared/dist/logger/index.js","../../shared/dist/shell-escape.js","../../shared/dist/types.js"],"sourcesContent":["/**\n * Safely extract a string value from an environment object\n *\n * @param env - Environment object with dynamic keys\n * @param key - The environment variable key to access\n * @returns The string value if present and is a string, undefined otherwise\n */\nexport function getEnvString(env, key) {\n const value = env?.[key];\n return typeof value === 'string' ? value : undefined;\n}\n","/**\n * Redact credentials from URLs for secure logging\n *\n * Replaces any credentials (username:password, tokens, etc.) embedded\n * in URLs with ****** to prevent sensitive data exposure in logs.\n * Works with URLs embedded in text (e.g., \"Error: https://token@github.com/repo.git failed\")\n *\n * @param text - String that may contain URLs with credentials\n * @returns String with credentials redacted from any URLs\n */\nexport function redactCredentials(text) {\n // Scan for http(s):// URLs and redact any credentials found\n let result = text;\n let pos = 0;\n while (pos < result.length) {\n const httpPos = result.indexOf('http://', pos);\n const httpsPos = result.indexOf('https://', pos);\n let protocolPos = -1;\n let protocolLen = 0;\n if (httpPos === -1 && httpsPos === -1)\n break;\n if (httpPos !== -1 && (httpsPos === -1 || httpPos < httpsPos)) {\n protocolPos = httpPos;\n protocolLen = 7; // 'http://'.length\n }\n else {\n protocolPos = httpsPos;\n protocolLen = 8; // 'https://'.length\n }\n // Look for @ after the protocol\n const searchStart = protocolPos + protocolLen;\n const atPos = result.indexOf('@', searchStart);\n // Find where the URL ends (whitespace, quotes, or structural delimiters)\n let urlEnd = searchStart;\n while (urlEnd < result.length) {\n const char = result[urlEnd];\n if (/[\\s\"'`<>,;{}[\\]]/.test(char))\n break;\n urlEnd++;\n }\n if (atPos !== -1 && atPos < urlEnd) {\n result = `${result.substring(0, searchStart)}******${result.substring(atPos)}`;\n pos = searchStart + 6; // Move past '******'\n }\n else {\n pos = protocolPos + protocolLen;\n }\n }\n return result;\n}\n/**\n * Sanitize data by redacting credentials from any strings\n * Recursively processes objects and arrays to ensure credentials are never leaked\n */\nexport function sanitizeGitData(data) {\n // Handle primitives\n if (typeof data === 'string') {\n return redactCredentials(data);\n }\n if (data === null || data === undefined) {\n return data;\n }\n // Handle arrays\n if (Array.isArray(data)) {\n return data.map((item) => sanitizeGitData(item));\n }\n // Handle objects - recursively sanitize all fields\n if (typeof data === 'object') {\n const result = {};\n for (const [key, value] of Object.entries(data)) {\n result[key] = sanitizeGitData(value);\n }\n return result;\n }\n return data;\n}\n/**\n * Logger wrapper that automatically sanitizes git credentials\n */\nexport class GitLogger {\n baseLogger;\n constructor(baseLogger) {\n this.baseLogger = baseLogger;\n }\n sanitizeContext(context) {\n return context\n ? sanitizeGitData(context)\n : context;\n }\n sanitizeError(error) {\n if (!error)\n return error;\n // Create a new error with sanitized message and stack\n const sanitized = new Error(redactCredentials(error.message));\n sanitized.name = error.name;\n if (error.stack) {\n sanitized.stack = redactCredentials(error.stack);\n }\n // Preserve other enumerable properties\n const sanitizedRecord = sanitized;\n const errorRecord = error;\n for (const key of Object.keys(error)) {\n if (key !== 'message' && key !== 'stack' && key !== 'name') {\n sanitizedRecord[key] = sanitizeGitData(errorRecord[key]);\n }\n }\n return sanitized;\n }\n debug(message, context) {\n this.baseLogger.debug(message, this.sanitizeContext(context));\n }\n info(message, context) {\n this.baseLogger.info(message, this.sanitizeContext(context));\n }\n warn(message, context) {\n this.baseLogger.warn(message, this.sanitizeContext(context));\n }\n error(message, error, context) {\n this.baseLogger.error(message, this.sanitizeError(error), this.sanitizeContext(context));\n }\n child(context) {\n const sanitized = sanitizeGitData(context);\n const childLogger = this.baseLogger.child(sanitized);\n return new GitLogger(childLogger);\n }\n}\n","// Execution Result Container\nexport class Execution {\n code;\n context;\n /**\n * All results from the execution\n */\n results = [];\n /**\n * Accumulated stdout and stderr\n */\n logs = {\n stdout: [],\n stderr: []\n };\n /**\n * Execution error if any\n */\n error;\n /**\n * Execution count (for interpreter)\n */\n executionCount;\n constructor(code, context) {\n this.code = code;\n this.context = context;\n }\n /**\n * Convert to a plain object for serialization\n */\n toJSON() {\n return {\n code: this.code,\n logs: this.logs,\n error: this.error,\n executionCount: this.executionCount,\n results: this.results.map((result) => ({\n text: result.text,\n html: result.html,\n png: result.png,\n jpeg: result.jpeg,\n svg: result.svg,\n latex: result.latex,\n markdown: result.markdown,\n javascript: result.javascript,\n json: result.json,\n chart: result.chart,\n data: result.data\n }))\n };\n }\n}\n// Implementation of Result\nexport class ResultImpl {\n raw;\n constructor(raw) {\n this.raw = raw;\n }\n get text() {\n return this.raw.text || this.raw.data?.['text/plain'];\n }\n get html() {\n return this.raw.html || this.raw.data?.['text/html'];\n }\n get png() {\n return this.raw.png || this.raw.data?.['image/png'];\n }\n get jpeg() {\n return this.raw.jpeg || this.raw.data?.['image/jpeg'];\n }\n get svg() {\n return this.raw.svg || this.raw.data?.['image/svg+xml'];\n }\n get latex() {\n return this.raw.latex || this.raw.data?.['text/latex'];\n }\n get markdown() {\n return this.raw.markdown || this.raw.data?.['text/markdown'];\n }\n get javascript() {\n return this.raw.javascript || this.raw.data?.['application/javascript'];\n }\n get json() {\n return this.raw.json || this.raw.data?.['application/json'];\n }\n get chart() {\n return this.raw.chart;\n }\n get data() {\n return this.raw.data;\n }\n formats() {\n const formats = [];\n if (this.text)\n formats.push('text');\n if (this.html)\n formats.push('html');\n if (this.png)\n formats.push('png');\n if (this.jpeg)\n formats.push('jpeg');\n if (this.svg)\n formats.push('svg');\n if (this.latex)\n formats.push('latex');\n if (this.markdown)\n formats.push('markdown');\n if (this.javascript)\n formats.push('javascript');\n if (this.json)\n formats.push('json');\n if (this.chart)\n formats.push('chart');\n return formats;\n }\n}\n","/**\n * Logger types for Cloudflare Sandbox SDK\n *\n * Provides structured, trace-aware logging across Worker, Durable Object, and Container.\n */\n/**\n * Log levels (from most to least verbose)\n */\nexport var LogLevel;\n(function (LogLevel) {\n LogLevel[LogLevel[\"DEBUG\"] = 0] = \"DEBUG\";\n LogLevel[LogLevel[\"INFO\"] = 1] = \"INFO\";\n LogLevel[LogLevel[\"WARN\"] = 2] = \"WARN\";\n LogLevel[LogLevel[\"ERROR\"] = 3] = \"ERROR\";\n})(LogLevel || (LogLevel = {}));\n","/**\n * Logger implementation\n */\nimport { LogLevel as LogLevelEnum } from './types.js';\n/**\n * ANSI color codes for terminal output\n */\nconst COLORS = {\n reset: '\\x1b[0m',\n debug: '\\x1b[36m', // Cyan\n info: '\\x1b[32m', // Green\n warn: '\\x1b[33m', // Yellow\n error: '\\x1b[31m', // Red\n dim: '\\x1b[2m' // Dim\n};\n/**\n * CloudflareLogger implements structured logging with support for\n * both JSON output (production) and pretty printing (development).\n */\nexport class CloudflareLogger {\n baseContext;\n minLevel;\n pretty;\n /**\n * Create a new CloudflareLogger\n *\n * @param baseContext Base context included in all log entries\n * @param minLevel Minimum log level to output (default: INFO)\n * @param pretty Enable pretty printing for human-readable output (default: false)\n */\n constructor(baseContext, minLevel = LogLevelEnum.INFO, pretty = false) {\n this.baseContext = baseContext;\n this.minLevel = minLevel;\n this.pretty = pretty;\n }\n /**\n * Log debug-level message\n */\n debug(message, context) {\n if (this.shouldLog(LogLevelEnum.DEBUG)) {\n const logData = this.buildLogData('debug', message, context);\n this.output(console.log, logData);\n }\n }\n /**\n * Log info-level message\n */\n info(message, context) {\n if (this.shouldLog(LogLevelEnum.INFO)) {\n const logData = this.buildLogData('info', message, context);\n this.output(console.log, logData);\n }\n }\n /**\n * Log warning-level message\n */\n warn(message, context) {\n if (this.shouldLog(LogLevelEnum.WARN)) {\n const logData = this.buildLogData('warn', message, context);\n this.output(console.warn, logData);\n }\n }\n /**\n * Log error-level message\n */\n error(message, error, context) {\n if (this.shouldLog(LogLevelEnum.ERROR)) {\n const logData = this.buildLogData('error', message, context, error);\n this.output(console.error, logData);\n }\n }\n /**\n * Create a child logger with additional context\n */\n child(context) {\n return new CloudflareLogger({ ...this.baseContext, ...context }, this.minLevel, this.pretty);\n }\n /**\n * Check if a log level should be output\n */\n shouldLog(level) {\n return level >= this.minLevel;\n }\n /**\n * Build log data object\n */\n buildLogData(level, message, context, error) {\n const logData = {\n level,\n msg: message,\n ...this.baseContext,\n ...context,\n timestamp: new Date().toISOString()\n };\n // Add error details if provided\n if (error) {\n logData.error = {\n message: error.message,\n stack: error.stack,\n name: error.name\n };\n }\n return logData;\n }\n /**\n * Output log data to console (pretty or JSON)\n */\n output(consoleFn, data) {\n if (this.pretty) {\n this.outputPretty(consoleFn, data);\n }\n else {\n this.outputJson(consoleFn, data);\n }\n }\n /**\n * Output as JSON (production)\n */\n outputJson(consoleFn, data) {\n consoleFn(JSON.stringify(data));\n }\n /**\n * Output as pretty-printed, colored text (development)\n *\n * Format: LEVEL [component] message (trace: tr_...) {context}\n * Example: INFO [sandbox-do] Command started (trace: tr_7f3a9b2c) {commandId: \"cmd-123\"}\n */\n outputPretty(consoleFn, data) {\n const { level, msg, timestamp, traceId, component, sandboxId, sessionId, processId, commandId, operation, duration, error, ...rest } = data;\n // Build the main log line\n const levelStr = String(level || 'INFO').toUpperCase();\n const levelColor = this.getLevelColor(levelStr);\n const componentBadge = component ? `[${component}]` : '';\n const traceIdShort = traceId ? String(traceId).substring(0, 12) : '';\n // Start with level and component\n let logLine = `${levelColor}${levelStr.padEnd(5)}${COLORS.reset} ${componentBadge} ${msg}`;\n // Add trace ID if present\n if (traceIdShort) {\n logLine += ` ${COLORS.dim}(trace: ${traceIdShort})${COLORS.reset}`;\n }\n // Collect important context fields\n const contextFields = [];\n if (operation)\n contextFields.push(`operation: ${operation}`);\n if (commandId)\n contextFields.push(`commandId: ${String(commandId).substring(0, 12)}`);\n if (sandboxId)\n contextFields.push(`sandboxId: ${sandboxId}`);\n if (sessionId)\n contextFields.push(`sessionId: ${String(sessionId).substring(0, 12)}`);\n if (processId)\n contextFields.push(`processId: ${processId}`);\n if (duration !== undefined)\n contextFields.push(`duration: ${duration}ms`);\n // Add important context inline\n if (contextFields.length > 0) {\n logLine += ` ${COLORS.dim}{${contextFields.join(', ')}}${COLORS.reset}`;\n }\n // Output main log line\n consoleFn(logLine);\n // Output error details on separate lines if present\n if (error && typeof error === 'object') {\n const errorObj = error;\n if (errorObj.message) {\n consoleFn(` ${COLORS.error}Error: ${errorObj.message}${COLORS.reset}`);\n }\n if (errorObj.stack) {\n consoleFn(` ${COLORS.dim}${errorObj.stack}${COLORS.reset}`);\n }\n }\n // Output additional context if present\n if (Object.keys(rest).length > 0) {\n consoleFn(` ${COLORS.dim}${JSON.stringify(rest, null, 2)}${COLORS.reset}`);\n }\n }\n /**\n * Get ANSI color code for log level\n */\n getLevelColor(level) {\n const levelLower = level.toLowerCase();\n switch (levelLower) {\n case 'debug':\n return COLORS.debug;\n case 'info':\n return COLORS.info;\n case 'warn':\n return COLORS.warn;\n case 'error':\n return COLORS.error;\n default:\n return COLORS.reset;\n }\n }\n}\n","/**\n * Trace context utilities for request correlation\n *\n * Trace IDs enable correlating logs across distributed components:\n * Worker → Durable Object → Container → back\n *\n * The trace ID is propagated via the X-Trace-Id HTTP header.\n */\n/**\n * Utility for managing trace context across distributed components\n */\n// biome-ignore lint/complexity/noStaticOnlyClass: Keep as class for namespace grouping and discoverability\nexport class TraceContext {\n /**\n * HTTP header name for trace ID propagation\n */\n static TRACE_HEADER = 'X-Trace-Id';\n /**\n * Generate a new trace ID\n *\n * Format: \"tr_\" + 16 random hex characters\n * Example: \"tr_7f3a9b2c4e5d6f1a\"\n *\n * @returns Newly generated trace ID\n */\n static generate() {\n // Use crypto.randomUUID() for randomness, extract 16 hex chars\n const randomHex = crypto.randomUUID().replace(/-/g, '').substring(0, 16);\n return `tr_${randomHex}`;\n }\n /**\n * Extract trace ID from HTTP request headers\n *\n * @param headers Request headers\n * @returns Trace ID if present, null otherwise\n */\n static fromHeaders(headers) {\n return headers.get(TraceContext.TRACE_HEADER);\n }\n /**\n * Create headers object with trace ID for outgoing requests\n *\n * @param traceId Trace ID to include\n * @returns Headers object with X-Trace-Id set\n */\n static toHeaders(traceId) {\n return { [TraceContext.TRACE_HEADER]: traceId };\n }\n /**\n * Get the header name used for trace ID propagation\n *\n * @returns Header name (\"X-Trace-Id\")\n */\n static getHeaderName() {\n return TraceContext.TRACE_HEADER;\n }\n}\n","/**\n * Logger module\n *\n * Provides structured, trace-aware logging with:\n * - Explicit logger passing via constructor injection\n * - Pretty printing for local development\n * - JSON output for production\n * - Environment auto-detection\n * - Log level configuration\n *\n * Usage:\n *\n * ```typescript\n * // Create a logger at entry point\n * const logger = createLogger({ component: 'sandbox-do', traceId: 'tr_abc123' });\n *\n * // Pass to classes via constructor\n * const service = new MyService(logger);\n *\n * // Create child loggers for additional context\n * const execLogger = logger.child({ operation: 'exec', commandId: 'cmd-456' });\n * execLogger.info('Operation started');\n * ```\n */\nimport { CloudflareLogger } from './logger.js';\nimport { TraceContext } from './trace-context.js';\nimport { LogLevel as LogLevelEnum } from './types.js';\nexport { CloudflareLogger } from './logger.js';\nexport { TraceContext } from './trace-context.js';\nexport { LogLevel as LogLevelEnum } from './types.js';\n/**\n * Create a no-op logger for testing\n *\n * Returns a logger that implements the Logger interface but does nothing.\n * Useful for tests that don't need actual logging output.\n *\n * @returns No-op logger instance\n *\n * @example\n * ```typescript\n * // In tests\n * const client = new HttpClient({\n * baseUrl: 'http://test.com',\n * logger: createNoOpLogger() // Optional - tests can enable real logging if needed\n * });\n * ```\n */\nexport function createNoOpLogger() {\n return {\n debug: () => { },\n info: () => { },\n warn: () => { },\n error: () => { },\n child: () => createNoOpLogger()\n };\n}\n/**\n * Create a new logger instance\n *\n * @param context Base context for the logger. Must include 'component'.\n * TraceId will be auto-generated if not provided.\n * @returns New logger instance\n *\n * @example\n * ```typescript\n * // In Durable Object\n * const logger = createLogger({\n * component: 'sandbox-do',\n * traceId: TraceContext.fromHeaders(request.headers) || TraceContext.generate(),\n * sandboxId: this.id\n * });\n *\n * // In Container\n * const logger = createLogger({\n * component: 'container',\n * traceId: TraceContext.fromHeaders(request.headers)!,\n * sessionId: this.id\n * });\n * ```\n */\nexport function createLogger(context) {\n const minLevel = getLogLevelFromEnv();\n const pretty = isPrettyPrintEnabled();\n const baseContext = {\n ...context,\n traceId: context.traceId || TraceContext.generate(),\n component: context.component\n };\n return new CloudflareLogger(baseContext, minLevel, pretty);\n}\n/**\n * Get log level from environment variable\n *\n * Checks SANDBOX_LOG_LEVEL env var, falls back to default based on environment.\n * Default: 'debug' for development, 'info' for production\n */\nfunction getLogLevelFromEnv() {\n const envLevel = getEnvVar('SANDBOX_LOG_LEVEL') || 'info';\n switch (envLevel.toLowerCase()) {\n case 'debug':\n return LogLevelEnum.DEBUG;\n case 'info':\n return LogLevelEnum.INFO;\n case 'warn':\n return LogLevelEnum.WARN;\n case 'error':\n return LogLevelEnum.ERROR;\n default:\n // Invalid level, fall back to info\n return LogLevelEnum.INFO;\n }\n}\n/**\n * Check if pretty printing should be enabled\n *\n * Checks SANDBOX_LOG_FORMAT env var, falls back to auto-detection:\n * - Local development: pretty (colored, human-readable)\n * - Production: json (structured)\n */\nfunction isPrettyPrintEnabled() {\n // Check explicit SANDBOX_LOG_FORMAT env var\n const format = getEnvVar('SANDBOX_LOG_FORMAT');\n if (format) {\n return format.toLowerCase() === 'pretty';\n }\n return false;\n}\n/**\n * Get environment variable value\n *\n * Supports both Node.js (process.env) and Bun (Bun.env)\n */\nfunction getEnvVar(name) {\n // Try process.env first (Node.js / Bun)\n if (typeof process !== 'undefined' && process.env) {\n return process.env[name];\n }\n // Try Bun.env (Bun runtime)\n if (typeof Bun !== 'undefined') {\n const bunEnv = Bun.env;\n if (bunEnv) {\n return bunEnv[name];\n }\n }\n return undefined;\n}\n","/**\n * Escapes a string for safe use in shell commands using POSIX single-quote escaping.\n * Prevents command injection by wrapping the string in single quotes and escaping\n * any single quotes within the string.\n */\nexport function shellEscape(str) {\n return `'${str.replace(/'/g, \"'\\\\''\")}'`;\n}\n","/**\n * Check if a process status indicates the process has terminated\n */\nexport function isTerminalStatus(status) {\n return (status === 'completed' ||\n status === 'failed' ||\n status === 'killed' ||\n status === 'error');\n}\n// Type guards for runtime validation\nexport function isExecResult(value) {\n return (value &&\n typeof value.success === 'boolean' &&\n typeof value.exitCode === 'number' &&\n typeof value.stdout === 'string' &&\n typeof value.stderr === 'string');\n}\nexport function isProcess(value) {\n return (value &&\n typeof value.id === 'string' &&\n typeof value.command === 'string' &&\n typeof value.status === 'string');\n}\nexport function isProcessStatus(value) {\n return [\n 'starting',\n 'running',\n 'completed',\n 'failed',\n 'killed',\n 'error'\n ].includes(value);\n}\n// Re-export interpreter types for convenience\nexport { Execution, ResultImpl } from './interpreter-types';\n"],"mappings":";;;;;;;;AAOA,SAAgB,aAAa,KAAK,KAAK;CACnC,MAAM,QAAQ,MAAM;AACpB,QAAO,OAAO,UAAU,WAAW,QAAQ;;;;;;;;;;;;;;;ACC/C,SAAgB,kBAAkB,MAAM;CAEpC,IAAI,SAAS;CACb,IAAI,MAAM;AACV,QAAO,MAAM,OAAO,QAAQ;EACxB,MAAM,UAAU,OAAO,QAAQ,WAAW,IAAI;EAC9C,MAAM,WAAW,OAAO,QAAQ,YAAY,IAAI;EAChD,IAAI,cAAc;EAClB,IAAI,cAAc;AACl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ACA;EACA;EACA;EACH,CAAC,SAAS,MAAM"}
|
|
1
|
+
{"version":3,"file":"dist-2SF6oOaz.js","names":["LogLevelEnum","LogLevelEnum"],"sources":["../../shared/dist/env.js","../../shared/dist/git.js","../../shared/dist/interpreter-types.js","../../shared/dist/logger/types.js","../../shared/dist/logger/logger.js","../../shared/dist/logger/trace-context.js","../../shared/dist/logger/index.js","../../shared/dist/shell-escape.js","../../shared/dist/types.js"],"sourcesContent":["/**\n * Safely extract a string value from an environment object\n *\n * @param env - Environment object with dynamic keys\n * @param key - The environment variable key to access\n * @returns The string value if present and is a string, undefined otherwise\n */\nexport function getEnvString(env, key) {\n const value = env?.[key];\n return typeof value === 'string' ? value : undefined;\n}\n","/**\n * Redact credentials from URLs for secure logging\n *\n * Replaces any credentials (username:password, tokens, etc.) embedded\n * in URLs with ****** to prevent sensitive data exposure in logs.\n * Works with URLs embedded in text (e.g., \"Error: https://token@github.com/repo.git failed\")\n *\n * @param text - String that may contain URLs with credentials\n * @returns String with credentials redacted from any URLs\n */\nexport function redactCredentials(text) {\n // Scan for http(s):// URLs and redact any credentials found\n let result = text;\n let pos = 0;\n while (pos < result.length) {\n const httpPos = result.indexOf('http://', pos);\n const httpsPos = result.indexOf('https://', pos);\n let protocolPos = -1;\n let protocolLen = 0;\n if (httpPos === -1 && httpsPos === -1)\n break;\n if (httpPos !== -1 && (httpsPos === -1 || httpPos < httpsPos)) {\n protocolPos = httpPos;\n protocolLen = 7; // 'http://'.length\n }\n else {\n protocolPos = httpsPos;\n protocolLen = 8; // 'https://'.length\n }\n // Look for @ after the protocol\n const searchStart = protocolPos + protocolLen;\n const atPos = result.indexOf('@', searchStart);\n // Find where the URL ends (whitespace, quotes, or structural delimiters)\n let urlEnd = searchStart;\n while (urlEnd < result.length) {\n const char = result[urlEnd];\n if (/[\\s\"'`<>,;{}[\\]]/.test(char))\n break;\n urlEnd++;\n }\n if (atPos !== -1 && atPos < urlEnd) {\n result = `${result.substring(0, searchStart)}******${result.substring(atPos)}`;\n pos = searchStart + 6; // Move past '******'\n }\n else {\n pos = protocolPos + protocolLen;\n }\n }\n return result;\n}\n/**\n * Sanitize data by redacting credentials from any strings\n * Recursively processes objects and arrays to ensure credentials are never leaked\n */\nexport function sanitizeGitData(data) {\n // Handle primitives\n if (typeof data === 'string') {\n return redactCredentials(data);\n }\n if (data === null || data === undefined) {\n return data;\n }\n // Handle arrays\n if (Array.isArray(data)) {\n return data.map((item) => sanitizeGitData(item));\n }\n // Handle objects - recursively sanitize all fields\n if (typeof data === 'object') {\n const result = {};\n for (const [key, value] of Object.entries(data)) {\n result[key] = sanitizeGitData(value);\n }\n return result;\n }\n return data;\n}\n/**\n * Logger wrapper that automatically sanitizes git credentials\n */\nexport class GitLogger {\n baseLogger;\n constructor(baseLogger) {\n this.baseLogger = baseLogger;\n }\n sanitizeContext(context) {\n return context\n ? sanitizeGitData(context)\n : context;\n }\n sanitizeError(error) {\n if (!error)\n return error;\n // Create a new error with sanitized message and stack\n const sanitized = new Error(redactCredentials(error.message));\n sanitized.name = error.name;\n if (error.stack) {\n sanitized.stack = redactCredentials(error.stack);\n }\n // Preserve other enumerable properties\n const sanitizedRecord = sanitized;\n const errorRecord = error;\n for (const key of Object.keys(error)) {\n if (key !== 'message' && key !== 'stack' && key !== 'name') {\n sanitizedRecord[key] = sanitizeGitData(errorRecord[key]);\n }\n }\n return sanitized;\n }\n debug(message, context) {\n this.baseLogger.debug(message, this.sanitizeContext(context));\n }\n info(message, context) {\n this.baseLogger.info(message, this.sanitizeContext(context));\n }\n warn(message, context) {\n this.baseLogger.warn(message, this.sanitizeContext(context));\n }\n error(message, error, context) {\n this.baseLogger.error(message, this.sanitizeError(error), this.sanitizeContext(context));\n }\n child(context) {\n const sanitized = sanitizeGitData(context);\n const childLogger = this.baseLogger.child(sanitized);\n return new GitLogger(childLogger);\n }\n}\n","// Execution Result Container\nexport class Execution {\n code;\n context;\n /**\n * All results from the execution\n */\n results = [];\n /**\n * Accumulated stdout and stderr\n */\n logs = {\n stdout: [],\n stderr: []\n };\n /**\n * Execution error if any\n */\n error;\n /**\n * Execution count (for interpreter)\n */\n executionCount;\n constructor(code, context) {\n this.code = code;\n this.context = context;\n }\n /**\n * Convert to a plain object for serialization\n */\n toJSON() {\n return {\n code: this.code,\n logs: this.logs,\n error: this.error,\n executionCount: this.executionCount,\n results: this.results.map((result) => ({\n text: result.text,\n html: result.html,\n png: result.png,\n jpeg: result.jpeg,\n svg: result.svg,\n latex: result.latex,\n markdown: result.markdown,\n javascript: result.javascript,\n json: result.json,\n chart: result.chart,\n data: result.data\n }))\n };\n }\n}\n// Implementation of Result\nexport class ResultImpl {\n raw;\n constructor(raw) {\n this.raw = raw;\n }\n get text() {\n return this.raw.text || this.raw.data?.['text/plain'];\n }\n get html() {\n return this.raw.html || this.raw.data?.['text/html'];\n }\n get png() {\n return this.raw.png || this.raw.data?.['image/png'];\n }\n get jpeg() {\n return this.raw.jpeg || this.raw.data?.['image/jpeg'];\n }\n get svg() {\n return this.raw.svg || this.raw.data?.['image/svg+xml'];\n }\n get latex() {\n return this.raw.latex || this.raw.data?.['text/latex'];\n }\n get markdown() {\n return this.raw.markdown || this.raw.data?.['text/markdown'];\n }\n get javascript() {\n return this.raw.javascript || this.raw.data?.['application/javascript'];\n }\n get json() {\n return this.raw.json || this.raw.data?.['application/json'];\n }\n get chart() {\n return this.raw.chart;\n }\n get data() {\n return this.raw.data;\n }\n formats() {\n const formats = [];\n if (this.text)\n formats.push('text');\n if (this.html)\n formats.push('html');\n if (this.png)\n formats.push('png');\n if (this.jpeg)\n formats.push('jpeg');\n if (this.svg)\n formats.push('svg');\n if (this.latex)\n formats.push('latex');\n if (this.markdown)\n formats.push('markdown');\n if (this.javascript)\n formats.push('javascript');\n if (this.json)\n formats.push('json');\n if (this.chart)\n formats.push('chart');\n return formats;\n }\n}\n","/**\n * Logger types for Cloudflare Sandbox SDK\n *\n * Provides structured, trace-aware logging across Worker, Durable Object, and Container.\n */\n/**\n * Log levels (from most to least verbose)\n */\nexport var LogLevel;\n(function (LogLevel) {\n LogLevel[LogLevel[\"DEBUG\"] = 0] = \"DEBUG\";\n LogLevel[LogLevel[\"INFO\"] = 1] = \"INFO\";\n LogLevel[LogLevel[\"WARN\"] = 2] = \"WARN\";\n LogLevel[LogLevel[\"ERROR\"] = 3] = \"ERROR\";\n})(LogLevel || (LogLevel = {}));\n","/**\n * Logger implementation\n */\nimport { LogLevel as LogLevelEnum } from './types.js';\n/**\n * ANSI color codes for terminal output\n */\nconst COLORS = {\n reset: '\\x1b[0m',\n debug: '\\x1b[36m', // Cyan\n info: '\\x1b[32m', // Green\n warn: '\\x1b[33m', // Yellow\n error: '\\x1b[31m', // Red\n dim: '\\x1b[2m' // Dim\n};\n/**\n * CloudflareLogger implements structured logging with support for\n * both JSON output (production) and pretty printing (development).\n */\nexport class CloudflareLogger {\n baseContext;\n minLevel;\n pretty;\n /**\n * Create a new CloudflareLogger\n *\n * @param baseContext Base context included in all log entries\n * @param minLevel Minimum log level to output (default: INFO)\n * @param pretty Enable pretty printing for human-readable output (default: false)\n */\n constructor(baseContext, minLevel = LogLevelEnum.INFO, pretty = false) {\n this.baseContext = baseContext;\n this.minLevel = minLevel;\n this.pretty = pretty;\n }\n /**\n * Log debug-level message\n */\n debug(message, context) {\n if (this.shouldLog(LogLevelEnum.DEBUG)) {\n const logData = this.buildLogData('debug', message, context);\n this.output(console.log, logData);\n }\n }\n /**\n * Log info-level message\n */\n info(message, context) {\n if (this.shouldLog(LogLevelEnum.INFO)) {\n const logData = this.buildLogData('info', message, context);\n this.output(console.log, logData);\n }\n }\n /**\n * Log warning-level message\n */\n warn(message, context) {\n if (this.shouldLog(LogLevelEnum.WARN)) {\n const logData = this.buildLogData('warn', message, context);\n this.output(console.warn, logData);\n }\n }\n /**\n * Log error-level message\n */\n error(message, error, context) {\n if (this.shouldLog(LogLevelEnum.ERROR)) {\n const logData = this.buildLogData('error', message, context, error);\n this.output(console.error, logData);\n }\n }\n /**\n * Create a child logger with additional context\n */\n child(context) {\n return new CloudflareLogger({ ...this.baseContext, ...context }, this.minLevel, this.pretty);\n }\n /**\n * Check if a log level should be output\n */\n shouldLog(level) {\n return level >= this.minLevel;\n }\n /**\n * Build log data object\n */\n buildLogData(level, message, context, error) {\n const logData = {\n level,\n msg: message,\n ...this.baseContext,\n ...context,\n timestamp: new Date().toISOString()\n };\n // Add error details if provided\n if (error) {\n logData.error = {\n message: error.message,\n stack: error.stack,\n name: error.name\n };\n }\n return logData;\n }\n /**\n * Output log data to console (pretty or JSON)\n */\n output(consoleFn, data) {\n if (this.pretty) {\n this.outputPretty(consoleFn, data);\n }\n else {\n this.outputJson(consoleFn, data);\n }\n }\n /**\n * Output as JSON (production)\n */\n outputJson(consoleFn, data) {\n consoleFn(JSON.stringify(data));\n }\n /**\n * Output as pretty-printed, colored text (development)\n *\n * Format: LEVEL [component] message (trace: tr_...) {context}\n * Example: INFO [sandbox-do] Command started (trace: tr_7f3a9b2c) {commandId: \"cmd-123\"}\n */\n outputPretty(consoleFn, data) {\n const { level, msg, timestamp, traceId, component, sandboxId, sessionId, processId, commandId, operation, duration, error, ...rest } = data;\n // Build the main log line\n const levelStr = String(level || 'INFO').toUpperCase();\n const levelColor = this.getLevelColor(levelStr);\n const componentBadge = component ? `[${component}]` : '';\n const traceIdShort = traceId ? String(traceId).substring(0, 12) : '';\n // Start with level and component\n let logLine = `${levelColor}${levelStr.padEnd(5)}${COLORS.reset} ${componentBadge} ${msg}`;\n // Add trace ID if present\n if (traceIdShort) {\n logLine += ` ${COLORS.dim}(trace: ${traceIdShort})${COLORS.reset}`;\n }\n // Collect important context fields\n const contextFields = [];\n if (operation)\n contextFields.push(`operation: ${operation}`);\n if (commandId)\n contextFields.push(`commandId: ${String(commandId).substring(0, 12)}`);\n if (sandboxId)\n contextFields.push(`sandboxId: ${sandboxId}`);\n if (sessionId)\n contextFields.push(`sessionId: ${String(sessionId).substring(0, 12)}`);\n if (processId)\n contextFields.push(`processId: ${processId}`);\n if (duration !== undefined)\n contextFields.push(`duration: ${duration}ms`);\n // Add important context inline\n if (contextFields.length > 0) {\n logLine += ` ${COLORS.dim}{${contextFields.join(', ')}}${COLORS.reset}`;\n }\n // Output main log line\n consoleFn(logLine);\n // Output error details on separate lines if present\n if (error && typeof error === 'object') {\n const errorObj = error;\n if (errorObj.message) {\n consoleFn(` ${COLORS.error}Error: ${errorObj.message}${COLORS.reset}`);\n }\n if (errorObj.stack) {\n consoleFn(` ${COLORS.dim}${errorObj.stack}${COLORS.reset}`);\n }\n }\n // Output additional context if present\n if (Object.keys(rest).length > 0) {\n consoleFn(` ${COLORS.dim}${JSON.stringify(rest, null, 2)}${COLORS.reset}`);\n }\n }\n /**\n * Get ANSI color code for log level\n */\n getLevelColor(level) {\n const levelLower = level.toLowerCase();\n switch (levelLower) {\n case 'debug':\n return COLORS.debug;\n case 'info':\n return COLORS.info;\n case 'warn':\n return COLORS.warn;\n case 'error':\n return COLORS.error;\n default:\n return COLORS.reset;\n }\n }\n}\n","/**\n * Trace context utilities for request correlation\n *\n * Trace IDs enable correlating logs across distributed components:\n * Worker → Durable Object → Container → back\n *\n * The trace ID is propagated via the X-Trace-Id HTTP header.\n */\n/**\n * Utility for managing trace context across distributed components\n */\n// biome-ignore lint/complexity/noStaticOnlyClass: Keep as class for namespace grouping and discoverability\nexport class TraceContext {\n /**\n * HTTP header name for trace ID propagation\n */\n static TRACE_HEADER = 'X-Trace-Id';\n /**\n * Generate a new trace ID\n *\n * Format: \"tr_\" + 16 random hex characters\n * Example: \"tr_7f3a9b2c4e5d6f1a\"\n *\n * @returns Newly generated trace ID\n */\n static generate() {\n // Use crypto.randomUUID() for randomness, extract 16 hex chars\n const randomHex = crypto.randomUUID().replace(/-/g, '').substring(0, 16);\n return `tr_${randomHex}`;\n }\n /**\n * Extract trace ID from HTTP request headers\n *\n * @param headers Request headers\n * @returns Trace ID if present, null otherwise\n */\n static fromHeaders(headers) {\n return headers.get(TraceContext.TRACE_HEADER);\n }\n /**\n * Create headers object with trace ID for outgoing requests\n *\n * @param traceId Trace ID to include\n * @returns Headers object with X-Trace-Id set\n */\n static toHeaders(traceId) {\n return { [TraceContext.TRACE_HEADER]: traceId };\n }\n /**\n * Get the header name used for trace ID propagation\n *\n * @returns Header name (\"X-Trace-Id\")\n */\n static getHeaderName() {\n return TraceContext.TRACE_HEADER;\n }\n}\n","/**\n * Logger module\n *\n * Provides structured, trace-aware logging with:\n * - Explicit logger passing via constructor injection\n * - Pretty printing for local development\n * - JSON output for production\n * - Environment auto-detection\n * - Log level configuration\n *\n * Usage:\n *\n * ```typescript\n * // Create a logger at entry point\n * const logger = createLogger({ component: 'sandbox-do', traceId: 'tr_abc123' });\n *\n * // Pass to classes via constructor\n * const service = new MyService(logger);\n *\n * // Create child loggers for additional context\n * const execLogger = logger.child({ operation: 'exec', commandId: 'cmd-456' });\n * execLogger.info('Operation started');\n * ```\n */\nimport { CloudflareLogger } from './logger.js';\nimport { TraceContext } from './trace-context.js';\nimport { LogLevel as LogLevelEnum } from './types.js';\nexport { CloudflareLogger } from './logger.js';\nexport { TraceContext } from './trace-context.js';\nexport { LogLevel as LogLevelEnum } from './types.js';\n/**\n * Create a no-op logger for testing\n *\n * Returns a logger that implements the Logger interface but does nothing.\n * Useful for tests that don't need actual logging output.\n *\n * @returns No-op logger instance\n *\n * @example\n * ```typescript\n * // In tests\n * const client = new HttpClient({\n * baseUrl: 'http://test.com',\n * logger: createNoOpLogger() // Optional - tests can enable real logging if needed\n * });\n * ```\n */\nexport function createNoOpLogger() {\n return {\n debug: () => { },\n info: () => { },\n warn: () => { },\n error: () => { },\n child: () => createNoOpLogger()\n };\n}\n/**\n * Create a new logger instance\n *\n * @param context Base context for the logger. Must include 'component'.\n * TraceId will be auto-generated if not provided.\n * @returns New logger instance\n *\n * @example\n * ```typescript\n * // In Durable Object\n * const logger = createLogger({\n * component: 'sandbox-do',\n * traceId: TraceContext.fromHeaders(request.headers) || TraceContext.generate(),\n * sandboxId: this.id\n * });\n *\n * // In Container\n * const logger = createLogger({\n * component: 'container',\n * traceId: TraceContext.fromHeaders(request.headers)!,\n * sessionId: this.id\n * });\n * ```\n */\nexport function createLogger(context) {\n const minLevel = getLogLevelFromEnv();\n const pretty = isPrettyPrintEnabled();\n const baseContext = {\n ...context,\n traceId: context.traceId || TraceContext.generate(),\n component: context.component\n };\n return new CloudflareLogger(baseContext, minLevel, pretty);\n}\n/**\n * Get log level from environment variable\n *\n * Checks SANDBOX_LOG_LEVEL env var, falls back to default based on environment.\n * Default: 'debug' for development, 'info' for production\n */\nfunction getLogLevelFromEnv() {\n const envLevel = getEnvVar('SANDBOX_LOG_LEVEL') || 'info';\n switch (envLevel.toLowerCase()) {\n case 'debug':\n return LogLevelEnum.DEBUG;\n case 'info':\n return LogLevelEnum.INFO;\n case 'warn':\n return LogLevelEnum.WARN;\n case 'error':\n return LogLevelEnum.ERROR;\n default:\n // Invalid level, fall back to info\n return LogLevelEnum.INFO;\n }\n}\n/**\n * Check if pretty printing should be enabled\n *\n * Checks SANDBOX_LOG_FORMAT env var, falls back to auto-detection:\n * - Local development: pretty (colored, human-readable)\n * - Production: json (structured)\n */\nfunction isPrettyPrintEnabled() {\n // Check explicit SANDBOX_LOG_FORMAT env var\n const format = getEnvVar('SANDBOX_LOG_FORMAT');\n if (format) {\n return format.toLowerCase() === 'pretty';\n }\n return false;\n}\n/**\n * Get environment variable value\n *\n * Supports both Node.js (process.env) and Bun (Bun.env)\n */\nfunction getEnvVar(name) {\n // Try process.env first (Node.js / Bun)\n if (typeof process !== 'undefined' && process.env) {\n return process.env[name];\n }\n // Try Bun.env (Bun runtime)\n if (typeof Bun !== 'undefined') {\n const bunEnv = Bun.env;\n if (bunEnv) {\n return bunEnv[name];\n }\n }\n return undefined;\n}\n","/**\n * Escapes a string for safe use in shell commands using POSIX single-quote escaping.\n * Prevents command injection by wrapping the string in single quotes and escaping\n * any single quotes within the string.\n */\nexport function shellEscape(str) {\n return `'${str.replace(/'/g, \"'\\\\''\")}'`;\n}\n","/**\n * Check if a process status indicates the process has terminated\n */\nexport function isTerminalStatus(status) {\n return (status === 'completed' ||\n status === 'failed' ||\n status === 'killed' ||\n status === 'error');\n}\n// Type guards for runtime validation\nexport function isExecResult(value) {\n return (value &&\n typeof value.success === 'boolean' &&\n typeof value.exitCode === 'number' &&\n typeof value.stdout === 'string' &&\n typeof value.stderr === 'string');\n}\nexport function isProcess(value) {\n return (value &&\n typeof value.id === 'string' &&\n typeof value.command === 'string' &&\n typeof value.status === 'string');\n}\nexport function isProcessStatus(value) {\n return [\n 'starting',\n 'running',\n 'completed',\n 'failed',\n 'killed',\n 'error'\n ].includes(value);\n}\n// Re-export interpreter types for convenience\nexport { Execution, ResultImpl } from './interpreter-types';\n"],"mappings":";;;;;;;;AAOA,SAAgB,aAAa,KAAK,KAAK;CACnC,MAAM,QAAQ,MAAM;AACpB,QAAO,OAAO,UAAU,WAAW,QAAQ;;;;;;;;;;;;;;;ACC/C,SAAgB,kBAAkB,MAAM;CAEpC,IAAI,SAAS;CACb,IAAI,MAAM;AACV,QAAO,MAAM,OAAO,QAAQ;EACxB,MAAM,UAAU,OAAO,QAAQ,WAAW,IAAI;EAC9C,MAAM,WAAW,OAAO,QAAQ,YAAY,IAAI;EAChD,IAAI,cAAc;EAClB,IAAI,cAAc;AAClB,MAAI,YAAY,MAAM,aAAa,GAC/B;AACJ,MAAI,YAAY,OAAO,aAAa,MAAM,UAAU,WAAW;AAC3D,iBAAc;AACd,iBAAc;SAEb;AACD,iBAAc;AACd,iBAAc;;EAGlB,MAAM,cAAc,cAAc;EAClC,MAAM,QAAQ,OAAO,QAAQ,KAAK,YAAY;EAE9C,IAAI,SAAS;AACb,SAAO,SAAS,OAAO,QAAQ;GAC3B,MAAM,OAAO,OAAO;AACpB,OAAI,mBAAmB,KAAK,KAAK,CAC7B;AACJ;;AAEJ,MAAI,UAAU,MAAM,QAAQ,QAAQ;AAChC,YAAS,GAAG,OAAO,UAAU,GAAG,YAAY,CAAC,QAAQ,OA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A,SAAa;;;;;;;;;;AAUhC,SAAS,uBAAuB;CAE5B,MAAM,SAAS,UAAU,qBAAqB;AAC9C,KAAI,OACA,QAAO,OAAO,aAAa,KAAK;AAEpC,QAAO;;;;;;;AAOX,SAAS,UAAU,MAAM;AAErB,KAAI,OAAO,YAAY,eAAe,QAAQ,IAC1C,QAAO,QAAQ,IAAI;AAGvB,KAAI,OAAO,QAAQ,aAAa;EAC5B,MAAM,SAAS,IAAI;AACnB,MAAI,OACA,QAAO,OAAO;;;;;;;;;;;ACxI1B,SAAgB,YAAY,KAAK;AAC7B,QAAO,IAAI,IAAI,QAAQ,MAAM,QAAQ,CAAC;;;;;;;;ACH1C,SAAgB,iBAAiB,QAAQ;AACrC,QAAQ,WAAW,eACf,WAAW,YACX,WAAW,YACX,WAAW;;AAGnB,SAAgB,aAAa,OAAO;AAChC,QAAQ,SACJ,OAAO,MAAM,YAAY,aACzB,OAAO,MAAM,aAAa,YAC1B,OAAO,MAAM,WAAW,YACxB,OAAO,MAAM,WAAW;;AAEhC,SAAgB,UAAU,OAAO;AAC7B,QAAQ,SACJ,OAAO,MAAM,OAAO,YACpB,OAAO,MAAM,YAAY,YACzB,OAAO,MAAM,WAAW;;AAEhC,SAAgB,gBAAgB,OAAO;AACnC,QAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACH,CAAC,SAAS,MAAM"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
//#region ../shared/dist/errors/codes.js
|
|
2
|
+
/**
|
|
3
|
+
* Centralized error code registry
|
|
4
|
+
* Each code maps to a specific error type with consistent semantics
|
|
5
|
+
*/
|
|
6
|
+
const ErrorCode = {
|
|
7
|
+
FILE_NOT_FOUND: "FILE_NOT_FOUND",
|
|
8
|
+
PERMISSION_DENIED: "PERMISSION_DENIED",
|
|
9
|
+
FILE_EXISTS: "FILE_EXISTS",
|
|
10
|
+
IS_DIRECTORY: "IS_DIRECTORY",
|
|
11
|
+
NOT_DIRECTORY: "NOT_DIRECTORY",
|
|
12
|
+
NO_SPACE: "NO_SPACE",
|
|
13
|
+
TOO_MANY_FILES: "TOO_MANY_FILES",
|
|
14
|
+
RESOURCE_BUSY: "RESOURCE_BUSY",
|
|
15
|
+
READ_ONLY: "READ_ONLY",
|
|
16
|
+
NAME_TOO_LONG: "NAME_TOO_LONG",
|
|
17
|
+
TOO_MANY_LINKS: "TOO_MANY_LINKS",
|
|
18
|
+
FILESYSTEM_ERROR: "FILESYSTEM_ERROR",
|
|
19
|
+
COMMAND_NOT_FOUND: "COMMAND_NOT_FOUND",
|
|
20
|
+
COMMAND_PERMISSION_DENIED: "COMMAND_PERMISSION_DENIED",
|
|
21
|
+
INVALID_COMMAND: "INVALID_COMMAND",
|
|
22
|
+
COMMAND_EXECUTION_ERROR: "COMMAND_EXECUTION_ERROR",
|
|
23
|
+
STREAM_START_ERROR: "STREAM_START_ERROR",
|
|
24
|
+
PROCESS_NOT_FOUND: "PROCESS_NOT_FOUND",
|
|
25
|
+
PROCESS_PERMISSION_DENIED: "PROCESS_PERMISSION_DENIED",
|
|
26
|
+
PROCESS_ERROR: "PROCESS_ERROR",
|
|
27
|
+
SESSION_ALREADY_EXISTS: "SESSION_ALREADY_EXISTS",
|
|
28
|
+
PORT_ALREADY_EXPOSED: "PORT_ALREADY_EXPOSED",
|
|
29
|
+
PORT_IN_USE: "PORT_IN_USE",
|
|
30
|
+
PORT_NOT_EXPOSED: "PORT_NOT_EXPOSED",
|
|
31
|
+
INVALID_PORT_NUMBER: "INVALID_PORT_NUMBER",
|
|
32
|
+
INVALID_PORT: "INVALID_PORT",
|
|
33
|
+
SERVICE_NOT_RESPONDING: "SERVICE_NOT_RESPONDING",
|
|
34
|
+
PORT_OPERATION_ERROR: "PORT_OPERATION_ERROR",
|
|
35
|
+
CUSTOM_DOMAIN_REQUIRED: "CUSTOM_DOMAIN_REQUIRED",
|
|
36
|
+
GIT_REPOSITORY_NOT_FOUND: "GIT_REPOSITORY_NOT_FOUND",
|
|
37
|
+
GIT_BRANCH_NOT_FOUND: "GIT_BRANCH_NOT_FOUND",
|
|
38
|
+
GIT_AUTH_FAILED: "GIT_AUTH_FAILED",
|
|
39
|
+
GIT_NETWORK_ERROR: "GIT_NETWORK_ERROR",
|
|
40
|
+
INVALID_GIT_URL: "INVALID_GIT_URL",
|
|
41
|
+
GIT_CLONE_FAILED: "GIT_CLONE_FAILED",
|
|
42
|
+
GIT_CHECKOUT_FAILED: "GIT_CHECKOUT_FAILED",
|
|
43
|
+
GIT_OPERATION_FAILED: "GIT_OPERATION_FAILED",
|
|
44
|
+
BUCKET_MOUNT_ERROR: "BUCKET_MOUNT_ERROR",
|
|
45
|
+
S3FS_MOUNT_ERROR: "S3FS_MOUNT_ERROR",
|
|
46
|
+
MISSING_CREDENTIALS: "MISSING_CREDENTIALS",
|
|
47
|
+
INVALID_MOUNT_CONFIG: "INVALID_MOUNT_CONFIG",
|
|
48
|
+
INTERPRETER_NOT_READY: "INTERPRETER_NOT_READY",
|
|
49
|
+
CONTEXT_NOT_FOUND: "CONTEXT_NOT_FOUND",
|
|
50
|
+
CODE_EXECUTION_ERROR: "CODE_EXECUTION_ERROR",
|
|
51
|
+
PYTHON_NOT_AVAILABLE: "PYTHON_NOT_AVAILABLE",
|
|
52
|
+
JAVASCRIPT_NOT_AVAILABLE: "JAVASCRIPT_NOT_AVAILABLE",
|
|
53
|
+
OPENCODE_STARTUP_FAILED: "OPENCODE_STARTUP_FAILED",
|
|
54
|
+
PROCESS_READY_TIMEOUT: "PROCESS_READY_TIMEOUT",
|
|
55
|
+
PROCESS_EXITED_BEFORE_READY: "PROCESS_EXITED_BEFORE_READY",
|
|
56
|
+
VALIDATION_FAILED: "VALIDATION_FAILED",
|
|
57
|
+
INVALID_JSON_RESPONSE: "INVALID_JSON_RESPONSE",
|
|
58
|
+
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
59
|
+
INTERNAL_ERROR: "INTERNAL_ERROR"
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region ../shared/dist/errors/status-map.js
|
|
64
|
+
/**
|
|
65
|
+
* Maps error codes to HTTP status codes
|
|
66
|
+
* Centralized mapping ensures consistency across SDK
|
|
67
|
+
*/
|
|
68
|
+
const ERROR_STATUS_MAP = {
|
|
69
|
+
[ErrorCode.FILE_NOT_FOUND]: 404,
|
|
70
|
+
[ErrorCode.COMMAND_NOT_FOUND]: 404,
|
|
71
|
+
[ErrorCode.PROCESS_NOT_FOUND]: 404,
|
|
72
|
+
[ErrorCode.PORT_NOT_EXPOSED]: 404,
|
|
73
|
+
[ErrorCode.GIT_REPOSITORY_NOT_FOUND]: 404,
|
|
74
|
+
[ErrorCode.GIT_BRANCH_NOT_FOUND]: 404,
|
|
75
|
+
[ErrorCode.CONTEXT_NOT_FOUND]: 404,
|
|
76
|
+
[ErrorCode.IS_DIRECTORY]: 400,
|
|
77
|
+
[ErrorCode.NOT_DIRECTORY]: 400,
|
|
78
|
+
[ErrorCode.INVALID_COMMAND]: 400,
|
|
79
|
+
[ErrorCode.INVALID_PORT_NUMBER]: 400,
|
|
80
|
+
[ErrorCode.INVALID_PORT]: 400,
|
|
81
|
+
[ErrorCode.INVALID_GIT_URL]: 400,
|
|
82
|
+
[ErrorCode.CUSTOM_DOMAIN_REQUIRED]: 400,
|
|
83
|
+
[ErrorCode.INVALID_JSON_RESPONSE]: 400,
|
|
84
|
+
[ErrorCode.NAME_TOO_LONG]: 400,
|
|
85
|
+
[ErrorCode.VALIDATION_FAILED]: 400,
|
|
86
|
+
[ErrorCode.MISSING_CREDENTIALS]: 400,
|
|
87
|
+
[ErrorCode.INVALID_MOUNT_CONFIG]: 400,
|
|
88
|
+
[ErrorCode.GIT_AUTH_FAILED]: 401,
|
|
89
|
+
[ErrorCode.PERMISSION_DENIED]: 403,
|
|
90
|
+
[ErrorCode.COMMAND_PERMISSION_DENIED]: 403,
|
|
91
|
+
[ErrorCode.PROCESS_PERMISSION_DENIED]: 403,
|
|
92
|
+
[ErrorCode.READ_ONLY]: 403,
|
|
93
|
+
[ErrorCode.FILE_EXISTS]: 409,
|
|
94
|
+
[ErrorCode.PORT_ALREADY_EXPOSED]: 409,
|
|
95
|
+
[ErrorCode.PORT_IN_USE]: 409,
|
|
96
|
+
[ErrorCode.RESOURCE_BUSY]: 409,
|
|
97
|
+
[ErrorCode.SESSION_ALREADY_EXISTS]: 409,
|
|
98
|
+
[ErrorCode.SERVICE_NOT_RESPONDING]: 502,
|
|
99
|
+
[ErrorCode.GIT_NETWORK_ERROR]: 502,
|
|
100
|
+
[ErrorCode.PYTHON_NOT_AVAILABLE]: 501,
|
|
101
|
+
[ErrorCode.JAVASCRIPT_NOT_AVAILABLE]: 501,
|
|
102
|
+
[ErrorCode.INTERPRETER_NOT_READY]: 503,
|
|
103
|
+
[ErrorCode.OPENCODE_STARTUP_FAILED]: 503,
|
|
104
|
+
[ErrorCode.PROCESS_READY_TIMEOUT]: 408,
|
|
105
|
+
[ErrorCode.PROCESS_EXITED_BEFORE_READY]: 500,
|
|
106
|
+
[ErrorCode.NO_SPACE]: 500,
|
|
107
|
+
[ErrorCode.TOO_MANY_FILES]: 500,
|
|
108
|
+
[ErrorCode.TOO_MANY_LINKS]: 500,
|
|
109
|
+
[ErrorCode.FILESYSTEM_ERROR]: 500,
|
|
110
|
+
[ErrorCode.COMMAND_EXECUTION_ERROR]: 500,
|
|
111
|
+
[ErrorCode.STREAM_START_ERROR]: 500,
|
|
112
|
+
[ErrorCode.PROCESS_ERROR]: 500,
|
|
113
|
+
[ErrorCode.PORT_OPERATION_ERROR]: 500,
|
|
114
|
+
[ErrorCode.GIT_CLONE_FAILED]: 500,
|
|
115
|
+
[ErrorCode.GIT_CHECKOUT_FAILED]: 500,
|
|
116
|
+
[ErrorCode.GIT_OPERATION_FAILED]: 500,
|
|
117
|
+
[ErrorCode.CODE_EXECUTION_ERROR]: 500,
|
|
118
|
+
[ErrorCode.BUCKET_MOUNT_ERROR]: 500,
|
|
119
|
+
[ErrorCode.S3FS_MOUNT_ERROR]: 500,
|
|
120
|
+
[ErrorCode.UNKNOWN_ERROR]: 500,
|
|
121
|
+
[ErrorCode.INTERNAL_ERROR]: 500
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
export { ErrorCode as t };
|
|
126
|
+
//# sourceMappingURL=errors-BCXUmJUn.js.map
|