@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
@@ -5,172 +5,196 @@ import { AxiosHeaders } from 'axios';
5
5
  import type { AxiosError } from 'axios';
6
6
  export type ResponseHeaders = InstanceType<typeof AxiosHeaders>;
7
7
  /**
8
- * Base error for Daytona SDK.
9
- *
10
- * @example
11
- * ```ts
12
- * try {
13
- * await daytona.get('missing-sandbox')
14
- * } catch (error) {
15
- * if (error instanceof DaytonaError) {
16
- * console.log(error.statusCode)
17
- * console.log(error.errorCode)
18
- * console.log(error.message)
19
- * }
20
- * }
21
- * ```
8
+ * Wire-format `source` identifiers set by the translation layer when a
9
+ * Daytona service stamps them on the wire envelope. `source = undefined`
10
+ * means the response did not carry a structured envelope (treat as opaque).
11
+ */
12
+ export declare const SOURCE_API = "DAYTONA_API";
13
+ export declare const SOURCE_DAEMON = "DAYTONA_DAEMON";
14
+ export declare const SOURCE_PROXY = "DAYTONA_PROXY";
15
+ /**
16
+ * Base error for Daytona SDK. `statusCode` and `code` are populated only
17
+ * for errors translated from a server response. `source` is `undefined`
18
+ * unless the caller (or the translation layer) sets it.
22
19
  */
23
20
  export declare class DaytonaError extends Error {
24
- /** HTTP status code if available */
25
21
  statusCode?: number;
26
- /** Machine-readable error code if available */
27
- errorCode?: string;
28
- /** Response headers if available */
22
+ code?: string;
23
+ readonly source?: string;
29
24
  headers?: ResponseHeaders;
30
- constructor(message: string, statusCode?: number, headers?: ResponseHeaders, errorCode?: string);
25
+ constructor(message: string, statusCode?: number, headers?: ResponseHeaders, code?: string, source?: string);
26
+ /**
27
+ * @deprecated Use {@link DaytonaError.code} instead. Kept so existing
28
+ * `err.errorCode` reads keep returning the machine-readable code.
29
+ * @returns the machine-readable error code, or `undefined` when the
30
+ * response did not carry one (same as {@link DaytonaError.code})
31
+ */
32
+ get errorCode(): string | undefined;
31
33
  }
32
- /**
33
- * Error thrown when a resource is not found (HTTP 404).
34
- *
35
- * @example
36
- * ```ts
37
- * try {
38
- * await sandbox.fs.downloadFile('/workspace/missing.txt')
39
- * } catch (error) {
40
- * if (error instanceof DaytonaNotFoundError) {
41
- * console.log(error.statusCode)
42
- * }
43
- * }
44
- * ```
45
- */
34
+ /** The request was malformed or invalid (HTTP 400). */
35
+ export declare class DaytonaBadRequestError extends DaytonaError {
36
+ }
37
+ /** Authentication failed — missing or invalid credentials (HTTP 401). */
38
+ export declare class DaytonaAuthenticationError extends DaytonaError {
39
+ }
40
+ /** The authenticated caller lacks permission for the operation (HTTP 403). */
41
+ export declare class DaytonaForbiddenError extends DaytonaError {
42
+ }
43
+ /** The requested resource does not exist (HTTP 404). */
46
44
  export declare class DaytonaNotFoundError extends DaytonaError {
47
45
  }
48
46
  /**
49
- * Error thrown when rate limit is exceeded.
47
+ * The operation timed out (HTTP 408, or 504 when a gateway timed out).
50
48
  *
51
- * @example
52
- * ```ts
53
- * try {
54
- * for await (const sandbox of daytona.list()) {
55
- * console.log(sandbox.id)
56
- * }
57
- * } catch (error) {
58
- * if (error instanceof DaytonaRateLimitError) {
59
- * console.log(error.errorCode)
60
- * }
61
- * }
62
- * ```
49
+ * Also matches {@link DaytonaConnectionTimeoutError} via `instanceof`, even
50
+ * though that class sits under {@link DaytonaConnectionError} in the prototype
51
+ * chain. Transport timeouts were raised as `DaytonaTimeoutError` before
52
+ * `DaytonaConnectionTimeoutError` existed, so this keeps pre-existing
53
+ * `catch (err) { if (err instanceof DaytonaTimeoutError) ... }` blocks working
54
+ * — the same compatibility the Python SDK gets from inheriting both classes.
63
55
  */
