@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.
Files changed (67) hide show
  1. package/Dockerfile +12 -17
  2. package/README.md +48 -2
  3. package/dist/bridge/index.d.ts.map +1 -1
  4. package/dist/bridge/index.js +1365 -1054
  5. package/dist/bridge/index.js.map +1 -1
  6. package/dist/{contexts-BS0Bs6IU.d.ts → contexts-1EsLHByO.d.ts} +240 -15
  7. package/dist/contexts-1EsLHByO.d.ts.map +1 -0
  8. package/dist/{dist-DF8sudAg.js → dist-Duor5GbS.js} +38 -147
  9. package/dist/dist-Duor5GbS.js.map +1 -0
  10. package/dist/errors/index.d.ts +4 -0
  11. package/dist/errors/index.js +4 -0
  12. package/dist/{errors-BG6NZiPD.js → errors-CXR0xBpw.js} +82 -13
  13. package/dist/errors-CXR0xBpw.js.map +1 -0
  14. package/dist/errors-QYlSkVGz.js +893 -0
  15. package/dist/errors-QYlSkVGz.js.map +1 -0
  16. package/dist/extensions/index.d.ts +4 -74
  17. package/dist/extensions/index.js +5 -152
  18. package/dist/extensions-CFB2xHqY.js +1023 -0
  19. package/dist/extensions-CFB2xHqY.js.map +1 -0
  20. package/dist/filesystem-BWAZCZER.d.ts +732 -0
  21. package/dist/filesystem-BWAZCZER.d.ts.map +1 -0
  22. package/dist/git/index.d.ts +63 -0
  23. package/dist/git/index.d.ts.map +1 -0
  24. package/dist/git/index.js +338 -0
  25. package/dist/git/index.js.map +1 -0
  26. package/dist/index-Bs4bqXDR.d.ts +438 -0
  27. package/dist/index-Bs4bqXDR.d.ts.map +1 -0
  28. package/dist/index-HNYBk-az.d.ts +444 -0
  29. package/dist/index-HNYBk-az.d.ts.map +1 -0
  30. package/dist/index.d.ts +487 -181
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +12 -43
  33. package/dist/index.js.map +1 -1
  34. package/dist/interpreter/index.d.ts +311 -0
  35. package/dist/interpreter/index.d.ts.map +1 -0
  36. package/dist/interpreter/index.js +292 -0
  37. package/dist/interpreter/index.js.map +1 -0
  38. package/dist/openai/index.d.ts +5 -4
  39. package/dist/openai/index.d.ts.map +1 -1
  40. package/dist/openai/index.js +11 -6
  41. package/dist/openai/index.js.map +1 -1
  42. package/dist/opencode/index.d.ts +133 -161
  43. package/dist/opencode/index.d.ts.map +1 -1
  44. package/dist/opencode/index.js +284 -203
  45. package/dist/opencode/index.js.map +1 -1
  46. package/dist/process-types-GStiZ8f8.d.ts +73 -0
  47. package/dist/process-types-GStiZ8f8.d.ts.map +1 -0
  48. package/dist/sandbox-Auuwfnur.js +10010 -0
  49. package/dist/sandbox-Auuwfnur.js.map +1 -0
  50. package/dist/sandbox-BbAabq93.d.ts +42 -0
  51. package/dist/sandbox-BbAabq93.d.ts.map +1 -0
  52. package/dist/xterm/index.d.ts +11 -7
  53. package/dist/xterm/index.d.ts.map +1 -1
  54. package/dist/xterm/index.js +61 -18
  55. package/dist/xterm/index.js.map +1 -1
  56. package/package.json +28 -4
  57. package/dist/contexts-BS0Bs6IU.d.ts.map +0 -1
  58. package/dist/dist-DF8sudAg.js.map +0 -1
  59. package/dist/errors-BG6NZiPD.js.map +0 -1
  60. package/dist/extensions/index.d.ts.map +0 -1
  61. package/dist/extensions/index.js.map +0 -1
  62. package/dist/rpc-types-PBUY-xXM.d.ts +0 -1679
  63. package/dist/rpc-types-PBUY-xXM.d.ts.map +0 -1
  64. package/dist/sandbox-BgwMBQ7S.js +0 -8273
  65. package/dist/sandbox-BgwMBQ7S.js.map +0 -1
  66. package/dist/sandbox-D_MMqExx.d.ts +0 -1077
  67. package/dist/sandbox-D_MMqExx.d.ts.map +0 -1
