@cloudflare/sandbox 0.12.4 → 0.12.6

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.
@@ -200,6 +200,34 @@ interface OpencodeStartupContext {
200
200
  stderr?: string;
201
201
  command?: string;
202
202
  }
203
+ /**
204
+ * Reason the sandbox container could not accept the incoming RPC connection.
205
+ * Callers may branch on this to distinguish container-startup unavailability
206
+ * from account-level capacity limits. `retryable` is always true regardless
207
+ * of reason.
208
+ */
209
+ type ContainerUnavailableReason = /** The container is still booting. */
210
+ 'container_starting'
211
+ /** The container is temporarily unhealthy. */ | 'container_unhealthy'
212
+ /** The container was replaced while the connection attempt was in progress. */ | 'container_replaced'
213
+ /** The WebSocket upgrade retry budget was exhausted. */ | 'rpc_upgrade_failed'
214
+ /**
215
+ * The Containers platform could not allocate an instance for the Durable
216
+ * Object during connection startup ("There is no container instance that
217
+ * can be provided to this Durable Object, try again later").
218
+ */ | 'no_container_instance_available'
219
+ /**
220
+ * The account reached its configured concurrent-instance ceiling
221
+ * ("Maximum number of running container instances exceeded. Try again
222
+ * later, or try configuring a higher value for max_instances").
223
+ */ | 'max_container_instances_exceeded'
224
+ /**
225
+ * The RPC connection was torn down before the container ever became
226
+ * reachable, and the underlying platform cause was not captured (e.g. the
227
+ * Durable Object was evicted mid-startup under capacity pressure). The
228
+ * container was never admitted — this is unavailability, not a cold start
229
+ * in progress.
230
+ */ | 'container_unreachable';
203
231
  /**
204
232
  * Container availability error context. Surfaced when the sandbox container
205
233
  * cannot accept the incoming RPC connection. The container may be starting
@@ -209,9 +237,9 @@ interface OpencodeStartupContext {
209
237
  interface ContainerUnavailableContext {
210
238
  /**
211
239
  * Categorical reason distinguishing startup unavailability from runtime
212
- * replacement and exhausted upgrade retries.
240
+ * replacement, exhausted upgrade retries, and account capacity limits.
213
241
  */
214
- reason: 'container_starting' | 'container_unhealthy' | 'container_replaced' | 'rpc_upgrade_failed';
242
+ reason: ContainerUnavailableReason;
215
243
  /**
216
244
  * Always true — this error represents a transient unavailability, not a
217
245
  * permanent failure. Callers should retry the same operation.
@@ -219,6 +247,12 @@ interface ContainerUnavailableContext {
219
247
  retryable: true;
220
248
  /** Suggested delay in milliseconds before the next retry attempt. */
221
249
  retryAfterMs?: number;
250
+ /**
251
+ * Original platform/transport error message, preserved verbatim when the
252
+ * unavailability was detected from a lower-level error (e.g. the platform
253
+ * container-allocation failure) rather than a structured response body.
254
+ */
255
+ originalMessage?: string;
222
256
  }
223
257
  /**
224
258
  * RPC transport error contexts. Surfaced when the capnweb WebSocket session
@@ -289,7 +323,22 @@ interface OperationInterruptedContext {
289
323
  recoveryAttempts?: number;
290
324
  /** Maximum number of internal recovery attempts allowed. */
291
325
  maxRecoveryAttempts?: number;
326
+ /**
327
+ * Container process exit code reported by the platform when the runtime
328
+ * stopped mid-operation (`reason === 'runtime_replaced'`). Preserved from
329
+ * the base container `onStop` params so a trace distinguishes an OOM kill
330
+ * (137) or signal (143) from a clean exit (0). Absent when the interruption
331
+ * was not driven by a container stop.
332
+ */
333
+ containerExitCode?: number;
334
+ /**
335
+ * Container stop reason reported by the platform (`'exit'` for a process
336
+ * exit, `'runtime_signal'` for a signalled shutdown/eviction). Preserved
337
+ * from the base container `onStop` params. Absent when not driven by a
338
+ * container stop.
339
+ */
340
+ stopReason?: string;
292
341
  }
293
342
  //#endregion
