@cloudflare/sandbox 0.3.6 → 0.4.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 (120) hide show
  1. package/.turbo/turbo-build.log +44 -0
  2. package/CHANGELOG.md +6 -8
  3. package/Dockerfile +88 -18
  4. package/README.md +89 -824
  5. package/dist/{chunk-JTKON2SH.js → chunk-BCJ7SF3Q.js} +9 -5
  6. package/dist/chunk-BCJ7SF3Q.js.map +1 -0
  7. package/dist/chunk-BFVUNTP4.js +104 -0
  8. package/dist/chunk-BFVUNTP4.js.map +1 -0
  9. package/dist/{chunk-NNGBXDMY.js → chunk-EKSWCBCA.js} +3 -6
  10. package/dist/chunk-EKSWCBCA.js.map +1 -0
  11. package/dist/chunk-HGF554LH.js +2236 -0
  12. package/dist/chunk-HGF554LH.js.map +1 -0
  13. package/dist/{chunk-6UAWTJ5S.js → chunk-Z532A7QC.js} +13 -20
  14. package/dist/{chunk-6UAWTJ5S.js.map → chunk-Z532A7QC.js.map} +1 -1
  15. package/dist/file-stream.d.ts +16 -38
  16. package/dist/file-stream.js +1 -2
  17. package/dist/index.d.ts +6 -5
  18. package/dist/index.js +35 -39
  19. package/dist/index.js.map +1 -1
  20. package/dist/interpreter.d.ts +3 -3
  21. package/dist/interpreter.js +2 -2
  22. package/dist/request-handler.d.ts +4 -3
  23. package/dist/request-handler.js +4 -7
  24. package/dist/sandbox-D9K2ypln.d.ts +583 -0
  25. package/dist/sandbox.d.ts +3 -3
  26. package/dist/sandbox.js +4 -7
  27. package/dist/security.d.ts +4 -3
  28. package/dist/security.js +3 -3
  29. package/dist/sse-parser.js +1 -1
  30. package/package.json +11 -5
  31. package/src/clients/base-client.ts +280 -0
  32. package/src/clients/command-client.ts +115 -0
  33. package/src/clients/file-client.ts +269 -0
  34. package/src/clients/git-client.ts +92 -0
  35. package/src/clients/index.ts +63 -0
  36. package/src/{interpreter-client.ts → clients/interpreter-client.ts} +148 -171
  37. package/src/clients/port-client.ts +105 -0
  38. package/src/clients/process-client.ts +177 -0
  39. package/src/clients/sandbox-client.ts +41 -0
  40. package/src/clients/types.ts +84 -0
  41. package/src/clients/utility-client.ts +94 -0
  42. package/src/errors/adapter.ts +180 -0
  43. package/src/errors/classes.ts +469 -0
  44. package/src/errors/index.ts +105 -0
  45. package/src/file-stream.ts +119 -117
  46. package/src/index.ts +81 -69
  47. package/src/interpreter.ts +17 -8
  48. package/src/request-handler.ts +69 -43
  49. package/src/sandbox.ts +694 -533
  50. package/src/security.ts +14 -23
  51. package/src/sse-parser.ts +4 -8
  52. package/startup.sh +3 -0
  53. package/tests/base-client.test.ts +328 -0
  54. package/tests/command-client.test.ts +407 -0
  55. package/tests/file-client.test.ts +643 -0
  56. package/tests/file-stream.test.ts +306 -0
  57. package/tests/git-client.test.ts +328 -0
  58. package/tests/port-client.test.ts +301 -0
  59. package/tests/process-client.test.ts +658 -0
  60. package/tests/sandbox.test.ts +465 -0
  61. package/tests/sse-parser.test.ts +290 -0
  62. package/tests/utility-client.test.ts +266 -0
  63. package/tests/wrangler.jsonc +35 -0
  64. package/tsconfig.json +9 -1
  65. package/vitest.config.ts +31 -0
  66. package/container_src/bun.lock +0 -76
  67. package/container_src/circuit-breaker.ts +0 -121
  68. package/container_src/control-process.ts +0 -784
  69. package/container_src/handler/exec.ts +0 -185
  70. package/container_src/handler/file.ts +0 -457
  71. package/container_src/handler/git.ts +0 -130
  72. package/container_src/handler/ports.ts +0 -314
  73. package/container_src/handler/process.ts +0 -568
  74. package/container_src/handler/session.ts +0 -92
  75. package/container_src/index.ts +0 -601
  76. package/container_src/interpreter-service.ts +0 -276
  77. package/container_src/isolation.ts +0 -1213
  78. package/container_src/mime-processor.ts +0 -255
  79. package/container_src/package.json +0 -18
  80. package/container_src/runtime/executors/javascript/node_executor.ts +0 -123
  81. package/container_src/runtime/executors/python/ipython_executor.py +0 -338
  82. package/container_src/runtime/executors/typescript/ts_executor.ts +0 -138
  83. package/container_src/runtime/process-pool.ts +0 -464
  84. package/container_src/shell-escape.ts +0 -42
  85. package/container_src/startup.sh +0 -11
  86. package/container_src/types.ts +0 -131
  87. package/dist/chunk-32UDXUPC.js +0 -671
  88. package/dist/chunk-32UDXUPC.js.map +0 -1
  89. package/dist/chunk-5DILEXGY.js +0 -85
  90. package/dist/chunk-5DILEXGY.js.map +0 -1
  91. package/dist/chunk-D3U63BZP.js +0 -240
  92. package/dist/chunk-D3U63BZP.js.map +0 -1
  93. package/dist/chunk-FXYPFGOZ.js +0 -129
  94. package/dist/chunk-FXYPFGOZ.js.map +0 -1
  95. package/dist/chunk-JTKON2SH.js.map +0 -1
  96. package/dist/chunk-NNGBXDMY.js.map +0 -1
  97. package/dist/chunk-SQLJNZ3K.js +0 -674
  98. package/dist/chunk-SQLJNZ3K.js.map +0 -1
  99. package/dist/chunk-W7TVRPBG.js +0 -108
  100. package/dist/chunk-W7TVRPBG.js.map +0 -1
  101. package/dist/client-B3RUab0s.d.ts +0 -225
  102. package/dist/client.d.ts +0 -4
  103. package/dist/client.js +0 -7
  104. package/dist/client.js.map +0 -1
  105. package/dist/errors.d.ts +0 -95
  106. package/dist/errors.js +0 -27
  107. package/dist/errors.js.map +0 -1
  108. package/dist/interpreter-client.d.ts +0 -4
  109. package/dist/interpreter-client.js +0 -9
  110. package/dist/interpreter-client.js.map +0 -1
  111. package/dist/interpreter-types.d.ts +0 -259
  112. package/dist/interpreter-types.js +0 -9
  113. package/dist/interpreter-types.js.map +0 -1
  114. package/dist/types.d.ts +0 -453
  115. package/dist/types.js +0 -45
  116. package/dist/types.js.map +0 -1
  117. package/src/client.ts +0 -1048
  118. package/src/errors.ts +0 -219
  119. package/src/interpreter-types.ts +0 -390
  120. package/src/types.ts +0 -571
