@daytona/sdk 0.161.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +180 -0
  2. package/package.json +56 -0
  3. package/src/CodeInterpreter.d.ts +94 -0
  4. package/src/CodeInterpreter.js +297 -0
  5. package/src/CodeInterpreter.js.map +1 -0
  6. package/src/ComputerUse.d.ts +538 -0
  7. package/src/ComputerUse.js +808 -0
  8. package/src/ComputerUse.js.map +1 -0
  9. package/src/Daytona.d.ts +340 -0
  10. package/src/Daytona.js +538 -0
  11. package/src/Daytona.js.map +1 -0
  12. package/src/FileSystem.d.ts +326 -0
  13. package/src/FileSystem.js +412 -0
  14. package/src/FileSystem.js.map +1 -0
  15. package/src/Git.d.ts +202 -0
  16. package/src/Git.js +326 -0
  17. package/src/Git.js.map +1 -0
  18. package/src/Image.d.ts +264 -0
  19. package/src/Image.js +546 -0
  20. package/src/Image.js.map +1 -0
  21. package/src/LspServer.d.ts +171 -0
  22. package/src/LspServer.js +258 -0
  23. package/src/LspServer.js.map +1 -0
  24. package/src/ObjectStorage.d.ts +78 -0
  25. package/src/ObjectStorage.js +199 -0
  26. package/src/ObjectStorage.js.map +1 -0
  27. package/src/Process.d.ts +490 -0
  28. package/src/Process.js +790 -0
  29. package/src/Process.js.map +1 -0
  30. package/src/PtyHandle.d.ts +154 -0
  31. package/src/PtyHandle.js +416 -0
  32. package/src/PtyHandle.js.map +1 -0
  33. package/src/Sandbox.d.ts +425 -0
  34. package/src/Sandbox.js +776 -0
  35. package/src/Sandbox.js.map +1 -0
  36. package/src/Snapshot.d.ts +139 -0
  37. package/src/Snapshot.js +248 -0
  38. package/src/Snapshot.js.map +1 -0
  39. package/src/Volume.d.ts +83 -0
  40. package/src/Volume.js +119 -0
  41. package/src/Volume.js.map +1 -0
  42. package/src/code-toolbox/SandboxJsCodeToolbox.d.ts +5 -0
  43. package/src/code-toolbox/SandboxJsCodeToolbox.js +20 -0
  44. package/src/code-toolbox/SandboxJsCodeToolbox.js.map +1 -0
  45. package/src/code-toolbox/SandboxPythonCodeToolbox.d.ts +11 -0
  46. package/src/code-toolbox/SandboxPythonCodeToolbox.js +359 -0
  47. package/src/code-toolbox/SandboxPythonCodeToolbox.js.map +1 -0
  48. package/src/code-toolbox/SandboxTsCodeToolbox.d.ts +5 -0
  49. package/src/code-toolbox/SandboxTsCodeToolbox.js +29 -0
  50. package/src/code-toolbox/SandboxTsCodeToolbox.js.map +1 -0
  51. package/src/errors/DaytonaError.d.ts +31 -0
  52. package/src/errors/DaytonaError.js +51 -0
  53. package/src/errors/DaytonaError.js.map +1 -0
  54. package/src/index.d.ts +21 -0
  55. package/src/index.js +45 -0
  56. package/src/index.js.map +1 -0
  57. package/src/types/Charts.d.ts +151 -0
  58. package/src/types/Charts.js +46 -0
  59. package/src/types/Charts.js.map +1 -0
  60. package/src/types/CodeInterpreter.d.ts +76 -0
  61. package/src/types/CodeInterpreter.js +7 -0
  62. package/src/types/CodeInterpreter.js.map +1 -0
  63. package/src/types/ExecuteResponse.d.ts +25 -0
  64. package/src/types/ExecuteResponse.js +7 -0
  65. package/src/types/ExecuteResponse.js.map +1 -0
  66. package/src/types/Pty.d.ts +47 -0
  67. package/src/types/Pty.js +7 -0
  68. package/src/types/Pty.js.map +1 -0
  69. package/src/utils/ArtifactParser.d.ts +13 -0
  70. package/src/utils/ArtifactParser.js +55 -0
  71. package/src/utils/ArtifactParser.js.map +1 -0
  72. package/src/utils/Binary.d.ts +38 -0
  73. package/src/utils/Binary.js +168 -0
  74. package/src/utils/Binary.js.map +1 -0
  75. package/src/utils/FileTransfer.d.ts +14 -0
  76. package/src/utils/FileTransfer.js +216 -0
  77. package/src/utils/FileTransfer.js.map +1 -0
  78. package/src/utils/Import.d.ts +97 -0
  79. package/src/utils/Import.js +79 -0
  80. package/src/utils/Import.js.map +1 -0
  81. package/src/utils/Multipart.d.ts +26 -0
  82. package/src/utils/Multipart.js +113 -0
  83. package/src/utils/Multipart.js.map +1 -0
  84. package/src/utils/Runtime.d.ts +43 -0
  85. package/src/utils/Runtime.js +95 -0
  86. package/src/utils/Runtime.js.map +1 -0
  87. package/src/utils/Stream.d.ts +19 -0
  88. package/src/utils/Stream.js +364 -0
  89. package/src/utils/Stream.js.map +1 -0
  90. package/src/utils/WebSocket.d.ts +9 -0
  91. package/src/utils/WebSocket.js +26 -0
  92. package/src/utils/WebSocket.js.map +1 -0
  93. package/src/utils/otel.decorator.d.ts +82 -0
  94. package/src/utils/otel.decorator.js +141 -0
  95. package/src/utils/otel.decorator.js.map +1 -0