294
- export { ErrorCode as _, ContainerUnavailableContext as a, OperationInterruptedContext as c, ProcessReadyTimeoutContext as d, RPCTransportContext as f, OperationType as g, ErrorResponse as h, BackupRestoreContext as i, OperationInterruptedReason as l, SessionTerminatedContext as m, BackupExpiredContext as n, InvalidBackupConfigContext as o, RPCTransportErrorKind as p, BackupNotFoundContext as r, OpencodeStartupContext as s, BackupCreateContext as t, ProcessExitedBeforeReadyContext as u };
295
- //# sourceMappingURL=contexts-mjA8ZsDG.d.ts.map
343
+ export { OperationType as _, ContainerUnavailableContext as a, OpencodeStartupContext as c, ProcessExitedBeforeReadyContext as d, ProcessReadyTimeoutContext as f, ErrorResponse as g, SessionTerminatedContext as h, BackupRestoreContext as i, OperationInterruptedContext as l, RPCTransportErrorKind as m, BackupExpiredContext as n, ContainerUnavailableReason as o, RPCTransportContext as p, BackupNotFoundContext as r, InvalidBackupConfigContext as s, BackupCreateContext as t, OperationInterruptedReason as u, ErrorCode as v };
344
+ //# sourceMappingURL=contexts-C186NnAB.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contexts-C186NnAB.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","OperationInterruptedReason","OperationInterruptedContext"],"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 RPC_TRANSPORT_ERROR: \"RPC_TRANSPORT_ERROR\";\n readonly CONTAINER_UNAVAILABLE: \"CONTAINER_UNAVAILABLE\";\n readonly OPERATION_INTERRUPTED: \"OPERATION_INTERRUPTED\";\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}\n/**\n * Reason the sandbox container could not accept the incoming RPC connection.\n * Callers may branch on this to distinguish container-startup unavailability\n * from account-level capacity limits. `retryable` is always true regardless\n * of reason.\n */\nexport type ContainerUnavailableReason = \n/** The container is still booting. */\n'container_starting'\n/** The container is temporarily unhealthy. */\n | 'container_unhealthy'\n/** The container was replaced while the connection attempt was in progress. */\n | 'container_replaced'\n/** The WebSocket upgrade retry budget was exhausted. */\n | 'rpc_upgrade_failed'\n/**\n * The Containers platform could not allocate an instance for the Durable\n * Object during connection startup (\"There is no container instance that\n * can be provided to this Durable Object, try again later\").\n */\n | 'no_container_instance_available'\n/**\n * The account reached its configured concurrent-instance ceiling\n * (\"Maximum number of running container instances exceeded. Try again\n * later, or try configuring a higher value for max_instances\").\n */\n | 'max_container_instances_exceeded'\n/**\n * The RPC connection was torn down before the container ever became\n * reachable, and the underlying platform cause was not captured (e.g. the\n * Durable Object was evicted mid-startup under capacity pressure). The\n * container was never admitted — this is unavailability, not a cold start\n * in progress.\n */\n | 'container_unreachable';\n/**\n * Container availability error context. Surfaced when the sandbox container\n * cannot accept the incoming RPC connection. The container may be starting\n * up, undergoing a runtime replacement, or temporarily unhealthy. The\n * caller should retry the same operation.\n */\nexport interface ContainerUnavailableContext {\n /**\n * Categorical reason distinguishing startup unavailability from runtime\n * replacement, exhausted upgrade retries, and account capacity limits.\n */\n reason: ContainerUnavailableReason;\n /**\n * Always true — this error represents a transient unavailability, not a\n * permanent failure. Callers should retry the same operation.\n */\n retryable: true;\n /** Suggested delay in milliseconds before the next retry attempt. */\n retryAfterMs?: number;\n /**\n * Original platform/transport error message, preserved verbatim when the\n * unavailability was detected from a lower-level error (e.g. the platform\n * container-allocation failure) rather than a structured response body.\n */\n originalMessage?: 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/**\n * Reason a sandbox-owned operation was interrupted. Callers may branch on\n * this to decide whether to retry the full operation.\n */\nexport type OperationInterruptedReason = \n/** The container runtime was replaced while the operation was in progress. */\n'runtime_replaced'\n/** The RPC session was disposed mid-operation. */\n | 'transport_disposed'\n/** The sandbox lifetime changed (destroy() was called). Not retryable. */\n | 'sandbox_lifetime_changed'\n/** Internal recovery attempts were exhausted. Not retryable. */\n | 'recovery_exhausted';\n/**\n * Operation interruption context. Surfaced when a sandbox-owned operation\n * (such as backup restore) was interrupted by a runtime replacement or\n * sandbox lifetime change. Public-safe: does not include internal ids.\n */\nexport interface OperationInterruptedContext {\n /**\n * Categorical reason. Use `retryable` to decide whether to retry rather\n * than branching on the reason string.\n */\n reason: OperationInterruptedReason;\n /** Name of the operation that was interrupted (e.g. 'backup.restore'). */\n operation: string;\n /** Lifecycle phase at which the interruption was detected. */\n phase: string;\n /**\n * Whether the operation's container-local side effects reached the runtime.\n * `false` means the operation was interrupted before admission; `true`\n * means effects were committed; `'unknown'` means the operation may or may\n * not have committed.\n */\n admitted: boolean | 'unknown';\n /**\n * Whether the caller can safely retry the full operation from the beginning.\n * `sandbox_lifetime_changed` and `recovery_exhausted` set this to false.\n */\n retryable: boolean;\n /** Number of internal recovery attempts made before surfacing this error. */\n recoveryAttempts?: number;\n /** Maximum number of internal recovery attempts allowed. */\n maxRecoveryAttempts?: number;\n /**\n * Container process exit code reported by the platform when the runtime\n * stopped mid-operation (`reason === 'runtime_replaced'`). Preserved from\n * the base container `onStop` params so a trace distinguishes an OOM kill\n * (137) or signal (143) from a clean exit (0). Absent when the interruption\n * was not driven by a container stop.\n */\n containerExitCode?: number;\n /**\n * Container stop reason reported by the platform (`'exit'` for a process\n * exit, `'runtime_signal'` for a signalled shutdown/eviction). Preserved\n * from the base container `onStop` params. Absent when not driven by a\n * container stop.\n */\n stopReason?: string;\n}\n//# sourceMappingURL=contexts.d.ts.map"],"mappings":";;AAIA;AAsEA;;cAtEqBA;;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,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,SAAAA,aAAAA,EAAoB,eAAA;EAIpBC,SAAAA,cAAAA,EAAAA,gBAA0B;EAM1BC,SAAAA,cAAAA,EAAsB,gBAAA;EAmB3BE,SAAAA,YAAAA,EAAAA,cAA0B;EAmCrBC,SAAAA,mBAAAA,EAA2B,qBAKhCD;EAoBAE,SAAAA,mBAAqB,EAAA,qBAAA;AAejC,CAAA;AAoBYE,KDrRAhD,aAAAA,GCqRAgD,CAAAA,ODrRwBjD,SCqRE,CAAA,CAAA,MAAA,ODrRsBA,SCqRtB,CAAA;AActC;;;;UD9RiBE,yBAAyBE;;;;QAIhCL;;;;;;;;cAQME;;;;;WAKHE;;;;;;;;;;;;;;;;;;;;;UCSIgB,wBAAAA;;;;;;;UAOAC,0BAAAA;;;;;;UAMAC,+BAAAA;;;;;;;;;UA8FAiB,mBAAAA;;;;;;UAMAC,oBAAAA;;;;;;UAMAC,qBAAAA;;;UAGAC,oBAAAA;;;;UAIAC,0BAAAA;;;;;;UAMAC,sBAAAA;;;;;;;;;;;KAmBLE,0BAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAmCKC,2BAAAA;;;;;UAKLD;;;;;;;;;;;;;;;;;;;;KAoBAE,qBAAAA;;;;;;;;UAeKC,mBAAAA;;QAEPD;;;;;;;;;;;;;;;;;;KAkBEE,0BAAAA;;;;;;;;;;UAcKC,2BAAAA;;;;;UAKLD"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as FileStreamEvent, A as RequestConfig, At as CreateContextOptions, B as BackupOptions, C as CommandClient, Ct as WaitForPortOptions, D as ContainerStub, Dt as isProcessStatus, E as BaseApiResponse, Et as isProcess, F as SandboxInterpreterAPI, G as CheckChangesResult, H as BucketCredentials, I as TunnelInfo, J as ExecOptions, K as DirectoryBackup, L as TunnelOptions, M as SessionRequest, Mt as ExecutionResult, N as NamedTunnelInfo, Nt as RunCodeOptions, O as ErrorResponse, Ot as PtyOptions, P as QuickTunnelInfo, Q as FileMetadata, R as ExecuteRequest, S as WriteFileRequest, St as WaitForLogResult, T as BackupClient, Tt as isExecResult, U as BucketProvider, V as BaseExecOptions, W as CheckChangesOptions, X as ExecutionSession, Y as ExecResult, Z as FileChunk, _ as GitClient, _t as RestoreBackupResult, a as CommandsResponse, at as LogEvent, b as MkdirRequest, bt as SessionOptions, c as DeleteSessionRequest, ct as ProcessCleanupResult, d as UtilityClient, dt as ProcessListResult, et as FileWatchSSEEvent, f as ProcessClient, ft as ProcessLogsResult, g as GitCheckoutRequest, gt as RemoteMountBucketOptions, h as InterpreterClient, ht as ProcessStatus, i as SandboxClient, it as LocalMountBucketOptions, j as ResponseHandler, jt as Execution, k as HttpClientOptions, kt as CodeContext, l as DeleteSessionResponse, lt as ProcessInfoResult, m as ExecutionCallbacks, mt as ProcessStartResult, n as Sandbox, nt as ISandbox, o as CreateSessionRequest, ot as MountBucketOptions, p as PortClient, pt as ProcessOptions, q as ExecEvent, r as getSandbox, rt as ListFilesOptions, s as CreateSessionResponse, st as Process, t as ContainerProxy, tt as GitCheckoutResult, u as PingResponse, ut as ProcessKillResult, v as FileClient, vt as SandboxOptions, w as ExecuteResponse, wt as WatchOptions, x as ReadFileRequest, xt as StreamOptions, y as FileOperationRequest, yt as SandboxTransport, z as StartProcessRequest } from "./sandbox-5MHau7vJ.js";
2
- import { _ as ErrorCode, a as ContainerUnavailableContext, c as OperationInterruptedContext, d as ProcessReadyTimeoutContext, f as RPCTransportContext, g as OperationType, h as ErrorResponse$1, i as BackupRestoreContext, l as OperationInterruptedReason, m as SessionTerminatedContext, n as BackupExpiredContext, o as InvalidBackupConfigContext, p as RPCTransportErrorKind, r as BackupNotFoundContext, t as BackupCreateContext, u as ProcessExitedBeforeReadyContext } from "./contexts-mjA8ZsDG.js";
1
+ import { $ as FileStreamEvent, A as RequestConfig, At as CreateContextOptions, B as BackupOptions, C as CommandClient, Ct as WaitForPortOptions, D as ContainerStub, Dt as isProcessStatus, E as BaseApiResponse, Et as isProcess, F as SandboxInterpreterAPI, G as CheckChangesResult, H as BucketCredentials, I as TunnelInfo, J as ExecOptions, K as DirectoryBackup, L as TunnelOptions, M as SessionRequest, Mt as ExecutionResult, N as NamedTunnelInfo, Nt as RunCodeOptions, O as ErrorResponse, Ot as PtyOptions, P as QuickTunnelInfo, Q as FileMetadata, R as ExecuteRequest, S as WriteFileRequest, St as WaitForLogResult, T as BackupClient, Tt as isExecResult, U as BucketProvider, V as BaseExecOptions, W as CheckChangesOptions, X as ExecutionSession, Y as ExecResult, Z as FileChunk, _ as GitClient, _t as RestoreBackupResult, a as CommandsResponse, at as LogEvent, b as MkdirRequest, bt as SessionOptions, c as DeleteSessionRequest, ct as ProcessCleanupResult, d as UtilityClient, dt as ProcessListResult, et as FileWatchSSEEvent, f as ProcessClient, ft as ProcessLogsResult, g as GitCheckoutRequest, gt as RemoteMountBucketOptions, h as InterpreterClient, ht as ProcessStatus, i as SandboxClient, it as LocalMountBucketOptions, j as ResponseHandler, jt as Execution, k as HttpClientOptions, kt as CodeContext, l as DeleteSessionResponse, lt as ProcessInfoResult, m as ExecutionCallbacks, mt as ProcessStartResult, n as Sandbox, nt as ISandbox, o as CreateSessionRequest, ot as MountBucketOptions, p as PortClient, pt as ProcessOptions, q as ExecEvent, r as getSandbox, rt as ListFilesOptions, s as CreateSessionResponse, st as Process, t as ContainerProxy, tt as GitCheckoutResult, u as PingResponse, ut as ProcessKillResult, v as FileClient, vt as SandboxOptions, w as ExecuteResponse, wt as WatchOptions, x as ReadFileRequest, xt as StreamOptions, y as FileOperationRequest, yt as SandboxTransport, z as StartProcessRequest } from "./sandbox-BtaWcmmG.js";
2
+ import { _ as OperationType, a as ContainerUnavailableContext, d as ProcessExitedBeforeReadyContext, f as ProcessReadyTimeoutContext, g as ErrorResponse$1, h as SessionTerminatedContext, i as BackupRestoreContext, l as OperationInterruptedContext, m as RPCTransportErrorKind, n as BackupExpiredContext, o as ContainerUnavailableReason, p as RPCTransportContext, r as BackupNotFoundContext, s as InvalidBackupConfigContext, t as BackupCreateContext, u as OperationInterruptedReason, v as ErrorCode } from "./contexts-C186NnAB.js";
3
3
 