@@ -0,0 +1,469 @@
1
+ /**
2
+ * Type-safe error classes that wrap ErrorResponse from container
3
+ *
4
+ * All error classes extend SandboxError<TContext> which wraps the full ErrorResponse
5
+ * and provides type-safe accessors for error properties.
6
+ */
7
+
8
+ import type {
9
+ CodeExecutionContext,
10
+ CommandErrorContext,
11
+ CommandNotFoundContext,
12
+ ContextNotFoundContext,ErrorResponse,
13
+ FileExistsContext,
14
+ FileNotFoundContext,
15
+ FileSystemContext,
16
+ GitAuthFailedContext,
17
+ GitBranchNotFoundContext,
18
+ GitErrorContext,
19
+ GitRepositoryNotFoundContext,
20
+ InternalErrorContext,
21
+ InterpreterNotReadyContext,
22
+ InvalidPortContext,
23
+ PortAlreadyExposedContext,
24
+ PortErrorContext,
25
+ PortNotExposedContext,
26
+ ProcessErrorContext,
27
+ ProcessNotFoundContext,
28
+ ValidationFailedContext,
29
+ } from '@repo/shared/errors';
30
+
31
+ /**
32
+ * Base SDK error that wraps ErrorResponse
33
+ * Preserves all error information from container
34
+ */
35
+ export class SandboxError<TContext = Record<string, unknown>> extends Error {
36
+ constructor(public readonly errorResponse: ErrorResponse<TContext>) {
37
+ super(errorResponse.message);
38
+ this.name = 'SandboxError';
39
+ }
40
+
41
+ // Convenience accessors
42
+ get code() { return this.errorResponse.code; }
43
+ get context() { return this.errorResponse.context; }
44
+ get httpStatus() { return this.errorResponse.httpStatus; }
45
+ get operation() { return this.errorResponse.operation; }
46
+ get suggestion() { return this.errorResponse.suggestion; }
47
+ get timestamp() { return this.errorResponse.timestamp; }
48
+ get documentation() { return this.errorResponse.documentation; }
49
+
50
+ // Custom serialization for logging
51
+ toJSON() {
52
+ return {
53
+ name: this.name,
54
+ message: this.message,
55
+ code: this.code,
56
+ context: this.context,
57
+ httpStatus: this.httpStatus,
58
+ operation: this.operation,
59
+ suggestion: this.suggestion,
60
+ timestamp: this.timestamp,
61
+ documentation: this.documentation,
62
+ stack: this.stack
63
+ };
64
+ }
65
+ }
66
+
67
+ // ============================================================================
68
+ // File System Errors
69
+ // ============================================================================
70
+
71
+ /**
72
+ * Error thrown when a file or directory is not found
73
+ */
74
+ export class FileNotFoundError extends SandboxError<FileNotFoundContext> {
75
+ constructor(errorResponse: ErrorResponse<FileNotFoundContext>) {
76
+ super(errorResponse);
77
+ this.name = 'FileNotFoundError';
78
+ }
79
+
80
+ // Type-safe accessors
81
+ get path() { return this.context.path; }
82
+ }
83
+
84
+ /**
85
+ * Error thrown when a file already exists
86
+ */
87
+ export class FileExistsError extends SandboxError<FileExistsContext> {
88
+ constructor(errorResponse: ErrorResponse<FileExistsContext>) {
89
+ super(errorResponse);
90
+ this.name = 'FileExistsError';
91
+ }
92
+
93
+ // Type-safe accessor
94
+ get path() { return this.context.path; }
95
+ }
96
+
97
+ /**
98
+ * Generic file system error (permissions, disk full, etc.)
99
+ */
100
+ export class FileSystemError extends SandboxError<FileSystemContext> {
101
+ constructor(errorResponse: ErrorResponse<FileSystemContext>) {
102
+ super(errorResponse);
103
+ this.name = 'FileSystemError';
104
+ }
105
+
106
+ // Type-safe accessors
107
+ get path() { return this.context.path; }
108
+ get stderr() { return this.context.stderr; }
109
+ get exitCode() { return this.context.exitCode; }
110
+ }
111
+
112
+ /**
113
+ * Error thrown when permission is denied
114
+ */
115
+ export class PermissionDeniedError extends SandboxError<FileSystemContext> {
116
+ constructor(errorResponse: ErrorResponse<FileSystemContext>) {
117
+ super(errorResponse);
118
+ this.name = 'PermissionDeniedError';
119
+ }
120
+
121
+ get path() { return this.context.path; }
122
+ }
123
+
124
+ // ============================================================================
125
+ // Command Errors
126
+ // ============================================================================
127
+
128
+ /**
129
+ * Error thrown when a command is not found
130
+ */
131
+ export class CommandNotFoundError extends SandboxError<CommandNotFoundContext> {
132
+ constructor(errorResponse: ErrorResponse<CommandNotFoundContext>) {
133
+ super(errorResponse);
134
+ this.name = 'CommandNotFoundError';
135
+ }
136
+
137
+ // Type-safe accessor
138
+ get command() { return this.context.command; }
139
+ }
140
+
141
+ /**
142
+ * Generic command execution error
143
+ */
144
+ export class CommandError extends SandboxError<CommandErrorContext> {
145
+ constructor(errorResponse: ErrorResponse<CommandErrorContext>) {
146
+ super(errorResponse);
147
+ this.name = 'CommandError';
148
+ }
149
+
150
+ // Type-safe accessors
151
+ get command() { return this.context.command; }
152
+ get exitCode() { return this.context.exitCode; }
153
+ get stdout() { return this.context.stdout; }
154
+ get stderr() { return this.context.stderr; }
155
+ }
156
+
157
+ // ============================================================================
158
+ // Process Errors
159
+ // ============================================================================
160
+
161
+ /**
162
+ * Error thrown when a process is not found
163
+ */
164
+ export class ProcessNotFoundError extends SandboxError<ProcessNotFoundContext> {
165
+ constructor(errorResponse: ErrorResponse<ProcessNotFoundContext>) {
166
+ super(errorResponse);
167
+ this.name = 'ProcessNotFoundError';
168
+ }
169
+
170
+ // Type-safe accessor
171
+ get processId() { return this.context.processId; }
172
+ }
173
+
174
+ /**
175
+ * Generic process error
176
+ */
177
+ export class ProcessError extends SandboxError<ProcessErrorContext> {
178
+ constructor(errorResponse: ErrorResponse<ProcessErrorContext>) {
179
+ super(errorResponse);
180
+ this.name = 'ProcessError';
181
+ }
182
+
183
+ // Type-safe accessors
184
+ get processId() { return this.context.processId; }
185
+ get pid() { return this.context.pid; }
186
+ get exitCode() { return this.context.exitCode; }
187
+ get stderr() { return this.context.stderr; }
188
+ }
189
+
190
+ // ============================================================================
191
+ // Port Errors
192
+ // ============================================================================
193
+
194
+ /**
195
+ * Error thrown when a port is already exposed
196
+ */
197
+ export class PortAlreadyExposedError extends SandboxError<PortAlreadyExposedContext> {
198
+ constructor(errorResponse: ErrorResponse<PortAlreadyExposedContext>) {
199
+ super(errorResponse);
200
+ this.name = 'PortAlreadyExposedError';
201
+ }
202
+
203
+ // Type-safe accessors
204
+ get port() { return this.context.port; }
205
+ get portName() { return this.context.portName; }
206
+ }
207
+
208
+ /**
209
+ * Error thrown when a port is not exposed
210
+ */
211
+ export class PortNotExposedError extends SandboxError<PortNotExposedContext> {
212
+ constructor(errorResponse: ErrorResponse<PortNotExposedContext>) {
213
+ super(errorResponse);
214
+ this.name = 'PortNotExposedError';
215
+ }
216
+
217
+ // Type-safe accessor
218
+ get port() { return this.context.port; }
219
+ }
220
+
221
+ /**
222
+ * Error thrown when a port number is invalid
223
+ */
224
+ export class InvalidPortError extends SandboxError<InvalidPortContext> {
225
+ constructor(errorResponse: ErrorResponse<InvalidPortContext>) {
226
+ super(errorResponse);
227
+ this.name = 'InvalidPortError';
228
+ }
229
+
230
+ // Type-safe accessors
231
+ get port() { return this.context.port; }
232
+ get reason() { return this.context.reason; }
233
+ }
234
+
235
+ /**
236
+ * Error thrown when a service on a port is not responding
237
+ */
238
+ export class ServiceNotRespondingError extends SandboxError<PortErrorContext> {
239
+ constructor(errorResponse: ErrorResponse<PortErrorContext>) {
240
+ super(errorResponse);
241
+ this.name = 'ServiceNotRespondingError';
242
+ }
243
+
244
+ // Type-safe accessors
245
+ get port() { return this.context.port; }
246
+ get portName() { return this.context.portName; }
247
+ }
248
+
249
+ /**
250
+ * Error thrown when a port is already in use
251
+ */
252
+ export class PortInUseError extends SandboxError<PortErrorContext> {
253
+ constructor(errorResponse: ErrorResponse<PortErrorContext>) {
254
+ super(errorResponse);
255
+ this.name = 'PortInUseError';
256
+ }
257
+
258
+ // Type-safe accessor
259
+ get port() { return this.context.port; }
260
+ }
261
+
262
+ /**
263
+ * Generic port operation error
264
+ */
265
+ export class PortError extends SandboxError<PortErrorContext> {
266
+ constructor(errorResponse: ErrorResponse<PortErrorContext>) {
267
+ super(errorResponse);
268
+ this.name = 'PortError';
269
+ }
270
+
271
+ // Type-safe accessors
272
+ get port() { return this.context.port; }
273
+ get portName() { return this.context.portName; }
274
+ get stderr() { return this.context.stderr; }
275
+ }
276
+
277
+ /**
278
+ * Error thrown when port exposure requires a custom domain
279
+ */
280
+ export class CustomDomainRequiredError extends SandboxError<InternalErrorContext> {
281
+ constructor(errorResponse: ErrorResponse<InternalErrorContext>) {
282
+ super(errorResponse);
283
+ this.name = 'CustomDomainRequiredError';
284
+ }
285
+ }
286
+
287
+ // ============================================================================
288
+ // Git Errors
289
+ // ============================================================================
290
+
291
+ /**
292
+ * Error thrown when a git repository is not found
293
+ */
294
+ export class GitRepositoryNotFoundError extends SandboxError<GitRepositoryNotFoundContext> {
295
+ constructor(errorResponse: ErrorResponse<GitRepositoryNotFoundContext>) {
296
+ super(errorResponse);
297
+ this.name = 'GitRepositoryNotFoundError';
298
+ }
299
+
300
+ // Type-safe accessor
301
+ get repository() { return this.context.repository; }
302
+ }
303
+
304
+ /**
305
+ * Error thrown when git authentication fails
306
+ */
307
+ export class GitAuthenticationError extends SandboxError<GitAuthFailedContext> {
308
+ constructor(errorResponse: ErrorResponse<GitAuthFailedContext>) {
309
+ super(errorResponse);
310
+ this.name = 'GitAuthenticationError';
311
+ }
312
+
313
+ // Type-safe accessor
314
+ get repository() { return this.context.repository; }
315
+ }
316
+
317
+ /**
318
+ * Error thrown when a git branch is not found
319
+ */
320
+ export class GitBranchNotFoundError extends SandboxError<GitBranchNotFoundContext> {
321
+ constructor(errorResponse: ErrorResponse<GitBranchNotFoundContext>) {
322
+ super(errorResponse);
323
+ this.name = 'GitBranchNotFoundError';
324
+ }
325
+
326
+ // Type-safe accessors
327
+ get branch() { return this.context.branch; }
328
+ get repository() { return this.context.repository; }
329
+ }
330
+
331
+ /**
332
+ * Error thrown when a git network operation fails
333
+ */
334
+ export class GitNetworkError extends SandboxError<GitErrorContext> {
335
+ constructor(errorResponse: ErrorResponse<GitErrorContext>) {
336
+ super(errorResponse);
337
+ this.name = 'GitNetworkError';
338
+ }
339
+
340
+ // Type-safe accessors
341
+ get repository() { return this.context.repository; }
342
+ get branch() { return this.context.branch; }
343
+ get targetDir() { return this.context.targetDir; }
344
+ }
345
+
346
+ /**
347
+ * Error thrown when git clone fails
348
+ */
349
+ export class GitCloneError extends SandboxError<GitErrorContext> {
350
+ constructor(errorResponse: ErrorResponse<GitErrorContext>) {
351
+ super(errorResponse);
352
+ this.name = 'GitCloneError';
353
+ }
354
+
355
+ // Type-safe accessors
356
+ get repository() { return this.context.repository; }
357
+ get targetDir() { return this.context.targetDir; }
358
+ get stderr() { return this.context.stderr; }
359
+ get exitCode() { return this.context.exitCode; }
360
+ }
361
+
362
+ /**
363
+ * Error thrown when git checkout fails
364
+ */
365
+ export class GitCheckoutError extends SandboxError<GitErrorContext> {
366
+ constructor(errorResponse: ErrorResponse<GitErrorContext>) {
367
+ super(errorResponse);
368
+ this.name = 'GitCheckoutError';
369
+ }
370
+
371
+ // Type-safe accessors
372
+ get branch() { return this.context.branch; }
373
+ get repository() { return this.context.repository; }
374
+ get stderr() { return this.context.stderr; }
375
+ }
376
+
377
+ /**
378
+ * Error thrown when a git URL is invalid
379
+ */
380
+ export class InvalidGitUrlError extends SandboxError<ValidationFailedContext> {
381
+ constructor(errorResponse: ErrorResponse<ValidationFailedContext>) {
382
+ super(errorResponse);
383
+ this.name = 'InvalidGitUrlError';
384
+ }
385
+
386
+ // Type-safe accessor
387
+ get validationErrors() { return this.context.validationErrors; }
388
+ }
389
+
390
+ /**
391
+ * Generic git operation error
392
+ */
393
+ export class GitError extends SandboxError<GitErrorContext> {
394
+ constructor(errorResponse: ErrorResponse<GitErrorContext>) {
395
+ super(errorResponse);
396
+ this.name = 'GitError';
397
+ }
398
+
399
+ // Type-safe accessors
400
+ get repository() { return this.context.repository; }
401
+ get branch() { return this.context.branch; }
402
+ get targetDir() { return this.context.targetDir; }
403
+ get stderr() { return this.context.stderr; }
404
+ get exitCode() { return this.context.exitCode; }
405
+ }
406
+
407
+ // ============================================================================
408
+ // Code Interpreter Errors
409
+ // ============================================================================
410
+
411
+ /**
412
+ * Error thrown when interpreter is not ready
413
+ */
414
+ export class InterpreterNotReadyError extends SandboxError<InterpreterNotReadyContext> {
415
+ constructor(errorResponse: ErrorResponse<InterpreterNotReadyContext>) {
416
+ super(errorResponse);
417
+ this.name = 'InterpreterNotReadyError';
418
+ }
419
+
420
+ // Type-safe accessors
421
+ get retryAfter() { return this.context.retryAfter; }
422
+ get progress() { return this.context.progress; }
423
+ }
424
+
425
+ /**
426
+ * Error thrown when a context is not found
427
+ */
428
+ export class ContextNotFoundError extends SandboxError<ContextNotFoundContext> {
429
+ constructor(errorResponse: ErrorResponse<ContextNotFoundContext>) {
430
+ super(errorResponse);
431
+ this.name = 'ContextNotFoundError';
432
+ }
433
+
434
+ // Type-safe accessor
435
+ get contextId() { return this.context.contextId; }
436
+ }
437
+
438
+ /**
439
+ * Error thrown when code execution fails
440
+ */
441
+ export class CodeExecutionError extends SandboxError<CodeExecutionContext> {
442
+ constructor(errorResponse: ErrorResponse<CodeExecutionContext>) {
443
+ super(errorResponse);
444
+ this.name = 'CodeExecutionError';
445
+ }
446
+
447
+ // Type-safe accessors
448
+ get contextId() { return this.context.contextId; }
449
+ get ename() { return this.context.ename; }
450
+ get evalue() { return this.context.evalue; }
451
+ get traceback() { return this.context.traceback; }
452
+ }
453
+
454
+ // ============================================================================
455
+ // Validation Errors
456
+ // ============================================================================
457
+
458
+ /**
459
+ * Error thrown when validation fails
460
+ */
461
+ export class ValidationFailedError extends SandboxError<ValidationFailedContext> {
462
+ constructor(errorResponse: ErrorResponse<ValidationFailedContext>) {
463
+ super(errorResponse);
464
+ this.name = 'ValidationFailedError';
465
+ }
466
+
467
+ // Type-safe accessor
468
+ get validationErrors() { return this.context.validationErrors; }
469
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * SDK Error System
3
+ *
4
+ * This module provides type-safe error classes that wrap ErrorResponse from the container.
5
+ * All error classes provide:
6
+ * - Type-safe accessors for error context
7
+ * - instanceof checks for error handling
8
+ * - Full ErrorResponse preservation via errorResponse property
9
+ * - Custom toJSON() for logging
10
+ *
11
+ * @example Basic error handling
12
+ * ```typescript
13
+ * import { FileNotFoundError } from './errors';
14
+ *
15
+ * try {
16
+ * await sandbox.file.read('/missing.txt');
17
+ * } catch (error) {
18
+ * if (error instanceof FileNotFoundError) {
19
+ * console.log(error.path); // Type-safe! string
20
+ * console.log(error.operation); // Type-safe! OperationType
21
+ * console.log(error.code); // "FILE_NOT_FOUND"
22
+ * console.log(error.suggestion); // Helpful message
23
+ * }
24
+ * }
25
+ * ```
26
+ *
27
+ * @example Error serialization
28
+ * ```typescript
29
+ * try {
30
+ * await sandbox.file.read('/missing.txt');
31
+ * } catch (error) {
32
+ * // Full context available
33
+ * console.log(error.errorResponse);
34
+ *
35
+ * // Pretty-prints with custom toJSON
36
+ * console.log(JSON.stringify(error, null, 2));
37
+ * }
38
+ * ```
39
+ */
40
+
41
+ // Re-export context types for advanced usage
42
+ export type {
43
+ CodeExecutionContext,
44
+ CommandErrorContext,
45
+ CommandNotFoundContext,
46
+ ContextNotFoundContext,ErrorCodeType, ErrorResponse,
47
+ FileExistsContext,
48
+ FileNotFoundContext,
49
+ FileSystemContext,
50
+ GitAuthFailedContext,
51
+ GitBranchNotFoundContext,
52
+ GitErrorContext,
53
+ GitRepositoryNotFoundContext,
54
+ InternalErrorContext,
55
+ InterpreterNotReadyContext,
56
+ InvalidPortContext,OperationType,
57
+ PortAlreadyExposedContext,
58
+ PortErrorContext,
59
+ PortNotExposedContext,
60
+ ProcessErrorContext,
61
+ ProcessNotFoundContext,
62
+ ValidationFailedContext,} from '@repo/shared/errors';
63
+ // Re-export shared types and constants
64
+ export { ErrorCode, Operation } from '@repo/shared/errors';
65
+
66
+ // Export adapter function
67
+ export { createErrorFromResponse } from './adapter';
68
+ // Export all error classes
69
+ export {
70
+ CodeExecutionError,
71
+ CommandError,
72
+ // Command Errors
73
+ CommandNotFoundError,
74
+ ContextNotFoundError,
75
+ CustomDomainRequiredError,
76
+ FileExistsError,
77
+ // File System Errors
78
+ FileNotFoundError,
79
+ FileSystemError,
80
+ GitAuthenticationError,
81
+ GitBranchNotFoundError,
82
+ GitCheckoutError,
83
+ GitCloneError,
84
+ GitError,
85
+ GitNetworkError,
86
+ // Git Errors
87
+ GitRepositoryNotFoundError,
88
+ // Code Interpreter Errors
89
+ InterpreterNotReadyError,
90
+ InvalidGitUrlError,
91
+ InvalidPortError,
92
+ PermissionDeniedError,
93
+ // Port Errors
94
+ PortAlreadyExposedError,
95
+ PortError,
96
+ PortInUseError,
97
+ PortNotExposedError,
98
+ ProcessError,
99
+ // Process Errors
100
+ ProcessNotFoundError,
101
+ SandboxError,
102
+ ServiceNotRespondingError,
103
+ // Validation Errors
104
+ ValidationFailedError,
105
+ } from './classes';