@daytonaio/sdk 0.200.1 → 0.202.0

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 (64) hide show
  1. package/cjs/CodeInterpreter.js +1 -1
  2. package/cjs/CodeInterpreter.js.map +1 -1
  3. package/cjs/Daytona.d.ts +17 -5
  4. package/cjs/Daytona.js +23 -16
  5. package/cjs/Daytona.js.map +1 -1
  6. package/cjs/FileSystem.d.ts +5 -1
  7. package/cjs/FileSystem.js +1 -1
  8. package/cjs/FileSystem.js.map +1 -1
  9. package/cjs/Image.js +14 -14
  10. package/cjs/Image.js.map +1 -1
  11. package/cjs/LspServer.js +1 -1
  12. package/cjs/LspServer.js.map +1 -1
  13. package/cjs/ObjectStorage.d.ts +2 -1
  14. package/cjs/ObjectStorage.js +1 -5
  15. package/cjs/ObjectStorage.js.map +1 -1
  16. package/cjs/Sandbox.d.ts +74 -10
  17. package/cjs/Sandbox.js +120 -31
  18. package/cjs/Sandbox.js.map +1 -1
  19. package/cjs/Snapshot.js +1 -0
  20. package/cjs/Snapshot.js.map +1 -1
  21. package/cjs/errors/DaytonaError.d.ts +152 -128
  22. package/cjs/errors/DaytonaError.js +276 -150
  23. package/cjs/errors/DaytonaError.js.map +1 -1
  24. package/cjs/index.d.ts +2 -2
  25. package/cjs/index.js +44 -6
  26. package/cjs/index.js.map +1 -1
  27. package/cjs/utils/FileTransfer.js +5 -2
  28. package/cjs/utils/FileTransfer.js.map +1 -1
  29. package/cjs/utils/fileUrlSigning.d.ts +4 -0
  30. package/cjs/utils/fileUrlSigning.js +47 -0
  31. package/cjs/utils/fileUrlSigning.js.map +1 -0
  32. package/esm/CodeInterpreter.js +2 -2
  33. package/esm/CodeInterpreter.js.map +1 -1
  34. package/esm/Daytona.d.ts +17 -5
  35. package/esm/Daytona.js +24 -17
  36. package/esm/Daytona.js.map +1 -1
  37. package/esm/FileSystem.d.ts +5 -1
  38. package/esm/FileSystem.js +1 -1
  39. package/esm/FileSystem.js.map +1 -1
  40. package/esm/Image.js +15 -15
  41. package/esm/Image.js.map +1 -1
  42. package/esm/LspServer.js +2 -2
  43. package/esm/LspServer.js.map +1 -1
  44. package/esm/ObjectStorage.d.ts +2 -1
  45. package/esm/ObjectStorage.js +1 -5
  46. package/esm/ObjectStorage.js.map +1 -1
  47. package/esm/Sandbox.d.ts +74 -10
  48. package/esm/Sandbox.js +121 -32
  49. package/esm/Sandbox.js.map +1 -1
  50. package/esm/Snapshot.js +1 -0
  51. package/esm/Snapshot.js.map +1 -1
  52. package/esm/errors/DaytonaError.d.ts +152 -128
  53. package/esm/errors/DaytonaError.js +242 -144
  54. package/esm/errors/DaytonaError.js.map +1 -1
  55. package/esm/index.d.ts +2 -2
  56. package/esm/index.js +13 -1
  57. package/esm/index.js.map +1 -1
  58. package/esm/utils/FileTransfer.js +5 -2
  59. package/esm/utils/FileTransfer.js.map +1 -1
  60. package/esm/utils/Import.js +5 -3
  61. package/esm/utils/fileUrlSigning.d.ts +4 -0
  62. package/esm/utils/fileUrlSigning.js +42 -0
  63. package/esm/utils/fileUrlSigning.js.map +1 -0
  64. package/package.json +15 -13
@@ -3,179 +3,274 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  /**
6
- * Base error for Daytona SDK.
7
- *
8
- * @example
9
- * ```ts
10
- * try {
11
- * await daytona.get('missing-sandbox')
12
- * } catch (error) {
13
- * if (error instanceof DaytonaError) {
14
- * console.log(error.statusCode)
15
- * console.log(error.errorCode)
16
- * console.log(error.message)
17
- * }
18
- * }
19
- * ```
6
+ * Wire-format `source` identifiers set by the translation layer when a
7
+ * Daytona service stamps them on the wire envelope. `source = undefined`
8
+ * means the response did not carry a structured envelope (treat as opaque).
9
+ */
10
+ export const SOURCE_API = 'DAYTONA_API';
11
+ export const SOURCE_DAEMON = 'DAYTONA_DAEMON';
12
+ export const SOURCE_PROXY = 'DAYTONA_PROXY';
13
+ /**
14
+ * Base error for Daytona SDK. `statusCode` and `code` are populated only
15
+ * for errors translated from a server response. `source` is `undefined`
16
+ * unless the caller (or the translation layer) sets it.
20
17
  */