4
4
  //#region src/platform-errors.d.ts
5
5
 
@@ -300,5 +300,5 @@ declare class InvalidMountConfigError extends BucketMountError {
300
300
  constructor(message: string);
301
301
  }
302
302
  //#endregion
303
- export { BackupClient, BackupCreateError, BackupExpiredError, BackupNotFoundError, type BackupOptions, BackupRestoreError, type BaseApiResponse, type BaseExecOptions, type BucketCredentials, BucketMountError, type BucketProvider, BucketUnmountError, type CheckChangesOptions, type CheckChangesResult, type CodeContext, CodeInterpreter, CommandClient, type ExecuteResponse as CommandExecuteResponse, type CommandsResponse, ContainerProxy, type ContainerStub, type ContainerUnavailableContext, ContainerUnavailableError, type CreateContextOptions, type CreateSessionRequest, type CreateSessionResponse, type DeleteSessionRequest, type DeleteSessionResponse, type DirectoryBackup, type ErrorResponse, type ExecEvent, type ExecOptions, type ExecResult, type ExecuteRequest, type ExecutionCallbacks, type ExecutionResult, type ExecutionSession, type FileChunk, FileClient, type FileMetadata, type FileOperationRequest, type FileStreamEvent, type FileWatchSSEEvent, type GitCheckoutRequest, type GitCheckoutResult, GitClient, type ISandbox, type InterpreterClient, InvalidBackupConfigError, InvalidMountConfigError, type ListFilesOptions, type LocalMountBucketOptions, type LogEvent, MissingCredentialsError, type MkdirRequest, type MountBucketOptions, type NamedTunnelInfo, type OperationInterruptedContext, OperationInterruptedError, type OperationInterruptedReason, type PingResponse, PortClient, type Process, type ProcessCleanupResult, ProcessClient, ProcessExitedBeforeReadyError, type ProcessInfoResult, type ProcessKillResult, type ProcessListResult, type ProcessLogsResult, type ProcessOptions, ProcessReadyTimeoutError, type ProcessStartResult, type ProcessStatus, type PtyOptions, type QuickTunnelInfo, type RPCTransportContext, RPCTransportError, type RPCTransportErrorKind, type ReadFileRequest, type RemoteMountBucketOptions, type RequestConfig, type ResponseHandler, type RestoreBackupResult, type RunCodeOptions, S3FSMountError, Sandbox, SandboxClient, type HttpClientOptions as SandboxClientOptions, type SandboxEnv, type SandboxOptions, type SandboxTransport, type SessionOptions, type SessionRequest, SessionTerminatedError, type StartProcessRequest, type StreamOptions, type TunnelInfo, type TunnelOptions, UtilityClient, type WaitForLogResult, type WaitForPortOptions, type WatchOptions, type WriteFileRequest, asyncIterableToSSEStream, collectFile, getSandbox, isDurableObjectCodeUpdateReset, isExecResult, isPlatformTransientError, isProcess, isProcessStatus, parseSSEStream, proxyTerminal, proxyToSandbox, responseToAsyncIterable, streamFile };
303
+ export { BackupClient, BackupCreateError, BackupExpiredError, BackupNotFoundError, type BackupOptions, BackupRestoreError, type BaseApiResponse, type BaseExecOptions, type BucketCredentials, BucketMountError, type BucketProvider, BucketUnmountError, type CheckChangesOptions, type CheckChangesResult, type CodeContext, CodeInterpreter, CommandClient, type ExecuteResponse as CommandExecuteResponse, type CommandsResponse, ContainerProxy, type ContainerStub, type ContainerUnavailableContext, ContainerUnavailableError, type ContainerUnavailableReason, type CreateContextOptions, type CreateSessionRequest, type CreateSessionResponse, type DeleteSessionRequest, type DeleteSessionResponse, type DirectoryBackup, type ErrorResponse, type ExecEvent, type ExecOptions, type ExecResult, type ExecuteRequest, type ExecutionCallbacks, type ExecutionResult, type ExecutionSession, type FileChunk, FileClient, type FileMetadata, type FileOperationRequest, type FileStreamEvent, type FileWatchSSEEvent, type GitCheckoutRequest, type GitCheckoutResult, GitClient, type ISandbox, type InterpreterClient, InvalidBackupConfigError, InvalidMountConfigError, type ListFilesOptions, type LocalMountBucketOptions, type LogEvent, MissingCredentialsError, type MkdirRequest, type MountBucketOptions, type NamedTunnelInfo, type OperationInterruptedContext, OperationInterruptedError, type OperationInterruptedReason, type PingResponse, PortClient, type Process, type ProcessCleanupResult, ProcessClient, ProcessExitedBeforeReadyError, type ProcessInfoResult, type ProcessKillResult, type ProcessListResult, type ProcessLogsResult, type ProcessOptions, ProcessReadyTimeoutError, type ProcessStartResult, type ProcessStatus, type PtyOptions, type QuickTunnelInfo, type RPCTransportContext, RPCTransportError, type RPCTransportErrorKind, type ReadFileRequest, type RemoteMountBucketOptions, type RequestConfig, type ResponseHandler, type RestoreBackupResult, type RunCodeOptions, S3FSMountError, Sandbox, SandboxClient, type HttpClientOptions as SandboxClientOptions, type SandboxEnv, type SandboxOptions, type SandboxTransport, type SessionOptions, type SessionRequest, SessionTerminatedError, type StartProcessRequest, type StreamOptions, type TunnelInfo, type TunnelOptions, UtilityClient, type WaitForLogResult, type WaitForPortOptions, type WatchOptions, type WriteFileRequest, asyncIterableToSSEStream, collectFile, getSandbox, isDurableObjectCodeUpdateReset, isExecResult, isPlatformTransientError, isProcess, isProcessStatus, parseSSEStream, proxyTerminal, proxyToSandbox, responseToAsyncIterable, streamFile };
304
304
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/platform-errors.ts","../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":";;;;;;;;;AA0CA;AAaA;iBAbgB,8BAAA;;;ACQhB;;AAEiD,iBDGjC,wBAAA,CCHiC,KAAA,EAAA,OAAA,CAAA,EAAA,OAAA;;;;;AAFjD;;AAEiD,cAFpC,YAEoC,CAAA,WAFZ,MAEY,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,SAFqB,KAAA,CAErB;EAAd,SAAA,aAAA,EAAA,eAAA,CAAc,QAAd,CAAA;EAAc,WAAA,CAAA,aAAA,EAAd,eAAc,CAAA,QAAA,CAAA,EAAA,OAAD,CAAC,EAAA;IAAd,KAAA,CAAA,EAAA,OAAA;EAAa,CAAA;EAiBnC,IAAA,IAAA,CAAA,CAAA,EAjBmC,SAiBnC;EAAA,IAAA,OAAA,CAAA,CAAA,EAAA,QAAA;EAME,IAAA,UAAA,CAAA,CAAA,EAAA,MAAA;mBANF,aAAA;;EAnByD,IAAA,SAAA,CAAA,CAAA,EAAA,MAAA;EA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,CAAA;;;;;;AAEuB,iBKmDzB,uBLnDyB,CAAA,CAAA,CAAA,CAAA,QAAA,EKoDpC,QLpDoC,EAAA,MAAA,CAAA,EKqDrC,WLrDqC,CAAA,EKsD7C,aLtD6C,CKsD/B,CLtD+B,CAAA;;;;;;;AAF2B,iBK4E3D,wBL5E2D,CAAA,CAAA,CAAA,CAAA,MAAA,EK6EjE,aL7EiE,CK6EnD,CL7EmD,CAAA,EAAA,OA8QhC,CA9QgC,EAAA;EA6Q9D,MAAA,CAAA,EK9LA,WL8LA;EAA4C,SAAA,CAAA,EAAA,CAAA,KAAA,EK7LjC,CL6LiC,EAAA,GAAA,MAAA;CACd,CAAA,EK5LxC,cL4LwC,CK5LzB,UL4LyB,CAAA;;;;AA9Q3C;;AAEiD,cMvCpC,gBAAA,SAAyB,KAAA,CNuCW;EAAd,SAAA,IAAA,EMtCX,SNsCW;EAAc,WAAA,CAAA,OAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EMpCZ,SNoCY;;;;;AAuBlC,cMjDF,cAAA,SAAuB,gBAAA,CNiDrB;;;;;AAoPf;AAAyD,cM3R5C,kBAAA,SAA2B,gBAAA,CN2RiB;EACd,WAAA,CAAA,OAAA,EAAA,MAAA;;;;AA4X3C;AAA2D,cM9oB9C,uBAAA,SAAgC,gBAAA,CN8oBc;EAChB,WAAA,CAAA,OAAA,EAAA,MAAA;;;;AAuB3C;AAAgE,cM5pBnD,uBAAA,SAAgC,gBAAA,CN4pBmB;EACrB,WAAA,CAAA,OAAA,EAAA,MAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/platform-errors.ts","../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":";;;;;;;;;;;iBAgHgB,8BAAA;;;AC+MhB;;AAC2C,iBDnM3B,wBAAA,CCmM2B,KAAA,EAAA,OAAA,CAAA,EAAA,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WAAA,CAAA,OAAA,EAAA,MAAA;;;;AA4X3C;AAA2D,cM9oB9C,uBAAA,SAAgC,gBAAA,CN8oBc;EAChB,WAAA,CAAA,OAAA,EAAA,MAAA;;;;AAuB3C;AAAgE,cM5pBnD,uBAAA,SAAgC,gBAAA,CN4pBmB;EACrB,WAAA,CAAA,OAAA,EAAA,MAAA"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as isExecResult, f as TraceContext, o as isProcess, s as isProcessStatus, u as createLogger } from "./dist-B_eXrP83.js";
2
2
  import "./errors-CpkKPbWC.js";