56
+ export declare class DaytonaTimeoutError extends DaytonaError {
57
+ static [Symbol.hasInstance](value: unknown): boolean;
58
+ }
59
+ /** The request conflicts with the current state of the resource (HTTP 409). */
60
+ export declare class DaytonaConflictError extends DaytonaError {
61
+ }
62
+ /** The resource existed but is permanently gone (HTTP 410). */
63
+ export declare class DaytonaGoneError extends DaytonaError {
64
+ }
65
+ /** The request was well-formed but semantically invalid (HTTP 422). */
66
+ export declare class DaytonaUnprocessableEntityError extends DaytonaError {
67
+ }
68
+ /** The caller exceeded a rate limit (HTTP 429). */
64
69
  export declare class DaytonaRateLimitError extends DaytonaError {
65
70
  }
66
- /**
67
- * Error thrown when authentication fails (HTTP 401).
68
- *
69
- * @example
70
- * ```ts
71
- * try {
72
- * for await (const sandbox of daytona.list()) {
73
- * console.log(sandbox.id)
74
- * }
75
- * } catch (error) {
76
- * if (error instanceof DaytonaAuthenticationError) {
77
- * console.log(error.statusCode)
78
- * }
79
- * }
80
- * ```
81
- */
82
- export declare class DaytonaAuthenticationError extends DaytonaError {
71
+ /** A Daytona service failed unexpectedly (HTTP 500). */
72
+ export declare class DaytonaInternalServerError extends DaytonaError {
83
73
  }
84
- /**
85
- * Error thrown when the request is forbidden (HTTP 403).
86
- *
87
- * @example
88
- * ```ts
89
- * try {
90
- * await daytona.get('sandbox-without-access')
91
- * } catch (error) {
92
- * if (error instanceof DaytonaAuthorizationError) {
93
- * console.log(error.message)
94
- * }
95
- * }
96
- * ```
97
- */
98
- export declare class DaytonaAuthorizationError extends DaytonaError {
74
+ /** An upstream gateway returned an invalid response (HTTP 502). */
75
+ export declare class DaytonaBadGatewayError extends DaytonaError {
99
76
  }
100
- /**
101
- * Error thrown when a resource conflict occurs (HTTP 409).
102
- *
103
- * @example
104
- * ```ts
105
- * try {
106
- * await daytona.create({ name: 'existing-sandbox' })
107
- * } catch (error) {
108
- * if (error instanceof DaytonaConflictError) {
109
- * console.log(error.errorCode)
110
- * }
111
- * }
112
- * ```
113
- */
114
- export declare class DaytonaConflictError extends DaytonaError {
77
+ /** The service is temporarily unable to handle the request (HTTP 503). */
78
+ export declare class DaytonaServiceUnavailableError extends DaytonaError {
115
79
  }
116
80
  /**
117
- * Error thrown when input validation fails (HTTP 400 or client-side validation).
81
+ * Legacy umbrella for validation failures. Kept so existing
82
+ * `catch (err) { if (err instanceof DaytonaValidationError) ... }` blocks keep
83
+ * matching both server-returned HTTP 400s and locally rejected arguments.
118
84
  *
119
- * @example
120
- * ```ts
121
- * try {
122
- * Image.debianSlim('3.8' as never)
123
- * } catch (error) {
124
- * if (error instanceof DaytonaValidationError) {
125
- * console.log(error.message)
126
- * }
127
- * }
128
- * ```
85
+ * @deprecated Do not throw or catch this directly in new code. Branch on the
86
+ * precise class instead:
87
+ * - {@link DaytonaInvalidArgumentError} — the SDK rejected your arguments
88
+ * locally, before any request was sent.
89
+ * - {@link DaytonaBadRequestError} a Daytona service returned HTTP 400.
90
+ * - {@link DaytonaUnprocessableEntityError} — a Daytona service returned
91
+ * HTTP 422 (well-formed but semantically invalid).
129
92
  */
130
- export declare class DaytonaValidationError extends DaytonaError {
93
+ export declare class DaytonaValidationError extends DaytonaBadRequestError {
131
94
  }
132
95
  /**
133
- * Error thrown when a timeout occurs.
134
- *
135
- * @example
136
- * ```ts
137
- * try {
138
- * await sandbox.waitUntilStarted(1)
139
- * } catch (error) {
140
- * if (error instanceof DaytonaTimeoutError) {
141
- * console.log(error.message)
142
- * }
143
- * }
144
- * ```
96
+ * @deprecated Use {@link DaytonaForbiddenError} instead.
145
97
  */
146
- export declare class DaytonaTimeoutError extends DaytonaError {
98
+ export declare class DaytonaAuthorizationError extends DaytonaForbiddenError {
147
99
  }
148
100
  /**
149
- * Error thrown when a network connection fails.
101
+ * The SDK rejected the caller's arguments locally, before any request was
102
+ * sent. `statusCode`, `code` and `source` are always `undefined` — no Daytona
103
+ * service was contacted, so there is no HTTP status to report.
104
+ *
105
+ * Distinct from {@link DaytonaBadRequestError} (a service returned HTTP 400)
106
+ * and {@link DaytonaUnprocessableEntityError} (a service returned HTTP 422).
107
+ * This one always means: fix the arguments at the call site.
150
108
  *
151
109
  * @example
152
110
  * ```ts
153
111
  * try {
154
- * await ptyHandle.waitForConnection()
155
- * } catch (error) {
156
- * if (error instanceof DaytonaConnectionError) {
157
- * console.log(error.message)
112
+ * await sandbox.setAutoStopInterval(-1)
113
+ * } catch (err) {
114
+ * if (err instanceof DaytonaInvalidArgumentError) {
115
+ * // never reached the API — the value itself is invalid
158
116
  * }
159
117
  * }
160
118
  * ```
161
119
  */
120
+ export declare class DaytonaInvalidArgumentError extends DaytonaValidationError {
121
+ }
122
+ /** Network connection failure (can't connect or mid-request drop). */
162
123
  export declare class DaytonaConnectionError extends DaytonaError {
163
124
  }
164
- /**
165
- * Maps an HTTP status code to the corresponding Daytona error class.
166
- */
125
+ /** Transport-layer timeout (connect / read). Subclass of DaytonaConnectionError. */
126
+ export declare class DaytonaConnectionTimeoutError extends DaytonaConnectionError {
127
+ }
128
+ /** Git authentication against the remote failed (code `GIT_AUTH_FAILED`). */
129
+ export declare class DaytonaGitAuthFailedError extends DaytonaAuthenticationError {
130
+ }
131
+ /** The git remote repository was not found (code `GIT_REPO_NOT_FOUND`). */
132
+ export declare class DaytonaGitRepoNotFoundError extends DaytonaNotFoundError {
133
+ }
134
+ /** The git branch does not exist (code `GIT_BRANCH_NOT_FOUND`). */
135
+ export declare class DaytonaGitBranchNotFoundError extends DaytonaNotFoundError {
136
+ }
137
+ /** The git branch already exists (code `GIT_BRANCH_EXISTS`). */
138
+ export declare class DaytonaGitBranchExistsError extends DaytonaConflictError {
139
+ }
140
+ /** The git push was rejected by the remote (code `GIT_PUSH_REJECTED`). */
141
+ export declare class DaytonaGitPushRejectedError extends DaytonaConflictError {
142
+ }
143
+ /** The operation requires a clean worktree (code `GIT_DIRTY_WORKTREE`). */
144
+ export declare class DaytonaGitDirtyWorktreeError extends DaytonaConflictError {
145
+ }
146
+ /** A git merge produced conflicts (code `GIT_MERGE_CONFLICT`). */
147
+ export declare class DaytonaGitMergeConflictError extends DaytonaConflictError {
148
+ }
149
+ /** The file does not exist in the sandbox (code `FILE_NOT_FOUND`). */
150
+ export declare class DaytonaFileNotFoundError extends DaytonaNotFoundError {
151
+ }
152
+ /** Access to the sandbox file was denied (code `FILE_ACCESS_DENIED`). */
153
+ export declare class DaytonaFileAccessDeniedError extends DaytonaForbiddenError {
154
+ }
155
+ /** The supplied file path was rejected by the daemon (code `INVALID_FILE_PATH`). */
156
+ export declare class DaytonaInvalidFilePathError extends DaytonaBadRequestError {
157
+ }
158
+ /** The daemon could not read the sandbox file (code `FILE_READ_FAILED`). */
159
+ export declare class DaytonaFileReadFailedError extends DaytonaInternalServerError {
160
+ }
161
+ /** The LSP server must be initialized first (code `LSP_SERVER_NOT_INITIALIZED`). */
162
+ export declare class DaytonaLspServerNotInitializedError extends DaytonaBadRequestError {
163
+ }
164
+ /** Command execution exceeded its timeout (code `PROCESS_EXECUTION_TIMEOUT`). */
165
+ export declare class DaytonaProcessExecutionTimeoutError extends DaytonaTimeoutError {
166
+ }
167
+ /** The sandbox process does not exist (code `PROCESS_NOT_FOUND`). */
168
+ export declare class DaytonaProcessNotFoundError extends DaytonaNotFoundError {
169
+ }
170
+ /** The session has already ended (code `SESSION_ENDED`). */
171
+ export declare class DaytonaSessionEndedError extends DaytonaGoneError {
172
+ }
173
+ /** The session command already finished (code `COMMAND_ALREADY_COMPLETED`). */
174
+ export declare class DaytonaCommandAlreadyCompletedError extends DaytonaGoneError {
175
+ }
176
+ /** The accessibility service is unavailable (code `A11Y_UNAVAILABLE`). */
177
+ export declare class DaytonaA11yUnavailableError extends DaytonaServiceUnavailableError {
178
+ }
179
+ /** A screen recording is still active (code `RECORDING_STILL_ACTIVE`). */
180
+ export declare class DaytonaRecordingStillActiveError extends DaytonaConflictError {
181
+ }
182
+ /** ffmpeg is not available for recording (code `RECORDING_FFMPEG_NOT_FOUND`). */
183
+ export declare class DaytonaRecordingFfmpegNotFoundError extends DaytonaServiceUnavailableError {
184
+ }
185
+ /** Maps an HTTP status code to the corresponding Daytona error class. */
167
186
  export declare function errorClassFromStatusCode(statusCode?: number): typeof DaytonaError;
168
187
  /**
169
188
  * Creates the appropriate Daytona error subclass from structured error metadata.
189
+ *
190
+ * Resolution order: (source, code) override -> HTTP status code -> DaytonaError.
170
191
  */
171
- export declare function createDaytonaError(message: string, statusCode?: number, headers?: ResponseHeaders, errorCode?: string): DaytonaError;
192
+ export declare function createDaytonaError(message: string, statusCode?: number, headers?: ResponseHeaders, code?: string, source?: string): DaytonaError;
172
193
  /**
173
- * Creates the appropriate Daytona error subclass from an Axios error.
194
+ * Creates the appropriate Daytona error subclass from an Axios error. Maps
195
+ * client-side timeouts to DaytonaConnectionTimeoutError, networking failures
196
+ * (no response received) to DaytonaConnectionError, and HTTP responses to
197
+ * the most specific subclass via `createDaytonaError`.
174
198
  */
175
199
  export declare function createAxiosDaytonaError(error: AxiosError): DaytonaError;
176
200
  //# sourceMappingURL=DaytonaError.d.ts.map