@cloudflare/sandbox 0.13.0-next.651.1 → 0.13.0-next.709.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/Dockerfile +12 -17
- package/README.md +48 -2
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/index.js +1365 -1054
- package/dist/bridge/index.js.map +1 -1
- package/dist/{contexts-BS0Bs6IU.d.ts → contexts-1EsLHByO.d.ts} +240 -15
- package/dist/contexts-1EsLHByO.d.ts.map +1 -0
- package/dist/{dist-DF8sudAg.js → dist-Duor5GbS.js} +38 -147
- package/dist/dist-Duor5GbS.js.map +1 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.js +4 -0
- package/dist/{errors-BG6NZiPD.js → errors-CXR0xBpw.js} +82 -13
- package/dist/errors-CXR0xBpw.js.map +1 -0
- package/dist/errors-QYlSkVGz.js +893 -0
- package/dist/errors-QYlSkVGz.js.map +1 -0
- package/dist/extensions/index.d.ts +4 -74
- package/dist/extensions/index.js +5 -152
- package/dist/extensions-CFB2xHqY.js +1023 -0
- package/dist/extensions-CFB2xHqY.js.map +1 -0
- package/dist/filesystem-BWAZCZER.d.ts +732 -0
- package/dist/filesystem-BWAZCZER.d.ts.map +1 -0
- package/dist/git/index.d.ts +63 -0
- package/dist/git/index.d.ts.map +1 -0
- package/dist/git/index.js +338 -0
- package/dist/git/index.js.map +1 -0
- package/dist/index-Bs4bqXDR.d.ts +438 -0
- package/dist/index-Bs4bqXDR.d.ts.map +1 -0
- package/dist/index-HNYBk-az.d.ts +444 -0
- package/dist/index-HNYBk-az.d.ts.map +1 -0
- package/dist/index.d.ts +487 -181
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -43
- package/dist/index.js.map +1 -1
- package/dist/interpreter/index.d.ts +311 -0
- package/dist/interpreter/index.d.ts.map +1 -0
- package/dist/interpreter/index.js +292 -0
- package/dist/interpreter/index.js.map +1 -0
- package/dist/openai/index.d.ts +5 -4
- package/dist/openai/index.d.ts.map +1 -1
- package/dist/openai/index.js +11 -6
- package/dist/openai/index.js.map +1 -1
- package/dist/opencode/index.d.ts +133 -161
- package/dist/opencode/index.d.ts.map +1 -1
- package/dist/opencode/index.js +284 -203
- package/dist/opencode/index.js.map +1 -1
- package/dist/process-types-GStiZ8f8.d.ts +73 -0
- package/dist/process-types-GStiZ8f8.d.ts.map +1 -0
- package/dist/sandbox-Auuwfnur.js +10010 -0
- package/dist/sandbox-Auuwfnur.js.map +1 -0
- package/dist/sandbox-BbAabq93.d.ts +42 -0
- package/dist/sandbox-BbAabq93.d.ts.map +1 -0
- package/dist/xterm/index.d.ts +11 -7
- package/dist/xterm/index.d.ts.map +1 -1
- package/dist/xterm/index.js +61 -18
- package/dist/xterm/index.js.map +1 -1
- package/package.json +28 -4
- package/dist/contexts-BS0Bs6IU.d.ts.map +0 -1
- package/dist/dist-DF8sudAg.js.map +0 -1
- package/dist/errors-BG6NZiPD.js.map +0 -1
- package/dist/extensions/index.d.ts.map +0 -1
- package/dist/extensions/index.js.map +0 -1
- package/dist/rpc-types-PBUY-xXM.d.ts +0 -1679
- package/dist/rpc-types-PBUY-xXM.d.ts.map +0 -1
- package/dist/sandbox-BgwMBQ7S.js +0 -8273
- package/dist/sandbox-BgwMBQ7S.js.map +0 -1
- package/dist/sandbox-D_MMqExx.d.ts +0 -1077
- package/dist/sandbox-D_MMqExx.d.ts.map +0 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { t as ProcessExit } from "./process-types-GStiZ8f8.js";
|
|
2
|
+
|
|
1
3
|
//#region ../shared/dist/errors/codes.d.ts
|
|
4
|
+
|
|
2
5
|
/**
|
|
3
6
|
* Centralized error code registry
|
|
4
7
|
* Each code maps to a specific error type with consistent semantics
|
|
@@ -23,11 +26,20 @@ declare const ErrorCode: {
|
|
|
23
26
|
readonly COMMAND_EXECUTION_ERROR: "COMMAND_EXECUTION_ERROR";
|
|
24
27
|
readonly STREAM_START_ERROR: "STREAM_START_ERROR";
|
|
25
28
|
readonly PROCESS_NOT_FOUND: "PROCESS_NOT_FOUND";
|
|
29
|
+
readonly TERMINAL_NOT_FOUND: "TERMINAL_NOT_FOUND";
|
|
30
|
+
readonly INVALID_PROCESS_CWD: "INVALID_PROCESS_CWD";
|
|
31
|
+
readonly INVALID_PROCESS_ENVIRONMENT: "INVALID_PROCESS_ENVIRONMENT";
|
|
32
|
+
readonly INVALID_PROCESS_CURSOR: "INVALID_PROCESS_CURSOR";
|
|
33
|
+
readonly INVALID_TERMINAL_CWD: "INVALID_TERMINAL_CWD";
|
|
34
|
+
readonly INVALID_TERMINAL_CURSOR: "INVALID_TERMINAL_CURSOR";
|
|
35
|
+
readonly STALE_PROCESS_HANDLE: "STALE_PROCESS_HANDLE";
|
|
36
|
+
readonly STALE_TERMINAL_HANDLE: "STALE_TERMINAL_HANDLE";
|
|
37
|
+
readonly PROCESS_WAIT_TIMEOUT: "PROCESS_WAIT_TIMEOUT";
|
|
38
|
+
readonly PROCESS_ABORTED: "PROCESS_ABORTED";
|
|
26
39
|
readonly PROCESS_PERMISSION_DENIED: "PROCESS_PERMISSION_DENIED";
|
|
27
40
|
readonly PROCESS_ERROR: "PROCESS_ERROR";
|
|
28
|
-
readonly
|
|
29
|
-
readonly
|
|
30
|
-
readonly SESSION_TERMINATED: "SESSION_TERMINATED";
|
|
41
|
+
readonly PROCESS_SPAWN_FAILED: "PROCESS_SPAWN_FAILED";
|
|
42
|
+
readonly TERMINAL_CONTROL_ERROR: "TERMINAL_CONTROL_ERROR";
|
|
31
43
|
readonly PORT_ALREADY_EXPOSED: "PORT_ALREADY_EXPOSED";
|
|
32
44
|
readonly PORT_IN_USE: "PORT_IN_USE";
|
|
33
45
|
readonly PORT_NOT_EXPOSED: "PORT_NOT_EXPOSED";
|
|
@@ -62,6 +74,7 @@ declare const ErrorCode: {
|
|
|
62
74
|
readonly OPENCODE_STARTUP_FAILED: "OPENCODE_STARTUP_FAILED";
|
|
63
75
|
readonly PROCESS_READY_TIMEOUT: "PROCESS_READY_TIMEOUT";
|
|
64
76
|
readonly PROCESS_EXITED_BEFORE_READY: "PROCESS_EXITED_BEFORE_READY";
|
|
77
|
+
readonly PROCESS_EXITED_BEFORE_LOG: "PROCESS_EXITED_BEFORE_LOG";
|
|
65
78
|
readonly WATCH_NOT_FOUND: "WATCH_NOT_FOUND";
|
|
66
79
|
readonly WATCH_START_ERROR: "WATCH_START_ERROR";
|
|
67
80
|
readonly WATCH_STOP_ERROR: "WATCH_STOP_ERROR";
|
|
@@ -70,6 +83,8 @@ declare const ErrorCode: {
|
|
|
70
83
|
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
71
84
|
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
72
85
|
readonly CONTAINER_UNAVAILABLE: "CONTAINER_UNAVAILABLE";
|
|
86
|
+
readonly CONTROL_PROTOCOL_INCOMPATIBLE: "CONTROL_PROTOCOL_INCOMPATIBLE";
|
|
87
|
+
readonly OPERATION_INTERRUPTED: "OPERATION_INTERRUPTED";
|
|
73
88
|
readonly RPC_TRANSPORT_ERROR: "RPC_TRANSPORT_ERROR";
|
|
74
89
|
};
|
|
75
90
|
type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
@@ -146,10 +161,113 @@ interface ErrorResponse<TContext = Record<string, unknown>> {
|
|
|
146
161
|
}
|
|
147
162
|
//#endregion
|
|
148
163
|
//#region ../shared/dist/errors/contexts.d.ts
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
164
|
+
/**
|
|
165
|
+
* File system error contexts
|
|
166
|
+
*/
|
|
167
|
+
interface FileNotFoundContext {
|
|
168
|
+
path: string;
|
|
169
|
+
operation: OperationType;
|
|
170
|
+
}
|
|
171
|
+
interface FileExistsContext {
|
|
172
|
+
path: string;
|
|
173
|
+
operation: OperationType;
|
|
174
|
+
}
|
|
175
|
+
interface FileTooLargeContext {
|
|
176
|
+
path: string;
|
|
177
|
+
operation: OperationType;
|
|
178
|
+
maxSize: number;
|
|
179
|
+
actualSize: number;
|
|
180
|
+
}
|
|
181
|
+
interface FileSystemContext {
|
|
182
|
+
path: string;
|
|
183
|
+
operation: OperationType;
|
|
184
|
+
stderr?: string;
|
|
185
|
+
exitCode?: number;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Command error contexts
|
|
189
|
+
*/
|
|
190
|
+
interface CommandNotFoundContext {
|
|
191
|
+
command: string;
|
|
192
|
+
}
|
|
193
|
+
interface CommandErrorContext {
|
|
194
|
+
command: string;
|
|
195
|
+
exitCode?: number;
|
|
196
|
+
stdout?: string;
|
|
197
|
+
stderr?: string;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Process error contexts
|
|
201
|
+
*/
|
|
202
|
+
interface ProcessNotFoundContext {
|
|
203
|
+
processId: string;
|
|
204
|
+
}
|
|
205
|
+
interface ProcessErrorContext {
|
|
206
|
+
processId: string;
|
|
207
|
+
pid?: number;
|
|
208
|
+
exitCode?: number;
|
|
209
|
+
stderr?: string;
|
|
210
|
+
}
|
|
211
|
+
interface InvalidProcessCwdContext {
|
|
212
|
+
processId?: string;
|
|
213
|
+
cwd: string;
|
|
214
|
+
reason: string;
|
|
215
|
+
}
|
|
216
|
+
interface InvalidProcessEnvironmentContext {
|
|
217
|
+
processId?: string;
|
|
218
|
+
name?: string;
|
|
219
|
+
reason: string;
|
|
220
|
+
}
|
|
221
|
+
interface ProcessSpawnFailedContext {
|
|
222
|
+
processId: string;
|
|
223
|
+
command: string;
|
|
224
|
+
cwd?: string;
|
|
225
|
+
stderr?: string;
|
|
226
|
+
}
|
|
227
|
+
interface InvalidProcessCursorContext {
|
|
228
|
+
processId: string;
|
|
229
|
+
cursor?: string;
|
|
230
|
+
reason: string;
|
|
231
|
+
}
|
|
232
|
+
interface StaleProcessHandleContext {
|
|
233
|
+
processId: string;
|
|
234
|
+
pid: number;
|
|
235
|
+
operation: string;
|
|
236
|
+
}
|
|
237
|
+
interface ProcessWaitTimeoutContext {
|
|
238
|
+
processId: string;
|
|
239
|
+
operation: 'output' | 'waitForExit' | 'waitForLog';
|
|
240
|
+
timeout: number;
|
|
241
|
+
}
|
|
242
|
+
interface ProcessAbortedContext {
|
|
243
|
+
processId: string;
|
|
244
|
+
operation: string;
|
|
245
|
+
}
|
|
246
|
+
interface TerminalNotFoundContext {
|
|
247
|
+
terminalId: string;
|
|
248
|
+
}
|
|
249
|
+
interface InvalidTerminalCwdContext {
|
|
250
|
+
terminalId: string;
|
|
251
|
+
cwd: string;
|
|
252
|
+
reason: string;
|
|
253
|
+
}
|
|
254
|
+
interface InvalidTerminalCursorContext {
|
|
255
|
+
terminalId: string;
|
|
256
|
+
cursor?: string;
|
|
257
|
+
reason: string;
|
|
258
|
+
}
|
|
259
|
+
interface TerminalControlErrorContext {
|
|
260
|
+
terminalId: string;
|
|
261
|
+
operation: string;
|
|
262
|
+
reason?: string;
|
|
263
|
+
failure?: {
|
|
264
|
+
code: string;
|
|
265
|
+
message: string;
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
interface StaleTerminalHandleContext {
|
|
269
|
+
terminalId: string;
|
|
270
|
+
operation: string;
|
|
153
271
|
}
|
|
154
272
|
/**
|
|
155
273
|
* Process readiness error contexts
|
|
@@ -166,6 +284,76 @@ interface ProcessExitedBeforeReadyContext {
|
|
|
166
284
|
condition: string;
|
|
167
285
|
exitCode: number;
|
|
168
286
|
}
|
|
287
|
+
interface ProcessExitedBeforeLogContext {
|
|
288
|
+
processId: string;
|
|
289
|
+
pid: number;
|
|
290
|
+
exit: ProcessExit;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Port error contexts
|
|
294
|
+
*/
|
|
295
|
+
interface PortAlreadyExposedContext {
|
|
296
|
+
port: number;
|
|
297
|
+
portName?: string;
|
|
298
|
+
}
|
|
299
|
+
interface PortNotExposedContext {
|
|
300
|
+
port: number;
|
|
301
|
+
}
|
|
302
|
+
interface InvalidPortContext {
|
|
303
|
+
port: number;
|
|
304
|
+
reason: string;
|
|
305
|
+
}
|
|
306
|
+
interface PortErrorContext {
|
|
307
|
+
port: number;
|
|
308
|
+
portName?: string;
|
|
309
|
+
stderr?: string;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Git error contexts
|
|
313
|
+
*/
|
|
314
|
+
interface GitRepositoryNotFoundContext {
|
|
315
|
+
repository: string;
|
|
316
|
+
}
|
|
317
|
+
interface GitAuthFailedContext {
|
|
318
|
+
repository: string;
|
|
319
|
+
}
|
|
320
|
+
interface GitBranchNotFoundContext {
|
|
321
|
+
branch: string;
|
|
322
|
+
repository?: string;
|
|
323
|
+
}
|
|
324
|
+
interface GitErrorContext {
|
|
325
|
+
repository?: string;
|
|
326
|
+
branch?: string;
|
|
327
|
+
targetDir?: string;
|
|
328
|
+
stderr?: string;
|
|
329
|
+
exitCode?: number;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Code interpreter error contexts
|
|
333
|
+
*/
|
|
334
|
+
interface InterpreterNotReadyContext {
|
|
335
|
+
retryAfter?: number;
|
|
336
|
+
progress?: number;
|
|
337
|
+
}
|
|
338
|
+
interface ContextNotFoundContext {
|
|
339
|
+
contextId: string;
|
|
340
|
+
}
|
|
341
|
+
interface CodeExecutionContext {
|
|
342
|
+
contextId?: string;
|
|
343
|
+
ename?: string;
|
|
344
|
+
evalue?: string;
|
|
345
|
+
traceback?: string[];
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Validation error contexts
|
|
349
|
+
*/
|
|
350
|
+
interface ValidationFailedContext {
|
|
351
|
+
validationErrors: Array<{
|
|
352
|
+
field: string;
|
|
353
|
+
message: string;
|
|
354
|
+
code?: string;
|
|
355
|
+
}>;
|
|
356
|
+
}
|
|
169
357
|
/**
|
|
170
358
|
* Backup error contexts
|
|
171
359
|
*/
|
|
@@ -194,15 +382,53 @@ interface InvalidBackupConfigContext {
|
|
|
194
382
|
/**
|
|
195
383
|
* OpenCode error contexts
|
|
196
384
|
*/
|
|
197
|
-
interface
|
|
385
|
+
interface OpenCodeStartupContext {
|
|
198
386
|
port: number;
|
|
199
387
|
stderr?: string;
|
|
200
388
|
command?: string;
|
|
201
389
|
}
|
|
202
|
-
|
|
390
|
+
/**
|
|
391
|
+
* Generic error contexts
|
|
392
|
+
*/
|
|
393
|
+
interface InternalErrorContext {
|
|
394
|
+
originalError?: string;
|
|
395
|
+
stack?: string;
|
|
396
|
+
[key: string]: unknown;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Container availability error context. Surfaced when the sandbox container
|
|
400
|
+
* cannot accept the incoming RPC connection. The container may be starting
|
|
401
|
+
* up, undergoing a runtime replacement, or temporarily unhealthy. The
|
|
402
|
+
* caller should retry the same operation.
|
|
403
|
+
*/
|
|
203
404
|
interface ContainerUnavailableContext {
|
|
204
|
-
|
|
205
|
-
|
|
405
|
+
/**
|
|
406
|
+
* Categorical reason distinguishing startup unavailability from runtime
|
|
407
|
+
* replacement and exhausted upgrade retries.
|
|
408
|
+
*/
|
|
409
|
+
reason: 'container_starting' | 'container_unhealthy' | 'container_replaced' | 'rpc_upgrade_failed';
|
|
410
|
+
/**
|
|
411
|
+
* Always true — this error represents a transient unavailability, not a
|
|
412
|
+
* permanent failure. Callers should retry the same operation.
|
|
413
|
+
*/
|
|
414
|
+
retryable: true;
|
|
415
|
+
/** Suggested delay in milliseconds before the next retry attempt. */
|
|
416
|
+
retryAfterMs?: number;
|
|
417
|
+
}
|
|
418
|
+
type OperationInterruptedReason = 'runtime_replaced' | 'container_stopped' | 'transport_disposed' | 'sandbox_destroyed' | 'sandbox_lifetime_changed' | 'recovery_exhausted' | 'unknown';
|
|
419
|
+
interface OperationInterruptedContext {
|
|
420
|
+
reason: OperationInterruptedReason;
|
|
421
|
+
operation: string;
|
|
422
|
+
phase?: string;
|
|
423
|
+
admitted: true | 'unknown';
|
|
424
|
+
retryable: boolean;
|
|
425
|
+
operationId?: string;
|
|
426
|
+
operationKey?: string;
|
|
427
|
+
idempotencyKey?: string;
|
|
428
|
+
recoveryAttempts?: number;
|
|
429
|
+
maxRecoveryAttempts?: number;
|
|
430
|
+
backupId?: string;
|
|
431
|
+
dir?: string;
|
|
206
432
|
}
|
|
207
433
|
/**
|
|
208
434
|
* RPC transport error contexts. Surfaced when the capnweb WebSocket session
|
|
@@ -214,8 +440,7 @@ type RPCTransportErrorKind = /** Server closed the WebSocket (container crash, D
|
|
|
214
440
|
/** Underlying socket fired the `error` event. */ | 'connection_failed'
|
|
215
441
|
/** WebSocket upgrade failed before the session was established. */ | 'upgrade_failed'
|
|
216
442
|
/** Peer sent a non-string frame; capnweb's wire format is JSON text only. */ | 'invalid_frame'
|
|
217
|
-
/** Peer sent a frame the wire-format parser rejected (capnweb readLoop SyntaxError). */ | 'protocol_error'
|
|
218
|
-
/** Session was disposed (locally or remotely) while a call was pending. */ | 'session_disposed'
|
|
443
|
+
/** Peer sent a frame the wire-format parser rejected (capnweb readLoop SyntaxError). */ | 'protocol_error' | 'session_disposed'
|
|
219
444
|
/** Anything else that bubbled up from the transport with no recognisable shape. */ | 'unknown';
|
|
220
445
|
interface RPCTransportContext {
|
|
221
446
|
/** Categorical bucket so callers can branch on `peer_closed` vs `upgrade_failed` etc. */
|
|
@@ -234,5 +459,5 @@ interface RPCTransportContext {
|
|
|
234
459
|
closeReason?: string;
|
|
235
460
|
}
|
|
236
461
|
//#endregion
|
|
237
|
-
export {
|
|
238
|
-
//# sourceMappingURL=contexts-
|
|
462
|
+
export { PortAlreadyExposedContext as A, ProcessWaitTimeoutContext as B, InvalidProcessCwdContext as C, OpenCodeStartupContext as D, InvalidTerminalCwdContext as E, ProcessExitedBeforeLogContext as F, TerminalControlErrorContext as G, RPCTransportErrorKind as H, ProcessExitedBeforeReadyContext as I, ErrorResponse as J, TerminalNotFoundContext as K, ProcessNotFoundContext as L, PortNotExposedContext as M, ProcessAbortedContext as N, OperationInterruptedContext as O, ProcessErrorContext as P, ProcessReadyTimeoutContext as R, InvalidProcessCursorContext as S, InvalidTerminalCursorContext as T, StaleProcessHandleContext as U, RPCTransportContext as V, StaleTerminalHandleContext as W, OperationType as X, Operation as Y, ErrorCode as Z, GitRepositoryNotFoundContext as _, CodeExecutionContext as a, InvalidBackupConfigContext as b, ContainerUnavailableContext as c, FileNotFoundContext as d, FileSystemContext as f, GitErrorContext as g, GitBranchNotFoundContext as h, BackupRestoreContext as i, PortErrorContext as j, OperationInterruptedReason as k, ContextNotFoundContext as l, GitAuthFailedContext as m, BackupExpiredContext as n, CommandErrorContext as o, FileTooLargeContext as p, ValidationFailedContext as q, BackupNotFoundContext as r, CommandNotFoundContext as s, BackupCreateContext as t, FileExistsContext as u, InternalErrorContext as v, InvalidProcessEnvironmentContext as w, InvalidPortContext as x, InterpreterNotReadyContext as y, ProcessSpawnFailedContext as z };
|
|
463
|
+
//# sourceMappingURL=contexts-1EsLHByO.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts-1EsLHByO.d.ts","names":["ErrorCode","ErrorCode","Operation","OperationType","ErrorResponse","TContext","Record","ServiceError","ServiceResult","T","ProcessExit","OperationType","FileNotFoundContext","FileExistsContext","FileTooLargeContext","FileSystemContext","CommandNotFoundContext","CommandErrorContext","ProcessNotFoundContext","ProcessErrorContext","InvalidProcessCwdContext","InvalidProcessEnvironmentContext","ProcessSpawnFailedContext","InvalidProcessCursorContext","StaleProcessHandleContext","ProcessWaitTimeoutContext","ProcessAbortedContext","TerminalNotFoundContext","InvalidTerminalCwdContext","InvalidTerminalCursorContext","TerminalControlErrorContext","StaleTerminalHandleContext","ProcessReadyTimeoutContext","ProcessExitedBeforeReadyContext","ProcessExitedBeforeLogContext","PortAlreadyExposedContext","PortNotExposedContext","InvalidPortContext","PortErrorContext","GitRepositoryNotFoundContext","GitAuthFailedContext","GitBranchNotFoundContext","GitErrorContext","InterpreterNotReadyContext","ContextNotFoundContext","CodeExecutionContext","ValidationFailedContext","Array","BucketMountContext","MissingCredentialsContext","InvalidMountConfigContext","BackupCreateContext","BackupRestoreContext","BackupNotFoundContext","BackupExpiredContext","InvalidBackupConfigContext","OpenCodeStartupContext","InternalErrorContext","ContainerUnavailableContext","OperationInterruptedReason","OperationInterruptedContext","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 TERMINAL_NOT_FOUND: \"TERMINAL_NOT_FOUND\";\n readonly INVALID_PROCESS_CWD: \"INVALID_PROCESS_CWD\";\n readonly INVALID_PROCESS_ENVIRONMENT: \"INVALID_PROCESS_ENVIRONMENT\";\n readonly INVALID_PROCESS_CURSOR: \"INVALID_PROCESS_CURSOR\";\n readonly INVALID_TERMINAL_CWD: \"INVALID_TERMINAL_CWD\";\n readonly INVALID_TERMINAL_CURSOR: \"INVALID_TERMINAL_CURSOR\";\n readonly STALE_PROCESS_HANDLE: \"STALE_PROCESS_HANDLE\";\n readonly STALE_TERMINAL_HANDLE: \"STALE_TERMINAL_HANDLE\";\n readonly PROCESS_WAIT_TIMEOUT: \"PROCESS_WAIT_TIMEOUT\";\n readonly PROCESS_ABORTED: \"PROCESS_ABORTED\";\n readonly PROCESS_PERMISSION_DENIED: \"PROCESS_PERMISSION_DENIED\";\n readonly PROCESS_ERROR: \"PROCESS_ERROR\";\n readonly PROCESS_SPAWN_FAILED: \"PROCESS_SPAWN_FAILED\";\n readonly TERMINAL_CONTROL_ERROR: \"TERMINAL_CONTROL_ERROR\";\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 PROCESS_EXITED_BEFORE_LOG: \"PROCESS_EXITED_BEFORE_LOG\";\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 CONTROL_PROTOCOL_INCOMPATIBLE: \"CONTROL_PROTOCOL_INCOMPATIBLE\";\n readonly OPERATION_INTERRUPTED: \"OPERATION_INTERRUPTED\";\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 { ProcessExit } from '../process-types';\nimport 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 InvalidProcessCwdContext {\n processId?: string;\n cwd: string;\n reason: string;\n}\nexport interface InvalidProcessEnvironmentContext {\n processId?: string;\n name?: string;\n reason: string;\n}\nexport interface ProcessSpawnFailedContext {\n processId: string;\n command: string;\n cwd?: string;\n stderr?: string;\n}\nexport interface InvalidProcessCursorContext {\n processId: string;\n cursor?: string;\n reason: string;\n}\nexport interface StaleProcessHandleContext {\n processId: string;\n pid: number;\n operation: string;\n}\nexport interface ProcessWaitTimeoutContext {\n processId: string;\n operation: 'output' | 'waitForExit' | 'waitForLog';\n timeout: number;\n}\nexport interface ProcessAbortedContext {\n processId: string;\n operation: string;\n}\nexport interface TerminalNotFoundContext {\n terminalId: string;\n}\nexport interface InvalidTerminalCwdContext {\n terminalId: string;\n cwd: string;\n reason: string;\n}\nexport interface InvalidTerminalCursorContext {\n terminalId: string;\n cursor?: string;\n reason: string;\n}\nexport interface TerminalControlErrorContext {\n terminalId: string;\n operation: string;\n reason?: string;\n failure?: {\n code: string;\n message: string;\n };\n}\nexport interface StaleTerminalHandleContext {\n terminalId: string;\n operation: string;\n}\n/**\n * Process readiness error contexts\n */\nexport interface ProcessReadyTimeoutContext {\n processId: string;\n command: string;\n condition: string;\n timeout: number;\n}\nexport interface ProcessExitedBeforeReadyContext {\n processId: string;\n command: string;\n condition: string;\n exitCode: number;\n}\nexport interface ProcessExitedBeforeLogContext {\n processId: string;\n pid: number;\n exit: ProcessExit;\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 * 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 and exhausted upgrade retries.\n */\n reason: 'container_starting' | 'container_unhealthy' | 'container_replaced' | 'rpc_upgrade_failed';\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}\nexport type OperationInterruptedReason = 'runtime_replaced' | 'container_stopped' | 'transport_disposed' | 'sandbox_destroyed' | 'sandbox_lifetime_changed' | 'recovery_exhausted' | 'unknown';\nexport interface OperationInterruptedContext {\n reason: OperationInterruptedReason;\n operation: string;\n phase?: string;\n admitted: true | 'unknown';\n retryable: boolean;\n operationId?: string;\n operationKey?: string;\n idempotencyKey?: string;\n recoveryAttempts?: number;\n maxRecoveryAttempts?: number;\n backupId?: string;\n dir?: 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' | '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;AAiFYA,cAjFSA,SAiFWA,EAAAA;;;;ECjFXE,SAAAA,YAyBpB,EAAA,cAAA;EACWC,SAAAA,aAAa,EAAA,eAAWD;EAKnBE,SAAAA,cAAaC,EAAAA,gBAAA;EAAYC,SAAAA,QAAAA,EAAAA,UAAAA;EAIhCL,SAAAA,cAAAA,EAAAA,gBAAAA;EAQME,SAAAA,aAAAA,EAAAA,eAAAA;EAKH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yBAAAA;;;;UAIAC,qBAAAA;;;UAGAC,kBAAAA;;;;UAIAC,gBAAAA;;;;;;;;UAQAC,4BAAAA;;;UAGAC,oBAAAA;;;UAGAC,wBAAAA;;;;UAIAC,eAAAA;;;;;;;;;;UAUAC,0BAAAA;;;;UAIAC,sBAAAA;;;UAGAC,oBAAAA;;;;;;;;;UASAC,uBAAAA;oBACKC;;;;;;;;;UA6BLI,mBAAAA;;;;;;UAMAC,oBAAAA;;;;;;UAMAC,qBAAAA;;;UAGAC,oBAAAA;;;;UAIAC,0BAAAA;;;;;;UAMAC,sBAAAA;;;;;;;;UAQAC,oBAAAA;;;;;;;;;;;UAWAC,2BAAAA;;;;;;;;;;;;;;KAcLC,0BAAAA;UACKC,2BAAAA;UACLD;;;;;;;;;;;;;;;;;;KAkBAE,qBAAAA;;;;;;;UAaKC,mBAAAA;;QAEPD"}
|
|
@@ -11,21 +11,6 @@ function getEnvString(env, key) {
|
|
|
11
11
|
return typeof value === "string" ? value : void 0;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Filter environment variables object to only include string values.
|
|
15
|
-
* Skips undefined, null, and non-string values.
|
|
16
|
-
*
|
|
17
|
-
* Use this when you only need the defined values (e.g., for per-command env
|
|
18
|
-
* where undefined means "don't override").
|
|
19
|
-
*
|
|
20
|
-
* @param envVars - Object that may contain undefined values
|
|
21
|
-
* @returns Clean object with only string values
|
|
22
|
-
*/
|
|
23
|
-
function filterEnvVars(envVars) {
|
|
24
|
-
const filtered = {};
|
|
25
|
-
for (const [key, value] of Object.entries(envVars)) if (value != null && typeof value === "string") filtered[key] = value;
|
|
26
|
-
return filtered;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
14
|
* Partition environment variables into values to set and keys to unset.
|
|
30
15
|
*
|
|
31
16
|
* - String values → toSet (will be exported)
|
|
@@ -152,105 +137,43 @@ function truncateForLog(value, maxLen = 120) {
|
|
|
152
137
|
}
|
|
153
138
|
|
|
154
139
|
//#endregion
|
|
155
|
-
//#region ../shared/dist/
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
*/
|
|
185
|
-
toJSON() {
|
|
186
|
-
return {
|
|
187
|
-
code: this.code,
|
|
188
|
-
logs: this.logs,
|
|
189
|
-
error: this.error,
|
|
190
|
-
executionCount: this.executionCount,
|
|
191
|
-
results: this.results.map((result) => ({
|
|
192
|
-
text: result.text,
|
|
193
|
-
html: result.html,
|
|
194
|
-
png: result.png,
|
|
195
|
-
jpeg: result.jpeg,
|
|
196
|
-
svg: result.svg,
|
|
197
|
-
latex: result.latex,
|
|
198
|
-
markdown: result.markdown,
|
|
199
|
-
javascript: result.javascript,
|
|
200
|
-
json: result.json,
|
|
201
|
-
chart: result.chart,
|
|
202
|
-
data: result.data
|
|
203
|
-
}))
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
var ResultImpl = class {
|
|
208
|
-
text;
|
|
209
|
-
html;
|
|
210
|
-
png;
|
|
211
|
-
jpeg;
|
|
212
|
-
svg;
|
|
213
|
-
latex;
|
|
214
|
-
markdown;
|
|
215
|
-
javascript;
|
|
216
|
-
json;
|
|
217
|
-
chart;
|
|
218
|
-
data;
|
|
219
|
-
constructor(raw) {
|
|
220
|
-
this.text = raw.text || raw.data?.["text/plain"];
|
|
221
|
-
this.html = raw.html || raw.data?.["text/html"];
|
|
222
|
-
this.png = raw.png || raw.data?.["image/png"];
|
|
223
|
-
this.jpeg = raw.jpeg || raw.data?.["image/jpeg"];
|
|
224
|
-
this.svg = raw.svg || raw.data?.["image/svg+xml"];
|
|
225
|
-
this.latex = raw.latex || raw.data?.["text/latex"];
|
|
226
|
-
this.markdown = raw.markdown || raw.data?.["text/markdown"];
|
|
227
|
-
this.javascript = raw.javascript || raw.data?.["application/javascript"];
|
|
228
|
-
this.json = raw.json || raw.data?.["application/json"];
|
|
229
|
-
this.chart = raw.chart;
|
|
230
|
-
this.data = raw.data;
|
|
231
|
-
}
|
|
232
|
-
formats() {
|
|
233
|
-
const fmts = [];
|
|
234
|
-
if (this.text) fmts.push("text");
|
|
235
|
-
if (this.html) fmts.push("html");
|
|
236
|
-
if (this.png) fmts.push("png");
|
|
237
|
-
if (this.jpeg) fmts.push("jpeg");
|
|
238
|
-
if (this.svg) fmts.push("svg");
|
|
239
|
-
if (this.latex) fmts.push("latex");
|
|
240
|
-
if (this.markdown) fmts.push("markdown");
|
|
241
|
-
if (this.javascript) fmts.push("javascript");
|
|
242
|
-
if (this.json) fmts.push("json");
|
|
243
|
-
if (this.chart) fmts.push("chart");
|
|
244
|
-
return fmts;
|
|
140
|
+
//#region ../shared/dist/git.js
|
|
141
|
+
/**
|
|
142
|
+
* Fallback repository name used when URL parsing fails
|
|
143
|
+
*/
|
|
144
|
+
const FALLBACK_REPO_NAME = "repository";
|
|
145
|
+
/** Default wall-clock timeout in milliseconds for git clone operations. */
|
|
146
|
+
const DEFAULT_GIT_CLONE_TIMEOUT_MS = 6e5;
|
|
147
|
+
/**
|
|
148
|
+
* Extract repository name from a Git URL
|
|
149
|
+
*
|
|
150
|
+
* Supports multiple URL formats:
|
|
151
|
+
* - HTTPS: https://github.com/user/repo.git → repo
|
|
152
|
+
* - HTTPS without .git: https://github.com/user/repo → repo
|
|
153
|
+
* - SSH: git@github.com:user/repo.git → repo
|
|
154
|
+
* - GitLab/others: https://gitlab.com/org/project.git → project
|
|
155
|
+
*
|
|
156
|
+
* @param repoUrl - Git repository URL (HTTPS or SSH format)
|
|
157
|
+
* @returns Repository name extracted from URL, or 'repository' as fallback
|
|
158
|
+
*/
|
|
159
|
+
function extractRepoName(repoUrl) {
|
|
160
|
+
try {
|
|
161
|
+
const pathParts = new URL(repoUrl).pathname.split("/");
|
|
162
|
+
const lastPart = pathParts[pathParts.length - 1];
|
|
163
|
+
if (lastPart) return lastPart.replace(/\.git$/, "");
|
|
164
|
+
} catch {}
|
|
165
|
+
if (repoUrl.includes(":") || repoUrl.includes("/")) {
|
|
166
|
+
const segments = repoUrl.split(/[:/]/).filter(Boolean);
|
|
167
|
+
const lastSegment = segments[segments.length - 1];
|
|
168
|
+
if (lastSegment) return lastSegment.replace(/\.git$/, "");
|
|
245
169
|
}
|
|
246
|
-
|
|
170
|
+
return FALLBACK_REPO_NAME;
|
|
171
|
+
}
|
|
247
172
|
|
|
248
173
|
//#endregion
|
|
249
174
|
//#region ../shared/dist/logger/canonical.js
|
|
250
175
|
/** Events that are low-value at info on success */
|
|
251
176
|
const DEBUG_ON_SUCCESS = new Set([
|
|
252
|
-
"session.create",
|
|
253
|
-
"session.destroy",
|
|
254
177
|
"file.read",
|
|
255
178
|
"file.write",
|
|
256
179
|
"file.delete",
|
|
@@ -292,9 +215,9 @@ function sanitizePayload(payload) {
|
|
|
292
215
|
* Format: `{event} {outcome} {key_context} [— {reason}] ({durationMs}ms[, {sizeBytes}B])`
|
|
293
216
|
*
|
|
294
217
|
* The if/else chain for key context has implicit priority: command > path >
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
218
|
+
* port > repoUrl > pid. If a payload has multiple, only the highest-priority
|
|
219
|
+
* one appears in the message. All fields are still present as discrete
|
|
220
|
+
* queryable keys in the structured log context.
|
|
298
221
|
*/
|
|
299
222
|
function buildMessage(payload, sanitizedCommand) {
|
|
300
223
|
const { event } = payload;
|
|
@@ -311,7 +234,6 @@ function buildMessage(payload, sanitizedCommand) {
|
|
|
311
234
|
const { value } = truncateForLog(redactCommand(payload.command));
|
|
312
235
|
parts.push(value);
|
|
313
236
|
} else if (payload.path !== void 0) parts.push(payload.path);
|
|
314
|
-
else if (event.includes("session") && payload.sessionId !== void 0) parts.push(payload.sessionId);
|
|
315
237
|
else if (payload.port !== void 0) parts.push(String(payload.port));
|
|
316
238
|
else if (payload.repoUrl !== void 0) {
|
|
317
239
|
let gitContext = payload.repoUrl;
|
|
@@ -527,7 +449,7 @@ var CloudflareLogger = class CloudflareLogger {
|
|
|
527
449
|
* Format: LEVEL [component] message trace=tr_... key=value key=value
|
|
528
450
|
*/
|
|
529
451
|
outputPretty(consoleFn, data) {
|
|
530
|
-
const { level, message: msg, timestamp, traceId, component, sandboxId,
|
|
452
|
+
const { level, message: msg, timestamp, traceId, component, sandboxId, processId, commandId, durationMs, serviceVersion, instanceId, error, ...rest } = data;
|
|
531
453
|
const levelStr = String(level || "INFO").toUpperCase();
|
|
532
454
|
const levelColor = this.getLevelColor(levelStr);
|
|
533
455
|
const componentBadge = component ? `[${component}]` : "";
|
|
@@ -536,7 +458,6 @@ var CloudflareLogger = class CloudflareLogger {
|
|
|
536
458
|
if (traceId) pairs.push(`trace=${String(traceId).substring(0, 12)}`);
|
|
537
459
|
if (commandId) pairs.push(`cmd=${String(commandId).substring(0, 12)}`);
|
|
538
460
|
if (sandboxId) pairs.push(`sandbox=${sandboxId}`);
|
|
539
|
-
if (sessionId) pairs.push(`session=${String(sessionId).substring(0, 12)}`);
|
|
540
461
|
if (processId) pairs.push(`proc=${processId}`);
|
|
541
462
|
if (durationMs !== void 0) pairs.push(`dur=${durationMs}ms`);
|
|
542
463
|
for (const [key, value] of Object.entries(rest)) {
|
|
@@ -703,7 +624,7 @@ function createNoOpLogger() {
|
|
|
703
624
|
* const logger = createLogger({
|
|
704
625
|
* component: 'container',
|
|
705
626
|
* traceId: TraceContext.fromHeaders(request.headers)!,
|
|
706
|
-
*
|
|
627
|
+
* sandboxId: this.id
|
|
707
628
|
* });
|
|
708
629
|
* ```
|
|
709
630
|
*/
|
|
@@ -779,17 +700,6 @@ function getEnvVar(name) {
|
|
|
779
700
|
*/
|
|
780
701
|
const EXTENSION_TARBALL_REQUIRED = "ExtensionTarballRequired";
|
|
781
702
|
|
|
782
|
-
//#endregion
|
|
783
|
-
//#region ../shared/dist/shell-escape.js
|
|
784
|
-
/**
|
|
785
|
-
* Escapes a string for safe use in shell commands using POSIX single-quote escaping.
|
|
786
|
-
* Prevents command injection by wrapping the string in single quotes and escaping
|
|
787
|
-
* any single quotes within the string.
|
|
788
|
-
*/
|
|
789
|
-
function shellEscape(str) {
|
|
790
|
-
return `'${str.replace(/'/g, "'\\''")}'`;
|
|
791
|
-
}
|
|
792
|
-
|
|
793
703
|
//#endregion
|
|
794
704
|
//#region ../shared/dist/sse.js
|
|
795
705
|
/**
|
|
@@ -838,24 +748,5 @@ function parseSSEFrames(buffer, currentEvent = { data: [] }) {
|
|
|
838
748
|
}
|
|
839
749
|
|
|
840
750
|
//#endregion
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
return value && typeof value.success === "boolean" && typeof value.exitCode === "number" && typeof value.stdout === "string" && typeof value.stderr === "string";
|
|
844
|
-
}
|
|
845
|
-
function isProcess(value) {
|
|
846
|
-
return value && typeof value.id === "string" && typeof value.command === "string" && typeof value.status === "string";
|
|
847
|
-
}
|
|
848
|
-
function isProcessStatus(value) {
|
|
849
|
-
return [
|
|
850
|
-
"starting",
|
|
851
|
-
"running",
|
|
852
|
-
"completed",
|
|
853
|
-
"failed",
|
|
854
|
-
"killed",
|
|
855
|
-
"error"
|
|
856
|
-
].includes(value);
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
//#endregion
|
|
860
|
-
export { shellEscape as a, createNoOpLogger as c, Execution as d, ResultImpl as f, partitionEnvVars as h, parseSSEFrames as i, TraceContext as l, getEnvString as m, isProcess as n, EXTENSION_TARBALL_REQUIRED as o, filterEnvVars as p, isProcessStatus as r, createLogger as s, isExecResult as t, logCanonicalEvent as u };
|
|
861
|
-
//# sourceMappingURL=dist-DF8sudAg.js.map
|
|
751
|
+
export { TraceContext as a, extractRepoName as c, partitionEnvVars as d, createNoOpLogger as i, redactCommand as l, EXTENSION_TARBALL_REQUIRED as n, logCanonicalEvent as o, createLogger as r, DEFAULT_GIT_CLONE_TIMEOUT_MS as s, parseSSEFrames as t, getEnvString as u };
|
|
752
|
+
//# sourceMappingURL=dist-Duor5GbS.js.map
|