3
- import { A as PortClient, B as InvalidBackupConfigError, C as collectFile, D as SandboxClient, E as isPlatformTransientError, F as BackupCreateError, G as SessionTerminatedError, H as ProcessExitedBeforeReadyError, I as BackupExpiredError, L as BackupNotFoundError, M as FileClient, N as CommandClient, O as UtilityClient, P as BackupClient, R as BackupRestoreError, T as isDurableObjectCodeUpdateReset, U as ProcessReadyTimeoutError, V as OperationInterruptedError, W as RPCTransportError, _ as responseToAsyncIterable, a as PREVIEW_PROXY_HEADER, b as sanitizeSandboxId, c as PREVIEW_PROXY_SANDBOX_ID_HEADER, d as BucketUnmountError, f as InvalidMountConfigError, g as parseSSEStream, h as asyncIterableToSSEStream, i as proxyTerminal, j as GitClient, k as ProcessClient, l as PREVIEW_PROXY_TOKEN_HEADER, m as S3FSMountError, n as Sandbox, o as PREVIEW_PROXY_HEADERS, p as MissingCredentialsError, r as getSandbox, s as PREVIEW_PROXY_PORT_HEADER, t as ContainerProxy, u as BucketMountError, v as CodeInterpreter, w as streamFile, x as validatePort, z as ContainerUnavailableError } from "./sandbox-CyqG4jca.js";
3
+ import { A as PortClient, B as InvalidBackupConfigError, C as collectFile, D as SandboxClient, E as isPlatformTransientError, F as BackupCreateError, G as SessionTerminatedError, H as ProcessExitedBeforeReadyError, I as BackupExpiredError, L as BackupNotFoundError, M as FileClient, N as CommandClient, O as UtilityClient, P as BackupClient, R as BackupRestoreError, T as isDurableObjectCodeUpdateReset, U as ProcessReadyTimeoutError, V as OperationInterruptedError, W as RPCTransportError, _ as responseToAsyncIterable, a as PREVIEW_PROXY_HEADER, b as sanitizeSandboxId, c as PREVIEW_PROXY_SANDBOX_ID_HEADER, d as BucketUnmountError, f as InvalidMountConfigError, g as parseSSEStream, h as asyncIterableToSSEStream, i as proxyTerminal, j as GitClient, k as ProcessClient, l as PREVIEW_PROXY_TOKEN_HEADER, m as S3FSMountError, n as Sandbox, o as PREVIEW_PROXY_HEADERS, p as MissingCredentialsError, r as getSandbox, s as PREVIEW_PROXY_PORT_HEADER, t as ContainerProxy, u as BucketMountError, v as CodeInterpreter, w as streamFile, x as validatePort, z as ContainerUnavailableError } from "./sandbox-FBmZ9mj1.js";
4
4
 
