@daytonaio/sdk 0.200.1 → 0.201.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 (50) hide show
  1. package/cjs/Daytona.js +2 -2
  2. package/cjs/Daytona.js.map +1 -1
  3. package/cjs/FileSystem.d.ts +5 -1
  4. package/cjs/FileSystem.js +1 -1
  5. package/cjs/FileSystem.js.map +1 -1
  6. package/cjs/ObjectStorage.d.ts +2 -1
  7. package/cjs/ObjectStorage.js +1 -5
  8. package/cjs/ObjectStorage.js.map +1 -1
  9. package/cjs/Sandbox.d.ts +53 -0
  10. package/cjs/Sandbox.js +72 -0
  11. package/cjs/Sandbox.js.map +1 -1
  12. package/cjs/Snapshot.js +1 -0
  13. package/cjs/Snapshot.js.map +1 -1
  14. package/cjs/errors/DaytonaError.d.ts +119 -141
  15. package/cjs/errors/DaytonaError.js +225 -163
  16. package/cjs/errors/DaytonaError.js.map +1 -1
  17. package/cjs/index.d.ts +1 -1
  18. package/cjs/index.js +40 -6
  19. package/cjs/index.js.map +1 -1
  20. package/cjs/utils/FileTransfer.js +5 -2
  21. package/cjs/utils/FileTransfer.js.map +1 -1
  22. package/cjs/utils/fileUrlSigning.d.ts +4 -0
  23. package/cjs/utils/fileUrlSigning.js +47 -0
  24. package/cjs/utils/fileUrlSigning.js.map +1 -0
  25. package/esm/Daytona.js +2 -2
  26. package/esm/Daytona.js.map +1 -1
  27. package/esm/FileSystem.d.ts +5 -1
  28. package/esm/FileSystem.js +1 -1
  29. package/esm/FileSystem.js.map +1 -1
  30. package/esm/ObjectStorage.d.ts +2 -1
  31. package/esm/ObjectStorage.js +1 -5
  32. package/esm/ObjectStorage.js.map +1 -1
  33. package/esm/Sandbox.d.ts +53 -0
  34. package/esm/Sandbox.js +72 -0
  35. package/esm/Sandbox.js.map +1 -1
  36. package/esm/Snapshot.js +1 -0
  37. package/esm/Snapshot.js.map +1 -1
  38. package/esm/errors/DaytonaError.d.ts +119 -141
  39. package/esm/errors/DaytonaError.js +194 -157
  40. package/esm/errors/DaytonaError.js.map +1 -1
  41. package/esm/index.d.ts +1 -1
  42. package/esm/index.js +11 -1
  43. package/esm/index.js.map +1 -1
  44. package/esm/utils/FileTransfer.js +5 -2
  45. package/esm/utils/FileTransfer.js.map +1 -1
  46. package/esm/utils/Import.js +5 -3
  47. package/esm/utils/fileUrlSigning.d.ts +4 -0
  48. package/esm/utils/fileUrlSigning.js +42 -0
  49. package/esm/utils/fileUrlSigning.js.map +1 -0
  50. package/package.json +15 -13
@@ -4,193 +4,252 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.DaytonaConnectionError = exports.DaytonaTimeoutError = exports.DaytonaValidationError = exports.DaytonaConflictError = exports.DaytonaAuthorizationError = exports.DaytonaAuthenticationError = exports.DaytonaRateLimitError = exports.DaytonaNotFoundError = exports.DaytonaError = void 0;
7
+ exports.DaytonaRecordingFfmpegNotFoundError = exports.DaytonaRecordingStillActiveError = exports.DaytonaA11yUnavailableError = exports.DaytonaCommandAlreadyCompletedError = exports.DaytonaSessionEndedError = exports.DaytonaProcessNotFoundError = exports.DaytonaProcessExecutionTimeoutError = exports.DaytonaLspServerNotInitializedError = exports.DaytonaFileAccessDeniedError = exports.DaytonaFileNotFoundError = exports.DaytonaGitMergeConflictError = exports.DaytonaGitDirtyWorktreeError = exports.DaytonaGitPushRejectedError = exports.DaytonaGitBranchExistsError = exports.DaytonaGitBranchNotFoundError = exports.DaytonaGitRepoNotFoundError = exports.DaytonaGitAuthFailedError = exports.DaytonaConnectionTimeoutError = exports.DaytonaConnectionError = exports.DaytonaAuthorizationError = exports.DaytonaValidationError = exports.DaytonaServiceUnavailableError = exports.DaytonaBadGatewayError = exports.DaytonaInternalServerError = exports.DaytonaRateLimitError = exports.DaytonaUnprocessableEntityError = exports.DaytonaGoneError = exports.DaytonaConflictError = exports.DaytonaTimeoutError = exports.DaytonaNotFoundError = exports.DaytonaForbiddenError = exports.DaytonaAuthenticationError = exports.DaytonaBadRequestError = exports.DaytonaError = exports.SOURCE_PROXY = exports.SOURCE_DAEMON = exports.SOURCE_API = void 0;
8
8
  exports.errorClassFromStatusCode = errorClassFromStatusCode;
9
9
  exports.createDaytonaError = createDaytonaError;
10
10
  exports.createAxiosDaytonaError = createAxiosDaytonaError;