@@ -0,0 +1,893 @@
1
+ import { i as ErrorCode, r as getHttpStatus } from "./errors-CXR0xBpw.js";
2
+
3
+ //#region src/errors/classes/base.ts
4
+ var SandboxError = class extends Error {
5
+ constructor(errorResponse, options) {
6
+ super(errorResponse.message, options);
7
+ this.errorResponse = errorResponse;
8
+ this.name = "SandboxError";
9
+ }
10
+ get code() {
11
+ return this.errorResponse.code;
12
+ }
13
+ get context() {
14
+ return this.errorResponse.context;
15
+ }
16
+ get httpStatus() {
17
+ return this.errorResponse.httpStatus;
18
+ }
19
+ get operation() {
20
+ return this.errorResponse.operation;
21
+ }
22
+ get suggestion() {
23
+ return this.errorResponse.suggestion;
24
+ }
25
+ get timestamp() {
26
+ return this.errorResponse.timestamp;
27
+ }
28
+ get documentation() {
29
+ return this.errorResponse.documentation;
30
+ }
31
+ toJSON() {
32
+ return {
33
+ name: this.name,
34
+ message: this.message,
35
+ code: this.code,
36
+ context: this.context,
37
+ httpStatus: this.httpStatus,
38
+ operation: this.operation,
39
+ suggestion: this.suggestion,
40
+ timestamp: this.timestamp,
41
+ documentation: this.documentation,
42
+ stack: this.stack
43
+ };
44
+ }
45
+ };
46
+
47
+ //#endregion
48
+ //#region src/errors/classes/backup-terminal-lifecycle.ts
49
+ /**
50
+ * Error thrown when a backup is not found in R2
51
+ */
52
+ var BackupNotFoundError = class extends SandboxError {
53
+ constructor(errorResponse) {
54
+ super(errorResponse);
55
+ this.name = "BackupNotFoundError";
56
+ }
57
+ get backupId() {
58
+ return this.context.backupId;
59
+ }
60
+ };
61
+ /**
62
+ * Error thrown when a backup has expired (past its TTL)
63
+ */
64
+ var BackupExpiredError = class extends SandboxError {
65
+ constructor(errorResponse) {
66
+ super(errorResponse);
67
+ this.name = "BackupExpiredError";
68
+ }
69
+ get backupId() {
70
+ return this.context.backupId;
71
+ }
72
+ get expiredAt() {
73
+ return this.context.expiredAt;
74
+ }
75
+ };
76
+ /**
77
+ * Error thrown when backup configuration or inputs are invalid
78
+ */
79
+ var InvalidBackupConfigError = class extends SandboxError {
80
+ constructor(errorResponse) {
81
+ super(errorResponse);
82
+ this.name = "InvalidBackupConfigError";
83
+ }
84
+ get reason() {
85
+ return this.context.reason;
86
+ }
87
+ };
88
+ /**
89
+ * Error thrown when backup creation fails
90
+ */
91
+ var BackupCreateError = class extends SandboxError {
92
+ constructor(errorResponse) {
93
+ super(errorResponse);
94
+ this.name = "BackupCreateError";
95
+ }
96
+ get dir() {
97
+ return this.context.dir;
98
+ }
99
+ get backupId() {
100
+ return this.context.backupId;
101
+ }
102
+ };
103
+ /**
104
+ * Error thrown when backup restoration fails
105
+ */
106
+ var BackupRestoreError = class extends SandboxError {
107
+ constructor(errorResponse) {
108
+ super(errorResponse);
109
+ this.name = "BackupRestoreError";
110
+ }
111
+ get dir() {
112
+ return this.context.dir;
113
+ }
114
+ get backupId() {
115
+ return this.context.backupId;
116
+ }
117
+ };
118
+ var TerminalNotFoundError = class extends SandboxError {
119
+ constructor(errorResponse) {
120
+ super(errorResponse);
121
+ this.name = "TerminalNotFoundError";
122
+ }
123
+ get terminalId() {
124
+ return this.context.terminalId;
125
+ }
126
+ };
127
+ var InvalidTerminalCwdError = class extends SandboxError {
128
+ constructor(errorResponse) {
129
+ super(errorResponse);
130
+ this.name = "InvalidTerminalCwdError";
131
+ }
132
+ get terminalId() {
133
+ return this.context.terminalId;
134
+ }
135
+ get cwd() {
136
+ return this.context.cwd;
137
+ }
138
+ };
139
+ var InvalidTerminalCursorError = class extends SandboxError {
140
+ constructor(errorResponse) {
141
+ super(errorResponse);
142
+ this.name = "InvalidTerminalCursorError";
143
+ }
144
+ get terminalId() {
145
+ return this.context.terminalId;
146
+ }
147
+ };
148
+ var TerminalControlError = class extends SandboxError {
149
+ constructor(errorResponse) {
150
+ super(errorResponse);
151
+ this.name = "TerminalControlError";
152
+ }
153
+ get terminalId() {
154
+ return this.context.terminalId;
155
+ }
156
+ get operationName() {
157
+ return this.context.operation;
158
+ }
159
+ };
160
+ var StaleTerminalHandleError = class extends SandboxError {
161
+ constructor(errorResponse) {
162
+ super(errorResponse);
163
+ this.name = "StaleTerminalHandleError";
164
+ }
165
+ get terminalId() {
166
+ return this.context.terminalId;
167
+ }
168
+ get operation() {
169
+ return this.context.operation;
170
+ }
171
+ };
172
+ var ContainerUnavailableError = class extends SandboxError {
173
+ constructor(errorResponse) {
174
+ super(errorResponse);
175
+ this.name = "ContainerUnavailableError";
176
+ }
177
+ };
178
+ var OperationInterruptedError = class extends SandboxError {
179
+ constructor(errorResponse) {
180
+ super(errorResponse);
181
+ this.name = "OperationInterruptedError";
182
+ }
183
+ get reason() {
184
+ return this.context.reason;
185
+ }
186
+ get retryable() {
187
+ return this.context.retryable;
188
+ }
189
+ get operationName() {
190
+ return this.context.operation;
191
+ }
192
+ };
193
+ /**
194
+ * Raised when the capnweb WebSocket session itself fails on the SDK side.
195
+ * Unlike the rest of the SandboxError tree, the container never produces
196
+ * this error — it is synthesised by `translateRPCError` from the plain
197
+ * Errors capnweb / DeferredTransport raise when the connection dies.
198
+ *
199
+ * `kind` distinguishes the failure mode (peer close, upgrade failed, etc.)
200
+ * so callers can branch on a structured code instead of substring-matching
201
+ * on the message.
202
+ *
203
+ * Always retryable: the SDK opens a fresh connection on the next call.
204
+ */
205
+ var RPCTransportError = class extends SandboxError {
206
+ constructor(errorResponse, options) {
207
+ super(errorResponse, options);
208
+ this.name = "RPCTransportError";
209
+ }
210
+ get kind() {
211
+ return this.errorResponse.context.kind;
212
+ }
213
+ get originalMessage() {
214
+ return this.errorResponse.context.originalMessage;
215
+ }
216
+ };
217
+
218
+ //#endregion
219
+ //#region src/errors/classes/filesystem.ts
220
+ /**
221
+ * Error thrown when a file or directory is not found
222
+ */
223
+ var FileNotFoundError = class extends SandboxError {
224
+ constructor(errorResponse) {
225
+ super(errorResponse);
226
+ this.name = "FileNotFoundError";
227
+ }
228
+ get path() {
229
+ return this.context.path;
230
+ }
231
+ };
232
+ /**
233
+ * Error thrown when a file already exists
234
+ */
235
+ var FileExistsError = class extends SandboxError {
236
+ constructor(errorResponse) {
237
+ super(errorResponse);
238
+ this.name = "FileExistsError";
239
+ }
240
+ get path() {
241
+ return this.context.path;
242
+ }
243
+ };
244
+ /**
245
+ * Error thrown when a file is too large
246
+ */
247
+ var FileTooLargeError = class extends SandboxError {
248
+ constructor(errorResponse) {
249
+ super(errorResponse);
250
+ this.name = "FileTooLargeError";
251
+ }
252
+ get path() {
253
+ return this.context.path;
254
+ }
255
+ };
256
+ /**
257
+ * Generic file system error (permissions, disk full, etc.)
258
+ */
259
+ var FileSystemError = class extends SandboxError {
260
+ constructor(errorResponse) {
261
+ super(errorResponse);
262
+ this.name = "FileSystemError";
263
+ }
264
+ get path() {
265
+ return this.context.path;
266
+ }
267
+ get stderr() {
268
+ return this.context.stderr;
269
+ }
270
+ get exitCode() {
271
+ return this.context.exitCode;
272
+ }
273
+ };
274
+ /**
275
+ * Error thrown when permission is denied
276
+ */
277
+ var PermissionDeniedError = class extends SandboxError {
278
+ constructor(errorResponse) {
279
+ super(errorResponse);
280
+ this.name = "PermissionDeniedError";
281
+ }
282
+ get path() {
283
+ return this.context.path;
284
+ }
285
+ };
286
+
287
+ //#endregion
288
+ //#region src/errors/classes/git-code.ts
289
+ /**
290
+ * Error thrown when a git repository is not found
291
+ */
292
+ var GitRepositoryNotFoundError = class extends SandboxError {
293
+ constructor(errorResponse) {
294
+ super(errorResponse);
295
+ this.name = "GitRepositoryNotFoundError";
296
+ }
297
+ get repository() {
298
+ return this.context.repository;
299
+ }
300
+ };
301
+ /**
302
+ * Error thrown when git authentication fails
303
+ */
304
+ var GitAuthenticationError = class extends SandboxError {
305
+ constructor(errorResponse) {
306
+ super(errorResponse);
307
+ this.name = "GitAuthenticationError";
308
+ }
309
+ get repository() {
310
+ return this.context.repository;
311
+ }
312
+ };
313
+ /**
314
+ * Error thrown when a git branch is not found
315
+ */
316
+ var GitBranchNotFoundError = class extends SandboxError {
317
+ constructor(errorResponse) {
318
+ super(errorResponse);
319
+ this.name = "GitBranchNotFoundError";
320
+ }
321
+ get branch() {
322
+ return this.context.branch;
323
+ }
324
+ get repository() {
325
+ return this.context.repository;
326
+ }
327
+ };
328
+ /**
329
+ * Error thrown when a git network operation fails
330
+ */
331
+ var GitNetworkError = class extends SandboxError {
332
+ constructor(errorResponse) {
333
+ super(errorResponse);
334
+ this.name = "GitNetworkError";
335
+ }
336
+ get repository() {
337
+ return this.context.repository;
338
+ }
339
+ get branch() {
340
+ return this.context.branch;
341
+ }
342
+ get targetDir() {
343
+ return this.context.targetDir;
344
+ }
345
+ };
346
+ /**
347
+ * Error thrown when git clone fails
348
+ */
349
+ var GitCloneError = class extends SandboxError {
350
+ constructor(errorResponse) {
351
+ super(errorResponse);
352
+ this.name = "GitCloneError";
353
+ }
354
+ get repository() {
355
+ return this.context.repository;
356
+ }
357
+ get targetDir() {
358
+ return this.context.targetDir;
359
+ }
360
+ get stderr() {
361
+ return this.context.stderr;
362
+ }
363
+ get exitCode() {
364
+ return this.context.exitCode;
365
+ }
366
+ };
367
+ /**
368
+ * Error thrown when git checkout fails
369
+ */
370
+ var GitCheckoutError = class extends SandboxError {
371
+ constructor(errorResponse) {
372
+ super(errorResponse);
373
+ this.name = "GitCheckoutError";
374
+ }
375
+ get branch() {
376
+ return this.context.branch;
377
+ }
378
+ get repository() {
379
+ return this.context.repository;
380
+ }
381
+ get stderr() {
382
+ return this.context.stderr;
383
+ }
384
+ };
385
+ /**
386
+ * Error thrown when a git URL is invalid
387
+ */
388
+ var InvalidGitUrlError = class extends SandboxError {
389
+ constructor(errorResponse) {
390
+ super(errorResponse);
391
+ this.name = "InvalidGitUrlError";
392
+ }
393
+ get validationErrors() {
394
+ return this.context.validationErrors;
395
+ }
396
+ };
397
+ /**
398
+ * Generic git operation error
399
+ */
400
+ var GitError = class extends SandboxError {
401
+ constructor(errorResponse) {
402
+ super(errorResponse);
403
+ this.name = "GitError";
404
+ }
405
+ get repository() {
406
+ return this.context.repository;
407
+ }
408
+ get branch() {
409
+ return this.context.branch;
410
+ }
411
+ get targetDir() {
412
+ return this.context.targetDir;
413
+ }
414
+ get stderr() {
415
+ return this.context.stderr;
416
+ }
417
+ get exitCode() {
418
+ return this.context.exitCode;
419
+ }
420
+ };
421
+ /**
422
+ * Error thrown when interpreter is not ready
423
+ */
424
+ var InterpreterNotReadyError = class extends SandboxError {
425
+ constructor(errorResponse) {
426
+ super(errorResponse);
427
+ this.name = "InterpreterNotReadyError";
428
+ }
429
+ get retryAfter() {
430
+ return this.context.retryAfter;
431
+ }
432
+ get progress() {
433
+ return this.context.progress;
434
+ }
435
+ };
436
+ /**
437
+ * Error thrown when a context is not found
438
+ */
439
+ var ContextNotFoundError = class extends SandboxError {
440
+ constructor(errorResponse) {
441
+ super(errorResponse);
442
+ this.name = "ContextNotFoundError";
443
+ }
444
+ get contextId() {
445
+ return this.context.contextId;
446
+ }
447
+ };
448
+ /**
449
+ * Error thrown when code execution fails
450
+ */
451
+ var CodeExecutionError = class extends SandboxError {
452
+ constructor(errorResponse) {
453
+ super(errorResponse);
454
+ this.name = "CodeExecutionError";
455
+ }
456
+ get contextId() {
457
+ return this.context.contextId;
458
+ }
459
+ get ename() {
460
+ return this.context.ename;
461
+ }
462
+ get evalue() {
463
+ return this.context.evalue;
464
+ }
465
+ get traceback() {
466
+ return this.context.traceback;
467
+ }
468
+ };
469
+ /**
470
+ * Error thrown when validation fails
471
+ */
472
+ var ValidationFailedError = class extends SandboxError {
473
+ constructor(errorResponse) {
474
+ super(errorResponse);
475
+ this.name = "ValidationFailedError";
476
+ }
477
+ get validationErrors() {
478
+ return this.context.validationErrors;
479
+ }
480
+ };
481
+
482
+ //#endregion
483
+ //#region src/errors/classes/port.ts
484
+ /**
485
+ * Error thrown when exposing a port that is already exposed.
486
+ */
487
+ var PortAlreadyExposedError = class extends SandboxError {
488
+ constructor(errorResponse) {
489
+ super(errorResponse);
490
+ this.name = "PortAlreadyExposedError";
491
+ }
492
+ get port() {
493
+ return this.context.port;
494
+ }
495
+ get portName() {
496
+ return this.context.portName;
497
+ }
498
+ };
499
+ /**
500
+ * Error thrown when operating on a port that has not been exposed.
501
+ */
502
+ var PortNotExposedError = class extends SandboxError {
503
+ constructor(errorResponse) {
504
+ super(errorResponse);
505
+ this.name = "PortNotExposedError";
506
+ }
507
+ get port() {
508
+ return this.context.port;
509
+ }
510
+ };
511
+ /**
512
+ * Error thrown when a port number is invalid
513
+ */
514
+ var InvalidPortError = class extends SandboxError {
515
+ constructor(errorResponse) {
516
+ super(errorResponse);
517
+ this.name = "InvalidPortError";
518
+ }
519
+ get port() {
520
+ return this.context.port;
521
+ }
522
+ get reason() {
523
+ return this.context.reason;
524
+ }
525
+ };
526
+ /**
527
+ * Error thrown when a service on a port is not responding
528
+ */
529
+ var ServiceNotRespondingError = class extends SandboxError {
530
+ constructor(errorResponse) {
531
+ super(errorResponse);
532
+ this.name = "ServiceNotRespondingError";
533
+ }
534
+ get port() {
535
+ return this.context.port;
536
+ }
537
+ get portName() {
538
+ return this.context.portName;
539
+ }
540
+ };
541
+ /**
542
+ * Error thrown when a port is already in use
543
+ */
544
+ var PortInUseError = class extends SandboxError {
545
+ constructor(errorResponse) {
546
+ super(errorResponse);
547
+ this.name = "PortInUseError";
548
+ }
549
+ get port() {
550
+ return this.context.port;
551
+ }
552
+ };
553
+ /**
554
+ * Generic port operation error
555
+ */
556
+ var PortError = class extends SandboxError {
557
+ constructor(errorResponse) {
558
+ super(errorResponse);
559
+ this.name = "PortError";
560
+ }
561
+ get port() {
562
+ return this.context.port;
563
+ }
564
+ get portName() {
565
+ return this.context.portName;
566
+ }
567
+ get stderr() {
568
+ return this.context.stderr;
569
+ }
570
+ };
571
+ /**
572
+ * Error thrown when port exposure requires a custom domain
573
+ */
574
+ var CustomDomainRequiredError = class extends SandboxError {
575
+ constructor(errorResponse) {
576
+ super(errorResponse);
577
+ this.name = "CustomDomainRequiredError";
578
+ }
579
+ };
580
+
581
+ //#endregion
582
+ //#region src/errors/classes/process.ts
583
+ /**
584
+ * Error thrown when a command is not found
585
+ */
586
+ var CommandNotFoundError = class extends SandboxError {
587
+ constructor(errorResponse) {
588
+ super(errorResponse);
589
+ this.name = "CommandNotFoundError";
590
+ }
591
+ get command() {
592
+ return this.context.command;
593
+ }
594
+ };
595
+ /**
596
+ * Generic command execution error
597
+ */
598
+ var CommandError = class extends SandboxError {
599
+ constructor(errorResponse) {
600
+ super(errorResponse);
601
+ this.name = "CommandError";
602
+ }
603
+ get command() {
604
+ return this.context.command;
605
+ }
606
+ get exitCode() {
607
+ return this.context.exitCode;
608
+ }
609
+ get stdout() {
610
+ return this.context.stdout;
611
+ }
612
+ get stderr() {
613
+ return this.context.stderr;
614
+ }
615
+ };
616
+ var InvalidProcessCwdError = class extends SandboxError {
617
+ constructor(errorResponse) {
618
+ super(errorResponse);
619
+ this.name = "InvalidProcessCwdError";
620
+ }
621
+ };
622
+ var InvalidProcessEnvironmentError = class extends SandboxError {
623
+ constructor(errorResponse) {
624
+ super(errorResponse);
625
+ this.name = "InvalidProcessEnvironmentError";
626
+ }
627
+ };
628
+ var InvalidProcessCursorError = class extends SandboxError {
629
+ constructor(errorResponse) {
630
+ super(errorResponse);
631
+ this.name = "InvalidProcessCursorError";
632
+ }
633
+ };
634
+ var ProcessSpawnFailedError = class extends SandboxError {
635
+ constructor(errorResponse) {
636
+ super(errorResponse);
637
+ this.name = "ProcessSpawnFailedError";
638
+ }
639
+ };
640
+ /**
641
+ * Error thrown when a process is not found
642
+ */
643
+ var ProcessNotFoundError = class extends SandboxError {
644
+ constructor(errorResponse) {
645
+ super(errorResponse);
646
+ this.name = "ProcessNotFoundError";
647
+ }
648
+ get processId() {
649
+ return this.context.processId;
650
+ }
651
+ };
652
+ /**
653
+ * Generic process error
654
+ */
655
+ var ProcessError = class extends SandboxError {
656
+ constructor(errorResponse) {
657
+ super(errorResponse);
658
+ this.name = "ProcessError";
659
+ }
660
+ get processId() {
661
+ return this.context.processId;
662
+ }
663
+ get pid() {
664
+ return this.context.pid;
665
+ }
666
+ get exitCode() {
667
+ return this.context.exitCode;
668
+ }
669
+ get stderr() {
670
+ return this.context.stderr;
671
+ }
672
+ };
673
+ var StaleProcessHandleError = class extends SandboxError {
674
+ constructor(errorResponse) {
675
+ super(errorResponse);
676
+ this.name = "StaleProcessHandleError";
677
+ }
678
+ get processId() {
679
+ return this.context.processId;
680
+ }
681
+ get pid() {
682
+ return this.context.pid;
683
+ }
684
+ get operation() {
685
+ return this.context.operation;
686
+ }
687
+ };
688
+ var ProcessWaitTimeoutError = class extends SandboxError {
689
+ constructor(errorResponse) {
690
+ super(errorResponse);
691
+ this.name = "ProcessWaitTimeoutError";
692
+ }
693
+ get processId() {
694
+ return this.context.processId;
695
+ }
696
+ get operation() {
697
+ return this.context.operation;
698
+ }
699
+ get timeout() {
700
+ return this.context.timeout;
701
+ }
702
+ };
703
+ var ProcessAbortedError = class extends SandboxError {
704
+ constructor(errorResponse) {
705
+ super(errorResponse);
706
+ this.name = "ProcessAbortedError";
707
+ }
708
+ get processId() {
709
+ return this.context.processId;
710
+ }
711
+ get operation() {
712
+ return this.context.operation;
713
+ }
714
+ };
715
+ var ProcessReadyTimeoutError = class extends SandboxError {
716
+ constructor(errorResponse) {
717
+ super(errorResponse);
718
+ this.name = "ProcessReadyTimeoutError";
719
+ }
720
+ get processId() {
721
+ return this.context.processId;
722
+ }
723
+ get command() {
724
+ return this.context.command;
725
+ }
726
+ get condition() {
727
+ return this.context.condition;
728
+ }
729
+ get timeout() {
730
+ return this.context.timeout;
731
+ }
732
+ };
733
+ var ProcessExitedBeforeLogError = class extends SandboxError {
734
+ constructor(errorResponse) {
735
+ super(errorResponse);
736
+ this.name = "ProcessExitedBeforeLogError";
737
+ }
738
+ get processId() {
739
+ return this.context.processId;
740
+ }
741
+ get pid() {
742
+ return this.context.pid;
743
+ }
744
+ get exit() {
745
+ return this.context.exit;
746
+ }
747
+ };
748
+ var ProcessExitedBeforeReadyError = class extends SandboxError {
749
+ constructor(errorResponse) {
750
+ super(errorResponse);
751
+ this.name = "ProcessExitedBeforeReadyError";
752
+ }
753
+ get processId() {
754
+ return this.context.processId;
755
+ }
756
+ get command() {
757
+ return this.context.command;
758
+ }
759
+ get condition() {
760
+ return this.context.condition;
761
+ }
762
+ get exitCode() {
763
+ return this.context.exitCode;
764
+ }
765
+ };
766
+
767
+ //#endregion
768
+ //#region src/errors/classes/runtime-control-protocol.ts
769
+ var RuntimeControlProtocolError = class extends SandboxError {
770
+ constructor(message, context, options) {
771
+ super({
772
+ code: ErrorCode.INTERNAL_ERROR,
773
+ message,
774
+ context,
775
+ httpStatus: getHttpStatus(ErrorCode.INTERNAL_ERROR),
776
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
777
+ }, options);
778
+ this.name = "RuntimeControlProtocolError";
779
+ }
780
+ };
781
+
782
+ //#endregion
783
+ //#region src/errors/classes/runtime-inactive.ts
784
+ var RuntimeIdentityInactiveError = class extends Error {
785
+ constructor() {
786
+ super("Runtime identity is no longer active");
787
+ this.name = "RuntimeIdentityInactiveError";
788
+ }
789
+ };
790
+
791
+ //#endregion
792
+ //#region src/errors/adapter.ts
793
+ function isStaleProcessHandleResponse(errorResponse) {
794
+ const { context } = errorResponse;
795
+ return errorResponse.code === ErrorCode.STALE_PROCESS_HANDLE && "processId" in context && typeof context.processId === "string" && "pid" in context && typeof context.pid === "number" && "operation" in context && typeof context.operation === "string";
796
+ }
797
+ function isStaleTerminalHandleResponse(errorResponse) {
798
+ const { context } = errorResponse;
799
+ return errorResponse.code === ErrorCode.STALE_TERMINAL_HANDLE && "terminalId" in context && typeof context.terminalId === "string" && "operation" in context && typeof context.operation === "string";
800
+ }
801
+ function isProcessWaitTimeoutResponse(errorResponse) {
802
+ const { context } = errorResponse;
803
+ return errorResponse.code === ErrorCode.PROCESS_WAIT_TIMEOUT && "processId" in context && typeof context.processId === "string" && "operation" in context && (context.operation === "output" || context.operation === "waitForExit" || context.operation === "waitForLog") && "timeout" in context && typeof context.timeout === "number";
804
+ }
805
+ function isProcessAbortedResponse(errorResponse) {
806
+ const { context } = errorResponse;
807
+ return errorResponse.code === ErrorCode.PROCESS_ABORTED && "processId" in context && typeof context.processId === "string" && "operation" in context && typeof context.operation === "string";
808
+ }
809
+ /**
810
+ * Convert ErrorResponse to appropriate Error class
811
+ * Simple switch statement - we trust the container sends correct context
812
+ */
813
+ function createErrorFromResponse(errorResponse, options) {
814
+ switch (errorResponse.code) {
815
+ case ErrorCode.FILE_NOT_FOUND: return new FileNotFoundError(errorResponse);
816
+ case ErrorCode.FILE_EXISTS: return new FileExistsError(errorResponse);
817
+ case ErrorCode.FILE_TOO_LARGE: return new FileTooLargeError(errorResponse);
818
+ case ErrorCode.PERMISSION_DENIED: return new PermissionDeniedError(errorResponse);
819
+ case ErrorCode.IS_DIRECTORY:
820
+ case ErrorCode.NOT_DIRECTORY:
821
+ case ErrorCode.NO_SPACE:
822
+ case ErrorCode.TOO_MANY_FILES:
823
+ case ErrorCode.RESOURCE_BUSY:
824
+ case ErrorCode.READ_ONLY:
825
+ case ErrorCode.NAME_TOO_LONG:
826
+ case ErrorCode.TOO_MANY_LINKS:
827
+ case ErrorCode.FILESYSTEM_ERROR: return new FileSystemError(errorResponse);
828
+ case ErrorCode.COMMAND_NOT_FOUND: return new CommandNotFoundError(errorResponse);
829
+ case ErrorCode.COMMAND_PERMISSION_DENIED:
830
+ case ErrorCode.COMMAND_EXECUTION_ERROR:
831
+ case ErrorCode.INVALID_COMMAND:
832
+ case ErrorCode.STREAM_START_ERROR: return new CommandError(errorResponse);
833
+ case ErrorCode.INVALID_PROCESS_CWD: return new InvalidProcessCwdError(errorResponse);
834
+ case ErrorCode.INVALID_PROCESS_ENVIRONMENT: return new InvalidProcessEnvironmentError(errorResponse);
835
+ case ErrorCode.INVALID_PROCESS_CURSOR: return new InvalidProcessCursorError(errorResponse);
836
+ case ErrorCode.PROCESS_SPAWN_FAILED: return new ProcessSpawnFailedError(errorResponse);
837
+ case ErrorCode.PROCESS_NOT_FOUND: return new ProcessNotFoundError(errorResponse);
838
+ case ErrorCode.STALE_PROCESS_HANDLE:
839
+ if (isStaleProcessHandleResponse(errorResponse)) return new StaleProcessHandleError(errorResponse);
840
+ return new SandboxError(errorResponse);
841
+ case ErrorCode.STALE_TERMINAL_HANDLE:
842
+ if (isStaleTerminalHandleResponse(errorResponse)) return new StaleTerminalHandleError(errorResponse);
843
+ return new SandboxError(errorResponse);
844
+ case ErrorCode.PROCESS_WAIT_TIMEOUT:
845
+ if (isProcessWaitTimeoutResponse(errorResponse)) return new ProcessWaitTimeoutError(errorResponse);
846
+ return new SandboxError(errorResponse);
847
+ case ErrorCode.PROCESS_ABORTED:
848
+ if (isProcessAbortedResponse(errorResponse)) return new ProcessAbortedError(errorResponse);
849
+ return new SandboxError(errorResponse);
850
+ case ErrorCode.TERMINAL_NOT_FOUND: return new TerminalNotFoundError(errorResponse);
851
+ case ErrorCode.INVALID_TERMINAL_CWD: return new InvalidTerminalCwdError(errorResponse);
852
+ case ErrorCode.INVALID_TERMINAL_CURSOR: return new InvalidTerminalCursorError(errorResponse);
853
+ case ErrorCode.TERMINAL_CONTROL_ERROR: return new TerminalControlError(errorResponse);
854
+ case ErrorCode.PROCESS_PERMISSION_DENIED:
855
+ case ErrorCode.PROCESS_ERROR: return new ProcessError(errorResponse);
856
+ case ErrorCode.PORT_ALREADY_EXPOSED: return new PortAlreadyExposedError(errorResponse);
857
+ case ErrorCode.PORT_NOT_EXPOSED: return new PortNotExposedError(errorResponse);
858
+ case ErrorCode.INVALID_PORT_NUMBER:
859
+ case ErrorCode.INVALID_PORT: return new InvalidPortError(errorResponse);
860
+ case ErrorCode.SERVICE_NOT_RESPONDING: return new ServiceNotRespondingError(errorResponse);
861
+ case ErrorCode.PORT_IN_USE: return new PortInUseError(errorResponse);
862
+ case ErrorCode.PORT_OPERATION_ERROR: return new PortError(errorResponse);
863
+ case ErrorCode.CUSTOM_DOMAIN_REQUIRED: return new CustomDomainRequiredError(errorResponse);
864
+ case ErrorCode.GIT_REPOSITORY_NOT_FOUND: return new GitRepositoryNotFoundError(errorResponse);
865
+ case ErrorCode.GIT_AUTH_FAILED: return new GitAuthenticationError(errorResponse);
866
+ case ErrorCode.GIT_BRANCH_NOT_FOUND: return new GitBranchNotFoundError(errorResponse);
867
+ case ErrorCode.GIT_NETWORK_ERROR: return new GitNetworkError(errorResponse);
868
+ case ErrorCode.GIT_CLONE_FAILED: return new GitCloneError(errorResponse);
869
+ case ErrorCode.GIT_CHECKOUT_FAILED: return new GitCheckoutError(errorResponse);
870
+ case ErrorCode.INVALID_GIT_URL: return new InvalidGitUrlError(errorResponse);
871
+ case ErrorCode.GIT_OPERATION_FAILED: return new GitError(errorResponse);
872
+ case ErrorCode.BACKUP_NOT_FOUND: return new BackupNotFoundError(errorResponse);
873
+ case ErrorCode.BACKUP_EXPIRED: return new BackupExpiredError(errorResponse);
874
+ case ErrorCode.INVALID_BACKUP_CONFIG: return new InvalidBackupConfigError(errorResponse);
875
+ case ErrorCode.BACKUP_CREATE_FAILED: return new BackupCreateError(errorResponse);
876
+ case ErrorCode.BACKUP_RESTORE_FAILED: return new BackupRestoreError(errorResponse);
877
+ case ErrorCode.INTERPRETER_NOT_READY: return new InterpreterNotReadyError(errorResponse);
878
+ case ErrorCode.CONTEXT_NOT_FOUND: return new ContextNotFoundError(errorResponse);
879
+ case ErrorCode.CODE_EXECUTION_ERROR: return new CodeExecutionError(errorResponse);
880
+ case ErrorCode.CONTAINER_UNAVAILABLE: return new ContainerUnavailableError(errorResponse);
881
+ case ErrorCode.OPERATION_INTERRUPTED: return new OperationInterruptedError(errorResponse);
882
+ case ErrorCode.RPC_TRANSPORT_ERROR: return new RPCTransportError(errorResponse, options);
883
+ case ErrorCode.VALIDATION_FAILED: return new ValidationFailedError(errorResponse);
884
+ case ErrorCode.INVALID_JSON_RESPONSE:
885
+ case ErrorCode.UNKNOWN_ERROR:
886
+ case ErrorCode.INTERNAL_ERROR: return new SandboxError(errorResponse);
887
+ default: return new SandboxError(errorResponse);
888
+ }
889
+ }
890
+
891
+ //#endregion
892
+ export { TerminalControlError as $, GitCloneError as A, FileTooLargeError as B, PortNotExposedError as C, GitAuthenticationError as D, ContextNotFoundError as E, InvalidGitUrlError as F, BackupRestoreError as G, BackupCreateError as H, ValidationFailedError as I, InvalidTerminalCursorError as J, ContainerUnavailableError as K, FileExistsError as L, GitNetworkError as M, GitRepositoryNotFoundError as N, GitBranchNotFoundError as O, InterpreterNotReadyError as P, StaleTerminalHandleError as Q, FileNotFoundError as R, PortInUseError as S, CodeExecutionError as T, BackupExpiredError as U, PermissionDeniedError as V, BackupNotFoundError as W, OperationInterruptedError as X, InvalidTerminalCwdError as Y, RPCTransportError as Z, StaleProcessHandleError as _, CommandNotFoundError as a, PortAlreadyExposedError as b, InvalidProcessEnvironmentError as c, ProcessExitedBeforeLogError as d, TerminalNotFoundError as et, ProcessExitedBeforeReadyError as f, ProcessWaitTimeoutError as g, ProcessSpawnFailedError as h, CommandError as i, GitError as j, GitCheckoutError as k, ProcessAbortedError as l, ProcessReadyTimeoutError as m, RuntimeIdentityInactiveError as n, InvalidProcessCursorError as o, ProcessNotFoundError as p, InvalidBackupConfigError as q, RuntimeControlProtocolError as r, InvalidProcessCwdError as s, createErrorFromResponse as t, SandboxError as tt, ProcessError as u, CustomDomainRequiredError as v, ServiceNotRespondingError as w, PortError as x, InvalidPortError as y, FileSystemError as z };
893
+ //# sourceMappingURL=errors-QYlSkVGz.js.map