@@ -0,0 +1,326 @@
1
+ import { Configuration, FileInfo, Match, ReplaceResult, SearchFilesResponse } from '@daytonaio/toolbox-api-client';
2
+ import { FileSystemApi } from '@daytonaio/toolbox-api-client';
3
+ /**
4
+ * Parameters for setting file permissions in the Sandbox.
5
+ *
6
+ * @interface
7
+ * @property {string} [mode] - File mode/permissions in octal format (e.g. "644")
8
+ * @property {string} [owner] - User owner of the file
9
+ * @property {string} [group] - Group owner of the file
10
+ *
11
+ * @example
12
+ * const permissions: FilePermissionsParams = {
13
+ * mode: '644',
14
+ * owner: 'daytona',
15
+ * group: 'users'
16
+ * };
17
+ */
18
+ export type FilePermissionsParams = {
19
+ /** Group owner of the file */
20
+ group?: string;
21
+ /** File mode/permissions in octal format (e.g. "644") */
22
+ mode?: string;
23
+ /** User owner of the file */
24
+ owner?: string;
25
+ };
26
+ /**
27
+ * Represents a file to be uploaded to the Sandbox.
28
+ *
29
+ * @interface
30
+ * @property {string | Buffer} source - File to upload. If a Buffer, it is interpreted as the file content which is loaded into memory.
31
+ * Make sure it fits into memory, otherwise use the local file path which content will be streamed to the Sandbox.
32
+ * @property {string} destination - Absolute destination path in the Sandbox. Relative paths are resolved based on the sandbox working directory.
33
+ */
34
+ export interface FileUpload {
35
+ source: string | Buffer;
36
+ destination: string;
37
+ }
38
+ /**
39
+ * Represents a request to download a single file from the Sandbox.
40
+ *
41
+ * @interface
42
+ * @property {string} source - Source path in the Sandbox. Relative paths are resolved based on the user's
43
+ * root directory.
44
+ * @property {string} [destination] - Destination path in the local filesystem where the file content will be
45
+ * streamed to. If not provided, the file will be downloaded in the bytes buffer (might cause memory issues if the file is large).
46
+ */
47
+ export interface FileDownloadRequest {
48
+ source: string;
49
+ destination?: string;
50
+ }
51
+ /**
52
+ * Represents the response to a single file download request.
53
+ *
54
+ * @interface
55
+ * @property {string} source - The original source path requested for download.
56
+ * @property {Buffer | string | undefined} [result] - The download result - file path (if destination provided in the request)
57
+ * or bytes content (if no destination in the request), undefined if failed or no data received.
58
+ * @property {string | undefined} [error] - Error message if the download failed, undefined if successful.
59
+ */
60
+ export interface FileDownloadResponse {
61
+ source: string;
62
+ result?: Buffer | string;
63
+ error?: string;
64
+ }
65
+ /**
66
+ * Represents metadata for a file download operation.
67
+ *
68
+ * @interface
69
+ * @property {string | undefined} [destination] - Destination path in the local filesystem where the file content will be streamed to.
70
+ * @property {string | undefined} [error] - Error message if the download failed, undefined if successful.
71
+ * @property {Buffer | string | Uint8Array | undefined} [result] - The download result - file path (if destination provided in the request)
72
+ * or bytes content (if no destination in the request), undefined if failed or no data received.
73
+ */
74
+ export interface DownloadMetadata {
75
+ destination?: string;
76
+ error?: string;
77
+ result?: Buffer | string | Uint8Array;
78
+ }
79
+ /**
80
+ * Provides file system operations within a Sandbox.
81
+ *
82
+ * @class
83
+ */
84
+ export declare class FileSystem {
85
+ private readonly clientConfig;
86
+ private readonly apiClient;
87
+ constructor(clientConfig: Configuration, apiClient: FileSystemApi);
88
+ /**
89
+ * Create a new directory in the Sandbox with specified permissions.
90
+ *
91
+ * @param {string} path - Path where the directory should be created. Relative paths are resolved based on the sandbox working directory.
92
+ * @param {string} mode - Directory permissions in octal format (e.g. "755")
93
+ * @returns {Promise<void>}
94
+ *
95
+ * @example
96
+ * // Create a directory with standard permissions
97
+ * await fs.createFolder('app/data', '755');
98
+ */
99
+ createFolder(path: string, mode: string): Promise<void>;
100
+ /**
101
+ * Deletes a file or directory from the Sandbox.
102
+ *
103
+ * @param {string} path - Path to the file or directory to delete. Relative paths are resolved based on the sandbox working directory.
104
+ * @param {boolean} [recursive] - If the file is a directory, this must be true to delete it.
105
+ * @returns {Promise<void>}
106
+ *
107
+ * @example
108
+ * // Delete a file
109
+ * await fs.deleteFile('app/temp.log');
110
+ */
111
+ deleteFile(path: string, recursive?: boolean): Promise<void>;
112
+ /**
113
+ * Downloads a file from the Sandbox. This method loads the entire file into memory, so it is not recommended
114
+ * for downloading large files.
115
+ *
116
+ * @param {string} remotePath - Path to the file to download. Relative paths are resolved based on the sandbox working directory.
117
+ * @param {number} [timeout] - Timeout for the download operation in seconds. 0 means no timeout.
118
+ * Default is 30 minutes.
119
+ * @returns {Promise<Buffer>} The file contents as a Buffer.
120
+ *
121
+ * @example
122
+ * // Download and process a file
123
+ * const fileBuffer = await fs.downloadFile('tmp/data.json');
124
+ * console.log('File content:', fileBuffer.toString());
125
+ */
126
+ downloadFile(remotePath: string, timeout?: number): Promise<Buffer>;
127
+ /**
128
+ * Downloads a file from the Sandbox and saves it to a local file. This method uses streaming to download the file,
129
+ * so it is recommended for downloading larger files.
130
+ *
131
+ * @param {string} remotePath - Path to the file to download in the Sandbox. Relative paths are resolved based on the sandbox working directory.
132
+ * @param {string} localPath - Path to save the downloaded file.
133
+ * @param {number} [timeout] - Timeout for the download operation in seconds. 0 means no timeout.
134
+ * Default is 30 minutes.
135
+ * @returns {Promise<void>}
136
+ *
137
+ * @example
138
+ * // Download and save a file
139
+ * await fs.downloadFile('tmp/data.json', 'local_file.json');
140
+ */
141
+ downloadFile(remotePath: string, localPath: string, timeout?: number): Promise<void>;
142
+ /**
143
+ * Downloads multiple files from the Sandbox. If the files already exist locally, they will be overwritten.
144
+ *
145
+ * @param {FileDownloadRequest[]} files - Array of file download requests.
146
+ * @param {number} [timeoutSec] - Timeout for the download operation in seconds. 0 means no timeout.
147
+ * Default is 30 minutes.
148
+ * @returns {Promise<FileDownloadResponse[]>} Array of download results.
149
+ *
150
+ * @throws {DaytonaError} If the request itself fails (network issues, invalid request/response, etc.). Individual
151
+ * file download errors are returned in the `FileDownloadResponse.error` field.
152
+ *
153
+ * @example
154
+ * // Download multiple files
155
+ * const results = await fs.downloadFiles([
156
+ * { source: 'tmp/data.json' },
157
+ * { source: 'tmp/config.json', destination: 'local_config.json' }
158
+ * ]);
159
+ * results.forEach(result => {
160
+ * if (result.error) {
161
+ * console.error(`Error downloading ${result.source}: ${result.error}`);
162
+ * } else if (result.result) {
163
+ * console.log(`Downloaded ${result.source} to ${result.result}`);
164
+ * }
165
+ * });
166
+ */
167
+ downloadFiles(files: FileDownloadRequest[], timeoutSec?: number): Promise<FileDownloadResponse[]>;
168
+ /**
169
+ * Searches for text patterns within files in the Sandbox.
170
+ *
171
+ * @param {string} path - Directory to search in. Relative paths are resolved based on the sandbox working directory.
172
+ * @param {string} pattern - Search pattern
173
+ * @returns {Promise<Array<Match>>} Array of matches with file and line information
174
+ *
175
+ * @example
176
+ * // Find all TODO comments in TypeScript files
177
+ * const matches = await fs.findFiles('app/src', 'TODO:');
178
+ * matches.forEach(match => {
179
+ * console.log(`${match.file}:${match.line}: ${match.content}`);
180
+ * });
181
+ */
182
+ findFiles(path: string, pattern: string): Promise<Array<Match>>;
183
+ /**
184
+ * Retrieves detailed information about a file or directory.
185
+ *
186
+ * @param {string} path - Path to the file or directory. Relative paths are resolved based on the sandbox working directory.
187
+ * @returns {Promise<FileInfo>} Detailed file information including size, permissions, modification time
188
+ *
189
+ * @example
190
+ * // Get file details
191
+ * const info = await fs.getFileDetails('app/config.json');
192
+ * console.log(`Size: ${info.size}, Modified: ${info.modTime}`);
193
+ */
194
+ getFileDetails(path: string): Promise<FileInfo>;
195
+ /**
196
+ * Lists contents of a directory in the Sandbox.
197
+ *
198
+ * @param {string} path - Directory path to list. Relative paths are resolved based on the sandbox working directory.
199
+ * @returns {Promise<FileInfo[]>} Array of file and directory information
200
+ *
201
+ * @example
202
+ * // List directory contents
203
+ * const files = await fs.listFiles('app/src');
204
+ * files.forEach(file => {
205
+ * console.log(`${file.name} (${file.size} bytes)`);
206
+ * });
207
+ */
208
+ listFiles(path: string): Promise<FileInfo[]>;
209
+ /**
210
+ * Moves or renames a file or directory.
211
+ *
212
+ * @param {string} source - Source path. Relative paths are resolved based on the sandbox working directory.
213
+ * @param {string} destination - Destination path. Relative paths are resolved based on the sandbox working directory.
214
+ * @returns {Promise<void>}
215
+ *
216
+ * @example
217
+ * // Move a file to a new location
218
+ * await fs.moveFiles('app/temp/data.json', 'app/data/data.json');
219
+ */
220
+ moveFiles(source: string, destination: string): Promise<void>;
221
+ /**
222
+ * Replaces text content in multiple files.
223
+ *
224
+ * @param {string[]} files - Array of file paths to process. Relative paths are resolved based on the sandbox working directory.
225
+ * @param {string} pattern - Pattern to replace
226
+ * @param {string} newValue - Replacement text
227
+ * @returns {Promise<Array<ReplaceResult>>} Results of the replace operation for each file
228
+ *
229
+ * @example
230
+ * // Update version number across multiple files
231
+ * const results = await fs.replaceInFiles(
232
+ * ['app/package.json', 'app/version.ts'],
233
+ * '"version": "1.0.0"',
234
+ * '"version": "1.1.0"'
235
+ * );
236
+ */
237
+ replaceInFiles(files: string[], pattern: string, newValue: string): Promise<Array<ReplaceResult>>;
238
+ /**
239
+ * Searches for files and directories by name pattern in the Sandbox.
240
+ *
241
+ * @param {string} path - Directory to search in. Relative paths are resolved based on the sandbox working directory.
242
+ * @param {string} pattern - File name pattern (supports globs)
243
+ * @returns {Promise<SearchFilesResponse>} Search results with matching files
244
+ *
245
+ * @example
246
+ * // Find all TypeScript files
247
+ * const result = await fs.searchFiles('app', '*.ts');
248
+ * result.files.forEach(file => console.log(file));
249
+ */
250
+ searchFiles(path: string, pattern: string): Promise<SearchFilesResponse>;
251
+ /**
252
+ * Sets permissions and ownership for a file or directory.
253
+ *
254
+ * @param {string} path - Path to the file or directory. Relative paths are resolved based on the sandbox working directory.
255
+ * @param {FilePermissionsParams} permissions - Permission settings
256
+ * @returns {Promise<void>}
257
+ *
258
+ * @example
259
+ * // Set file permissions and ownership
260
+ * await fs.setFilePermissions('app/script.sh', {
261
+ * owner: 'daytona',
262
+ * group: 'users',
263
+ * mode: '755' // Execute permission for shell script
264
+ * });
265
+ */
266
+ setFilePermissions(path: string, permissions: FilePermissionsParams): Promise<void>;
267
+ /**
268
+ * Uploads a file to the Sandbox. This method loads the entire file into memory, so it is not recommended
269
+ * for uploading large files.
270
+ *
271
+ * @param {Buffer} file - Buffer of the file to upload.
272
+ * @param {string} remotePath - Destination path in the Sandbox. Relative paths are resolved based on the sandbox working directory.
273
+ * @param {number} [timeout] - Timeout for the upload operation in seconds. 0 means no timeout.
274
+ * Default is 30 minutes.
275
+ * @returns {Promise<void>}
276
+ *
277
+ * @example
278
+ * // Upload a configuration file
279
+ * await fs.uploadFile(Buffer.from('{"setting": "value"}'), 'tmp/config.json');
280
+ */
281
+ uploadFile(file: Buffer, remotePath: string, timeout?: number): Promise<void>;
282
+ /**
283
+ * Uploads a file from the local file system to the Sandbox. This method uses streaming to upload the file,
284
+ * so it is recommended for uploading larger files.
285
+ *
286
+ * @param {string} localPath - Path to the local file to upload.
287
+ * @param {string} remotePath - Destination path in the Sandbox. Relative paths are resolved based on the sandbox working directory.
288
+ * @param {number} [timeout] - Timeout for the upload operation in seconds. 0 means no timeout.
289
+ * Default is 30 minutes.
290
+ * @returns {Promise<void>}
291
+ *
292
+ * @example
293
+ * // Upload a local file
294
+ * await fs.uploadFile('local_file.txt', 'tmp/file.txt');
295
+ */
296
+ uploadFile(localPath: string, remotePath: string, timeout?: number): Promise<void>;
297
+ /**
298
+ * Uploads multiple files to the Sandbox. If files already exist at the destination paths,
299
+ * they will be overwritten.
300
+ *
301
+ * @param {FileUpload[]} files - Array of files to upload.
302
+ * @param {number} [timeout] - Timeout for the upload operation in seconds. 0 means no timeout.
303
+ * Default is 30 minutes.
304
+ * @returns {Promise<void>}
305
+ *
306
+ * @example
307
+ * // Upload multiple text files
308
+ * const files = [
309
+ * {
310
+ * source: Buffer.from('Content of file 1'),
311
+ * destination: '/tmp/file1.txt'
312
+ * },
313
+ * {
314
+ * source: 'app/data/file2.txt',
315
+ * destination: '/tmp/file2.txt'
316
+ * },
317
+ * {
318
+ * source: Buffer.from('{"key": "value"}'),
319
+ * destination: '/tmp/config.json'
320
+ * }
321
+ * ];
322
+ * await fs.uploadFiles(files);
323
+ */
324
+ uploadFiles(files: FileUpload[], timeout?: number): Promise<void>;
325
+ private makeFilePayload;
326
+ }