11
11
  /**
12
- * Base error for Daytona SDK.
13
- *
14
- * @example
15
- * ```ts
16
- * try {
17
- * await daytona.get('missing-sandbox')
18
- * } catch (error) {
19
- * if (error instanceof DaytonaError) {
20
- * console.log(error.statusCode)
21
- * console.log(error.errorCode)
22
- * console.log(error.message)
23
- * }
24
- * }
25
- * ```
12
+ * Wire-format `source` identifiers set by the translation layer when a
13
+ * Daytona service stamps them on the wire envelope. `source = undefined`
14
+ * means the response did not carry a structured envelope (treat as opaque).
15
+ */
16
+ exports.SOURCE_API = 'DAYTONA_API';
17
+ exports.SOURCE_DAEMON = 'DAYTONA_DAEMON';
18
+ exports.SOURCE_PROXY = 'DAYTONA_PROXY';
19
+ /**
20
+ * Base error for Daytona SDK. `statusCode` and `code` are populated only
21
+ * for errors translated from a server response. `source` is `undefined`
22
+ * unless the caller (or the translation layer) sets it.
26
23
  */
27
24
  class DaytonaError extends Error {
28
- /** HTTP status code if available */
29
25
  statusCode;
30
- /** Machine-readable error code if available */
31
- errorCode;
32
- /** Response headers if available */
26
+ code;
27
+ source;
33
28
  headers;
34
- constructor(message, statusCode, headers, errorCode) {
29
+ constructor(message, statusCode, headers, code, source) {
35
30
  super(message);
36
31
  this.name = new.target.name;
37
32
  this.statusCode = statusCode;
38
33
  this.headers = headers;
39
- this.errorCode = errorCode;
34
+ this.code = code;
35
+ this.source = source;
36
+ }
37
+ /**
38
+ * @deprecated Use {@link DaytonaError.code} instead. Kept so existing
39
+ * `err.errorCode` reads keep returning the machine-readable code.
40
+ * @returns the machine-readable error code, or `undefined` when the
41
+ * response did not carry one (same as {@link DaytonaError.code})
42
+ */
43
+ get errorCode() {
44
+ return this.code;
40
45
  }
41
46
  }
42
47
  exports.DaytonaError = DaytonaError;
43
- /**
44
- * Error thrown when a resource is not found (HTTP 404).
45
- *
46
- * @example
47
- * ```ts
48
- * try {
49
- * await sandbox.fs.downloadFile('/workspace/missing.txt')
50
- * } catch (error) {
51
- * if (error instanceof DaytonaNotFoundError) {
52
- * console.log(error.statusCode)
53
- * }
54
- * }
55
- * ```
56
- */
48
+ // HTTP-status classes — one per status code Daytona services emit.
49
+ // Names follow HTTP terminology (BadRequest=400, Forbidden=403).
50
+ /** The request was malformed or invalid (HTTP 400). */
51
+ class DaytonaBadRequestError extends DaytonaError {
52
+ }
53
+ exports.DaytonaBadRequestError = DaytonaBadRequestError;
54
+ /** Authentication failed — missing or invalid credentials (HTTP 401). */
55
+ class DaytonaAuthenticationError extends DaytonaError {
56
+ }
57
+ exports.DaytonaAuthenticationError = DaytonaAuthenticationError;
58
+ /** The authenticated caller lacks permission for the operation (HTTP 403). */
59
+ class DaytonaForbiddenError extends DaytonaError {
60
+ }
61
+ exports.DaytonaForbiddenError = DaytonaForbiddenError;
62
+ /** The requested resource does not exist (HTTP 404). */
57
63
  class DaytonaNotFoundError extends DaytonaError {
58
64
  }
59
65
  exports.DaytonaNotFoundError = DaytonaNotFoundError;
60
- /**
61
- * Error thrown when rate limit is exceeded.
62
- *
63
- * @example
64
- * ```ts
65
- * try {
66
- * for await (const sandbox of daytona.list()) {
67
- * console.log(sandbox.id)
68
- * }
69
- * } catch (error) {
70
- * if (error instanceof DaytonaRateLimitError) {
71
- * console.log(error.errorCode)
72
- * }
73
- * }
74
- * ```
75
- */
66
+ /** The operation timed out (HTTP 408, or 504 when a gateway timed out). */
67
+ class DaytonaTimeoutError extends DaytonaError {
68
+ }
69
+ exports.DaytonaTimeoutError = DaytonaTimeoutError;
70
+ /** The request conflicts with the current state of the resource (HTTP 409). */
71
+ class DaytonaConflictError extends DaytonaError {
72
+ }
73
+ exports.DaytonaConflictError = DaytonaConflictError;
74
+ /** The resource existed but is permanently gone (HTTP 410). */
75
+ class DaytonaGoneError extends DaytonaError {
76
+ }
77
+ exports.DaytonaGoneError = DaytonaGoneError;
78
+ /** The request was well-formed but semantically invalid (HTTP 422). */
79
+ class DaytonaUnprocessableEntityError extends DaytonaError {
80
+ }
81
+ exports.DaytonaUnprocessableEntityError = DaytonaUnprocessableEntityError;
82
+ /** The caller exceeded a rate limit (HTTP 429). */
76
83
  class DaytonaRateLimitError extends DaytonaError {
77
84
  }
78
85
  exports.DaytonaRateLimitError = DaytonaRateLimitError;
79
- /**
80
- * Error thrown when authentication fails (HTTP 401).
81
- *
82
- * @example
83
- * ```ts
84
- * try {
85
- * for await (const sandbox of daytona.list()) {
86
- * console.log(sandbox.id)
87
- * }
88
- * } catch (error) {
89
- * if (error instanceof DaytonaAuthenticationError) {
90
- * console.log(error.statusCode)
91
- * }
92
- * }
93
- * ```
94
- */
95
- class DaytonaAuthenticationError extends DaytonaError {
86
+ /** A Daytona service failed unexpectedly (HTTP 500). */
87
+ class DaytonaInternalServerError extends DaytonaError {
96
88
  }
97
- exports.DaytonaAuthenticationError = DaytonaAuthenticationError;
98
- /**
99
- * Error thrown when the request is forbidden (HTTP 403).
100
- *
101
- * @example
102
- * ```ts
103
- * try {
104
- * await daytona.get('sandbox-without-access')
105
- * } catch (error) {
106
- * if (error instanceof DaytonaAuthorizationError) {
107
- * console.log(error.message)
108
- * }
109
- * }
110
- * ```
111
- */
112
- class DaytonaAuthorizationError extends DaytonaError {
89
+ exports.DaytonaInternalServerError = DaytonaInternalServerError;
90
+ /** An upstream gateway returned an invalid response (HTTP 502). */
91
+ class DaytonaBadGatewayError extends DaytonaError {
113
92
  }
114
- exports.DaytonaAuthorizationError = DaytonaAuthorizationError;
115
- /**
116
- * Error thrown when a resource conflict occurs (HTTP 409).
117
- *
118
- * @example
119
- * ```ts
120
- * try {
121
- * await daytona.create({ name: 'existing-sandbox' })
122
- * } catch (error) {
123
- * if (error instanceof DaytonaConflictError) {
124
- * console.log(error.errorCode)
125
- * }
126
- * }
127
- * ```
128
- */
129
- class DaytonaConflictError extends DaytonaError {
93
+ exports.DaytonaBadGatewayError = DaytonaBadGatewayError;
94
+ /** The service is temporarily unable to handle the request (HTTP 503). */
95
+ class DaytonaServiceUnavailableError extends DaytonaError {
130
96
  }
131
- exports.DaytonaConflictError = DaytonaConflictError;
97
+ exports.DaytonaServiceUnavailableError = DaytonaServiceUnavailableError;
98
+ // ============================================================================
99
+ // Backward-compatibility subclasses. New functionality belongs elsewhere in
100
+ // this file, not here. These are what the 400/403 entries of
101
+ // STATUS_CODE_TO_ERROR throw so pre-rename `instanceof` checks keep matching.
102
+ // They must stay declared BEFORE that map (TDZ) and in this file (import
103
+ // cycle), and can be removed together with those two map entries in a future
104
+ // major release. The deprecated `errorCode` getter on DaytonaError belongs to
105
+ // the same removal set.
106
+ // ============================================================================
132
107
  /**
133
- * Error thrown when input validation fails (HTTP 400 or client-side validation).
134
- *
135
- * @example
136
- * ```ts
137
- * try {
138
- * Image.debianSlim('3.8' as never)
139
- * } catch (error) {
140
- * if (error instanceof DaytonaValidationError) {
141
- * console.log(error.message)
142
- * }
143
- * }
144
- * ```
108
+ * @deprecated Use {@link DaytonaBadRequestError} instead. Re-exported so
109
+ * existing `catch (err) { if (err instanceof DaytonaValidationError) ... }`
110
+ * blocks keep working.
145
111
  */
146
- class DaytonaValidationError extends DaytonaError {
112
+ class DaytonaValidationError extends DaytonaBadRequestError {
147
113
  }
148
114
  exports.DaytonaValidationError = DaytonaValidationError;
149
115
  /**
150
- * Error thrown when a timeout occurs.
151
- *
152
- * @example
153
- * ```ts
154
- * try {
155
- * await sandbox.waitUntilStarted(1)
156
- * } catch (error) {
157
- * if (error instanceof DaytonaTimeoutError) {
158
- * console.log(error.message)
159
- * }
160
- * }
161
- * ```
116
+ * @deprecated Use {@link DaytonaForbiddenError} instead.
162
117
  */
163
- class DaytonaTimeoutError extends DaytonaError {
118
+ class DaytonaAuthorizationError extends DaytonaForbiddenError {
164
119
  }
165
- exports.DaytonaTimeoutError = DaytonaTimeoutError;
120
+ exports.DaytonaAuthorizationError = DaytonaAuthorizationError;
121
+ /** Network connection failure (can't connect or mid-request drop). */
122
+ class DaytonaConnectionError extends DaytonaError {
123
+ }
124
+ exports.DaytonaConnectionError = DaytonaConnectionError;
125
+ /** Transport-layer timeout (connect / read). Subclass of DaytonaConnectionError. */
126
+ class DaytonaConnectionTimeoutError extends DaytonaConnectionError {
127
+ }
128
+ exports.DaytonaConnectionTimeoutError = DaytonaConnectionTimeoutError;
129
+ // Domain-specific subclasses. Each inherits from the HTTP-status class that
130
+ // matches its server-side status, so callers can catch either level.
131
+ // --- Git (daemon) ---
132
+ /** Git authentication against the remote failed (code `GIT_AUTH_FAILED`). */
133
+ class DaytonaGitAuthFailedError extends DaytonaAuthenticationError {
134
+ }
135
+ exports.DaytonaGitAuthFailedError = DaytonaGitAuthFailedError;
136
+ /** The git remote repository was not found (code `GIT_REPO_NOT_FOUND`). */
137
+ class DaytonaGitRepoNotFoundError extends DaytonaNotFoundError {
138
+ }
139
+ exports.DaytonaGitRepoNotFoundError = DaytonaGitRepoNotFoundError;
140
+ /** The git branch does not exist (code `GIT_BRANCH_NOT_FOUND`). */
141
+ class DaytonaGitBranchNotFoundError extends DaytonaNotFoundError {
142
+ }
143
+ exports.DaytonaGitBranchNotFoundError = DaytonaGitBranchNotFoundError;
144
+ /** The git branch already exists (code `GIT_BRANCH_EXISTS`). */
145
+ class DaytonaGitBranchExistsError extends DaytonaConflictError {
146
+ }
147
+ exports.DaytonaGitBranchExistsError = DaytonaGitBranchExistsError;
148
+ /** The git push was rejected by the remote (code `GIT_PUSH_REJECTED`). */
149
+ class DaytonaGitPushRejectedError extends DaytonaConflictError {
150
+ }
151
+ exports.DaytonaGitPushRejectedError = DaytonaGitPushRejectedError;
152
+ /** The operation requires a clean worktree (code `GIT_DIRTY_WORKTREE`). */
153
+ class DaytonaGitDirtyWorktreeError extends DaytonaConflictError {
154
+ }
155
+ exports.DaytonaGitDirtyWorktreeError = DaytonaGitDirtyWorktreeError;
156
+ /** A git merge produced conflicts (code `GIT_MERGE_CONFLICT`). */
157
+ class DaytonaGitMergeConflictError extends DaytonaConflictError {
158
+ }
159
+ exports.DaytonaGitMergeConflictError = DaytonaGitMergeConflictError;
160
+ // --- Filesystem (daemon) ---
161
+ /** The file does not exist in the sandbox (code `FILE_NOT_FOUND`). */
162
+ class DaytonaFileNotFoundError extends DaytonaNotFoundError {
163
+ }
164
+ exports.DaytonaFileNotFoundError = DaytonaFileNotFoundError;
165
+ /** Access to the sandbox file was denied (code `FILE_ACCESS_DENIED`). */
166
+ class DaytonaFileAccessDeniedError extends DaytonaForbiddenError {
167
+ }
168
+ exports.DaytonaFileAccessDeniedError = DaytonaFileAccessDeniedError;
169
+ // --- LSP (daemon) ---
170
+ /** The LSP server must be initialized first (code `LSP_SERVER_NOT_INITIALIZED`). */
171
+ class DaytonaLspServerNotInitializedError extends DaytonaBadRequestError {
172
+ }
173
+ exports.DaytonaLspServerNotInitializedError = DaytonaLspServerNotInitializedError;
174
+ // --- Process / session (daemon) ---
175
+ /** Command execution exceeded its timeout (code `PROCESS_EXECUTION_TIMEOUT`). */
176
+ class DaytonaProcessExecutionTimeoutError extends DaytonaTimeoutError {
177
+ }
178
+ exports.DaytonaProcessExecutionTimeoutError = DaytonaProcessExecutionTimeoutError;
179
+ /** The sandbox process does not exist (code `PROCESS_NOT_FOUND`). */
180
+ class DaytonaProcessNotFoundError extends DaytonaNotFoundError {
181
+ }
182
+ exports.DaytonaProcessNotFoundError = DaytonaProcessNotFoundError;
183
+ /** The session has already ended (code `SESSION_ENDED`). */
184
+ class DaytonaSessionEndedError extends DaytonaGoneError {
185
+ }
186
+ exports.DaytonaSessionEndedError = DaytonaSessionEndedError;
187
+ /** The session command already finished (code `COMMAND_ALREADY_COMPLETED`). */
188
+ class DaytonaCommandAlreadyCompletedError extends DaytonaGoneError {
189
+ }
190
+ exports.DaytonaCommandAlreadyCompletedError = DaytonaCommandAlreadyCompletedError;
191
+ // --- Computer-use (daemon) ---
192
+ /** The accessibility service is unavailable (code `A11Y_UNAVAILABLE`). */
193
+ class DaytonaA11yUnavailableError extends DaytonaServiceUnavailableError {
194
+ }
195
+ exports.DaytonaA11yUnavailableError = DaytonaA11yUnavailableError;
196
+ /** A screen recording is still active (code `RECORDING_STILL_ACTIVE`). */
197
+ class DaytonaRecordingStillActiveError extends DaytonaConflictError {
198
+ }
199
+ exports.DaytonaRecordingStillActiveError = DaytonaRecordingStillActiveError;
200
+ /** ffmpeg is not available for recording (code `RECORDING_FFMPEG_NOT_FOUND`). */
201
+ class DaytonaRecordingFfmpegNotFoundError extends DaytonaServiceUnavailableError {
202
+ }
203
+ exports.DaytonaRecordingFfmpegNotFoundError = DaytonaRecordingFfmpegNotFoundError;
166
204
  /**
167
- * Error thrown when a network connection fails.
205
+ * (source, code) precise DaytonaError subclass. Lookup runs before the
206
+ * HTTP status code fallback, so a domain code wins over the status default.
168
207
  *
169
- * @example
170
- * ```ts
171
- * try {
172
- * await ptyHandle.waitForConnection()
173
- * } catch (error) {
174
- * if (error instanceof DaytonaConnectionError) {
175
- * console.log(error.message)
176
- * }
177
- * }
178
- * ```
208
+ * Code strings are kept inline (not imported from the generated clients) so
209
+ * tests that virtual-mock the API client modules don't break module init.
210
+ * Drift is caught by the cross-language code-catalog generator + CI checks.
179
211
  */
180
- class DaytonaConnectionError extends DaytonaError {
212
+ const CODE_TO_ERROR_CLASS = {
213
+ // Daemon
214
+ 'DAYTONA_DAEMON|GIT_AUTH_FAILED': DaytonaGitAuthFailedError,
215
+ 'DAYTONA_DAEMON|GIT_REPO_NOT_FOUND': DaytonaGitRepoNotFoundError,
216
+ 'DAYTONA_DAEMON|GIT_BRANCH_NOT_FOUND': DaytonaGitBranchNotFoundError,
217
+ 'DAYTONA_DAEMON|GIT_BRANCH_EXISTS': DaytonaGitBranchExistsError,
218
+ 'DAYTONA_DAEMON|GIT_PUSH_REJECTED': DaytonaGitPushRejectedError,
219
+ 'DAYTONA_DAEMON|GIT_DIRTY_WORKTREE': DaytonaGitDirtyWorktreeError,
220
+ 'DAYTONA_DAEMON|GIT_MERGE_CONFLICT': DaytonaGitMergeConflictError,
221
+ 'DAYTONA_DAEMON|FILE_NOT_FOUND': DaytonaFileNotFoundError,
222
+ 'DAYTONA_DAEMON|FILE_ACCESS_DENIED': DaytonaFileAccessDeniedError,
223
+ 'DAYTONA_DAEMON|LSP_SERVER_NOT_INITIALIZED': DaytonaLspServerNotInitializedError,
224
+ 'DAYTONA_DAEMON|PROCESS_EXECUTION_TIMEOUT': DaytonaProcessExecutionTimeoutError,
225
+ 'DAYTONA_DAEMON|PROCESS_NOT_FOUND': DaytonaProcessNotFoundError,
226
+ 'DAYTONA_DAEMON|SESSION_ENDED': DaytonaSessionEndedError,
227
+ 'DAYTONA_DAEMON|COMMAND_ALREADY_COMPLETED': DaytonaCommandAlreadyCompletedError,
228
+ 'DAYTONA_DAEMON|A11Y_UNAVAILABLE': DaytonaA11yUnavailableError,
229
+ 'DAYTONA_DAEMON|RECORDING_STILL_ACTIVE': DaytonaRecordingStillActiveError,
230
+ 'DAYTONA_DAEMON|RECORDING_FFMPEG_NOT_FOUND': DaytonaRecordingFfmpegNotFoundError,
231
+ };
232
+ function lookupErrorClass(source, code) {
233
+ if (!code || !source)
234
+ return undefined;
235
+ return CODE_TO_ERROR_CLASS[`${source}|${code}`];
181
236
  }
182
- exports.DaytonaConnectionError = DaytonaConnectionError;
183
237
  const STATUS_CODE_TO_ERROR = {
184
238
  400: DaytonaValidationError,
185
239
  401: DaytonaAuthenticationError,
186
240
  403: DaytonaAuthorizationError,
187
241
  404: DaytonaNotFoundError,
242
+ 408: DaytonaTimeoutError,
188
243
  409: DaytonaConflictError,
244
+ 410: DaytonaGoneError,
245
+ 422: DaytonaUnprocessableEntityError,
189
246
  429: DaytonaRateLimitError,
247
+ 500: DaytonaInternalServerError,
248
+ 502: DaytonaBadGatewayError,
249
+ 503: DaytonaServiceUnavailableError,
250
+ 504: DaytonaTimeoutError,
190
251
  };
191
- /**
192
- * Maps an HTTP status code to the corresponding Daytona error class.
193
- */
252
+ /** Maps an HTTP status code to the corresponding Daytona error class. */
194
253
  function errorClassFromStatusCode(statusCode) {
195
254
  if (statusCode === undefined) {
196
255
  return DaytonaError;
@@ -199,10 +258,12 @@ function errorClassFromStatusCode(statusCode) {
199
258
  }
200
259
  /**
201
260
  * Creates the appropriate Daytona error subclass from structured error metadata.
261
+ *
262
+ * Resolution order: (source, code) override -> HTTP status code -> DaytonaError.
202
263
  */
203
- function createDaytonaError(message, statusCode, headers, errorCode) {
204
- const ErrorClass = errorClassFromStatusCode(statusCode);
205
- return new ErrorClass(message, statusCode, headers, errorCode);
264
+ function createDaytonaError(message, statusCode, headers, code, source) {
265
+ const ErrorClass = lookupErrorClass(source, code) || errorClassFromStatusCode(statusCode);
266
+ return new ErrorClass(message, statusCode, headers, code, source);
206
267
  }
207
268
  function isAxiosTimeoutError(error) {
208
269
  return error.code === 'ECONNABORTED' || error.code === 'ETIMEDOUT' || error.message.includes('timeout of');
@@ -214,23 +275,20 @@ function getAxiosResponseDataObject(error) {
214
275
  return error.response.data;
215
276
  }
216
277
  function extractAxiosErrorCode(responseData) {
217
- if (typeof responseData?.code === 'string') {
218
- return responseData.code;
219
- }
220
- if (typeof responseData?.error_code === 'string') {
221
- return responseData.error_code;
222
- }
223
- if (typeof responseData?.error === 'string') {
224
- return responseData.error;
225
- }
226
- return undefined;
278
+ const code = responseData?.code ?? responseData?.error_code;
279
+ return typeof code === 'string' ? code : undefined;
280
+ }
281
+ function extractAxiosErrorSource(responseData) {
282
+ return typeof responseData?.source === 'string' ? responseData.source : undefined;
227
283
  }
228
284
  function extractAxiosErrorMessage(error) {
229
285
  if (isAxiosTimeoutError(error)) {
230
286
  return 'Operation timed out';
231
287
  }
232
288
  const responseData = getAxiosResponseDataObject(error);
233
- const responseMessage = responseData?.message || error.response?.data;
289
+ const responseMessage = (typeof responseData?.message === 'string' ? responseData.message : undefined) ??
290
+ (typeof responseData?.error === 'string' ? responseData.error : undefined) ??
291
+ error.response?.data;
234
292
  const message = responseMessage || error.message || String(error);
235
293
  if (typeof message === 'object') {
236
294
  try {
@@ -243,20 +301,24 @@ function extractAxiosErrorMessage(error) {
243
301
  return String(message);
244
302
  }
245
303
  /**
246
- * Creates the appropriate Daytona error subclass from an Axios error.
304
+ * Creates the appropriate Daytona error subclass from an Axios error. Maps
305
+ * client-side timeouts to DaytonaConnectionTimeoutError, networking failures
306
+ * (no response received) to DaytonaConnectionError, and HTTP responses to
307
+ * the most specific subclass via `createDaytonaError`.
247
308
  */
248
309
  function createAxiosDaytonaError(error) {
249
310
  const message = extractAxiosErrorMessage(error);
250
311
  const statusCode = error.response?.status;
251
312
  const headers = error.response?.headers;
252
313
  const responseData = getAxiosResponseDataObject(error);
253
- const errorCode = extractAxiosErrorCode(responseData);
314
+ const code = extractAxiosErrorCode(responseData);
315
+ const source = extractAxiosErrorSource(responseData);
254
316
  if (isAxiosTimeoutError(error)) {
255
- return new DaytonaTimeoutError(message, statusCode, headers, errorCode);
317
+ return new DaytonaConnectionTimeoutError(message, statusCode, headers, code, source);
256
318
  }
257
319
  if (!error.response && (error.request || error.code)) {
258
- return new DaytonaConnectionError(message, statusCode, headers, errorCode);
320
+ return new DaytonaConnectionError(message, statusCode, headers, code, source);
259
321
  }
260
- return createDaytonaError(message, statusCode, headers, errorCode);
322
+ return createDaytonaError(message, statusCode, headers, code, source);
261
323
  }
262
324
  //# sourceMappingURL=DaytonaError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DaytonaError.js","sourceRoot":"","sources":["../../../../../sdk-typescript/src/errors/DaytonaError.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA4LH,4DAMC;AAKD,gDAQC;AAqDD,0DAgBC;AAzQD;;;;;;;;;;;;;;;GAeG;AACH,MAAa,YAAa,SAAQ,KAAK;IACrC,oCAAoC;IAC7B,UAAU,CAAS;IAC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uBAAuB,CAAC,YAAY,CAAC,CAAA;IAEpD,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,6BAA6B,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IACtF,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IAC/E,CAAC;IAED,OAAO,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;AACvE,CAAC"}
package/cjs/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export type { DownloadProgress, DownloadMetadata, DownloadStreamOptions, UploadP
5
5
  export { Git } from './Git';
6
6
  export { LspLanguageId } from './LspServer';
7
7
  export { Process } from './Process';
8
- export { DaytonaAuthenticationError, DaytonaAuthorizationError, DaytonaConflictError, DaytonaConnectionError, DaytonaError, DaytonaNotFoundError, DaytonaRateLimitError, DaytonaTimeoutError, DaytonaValidationError, } from './errors/DaytonaError';
8
+ export { SOURCE_API, SOURCE_DAEMON, SOURCE_PROXY, DaytonaError, DaytonaBadRequestError, DaytonaValidationError, DaytonaAuthenticationError, DaytonaForbiddenError, DaytonaAuthorizationError, DaytonaNotFoundError, DaytonaTimeoutError, DaytonaConflictError, DaytonaGoneError, DaytonaUnprocessableEntityError, DaytonaRateLimitError, DaytonaInternalServerError, DaytonaBadGatewayError, DaytonaServiceUnavailableError, DaytonaConnectionError, DaytonaConnectionTimeoutError, DaytonaGitAuthFailedError, DaytonaGitRepoNotFoundError, DaytonaGitBranchNotFoundError, DaytonaGitBranchExistsError, DaytonaGitPushRejectedError, DaytonaGitDirtyWorktreeError, DaytonaGitMergeConflictError, DaytonaFileNotFoundError, DaytonaFileAccessDeniedError, DaytonaLspServerNotInitializedError, DaytonaProcessExecutionTimeoutError, DaytonaProcessNotFoundError, DaytonaSessionEndedError, DaytonaCommandAlreadyCompletedError, DaytonaA11yUnavailableError, DaytonaRecordingStillActiveError, DaytonaRecordingFfmpegNotFoundError, } from './errors/DaytonaError';
9
9
  export { Image } from './Image';
10
10
  export { Sandbox } from './Sandbox';
11
11
  export type { ListSandboxesQuery, SandboxMetrics } from './Sandbox';
package/cjs/index.js CHANGED
@@ -4,7 +4,8 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ListSecretsPaginatedOrderEnum = exports.ListSecretsPaginatedSortEnum = exports.SandboxClass = exports.SandboxListSortDirection = exports.SandboxListSortField = exports.SandboxState = exports.GpuType = exports.ChartType = exports.Accessibility = exports.Display = exports.Screenshot = exports.Keyboard = exports.Mouse = exports.ComputerUse = exports.Sandbox = exports.Image = exports.DaytonaValidationError = exports.DaytonaTimeoutError = exports.DaytonaRateLimitError = exports.DaytonaNotFoundError = exports.DaytonaError = exports.DaytonaConnectionError = exports.DaytonaConflictError = exports.DaytonaAuthorizationError = exports.DaytonaAuthenticationError = exports.Process = exports.LspLanguageId = exports.Git = exports.FileSystem = exports.Daytona = exports.CodeLanguage = void 0;
7
+ exports.Display = exports.Screenshot = exports.Keyboard = exports.Mouse = exports.ComputerUse = exports.Sandbox = exports.Image = exports.DaytonaRecordingFfmpegNotFoundError = exports.DaytonaRecordingStillActiveError = exports.DaytonaA11yUnavailableError = exports.DaytonaCommandAlreadyCompletedError = exports.DaytonaSessionEndedError = exports.DaytonaProcessNotFoundError = exports.DaytonaProcessExecutionTimeoutError = exports.DaytonaLspServerNotInitializedError = exports.DaytonaFileAccessDeniedError = exports.DaytonaFileNotFoundError = exports.DaytonaGitMergeConflictError = exports.DaytonaGitDirtyWorktreeError = exports.DaytonaGitPushRejectedError = exports.DaytonaGitBranchExistsError = exports.DaytonaGitBranchNotFoundError = exports.DaytonaGitRepoNotFoundError = exports.DaytonaGitAuthFailedError = exports.DaytonaConnectionTimeoutError = exports.DaytonaConnectionError = exports.DaytonaServiceUnavailableError = exports.DaytonaBadGatewayError = exports.DaytonaInternalServerError = exports.DaytonaRateLimitError = exports.DaytonaUnprocessableEntityError = exports.DaytonaGoneError = exports.DaytonaConflictError = exports.DaytonaTimeoutError = exports.DaytonaNotFoundError = exports.DaytonaAuthorizationError = exports.DaytonaForbiddenError = exports.DaytonaAuthenticationError = exports.DaytonaValidationError = exports.DaytonaBadRequestError = exports.DaytonaError = exports.SOURCE_PROXY = exports.SOURCE_DAEMON = exports.SOURCE_API = exports.Process = exports.LspLanguageId = exports.Git = exports.FileSystem = exports.Daytona = exports.CodeLanguage = void 0;
8
+ exports.ListSecretsPaginatedOrderEnum = exports.ListSecretsPaginatedSortEnum = exports.SandboxClass = exports.SandboxListSortDirection = exports.SandboxListSortField = exports.SandboxState = exports.GpuType = exports.ChartType = exports.Accessibility = void 0;
8
9
  const tslib_1 = require("tslib");
9
10
  var Daytona_1 = require("./Daytona");
10
11
  Object.defineProperty(exports, "CodeLanguage", { enumerable: true, get: function () { return Daytona_1.CodeLanguage; } });
@@ -20,15 +21,48 @@ Object.defineProperty(exports, "Process", { enumerable: true, get: function () {
20
21
  // export { LspServer } from './LspServer'
21
22
  // export type { LspLanguageId, Position } from './LspServer'
22
23
  var DaytonaError_1 = require("./errors/DaytonaError");
24
+ // Wire-format `source` identifiers for matching against `error.source`
25
+ Object.defineProperty(exports, "SOURCE_API", { enumerable: true, get: function () { return DaytonaError_1.SOURCE_API; } });
26
+ Object.defineProperty(exports, "SOURCE_DAEMON", { enumerable: true, get: function () { return DaytonaError_1.SOURCE_DAEMON; } });
27
+ Object.defineProperty(exports, "SOURCE_PROXY", { enumerable: true, get: function () { return DaytonaError_1.SOURCE_PROXY; } });
28
+ // Base + status-code classes
29
+ Object.defineProperty(exports, "DaytonaError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaError; } });
30
+ Object.defineProperty(exports, "DaytonaBadRequestError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaBadRequestError; } });
31
+ // Deprecated aliases
32
+ Object.defineProperty(exports, "DaytonaValidationError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaValidationError; } });
23
33
  Object.defineProperty(exports, "DaytonaAuthenticationError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaAuthenticationError; } });
34
+ Object.defineProperty(exports, "DaytonaForbiddenError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaForbiddenError; } });
35
+ // Deprecated alias
24
36
  Object.defineProperty(exports, "DaytonaAuthorizationError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaAuthorizationError; } });
25
- Object.defineProperty(exports, "DaytonaConflictError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaConflictError; } });
26
- Object.defineProperty(exports, "DaytonaConnectionError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaConnectionError; } });
27
- Object.defineProperty(exports, "DaytonaError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaError; } });
28
37
  Object.defineProperty(exports, "DaytonaNotFoundError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaNotFoundError; } });
29
- Object.defineProperty(exports, "DaytonaRateLimitError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaRateLimitError; } });
30
38
  Object.defineProperty(exports, "DaytonaTimeoutError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaTimeoutError; } });
31
- Object.defineProperty(exports, "DaytonaValidationError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaValidationError; } });
39
+ Object.defineProperty(exports, "DaytonaConflictError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaConflictError; } });
40
+ Object.defineProperty(exports, "DaytonaGoneError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaGoneError; } });
41
+ Object.defineProperty(exports, "DaytonaUnprocessableEntityError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaUnprocessableEntityError; } });
42
+ Object.defineProperty(exports, "DaytonaRateLimitError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaRateLimitError; } });
43
+ Object.defineProperty(exports, "DaytonaInternalServerError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaInternalServerError; } });
44
+ Object.defineProperty(exports, "DaytonaBadGatewayError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaBadGatewayError; } });
45
+ Object.defineProperty(exports, "DaytonaServiceUnavailableError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaServiceUnavailableError; } });
46
+ Object.defineProperty(exports, "DaytonaConnectionError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaConnectionError; } });
47
+ Object.defineProperty(exports, "DaytonaConnectionTimeoutError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaConnectionTimeoutError; } });
48
+ // Domain-specific subclasses
49
+ Object.defineProperty(exports, "DaytonaGitAuthFailedError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaGitAuthFailedError; } });
50
+ Object.defineProperty(exports, "DaytonaGitRepoNotFoundError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaGitRepoNotFoundError; } });
51
+ Object.defineProperty(exports, "DaytonaGitBranchNotFoundError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaGitBranchNotFoundError; } });
52
+ Object.defineProperty(exports, "DaytonaGitBranchExistsError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaGitBranchExistsError; } });
53
+ Object.defineProperty(exports, "DaytonaGitPushRejectedError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaGitPushRejectedError; } });
54
+ Object.defineProperty(exports, "DaytonaGitDirtyWorktreeError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaGitDirtyWorktreeError; } });
55
+ Object.defineProperty(exports, "DaytonaGitMergeConflictError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaGitMergeConflictError; } });
56
+ Object.defineProperty(exports, "DaytonaFileNotFoundError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaFileNotFoundError; } });
57
+ Object.defineProperty(exports, "DaytonaFileAccessDeniedError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaFileAccessDeniedError; } });
58
+ Object.defineProperty(exports, "DaytonaLspServerNotInitializedError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaLspServerNotInitializedError; } });
59
+ Object.defineProperty(exports, "DaytonaProcessExecutionTimeoutError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaProcessExecutionTimeoutError; } });
60
+ Object.defineProperty(exports, "DaytonaProcessNotFoundError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaProcessNotFoundError; } });
61
+ Object.defineProperty(exports, "DaytonaSessionEndedError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaSessionEndedError; } });
62
+ Object.defineProperty(exports, "DaytonaCommandAlreadyCompletedError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaCommandAlreadyCompletedError; } });
63
+ Object.defineProperty(exports, "DaytonaA11yUnavailableError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaA11yUnavailableError; } });
64
+ Object.defineProperty(exports, "DaytonaRecordingStillActiveError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaRecordingStillActiveError; } });
65
+ Object.defineProperty(exports, "DaytonaRecordingFfmpegNotFoundError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaRecordingFfmpegNotFoundError; } });
32
66
  var Image_1 = require("./Image");
33
67
  Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return Image_1.Image; } });
34
68
  var Sandbox_1 = require("./Sandbox");
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../sdk-typescript/src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,qCAAiD;AAAxC,uGAAA,YAAY,OAAA;AAAE,kGAAA,OAAO,OAAA;AAS9B,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AAcnB,6BAA2B;AAAlB,0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d,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAIhB,6CAAgG;AAAvF,0GAAA,WAAW,OAAA;AAAE,oGAAA,KAAK,OAAA;AAAE,uGAAA,QAAQ,OAAA;AAAE,yGAAA,UAAU,OAAA;AAAE,sGAAA,OAAO,OAAA;AAAE,4GAAA,aAAa,OAAA;AAiBzE,yCAA0C;AAAjC,mGAAA,SAAS,OAAA;AAGlB,kDAQ4B;AAP1B,qGAAA,OAAO,OAAA;AACP,0GAAA,YAAY,OAAA;AACZ,kHAAA,oBAAoB,OAAA;AACpB,sHAAA,wBAAwB,OAAA;AACxB,0GAAA,YAAY,OAAA;AACZ,0HAAA,4BAA4B,OAAA;AAC5B,2HAAA,6BAA6B,OAAA;AAkB/B,oDAAyB;AACzB,sDAA2B;AAC3B,sDAA2B"}
@@ -32,7 +32,8 @@ function parseDownloadErrorPart(data, contentType) {
32
32
  const payloadObject = payload;
33
33
  const structuredMessage = payloadObject.message;
34
34
  const statusCode = payloadObject.statusCode ?? payloadObject.status_code;
35
- const errorCode = payloadObject.code ?? payloadObject.error_code;
35
+ const code = payloadObject.code ?? payloadObject.error_code;
36
+ const source = payloadObject.source;
36
37
  if (typeof structuredMessage === 'string') {
37
38
  message = structuredMessage;
38
39
  }
@@ -41,7 +42,9 @@ function parseDownloadErrorPart(data, contentType) {
41
42
  errorDetails: {
42
43
  message,
43
44
  statusCode: typeof statusCode === 'number' ? statusCode : undefined,
44
- errorCode: typeof errorCode === 'string' ? errorCode : undefined,
45
+ code: typeof code === 'string' ? code : undefined,
46
+ errorCode: typeof code === 'string' ? code : undefined,
47
+ source: typeof source === 'string' ? source : undefined,
45
48
  },
46
49
  };
47
50
  }