@cloudflare/sandbox 0.13.0-next.649.1 → 0.13.0-next.681.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 +6 -11
- package/README.md +2 -2
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/index.js +68 -49
- package/dist/bridge/index.js.map +1 -1
- package/dist/codes-y-U76vnQ.d.ts +79 -0
- package/dist/codes-y-U76vnQ.d.ts.map +1 -0
- package/dist/contexts-DY1LHU1v.d.ts +327 -0
- package/dist/contexts-DY1LHU1v.d.ts.map +1 -0
- package/dist/{dist-mAH_7Ui7.js → dist-BStBkGIC.js} +50 -93
- package/dist/dist-BStBkGIC.js.map +1 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.js +4 -0
- package/dist/errors-ewgSNicb.js +741 -0
- package/dist/errors-ewgSNicb.js.map +1 -0
- package/dist/{errors-CpoDEfUZ.js → errors-k3B8orjH.js} +41 -4
- package/dist/errors-k3B8orjH.js.map +1 -0
- package/dist/extensions/index.d.ts +2 -0
- package/dist/extensions/index.js +4 -0
- package/dist/extensions-CepYdzro.js +191 -0
- package/dist/extensions-CepYdzro.js.map +1 -0
- package/dist/git/index.d.ts +74 -0
- package/dist/git/index.d.ts.map +1 -0
- package/dist/git/index.js +345 -0
- package/dist/git/index.js.map +1 -0
- package/dist/index-B7QgIs0N.d.ts +1841 -0
- package/dist/index-B7QgIs0N.d.ts.map +1 -0
- package/dist/index-Dy6u9r60.d.ts +390 -0
- package/dist/index-Dy6u9r60.d.ts.map +1 -0
- package/dist/index.d.ts +27 -189
- 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 +309 -0
- package/dist/interpreter/index.d.ts.map +1 -0
- package/dist/interpreter/index.js +264 -0
- package/dist/interpreter/index.js.map +1 -0
- package/dist/openai/index.d.ts +3 -2
- package/dist/openai/index.d.ts.map +1 -1
- package/dist/openai/index.js +2 -2
- package/dist/openai/index.js.map +1 -1
- package/dist/opencode/index.d.ts +137 -160
- package/dist/opencode/index.d.ts.map +1 -1
- package/dist/opencode/index.js +269 -159
- package/dist/opencode/index.js.map +1 -1
- package/dist/sandbox-DHNO89IF.d.ts +828 -0
- package/dist/sandbox-DHNO89IF.d.ts.map +1 -0
- package/dist/{sandbox-B-FLGbkP.js → sandbox-boKWPIcd.js} +8214 -7267
- package/dist/sandbox-boKWPIcd.js.map +1 -0
- package/dist/sidecar/index.d.ts +77 -0
- package/dist/sidecar/index.d.ts.map +1 -0
- package/dist/sidecar/index.js +201 -0
- package/dist/sidecar/index.js.map +1 -0
- package/dist/xterm/index.d.ts +6 -6
- package/dist/xterm/index.d.ts.map +1 -1
- package/dist/xterm/index.js +6 -6
- package/dist/xterm/index.js.map +1 -1
- package/package.json +36 -3
- package/dist/contexts-DPFhc2nR.d.ts +0 -238
- package/dist/contexts-DPFhc2nR.d.ts.map +0 -1
- package/dist/dist-mAH_7Ui7.js.map +0 -1
- package/dist/errors-CpoDEfUZ.js.map +0 -1
- package/dist/sandbox-44kEJjAc.d.ts +0 -2652
- package/dist/sandbox-44kEJjAc.d.ts.map +0 -1
- package/dist/sandbox-B-FLGbkP.js.map +0 -1
|
@@ -0,0 +1,741 @@
|
|
|
1
|
+
import { i as ErrorCode } from "./errors-k3B8orjH.js";
|
|
2
|
+
|
|
3
|
+
//#region src/errors/classes.ts
|
|
4
|
+
/**
|
|
5
|
+
* Base SDK error that wraps ErrorResponse
|
|
6
|
+
* Preserves all error information from container
|
|
7
|
+
*/
|
|
8
|
+
var SandboxError = class extends Error {
|
|
9
|
+
constructor(errorResponse, options) {
|
|
10
|
+
super(errorResponse.message, options);
|
|
11
|
+
this.errorResponse = errorResponse;
|
|
12
|
+
this.name = "SandboxError";
|
|
13
|
+
}
|
|
14
|
+
get code() {
|
|
15
|
+
return this.errorResponse.code;
|
|
16
|
+
}
|
|
17
|
+
get context() {
|
|
18
|
+
return this.errorResponse.context;
|
|
19
|
+
}
|
|
20
|
+
get httpStatus() {
|
|
21
|
+
return this.errorResponse.httpStatus;
|
|
22
|
+
}
|
|
23
|
+
get operation() {
|
|
24
|
+
return this.errorResponse.operation;
|
|
25
|
+
}
|
|
26
|
+
get suggestion() {
|
|
27
|
+
return this.errorResponse.suggestion;
|
|
28
|
+
}
|
|
29
|
+
get timestamp() {
|
|
30
|
+
return this.errorResponse.timestamp;
|
|
31
|
+
}
|
|
32
|
+
get documentation() {
|
|
33
|
+
return this.errorResponse.documentation;
|
|
34
|
+
}
|
|
35
|
+
toJSON() {
|
|
36
|
+
return {
|
|
37
|
+
name: this.name,
|
|
38
|
+
message: this.message,
|
|
39
|
+
code: this.code,
|
|
40
|
+
context: this.context,
|
|
41
|
+
httpStatus: this.httpStatus,
|
|
42
|
+
operation: this.operation,
|
|
43
|
+
suggestion: this.suggestion,
|
|
44
|
+
timestamp: this.timestamp,
|
|
45
|
+
documentation: this.documentation,
|
|
46
|
+
stack: this.stack
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Error thrown when a file or directory is not found
|
|
52
|
+
*/
|
|
53
|
+
var FileNotFoundError = class extends SandboxError {
|
|
54
|
+
constructor(errorResponse) {
|
|
55
|
+
super(errorResponse);
|
|
56
|
+
this.name = "FileNotFoundError";
|
|
57
|
+
}
|
|
58
|
+
get path() {
|
|
59
|
+
return this.context.path;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Error thrown when a file already exists
|
|
64
|
+
*/
|
|
65
|
+
var FileExistsError = class extends SandboxError {
|
|
66
|
+
constructor(errorResponse) {
|
|
67
|
+
super(errorResponse);
|
|
68
|
+
this.name = "FileExistsError";
|
|
69
|
+
}
|
|
70
|
+
get path() {
|
|
71
|
+
return this.context.path;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Error thrown when a file is too large
|
|
76
|
+
*/
|
|
77
|
+
var FileTooLargeError = class extends SandboxError {
|
|
78
|
+
constructor(errorResponse) {
|
|
79
|
+
super(errorResponse);
|
|
80
|
+
this.name = "FileTooLargeError";
|
|
81
|
+
}
|
|
82
|
+
get path() {
|
|
83
|
+
return this.context.path;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Generic file system error (permissions, disk full, etc.)
|
|
88
|
+
*/
|
|
89
|
+
var FileSystemError = class extends SandboxError {
|
|
90
|
+
constructor(errorResponse) {
|
|
91
|
+
super(errorResponse);
|
|
92
|
+
this.name = "FileSystemError";
|
|
93
|
+
}
|
|
94
|
+
get path() {
|
|
95
|
+
return this.context.path;
|
|
96
|
+
}
|
|
97
|
+
get stderr() {
|
|
98
|
+
return this.context.stderr;
|
|
99
|
+
}
|
|
100
|
+
get exitCode() {
|
|
101
|
+
return this.context.exitCode;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Error thrown when permission is denied
|
|
106
|
+
*/
|
|
107
|
+
var PermissionDeniedError = class extends SandboxError {
|
|
108
|
+
constructor(errorResponse) {
|
|
109
|
+
super(errorResponse);
|
|
110
|
+
this.name = "PermissionDeniedError";
|
|
111
|
+
}
|
|
112
|
+
get path() {
|
|
113
|
+
return this.context.path;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Error thrown when a command is not found
|
|
118
|
+
*/
|
|
119
|
+
var CommandNotFoundError = class extends SandboxError {
|
|
120
|
+
constructor(errorResponse) {
|
|
121
|
+
super(errorResponse);
|
|
122
|
+
this.name = "CommandNotFoundError";
|
|
123
|
+
}
|
|
124
|
+
get command() {
|
|
125
|
+
return this.context.command;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Generic command execution error
|
|
130
|
+
*/
|
|
131
|
+
var CommandError = class extends SandboxError {
|
|
132
|
+
constructor(errorResponse) {
|
|
133
|
+
super(errorResponse);
|
|
134
|
+
this.name = "CommandError";
|
|
135
|
+
}
|
|
136
|
+
get command() {
|
|
137
|
+
return this.context.command;
|
|
138
|
+
}
|
|
139
|
+
get exitCode() {
|
|
140
|
+
return this.context.exitCode;
|
|
141
|
+
}
|
|
142
|
+
get stdout() {
|
|
143
|
+
return this.context.stdout;
|
|
144
|
+
}
|
|
145
|
+
get stderr() {
|
|
146
|
+
return this.context.stderr;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Error thrown when a process is not found
|
|
151
|
+
*/
|
|
152
|
+
var ProcessNotFoundError = class extends SandboxError {
|
|
153
|
+
constructor(errorResponse) {
|
|
154
|
+
super(errorResponse);
|
|
155
|
+
this.name = "ProcessNotFoundError";
|
|
156
|
+
}
|
|
157
|
+
get processId() {
|
|
158
|
+
return this.context.processId;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Generic process error
|
|
163
|
+
*/
|
|
164
|
+
var ProcessError = class extends SandboxError {
|
|
165
|
+
constructor(errorResponse) {
|
|
166
|
+
super(errorResponse);
|
|
167
|
+
this.name = "ProcessError";
|
|
168
|
+
}
|
|
169
|
+
get processId() {
|
|
170
|
+
return this.context.processId;
|
|
171
|
+
}
|
|
172
|
+
get pid() {
|
|
173
|
+
return this.context.pid;
|
|
174
|
+
}
|
|
175
|
+
get exitCode() {
|
|
176
|
+
return this.context.exitCode;
|
|
177
|
+
}
|
|
178
|
+
get stderr() {
|
|
179
|
+
return this.context.stderr;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Error thrown when a session already exists
|
|
184
|
+
*/
|
|
185
|
+
var SessionAlreadyExistsError = class extends SandboxError {
|
|
186
|
+
constructor(errorResponse) {
|
|
187
|
+
super(errorResponse);
|
|
188
|
+
this.name = "SessionAlreadyExistsError";
|
|
189
|
+
}
|
|
190
|
+
get sessionId() {
|
|
191
|
+
return this.context.sessionId;
|
|
192
|
+
}
|
|
193
|
+
get containerPlacementId() {
|
|
194
|
+
return this.context.containerPlacementId;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Error thrown when a session was destroyed while a command was executing
|
|
199
|
+
*/
|
|
200
|
+
var SessionDestroyedError = class extends SandboxError {
|
|
201
|
+
constructor(errorResponse) {
|
|
202
|
+
super(errorResponse);
|
|
203
|
+
this.name = "SessionDestroyedError";
|
|
204
|
+
}
|
|
205
|
+
get sessionId() {
|
|
206
|
+
return this.context.sessionId;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Error thrown when a session's underlying shell exited without an explicit
|
|
211
|
+
* `destroy()` call (user ran `exit`, the shell crashed, or a child process
|
|
212
|
+
* took the shell down). The session-local state is gone, but the next call
|
|
213
|
+
* with the same sessionId will transparently start a fresh session.
|
|
214
|
+
*/
|
|
215
|
+
var SessionTerminatedError = class extends SandboxError {
|
|
216
|
+
constructor(errorResponse) {
|
|
217
|
+
super(errorResponse);
|
|
218
|
+
this.name = "SessionTerminatedError";
|
|
219
|
+
}
|
|
220
|
+
get sessionId() {
|
|
221
|
+
return this.context.sessionId;
|
|
222
|
+
}
|
|
223
|
+
get exitCode() {
|
|
224
|
+
return this.context.exitCode;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Compatibility error for legacy port exposure registry responses.
|
|
229
|
+
*/
|
|
230
|
+
var PortAlreadyExposedError = class extends SandboxError {
|
|
231
|
+
constructor(errorResponse) {
|
|
232
|
+
super(errorResponse);
|
|
233
|
+
this.name = "PortAlreadyExposedError";
|
|
234
|
+
}
|
|
235
|
+
get port() {
|
|
236
|
+
return this.context.port;
|
|
237
|
+
}
|
|
238
|
+
get portName() {
|
|
239
|
+
return this.context.portName;
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Compatibility error for legacy port exposure registry responses.
|
|
244
|
+
*/
|
|
245
|
+
var PortNotExposedError = class extends SandboxError {
|
|
246
|
+
constructor(errorResponse) {
|
|
247
|
+
super(errorResponse);
|
|
248
|
+
this.name = "PortNotExposedError";
|
|
249
|
+
}
|
|
250
|
+
get port() {
|
|
251
|
+
return this.context.port;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Error thrown when a port number is invalid
|
|
256
|
+
*/
|
|
257
|
+
var InvalidPortError = class extends SandboxError {
|
|
258
|
+
constructor(errorResponse) {
|
|
259
|
+
super(errorResponse);
|
|
260
|
+
this.name = "InvalidPortError";
|
|
261
|
+
}
|
|
262
|
+
get port() {
|
|
263
|
+
return this.context.port;
|
|
264
|
+
}
|
|
265
|
+
get reason() {
|
|
266
|
+
return this.context.reason;
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Error thrown when a service on a port is not responding
|
|
271
|
+
*/
|
|
272
|
+
var ServiceNotRespondingError = class extends SandboxError {
|
|
273
|
+
constructor(errorResponse) {
|
|
274
|
+
super(errorResponse);
|
|
275
|
+
this.name = "ServiceNotRespondingError";
|
|
276
|
+
}
|
|
277
|
+
get port() {
|
|
278
|
+
return this.context.port;
|
|
279
|
+
}
|
|
280
|
+
get portName() {
|
|
281
|
+
return this.context.portName;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Error thrown when a port is already in use
|
|
286
|
+
*/
|
|
287
|
+
var PortInUseError = class extends SandboxError {
|
|
288
|
+
constructor(errorResponse) {
|
|
289
|
+
super(errorResponse);
|
|
290
|
+
this.name = "PortInUseError";
|
|
291
|
+
}
|
|
292
|
+
get port() {
|
|
293
|
+
return this.context.port;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Generic port operation error
|
|
298
|
+
*/
|
|
299
|
+
var PortError = class extends SandboxError {
|
|
300
|
+
constructor(errorResponse) {
|
|
301
|
+
super(errorResponse);
|
|
302
|
+
this.name = "PortError";
|
|
303
|
+
}
|
|
304
|
+
get port() {
|
|
305
|
+
return this.context.port;
|
|
306
|
+
}
|
|
307
|
+
get portName() {
|
|
308
|
+
return this.context.portName;
|
|
309
|
+
}
|
|
310
|
+
get stderr() {
|
|
311
|
+
return this.context.stderr;
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* Error thrown when port exposure requires a custom domain
|
|
316
|
+
*/
|
|
317
|
+
var CustomDomainRequiredError = class extends SandboxError {
|
|
318
|
+
constructor(errorResponse) {
|
|
319
|
+
super(errorResponse);
|
|
320
|
+
this.name = "CustomDomainRequiredError";
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Error thrown when a git repository is not found
|
|
325
|
+
*/
|
|
326
|
+
var GitRepositoryNotFoundError = class extends SandboxError {
|
|
327
|
+
constructor(errorResponse) {
|
|
328
|
+
super(errorResponse);
|
|
329
|
+
this.name = "GitRepositoryNotFoundError";
|
|
330
|
+
}
|
|
331
|
+
get repository() {
|
|
332
|
+
return this.context.repository;
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* Error thrown when git authentication fails
|
|
337
|
+
*/
|
|
338
|
+
var GitAuthenticationError = class extends SandboxError {
|
|
339
|
+
constructor(errorResponse) {
|
|
340
|
+
super(errorResponse);
|
|
341
|
+
this.name = "GitAuthenticationError";
|
|
342
|
+
}
|
|
343
|
+
get repository() {
|
|
344
|
+
return this.context.repository;
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* Error thrown when a git branch is not found
|
|
349
|
+
*/
|
|
350
|
+
var GitBranchNotFoundError = class extends SandboxError {
|
|
351
|
+
constructor(errorResponse) {
|
|
352
|
+
super(errorResponse);
|
|
353
|
+
this.name = "GitBranchNotFoundError";
|
|
354
|
+
}
|
|
355
|
+
get branch() {
|
|
356
|
+
return this.context.branch;
|
|
357
|
+
}
|
|
358
|
+
get repository() {
|
|
359
|
+
return this.context.repository;
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
/**
|
|
363
|
+
* Error thrown when a git network operation fails
|
|
364
|
+
*/
|
|
365
|
+
var GitNetworkError = class extends SandboxError {
|
|
366
|
+
constructor(errorResponse) {
|
|
367
|
+
super(errorResponse);
|
|
368
|
+
this.name = "GitNetworkError";
|
|
369
|
+
}
|
|
370
|
+
get repository() {
|
|
371
|
+
return this.context.repository;
|
|
372
|
+
}
|
|
373
|
+
get branch() {
|
|
374
|
+
return this.context.branch;
|
|
375
|
+
}
|
|
376
|
+
get targetDir() {
|
|
377
|
+
return this.context.targetDir;
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* Error thrown when git clone fails
|
|
382
|
+
*/
|
|
383
|
+
var GitCloneError = class extends SandboxError {
|
|
384
|
+
constructor(errorResponse) {
|
|
385
|
+
super(errorResponse);
|
|
386
|
+
this.name = "GitCloneError";
|
|
387
|
+
}
|
|
388
|
+
get repository() {
|
|
389
|
+
return this.context.repository;
|
|
390
|
+
}
|
|
391
|
+
get targetDir() {
|
|
392
|
+
return this.context.targetDir;
|
|
393
|
+
}
|
|
394
|
+
get stderr() {
|
|
395
|
+
return this.context.stderr;
|
|
396
|
+
}
|
|
397
|
+
get exitCode() {
|
|
398
|
+
return this.context.exitCode;
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* Error thrown when git checkout fails
|
|
403
|
+
*/
|
|
404
|
+
var GitCheckoutError = class extends SandboxError {
|
|
405
|
+
constructor(errorResponse) {
|
|
406
|
+
super(errorResponse);
|
|
407
|
+
this.name = "GitCheckoutError";
|
|
408
|
+
}
|
|
409
|
+
get branch() {
|
|
410
|
+
return this.context.branch;
|
|
411
|
+
}
|
|
412
|
+
get repository() {
|
|
413
|
+
return this.context.repository;
|
|
414
|
+
}
|
|
415
|
+
get stderr() {
|
|
416
|
+
return this.context.stderr;
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
/**
|
|
420
|
+
* Error thrown when a git URL is invalid
|
|
421
|
+
*/
|
|
422
|
+
var InvalidGitUrlError = class extends SandboxError {
|
|
423
|
+
constructor(errorResponse) {
|
|
424
|
+
super(errorResponse);
|
|
425
|
+
this.name = "InvalidGitUrlError";
|
|
426
|
+
}
|
|
427
|
+
get validationErrors() {
|
|
428
|
+
return this.context.validationErrors;
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
/**
|
|
432
|
+
* Generic git operation error
|
|
433
|
+
*/
|
|
434
|
+
var GitError = class extends SandboxError {
|
|
435
|
+
constructor(errorResponse) {
|
|
436
|
+
super(errorResponse);
|
|
437
|
+
this.name = "GitError";
|
|
438
|
+
}
|
|
439
|
+
get repository() {
|
|
440
|
+
return this.context.repository;
|
|
441
|
+
}
|
|
442
|
+
get branch() {
|
|
443
|
+
return this.context.branch;
|
|
444
|
+
}
|
|
445
|
+
get targetDir() {
|
|
446
|
+
return this.context.targetDir;
|
|
447
|
+
}
|
|
448
|
+
get stderr() {
|
|
449
|
+
return this.context.stderr;
|
|
450
|
+
}
|
|
451
|
+
get exitCode() {
|
|
452
|
+
return this.context.exitCode;
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* Error thrown when interpreter is not ready
|
|
457
|
+
*/
|
|
458
|
+
var InterpreterNotReadyError = class extends SandboxError {
|
|
459
|
+
constructor(errorResponse) {
|
|
460
|
+
super(errorResponse);
|
|
461
|
+
this.name = "InterpreterNotReadyError";
|
|
462
|
+
}
|
|
463
|
+
get retryAfter() {
|
|
464
|
+
return this.context.retryAfter;
|
|
465
|
+
}
|
|
466
|
+
get progress() {
|
|
467
|
+
return this.context.progress;
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
/**
|
|
471
|
+
* Error thrown when a context is not found
|
|
472
|
+
*/
|
|
473
|
+
var ContextNotFoundError = class extends SandboxError {
|
|
474
|
+
constructor(errorResponse) {
|
|
475
|
+
super(errorResponse);
|
|
476
|
+
this.name = "ContextNotFoundError";
|
|
477
|
+
}
|
|
478
|
+
get contextId() {
|
|
479
|
+
return this.context.contextId;
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
/**
|
|
483
|
+
* Error thrown when code execution fails
|
|
484
|
+
*/
|
|
485
|
+
var CodeExecutionError = class extends SandboxError {
|
|
486
|
+
constructor(errorResponse) {
|
|
487
|
+
super(errorResponse);
|
|
488
|
+
this.name = "CodeExecutionError";
|
|
489
|
+
}
|
|
490
|
+
get contextId() {
|
|
491
|
+
return this.context.contextId;
|
|
492
|
+
}
|
|
493
|
+
get ename() {
|
|
494
|
+
return this.context.ename;
|
|
495
|
+
}
|
|
496
|
+
get evalue() {
|
|
497
|
+
return this.context.evalue;
|
|
498
|
+
}
|
|
499
|
+
get traceback() {
|
|
500
|
+
return this.context.traceback;
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* Error thrown when validation fails
|
|
505
|
+
*/
|
|
506
|
+
var ValidationFailedError = class extends SandboxError {
|
|
507
|
+
constructor(errorResponse) {
|
|
508
|
+
super(errorResponse);
|
|
509
|
+
this.name = "ValidationFailedError";
|
|
510
|
+
}
|
|
511
|
+
get validationErrors() {
|
|
512
|
+
return this.context.validationErrors;
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
/**
|
|
516
|
+
* Error thrown when a process does not become ready within the timeout period
|
|
517
|
+
*/
|
|
518
|
+
var ProcessReadyTimeoutError = class extends SandboxError {
|
|
519
|
+
constructor(errorResponse) {
|
|
520
|
+
super(errorResponse);
|
|
521
|
+
this.name = "ProcessReadyTimeoutError";
|
|
522
|
+
}
|
|
523
|
+
get processId() {
|
|
524
|
+
return this.context.processId;
|
|
525
|
+
}
|
|
526
|
+
get command() {
|
|
527
|
+
return this.context.command;
|
|
528
|
+
}
|
|
529
|
+
get condition() {
|
|
530
|
+
return this.context.condition;
|
|
531
|
+
}
|
|
532
|
+
get timeout() {
|
|
533
|
+
return this.context.timeout;
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
/**
|
|
537
|
+
* Error thrown when a process exits before becoming ready
|
|
538
|
+
*/
|
|
539
|
+
var ProcessExitedBeforeReadyError = class extends SandboxError {
|
|
540
|
+
constructor(errorResponse) {
|
|
541
|
+
super(errorResponse);
|
|
542
|
+
this.name = "ProcessExitedBeforeReadyError";
|
|
543
|
+
}
|
|
544
|
+
get processId() {
|
|
545
|
+
return this.context.processId;
|
|
546
|
+
}
|
|
547
|
+
get command() {
|
|
548
|
+
return this.context.command;
|
|
549
|
+
}
|
|
550
|
+
get condition() {
|
|
551
|
+
return this.context.condition;
|
|
552
|
+
}
|
|
553
|
+
get exitCode() {
|
|
554
|
+
return this.context.exitCode;
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
/**
|
|
558
|
+
* Error thrown when a backup is not found in R2
|
|
559
|
+
*/
|
|
560
|
+
var BackupNotFoundError = class extends SandboxError {
|
|
561
|
+
constructor(errorResponse) {
|
|
562
|
+
super(errorResponse);
|
|
563
|
+
this.name = "BackupNotFoundError";
|
|
564
|
+
}
|
|
565
|
+
get backupId() {
|
|
566
|
+
return this.context.backupId;
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
/**
|
|
570
|
+
* Error thrown when a backup has expired (past its TTL)
|
|
571
|
+
*/
|
|
572
|
+
var BackupExpiredError = class extends SandboxError {
|
|
573
|
+
constructor(errorResponse) {
|
|
574
|
+
super(errorResponse);
|
|
575
|
+
this.name = "BackupExpiredError";
|
|
576
|
+
}
|
|
577
|
+
get backupId() {
|
|
578
|
+
return this.context.backupId;
|
|
579
|
+
}
|
|
580
|
+
get expiredAt() {
|
|
581
|
+
return this.context.expiredAt;
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
/**
|
|
585
|
+
* Error thrown when backup configuration or inputs are invalid
|
|
586
|
+
*/
|
|
587
|
+
var InvalidBackupConfigError = class extends SandboxError {
|
|
588
|
+
constructor(errorResponse) {
|
|
589
|
+
super(errorResponse);
|
|
590
|
+
this.name = "InvalidBackupConfigError";
|
|
591
|
+
}
|
|
592
|
+
get reason() {
|
|
593
|
+
return this.context.reason;
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
/**
|
|
597
|
+
* Error thrown when backup creation fails
|
|
598
|
+
*/
|
|
599
|
+
var BackupCreateError = class extends SandboxError {
|
|
600
|
+
constructor(errorResponse) {
|
|
601
|
+
super(errorResponse);
|
|
602
|
+
this.name = "BackupCreateError";
|
|
603
|
+
}
|
|
604
|
+
get dir() {
|
|
605
|
+
return this.context.dir;
|
|
606
|
+
}
|
|
607
|
+
get backupId() {
|
|
608
|
+
return this.context.backupId;
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Error thrown when backup restoration fails
|
|
613
|
+
*/
|
|
614
|
+
var BackupRestoreError = class extends SandboxError {
|
|
615
|
+
constructor(errorResponse) {
|
|
616
|
+
super(errorResponse);
|
|
617
|
+
this.name = "BackupRestoreError";
|
|
618
|
+
}
|
|
619
|
+
get dir() {
|
|
620
|
+
return this.context.dir;
|
|
621
|
+
}
|
|
622
|
+
get backupId() {
|
|
623
|
+
return this.context.backupId;
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
var ContainerUnavailableError = class extends SandboxError {
|
|
627
|
+
constructor(errorResponse) {
|
|
628
|
+
super(errorResponse);
|
|
629
|
+
this.name = "ContainerUnavailableError";
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
var OperationInterruptedError = class extends SandboxError {
|
|
633
|
+
constructor(errorResponse) {
|
|
634
|
+
super(errorResponse);
|
|
635
|
+
this.name = "OperationInterruptedError";
|
|
636
|
+
}
|
|
637
|
+
get reason() {
|
|
638
|
+
return this.context.reason;
|
|
639
|
+
}
|
|
640
|
+
get retryable() {
|
|
641
|
+
return this.context.retryable;
|
|
642
|
+
}
|
|
643
|
+
get operationName() {
|
|
644
|
+
return this.context.operation;
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
/**
|
|
648
|
+
* Raised when the capnweb WebSocket session itself fails on the SDK side.
|
|
649
|
+
* Unlike the rest of the SandboxError tree, the container never produces
|
|
650
|
+
* this error — it is synthesised by `translateRPCError` from the plain
|
|
651
|
+
* Errors capnweb / DeferredTransport raise when the connection dies.
|
|
652
|
+
*
|
|
653
|
+
* `kind` distinguishes the failure mode (peer close, upgrade failed, etc.)
|
|
654
|
+
* so callers can branch on a structured code instead of substring-matching
|
|
655
|
+
* on the message.
|
|
656
|
+
*
|
|
657
|
+
* Always retryable: the SDK opens a fresh connection on the next call.
|
|
658
|
+
*/
|
|
659
|
+
var RPCTransportError = class extends SandboxError {
|
|
660
|
+
constructor(errorResponse, options) {
|
|
661
|
+
super(errorResponse, options);
|
|
662
|
+
this.name = "RPCTransportError";
|
|
663
|
+
}
|
|
664
|
+
get kind() {
|
|
665
|
+
return this.errorResponse.context.kind;
|
|
666
|
+
}
|
|
667
|
+
get originalMessage() {
|
|
668
|
+
return this.errorResponse.context.originalMessage;
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
//#endregion
|
|
673
|
+
//#region src/errors/adapter.ts
|
|
674
|
+
/**
|
|
675
|
+
* Convert ErrorResponse to appropriate Error class
|
|
676
|
+
* Simple switch statement - we trust the container sends correct context
|
|
677
|
+
*/
|
|
678
|
+
function createErrorFromResponse(errorResponse, options) {
|
|
679
|
+
switch (errorResponse.code) {
|
|
680
|
+
case ErrorCode.FILE_NOT_FOUND: return new FileNotFoundError(errorResponse);
|
|
681
|
+
case ErrorCode.FILE_EXISTS: return new FileExistsError(errorResponse);
|
|
682
|
+
case ErrorCode.FILE_TOO_LARGE: return new FileTooLargeError(errorResponse);
|
|
683
|
+
case ErrorCode.PERMISSION_DENIED: return new PermissionDeniedError(errorResponse);
|
|
684
|
+
case ErrorCode.IS_DIRECTORY:
|
|
685
|
+
case ErrorCode.NOT_DIRECTORY:
|
|
686
|
+
case ErrorCode.NO_SPACE:
|
|
687
|
+
case ErrorCode.TOO_MANY_FILES:
|
|
688
|
+
case ErrorCode.RESOURCE_BUSY:
|
|
689
|
+
case ErrorCode.READ_ONLY:
|
|
690
|
+
case ErrorCode.NAME_TOO_LONG:
|
|
691
|
+
case ErrorCode.TOO_MANY_LINKS:
|
|
692
|
+
case ErrorCode.FILESYSTEM_ERROR: return new FileSystemError(errorResponse);
|
|
693
|
+
case ErrorCode.COMMAND_NOT_FOUND: return new CommandNotFoundError(errorResponse);
|
|
694
|
+
case ErrorCode.COMMAND_PERMISSION_DENIED:
|
|
695
|
+
case ErrorCode.COMMAND_EXECUTION_ERROR:
|
|
696
|
+
case ErrorCode.INVALID_COMMAND:
|
|
697
|
+
case ErrorCode.STREAM_START_ERROR: return new CommandError(errorResponse);
|
|
698
|
+
case ErrorCode.PROCESS_NOT_FOUND: return new ProcessNotFoundError(errorResponse);
|
|
699
|
+
case ErrorCode.PROCESS_PERMISSION_DENIED:
|
|
700
|
+
case ErrorCode.PROCESS_ERROR: return new ProcessError(errorResponse);
|
|
701
|
+
case ErrorCode.SESSION_ALREADY_EXISTS: return new SessionAlreadyExistsError(errorResponse);
|
|
702
|
+
case ErrorCode.SESSION_DESTROYED: return new SessionDestroyedError(errorResponse);
|
|
703
|
+
case ErrorCode.SESSION_TERMINATED: return new SessionTerminatedError(errorResponse);
|
|
704
|
+
case ErrorCode.PORT_ALREADY_EXPOSED: return new PortAlreadyExposedError(errorResponse);
|
|
705
|
+
case ErrorCode.PORT_NOT_EXPOSED: return new PortNotExposedError(errorResponse);
|
|
706
|
+
case ErrorCode.INVALID_PORT_NUMBER:
|
|
707
|
+
case ErrorCode.INVALID_PORT: return new InvalidPortError(errorResponse);
|
|
708
|
+
case ErrorCode.SERVICE_NOT_RESPONDING: return new ServiceNotRespondingError(errorResponse);
|
|
709
|
+
case ErrorCode.PORT_IN_USE: return new PortInUseError(errorResponse);
|
|
710
|
+
case ErrorCode.PORT_OPERATION_ERROR: return new PortError(errorResponse);
|
|
711
|
+
case ErrorCode.CUSTOM_DOMAIN_REQUIRED: return new CustomDomainRequiredError(errorResponse);
|
|
712
|
+
case ErrorCode.GIT_REPOSITORY_NOT_FOUND: return new GitRepositoryNotFoundError(errorResponse);
|
|
713
|
+
case ErrorCode.GIT_AUTH_FAILED: return new GitAuthenticationError(errorResponse);
|
|
714
|
+
case ErrorCode.GIT_BRANCH_NOT_FOUND: return new GitBranchNotFoundError(errorResponse);
|
|
715
|
+
case ErrorCode.GIT_NETWORK_ERROR: return new GitNetworkError(errorResponse);
|
|
716
|
+
case ErrorCode.GIT_CLONE_FAILED: return new GitCloneError(errorResponse);
|
|
717
|
+
case ErrorCode.GIT_CHECKOUT_FAILED: return new GitCheckoutError(errorResponse);
|
|
718
|
+
case ErrorCode.INVALID_GIT_URL: return new InvalidGitUrlError(errorResponse);
|
|
719
|
+
case ErrorCode.GIT_OPERATION_FAILED: return new GitError(errorResponse);
|
|
720
|
+
case ErrorCode.BACKUP_NOT_FOUND: return new BackupNotFoundError(errorResponse);
|
|
721
|
+
case ErrorCode.BACKUP_EXPIRED: return new BackupExpiredError(errorResponse);
|
|
722
|
+
case ErrorCode.INVALID_BACKUP_CONFIG: return new InvalidBackupConfigError(errorResponse);
|
|
723
|
+
case ErrorCode.BACKUP_CREATE_FAILED: return new BackupCreateError(errorResponse);
|
|
724
|
+
case ErrorCode.BACKUP_RESTORE_FAILED: return new BackupRestoreError(errorResponse);
|
|
725
|
+
case ErrorCode.INTERPRETER_NOT_READY: return new InterpreterNotReadyError(errorResponse);
|
|
726
|
+
case ErrorCode.CONTEXT_NOT_FOUND: return new ContextNotFoundError(errorResponse);
|
|
727
|
+
case ErrorCode.CODE_EXECUTION_ERROR: return new CodeExecutionError(errorResponse);
|
|
728
|
+
case ErrorCode.CONTAINER_UNAVAILABLE: return new ContainerUnavailableError(errorResponse);
|
|
729
|
+
case ErrorCode.OPERATION_INTERRUPTED: return new OperationInterruptedError(errorResponse);
|
|
730
|
+
case ErrorCode.RPC_TRANSPORT_ERROR: return new RPCTransportError(errorResponse, options);
|
|
731
|
+
case ErrorCode.VALIDATION_FAILED: return new ValidationFailedError(errorResponse);
|
|
732
|
+
case ErrorCode.INVALID_JSON_RESPONSE:
|
|
733
|
+
case ErrorCode.UNKNOWN_ERROR:
|
|
734
|
+
case ErrorCode.INTERNAL_ERROR: return new SandboxError(errorResponse);
|
|
735
|
+
default: return new SandboxError(errorResponse);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
//#endregion
|
|
740
|
+
export { PortError as A, SessionAlreadyExistsError as B, InterpreterNotReadyError as C, OperationInterruptedError as D, InvalidPortError as E, ProcessNotFoundError as F, SessionTerminatedError as H, ProcessReadyTimeoutError as I, RPCTransportError as L, PortNotExposedError as M, ProcessError as N, PermissionDeniedError as O, ProcessExitedBeforeReadyError as P, SandboxError as R, GitRepositoryNotFoundError as S, InvalidGitUrlError as T, ValidationFailedError as U, SessionDestroyedError as V, GitBranchNotFoundError as _, BackupRestoreError as a, GitError as b, CommandNotFoundError as c, CustomDomainRequiredError as d, FileExistsError as f, GitAuthenticationError as g, FileTooLargeError as h, BackupNotFoundError as i, PortInUseError as j, PortAlreadyExposedError as k, ContainerUnavailableError as l, FileSystemError as m, BackupCreateError as n, CodeExecutionError as o, FileNotFoundError as p, BackupExpiredError as r, CommandError as s, createErrorFromResponse as t, ContextNotFoundError as u, GitCheckoutError as v, InvalidBackupConfigError as w, GitNetworkError as x, GitCloneError as y, ServiceNotRespondingError as z };
|
|
741
|
+
//# sourceMappingURL=errors-ewgSNicb.js.map
|