21
18
  export class DaytonaError extends Error {
22
- /** HTTP status code if available */
23
19
  statusCode;
24
- /** Machine-readable error code if available */
25
- errorCode;
26
- /** Response headers if available */
20
+ code;
21
+ source;
27
22
  headers;
28
- constructor(message, statusCode, headers, errorCode) {
23
+ constructor(message, statusCode, headers, code, source) {
29
24
  super(message);
30
25
  this.name = new.target.name;
31
26
  this.statusCode = statusCode;
32
27
  this.headers = headers;
33
- this.errorCode = errorCode;
28
+ this.code = code;
29
+ this.source = source;
30
+ }
31
+ /**
32
+ * @deprecated Use {@link DaytonaError.code} instead. Kept so existing
33
+ * `err.errorCode` reads keep returning the machine-readable code.
34
+ * @returns the machine-readable error code, or `undefined` when the
35
+ * response did not carry one (same as {@link DaytonaError.code})
36
+ */
37
+ get errorCode() {
38
+ return this.code;
34
39
  }
35
40
  }
36
- /**
37
- * Error thrown when a resource is not found (HTTP 404).
38
- *
39
- * @example
40
- * ```ts
41
- * try {
42
- * await sandbox.fs.downloadFile('/workspace/missing.txt')
43
- * } catch (error) {
44
- * if (error instanceof DaytonaNotFoundError) {
45
- * console.log(error.statusCode)
46
- * }
47
- * }
48
- * ```
49
- */
41
+ // HTTP-status classes — one per status code Daytona services emit.
42
+ // Names follow HTTP terminology (BadRequest=400, Forbidden=403).
43
+ /** The request was malformed or invalid (HTTP 400). */
44
+ export class DaytonaBadRequestError extends DaytonaError {
45
+ }
46
+ /** Authentication failed — missing or invalid credentials (HTTP 401). */
47
+ export class DaytonaAuthenticationError extends DaytonaError {
48
+ }
49
+ /** The authenticated caller lacks permission for the operation (HTTP 403). */
50
+ export class DaytonaForbiddenError extends DaytonaError {
51
+ }
52
+ /** The requested resource does not exist (HTTP 404). */
50
53
  export class DaytonaNotFoundError extends DaytonaError {
51
54
  }
52
55
  /**
53
- * Error thrown when rate limit is exceeded.
56
+ * The operation timed out (HTTP 408, or 504 when a gateway timed out).
54
57
  *
55
- * @example
56
- * ```ts
57
- * try {
58
- * for await (const sandbox of daytona.list()) {
59
- * console.log(sandbox.id)
60
- * }
61
- * } catch (error) {
62
- * if (error instanceof DaytonaRateLimitError) {
63
- * console.log(error.errorCode)
64
- * }
65
- * }
66
- * ```
58
+ * Also matches {@link DaytonaConnectionTimeoutError} via `instanceof`, even
59
+ * though that class sits under {@link DaytonaConnectionError} in the prototype
60
+ * chain. Transport timeouts were raised as `DaytonaTimeoutError` before
61
+ * `DaytonaConnectionTimeoutError` existed, so this keeps pre-existing
62
+ * `catch (err) { if (err instanceof DaytonaTimeoutError) ... }` blocks working
63
+ * — the same compatibility the Python SDK gets from inheriting both classes.
67
64
  */
65
+ export class DaytonaTimeoutError extends DaytonaError {
66
+ static [Symbol.hasInstance](value) {
67
+ // Only the base class widens; subclasses (e.g. ProcessExecutionTimeout)
68
+ // must keep exact prototype-chain semantics.
69
+ if (this === DaytonaTimeoutError && value instanceof DaytonaConnectionTimeoutError) {
70
+ return true;
71
+ }
72
+ return Function.prototype[Symbol.hasInstance].call(this, value);
73
+ }
74
+ }
75
+ /** The request conflicts with the current state of the resource (HTTP 409). */
76
+ export class DaytonaConflictError extends DaytonaError {
77
+ }
78
+ /** The resource existed but is permanently gone (HTTP 410). */
79
+ export class DaytonaGoneError extends DaytonaError {
80
+ }
81
+ /** The request was well-formed but semantically invalid (HTTP 422). */
82
+ export class DaytonaUnprocessableEntityError extends DaytonaError {
83
+ }
84
+ /** The caller exceeded a rate limit (HTTP 429). */
68
85
  export class DaytonaRateLimitError extends DaytonaError {
69
86
  }
70
- /**
71
- * Error thrown when authentication fails (HTTP 401).
72
- *
73
- * @example
74
- * ```ts
75
- * try {
76
- * for await (const sandbox of daytona.list()) {
77
- * console.log(sandbox.id)
78
- * }
79
- * } catch (error) {
80
- * if (error instanceof DaytonaAuthenticationError) {
81
- * console.log(error.statusCode)
82
- * }
83
- * }
84
- * ```
85
- */
86
- export class DaytonaAuthenticationError extends DaytonaError {
87
+ /** A Daytona service failed unexpectedly (HTTP 500). */
88
+ export class DaytonaInternalServerError extends DaytonaError {
87
89
  }
88
- /**
89
- * Error thrown when the request is forbidden (HTTP 403).
90
- *
91
- * @example
92
- * ```ts
93
- * try {
94
- * await daytona.get('sandbox-without-access')
95
- * } catch (error) {
96
- * if (error instanceof DaytonaAuthorizationError) {
97
- * console.log(error.message)
98
- * }
99
- * }
100
- * ```
101
- */
102
- export class DaytonaAuthorizationError extends DaytonaError {
90
+ /** An upstream gateway returned an invalid response (HTTP 502). */
91
+ export class DaytonaBadGatewayError extends DaytonaError {
92
+ }
93
+ /** The service is temporarily unable to handle the request (HTTP 503). */
94
+ export class DaytonaServiceUnavailableError extends DaytonaError {
103
95
  }
96
+ // ============================================================================
97
+ // Backward-compatibility subclasses. New functionality belongs elsewhere in
98
+ // this file, not here. These are what the 400/403 entries of
99
+ // STATUS_CODE_TO_ERROR throw so pre-rename `instanceof` checks keep matching.
100
+ // They must stay declared BEFORE that map (TDZ) and in this file (import
101
+ // cycle), and can be removed together with those two map entries in a future
102
+ // major release. The deprecated `errorCode` getter on DaytonaError belongs to
103
+ // the same removal set.
104
+ // ============================================================================
104
105
  /**
105
- * Error thrown when a resource conflict occurs (HTTP 409).
106
+ * Legacy umbrella for validation failures. Kept so existing
107
+ * `catch (err) { if (err instanceof DaytonaValidationError) ... }` blocks keep
108
+ * matching both server-returned HTTP 400s and locally rejected arguments.
106
109
  *
107
- * @example
108
- * ```ts
109
- * try {
110
- * await daytona.create({ name: 'existing-sandbox' })
111
- * } catch (error) {
112
- * if (error instanceof DaytonaConflictError) {
113
- * console.log(error.errorCode)
114
- * }
115
- * }
116
- * ```
110
+ * @deprecated Do not throw or catch this directly in new code. Branch on the
111
+ * precise class instead:
112
+ * - {@link DaytonaInvalidArgumentError} — the SDK rejected your arguments
113
+ * locally, before any request was sent.
114
+ * - {@link DaytonaBadRequestError} a Daytona service returned HTTP 400.
115
+ * - {@link DaytonaUnprocessableEntityError} — a Daytona service returned
116
+ * HTTP 422 (well-formed but semantically invalid).
117
117
  */
118
- export class DaytonaConflictError extends DaytonaError {
118
+ export class DaytonaValidationError extends DaytonaBadRequestError {
119
119
  }
120
120
  /**
121
- * Error thrown when input validation fails (HTTP 400 or client-side validation).
122
- *
123
- * @example
124
- * ```ts
125
- * try {
126
- * Image.debianSlim('3.8' as never)
127
- * } catch (error) {
128
- * if (error instanceof DaytonaValidationError) {
129
- * console.log(error.message)
130
- * }
131
- * }
132
- * ```
121
+ * @deprecated Use {@link DaytonaForbiddenError} instead.
133
122
  */
134
- export class DaytonaValidationError extends DaytonaError {
123
+ export class DaytonaAuthorizationError extends DaytonaForbiddenError {
135
124
  }
125
+ // Not part of the deprecated set above. It extends DaytonaValidationError only
126
+ // so pre-existing `instanceof DaytonaValidationError` / `DaytonaBadRequestError`
127
+ // catches keep matching local argument rejections; reparent it directly onto
128
+ // DaytonaError in the next major.
136
129
  /**
137
- * Error thrown when a timeout occurs.
130
+ * The SDK rejected the caller's arguments locally, before any request was
131
+ * sent. `statusCode`, `code` and `source` are always `undefined` — no Daytona
132
+ * service was contacted, so there is no HTTP status to report.
133
+ *
134
+ * Distinct from {@link DaytonaBadRequestError} (a service returned HTTP 400)
135
+ * and {@link DaytonaUnprocessableEntityError} (a service returned HTTP 422).
136
+ * This one always means: fix the arguments at the call site.
138
137
  *
139
138
  * @example
140
139
  * ```ts
141
140
  * try {
142
- * await sandbox.waitUntilStarted(1)
143
- * } catch (error) {
144
- * if (error instanceof DaytonaTimeoutError) {
145
- * console.log(error.message)
141
+ * await sandbox.setAutoStopInterval(-1)
142
+ * } catch (err) {
143
+ * if (err instanceof DaytonaInvalidArgumentError) {
144
+ * // never reached the API — the value itself is invalid
146
145
  * }
147
146
  * }
148
147
  * ```
149
148
  */
150
- export class DaytonaTimeoutError extends DaytonaError {
149
+ export class DaytonaInvalidArgumentError extends DaytonaValidationError {
150
+ }
151
+ /** Network connection failure (can't connect or mid-request drop). */
152
+ export class DaytonaConnectionError extends DaytonaError {
153
+ }
154
+ /** Transport-layer timeout (connect / read). Subclass of DaytonaConnectionError. */
155
+ export class DaytonaConnectionTimeoutError extends DaytonaConnectionError {
156
+ }
157
+ // Domain-specific subclasses. Each inherits from the HTTP-status class that
158
+ // matches its server-side status, so callers can catch either level.
159
+ // --- Git (daemon) ---
160
+ /** Git authentication against the remote failed (code `GIT_AUTH_FAILED`). */
161
+ export class DaytonaGitAuthFailedError extends DaytonaAuthenticationError {
162
+ }
163
+ /** The git remote repository was not found (code `GIT_REPO_NOT_FOUND`). */
164
+ export class DaytonaGitRepoNotFoundError extends DaytonaNotFoundError {
165
+ }
166
+ /** The git branch does not exist (code `GIT_BRANCH_NOT_FOUND`). */
167
+ export class DaytonaGitBranchNotFoundError extends DaytonaNotFoundError {
168
+ }
169
+ /** The git branch already exists (code `GIT_BRANCH_EXISTS`). */
170
+ export class DaytonaGitBranchExistsError extends DaytonaConflictError {
171
+ }
172
+ /** The git push was rejected by the remote (code `GIT_PUSH_REJECTED`). */
173
+ export class DaytonaGitPushRejectedError extends DaytonaConflictError {
174
+ }
175
+ /** The operation requires a clean worktree (code `GIT_DIRTY_WORKTREE`). */
176
+ export class DaytonaGitDirtyWorktreeError extends DaytonaConflictError {
177
+ }
178
+ /** A git merge produced conflicts (code `GIT_MERGE_CONFLICT`). */
179
+ export class DaytonaGitMergeConflictError extends DaytonaConflictError {
180
+ }
181
+ // --- Filesystem (daemon) ---
182
+ /** The file does not exist in the sandbox (code `FILE_NOT_FOUND`). */
183
+ export class DaytonaFileNotFoundError extends DaytonaNotFoundError {
184
+ }
185
+ /** Access to the sandbox file was denied (code `FILE_ACCESS_DENIED`). */
186
+ export class DaytonaFileAccessDeniedError extends DaytonaForbiddenError {
187
+ }
188
+ /** The supplied file path was rejected by the daemon (code `INVALID_FILE_PATH`). */
189
+ export class DaytonaInvalidFilePathError extends DaytonaBadRequestError {
190
+ }
191
+ /** The daemon could not read the sandbox file (code `FILE_READ_FAILED`). */
192
+ export class DaytonaFileReadFailedError extends DaytonaInternalServerError {
193
+ }
194
+ // --- LSP (daemon) ---
195
+ /** The LSP server must be initialized first (code `LSP_SERVER_NOT_INITIALIZED`). */
196
+ export class DaytonaLspServerNotInitializedError extends DaytonaBadRequestError {
197
+ }
198
+ // --- Process / session (daemon) ---
199
+ /** Command execution exceeded its timeout (code `PROCESS_EXECUTION_TIMEOUT`). */
200
+ export class DaytonaProcessExecutionTimeoutError extends DaytonaTimeoutError {
201
+ }
202
+ /** The sandbox process does not exist (code `PROCESS_NOT_FOUND`). */
203
+ export class DaytonaProcessNotFoundError extends DaytonaNotFoundError {
204
+ }
205
+ /** The session has already ended (code `SESSION_ENDED`). */
206
+ export class DaytonaSessionEndedError extends DaytonaGoneError {
207
+ }
208
+ /** The session command already finished (code `COMMAND_ALREADY_COMPLETED`). */
209
+ export class DaytonaCommandAlreadyCompletedError extends DaytonaGoneError {
210
+ }
211
+ // --- Computer-use (daemon) ---
212
+ /** The accessibility service is unavailable (code `A11Y_UNAVAILABLE`). */
213
+ export class DaytonaA11yUnavailableError extends DaytonaServiceUnavailableError {
214
+ }
215
+ /** A screen recording is still active (code `RECORDING_STILL_ACTIVE`). */
216
+ export class DaytonaRecordingStillActiveError extends DaytonaConflictError {
217
+ }
218
+ /** ffmpeg is not available for recording (code `RECORDING_FFMPEG_NOT_FOUND`). */
219
+ export class DaytonaRecordingFfmpegNotFoundError extends DaytonaServiceUnavailableError {
151
220
  }
152
221
  /**
153
- * Error thrown when a network connection fails.
222
+ * (source, code) precise DaytonaError subclass. Lookup runs before the
223
+ * HTTP status code fallback, so a domain code wins over the status default.
154
224
  *
155
- * @example
156
- * ```ts
157
- * try {
158
- * await ptyHandle.waitForConnection()
159
- * } catch (error) {
160
- * if (error instanceof DaytonaConnectionError) {
161
- * console.log(error.message)
162
- * }
163
- * }
164
- * ```
225
+ * Code strings are kept inline (not imported from the generated clients) so
226
+ * tests that virtual-mock the API client modules don't break module init.
227
+ *
228
+ * There is currently NO automated drift check against the daemon's
229
+ * `DaemonErrorCode` enum keep this map in sync by hand when codes are added.
165
230
  */
166
- export class DaytonaConnectionError extends DaytonaError {
231
+ const CODE_TO_ERROR_CLASS = {
232
+ // Daemon
233
+ 'DAYTONA_DAEMON|GIT_AUTH_FAILED': DaytonaGitAuthFailedError,
234
+ 'DAYTONA_DAEMON|GIT_REPO_NOT_FOUND': DaytonaGitRepoNotFoundError,
235
+ 'DAYTONA_DAEMON|GIT_BRANCH_NOT_FOUND': DaytonaGitBranchNotFoundError,
236
+ 'DAYTONA_DAEMON|GIT_BRANCH_EXISTS': DaytonaGitBranchExistsError,
237
+ 'DAYTONA_DAEMON|GIT_PUSH_REJECTED': DaytonaGitPushRejectedError,
238
+ 'DAYTONA_DAEMON|GIT_DIRTY_WORKTREE': DaytonaGitDirtyWorktreeError,
239
+ 'DAYTONA_DAEMON|GIT_MERGE_CONFLICT': DaytonaGitMergeConflictError,
240
+ 'DAYTONA_DAEMON|FILE_NOT_FOUND': DaytonaFileNotFoundError,
241
+ 'DAYTONA_DAEMON|FILE_ACCESS_DENIED': DaytonaFileAccessDeniedError,
242
+ 'DAYTONA_DAEMON|INVALID_FILE_PATH': DaytonaInvalidFilePathError,
243
+ 'DAYTONA_DAEMON|FILE_READ_FAILED': DaytonaFileReadFailedError,
244
+ 'DAYTONA_DAEMON|LSP_SERVER_NOT_INITIALIZED': DaytonaLspServerNotInitializedError,
245
+ 'DAYTONA_DAEMON|PROCESS_EXECUTION_TIMEOUT': DaytonaProcessExecutionTimeoutError,
246
+ 'DAYTONA_DAEMON|PROCESS_NOT_FOUND': DaytonaProcessNotFoundError,
247
+ 'DAYTONA_DAEMON|SESSION_ENDED': DaytonaSessionEndedError,
248
+ 'DAYTONA_DAEMON|COMMAND_ALREADY_COMPLETED': DaytonaCommandAlreadyCompletedError,
249
+ 'DAYTONA_DAEMON|A11Y_UNAVAILABLE': DaytonaA11yUnavailableError,
250
+ 'DAYTONA_DAEMON|RECORDING_STILL_ACTIVE': DaytonaRecordingStillActiveError,
251
+ 'DAYTONA_DAEMON|RECORDING_FFMPEG_NOT_FOUND': DaytonaRecordingFfmpegNotFoundError,
252
+ };
253
+ function lookupErrorClass(source, code) {
254
+ if (!code || !source)
255
+ return undefined;
256
+ return CODE_TO_ERROR_CLASS[`${source}|${code}`];
167
257
  }
168
258
  const STATUS_CODE_TO_ERROR = {
169
259
  400: DaytonaValidationError,
170
260
  401: DaytonaAuthenticationError,
171
261
  403: DaytonaAuthorizationError,
172
262
  404: DaytonaNotFoundError,
263
+ 408: DaytonaTimeoutError,
173
264
  409: DaytonaConflictError,
265
+ 410: DaytonaGoneError,
266
+ 422: DaytonaUnprocessableEntityError,
174
267
  429: DaytonaRateLimitError,
268
+ 500: DaytonaInternalServerError,
269
+ 502: DaytonaBadGatewayError,
270
+ 503: DaytonaServiceUnavailableError,
271
+ 504: DaytonaTimeoutError,
175
272
  };
176
- /**
177
- * Maps an HTTP status code to the corresponding Daytona error class.
178
- */
273
+ /** Maps an HTTP status code to the corresponding Daytona error class. */
179
274
  export function errorClassFromStatusCode(statusCode) {
180
275
  if (statusCode === undefined) {
181
276
  return DaytonaError;
@@ -184,10 +279,12 @@ export function errorClassFromStatusCode(statusCode) {
184
279
  }
185
280
  /**
186
281
  * Creates the appropriate Daytona error subclass from structured error metadata.
282
+ *
283
+ * Resolution order: (source, code) override -> HTTP status code -> DaytonaError.
187
284
  */
188
- export function createDaytonaError(message, statusCode, headers, errorCode) {
189
- const ErrorClass = errorClassFromStatusCode(statusCode);
190
- return new ErrorClass(message, statusCode, headers, errorCode);
285
+ export function createDaytonaError(message, statusCode, headers, code, source) {
286
+ const ErrorClass = lookupErrorClass(source, code) || errorClassFromStatusCode(statusCode);
287
+ return new ErrorClass(message, statusCode, headers, code, source);
191
288
  }
192
289
  function isAxiosTimeoutError(error) {
193
290
  return error.code === 'ECONNABORTED' || error.code === 'ETIMEDOUT' || error.message.includes('timeout of');
@@ -199,23 +296,20 @@ function getAxiosResponseDataObject(error) {
199
296
  return error.response.data;
200
297
  }
201
298
  function extractAxiosErrorCode(responseData) {
202
- if (typeof responseData?.code === 'string') {
203
- return responseData.code;
204
- }
205
- if (typeof responseData?.error_code === 'string') {
206
- return responseData.error_code;
207
- }
208
- if (typeof responseData?.error === 'string') {
209
- return responseData.error;
210
- }
211
- return undefined;
299
+ const code = responseData?.code ?? responseData?.error_code;
300
+ return typeof code === 'string' ? code : undefined;
301
+ }
302
+ function extractAxiosErrorSource(responseData) {
303
+ return typeof responseData?.source === 'string' ? responseData.source : undefined;
212
304
  }
213
305
  function extractAxiosErrorMessage(error) {
214
306
  if (isAxiosTimeoutError(error)) {
215
307
  return 'Operation timed out';
216
308
  }
217
309
  const responseData = getAxiosResponseDataObject(error);
218
- const responseMessage = responseData?.message || error.response?.data;
310
+ const responseMessage = (typeof responseData?.message === 'string' ? responseData.message : undefined) ??
311
+ (typeof responseData?.error === 'string' ? responseData.error : undefined) ??
312
+ error.response?.data;
219
313
  const message = responseMessage || error.message || String(error);
220
314
  if (typeof message === 'object') {
221
315
  try {
@@ -228,20 +322,24 @@ function extractAxiosErrorMessage(error) {
228
322
  return String(message);
229
323
  }
230
324
  /**
231
- * Creates the appropriate Daytona error subclass from an Axios error.
325
+ * Creates the appropriate Daytona error subclass from an Axios error. Maps
326
+ * client-side timeouts to DaytonaConnectionTimeoutError, networking failures
327
+ * (no response received) to DaytonaConnectionError, and HTTP responses to
328
+ * the most specific subclass via `createDaytonaError`.
232
329
  */
233
330
  export function createAxiosDaytonaError(error) {
234
331
  const message = extractAxiosErrorMessage(error);
235
332
  const statusCode = error.response?.status;
236
333
  const headers = error.response?.headers;
237
334
  const responseData = getAxiosResponseDataObject(error);
238
- const errorCode = extractAxiosErrorCode(responseData);
335
+ const code = extractAxiosErrorCode(responseData);
336
+ const source = extractAxiosErrorSource(responseData);
239
337
  if (isAxiosTimeoutError(error)) {
240
- return new DaytonaTimeoutError(message, statusCode, headers, errorCode);
338
+ return new DaytonaConnectionTimeoutError(message, statusCode, headers, code, source);
241
339
  }
242
340
  if (!error.response && (error.request || error.code)) {
243
- return new DaytonaConnectionError(message, statusCode, headers, errorCode);
341
+ return new DaytonaConnectionError(message, statusCode, headers, code, source);
244
342
  }
245
- return createDaytonaError(message, statusCode, headers, errorCode);
343
+ return createDaytonaError(message, statusCode, headers, code, source);
246
344
  }
247
345
  //# sourceMappingURL=DaytonaError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DaytonaError.js","sourceRoot":"","sources":["../../../../../sdk-typescript/src/errors/DaytonaError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,oCAAoC;IAC7B,UAAU,CAAS;IAC1B,+CAA+C;IACxC,SAAS,CAAS;IACzB,oCAAoC;IAC7B,OAAO,CAAkB;IAEhC,YAAY,OAAe,EAAE,UAAmB,EAAE,OAAyB,EAAE,SAAkB;QAC7F,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,oBAAqB,SAAQ,YAAY;CAAG;AAEzD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,qBAAsB,SAAQ,YAAY;CAAG;AAE1D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,0BAA2B,SAAQ,YAAY;CAAG;AAE/D;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,yBAA0B,SAAQ,YAAY;CAAG;AAE9D;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,oBAAqB,SAAQ,YAAY;CAAG;AAEzD;;;;;;;;;;;;;GAaG;AAC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C,CAAA;AACvE,CAAC"}
package/esm/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export { CodeLanguage, Daytona } from './Daytona.js';
2
- export type { CreateSandboxBaseParams, CreateSandboxFromImageParams, CreateSandboxFromSnapshotParams, DaytonaConfig, Resources, VolumeMount, } from './Daytona.js';
2
+ export type { CreateSandboxBaseParams, CreateSandboxFromImageParams, CreateSandboxFromSnapshotParams, DaytonaConfig, ForkSandboxParams, Resources, VolumeMount, } from './Daytona.js';
3
3
  export { FileSystem } from './FileSystem.js';
4
4
  export type { DownloadProgress, DownloadMetadata, DownloadStreamOptions, UploadProgress, UploadStreamOptions, UploadSource, FileDownloadErrorDetails, FileDownloadRequest, FileDownloadResponse, FilePermissionsParams, FileUpload, } from './FileSystem.js';
5
5
  export { Git } from './Git.js';
6
6
  export { LspLanguageId } from './LspServer.js';
7
7
  export { Process } from './Process.js';
8
- export { DaytonaAuthenticationError, DaytonaAuthorizationError, DaytonaConflictError, DaytonaConnectionError, DaytonaError, DaytonaNotFoundError, DaytonaRateLimitError, DaytonaTimeoutError, DaytonaValidationError, } from './errors/DaytonaError.js';
8
+ export { SOURCE_API, SOURCE_DAEMON, SOURCE_PROXY, DaytonaError, DaytonaBadRequestError, DaytonaInvalidArgumentError, DaytonaValidationError, DaytonaAuthenticationError, DaytonaForbiddenError, DaytonaAuthorizationError, DaytonaNotFoundError, DaytonaTimeoutError, DaytonaConflictError, DaytonaGoneError, DaytonaUnprocessableEntityError, DaytonaRateLimitError, DaytonaInternalServerError, DaytonaBadGatewayError, DaytonaServiceUnavailableError, DaytonaConnectionError, DaytonaConnectionTimeoutError, DaytonaGitAuthFailedError, DaytonaGitRepoNotFoundError, DaytonaGitBranchNotFoundError, DaytonaGitBranchExistsError, DaytonaGitPushRejectedError, DaytonaGitDirtyWorktreeError, DaytonaGitMergeConflictError, DaytonaFileNotFoundError, DaytonaFileAccessDeniedError, DaytonaInvalidFilePathError, DaytonaFileReadFailedError, DaytonaLspServerNotInitializedError, DaytonaProcessExecutionTimeoutError, DaytonaProcessNotFoundError, DaytonaSessionEndedError, DaytonaCommandAlreadyCompletedError, DaytonaA11yUnavailableError, DaytonaRecordingStillActiveError, DaytonaRecordingFfmpegNotFoundError, } from './errors/DaytonaError.js';
9
9
  export { Image } from './Image.js';
10
10
  export { Sandbox } from './Sandbox.js';
11
11
  export type { ListSandboxesQuery, SandboxMetrics } from './Sandbox.js';
package/esm/index.js CHANGED
@@ -9,7 +9,19 @@ export { LspLanguageId } from './LspServer.js';
9
9
  export { Process } from './Process.js';
10
10
  // export { LspServer } from './LspServer'
11
11
  // export type { LspLanguageId, Position } from './LspServer'
12
- export { DaytonaAuthenticationError, DaytonaAuthorizationError, DaytonaConflictError, DaytonaConnectionError, DaytonaError, DaytonaNotFoundError, DaytonaRateLimitError, DaytonaTimeoutError, DaytonaValidationError, } from './errors/DaytonaError.js';
12
+ export {
13
+ // Wire-format `source` identifiers for matching against `error.source`
14
+ SOURCE_API, SOURCE_DAEMON, SOURCE_PROXY,
15
+ // Base + status-code classes
16
+ DaytonaError, DaytonaBadRequestError,
17
+ // Client-side (pre-flight) argument validation
18
+ DaytonaInvalidArgumentError,
19
+ // Deprecated aliases
20
+ DaytonaValidationError, DaytonaAuthenticationError, DaytonaForbiddenError,
21
+ // Deprecated alias
22
+ DaytonaAuthorizationError, DaytonaNotFoundError, DaytonaTimeoutError, DaytonaConflictError, DaytonaGoneError, DaytonaUnprocessableEntityError, DaytonaRateLimitError, DaytonaInternalServerError, DaytonaBadGatewayError, DaytonaServiceUnavailableError, DaytonaConnectionError, DaytonaConnectionTimeoutError,
23
+ // Domain-specific subclasses
24
+ DaytonaGitAuthFailedError, DaytonaGitRepoNotFoundError, DaytonaGitBranchNotFoundError, DaytonaGitBranchExistsError, DaytonaGitPushRejectedError, DaytonaGitDirtyWorktreeError, DaytonaGitMergeConflictError, DaytonaFileNotFoundError, DaytonaFileAccessDeniedError, DaytonaInvalidFilePathError, DaytonaFileReadFailedError, DaytonaLspServerNotInitializedError, DaytonaProcessExecutionTimeoutError, DaytonaProcessNotFoundError, DaytonaSessionEndedError, DaytonaCommandAlreadyCompletedError, DaytonaA11yUnavailableError, DaytonaRecordingStillActiveError, DaytonaRecordingFfmpegNotFoundError, } from './errors/DaytonaError.js';
13
25
  export { Image } from './Image.js';
14
26
  export { Sandbox } from './Sandbox.js';
15
27
  export { ComputerUse, Mouse, Keyboard, Screenshot, Display, Accessibility } from './ComputerUse.js';
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../sdk-typescript/src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASjD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAczC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,0CAA0C;AAC1C,6DAA6D;AAC7D,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAiBhG,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG1C,OAAO,EACL,OAAO,EACP,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,EACZ,4BAA4B,EAC5B,6BAA6B,G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SAAS,CAAA;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAiBhG,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG1C,OAAO,EACL,OAAO,EACP,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,EACZ,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,qBAAqB,CAAA;AAiB5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
@@ -23,7 +23,8 @@ function parseDownloadErrorPart(data, contentType) {
23
23
  const payloadObject = payload;
24
24
  const structuredMessage = payloadObject.message;
25
25
  const statusCode = payloadObject.statusCode ?? payloadObject.status_code;
26
- const errorCode = payloadObject.code ?? payloadObject.error_code;
26
+ const code = payloadObject.code ?? payloadObject.error_code;
27
+ const source = payloadObject.source;
27
28
  if (typeof structuredMessage === 'string') {
28
29
  message = structuredMessage;
29
30
  }
@@ -32,7 +33,9 @@ function parseDownloadErrorPart(data, contentType) {
32
33
  errorDetails: {
33
34
  message,
34
35
  statusCode: typeof statusCode === 'number' ? statusCode : undefined,
35
- errorCode: typeof errorCode === 'string' ? errorCode : undefined,
36
+ code: typeof code === 'string' ? code : undefined,
37
+ errorCode: typeof code === 'string' ? code : undefined,
38
+ source: typeof source === 'string' ? source : undefined,
36
39
  },
37
40
  };
38
41
  }