@daytonaio/sdk 0.16.0-alpha.2 → 0.16.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.
- package/README.md +9 -9
- package/dist/Daytona.d.ts +3 -32
- package/dist/Daytona.js +9 -92
- package/dist/FileSystem.d.ts +40 -28
- package/dist/FileSystem.js +57 -38
- package/dist/Git.d.ts +29 -21
- package/dist/Git.js +37 -28
- package/dist/LspServer.d.ts +13 -9
- package/dist/LspServer.js +18 -13
- package/dist/Process.d.ts +8 -5
- package/dist/Process.js +71 -27
- package/dist/Sandbox.d.ts +9 -5
- package/dist/Sandbox.js +28 -19
- package/dist/index.d.ts +0 -3
- package/dist/index.js +1 -3
- package/dist/utils/Path.d.ts +1 -0
- package/dist/utils/Path.js +50 -0
- package/package.json +4 -13
- package/dist/Image.d.ts +0 -261
- package/dist/Image.js +0 -557
- package/dist/ObjectStorage.d.ts +0 -84
- package/dist/ObjectStorage.js +0 -219
package/README.md
CHANGED
|
@@ -99,12 +99,12 @@ console.log(response.result)
|
|
|
99
99
|
```typescript
|
|
100
100
|
// Upload a file
|
|
101
101
|
await sandbox.fs.uploadFile(
|
|
102
|
-
'
|
|
102
|
+
'path/to/file.txt',
|
|
103
103
|
new File([Buffer.from('Hello, World!')], 'file.txt', { type: 'text/plain' }),
|
|
104
104
|
)
|
|
105
105
|
|
|
106
106
|
// Download a file
|
|
107
|
-
const content = await sandbox.fs.downloadFile('
|
|
107
|
+
const content = await sandbox.fs.downloadFile('path/to/file.txt')
|
|
108
108
|
|
|
109
109
|
// Search for files
|
|
110
110
|
const matches = await sandbox.fs.findFiles(root_dir, 'search_pattern')
|
|
@@ -114,30 +114,30 @@ const matches = await sandbox.fs.findFiles(root_dir, 'search_pattern')
|
|
|
114
114
|
|
|
115
115
|
```typescript
|
|
116
116
|
// Clone a repository
|
|
117
|
-
await sandbox.git.clone('https://github.com/example/repo', '
|
|
117
|
+
await sandbox.git.clone('https://github.com/example/repo', 'path/to/clone')
|
|
118
118
|
|
|
119
119
|
// List branches
|
|
120
|
-
const branches = await sandbox.git.branches('
|
|
120
|
+
const branches = await sandbox.git.branches('path/to/repo')
|
|
121
121
|
|
|
122
122
|
// Add files
|
|
123
|
-
await sandbox.git.add('
|
|
123
|
+
await sandbox.git.add('path/to/repo', ['file1.txt', 'file2.txt'])
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
### Language Server Protocol
|
|
127
127
|
|
|
128
128
|
```typescript
|
|
129
129
|
// Create and start a language server
|
|
130
|
-
const lsp = sandbox.createLspServer('typescript', '
|
|
130
|
+
const lsp = await sandbox.createLspServer('typescript', 'path/to/project')
|
|
131
131
|
await lsp.start()
|
|
132
132
|
|
|
133
133
|
// Notify the lsp for the file
|
|
134
|
-
await lsp.didOpen('
|
|
134
|
+
await lsp.didOpen('path/to/file.ts')
|
|
135
135
|
|
|
136
136
|
// Get document symbols
|
|
137
|
-
const symbols = await lsp.documentSymbols('
|
|
137
|
+
const symbols = await lsp.documentSymbols('path/to/file.ts')
|
|
138
138
|
|
|
139
139
|
// Get completions
|
|
140
|
-
const completions = await lsp.completions('
|
|
140
|
+
const completions = await lsp.completions('path/to/file.ts', {
|
|
141
141
|
line: 10,
|
|
142
142
|
character: 15,
|
|
143
143
|
})
|
package/dist/Daytona.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CreateWorkspaceTargetEnum as SandboxTargetRegion } from '@daytonaio/api-client';
|
|
2
|
-
import { Image } from './Image';
|
|
3
2
|
import { Sandbox, Sandbox as Workspace } from './Sandbox';
|
|
4
3
|
/**
|
|
5
4
|
* Configuration options for initializing the Daytona client.
|
|
@@ -77,7 +76,7 @@ export interface SandboxResources {
|
|
|
77
76
|
* Parameters for creating a new Sandbox.
|
|
78
77
|
*
|
|
79
78
|
* @interface
|
|
80
|
-
* @property {string
|
|
79
|
+
* @property {string} [image] - Optional Docker image to use for the Sandbox
|
|
81
80
|
* @property {string} [user] - Optional os user to use for the Sandbox
|
|
82
81
|
* @property {CodeLanguage | string} [language] - Programming language for direct code execution
|
|
83
82
|
* @property {Record<string, string>} [envVars] - Optional environment variables to set in the Sandbox
|
|
@@ -102,8 +101,8 @@ export interface SandboxResources {
|
|
|
102
101
|
* const sandbox = await daytona.create(params, 50);
|
|
103
102
|
*/
|
|
104
103
|
export type CreateSandboxParams = {
|
|
105
|
-
/** Optional Docker image to use for the Sandbox
|
|
106
|
-
image?: string
|
|
104
|
+
/** Optional Docker image to use for the Sandbox */
|
|
105
|
+
image?: string;
|
|
107
106
|
/** Optional os user to use for the Sandbox */
|
|
108
107
|
user?: string;
|
|
109
108
|
/** Programming language for direct code execution */
|
|
@@ -166,8 +165,6 @@ export type SandboxFilter = {
|
|
|
166
165
|
export declare class Daytona {
|
|
167
166
|
private readonly sandboxApi;
|
|
168
167
|
private readonly toolboxApi;
|
|
169
|
-
private readonly imagesApi;
|
|
170
|
-
private readonly objectStorageApi;
|
|
171
168
|
private readonly target;
|
|
172
169
|
private readonly apiKey?;
|
|
173
170
|
private readonly jwtToken?;
|
|
@@ -303,24 +300,6 @@ export declare class Daytona {
|
|
|
303
300
|
* console.log(`Current sandbox state: ${sandbox.instance.state}`);
|
|
304
301
|
*/
|
|
305
302
|
getCurrentSandbox(sandboxId: string): Promise<Sandbox>;
|
|
306
|
-
/**
|
|
307
|
-
* Creates and registers a new image from the given Image definition.
|
|
308
|
-
*
|
|
309
|
-
* @param {string} name - The name of the image to create.
|
|
310
|
-
* @param {Image} image - The Image instance.
|
|
311
|
-
* @param {object} options - Options for the create operation.
|
|
312
|
-
* @param {boolean} options.verbose - Default is false. Whether to log progress information upon each state change of the image.
|
|
313
|
-
* @param {number} options.timeout - Default is no timeout. Timeout in seconds (0 means no timeout).
|
|
314
|
-
* @returns {Promise<void>}
|
|
315
|
-
*
|
|
316
|
-
* @example
|
|
317
|
-
* const image = Image.debianSlim('3.12').pipInstall('numpy');
|
|
318
|
-
* await daytona.createImage('my-python-image', image);
|
|
319
|
-
*/
|
|
320
|
-
createImage(name: string, image: Image, options?: {
|
|
321
|
-
verbose?: boolean;
|
|
322
|
-
timeout?: number;
|
|
323
|
-
}): Promise<void>;
|
|
324
303
|
/**
|
|
325
304
|
* Gets the appropriate code toolbox based on language.
|
|
326
305
|
*
|
|
@@ -330,12 +309,4 @@ export declare class Daytona {
|
|
|
330
309
|
* @throws {DaytonaError} - `DaytonaError` - When an unsupported language is specified
|
|
331
310
|
*/
|
|
332
311
|
private getCodeToolbox;
|
|
333
|
-
/**
|
|
334
|
-
* Processes the image contexts by uploading them to object storage
|
|
335
|
-
*
|
|
336
|
-
* @private
|
|
337
|
-
* @param {Image} image - The Image instance.
|
|
338
|
-
* @returns {Promise<string[]>} The list of context hashes stored in object storage.
|
|
339
|
-
*/
|
|
340
|
-
private processImageContext;
|
|
341
312
|
}
|
package/dist/Daytona.js
CHANGED
|
@@ -43,8 +43,6 @@ const dotenv_1 = __importDefault(require("dotenv"));
|
|
|
43
43
|
const SandboxPythonCodeToolbox_1 = require("./code-toolbox/SandboxPythonCodeToolbox");
|
|
44
44
|
const SandboxTsCodeToolbox_1 = require("./code-toolbox/SandboxTsCodeToolbox");
|
|
45
45
|
const DaytonaError_1 = require("./errors/DaytonaError");
|
|
46
|
-
const Image_1 = require("./Image");
|
|
47
|
-
const ObjectStorage_1 = require("./ObjectStorage");
|
|
48
46
|
const Sandbox_1 = require("./Sandbox");
|
|
49
47
|
/**
|
|
50
48
|
* Supported programming languages for code execution
|
|
@@ -129,7 +127,9 @@ class Daytona {
|
|
|
129
127
|
},
|
|
130
128
|
},
|
|
131
129
|
});
|
|
132
|
-
const axiosInstance = axios_1.default.create(
|
|
130
|
+
const axiosInstance = axios_1.default.create({
|
|
131
|
+
timeout: 24 * 60 * 60 * 1000, // 24 hours
|
|
132
|
+
});
|
|
133
133
|
axiosInstance.interceptors.response.use((response) => {
|
|
134
134
|
return response;
|
|
135
135
|
}, (error) => {
|
|
@@ -151,8 +151,6 @@ class Daytona {
|
|
|
151
151
|
});
|
|
152
152
|
this.sandboxApi = new api_client_1.WorkspaceApi(configuration, '', axiosInstance);
|
|
153
153
|
this.toolboxApi = new api_client_1.ToolboxApi(configuration, '', axiosInstance);
|
|
154
|
-
this.imagesApi = new api_client_1.ImagesApi(configuration, '', axiosInstance);
|
|
155
|
-
this.objectStorageApi = new api_client_1.ObjectStorageApi(configuration, '', axiosInstance);
|
|
156
154
|
}
|
|
157
155
|
/**
|
|
158
156
|
* Creates Sandboxes with default or custom configurations. You can specify various parameters,
|
|
@@ -184,8 +182,8 @@ class Daytona {
|
|
|
184
182
|
* const sandbox = await daytona.create(params, 40);
|
|
185
183
|
*/
|
|
186
184
|
async create(params, timeout = 60) {
|
|
185
|
+
// const startTime = Date.now();
|
|
187
186
|
var _a, _b, _c, _d;
|
|
188
|
-
const startTime = Date.now();
|
|
189
187
|
if (params == null) {
|
|
190
188
|
params = { language: 'python' };
|
|
191
189
|
}
|
|
@@ -204,22 +202,8 @@ class Daytona {
|
|
|
204
202
|
}
|
|
205
203
|
const codeToolbox = this.getCodeToolbox(params.language);
|
|
206
204
|
try {
|
|
207
|
-
// Handle Image instance if provided
|
|
208
|
-
let imageStr;
|
|
209
|
-
let buildInfo;
|
|
210
|
-
if (typeof params.image === 'string') {
|
|
211
|
-
imageStr = params.image;
|
|
212
|
-
}
|
|
213
|
-
else if (params.image instanceof Image_1.Image) {
|
|
214
|
-
const contextHashes = await this.processImageContext(params.image);
|
|
215
|
-
buildInfo = {
|
|
216
|
-
contextHashes,
|
|
217
|
-
dockerfileContent: params.image.dockerfile,
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
205
|
const response = await this.sandboxApi.createWorkspace({
|
|
221
|
-
image:
|
|
222
|
-
buildInfo,
|
|
206
|
+
image: params.image,
|
|
223
207
|
user: params.user,
|
|
224
208
|
env: params.envVars || {},
|
|
225
209
|
labels: params.labels,
|
|
@@ -240,10 +224,10 @@ class Daytona {
|
|
|
240
224
|
name: '',
|
|
241
225
|
};
|
|
242
226
|
const sandbox = new Sandbox_1.Sandbox(sandboxInstance.id, sandboxInstance, this.sandboxApi, this.toolboxApi, codeToolbox);
|
|
243
|
-
if (!params.async
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
227
|
+
// if (!params.async) {
|
|
228
|
+
// const timeElapsed = Date.now() - startTime;
|
|
229
|
+
// await sandbox.waitUntilStarted(effectiveTimeout ? effectiveTimeout - (timeElapsed / 1000) : 0);
|
|
230
|
+
// }
|
|
247
231
|
return sandbox;
|
|
248
232
|
}
|
|
249
233
|
catch (error) {
|
|
@@ -386,48 +370,6 @@ class Daytona {
|
|
|
386
370
|
async getCurrentSandbox(sandboxId) {
|
|
387
371
|
return await this.get(sandboxId);
|
|
388
372
|
}
|
|
389
|
-
/**
|
|
390
|
-
* Creates and registers a new image from the given Image definition.
|
|
391
|
-
*
|
|
392
|
-
* @param {string} name - The name of the image to create.
|
|
393
|
-
* @param {Image} image - The Image instance.
|
|
394
|
-
* @param {object} options - Options for the create operation.
|
|
395
|
-
* @param {boolean} options.verbose - Default is false. Whether to log progress information upon each state change of the image.
|
|
396
|
-
* @param {number} options.timeout - Default is no timeout. Timeout in seconds (0 means no timeout).
|
|
397
|
-
* @returns {Promise<void>}
|
|
398
|
-
*
|
|
399
|
-
* @example
|
|
400
|
-
* const image = Image.debianSlim('3.12').pipInstall('numpy');
|
|
401
|
-
* await daytona.createImage('my-python-image', image);
|
|
402
|
-
*/
|
|
403
|
-
async createImage(name, image, options = {}) {
|
|
404
|
-
const contextHashes = await this.processImageContext(image);
|
|
405
|
-
let builtImage = (await this.imagesApi.buildImage({
|
|
406
|
-
name,
|
|
407
|
-
buildInfo: {
|
|
408
|
-
contextHashes,
|
|
409
|
-
dockerfileContent: image.dockerfile,
|
|
410
|
-
},
|
|
411
|
-
}, undefined, {
|
|
412
|
-
timeout: (options.timeout || 0) * 1000,
|
|
413
|
-
})).data;
|
|
414
|
-
let previousState = null;
|
|
415
|
-
while (builtImage.state !== api_client_1.ImageState.ACTIVE && builtImage.state !== api_client_1.ImageState.ERROR) {
|
|
416
|
-
if (options.verbose && previousState !== builtImage.state) {
|
|
417
|
-
console.log(`Building image ${builtImage.name} (${builtImage.state})`);
|
|
418
|
-
previousState = builtImage.state;
|
|
419
|
-
}
|
|
420
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
421
|
-
const response = await this.imagesApi.getImage(builtImage.id);
|
|
422
|
-
builtImage = response.data;
|
|
423
|
-
}
|
|
424
|
-
if (builtImage.state === api_client_1.ImageState.ERROR) {
|
|
425
|
-
throw new DaytonaError_1.DaytonaError(`Failed to build image. Image ended in the ERROR state. name: ${builtImage.name}; error reason: ${builtImage.errorReason}`);
|
|
426
|
-
}
|
|
427
|
-
if (options.verbose) {
|
|
428
|
-
console.log(`Built image ${builtImage.name} (${builtImage.state})`);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
373
|
/**
|
|
432
374
|
* Gets the appropriate code toolbox based on language.
|
|
433
375
|
*
|
|
@@ -448,30 +390,5 @@ class Daytona {
|
|
|
448
390
|
throw new DaytonaError_1.DaytonaError(`Unsupported language: ${language}, supported languages: ${Object.values(CodeLanguage).join(', ')}`);
|
|
449
391
|
}
|
|
450
392
|
}
|
|
451
|
-
/**
|
|
452
|
-
* Processes the image contexts by uploading them to object storage
|
|
453
|
-
*
|
|
454
|
-
* @private
|
|
455
|
-
* @param {Image} image - The Image instance.
|
|
456
|
-
* @returns {Promise<string[]>} The list of context hashes stored in object storage.
|
|
457
|
-
*/
|
|
458
|
-
async processImageContext(image) {
|
|
459
|
-
if (!image.contextList || !image.contextList.length) {
|
|
460
|
-
return [];
|
|
461
|
-
}
|
|
462
|
-
const pushAccessCreds = (await this.objectStorageApi.getPushAccess()).data;
|
|
463
|
-
const objectStorage = new ObjectStorage_1.ObjectStorage({
|
|
464
|
-
endpointUrl: pushAccessCreds.storageUrl,
|
|
465
|
-
accessKeyId: pushAccessCreds.accessKey,
|
|
466
|
-
secretAccessKey: pushAccessCreds.secret,
|
|
467
|
-
sessionToken: pushAccessCreds.sessionToken,
|
|
468
|
-
});
|
|
469
|
-
const contextHashes = [];
|
|
470
|
-
for (const context of image.contextList) {
|
|
471
|
-
const contextHash = await objectStorage.upload(context.sourcePath, pushAccessCreds.organizationId, context.archivePath);
|
|
472
|
-
contextHashes.push(contextHash);
|
|
473
|
-
}
|
|
474
|
-
return contextHashes;
|
|
475
|
-
}
|
|
476
393
|
}
|
|
477
394
|
exports.Daytona = Daytona;
|
package/dist/FileSystem.d.ts
CHANGED
|
@@ -44,52 +44,57 @@ export interface FileUpload {
|
|
|
44
44
|
export declare class FileSystem {
|
|
45
45
|
private readonly instance;
|
|
46
46
|
private readonly toolboxApi;
|
|
47
|
-
|
|
47
|
+
private readonly getRootDir;
|
|
48
|
+
constructor(instance: SandboxInstance, toolboxApi: ToolboxApi, getRootDir: () => Promise<string>);
|
|
48
49
|
/**
|
|
49
50
|
* Create a new directory in the Sandbox with specified permissions.
|
|
50
51
|
*
|
|
51
|
-
* @param {string} path - Path where the directory should be created
|
|
52
|
+
* @param {string} path - Path where the directory should be created. Relative paths are resolved based on the user's
|
|
53
|
+
* root directory.
|
|
52
54
|
* @param {string} mode - Directory permissions in octal format (e.g. "755")
|
|
53
55
|
* @returns {Promise<void>}
|
|
54
56
|
*
|
|
55
57
|
* @example
|
|
56
58
|
* // Create a directory with standard permissions
|
|
57
|
-
* await fs.createFolder('
|
|
59
|
+
* await fs.createFolder('app/data', '755');
|
|
58
60
|
*/
|
|
59
61
|
createFolder(path: string, mode: string): Promise<void>;
|
|
60
62
|
/**
|
|
61
63
|
* Deletes a file or directory from the Sandbox.
|
|
62
64
|
*
|
|
63
|
-
* @param {string} path - Path to the file or directory to delete
|
|
65
|
+
* @param {string} path - Path to the file or directory to delete. Relative paths are resolved based on the user's
|
|
66
|
+
* root directory.
|
|
64
67
|
* @returns {Promise<void>}
|
|
65
68
|
*
|
|
66
69
|
* @example
|
|
67
70
|
* // Delete a file
|
|
68
|
-
* await fs.deleteFile('
|
|
71
|
+
* await fs.deleteFile('app/temp.log');
|
|
69
72
|
*/
|
|
70
73
|
deleteFile(path: string): Promise<void>;
|
|
71
74
|
/**
|
|
72
75
|
* Downloads a file from the Sandbox.
|
|
73
76
|
*
|
|
74
|
-
* @param {string} path - Path to the file to download
|
|
77
|
+
* @param {string} path - Path to the file to download. Relative paths are resolved based on the user's
|
|
78
|
+
* root directory.
|
|
75
79
|
* @returns {Promise<Blob>} The file contents as a Blob
|
|
76
80
|
*
|
|
77
81
|
* @example
|
|
78
82
|
* // Download and process a file
|
|
79
|
-
* const fileBlob = await fs.downloadFile('
|
|
83
|
+
* const fileBlob = await fs.downloadFile('app/data.json');
|
|
80
84
|
* console.log('File content:', fileBlob.toString());
|
|
81
85
|
*/
|
|
82
86
|
downloadFile(path: string): Promise<Blob>;
|
|
83
87
|
/**
|
|
84
88
|
* Searches for text patterns within files in the Sandbox.
|
|
85
89
|
*
|
|
86
|
-
* @param {string} path - Directory to search in
|
|
90
|
+
* @param {string} path - Directory to search in. Relative paths are resolved based on the user's
|
|
91
|
+
* root directory.
|
|
87
92
|
* @param {string} pattern - Search pattern
|
|
88
93
|
* @returns {Promise<Array<Match>>} Array of matches with file and line information
|
|
89
94
|
*
|
|
90
95
|
* @example
|
|
91
96
|
* // Find all TODO comments in TypeScript files
|
|
92
|
-
* const matches = await fs.findFiles('
|
|
97
|
+
* const matches = await fs.findFiles('app/src', 'TODO:');
|
|
93
98
|
* matches.forEach(match => {
|
|
94
99
|
* console.log(`${match.file}:${match.line}: ${match.content}`);
|
|
95
100
|
* });
|
|
@@ -98,24 +103,26 @@ export declare class FileSystem {
|
|
|
98
103
|
/**
|
|
99
104
|
* Retrieves detailed information about a file or directory.
|
|
100
105
|
*
|
|
101
|
-
* @param {string} path - Path to the file or directory
|
|
106
|
+
* @param {string} path - Path to the file or directory. Relative paths are resolved based on the user's
|
|
107
|
+
* root directory.
|
|
102
108
|
* @returns {Promise<FileInfo>} Detailed file information including size, permissions, modification time
|
|
103
109
|
*
|
|
104
110
|
* @example
|
|
105
111
|
* // Get file details
|
|
106
|
-
* const info = await fs.getFileDetails('
|
|
112
|
+
* const info = await fs.getFileDetails('app/config.json');
|
|
107
113
|
* console.log(`Size: ${info.size}, Modified: ${info.modTime}`);
|
|
108
114
|
*/
|
|
109
115
|
getFileDetails(path: string): Promise<FileInfo>;
|
|
110
116
|
/**
|
|
111
117
|
* Lists contents of a directory in the Sandbox.
|
|
112
118
|
*
|
|
113
|
-
* @param {string} path - Directory path to list
|
|
119
|
+
* @param {string} path - Directory path to list. Relative paths are resolved based on the user's
|
|
120
|
+
* root directory.
|
|
114
121
|
* @returns {Promise<FileInfo[]>} Array of file and directory information
|
|
115
122
|
*
|
|
116
123
|
* @example
|
|
117
124
|
* // List directory contents
|
|
118
|
-
* const files = await fs.listFiles('
|
|
125
|
+
* const files = await fs.listFiles('app/src');
|
|
119
126
|
* files.forEach(file => {
|
|
120
127
|
* console.log(`${file.name} (${file.size} bytes)`);
|
|
121
128
|
* });
|
|
@@ -124,19 +131,21 @@ export declare class FileSystem {
|
|
|
124
131
|
/**
|
|
125
132
|
* Moves or renames a file or directory.
|
|
126
133
|
*
|
|
127
|
-
* @param {string} source - Source path
|
|
128
|
-
*
|
|
134
|
+
* @param {string} source - Source path. Relative paths are resolved based on the user's
|
|
135
|
+
* root directory.
|
|
136
|
+
* @param {string} destination - Destination path. Relative paths are resolved based on the user's
|
|
137
|
+
* root directory.
|
|
129
138
|
* @returns {Promise<void>}
|
|
130
139
|
*
|
|
131
140
|
* @example
|
|
132
141
|
* // Move a file to a new location
|
|
133
|
-
* await fs.moveFiles('
|
|
142
|
+
* await fs.moveFiles('app/temp/data.json', 'app/data/data.json');
|
|
134
143
|
*/
|
|
135
144
|
moveFiles(source: string, destination: string): Promise<void>;
|
|
136
145
|
/**
|
|
137
146
|
* Replaces text content in multiple files.
|
|
138
147
|
*
|
|
139
|
-
* @param {string[]} files - Array of file paths to process
|
|
148
|
+
* @param {string[]} files - Array of file paths to process. Relative paths are resolved based on the user's
|
|
140
149
|
* @param {string} pattern - Pattern to replace
|
|
141
150
|
* @param {string} newValue - Replacement text
|
|
142
151
|
* @returns {Promise<Array<ReplaceResult>>} Results of the replace operation for each file
|
|
@@ -144,7 +153,7 @@ export declare class FileSystem {
|
|
|
144
153
|
* @example
|
|
145
154
|
* // Update version number across multiple files
|
|
146
155
|
* const results = await fs.replaceInFiles(
|
|
147
|
-
* ['
|
|
156
|
+
* ['app/package.json', 'app/version.ts'],
|
|
148
157
|
* '"version": "1.0.0"',
|
|
149
158
|
* '"version": "1.1.0"'
|
|
150
159
|
* );
|
|
@@ -153,26 +162,27 @@ export declare class FileSystem {
|
|
|
153
162
|
/**
|
|
154
163
|
* Searches for files and directories by name pattern in the Sandbox.
|
|
155
164
|
*
|
|
156
|
-
* @param {string} path - Directory to search in
|
|
165
|
+
* @param {string} path - Directory to search in. Relative paths are resolved based on the user's
|
|
157
166
|
* @param {string} pattern - File name pattern (supports globs)
|
|
158
167
|
* @returns {Promise<SearchFilesResponse>} Search results with matching files
|
|
159
168
|
*
|
|
160
169
|
* @example
|
|
161
170
|
* // Find all TypeScript files
|
|
162
|
-
* const result = await fs.searchFiles('
|
|
171
|
+
* const result = await fs.searchFiles('app', '*.ts');
|
|
163
172
|
* result.files.forEach(file => console.log(file));
|
|
164
173
|
*/
|
|
165
174
|
searchFiles(path: string, pattern: string): Promise<SearchFilesResponse>;
|
|
166
175
|
/**
|
|
167
176
|
* Sets permissions and ownership for a file or directory.
|
|
168
177
|
*
|
|
169
|
-
* @param {string} path - Path to the file or directory
|
|
178
|
+
* @param {string} path - Path to the file or directory. Relative paths are resolved based on the user's
|
|
179
|
+
* root directory.
|
|
170
180
|
* @param {FilePermissionsParams} permissions - Permission settings
|
|
171
181
|
* @returns {Promise<void>}
|
|
172
182
|
*
|
|
173
183
|
* @example
|
|
174
184
|
* // Set file permissions and ownership
|
|
175
|
-
* await fs.setFilePermissions('
|
|
185
|
+
* await fs.setFilePermissions('app/script.sh', {
|
|
176
186
|
* owner: 'daytona',
|
|
177
187
|
* group: 'users',
|
|
178
188
|
* mode: '755' // Execute permission for shell script
|
|
@@ -182,36 +192,38 @@ export declare class FileSystem {
|
|
|
182
192
|
/**
|
|
183
193
|
* Uploads a file to the Sandbox.
|
|
184
194
|
*
|
|
185
|
-
* @param {string} path - Destination path in the Sandbox
|
|
195
|
+
* @param {string} path - Destination path in the Sandbox. Relative paths are resolved based on the user's
|
|
196
|
+
* root directory.
|
|
186
197
|
* @param {File} file - File to upload
|
|
187
198
|
* @returns {Promise<void>}
|
|
188
199
|
*
|
|
189
200
|
* @example
|
|
190
201
|
* // Upload a configuration file
|
|
191
202
|
* const configFile = new File(['{"setting": "value"}'], 'config.json');
|
|
192
|
-
* await fs.uploadFile('
|
|
203
|
+
* await fs.uploadFile('app/config.json', configFile);
|
|
193
204
|
*/
|
|
194
205
|
uploadFile(path: string, file: File): Promise<void>;
|
|
195
206
|
/**
|
|
196
207
|
* Uploads multiple files to the Sandbox. The parent directories must exist.
|
|
197
208
|
* If files already exist at the destination paths, they will be overwritten.
|
|
198
209
|
*
|
|
199
|
-
* @param {FileUpload[]} files - Array of files to upload
|
|
210
|
+
* @param {FileUpload[]} files - Array of files to upload. Relative paths are resolved based on the user's
|
|
211
|
+
* root directory.
|
|
200
212
|
* @returns {Promise<void>}
|
|
201
213
|
*
|
|
202
214
|
* @example
|
|
203
215
|
* // Upload multiple text files
|
|
204
216
|
* const files = [
|
|
205
217
|
* {
|
|
206
|
-
* path: '
|
|
218
|
+
* path: 'app/data/file1.txt',
|
|
207
219
|
* content: new File(['Content of file 1'], 'file1.txt')
|
|
208
220
|
* },
|
|
209
221
|
* {
|
|
210
|
-
* path: '
|
|
222
|
+
* path: 'app/data/file2.txt',
|
|
211
223
|
* content: new File(['Content of file 2'], 'file2.txt')
|
|
212
224
|
* },
|
|
213
225
|
* {
|
|
214
|
-
* path: '
|
|
226
|
+
* path: 'app/config/settings.json',
|
|
215
227
|
* content: new File(['{"key": "value"}'], 'settings.json')
|
|
216
228
|
* }
|
|
217
229
|
* ];
|