5
5
  //#region src/request-handler.ts
6
6
  function createProxyLogger(request) {
@@ -1,4 +1,4 @@
1
- import { n as Sandbox } from "../sandbox-5MHau7vJ.js";
1
+ import { n as Sandbox } from "../sandbox-BtaWcmmG.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
@@ -1,5 +1,5 @@
1
- import { n as Sandbox } from "../sandbox-5MHau7vJ.js";
2
- import { s as OpencodeStartupContext } from "../contexts-mjA8ZsDG.js";
1
+ import { n as Sandbox } from "../sandbox-BtaWcmmG.js";
2
+ import { c as OpencodeStartupContext } from "../contexts-C186NnAB.js";
3
3
  import { OpencodeClient } from "@opencode-ai/sdk/v2/client";
4
4
  import { Config } from "@opencode-ai/sdk/v2";
5
5
 
@@ -1,4 +1,4 @@
1
- import { Container, ContainerProxy } from "@cloudflare/containers";
1
+ import { Container, ContainerProxy, StopParams } from "@cloudflare/containers";
2
2
  import "capnweb";
3
3
 
4
4
  //#region ../shared/dist/logger/types.d.ts
@@ -2540,6 +2540,37 @@ interface ContainerControlConnectionOptions {
2540
2540
  stub: ContainerFetchStub;
2541
2541
  port?: number;
2542
2542
  logger?: Logger;
2543
+ /**
2544
+ * Lazily resolve sandbox identifiers for trace spans. Queried at span time
2545
+ * (not construction) so a name that is set after the client is built — or
2546
+ * changes across the connection's lifetime — is reflected. Stamped on spans
2547
+ * as `sandbox.id` and `sandbox.name`.
2548
+ */
2549
+ getSandboxInfo?: () => {
2550
+ id?: string;
2551
+ name?: string;
2552
+ };
2553
+ /**
2554
+ * Optional hook to explicitly start the container (and wait for its ports)
2555
+ * before issuing the WebSocket upgrade.
2556
+ *
2557
+ * When provided, the platform's container-admission failure ("no container
2558
+ * instance" / "max instances exceeded") is thrown here — synchronously in
2559
+ * the connection's own retry loop — so it is retried within the upgrade
2560
+ * budget and, when exhausted, classified and surfaced directly as a typed
2561
+ * `ContainerUnavailableError` via `onConnectionError`. This avoids relying
2562
+ * on the failure being round-tripped through a 503 upgrade-response body.
2563
+ *
2564
+ * When omitted, the upgrade fetch itself triggers container start (the
2565
+ * legacy behavior, still exercised by unit tests that pass a bare `fetch`
2566
+ * stub).
2567
+ *
2568
+ * Runs under the container's own instance-get / port-ready budget — it is
2569
+ * intentionally NOT passed the per-attempt connect-timeout signal, so the
2570
+ * base class can run its budget to exhaustion and throw the classifiable
2571
+ * no-instance error rather than a generic abort error.
2572
+ */
2573
+ startContainer?: () => Promise<void>;
2543
2574
  /**
2544
2575
  * Total retry budget (ms) for retryable upgrade responses while the
2545
2576
  * container is unavailable. Defaults to 120 000 (2 minutes), matching the
@@ -2563,6 +2594,26 @@ interface ContainerControlConnectionOptions {
2563
2594
  * Not fired for `disconnect()`.
2564
2595
  */
2565
2596
  onClose?: () => void;
2597
+ /**
2598
+ * Invoked with the connection-startup error just before the deferred
2599
+ * transport is aborted. Lets the owner capture the *real* failure cause
2600
+ * (e.g. a platform container-allocation error) before capnweb replaces it
2601
+ * with a generic "RPC session was shut down" message on the queued calls
2602
+ * that reject as a result of the abort.
2603
+ *
2604
+ * Fired for connection-attempt failures before queued RPC calls are rejected.
2605
+ * A single logical connect can emit multiple errors as the retry loop observes
2606
+ * transient failures; the owner should treat the latest value as the current
2607
+ * best startup cause. Not fired for `disconnect()`.
2608
+ */
2609
+ onConnectionError?: (error: unknown) => void;
2610
+ /**
2611
+ * Invoked once when the WebSocket upgrade succeeds and the capnweb session
2612
+ * is live. Lets the owner record that the session actually established a
2613
+ * connection to a running container, so a later teardown can be classified
2614
+ * as a true interruption rather than a never-connected failure.
2615
+ */
2616
+ onConnected?: () => void;
2566
2617
  }
2567
2618
  //#endregion
2568
2619
  //#region src/container-control/client.d.ts
@@ -2615,8 +2666,34 @@ declare class ContainerControlClient {
2615
2666
  private readonly onSessionBusy;
2616
2667
  private readonly onSessionIdle;
2617
2668
  private conn;
2669
+ /**
2670
+ * Real cause captured by the connection during startup failure (e.g. a
2671
+ * platform container-allocation error). Preferred over the generic capnweb
2672
+ * disposal error when translating queued RPC rejections. Cleared each time a
2673
+ * fresh connection is created.
2674
+ */
2675
+ private lastConnectionError;
2676
+ /**
2677
+ * Whether `lastConnectionError` was captured from an actual connection
2678
+ * attempt failure (authoritative root cause) rather than a lifecycle
2679
+ * teardown reason (weak). A weak teardown cause — e.g. `onStop` firing
2680
+ * `runtime_replaced` — is usually a downstream *consequence* of the real
2681
+ * failure, so it must not overwrite an authoritative cause already
2682
+ * captured from the connect attempt.
2683
+ */
2684
+ private connectionErrorIsAuthoritative;
2685
+ /**
2686
+ * Whether the current connection ever established a live session to a
2687
+ * running container. Set true by the connection's `onConnected` callback,
2688
+ * reset when a fresh connection is created. Lets `translateRPCError`
2689
+ * distinguish a true interruption (established, then dropped) from a
2690
+ * never-connected failure (container never started).
2691
+ */
2692
+ private sessionEstablished;
2618
2693
  private idleTimer;
2619
2694
  private busyPollTimer;
2695
+ /** Number of RPC method promises that have started but not settled. */
2696
+ private activeCalls;
2620
2697
  /** Tracks whether we currently believe the session is busy. */
2621
2698
  private busy;
2622
2699
  constructor(options: ContainerControlClientOptions);
@@ -2625,12 +2702,38 @@ declare class ContainerControlClient {
2625
2702
  * Starts the busy-poll timer the first time a connection is materialized.
2626
2703
  */
2627
2704
  private getConnection;
2705
+ /**
2706
+ * Stamp a *weak* connection cause (a lifecycle teardown reason). Only takes
2707
+ * effect if no authoritative connect-attempt failure has been captured, so
2708
+ * a teardown consequence never masks the real root cause.
2709
+ */
2710
+ private stampWeakConnectionCause;
2711
+ private fireUserCallback;
2712
+ private fireActivity;
2713
+ private fireSessionBusy;
2714
+ private fireSessionIdle;
2715
+ private markBusy;
2716
+ private isSessionBusy;
2717
+ private maybeTransitionIdle;
2718
+ private transitionIdleIfReady;
2628
2719
  /**
2629
2720
  * Called synchronously at the start of each RPC method invocation.
2630
2721
  * Renews the DO activity timeout so the sleepAfter alarm is pushed
2631
- * forward before the container processes the call.
2722
+ * forward before the container processes the call, and pins the RPC
2723
+ * WebSocket as busy until the method's promise settles.
2724
+ */
2725
+ private recordCallStarted;
2726
+ private recordCallSettled;
2727
+ /** Return the last connection-startup error captured, if any. */
2728
+ private getLastConnectionError;
2729
+ /** Whether the current connection ever established a live session. */
2730
+ private getSessionEstablished;
2731
+ /**
2732
+ * Base span attributes for RPC-call spans: sandbox identifiers plus the
2733
+ * container port. Mirrors the connection's `spanAttrs()` so all
2734
+ * `sandbox.rpc.*` spans share a consistent shape.
2632
2735
  */
2633
- private renewActivity;
2736
+ private getSpanAttrs;
2634
2737
  /**
2635
2738
  * Sample `getStats()` and update busy/idle state. While busy, renews the
2636
2739
  * activity timeout each tick so an in-flight stream keeps pushing the
@@ -2667,7 +2770,26 @@ declare class ContainerControlClient {
2667
2770
  getTransportMode(): SandboxTransport;
2668
2771
  isWebSocketConnected(): boolean;
2669
2772
  connect(): Promise<void>;
2670
- disconnect(): void;
2773
+ /**
2774
+ * Tear down the active connection.
2775
+ *
2776
+ * When a connection attempt is still in progress, the teardown is deferred
2777
+ * until that attempt settles — so a lifecycle disconnect (e.g. the DO's
2778
+ * alarm firing `onStop`) cannot rip the transport out from under an
2779
+ * in-flight connect and reject queued calls with a generic disposal error.
2780
+ * The provided `cause` is stamped immediately so that if the attempt fails,
2781
+ * queued calls surface it; if the attempt succeeds, the (now-established)
2782
+ * connection is then torn down cleanly with the cause.
2783
+ *
2784
+ * During this deferral window `this.conn` still points at the connecting
2785
+ * transport so queued calls can keep their original connection context.
2786
+ * Container lifecycle code treats `disconnect()` as terminal and does not
2787
+ * issue more RPC calls after requesting it.
2788
+ *
2789
+ * `cause` should be a typed `SandboxError` describing why the connection is
2790
+ * being torn down (sandbox stopping, lifetime change, transport switch).
2791
+ */
2792
+ disconnect(cause?: unknown): void;
2671
2793
  }
2672
2794
  //#endregion
2673
2795
  //#region src/tunnels/tunnels-handler.d.ts
@@ -2942,7 +3064,7 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
2942
3064
  * Logs a warning if there's a mismatch
2943
3065
  */
2944
3066
  private checkVersionCompatibility;
2945
- onStop(): Promise<void>;
3067
+ onStop(params?: StopParams): Promise<void>;
2946
3068
  onError(error: unknown): void;
2947
3069
  /**
2948
3070
  * Override Container.containerFetch to use production-friendly timeouts
@@ -2954,6 +3076,43 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
2954
3076
  * This indicates the container VM is still being provisioned.
2955
3077
  */
2956
3078
  private isNoInstanceError;
3079
+ /**
3080
+ * Explicit container-start hook for the RPC transport.
3081
+ *
3082
+ * Runs `startAndWaitForPorts` under a short instance-get budget
3083
+ * ({@link RPC_START_INSTANCE_GET_TIMEOUT_MS}) so a single attempt fails fast
3084
+ * under capacity pressure — the base class throws the classifiable
3085
+ * `NO_CONTAINER_INSTANCE_ERROR` once that budget is exhausted, and the RPC
3086
+ * control connection's own retry loop (with backoff) owns cross-attempt
3087
+ * retries. Port readiness still uses the full `portReadyTimeoutMS` so a
3088
+ * genuinely-booting app isn't cut short once an instance exists.
3089
+ *
3090
+ * Always throws a typed `SandboxError` on failure so the control connection
3091
+ * never surfaces a raw capnweb/transport string to the caller:
3092
+ * - container-admission/capacity failures → retryable
3093
+ * `ContainerUnavailableError` (preserving the platform message so the
3094
+ * connection's `shouldRetryError` still recognizes and retries it);
3095
+ * - anything else (platform-transient DO reset, network loss, unexpected
3096
+ * startup failure) → `INTERNAL_ERROR`-coded SandboxError carrying the
3097
+ * original message.
3098
+ */
3099
+ private startContainerForRPC;
3100
+ /**
3101
+ * Convert a container-start failure into a typed SandboxError. Preserves an
3102
+ * existing SandboxError as-is; maps platform admission/capacity failures to
3103
+ * a retryable ContainerUnavailableError; and wraps everything else as an
3104
+ * INTERNAL_ERROR carrying the original message (never a raw transport
3105
+ * string).
3106
+ */
3107
+ private toContainerStartError;
3108
+ /**
3109
+ * Build a typed lifecycle cause to stamp on the RPC transport when the DO
3110
+ * tears the connection down for its own reasons (container stopped, sandbox
3111
+ * destroyed, transport switched). Handed to `client.disconnect(cause)` so
3112
+ * any RPC calls queued on the transport reject with this actionable reason
3113
+ * instead of the generic capnweb "disposing the main stub" message.
3114
+ */
3115
+ private buildDisconnectCause;
2957
3116
  /**
2958
3117
  * Helper: Check if error is a transient startup error that should trigger retry
2959
3118
  *
@@ -3516,4 +3675,4 @@ declare class Sandbox<Env = unknown> extends Container<Env> implements ISandbox
3516
3675
  }
3517
3676
  //#endregion
3518
3677
  export { FileStreamEvent as $, RequestConfig as A, CreateContextOptions as At, BackupOptions as B, CommandClient as C, WaitForPortOptions as Ct, ContainerStub as D, isProcessStatus as Dt, BaseApiResponse as E, isProcess as Et, SandboxInterpreterAPI as F, CheckChangesResult as G, BucketCredentials as H, TunnelInfo as I, ExecOptions as J, DirectoryBackup as K, TunnelOptions as L, SessionRequest as M, ExecutionResult as Mt, NamedTunnelInfo as N, RunCodeOptions as Nt, ErrorResponse as O, PtyOptions as Ot, QuickTunnelInfo as P, FileMetadata as Q, ExecuteRequest as R, WriteFileRequest as S, WaitForLogResult as St, BackupClient as T, isExecResult as Tt, BucketProvider as U, BaseExecOptions as V, CheckChangesOptions as W, ExecutionSession as X, ExecResult as Y, FileChunk as Z, GitClient as _, RestoreBackupResult as _t, CommandsResponse as a, LogEvent as at, MkdirRequest as b, SessionOptions as bt, DeleteSessionRequest as c, ProcessCleanupResult as ct, UtilityClient as d, ProcessListResult as dt, FileWatchSSEEvent as et, ProcessClient as f, ProcessLogsResult as ft, GitCheckoutRequest as g, RemoteMountBucketOptions as gt, InterpreterClient as h, ProcessStatus as ht, SandboxClient as i, LocalMountBucketOptions as it, ResponseHandler as j, Execution as jt, HttpClientOptions as k, CodeContext as kt, DeleteSessionResponse as l, ProcessInfoResult as lt, ExecutionCallbacks as m, ProcessStartResult as mt, Sandbox as n, ISandbox as nt, CreateSessionRequest as o, MountBucketOptions as ot, PortClient as p, ProcessOptions as pt, ExecEvent as q, getSandbox as r, ListFilesOptions as rt, CreateSessionResponse as s, Process as st, ContainerProxy$1 as t, GitCheckoutResult as tt, PingResponse as u, ProcessKillResult as ut, FileClient as v, SandboxOptions as vt, ExecuteResponse as w, WatchOptions as wt, ReadFileRequest as x, StreamOptions as xt, FileOperationRequest as y, SandboxTransport as yt, StartProcessRequest as z };
3519
- //# sourceMappingURL=sandbox-5MHau7vJ.d.ts.map
3678
+ //# sourceMappingURL=sandbox-BtaWcmmG.d.ts.map