@cloudflare/sandbox 0.12.1 → 0.13.0-next.633.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/dist/bridge/index.js +3 -3
- package/dist/{contexts-B0_bcx9f.d.ts → contexts-DPFhc2nR.d.ts} +8 -2
- package/dist/contexts-DPFhc2nR.d.ts.map +1 -0
- package/dist/{dist-B_eXrP83.js → dist-mAH_7Ui7.js} +2 -122
- package/dist/dist-mAH_7Ui7.js.map +1 -0
- package/dist/{errors-aRUdk9K8.js → errors-CpoDEfUZ.js} +8 -1
- package/dist/errors-CpoDEfUZ.js.map +1 -0
- package/dist/index.d.ts +17 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/openai/index.d.ts +1 -1
- package/dist/openai/index.js +1 -1
- package/dist/opencode/index.d.ts +2 -2
- package/dist/opencode/index.js +2 -2
- package/dist/{sandbox-C8l-pMlL.d.ts → sandbox-44kEJjAc.d.ts} +46 -825
- package/dist/sandbox-44kEJjAc.d.ts.map +1 -0
- package/dist/{sandbox-DKG3H156.js → sandbox-C9CHzLDx.js} +1027 -2745
- package/dist/sandbox-C9CHzLDx.js.map +1 -0
- package/package.json +1 -1
- package/dist/contexts-B0_bcx9f.d.ts.map +0 -1
- package/dist/dist-B_eXrP83.js.map +0 -1
- package/dist/errors-aRUdk9K8.js.map +0 -1
- package/dist/sandbox-C8l-pMlL.d.ts.map +0 -1
- package/dist/sandbox-DKG3H156.js.map +0 -1
package/README.md
CHANGED
|
@@ -106,7 +106,7 @@ setup required — cloudflared opens a persistent QUIC connection to
|
|
|
106
106
|
Cloudflare's edge and Cloudflare hands back a hostname.
|
|
107
107
|
|
|
108
108
|
```ts
|
|
109
|
-
// Inside a Worker with
|
|
109
|
+
// Inside a Worker with a sandbox:
|
|
110
110
|
const tunnel = await sandbox.tunnels.get(8080);
|
|
111
111
|
console.log(tunnel.url);
|
|
112
112
|
// → https://random-words-here.trycloudflare.com
|
|
@@ -127,8 +127,6 @@ tunnel.
|
|
|
127
127
|
|
|
128
128
|
Notes:
|
|
129
129
|
|
|
130
|
-
- Requires the RPC transport. The route-based transport's `tunnels`
|
|
131
|
-
stub throws "RPC transport required".
|
|
132
130
|
- URLs do **not** survive a container restart. Cloudflare assigns the
|
|
133
131
|
hostname during cloudflared's startup handshake, so every restart
|
|
134
132
|
yields a new URL. The SDK clears its cache on container start, so
|
package/dist/bridge/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../dist-
|
|
2
|
-
import "../errors-
|
|
3
|
-
import { S as validateTunnelName, r as getSandbox, w as streamFile, x as validatePort, y as SandboxSecurityError } from "../sandbox-
|
|
1
|
+
import "../dist-mAH_7Ui7.js";
|
|
2
|
+
import "../errors-CpoDEfUZ.js";
|
|
3
|
+
import { S as validateTunnelName, r as getSandbox, w as streamFile, x as validatePort, y as SandboxSecurityError } from "../sandbox-C9CHzLDx.js";
|
|
4
4
|
import { DurableObject, env } from "cloudflare:workers";
|
|
5
5
|
import { Hono } from "hono";
|
|
6
6
|
|
|
@@ -69,6 +69,7 @@ declare const ErrorCode: {
|
|
|
69
69
|
readonly INVALID_JSON_RESPONSE: "INVALID_JSON_RESPONSE";
|
|
70
70
|
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
71
71
|
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
72
|
+
readonly CONTAINER_UNAVAILABLE: "CONTAINER_UNAVAILABLE";
|
|
72
73
|
readonly RPC_TRANSPORT_ERROR: "RPC_TRANSPORT_ERROR";
|
|
73
74
|
};
|
|
74
75
|
type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
@@ -198,6 +199,11 @@ interface OpencodeStartupContext {
|
|
|
198
199
|
stderr?: string;
|
|
199
200
|
command?: string;
|
|
200
201
|
}
|
|
202
|
+
type ContainerUnavailableReason = 'provisioning' | 'startup' | 'container_restarted';
|
|
203
|
+
interface ContainerUnavailableContext {
|
|
204
|
+
reason?: ContainerUnavailableReason;
|
|
205
|
+
sessionId?: string;
|
|
206
|
+
}
|
|
201
207
|
/**
|
|
202
208
|
* RPC transport error contexts. Surfaced when the capnweb WebSocket session
|
|
203
209
|
* fails on the SDK side rather than the container reporting a structured
|
|
@@ -228,5 +234,5 @@ interface RPCTransportContext {
|
|
|
228
234
|
closeReason?: string;
|
|
229
235
|
}
|
|
230
236
|
//#endregion
|
|
231
|
-
export {
|
|
232
|
-
//# sourceMappingURL=contexts-
|
|
237
|
+
export { ContainerUnavailableContext as a, ProcessExitedBeforeReadyContext as c, RPCTransportErrorKind as d, SessionTerminatedContext as f, ErrorCode as h, BackupRestoreContext as i, ProcessReadyTimeoutContext as l, OperationType as m, BackupExpiredContext as n, InvalidBackupConfigContext as o, ErrorResponse as p, BackupNotFoundContext as r, OpencodeStartupContext as s, BackupCreateContext as t, RPCTransportContext as u };
|
|
238
|
+
//# sourceMappingURL=contexts-DPFhc2nR.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts-DPFhc2nR.d.ts","names":["ErrorCode","ErrorCode","Operation","OperationType","ErrorResponse","TContext","Record","ServiceError","ServiceResult","T","OperationType","FileNotFoundContext","FileExistsContext","FileTooLargeContext","FileSystemContext","CommandNotFoundContext","CommandErrorContext","ProcessNotFoundContext","ProcessErrorContext","SessionAlreadyExistsContext","SessionDestroyedContext","SessionTerminatedContext","ProcessReadyTimeoutContext","ProcessExitedBeforeReadyContext","PortAlreadyExposedContext","PortNotExposedContext","InvalidPortContext","PortErrorContext","GitRepositoryNotFoundContext","GitAuthFailedContext","GitBranchNotFoundContext","GitErrorContext","InterpreterNotReadyContext","ContextNotFoundContext","CodeExecutionContext","ValidationFailedContext","Array","BucketMountContext","MissingCredentialsContext","InvalidMountConfigContext","BackupCreateContext","BackupRestoreContext","BackupNotFoundContext","BackupExpiredContext","InvalidBackupConfigContext","OpencodeStartupContext","InternalErrorContext","ContainerUnavailableReason","ContainerUnavailableContext","RPCTransportErrorKind","RPCTransportContext"],"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 FILE_TOO_LARGE: \"FILE_TOO_LARGE\";\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 SESSION_DESTROYED: \"SESSION_DESTROYED\";\n readonly SESSION_TERMINATED: \"SESSION_TERMINATED\";\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 BUCKET_UNMOUNT_ERROR: \"BUCKET_UNMOUNT_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 BACKUP_CREATE_FAILED: \"BACKUP_CREATE_FAILED\";\n readonly BACKUP_RESTORE_FAILED: \"BACKUP_RESTORE_FAILED\";\n readonly BACKUP_NOT_FOUND: \"BACKUP_NOT_FOUND\";\n readonly BACKUP_EXPIRED: \"BACKUP_EXPIRED\";\n readonly INVALID_BACKUP_CONFIG: \"INVALID_BACKUP_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 WATCH_NOT_FOUND: \"WATCH_NOT_FOUND\";\n readonly WATCH_START_ERROR: \"WATCH_START_ERROR\";\n readonly WATCH_STOP_ERROR: \"WATCH_STOP_ERROR\";\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 readonly CONTAINER_UNAVAILABLE: \"CONTAINER_UNAVAILABLE\";\n readonly RPC_TRANSPORT_ERROR: \"RPC_TRANSPORT_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 GIT_CLONE: \"git.clone\";\n readonly GIT_CHECKOUT: \"git.checkout\";\n readonly GIT_OPERATION: \"git.operation\";\n readonly BACKUP_CREATE: \"backup.create\";\n readonly BACKUP_RESTORE: \"backup.restore\";\n readonly BACKUP_UNMOUNT: \"backup.unmount\";\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 FileTooLargeContext {\n path: string;\n operation: OperationType;\n maxSize: number;\n actualSize: number;\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 * `CLOUDFLARE_PLACEMENT_ID` captured from the container at the moment the\n * duplicate create was detected. Included so a restarted DO can learn the\n * container's placement ID from an idempotent session-create. `null` when\n * the env var is not set (for example, in local development).\n */\n containerPlacementId?: string | null;\n}\nexport interface SessionDestroyedContext {\n sessionId: string;\n}\nexport interface SessionTerminatedContext {\n sessionId: string;\n exitCode: number | null;\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 * Backup error contexts\n */\nexport interface BackupCreateContext {\n dir: string;\n backupId?: string;\n stderr?: string;\n exitCode?: number;\n}\nexport interface BackupRestoreContext {\n dir: string;\n backupId: string;\n stderr?: string;\n exitCode?: number;\n}\nexport interface BackupNotFoundContext {\n backupId: string;\n}\nexport interface BackupExpiredContext {\n backupId: string;\n expiredAt?: string;\n}\nexport interface InvalidBackupConfigContext {\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}\nexport type ContainerUnavailableReason = 'provisioning' | 'startup' | 'container_restarted';\nexport interface ContainerUnavailableContext {\n reason?: ContainerUnavailableReason;\n sessionId?: string;\n}\n/**\n * RPC transport error contexts. Surfaced when the capnweb WebSocket session\n * fails on the SDK side rather than the container reporting a structured\n * error. Always retryable — the next call will open a fresh connection.\n */\nexport type RPCTransportErrorKind = \n/** Server closed the WebSocket (container crash, DO eviction, network blip). */\n'peer_closed'\n/** Underlying socket fired the `error` event. */\n | 'connection_failed'\n/** WebSocket upgrade failed before the session was established. */\n | 'upgrade_failed'\n/** Peer sent a non-string frame; capnweb's wire format is JSON text only. */\n | 'invalid_frame'\n/** Peer sent a frame the wire-format parser rejected (capnweb readLoop SyntaxError). */\n | 'protocol_error'\n/** Session was disposed (locally or remotely) while a call was pending. */\n | 'session_disposed'\n/** Anything else that bubbled up from the transport with no recognisable shape. */\n | 'unknown';\nexport interface RPCTransportContext {\n /** Categorical bucket so callers can branch on `peer_closed` vs `upgrade_failed` etc. */\n kind: RPCTransportErrorKind;\n /** Original error message, verbatim from capnweb / our DeferredTransport. */\n originalMessage: string;\n /**\n * The underlying Error's `name` property. capnweb preserves this across\n * the wire for the standard built-ins (TypeError, SyntaxError, etc.), so\n * it's a more reliable hint than the message string for those cases.\n */\n errorName: string;\n /** WebSocket close code, when available (kind === 'peer_closed'). */\n closeCode?: number;\n /** WebSocket close reason, when available (kind === 'peer_closed'). */\n closeReason?: string;\n}\n//# sourceMappingURL=contexts.d.ts.map"],"mappings":";;AAIA;AAqEA;;cArEqBA;;ECAAE,SAAAA,iBAyBpB,EAAA,mBAAA;EACWC,SAAAA,WAAa,EAAA,aAAWD;EAKnBE,SAAAA,YAAa,EAAAC,cAAA;EAAYC,SAAAA,aAAAA,EAAAA,eAAAA;EAIhCL,SAAAA,cAAAA,EAAAA,gBAAAA;EAQME,SAAAA,QAAAA,EAAAA,UAAAA;EAKHE,SAAAA,cAAAA,EAAAA,gBAAAA;EAAQ,SAAA,aAAA,EAAA,eAAA;;;;ECSJgB,SAAAA,gBAAAA,EAAwB,kBAAA;EAOxBC,SAAAA,iBAAAA,EAAAA,mBAA0B;EAM1BC,SAAAA,yBAA+B,EAAA,2BAAA;EA8F/BiB,SAAAA,eAAmB,EAAA,iBAAA;EAMnBC,SAAAA,uBAAoB,EAAA,yBAAA;EAMpBC,SAAAA,kBAAqB,EAAA,oBAAA;EAGrBC,SAAAA,iBAAoB,EAAA,mBAAA;EAIpBC,SAAAA,yBAA0B,EAAA,2BAAA;EAM1BC,SAAAA,aAAAA,EAAAA,eAAsB;EAa3BE,SAAAA,sBAA0B,EAAA,wBAAA;EACrBC,SAAAA,iBAAAA,EAAAA,mBACJD;EAQDE,SAAAA,kBAAqB,EAAA,oBAAA;EAehBC,SAAAA,oBAAmB,EAAA,sBAE1BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KF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 +151,6 @@ function truncateForLog(value, maxLen = 120) {
|
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region ../shared/dist/git.js
|
|
156
|
-
/**
|
|
157
|
-
* Fallback repository name used when URL parsing fails
|
|
158
|
-
*/
|
|
159
|
-
const FALLBACK_REPO_NAME = "repository";
|
|
160
|
-
/** Default wall-clock timeout in milliseconds for git clone operations. */
|
|
161
|
-
const DEFAULT_GIT_CLONE_TIMEOUT_MS = 6e5;
|
|
162
|
-
/**
|
|
163
|
-
* Extract repository name from a Git URL
|
|
164
|
-
*
|
|
165
|
-
* Supports multiple URL formats:
|
|
166
|
-
* - HTTPS: https://github.com/user/repo.git → repo
|
|
167
|
-
* - HTTPS without .git: https://github.com/user/repo → repo
|
|
168
|
-
* - SSH: git@github.com:user/repo.git → repo
|
|
169
|
-
* - GitLab/others: https://gitlab.com/org/project.git → project
|
|
170
|
-
*
|
|
171
|
-
* @param repoUrl - Git repository URL (HTTPS or SSH format)
|
|
172
|
-
* @returns Repository name extracted from URL, or 'repository' as fallback
|
|
173
|
-
*/
|
|
174
|
-
function extractRepoName(repoUrl) {
|
|
175
|
-
try {
|
|
176
|
-
const pathParts = new URL(repoUrl).pathname.split("/");
|
|
177
|
-
const lastPart = pathParts[pathParts.length - 1];
|
|
178
|
-
if (lastPart) return lastPart.replace(/\.git$/, "");
|
|
179
|
-
} catch {}
|
|
180
|
-
if (repoUrl.includes(":") || repoUrl.includes("/")) {
|
|
181
|
-
const segments = repoUrl.split(/[:/]/).filter(Boolean);
|
|
182
|
-
const lastSegment = segments[segments.length - 1];
|
|
183
|
-
if (lastSegment) return lastSegment.replace(/\.git$/, "");
|
|
184
|
-
}
|
|
185
|
-
return FALLBACK_REPO_NAME;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Sanitize data by redacting credentials from any strings
|
|
189
|
-
* Recursively processes objects and arrays to ensure credentials are never leaked
|
|
190
|
-
*/
|
|
191
|
-
function sanitizeGitData(data) {
|
|
192
|
-
if (typeof data === "string") return redactCommand(data);
|
|
193
|
-
if (data === null || data === void 0) return data;
|
|
194
|
-
if (Array.isArray(data)) return data.map((item) => sanitizeGitData(item));
|
|
195
|
-
if (typeof data === "object") {
|
|
196
|
-
const result = {};
|
|
197
|
-
for (const [key, value] of Object.entries(data)) result[key] = sanitizeGitData(value);
|
|
198
|
-
return result;
|
|
199
|
-
}
|
|
200
|
-
return data;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Logger wrapper that automatically sanitizes git credentials
|
|
204
|
-
*/
|
|
205
|
-
var GitLogger = class GitLogger {
|
|
206
|
-
baseLogger;
|
|
207
|
-
constructor(baseLogger) {
|
|
208
|
-
this.baseLogger = baseLogger;
|
|
209
|
-
}
|
|
210
|
-
sanitizeContext(context) {
|
|
211
|
-
return context ? sanitizeGitData(context) : context;
|
|
212
|
-
}
|
|
213
|
-
sanitizeError(error) {
|
|
214
|
-
if (!error) return error;
|
|
215
|
-
const sanitized = new Error(redactCommand(error.message));
|
|
216
|
-
sanitized.name = error.name;
|
|
217
|
-
if (error.stack) sanitized.stack = redactCommand(error.stack);
|
|
218
|
-
const sanitizedRecord = sanitized;
|
|
219
|
-
const errorRecord = error;
|
|
220
|
-
for (const key of Object.keys(error)) if (key !== "message" && key !== "stack" && key !== "name") sanitizedRecord[key] = sanitizeGitData(errorRecord[key]);
|
|
221
|
-
return sanitized;
|
|
222
|
-
}
|
|
223
|
-
debug(message, context) {
|
|
224
|
-
this.baseLogger.debug(message, this.sanitizeContext(context));
|
|
225
|
-
}
|
|
226
|
-
info(message, context) {
|
|
227
|
-
this.baseLogger.info(message, this.sanitizeContext(context));
|
|
228
|
-
}
|
|
229
|
-
warn(message, context) {
|
|
230
|
-
this.baseLogger.warn(message, this.sanitizeContext(context));
|
|
231
|
-
}
|
|
232
|
-
error(message, error, context) {
|
|
233
|
-
this.baseLogger.error(message, this.sanitizeError(error), this.sanitizeContext(context));
|
|
234
|
-
}
|
|
235
|
-
child(context) {
|
|
236
|
-
const sanitized = sanitizeGitData(context);
|
|
237
|
-
return new GitLogger(this.baseLogger.child(sanitized));
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
|
|
241
154
|
//#endregion
|
|
242
155
|
//#region ../shared/dist/interpreter-types.js
|
|
243
156
|
var Execution = class {
|
|
@@ -927,38 +840,5 @@ function isProcessStatus(value) {
|
|
|
927
840
|
}
|
|
928
841
|
|
|
929
842
|
//#endregion
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
* Type guard for WSResponse
|
|
933
|
-
*
|
|
934
|
-
* Note: Only validates the discriminator field (type === 'response').
|
|
935
|
-
*/
|
|
936
|
-
function isWSResponse(msg) {
|
|
937
|
-
return typeof msg === "object" && msg !== null && "type" in msg && msg.type === "response";
|
|
938
|
-
}
|
|
939
|
-
/**
|
|
940
|
-
* Type guard for WSStreamChunk
|
|
941
|
-
*
|
|
942
|
-
* Note: Only validates the discriminator field (type === 'stream').
|
|
943
|
-
*/
|
|
944
|
-
function isWSStreamChunk(msg) {
|
|
945
|
-
return typeof msg === "object" && msg !== null && "type" in msg && msg.type === "stream";
|
|
946
|
-
}
|
|
947
|
-
/**
|
|
948
|
-
* Type guard for WSError
|
|
949
|
-
*
|
|
950
|
-
* Note: Only validates the discriminator field (type === 'error').
|
|
951
|
-
*/
|
|
952
|
-
function isWSError(msg) {
|
|
953
|
-
return typeof msg === "object" && msg !== null && "type" in msg && msg.type === "error";
|
|
954
|
-
}
|
|
955
|
-
/**
|
|
956
|
-
* Generate a unique request ID
|
|
957
|
-
*/
|
|
958
|
-
function generateRequestId() {
|
|
959
|
-
return `ws_${Date.now()}_${Math.random().toString(36).substring(2, 10)}`;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
//#endregion
|
|
963
|
-
export { GitLogger as _, isExecResult as a, getEnvString as b, parseSSEFrames as c, createNoOpLogger as d, TraceContext as f, DEFAULT_GIT_CLONE_TIMEOUT_MS as g, ResultImpl as h, isWSStreamChunk as i, shellEscape as l, Execution as m, isWSError as n, isProcess as o, logCanonicalEvent as p, isWSResponse as r, isProcessStatus as s, generateRequestId as t, createLogger as u, extractRepoName as v, partitionEnvVars as x, filterEnvVars as y };
|
|
964
|
-
//# sourceMappingURL=dist-B_eXrP83.js.map
|
|
843
|
+
export { shellEscape as a, TraceContext as c, ResultImpl as d, filterEnvVars as f, parseSSEFrames as i, logCanonicalEvent as l, partitionEnvVars as m, isProcess as n, createLogger as o, getEnvString as p, isProcessStatus as r, createNoOpLogger as s, isExecResult as t, Execution as u };
|
|
844
|
+
//# sourceMappingURL=dist-mAH_7Ui7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-mAH_7Ui7.js","names":["parts","LogLevelEnum","LogLevelEnum"],"sources":["../../shared/dist/env.js","../../shared/dist/logger/sanitize.js","../../shared/dist/interpreter-types.js","../../shared/dist/logger/canonical.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/sse.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 * Filter environment variables object to only include string values.\n * Skips undefined, null, and non-string values.\n *\n * Use this when you only need the defined values (e.g., for per-command env\n * where undefined means \"don't override\").\n *\n * @param envVars - Object that may contain undefined values\n * @returns Clean object with only string values\n */\nexport function filterEnvVars(envVars) {\n const filtered = {};\n for (const [key, value] of Object.entries(envVars)) {\n if (value != null && typeof value === 'string') {\n filtered[key] = value;\n }\n }\n return filtered;\n}\n/**\n * Partition environment variables into values to set and keys to unset.\n *\n * - String values → toSet (will be exported)\n * - undefined/null → toUnset (will be unset)\n *\n * This enables idiomatic JS patterns where undefined means \"remove\":\n * ```typescript\n * await sandbox.setEnvVars({\n * API_KEY: 'new-key', // will be set\n * OLD_VAR: undefined, // will be unset\n * });\n * ```\n */\nexport function partitionEnvVars(envVars) {\n const toSet = {};\n const toUnset = [];\n for (const [key, value] of Object.entries(envVars)) {\n if (value != null && typeof value === 'string') {\n toSet[key] = value;\n }\n else {\n toUnset.push(key);\n }\n }\n return { toSet, toUnset };\n}\n","/**\n * Log-only sanitization helpers\n *\n * These functions redact sensitive values for logging output.\n * They MUST NOT be used to mutate command strings before execution.\n */\n/**\n * Sensitive query parameter names to redact from URLs.\n * Anchored to query string context ([?&]) to avoid matching path segments.\n * Value matching stops at & and common URL/command delimiters.\n */\nconst SENSITIVE_PARAMS = /([?&])(X-Amz-Credential|X-Amz-Signature|X-Amz-Security-Token|token|secret|password)=[^&\\s\"'`<>]*/gi;\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.\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 * Redact sensitive query parameters from URLs\n *\n * Strips X-Amz-Credential, X-Amz-Signature, X-Amz-Security-Token,\n * token, secret, and password query params from URLs. Returns\n * non-URL strings unchanged.\n *\n * @param input - String that may contain URLs with sensitive params\n * @returns String with sensitive params replaced by REDACTED\n */\nexport function redactSensitiveParams(input) {\n if (!input.includes('?') || !input.includes('='))\n return input;\n return input.replace(SENSITIVE_PARAMS, '$1$2=REDACTED');\n}\n/**\n * Redact sensitive data from a command string for logging\n *\n * Composes redactCredentials (URL credentials) and redactSensitiveParams\n * (presigned URL query params). For log values only — never mutate\n * command strings before execution.\n *\n * @param command - Command string to sanitize for logging\n * @returns Sanitized command string\n */\nexport function redactCommand(command) {\n return redactSensitiveParams(redactCredentials(command));\n}\n/**\n * Truncate a string for log output with a truncation indicator\n *\n * @param value - String to potentially truncate\n * @param maxLen - Maximum length before truncation (default 120)\n * @returns Object with truncated value and boolean flag\n */\nexport function truncateForLog(value, maxLen = 120) {\n if (value.length <= maxLen) {\n return { value, truncated: false };\n }\n const cutoff = Math.max(0, maxLen - 3);\n return { value: `${value.substring(0, cutoff)}...`, truncated: true };\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 text;\n html;\n png;\n jpeg;\n svg;\n latex;\n markdown;\n javascript;\n json;\n chart;\n data;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- raw SSE data has dynamic shape\n constructor(raw) {\n this.text = raw.text || raw.data?.['text/plain'];\n this.html = raw.html || raw.data?.['text/html'];\n this.png = raw.png || raw.data?.['image/png'];\n this.jpeg = raw.jpeg || raw.data?.['image/jpeg'];\n this.svg = raw.svg || raw.data?.['image/svg+xml'];\n this.latex = raw.latex || raw.data?.['text/latex'];\n this.markdown = raw.markdown || raw.data?.['text/markdown'];\n this.javascript = raw.javascript || raw.data?.['application/javascript'];\n this.json = raw.json || raw.data?.['application/json'];\n this.chart = raw.chart;\n this.data = raw.data;\n }\n formats() {\n const fmts = [];\n if (this.text)\n fmts.push('text');\n if (this.html)\n fmts.push('html');\n if (this.png)\n fmts.push('png');\n if (this.jpeg)\n fmts.push('jpeg');\n if (this.svg)\n fmts.push('svg');\n if (this.latex)\n fmts.push('latex');\n if (this.markdown)\n fmts.push('markdown');\n if (this.javascript)\n fmts.push('javascript');\n if (this.json)\n fmts.push('json');\n if (this.chart)\n fmts.push('chart');\n return fmts;\n }\n}\n","import { redactCommand, truncateForLog } from './sanitize.js';\n/** Events that are low-value at info on success */\nconst DEBUG_ON_SUCCESS = new Set([\n 'session.create',\n 'session.destroy',\n 'file.read',\n 'file.write',\n 'file.delete',\n 'file.mkdir'\n]);\nexport function resolveLogLevel(payload, options) {\n if (payload.outcome === 'error')\n return 'error';\n if (options?.successLevel)\n return options.successLevel;\n if (payload.origin === 'internal')\n return 'debug';\n if (DEBUG_ON_SUCCESS.has(payload.event))\n return 'debug';\n return 'info';\n}\n/**\n * Sanitize an Error object by redacting sensitive data from message and stack.\n * Produces a copy so the caller's original Error is not mutated.\n */\nfunction sanitizeError(error) {\n if (!error)\n return undefined;\n const sanitized = new Error(redactCommand(error.message));\n sanitized.name = error.name;\n sanitized.stack = error.stack ? redactCommand(error.stack) : undefined;\n return sanitized;\n}\n/**\n * Sanitize and prepare payload fields for both message building and context emission.\n * Called once by logCanonicalEvent to avoid double-redaction.\n */\nfunction sanitizePayload(payload) {\n if (payload.command === undefined) {\n return { commandTruncated: false };\n }\n const redacted = redactCommand(payload.command);\n const { value, truncated } = truncateForLog(redacted);\n return { sanitizedCommand: value, commandTruncated: truncated };\n}\n/**\n * Build a human-readable canonical event message for dashboards and log viewers.\n *\n * Format: `{event} {outcome} {key_context} [— {reason}] ({durationMs}ms[, {sizeBytes}B])`\n *\n * The if/else chain for key context has implicit priority: command > path >\n * sessionId > port > repoUrl > pid. If a payload has multiple, only the\n * highest-priority one appears in the message. All fields are still present\n * as discrete queryable keys in the structured log context.\n */\nexport function buildMessage(payload, sanitizedCommand) {\n const { event } = payload;\n // version.check has its own format: no outcome, no duration\n if (event === 'version.check') {\n const parts = ['version.check'];\n if (payload.sdkVersion)\n parts.push(`sdk=${payload.sdkVersion}`);\n if (payload.containerVersion)\n parts.push(`container=${payload.containerVersion}`);\n if (payload.versionOutcome && payload.versionOutcome !== 'compatible') {\n parts.push(`(${payload.versionOutcome})`);\n }\n return parts.join(' ');\n }\n const parts = [event, payload.outcome];\n // Key context — highest priority field shown in message\n if (sanitizedCommand !== undefined) {\n parts.push(sanitizedCommand);\n }\n else if (payload.command !== undefined) {\n // Fallback for direct buildMessage calls without pre-sanitized command\n const redacted = redactCommand(payload.command);\n const { value } = truncateForLog(redacted);\n parts.push(value);\n }\n else if (payload.path !== undefined) {\n parts.push(payload.path);\n }\n else if (event.includes('session') && payload.sessionId !== undefined) {\n parts.push(payload.sessionId);\n }\n else if (payload.port !== undefined) {\n parts.push(String(payload.port));\n }\n else if (payload.repoUrl !== undefined) {\n let gitContext = payload.repoUrl;\n if (payload.branch !== undefined) {\n gitContext += ` ${payload.branch}`;\n }\n parts.push(gitContext);\n }\n else if (payload.pid !== undefined) {\n parts.push(String(payload.pid));\n }\n else if (payload.backupId !== undefined) {\n parts.push(payload.backupId);\n }\n else if (payload.repoPath !== undefined) {\n let gitContext = payload.repoPath;\n if (payload.branch !== undefined) {\n gitContext += ` branch=${payload.branch}`;\n }\n parts.push(gitContext);\n }\n else if (payload.mountsProcessed !== undefined) {\n let destroyContext = `${payload.mountsProcessed} mounts`;\n if (payload.mountFailures)\n destroyContext += `, ${payload.mountFailures} failed`;\n parts.push(destroyContext);\n }\n else if (payload.mountPath !== undefined) {\n parts.push(payload.mountPath);\n }\n // Error reason after em-dash\n if (payload.outcome === 'error') {\n if (payload.errorMessage !== undefined) {\n parts.push(`\\u2014 ${payload.errorMessage}`);\n }\n else if (payload.exitCode !== undefined) {\n parts.push(`\\u2014 exitCode=${payload.exitCode}`);\n }\n }\n // Duration suffix (and optional size)\n const durationSuffix = payload.sizeBytes !== undefined\n ? `(${payload.durationMs}ms, ${payload.sizeBytes}B)`\n : `(${payload.durationMs}ms)`;\n parts.push(durationSuffix);\n return parts.join(' ');\n}\n/**\n * Log a canonical event — the single entry point for all structured operational events.\n *\n * Sanitizes command fields once, builds the message, selects log level from\n * outcome, and emits a structured log entry with the full payload as context.\n */\nexport function logCanonicalEvent(logger, payload, options) {\n // Auto-derive errorMessage from error.message when not explicitly set,\n // then sanitize to prevent credential leaks (e.g., presigned URLs in error strings)\n const resolvedErrorMessage = payload.errorMessage ?? payload.error?.message;\n const sanitizedErrorMessage = resolvedErrorMessage\n ? redactCommand(resolvedErrorMessage)\n : undefined;\n const enrichedPayload = sanitizedErrorMessage !== undefined\n ? { ...payload, errorMessage: sanitizedErrorMessage }\n : payload;\n // Sanitize once, use for both message and context\n const { sanitizedCommand, commandTruncated } = sanitizePayload(enrichedPayload);\n const message = buildMessage(enrichedPayload, sanitizedCommand);\n // Build context from enriched payload, excluding the error object (passed separately)\n const context = {};\n for (const [key, value] of Object.entries(enrichedPayload)) {\n if (key === 'error')\n continue;\n context[key] = value;\n }\n // Apply sanitized command to context\n if (sanitizedCommand !== undefined) {\n context.command = sanitizedCommand;\n if (commandTruncated) {\n context.commandTruncated = true;\n }\n }\n const level = resolveLogLevel(enrichedPayload, options);\n if (level === 'error') {\n logger.error(message, sanitizeError(payload.error), context);\n }\n else if (level === 'warn') {\n logger.warn(message, context);\n }\n else if (level === 'debug') {\n logger.debug(message, context);\n }\n else {\n logger.info(message, context);\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 outputMode;\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 outputMode How log entries are formatted and emitted (default: 'structured')\n */\n constructor(baseContext, minLevel = LogLevelEnum.INFO, outputMode = 'structured') {\n this.baseContext = baseContext;\n this.minLevel = minLevel;\n this.outputMode = outputMode;\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.outputMode);\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 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 using the configured output mode\n */\n output(consoleFn, data) {\n switch (this.outputMode) {\n case 'pretty':\n this.outputPretty(consoleFn, data);\n break;\n case 'json-line':\n this.outputJsonLine(consoleFn, data);\n break;\n case 'structured':\n this.outputStructured(consoleFn, data);\n break;\n }\n }\n /**\n * Output as JSON string (container stdout — parsed by Containers pipeline)\n */\n outputJsonLine(consoleFn, data) {\n consoleFn(JSON.stringify(data));\n }\n /**\n * Output as raw object (Workers/DOs — Workers Logs auto-indexes fields)\n */\n outputStructured(consoleFn, data) {\n consoleFn(data);\n }\n /**\n * Output as pretty-printed, colored text (development)\n *\n * Each log event is a single consoleFn() call so it appears as one entry\n * in the Cloudflare dashboard. Context is rendered inline as compact key=value pairs.\n *\n * Format: LEVEL [component] message trace=tr_... key=value key=value\n */\n outputPretty(consoleFn, data) {\n const { level, message: msg, timestamp, traceId, component, sandboxId, sessionId, processId, commandId, durationMs, serviceVersion, instanceId, error, ...rest } = data;\n const levelStr = String(level || 'INFO').toUpperCase();\n const levelColor = this.getLevelColor(levelStr);\n const componentBadge = component ? `[${component}]` : '';\n const timeStr = timestamp\n ? `${COLORS.dim}${new Date(timestamp).toISOString().substring(11, 23)}${COLORS.reset} `\n : '';\n let logLine = `${timeStr}${levelColor}${levelStr.padEnd(5)}${COLORS.reset} ${componentBadge} ${msg}`;\n // Append all context as compact key=value pairs on the same line\n const pairs = [];\n if (traceId)\n pairs.push(`trace=${String(traceId).substring(0, 12)}`);\n if (commandId)\n pairs.push(`cmd=${String(commandId).substring(0, 12)}`);\n if (sandboxId)\n pairs.push(`sandbox=${sandboxId}`);\n if (sessionId)\n pairs.push(`session=${String(sessionId).substring(0, 12)}`);\n if (processId)\n pairs.push(`proc=${processId}`);\n if (durationMs !== undefined)\n pairs.push(`dur=${durationMs}ms`);\n // Append remaining context fields inline\n for (const [key, value] of Object.entries(rest)) {\n if (value === undefined || value === null)\n continue;\n const v = typeof value === 'object'\n ? JSON.stringify(value)\n : this.sanitizePrettyValue(String(value));\n pairs.push(`${key}=${v}`);\n }\n // Append error info inline\n if (error && typeof error === 'object') {\n const errorObj = error;\n if (errorObj.name)\n pairs.push(`err.name=${this.sanitizePrettyValue(errorObj.name)}`);\n if (errorObj.message)\n pairs.push(`err.msg=${this.sanitizePrettyValue(errorObj.message)}`);\n if (errorObj.stack)\n pairs.push(`err.stack=${this.sanitizePrettyValue(errorObj.stack)}`);\n }\n if (pairs.length > 0) {\n logLine += ` ${COLORS.dim}${pairs.join(' ')}${COLORS.reset}`;\n }\n // Single consoleFn call = single log entry in the dashboard\n consoleFn(logLine);\n }\n /**\n * Collapse newlines so a single consoleFn() call stays on one line.\n * Cloudflare's log pipeline splits on literal newlines, which fragments\n * stack traces and multi-line error messages into separate entries.\n */\n sanitizePrettyValue(value) {\n return value.replace(/\\r/g, '\\\\r').replace(/\\n/g, '\\\\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 * - Three output modes: structured (Workers/DOs), json-line (container), pretty (local dev)\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({ 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 { buildMessage, logCanonicalEvent, resolveLogLevel } from './canonical.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 outputMode = getOutputMode(context.component);\n const baseContext = {\n ...context,\n traceId: context.traceId || TraceContext.generate(),\n component: context.component,\n serviceVersion: context.serviceVersion || getEnvVar('SANDBOX_VERSION') || undefined,\n instanceId: context.instanceId ||\n getEnvVar('HOSTNAME') ||\n getEnvVar('SANDBOX_INSTANCE_ID') ||\n undefined\n };\n return new CloudflareLogger(baseContext, minLevel, outputMode);\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 * Determine output mode based on component and environment:\n * - SANDBOX_LOG_FORMAT=pretty → 'pretty' for all components (local wrangler dev)\n * - Container/Executor without pretty → 'json-line' (Bun stdout → Containers pipeline)\n * - Everything else without pretty → 'structured' (Workers/DOs → Workers Logs)\n *\n * In local dev, setting SANDBOX_LOG_FORMAT=pretty gives readable terminal\n * output on both the DO side and container side. In production (where the\n * var isn't set), DOs emit structured objects and containers emit single-line\n * JSON — both queryable by their respective observability pipelines.\n */\nfunction getOutputMode(component) {\n const format = getEnvVar('SANDBOX_LOG_FORMAT');\n if (format?.toLowerCase() === 'pretty') {\n return 'pretty';\n }\n if (component === 'container' || component === 'executor') {\n return 'json-line';\n }\n return 'structured';\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 * Shared SSE parsing utilities.\n *\n * Parses SSE frames from arbitrary text chunks while preserving partial state\n * across chunk boundaries.\n */\n/**\n * Parse SSE frames from a buffer.\n *\n * Returns parsed events, remaining unparsed text, and the current partial event\n * so callers can continue parsing on the next chunk.\n */\nexport function parseSSEFrames(buffer, currentEvent = { data: [] }) {\n const events = [];\n let i = 0;\n while (i < buffer.length) {\n const newlineIndex = buffer.indexOf('\\n', i);\n if (newlineIndex === -1)\n break;\n const rawLine = buffer.substring(i, newlineIndex);\n const line = rawLine.endsWith('\\r') ? rawLine.slice(0, -1) : rawLine;\n i = newlineIndex + 1;\n if (line === '' && currentEvent.data.length > 0) {\n events.push({\n event: currentEvent.event,\n data: currentEvent.data.join('\\n')\n });\n currentEvent = { data: [] };\n continue;\n }\n if (line.startsWith('event:')) {\n const value = line.startsWith('event: ')\n ? line.substring(7)\n : line.substring(6);\n currentEvent.event = value;\n continue;\n }\n if (line.startsWith('data:')) {\n const value = line.startsWith('data: ')\n ? line.substring(6)\n : line.substring(5);\n currentEvent.data.push(value);\n }\n }\n return {\n events,\n remaining: buffer.substring(i),\n currentEvent\n };\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;;;;;;;;;;;;AAY/C,SAAgB,c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MAAM;;;AAGrC,QAAO;EACH;EACA,WAAW,OAAO,UAAU,EAAE;EAC9B;EACH;;;;;ACtCL,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"}
|
|
@@ -69,6 +69,7 @@ const ErrorCode = {
|
|
|
69
69
|
INVALID_JSON_RESPONSE: "INVALID_JSON_RESPONSE",
|
|
70
70
|
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
71
71
|
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
72
|
+
CONTAINER_UNAVAILABLE: "CONTAINER_UNAVAILABLE",
|
|
72
73
|
RPC_TRANSPORT_ERROR: "RPC_TRANSPORT_ERROR"
|
|
73
74
|
};
|
|
74
75
|
|
|
@@ -123,6 +124,7 @@ const ERROR_STATUS_MAP = {
|
|
|
123
124
|
[ErrorCode.JAVASCRIPT_NOT_AVAILABLE]: 501,
|
|
124
125
|
[ErrorCode.INTERPRETER_NOT_READY]: 503,
|
|
125
126
|
[ErrorCode.OPENCODE_STARTUP_FAILED]: 503,
|
|
127
|
+
[ErrorCode.CONTAINER_UNAVAILABLE]: 503,
|
|
126
128
|
[ErrorCode.RPC_TRANSPORT_ERROR]: 503,
|
|
127
129
|
[ErrorCode.PROCESS_READY_TIMEOUT]: 408,
|
|
128
130
|
[ErrorCode.PROCESS_EXITED_BEFORE_READY]: 500,
|
|
@@ -191,6 +193,11 @@ function getSuggestion(code, context) {
|
|
|
191
193
|
case ErrorCode.INVALID_BACKUP_CONFIG: return `Invalid backup configuration: ${context.reason}`;
|
|
192
194
|
case ErrorCode.BACKUP_CREATE_FAILED: return "Backup creation failed. Check that the directory exists and you have sufficient disk space";
|
|
193
195
|
case ErrorCode.BACKUP_RESTORE_FAILED: return "Backup restoration failed. The archive may be corrupted or the target directory may be in use";
|
|
196
|
+
case ErrorCode.CONTAINER_UNAVAILABLE: switch (context.reason) {
|
|
197
|
+
case "provisioning": return "The container is still being provisioned. Retry the operation in a moment.";
|
|
198
|
+
case "container_restarted": return "The container restarted while the SDK was preparing the default session. Retry the operation to use the new container.";
|
|
199
|
+
default: return "The container is not ready yet. Retry the operation in a moment.";
|
|
200
|
+
}
|
|
194
201
|
case ErrorCode.RPC_TRANSPORT_ERROR: switch (context.kind) {
|
|
195
202
|
case "peer_closed": return "The container closed the WebSocket mid-call (likely a container restart, eviction, or crash). Retry the call — the SDK will open a fresh connection.";
|
|
196
203
|
case "connection_failed": return "The WebSocket connection failed. Retry the call; if the failure persists, check container health and network connectivity.";
|
|
@@ -206,4 +213,4 @@ function getSuggestion(code, context) {
|
|
|
206
213
|
|
|
207
214
|
//#endregion
|
|
208
215
|
export { getHttpStatus as n, ErrorCode as r, getSuggestion as t };
|
|
209
|
-
//# sourceMappingURL=errors-
|
|
216
|
+
//# sourceMappingURL=errors-CpoDEfUZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-CpoDEfUZ.js","names":[],"sources":["../../shared/dist/errors/codes.js","../../shared/dist/errors/status-map.js","../../shared/dist/errors/suggestions.js"],"sourcesContent":["/**\n * Centralized error code registry\n * Each code maps to a specific error type with consistent semantics\n */\nexport const ErrorCode = {\n // File System Errors (404)\n FILE_NOT_FOUND: 'FILE_NOT_FOUND',\n // Permission Errors (403)\n PERMISSION_DENIED: 'PERMISSION_DENIED',\n // File System Errors (409)\n FILE_EXISTS: 'FILE_EXISTS',\n // File System Errors (400)\n IS_DIRECTORY: 'IS_DIRECTORY',\n NOT_DIRECTORY: 'NOT_DIRECTORY',\n // File Too Large Errors (413)\n FILE_TOO_LARGE: 'FILE_TOO_LARGE',\n // File System Errors (500)\n NO_SPACE: 'NO_SPACE',\n TOO_MANY_FILES: 'TOO_MANY_FILES',\n RESOURCE_BUSY: 'RESOURCE_BUSY',\n READ_ONLY: 'READ_ONLY',\n NAME_TOO_LONG: 'NAME_TOO_LONG',\n TOO_MANY_LINKS: 'TOO_MANY_LINKS',\n FILESYSTEM_ERROR: 'FILESYSTEM_ERROR',\n // Command Errors (404)\n COMMAND_NOT_FOUND: 'COMMAND_NOT_FOUND',\n // Command Errors (403/400)\n COMMAND_PERMISSION_DENIED: 'COMMAND_PERMISSION_DENIED',\n INVALID_COMMAND: 'INVALID_COMMAND',\n // Command Errors (500)\n COMMAND_EXECUTION_ERROR: 'COMMAND_EXECUTION_ERROR',\n STREAM_START_ERROR: 'STREAM_START_ERROR',\n // Process Errors (404)\n PROCESS_NOT_FOUND: 'PROCESS_NOT_FOUND',\n // Process Errors (403/500)\n PROCESS_PERMISSION_DENIED: 'PROCESS_PERMISSION_DENIED',\n PROCESS_ERROR: 'PROCESS_ERROR',\n // Session Errors (409)\n SESSION_ALREADY_EXISTS: 'SESSION_ALREADY_EXISTS',\n // Session Errors (410)\n SESSION_DESTROYED: 'SESSION_DESTROYED',\n SESSION_TERMINATED: 'SESSION_TERMINATED',\n // Port Errors (409)\n PORT_ALREADY_EXPOSED: 'PORT_ALREADY_EXPOSED',\n PORT_IN_USE: 'PORT_IN_USE',\n // Port Errors (404)\n PORT_NOT_EXPOSED: 'PORT_NOT_EXPOSED',\n // Port Errors (400)\n INVALID_PORT_NUMBER: 'INVALID_PORT_NUMBER',\n INVALID_PORT: 'INVALID_PORT',\n // Port Errors (502/500)\n SERVICE_NOT_RESPONDING: 'SERVICE_NOT_RESPONDING',\n PORT_OPERATION_ERROR: 'PORT_OPERATION_ERROR',\n // Port Errors (400)\n CUSTOM_DOMAIN_REQUIRED: 'CUSTOM_DOMAIN_REQUIRED',\n // Git Errors (404)\n GIT_REPOSITORY_NOT_FOUND: 'GIT_REPOSITORY_NOT_FOUND',\n GIT_BRANCH_NOT_FOUND: 'GIT_BRANCH_NOT_FOUND',\n // Git Errors (401)\n GIT_AUTH_FAILED: 'GIT_AUTH_FAILED',\n // Git Errors (502)\n GIT_NETWORK_ERROR: 'GIT_NETWORK_ERROR',\n // Git Errors (400)\n INVALID_GIT_URL: 'INVALID_GIT_URL',\n // Git Errors (500)\n GIT_CLONE_FAILED: 'GIT_CLONE_FAILED',\n GIT_CHECKOUT_FAILED: 'GIT_CHECKOUT_FAILED',\n GIT_OPERATION_FAILED: 'GIT_OPERATION_FAILED',\n // Bucket mounting errors\n BUCKET_MOUNT_ERROR: 'BUCKET_MOUNT_ERROR',\n BUCKET_UNMOUNT_ERROR: 'BUCKET_UNMOUNT_ERROR',\n S3FS_MOUNT_ERROR: 'S3FS_MOUNT_ERROR',\n MISSING_CREDENTIALS: 'MISSING_CREDENTIALS',\n INVALID_MOUNT_CONFIG: 'INVALID_MOUNT_CONFIG',\n // Backup Errors (500)\n BACKUP_CREATE_FAILED: 'BACKUP_CREATE_FAILED',\n BACKUP_RESTORE_FAILED: 'BACKUP_RESTORE_FAILED',\n // Backup Errors (404)\n BACKUP_NOT_FOUND: 'BACKUP_NOT_FOUND',\n // Backup Errors (400)\n BACKUP_EXPIRED: 'BACKUP_EXPIRED',\n INVALID_BACKUP_CONFIG: 'INVALID_BACKUP_CONFIG',\n // Code Interpreter Errors (503)\n INTERPRETER_NOT_READY: 'INTERPRETER_NOT_READY',\n // Code Interpreter Errors (404)\n CONTEXT_NOT_FOUND: 'CONTEXT_NOT_FOUND',\n // Code Interpreter Errors (500)\n CODE_EXECUTION_ERROR: 'CODE_EXECUTION_ERROR',\n // Code Interpreter Errors (501) - Feature not available in image variant\n PYTHON_NOT_AVAILABLE: 'PYTHON_NOT_AVAILABLE',\n JAVASCRIPT_NOT_AVAILABLE: 'JAVASCRIPT_NOT_AVAILABLE',\n // OpenCode Errors (503)\n OPENCODE_STARTUP_FAILED: 'OPENCODE_STARTUP_FAILED',\n // Process Readiness Errors (408/500)\n PROCESS_READY_TIMEOUT: 'PROCESS_READY_TIMEOUT',\n PROCESS_EXITED_BEFORE_READY: 'PROCESS_EXITED_BEFORE_READY',\n // File Watch Errors (404)\n WATCH_NOT_FOUND: 'WATCH_NOT_FOUND',\n // File Watch Errors (500)\n WATCH_START_ERROR: 'WATCH_START_ERROR',\n WATCH_STOP_ERROR: 'WATCH_STOP_ERROR',\n // Validation Errors (400)\n VALIDATION_FAILED: 'VALIDATION_FAILED',\n // Generic Errors (400/500)\n INVALID_JSON_RESPONSE: 'INVALID_JSON_RESPONSE',\n UNKNOWN_ERROR: 'UNKNOWN_ERROR',\n INTERNAL_ERROR: 'INTERNAL_ERROR',\n // Container Availability Errors (503)\n CONTAINER_UNAVAILABLE: 'CONTAINER_UNAVAILABLE',\n // RPC Transport Errors (503) — capnweb WebSocket session-level failures\n // raised on the SDK side, not by the container. The container went away\n // mid-call (peer close), the WebSocket failed before/after upgrade, the\n // peer sent a frame the transport cannot handle, or the session was\n // disposed while a call was in flight.\n RPC_TRANSPORT_ERROR: 'RPC_TRANSPORT_ERROR'\n};\n","import { ErrorCode } from './codes';\n/**\n * Maps error codes to HTTP status codes\n * Centralized mapping ensures consistency across SDK\n */\nexport const ERROR_STATUS_MAP = {\n // 404 Not Found\n [ErrorCode.FILE_NOT_FOUND]: 404,\n [ErrorCode.COMMAND_NOT_FOUND]: 404,\n [ErrorCode.PROCESS_NOT_FOUND]: 404,\n [ErrorCode.PORT_NOT_EXPOSED]: 404,\n [ErrorCode.GIT_REPOSITORY_NOT_FOUND]: 404,\n [ErrorCode.GIT_BRANCH_NOT_FOUND]: 404,\n [ErrorCode.CONTEXT_NOT_FOUND]: 404,\n [ErrorCode.WATCH_NOT_FOUND]: 404,\n // 400 Bad Request\n [ErrorCode.IS_DIRECTORY]: 400,\n [ErrorCode.NOT_DIRECTORY]: 400,\n [ErrorCode.INVALID_COMMAND]: 400,\n [ErrorCode.INVALID_PORT_NUMBER]: 400,\n [ErrorCode.INVALID_PORT]: 400,\n [ErrorCode.INVALID_GIT_URL]: 400,\n [ErrorCode.CUSTOM_DOMAIN_REQUIRED]: 400,\n [ErrorCode.INVALID_JSON_RESPONSE]: 400,\n [ErrorCode.NAME_TOO_LONG]: 400,\n [ErrorCode.VALIDATION_FAILED]: 400,\n [ErrorCode.MISSING_CREDENTIALS]: 400,\n [ErrorCode.INVALID_MOUNT_CONFIG]: 400,\n // 401 Unauthorized\n [ErrorCode.GIT_AUTH_FAILED]: 401,\n // 403 Forbidden\n [ErrorCode.PERMISSION_DENIED]: 403,\n [ErrorCode.COMMAND_PERMISSION_DENIED]: 403,\n [ErrorCode.PROCESS_PERMISSION_DENIED]: 403,\n [ErrorCode.READ_ONLY]: 403,\n // 409 Conflict\n [ErrorCode.FILE_EXISTS]: 409,\n [ErrorCode.PORT_ALREADY_EXPOSED]: 409,\n [ErrorCode.PORT_IN_USE]: 409,\n [ErrorCode.RESOURCE_BUSY]: 409,\n [ErrorCode.SESSION_ALREADY_EXISTS]: 409,\n // 410 Gone\n [ErrorCode.SESSION_DESTROYED]: 410,\n [ErrorCode.SESSION_TERMINATED]: 410,\n // 413 Content Too Large\n [ErrorCode.FILE_TOO_LARGE]: 413,\n // 502 Bad Gateway\n [ErrorCode.SERVICE_NOT_RESPONDING]: 502,\n [ErrorCode.GIT_NETWORK_ERROR]: 502,\n // Backup errors\n [ErrorCode.BACKUP_NOT_FOUND]: 404,\n [ErrorCode.BACKUP_EXPIRED]: 400,\n [ErrorCode.INVALID_BACKUP_CONFIG]: 400,\n [ErrorCode.BACKUP_CREATE_FAILED]: 500,\n [ErrorCode.BACKUP_RESTORE_FAILED]: 500,\n // 501 Not Implemented (feature not available in image variant)\n [ErrorCode.PYTHON_NOT_AVAILABLE]: 501,\n [ErrorCode.JAVASCRIPT_NOT_AVAILABLE]: 501,\n // 503 Service Unavailable\n [ErrorCode.INTERPRETER_NOT_READY]: 503,\n [ErrorCode.OPENCODE_STARTUP_FAILED]: 503,\n [ErrorCode.CONTAINER_UNAVAILABLE]: 503,\n [ErrorCode.RPC_TRANSPORT_ERROR]: 503,\n // 408 Request Timeout\n [ErrorCode.PROCESS_READY_TIMEOUT]: 408,\n // 500 Internal Server Error\n [ErrorCode.PROCESS_EXITED_BEFORE_READY]: 500,\n [ErrorCode.NO_SPACE]: 500,\n [ErrorCode.TOO_MANY_FILES]: 500,\n [ErrorCode.TOO_MANY_LINKS]: 500,\n [ErrorCode.FILESYSTEM_ERROR]: 500,\n [ErrorCode.COMMAND_EXECUTION_ERROR]: 500,\n [ErrorCode.STREAM_START_ERROR]: 500,\n [ErrorCode.PROCESS_ERROR]: 500,\n [ErrorCode.PORT_OPERATION_ERROR]: 500,\n [ErrorCode.GIT_CLONE_FAILED]: 500,\n [ErrorCode.GIT_CHECKOUT_FAILED]: 500,\n [ErrorCode.GIT_OPERATION_FAILED]: 500,\n [ErrorCode.CODE_EXECUTION_ERROR]: 500,\n [ErrorCode.BUCKET_MOUNT_ERROR]: 500,\n [ErrorCode.BUCKET_UNMOUNT_ERROR]: 500,\n [ErrorCode.S3FS_MOUNT_ERROR]: 500,\n [ErrorCode.WATCH_START_ERROR]: 500,\n [ErrorCode.WATCH_STOP_ERROR]: 500,\n [ErrorCode.UNKNOWN_ERROR]: 500,\n [ErrorCode.INTERNAL_ERROR]: 500\n};\n/**\n * Get HTTP status code for an error code\n * Falls back to 500 for unknown errors\n */\nexport function getHttpStatus(code) {\n return ERROR_STATUS_MAP[code] || 500;\n}\n","import { ErrorCode } from './codes';\n/**\n * Get actionable suggestion for an error code\n * Used by handlers when enriching ServiceError → ErrorResponse\n */\nexport function getSuggestion(code, context) {\n switch (code) {\n case ErrorCode.FILE_NOT_FOUND:\n return `Ensure the file exists at ${context.path} before attempting to access it`;\n case ErrorCode.FILE_EXISTS:\n return `File already exists at ${context.path}. Use a different path or delete the existing file first`;\n case ErrorCode.COMMAND_NOT_FOUND:\n return `Check that \"${context.command}\" is installed and available in the system PATH`;\n case ErrorCode.PROCESS_NOT_FOUND:\n return 'Verify the process ID is correct and the process has not already exited';\n case ErrorCode.PORT_NOT_EXPOSED:\n return `Port ${context.port} is not currently available for this operation`;\n case ErrorCode.PORT_ALREADY_EXPOSED:\n return `Port ${context.port} already has preview URL authorization or activation state`;\n case ErrorCode.PORT_IN_USE:\n return `Port ${context.port} is already in use by another service. Choose a different port`;\n case ErrorCode.SESSION_ALREADY_EXISTS:\n return `Session \"${context.sessionId}\" already exists. Use a different session ID or reuse the existing session`;\n case ErrorCode.SESSION_DESTROYED:\n return `Session \"${context.sessionId}\" was destroyed. Create a new session to continue executing commands`;\n case ErrorCode.SESSION_TERMINATED:\n return `Session \"${context.sessionId}\" ended because its shell exited (exit code: ${context.exitCode ?? 'unknown'}). Session-local state (env vars, cwd, shell functions) has been lost. Retry the call to start a fresh session, or call createSession() with the same id to recreate it explicitly`;\n case ErrorCode.INVALID_PORT:\n return `Port must be between 1 and 65535. Port ${context.port} is ${context.reason}`;\n case ErrorCode.GIT_REPOSITORY_NOT_FOUND:\n return 'Verify the repository URL is correct and accessible';\n case ErrorCode.GIT_AUTH_FAILED:\n return 'Check authentication credentials or use a public repository';\n case ErrorCode.GIT_BRANCH_NOT_FOUND:\n return `Branch \"${context.branch}\" does not exist in the repository. Check the branch name or use the default branch`;\n case ErrorCode.INTERPRETER_NOT_READY:\n return context.retryAfter\n ? `Code interpreter is starting up. Retry after ${context.retryAfter} seconds`\n : 'Code interpreter is not ready. Please wait a moment and try again';\n case ErrorCode.CONTEXT_NOT_FOUND:\n return `Context \"${context.contextId}\" does not exist. Create a context first using createContext()`;\n case ErrorCode.VALIDATION_FAILED:\n return 'Check the request parameters and ensure they match the required format';\n case ErrorCode.NO_SPACE:\n return 'Not enough disk space available. Consider cleaning up temporary files or increasing storage';\n case ErrorCode.PERMISSION_DENIED:\n return 'Operation not permitted. Check file/directory permissions';\n case ErrorCode.IS_DIRECTORY:\n return `Cannot perform this operation on a directory. Path ${context.path} is a directory`;\n case ErrorCode.NOT_DIRECTORY:\n return `Expected a directory but found a file at ${context.path}`;\n case ErrorCode.RESOURCE_BUSY:\n return 'Resource is currently in use. Wait for the current operation to complete';\n case ErrorCode.READ_ONLY:\n return 'Cannot modify a read-only resource';\n case ErrorCode.SERVICE_NOT_RESPONDING:\n return 'Service is not responding. Check if the service is running and accessible';\n case ErrorCode.BACKUP_NOT_FOUND:\n return `Backup \"${context.backupId}\" does not exist. Verify the backup ID is correct`;\n case ErrorCode.BACKUP_EXPIRED:\n return `Backup \"${context.backupId}\" has expired. Create a new backup`;\n case ErrorCode.INVALID_BACKUP_CONFIG:\n return `Invalid backup configuration: ${context.reason}`;\n case ErrorCode.BACKUP_CREATE_FAILED:\n return 'Backup creation failed. Check that the directory exists and you have sufficient disk space';\n case ErrorCode.BACKUP_RESTORE_FAILED:\n return 'Backup restoration failed. The archive may be corrupted or the target directory may be in use';\n case ErrorCode.CONTAINER_UNAVAILABLE: {\n const reason = context.reason;\n switch (reason) {\n case 'provisioning':\n return 'The container is still being provisioned. Retry the operation in a moment.';\n case 'container_restarted':\n return 'The container restarted while the SDK was preparing the default session. Retry the operation to use the new container.';\n default:\n return 'The container is not ready yet. Retry the operation in a moment.';\n }\n }\n case ErrorCode.RPC_TRANSPORT_ERROR: {\n const kind = context.kind;\n switch (kind) {\n case 'peer_closed':\n return 'The container closed the WebSocket mid-call (likely a container restart, eviction, or crash). Retry the call — the SDK will open a fresh connection.';\n case 'connection_failed':\n return 'The WebSocket connection failed. Retry the call; if the failure persists, check container health and network connectivity.';\n case 'upgrade_failed':\n return 'The WebSocket upgrade was rejected by the container. Verify the container is running and reachable on the configured port.';\n case 'invalid_frame':\n return 'The container sent a frame the RPC transport cannot handle. This usually indicates a version mismatch between the SDK and the container image.';\n case 'protocol_error':\n return 'The peer sent a malformed RPC message (could not parse the wire format). This usually indicates a version mismatch between the SDK and the container image.';\n case 'session_disposed':\n return 'The RPC session was disposed while a call was in flight. Avoid reusing stubs after disconnect(); the next method call will reconnect automatically.';\n default:\n return 'The RPC transport raised an error. Retry the call — the SDK will open a fresh connection.';\n }\n }\n // Generic fallback for other errors\n default:\n return undefined;\n }\n}\n"],"mappings":";;;;;AAIA,MAAa,YAAY;CAErB,gBAAgB;CAEhB,mBAAmB;CAEnB,aAAa;CAEb,cAAc;CACd,eAAe;CAEf,gBAAgB;CAEhB,UAAU;CACV,gBAAgB;CAChB,eAAe;CACf,WAAW;CACX,eAAe;CACf,gBAAgB;CAChB,kBAAkB;CAElB,mBAAmB;CAEnB,2BAA2B;CAC3B,iBAAiB;CAEjB,yBAAyB;CACzB,oBAAoB;CAEpB,mBAAmB;CAEnB,2BAA2B;CAC3B,eAAe;CAEf,wBAAwB;CAExB,mBAAmB;CACnB,oBAAoB;CAEpB,sBAAsB;CACtB,aAAa;CAEb,kBAAkB;CAElB,qBAAqB;CACrB,cAAc;CAEd,wBAAwB;CACxB,sBAAsB;CAEtB,wBAAwB;CAExB,0BAA0B;CAC1B,sBAAsB;CAEtB,iBAAiB;CAEjB,mBAAmB;CAEnB,iBAAiB;CAEjB,kBAAkB;CAClB,qBAAqB;CACrB,sBAAsB;CAEtB,oBAAoB;CACpB,sBAAsB;CACtB,kBAAkB;CAClB,qBAAqB;CACrB,sBAAsB;CAEtB,sBAAsB;CACtB,uBAAuB;CAEvB,kBAAkB;CAElB,gBAAgB;CAChB,uBAAuB;CAEvB,uBAAuB;CAEvB,mBAAmB;CAEnB,sBAAsB;CAEtB,sBAAsB;CACtB,0BAA0B;CAE1B,yBAAyB;CAEzB,uBAAuB;CACvB,6BAA6B;CAE7B,iBAAiB;CAEjB,mBAAmB;CACnB,kBAAkB;CAElB,mBAAmB;CAEnB,uBAAuB;CACvB,eAAe;CACf,gBAAgB;CAEhB,uBAAuB;CAMvB,qBAAqB;CACxB;;;;;;;;AC9GD,MAAa,mBAAmB;EAE3B,UAAU,iBAAiB;EAC3B,UAAU,oBAAoB;EAC9B,UAAU,oBA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X,QAAO;EACX,KAAK,UAAU,UACX,QAAO;EACX,KAAK,UAAU,uBACX,QAAO;EACX,KAAK,UAAU,iBACX,QAAO,WAAW,QAAQ,SAAS;EACvC,KAAK,UAAU,eACX,QAAO,WAAW,QAAQ,SAAS;EACvC,KAAK,UAAU,sBACX,QAAO,iCAAiC,QAAQ;EACpD,KAAK,UAAU,qBACX,QAAO;EACX,KAAK,UAAU,sBACX,QAAO;EACX,KAAK,UAAU,sBAEX,SADe,QAAQ,QACvB;GACI,KAAK,eACD,QAAO;GACX,KAAK,sBACD,QAAO;GACX,QACI,QAAO;;EAGnB,KAAK,UAAU,oBAEX,SADa,QAAQ,MACrB;GACI,KAAK,cACD,QAAO;GACX,KAAK,oBACD,QAAO;GACX,KAAK,iBACD,QAAO;GACX,KAAK,gBACD,QAAO;GACX,KAAK,iBACD,QAAO;GACX,KAAK,mBACD,QAAO;GACX,QACI,QAAO;;EAInB,QACI"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
1
|
+
import { A as Process, B as WatchOptions, C as FileWatchSSEEvent, D as LocalMountBucketOptions, E as ListFilesOptions, F as SandboxOptions, G as CodeContext, H as isProcess, I as SessionOptions, J as ExecutionResult, K as CreateContextOptions, L as StreamOptions, M as ProcessStatus, N as RemoteMountBucketOptions, O as LogEvent, P as RestoreBackupResult, R as WaitForLogResult, S as FileStreamEvent, T as ISandbox, U as isProcessStatus, V as isExecResult, W as PtyOptions, Y as RunCodeOptions, _ as ExecOptions, a as QuickTunnelInfo, b as FileChunk, c as TunnelOptions, d as BucketCredentials, f as BucketProvider, g as ExecEvent, h as DirectoryBackup, i as NamedTunnelInfo, j as ProcessOptions, k as MountBucketOptions, l as BackupOptions, m as CheckChangesResult, n as Sandbox, o as SandboxInterpreterAPI, p as CheckChangesOptions, q as Execution, r as getSandbox, s as TunnelInfo, t as ContainerProxy, u as BaseExecOptions, v as ExecResult, w as GitCheckoutResult, x as FileMetadata, y as ExecutionSession, z as WaitForPortOptions } from "./sandbox-44kEJjAc.js";
|
|
2
|
+
import { a as ContainerUnavailableContext, c as ProcessExitedBeforeReadyContext, d as RPCTransportErrorKind, f as SessionTerminatedContext, h as ErrorCode, i as BackupRestoreContext, l as ProcessReadyTimeoutContext, m as OperationType, n as BackupExpiredContext, o as InvalidBackupConfigContext, p as ErrorResponse, r as BackupNotFoundContext, t as BackupCreateContext, u as RPCTransportContext } from "./contexts-DPFhc2nR.js";
|
|
3
3
|
|
|
4
4
|
//#region src/errors/classes.d.ts
|
|
5
5
|
|
|
@@ -8,8 +8,8 @@ import { a as InvalidBackupConfigContext, c as ProcessReadyTimeoutContext, d as
|
|
|
8
8
|
* Preserves all error information from container
|
|
9
9
|
*/
|
|
10
10
|
declare class SandboxError<TContext = Record<string, unknown>> extends Error {
|
|
11
|
-
readonly errorResponse: ErrorResponse
|
|
12
|
-
constructor(errorResponse: ErrorResponse
|
|
11
|
+
readonly errorResponse: ErrorResponse<TContext>;
|
|
12
|
+
constructor(errorResponse: ErrorResponse<TContext>, options?: {
|
|
13
13
|
cause?: unknown;
|
|
14
14
|
});
|
|
15
15
|
get code(): ErrorCode;
|
|
@@ -39,7 +39,7 @@ declare class SandboxError<TContext = Record<string, unknown>> extends Error {
|
|
|
39
39
|
* with the same sessionId will transparently start a fresh session.
|
|
40
40
|
*/
|
|
41
41
|
declare class SessionTerminatedError extends SandboxError<SessionTerminatedContext> {
|
|
42
|
-
constructor(errorResponse: ErrorResponse
|
|
42
|
+
constructor(errorResponse: ErrorResponse<SessionTerminatedContext>);
|
|
43
43
|
get sessionId(): string;
|
|
44
44
|
get exitCode(): number | null;
|
|
45
45
|
}
|
|
@@ -47,7 +47,7 @@ declare class SessionTerminatedError extends SandboxError<SessionTerminatedConte
|
|
|
47
47
|
* Error thrown when a process does not become ready within the timeout period
|
|
48
48
|
*/
|
|
49
49
|
declare class ProcessReadyTimeoutError extends SandboxError<ProcessReadyTimeoutContext> {
|
|
50
|
-
constructor(errorResponse: ErrorResponse
|
|
50
|
+
constructor(errorResponse: ErrorResponse<ProcessReadyTimeoutContext>);
|
|
51
51
|
get processId(): string;
|
|
52
52
|
get command(): string;
|
|
53
53
|
get condition(): string;
|
|
@@ -57,7 +57,7 @@ declare class ProcessReadyTimeoutError extends SandboxError<ProcessReadyTimeoutC
|
|
|
57
57
|
* Error thrown when a process exits before becoming ready
|
|
58
58
|
*/
|
|
59
59
|
declare class ProcessExitedBeforeReadyError extends SandboxError<ProcessExitedBeforeReadyContext> {
|
|
60
|
-
constructor(errorResponse: ErrorResponse
|
|
60
|
+
constructor(errorResponse: ErrorResponse<ProcessExitedBeforeReadyContext>);
|
|
61
61
|
get processId(): string;
|
|
62
62
|
get command(): string;
|
|
63
63
|
get condition(): string;
|
|
@@ -67,14 +67,14 @@ declare class ProcessExitedBeforeReadyError extends SandboxError<ProcessExitedBe
|
|
|
67
67
|
* Error thrown when a backup is not found in R2
|
|
68
68
|
*/
|
|
69
69
|
declare class BackupNotFoundError extends SandboxError<BackupNotFoundContext> {
|
|
70
|
-
constructor(errorResponse: ErrorResponse
|
|
70
|
+
constructor(errorResponse: ErrorResponse<BackupNotFoundContext>);
|
|
71
71
|
get backupId(): string;
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Error thrown when a backup has expired (past its TTL)
|
|
75
75
|
*/
|
|
76
76
|
declare class BackupExpiredError extends SandboxError<BackupExpiredContext> {
|
|
77
|
-
constructor(errorResponse: ErrorResponse
|
|
77
|
+
constructor(errorResponse: ErrorResponse<BackupExpiredContext>);
|
|
78
78
|
get backupId(): string;
|
|
79
79
|
get expiredAt(): string | undefined;
|
|
80
80
|
}
|
|
@@ -82,14 +82,14 @@ declare class BackupExpiredError extends SandboxError<BackupExpiredContext> {
|
|
|
82
82
|
* Error thrown when backup configuration or inputs are invalid
|
|
83
83
|
*/
|
|
84
84
|
declare class InvalidBackupConfigError extends SandboxError<InvalidBackupConfigContext> {
|
|
85
|
-
constructor(errorResponse: ErrorResponse
|
|
85
|
+
constructor(errorResponse: ErrorResponse<InvalidBackupConfigContext>);
|
|
86
86
|
get reason(): string;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Error thrown when backup creation fails
|
|
90
90
|
*/
|
|
91
91
|
declare class BackupCreateError extends SandboxError<BackupCreateContext> {
|
|
92
|
-
constructor(errorResponse: ErrorResponse
|
|
92
|
+
constructor(errorResponse: ErrorResponse<BackupCreateContext>);
|
|
93
93
|
get dir(): string;
|
|
94
94
|
get backupId(): string | undefined;
|
|
95
95
|
}
|
|
@@ -97,10 +97,13 @@ declare class BackupCreateError extends SandboxError<BackupCreateContext> {
|
|
|
97
97
|
* Error thrown when backup restoration fails
|
|
98
98
|
*/
|
|
99
99
|
declare class BackupRestoreError extends SandboxError<BackupRestoreContext> {
|
|
100
|
-
constructor(errorResponse: ErrorResponse
|
|
100
|
+
constructor(errorResponse: ErrorResponse<BackupRestoreContext>);
|
|
101
101
|
get dir(): string;
|
|
102
102
|
get backupId(): string;
|
|
103
103
|
}
|
|
104
|
+
declare class ContainerUnavailableError extends SandboxError<ContainerUnavailableContext> {
|
|
105
|
+
constructor(errorResponse: ErrorResponse<ContainerUnavailableContext>);
|
|
106
|
+
}
|
|
104
107
|
/**
|
|
105
108
|
* Raised when the capnweb WebSocket session itself fails on the SDK side.
|
|
106
109
|
* Unlike the rest of the SandboxError tree, the container never produces
|
|
@@ -114,7 +117,7 @@ declare class BackupRestoreError extends SandboxError<BackupRestoreContext> {
|
|
|
114
117
|
* Always retryable: the SDK opens a fresh connection on the next call.
|
|
115
118
|
*/
|
|
116
119
|
declare class RPCTransportError extends SandboxError<RPCTransportContext> {
|
|
117
|
-
constructor(errorResponse: ErrorResponse
|
|
120
|
+
constructor(errorResponse: ErrorResponse<RPCTransportContext>, options?: {
|
|
118
121
|
cause?: unknown;
|
|
119
122
|
});
|
|
120
123
|
get kind(): RPCTransportErrorKind;
|
|
@@ -262,5 +265,5 @@ declare class InvalidMountConfigError extends BucketMountError {
|
|
|
262
265
|
constructor(message: string);
|
|
263
266
|
}
|
|
264
267
|
//#endregion
|
|
265
|
-
export {
|
|
268
|
+
export { BackupCreateError, BackupExpiredError, BackupNotFoundError, type BackupOptions, BackupRestoreError, type BaseExecOptions, type BucketCredentials, BucketMountError, type BucketProvider, BucketUnmountError, type CheckChangesOptions, type CheckChangesResult, type CodeContext, CodeInterpreter, ContainerProxy, ContainerUnavailableError, type CreateContextOptions, type DirectoryBackup, type ExecEvent, type ExecOptions, type ExecResult, type ExecutionResult, type ExecutionSession, type FileChunk, type FileMetadata, type FileStreamEvent, type FileWatchSSEEvent, type GitCheckoutResult, type ISandbox, InvalidBackupConfigError, InvalidMountConfigError, type ListFilesOptions, type LocalMountBucketOptions, type LogEvent, MissingCredentialsError, type MountBucketOptions, type NamedTunnelInfo, type Process, ProcessExitedBeforeReadyError, type ProcessOptions, ProcessReadyTimeoutError, type ProcessStatus, type PtyOptions, type QuickTunnelInfo, type RPCTransportContext, RPCTransportError, type RPCTransportErrorKind, type RemoteMountBucketOptions, type RestoreBackupResult, type RunCodeOptions, S3FSMountError, Sandbox, type SandboxEnv, type SandboxOptions, type SessionOptions, SessionTerminatedError, type StreamOptions, type TunnelInfo, type TunnelOptions, type WaitForLogResult, type WaitForPortOptions, type WatchOptions, asyncIterableToSSEStream, collectFile, getSandbox, isExecResult, isProcess, isProcessStatus, parseSSEStream, proxyTerminal, proxyToSandbox, responseToAsyncIterable, streamFile };
|
|
266
269
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/errors/classes.ts","../src/file-stream.ts","../src/interpreter.ts","../src/pty/proxy.ts","../src/request-handler.ts","../src/sse-parser.ts","../src/storage-mount/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/errors/classes.ts","../src/file-stream.ts","../src/interpreter.ts","../src/pty/proxy.ts","../src/request-handler.ts","../src/sse-parser.ts","../src/storage-mount/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAoEa,cAnBA,YAmBA,CAAA,WAnBwB,MAmBxB,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,SAnByD,KAAA,CAmBzD;EAAA,SAAA,aAAA,EAjBsB,aAiBtB,CAjBoC,QAiBpC,CAAA;EAME,WAAA,CAAA,aAAA,EAvBoB,aAuBpB,CAvBkC,QAuBlC,CAAA,EAAA,QAAA,EAAA;;;EAzBuD,IAAA,IAAA,CAAA,CAAA,EAEtB,SAFsB;EAAK,IAAA,OAAA,CAAA,CAAA,EAmB9D,QAnB8D;EA6Q9D,IAAA,UAAA,CAAA,CAAA,EAAA,MAAA;EAA4C,IAAA,SAAA,CAAA,CAAA,EA1P5C,aAAA,GA0P4C,SAAA;EACd,IAAA,UAAA,CAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EAAd,IAAA,SAAA,CAAA,CAAA,EAAA,MAAA;EADe,IAAA,aAAA,CAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EAAY,MAAA,CAAA,CAAA,EAAA;IA6X3C,IAAA,EAAA,MAAA;IAA8C,OAAA,EAAA,MAAA;IAChB,IAAA,EAlnB5B,SAknB4B;IAAd,OAAA,UAAA;IADiB,UAAA,EAAA,MAAA;IAAY,SAAA,kBAAA,SAAA;IAwB7C,UAAA,EAAA,MAAA,GAAA,SAA8B;IAAqB,SAAA,EAAA,MAAA;IACrB,aAAA,EAAA,MAAA,GAAA,SAAA;IAAd,KAAA,EAAA,MAAA,GAAA,SAAA;EADsB,CAAA;;;;;;;;cArZtC,sBAAA,SAA+B,aAAa;6BAC5B,cAAc;EIpT1B,IAAA,SAAU,CAAA,CAAA,EAAA,MAAA;EAAW,IAAA,QAAA,CAAA,CAAA,EAAA,MAAA,GAAA,IAAA;;;;;cJgrBzB,wBAAA,SAAiC,aAA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1DsB,SN0DtB;;;;;AAoPF,cMpSA,cAAA,SAAuB,gBAAA,CNoSA;EAAqB,WAAA,CAAA,OAAA,EAAA,MAAA;;;;;AA6X5C,cMvpBA,kBAAA,SAA2B,gBAAA,CNupBF;EAAqB,WAAA,CAAA,OAAA,EAAA,MAAA;;;;;AAwB9C,cMrqBA,uBAAA,SAAgC,gBAAA,CNqqBF;EAAqB,WAAA,CAAA,OAAA,EAAA,MAAA;;;;;AA4BnD,cMvrBA,uBAAA,SAAgC,gBAAA,CNurBZ;EAAqB,WAAA,CAAA,OAAA,EAAA,MAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./errors-
|
|
3
|
-
import { A as
|
|
1
|
+
import { c as TraceContext, n as isProcess, o as createLogger, r as isProcessStatus, t as isExecResult } from "./dist-mAH_7Ui7.js";
|
|
2
|
+
import "./errors-CpoDEfUZ.js";
|
|
3
|
+
import { A as InvalidBackupConfigError, C as collectFile, D as BackupNotFoundError, E as BackupExpiredError, M as ProcessReadyTimeoutError, N as RPCTransportError, O as BackupRestoreError, P as SessionTerminatedError, T as BackupCreateError, _ as proxyTerminal, a as BucketUnmountError, b as sanitizeSandboxId, c as S3FSMountError, d as responseToAsyncIterable, f as PREVIEW_PROXY_HEADER, g as PREVIEW_PROXY_TOKEN_HEADER, h as PREVIEW_PROXY_SANDBOX_ID_HEADER, i as BucketMountError, j as ProcessExitedBeforeReadyError, k as ContainerUnavailableError, l as asyncIterableToSSEStream, m as PREVIEW_PROXY_PORT_HEADER, n as Sandbox, o as InvalidMountConfigError, p as PREVIEW_PROXY_HEADERS, r as getSandbox, s as MissingCredentialsError, t as ContainerProxy, u as parseSSEStream, v as CodeInterpreter, w as streamFile, x as validatePort } from "./sandbox-C9CHzLDx.js";
|
|
4
4
|
|
|
5
5
|
//#region src/request-handler.ts
|
|
6
6
|
function createProxyLogger(request) {
|
|
@@ -60,5 +60,5 @@ function extractSandboxRoute(url) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
//#endregion
|
|
63
|
-
export {
|
|
63
|
+
export { BackupCreateError, BackupExpiredError, BackupNotFoundError, BackupRestoreError, BucketMountError, BucketUnmountError, CodeInterpreter, ContainerProxy, ContainerUnavailableError, InvalidBackupConfigError, InvalidMountConfigError, MissingCredentialsError, ProcessExitedBeforeReadyError, ProcessReadyTimeoutError, RPCTransportError, S3FSMountError, Sandbox, SessionTerminatedError, asyncIterableToSSEStream, collectFile, getSandbox, isExecResult, isProcess, isProcessStatus, parseSSEStream, proxyTerminal, proxyToSandbox, responseToAsyncIterable, streamFile };
|
|
64
64
|
//# sourceMappingURL=index.js.map
|
package/dist/openai/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Sandbox } from "../sandbox-
|
|
1
|
+
import { n as Sandbox } from "../sandbox-44kEJjAc.js";
|
|
2
2
|
import { ApplyPatchOperation, ApplyPatchResult, Editor as Editor$1, Shell as Shell$1, ShellAction, ShellResult } from "@openai/agents";
|
|
3
3
|
|
|
4
4
|
//#region src/openai/index.d.ts
|