@daytonaio/sdk 0.10.3-alpha.1 → 0.10.4
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 +3 -7
- package/dist/Daytona.d.ts +5 -5
- package/dist/Daytona.js +4 -7
- package/dist/FileSystem.d.ts +8 -8
- package/dist/FileSystem.js +8 -8
- package/dist/Git.d.ts +18 -18
- package/dist/Git.js +18 -18
- package/dist/LspServer.d.ts +10 -10
- package/dist/LspServer.js +10 -10
- package/dist/Process.d.ts +5 -5
- package/dist/Process.js +5 -5
- package/dist/Sandbox.d.ts +10 -6
- package/dist/Sandbox.js +13 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,11 +70,11 @@ const sandbox = await daytona.create({
|
|
|
70
70
|
|
|
71
71
|
## Features
|
|
72
72
|
|
|
73
|
-
- **Sandbox Management**: Create, manage and remove
|
|
73
|
+
- **Sandbox Management**: Create, manage and remove sandboxes
|
|
74
74
|
- **Git Operations**: Clone repositories, manage branches, and more
|
|
75
75
|
- **File System Operations**: Upload, download, search and manipulate files
|
|
76
76
|
- **Language Server Protocol**: Interact with language servers for code intelligence
|
|
77
|
-
- **Process Management**: Execute code and commands in
|
|
77
|
+
- **Process Management**: Execute code and commands in sandboxes
|
|
78
78
|
|
|
79
79
|
## Examples
|
|
80
80
|
|
|
@@ -100,11 +100,7 @@ console.log(response.result)
|
|
|
100
100
|
// Upload a file
|
|
101
101
|
await sandbox.fs.uploadFile(
|
|
102
102
|
'/path/to/file.txt',
|
|
103
|
-
new File(
|
|
104
|
-
[Buffer.from('Hello, World!')],
|
|
105
|
-
'file.txt',
|
|
106
|
-
{ type: 'text/plain' }
|
|
107
|
-
)
|
|
103
|
+
new File([Buffer.from('Hello, World!')], 'file.txt', { type: 'text/plain' }),
|
|
108
104
|
)
|
|
109
105
|
|
|
110
106
|
// Download a file
|
package/dist/Daytona.d.ts
CHANGED
|
@@ -67,9 +67,9 @@ export interface DaytonaConfig {
|
|
|
67
67
|
/** API key for authentication with Daytona server */
|
|
68
68
|
apiKey: string;
|
|
69
69
|
/** URL of the Daytona server */
|
|
70
|
-
serverUrl
|
|
71
|
-
/** Target environment for
|
|
72
|
-
target
|
|
70
|
+
serverUrl?: string;
|
|
71
|
+
/** Target environment for sandboxes */
|
|
72
|
+
target?: SandboxTargetRegion;
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Supported programming languages for code execution
|
|
@@ -247,8 +247,8 @@ export declare class Daytona {
|
|
|
247
247
|
* @returns {Promise<Sandbox[]>} Array of Sandboxes
|
|
248
248
|
*
|
|
249
249
|
* @example
|
|
250
|
-
* const
|
|
251
|
-
* for (const sandbox of
|
|
250
|
+
* const sandboxes = await daytona.list();
|
|
251
|
+
* for (const sandbox of sandboxes) {
|
|
252
252
|
* console.log(`${sandbox.id}: ${sandbox.instance.state}`);
|
|
253
253
|
* }
|
|
254
254
|
*/
|
package/dist/Daytona.js
CHANGED
|
@@ -122,10 +122,7 @@ class Daytona {
|
|
|
122
122
|
if (!apiKey) {
|
|
123
123
|
throw new DaytonaError_1.DaytonaError('API key is required');
|
|
124
124
|
}
|
|
125
|
-
const serverUrl = (config === null || config === void 0 ? void 0 : config.serverUrl) || process.env.DAYTONA_SERVER_URL;
|
|
126
|
-
if (!serverUrl) {
|
|
127
|
-
throw new DaytonaError_1.DaytonaError('Server URL is required');
|
|
128
|
-
}
|
|
125
|
+
const serverUrl = (config === null || config === void 0 ? void 0 : config.serverUrl) || process.env.DAYTONA_SERVER_URL || 'https://app.daytona.io/api';
|
|
129
126
|
const envTarget = process.env.DAYTONA_TARGET;
|
|
130
127
|
const target = (config === null || config === void 0 ? void 0 : config.target) || envTarget || api_client_1.CreateWorkspaceTargetEnum.US;
|
|
131
128
|
this.apiKey = apiKey;
|
|
@@ -190,8 +187,8 @@ class Daytona {
|
|
|
190
187
|
* const sandbox = await daytona.create(params, 40);
|
|
191
188
|
*/
|
|
192
189
|
async create(params, timeout = 60) {
|
|
190
|
+
// const startTime = Date.now();
|
|
193
191
|
var _a, _b, _c, _d;
|
|
194
|
-
const startTime = Date.now();
|
|
195
192
|
if (params == null) {
|
|
196
193
|
params = { language: 'python' };
|
|
197
194
|
}
|
|
@@ -269,8 +266,8 @@ class Daytona {
|
|
|
269
266
|
* @returns {Promise<Sandbox[]>} Array of Sandboxes
|
|
270
267
|
*
|
|
271
268
|
* @example
|
|
272
|
-
* const
|
|
273
|
-
* for (const sandbox of
|
|
269
|
+
* const sandboxes = await daytona.list();
|
|
270
|
+
* for (const sandbox of sandboxes) {
|
|
274
271
|
* console.log(`${sandbox.id}: ${sandbox.instance.state}`);
|
|
275
272
|
* }
|
|
276
273
|
*/
|
package/dist/FileSystem.d.ts
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
* const sandbox = await daytona.create();
|
|
12
12
|
*
|
|
13
13
|
* // Create a directory
|
|
14
|
-
* await sandbox.fs.createFolder('/
|
|
14
|
+
* await sandbox.fs.createFolder('/workspace/data', '755');
|
|
15
15
|
*
|
|
16
16
|
* // Upload a file
|
|
17
17
|
* const fileContent = new File(['content'], 'local_file.txt');
|
|
18
|
-
* await sandbox.fs.uploadFile('/
|
|
18
|
+
* await sandbox.fs.uploadFile('/workspace/data/file.txt', fileContent);
|
|
19
19
|
*
|
|
20
20
|
* // List directory contents
|
|
21
|
-
* const files = await sandbox.fs.listFiles('/
|
|
21
|
+
* const files = await sandbox.fs.listFiles('/workspace');
|
|
22
22
|
* files.forEach(file => {
|
|
23
23
|
* console.log(`Name: ${file.name}`);
|
|
24
24
|
* console.log(`Is directory: ${file.isDir}`);
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
*
|
|
29
29
|
* // Search file contents
|
|
30
30
|
* const matches = await sandbox.fs.findFiles(
|
|
31
|
-
* '/
|
|
31
|
+
* '/workspace/src',
|
|
32
32
|
* 'text-of-interest'
|
|
33
33
|
* );
|
|
34
34
|
* matches.forEach(match => {
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
* // File manipulation
|
|
42
42
|
* // Move files
|
|
43
43
|
* await sandbox.fs.moveFiles(
|
|
44
|
-
* '/
|
|
45
|
-
* '/
|
|
44
|
+
* '/workspace/data/old.txt',
|
|
45
|
+
* '/workspace/data/new.txt'
|
|
46
46
|
* );
|
|
47
47
|
*
|
|
48
48
|
* // Replace text in files
|
|
49
49
|
* const results = await sandbox.fs.replaceInFiles(
|
|
50
|
-
* ['/
|
|
50
|
+
* ['/workspace/data/new.txt'],
|
|
51
51
|
* 'old_version',
|
|
52
52
|
* 'new_version'
|
|
53
53
|
* );
|
|
54
54
|
*
|
|
55
55
|
* // Set permissions
|
|
56
56
|
* await sandbox.fs.setFilePermissions(
|
|
57
|
-
* '/
|
|
57
|
+
* '/workspace/data/script.sh',
|
|
58
58
|
* {
|
|
59
59
|
* mode: '755',
|
|
60
60
|
* owner: 'daytona'
|
package/dist/FileSystem.js
CHANGED
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
* const sandbox = await daytona.create();
|
|
13
13
|
*
|
|
14
14
|
* // Create a directory
|
|
15
|
-
* await sandbox.fs.createFolder('/
|
|
15
|
+
* await sandbox.fs.createFolder('/workspace/data', '755');
|
|
16
16
|
*
|
|
17
17
|
* // Upload a file
|
|
18
18
|
* const fileContent = new File(['content'], 'local_file.txt');
|
|
19
|
-
* await sandbox.fs.uploadFile('/
|
|
19
|
+
* await sandbox.fs.uploadFile('/workspace/data/file.txt', fileContent);
|
|
20
20
|
*
|
|
21
21
|
* // List directory contents
|
|
22
|
-
* const files = await sandbox.fs.listFiles('/
|
|
22
|
+
* const files = await sandbox.fs.listFiles('/workspace');
|
|
23
23
|
* files.forEach(file => {
|
|
24
24
|
* console.log(`Name: ${file.name}`);
|
|
25
25
|
* console.log(`Is directory: ${file.isDir}`);
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
*
|
|
30
30
|
* // Search file contents
|
|
31
31
|
* const matches = await sandbox.fs.findFiles(
|
|
32
|
-
* '/
|
|
32
|
+
* '/workspace/src',
|
|
33
33
|
* 'text-of-interest'
|
|
34
34
|
* );
|
|
35
35
|
* matches.forEach(match => {
|
|
@@ -42,20 +42,20 @@
|
|
|
42
42
|
* // File manipulation
|
|
43
43
|
* // Move files
|
|
44
44
|
* await sandbox.fs.moveFiles(
|
|
45
|
-
* '/
|
|
46
|
-
* '/
|
|
45
|
+
* '/workspace/data/old.txt',
|
|
46
|
+
* '/workspace/data/new.txt'
|
|
47
47
|
* );
|
|
48
48
|
*
|
|
49
49
|
* // Replace text in files
|
|
50
50
|
* const results = await sandbox.fs.replaceInFiles(
|
|
51
|
-
* ['/
|
|
51
|
+
* ['/workspace/data/new.txt'],
|
|
52
52
|
* 'old_version',
|
|
53
53
|
* 'new_version'
|
|
54
54
|
* );
|
|
55
55
|
*
|
|
56
56
|
* // Set permissions
|
|
57
57
|
* await sandbox.fs.setFilePermissions(
|
|
58
|
-
* '/
|
|
58
|
+
* '/workspace/data/script.sh',
|
|
59
59
|
* {
|
|
60
60
|
* mode: '755',
|
|
61
61
|
* owner: 'daytona'
|
package/dist/Git.d.ts
CHANGED
|
@@ -14,19 +14,19 @@
|
|
|
14
14
|
* // Clone a repository
|
|
15
15
|
* await sandbox.git.clone(
|
|
16
16
|
* 'https://github.com/user/repo.git',
|
|
17
|
-
* '/
|
|
17
|
+
* '/workspace/repo'
|
|
18
18
|
* );
|
|
19
19
|
*
|
|
20
20
|
* // Make some changes
|
|
21
21
|
* await sandbox.fs.uploadFile(
|
|
22
|
-
* '/
|
|
22
|
+
* '/workspace/repo/test.txt',
|
|
23
23
|
* new File([Buffer.from('Hello, World!')], 'test.txt')
|
|
24
24
|
* );
|
|
25
25
|
*
|
|
26
26
|
* // Stage and commit changes
|
|
27
|
-
* await sandbox.git.add('/
|
|
27
|
+
* await sandbox.git.add('/workspace/repo', ['test.txt']);
|
|
28
28
|
* await sandbox.git.commit(
|
|
29
|
-
* '/
|
|
29
|
+
* '/workspace/repo',
|
|
30
30
|
* 'Add test file',
|
|
31
31
|
* 'John Doe',
|
|
32
32
|
* 'john@example.com'
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
*
|
|
35
35
|
* // Push changes (with authentication)
|
|
36
36
|
* await sandbox.git.push(
|
|
37
|
-
* '/
|
|
37
|
+
* '/workspace/repo',
|
|
38
38
|
* 'user',
|
|
39
39
|
* 'token'
|
|
40
40
|
* );
|
|
@@ -59,11 +59,11 @@ export declare class Git {
|
|
|
59
59
|
*
|
|
60
60
|
* @example
|
|
61
61
|
* // Stage a single file
|
|
62
|
-
* await git.add('/
|
|
62
|
+
* await git.add('/workspace/repo', ['file.txt']);
|
|
63
63
|
*
|
|
64
64
|
* @example
|
|
65
65
|
* // Stage whole repository
|
|
66
|
-
* await git.add('/
|
|
66
|
+
* await git.add('/workspace/repo', ['.']);
|
|
67
67
|
*/
|
|
68
68
|
add(path: string, files: string[]): Promise<void>;
|
|
69
69
|
/**
|
|
@@ -75,7 +75,7 @@ export declare class Git {
|
|
|
75
75
|
* @returns {Promise<ListBranchResponse>} List of branches in the repository
|
|
76
76
|
*
|
|
77
77
|
* @example
|
|
78
|
-
* const response = await git.branches('/
|
|
78
|
+
* const response = await git.branches('/workspace/repo');
|
|
79
79
|
* console.log(`Branches: ${response.branches}`);
|
|
80
80
|
*/
|
|
81
81
|
branches(path: string): Promise<ListBranchResponse>;
|
|
@@ -98,14 +98,14 @@ export declare class Git {
|
|
|
98
98
|
* // Clone the default branch
|
|
99
99
|
* await git.clone(
|
|
100
100
|
* 'https://github.com/user/repo.git',
|
|
101
|
-
* '/
|
|
101
|
+
* '/workspace/repo'
|
|
102
102
|
* );
|
|
103
103
|
*
|
|
104
104
|
* @example
|
|
105
105
|
* // Clone a specific branch with authentication
|
|
106
106
|
* await git.clone(
|
|
107
107
|
* 'https://github.com/user/private-repo.git',
|
|
108
|
-
* '/
|
|
108
|
+
* '/workspace/private',
|
|
109
109
|
* branch='develop',
|
|
110
110
|
* username='user',
|
|
111
111
|
* password='token'
|
|
@@ -115,7 +115,7 @@ export declare class Git {
|
|
|
115
115
|
* // Clone a specific commit
|
|
116
116
|
* await git.clone(
|
|
117
117
|
* 'https://github.com/user/repo.git',
|
|
118
|
-
* '/
|
|
118
|
+
* '/workspace/repo-old',
|
|
119
119
|
* commitId='abc123'
|
|
120
120
|
* );
|
|
121
121
|
*/
|
|
@@ -134,9 +134,9 @@ export declare class Git {
|
|
|
134
134
|
*
|
|
135
135
|
* @example
|
|
136
136
|
* // Stage and commit changes
|
|
137
|
-
* await git.add('/
|
|
137
|
+
* await git.add('/workspace/repo', ['README.md']);
|
|
138
138
|
* await git.commit(
|
|
139
|
-
* '/
|
|
139
|
+
* '/workspace/repo',
|
|
140
140
|
* 'Update documentation',
|
|
141
141
|
* 'John Doe',
|
|
142
142
|
* 'john@example.com'
|
|
@@ -156,12 +156,12 @@ export declare class Git {
|
|
|
156
156
|
*
|
|
157
157
|
* @example
|
|
158
158
|
* // Push to a public repository
|
|
159
|
-
* await git.push('/
|
|
159
|
+
* await git.push('/workspace/repo');
|
|
160
160
|
*
|
|
161
161
|
* @example
|
|
162
162
|
* // Push to a private repository
|
|
163
163
|
* await git.push(
|
|
164
|
-
* '/
|
|
164
|
+
* '/workspace/repo',
|
|
165
165
|
* 'user',
|
|
166
166
|
* 'token'
|
|
167
167
|
* );
|
|
@@ -180,12 +180,12 @@ export declare class Git {
|
|
|
180
180
|
*
|
|
181
181
|
* @example
|
|
182
182
|
* // Pull from a public repository
|
|
183
|
-
* await git.pull('/
|
|
183
|
+
* await git.pull('/workspace/repo');
|
|
184
184
|
*
|
|
185
185
|
* @example
|
|
186
186
|
* // Pull from a private repository
|
|
187
187
|
* await git.pull(
|
|
188
|
-
* '/
|
|
188
|
+
* '/workspace/repo',
|
|
189
189
|
* 'user',
|
|
190
190
|
* 'token'
|
|
191
191
|
* );
|
|
@@ -206,7 +206,7 @@ export declare class Git {
|
|
|
206
206
|
* - fileStatus: List of file statuses
|
|
207
207
|
*
|
|
208
208
|
* @example
|
|
209
|
-
* const status = await sandbox.git.status('/
|
|
209
|
+
* const status = await sandbox.git.status('/workspace/repo');
|
|
210
210
|
* console.log(`Current branch: ${status.currentBranch}`);
|
|
211
211
|
* console.log(`Commits ahead: ${status.ahead}`);
|
|
212
212
|
* console.log(`Commits behind: ${status.behind}`);
|
package/dist/Git.js
CHANGED
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
* // Clone a repository
|
|
16
16
|
* await sandbox.git.clone(
|
|
17
17
|
* 'https://github.com/user/repo.git',
|
|
18
|
-
* '/
|
|
18
|
+
* '/workspace/repo'
|
|
19
19
|
* );
|
|
20
20
|
*
|
|
21
21
|
* // Make some changes
|
|
22
22
|
* await sandbox.fs.uploadFile(
|
|
23
|
-
* '/
|
|
23
|
+
* '/workspace/repo/test.txt',
|
|
24
24
|
* new File([Buffer.from('Hello, World!')], 'test.txt')
|
|
25
25
|
* );
|
|
26
26
|
*
|
|
27
27
|
* // Stage and commit changes
|
|
28
|
-
* await sandbox.git.add('/
|
|
28
|
+
* await sandbox.git.add('/workspace/repo', ['test.txt']);
|
|
29
29
|
* await sandbox.git.commit(
|
|
30
|
-
* '/
|
|
30
|
+
* '/workspace/repo',
|
|
31
31
|
* 'Add test file',
|
|
32
32
|
* 'John Doe',
|
|
33
33
|
* 'john@example.com'
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
*
|
|
36
36
|
* // Push changes (with authentication)
|
|
37
37
|
* await sandbox.git.push(
|
|
38
|
-
* '/
|
|
38
|
+
* '/workspace/repo',
|
|
39
39
|
* 'user',
|
|
40
40
|
* 'token'
|
|
41
41
|
* );
|
|
@@ -61,11 +61,11 @@ class Git {
|
|
|
61
61
|
*
|
|
62
62
|
* @example
|
|
63
63
|
* // Stage a single file
|
|
64
|
-
* await git.add('/
|
|
64
|
+
* await git.add('/workspace/repo', ['file.txt']);
|
|
65
65
|
*
|
|
66
66
|
* @example
|
|
67
67
|
* // Stage whole repository
|
|
68
|
-
* await git.add('/
|
|
68
|
+
* await git.add('/workspace/repo', ['.']);
|
|
69
69
|
*/
|
|
70
70
|
async add(path, files) {
|
|
71
71
|
await this.toolboxApi.gitAddFiles(this.instance.id, {
|
|
@@ -82,7 +82,7 @@ class Git {
|
|
|
82
82
|
* @returns {Promise<ListBranchResponse>} List of branches in the repository
|
|
83
83
|
*
|
|
84
84
|
* @example
|
|
85
|
-
* const response = await git.branches('/
|
|
85
|
+
* const response = await git.branches('/workspace/repo');
|
|
86
86
|
* console.log(`Branches: ${response.branches}`);
|
|
87
87
|
*/
|
|
88
88
|
async branches(path) {
|
|
@@ -108,14 +108,14 @@ class Git {
|
|
|
108
108
|
* // Clone the default branch
|
|
109
109
|
* await git.clone(
|
|
110
110
|
* 'https://github.com/user/repo.git',
|
|
111
|
-
* '/
|
|
111
|
+
* '/workspace/repo'
|
|
112
112
|
* );
|
|
113
113
|
*
|
|
114
114
|
* @example
|
|
115
115
|
* // Clone a specific branch with authentication
|
|
116
116
|
* await git.clone(
|
|
117
117
|
* 'https://github.com/user/private-repo.git',
|
|
118
|
-
* '/
|
|
118
|
+
* '/workspace/private',
|
|
119
119
|
* branch='develop',
|
|
120
120
|
* username='user',
|
|
121
121
|
* password='token'
|
|
@@ -125,7 +125,7 @@ class Git {
|
|
|
125
125
|
* // Clone a specific commit
|
|
126
126
|
* await git.clone(
|
|
127
127
|
* 'https://github.com/user/repo.git',
|
|
128
|
-
* '/
|
|
128
|
+
* '/workspace/repo-old',
|
|
129
129
|
* commitId='abc123'
|
|
130
130
|
* );
|
|
131
131
|
*/
|
|
@@ -153,9 +153,9 @@ class Git {
|
|
|
153
153
|
*
|
|
154
154
|
* @example
|
|
155
155
|
* // Stage and commit changes
|
|
156
|
-
* await git.add('/
|
|
156
|
+
* await git.add('/workspace/repo', ['README.md']);
|
|
157
157
|
* await git.commit(
|
|
158
|
-
* '/
|
|
158
|
+
* '/workspace/repo',
|
|
159
159
|
* 'Update documentation',
|
|
160
160
|
* 'John Doe',
|
|
161
161
|
* 'john@example.com'
|
|
@@ -182,12 +182,12 @@ class Git {
|
|
|
182
182
|
*
|
|
183
183
|
* @example
|
|
184
184
|
* // Push to a public repository
|
|
185
|
-
* await git.push('/
|
|
185
|
+
* await git.push('/workspace/repo');
|
|
186
186
|
*
|
|
187
187
|
* @example
|
|
188
188
|
* // Push to a private repository
|
|
189
189
|
* await git.push(
|
|
190
|
-
* '/
|
|
190
|
+
* '/workspace/repo',
|
|
191
191
|
* 'user',
|
|
192
192
|
* 'token'
|
|
193
193
|
* );
|
|
@@ -212,12 +212,12 @@ class Git {
|
|
|
212
212
|
*
|
|
213
213
|
* @example
|
|
214
214
|
* // Pull from a public repository
|
|
215
|
-
* await git.pull('/
|
|
215
|
+
* await git.pull('/workspace/repo');
|
|
216
216
|
*
|
|
217
217
|
* @example
|
|
218
218
|
* // Pull from a private repository
|
|
219
219
|
* await git.pull(
|
|
220
|
-
* '/
|
|
220
|
+
* '/workspace/repo',
|
|
221
221
|
* 'user',
|
|
222
222
|
* 'token'
|
|
223
223
|
* );
|
|
@@ -244,7 +244,7 @@ class Git {
|
|
|
244
244
|
* - fileStatus: List of file statuses
|
|
245
245
|
*
|
|
246
246
|
* @example
|
|
247
|
-
* const status = await sandbox.git.status('/
|
|
247
|
+
* const status = await sandbox.git.status('/workspace/repo');
|
|
248
248
|
* console.log(`Current branch: ${status.currentBranch}`);
|
|
249
249
|
* console.log(`Commits ahead: ${status.ahead}`);
|
|
250
250
|
* console.log(`Commits behind: ${status.behind}`);
|
package/dist/LspServer.d.ts
CHANGED
|
@@ -13,27 +13,27 @@
|
|
|
13
13
|
* const sandbox = await daytona.create();
|
|
14
14
|
*
|
|
15
15
|
* // Create and start LSP server
|
|
16
|
-
* const lsp = sandbox.createLspServer('typescript', '/
|
|
16
|
+
* const lsp = sandbox.createLspServer('typescript', '/workspace/project');
|
|
17
17
|
* await lsp.start();
|
|
18
18
|
*
|
|
19
19
|
* // Open a file for editing
|
|
20
|
-
* await lsp.didOpen('/
|
|
20
|
+
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
21
21
|
*
|
|
22
22
|
* // Get completions at a position
|
|
23
23
|
* const completions = await lsp.completions(
|
|
24
|
-
* '/
|
|
24
|
+
* '/workspace/project/src/index.ts',
|
|
25
25
|
* { line: 10, character: 15 }
|
|
26
26
|
* );
|
|
27
27
|
* console.log('Completions:', completions);
|
|
28
28
|
*
|
|
29
29
|
* // Get document symbols
|
|
30
|
-
* const symbols = await lsp.documentSymbols('/
|
|
30
|
+
* const symbols = await lsp.documentSymbols('/workspace/project/src/index.ts');
|
|
31
31
|
* symbols.forEach(symbol => {
|
|
32
32
|
* console.log(`${symbol.name}: ${symbol.kind}`);
|
|
33
33
|
* });
|
|
34
34
|
*
|
|
35
35
|
* // Clean up
|
|
36
|
-
* await lsp.didClose('/
|
|
36
|
+
* await lsp.didClose('/workspace/project/src/index.ts');
|
|
37
37
|
* await lsp.stop();
|
|
38
38
|
*
|
|
39
39
|
*/
|
|
@@ -97,7 +97,7 @@ export declare class LspServer {
|
|
|
97
97
|
* @returns {Promise<void>}
|
|
98
98
|
*
|
|
99
99
|
* @example
|
|
100
|
-
* const lsp = sandbox.createLspServer('typescript', '/
|
|
100
|
+
* const lsp = sandbox.createLspServer('typescript', '/workspace/project');
|
|
101
101
|
* await lsp.start(); // Initialize the server
|
|
102
102
|
* // Now ready for LSP operations
|
|
103
103
|
*/
|
|
@@ -127,7 +127,7 @@ export declare class LspServer {
|
|
|
127
127
|
*
|
|
128
128
|
* @example
|
|
129
129
|
* // When opening a file for editing
|
|
130
|
-
* await lsp.didOpen('/
|
|
130
|
+
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
131
131
|
* // Now can get completions, symbols, etc. for this file
|
|
132
132
|
*/
|
|
133
133
|
didOpen(path: string): Promise<void>;
|
|
@@ -142,7 +142,7 @@ export declare class LspServer {
|
|
|
142
142
|
*
|
|
143
143
|
* @example
|
|
144
144
|
* // When done editing a file
|
|
145
|
-
* await lsp.didClose('/
|
|
145
|
+
* await lsp.didClose('/workspace/project/src/index.ts');
|
|
146
146
|
*/
|
|
147
147
|
didClose(path: string): Promise<void>;
|
|
148
148
|
/**
|
|
@@ -159,7 +159,7 @@ export declare class LspServer {
|
|
|
159
159
|
*
|
|
160
160
|
* @example
|
|
161
161
|
* // Get all symbols in a file
|
|
162
|
-
* const symbols = await lsp.documentSymbols('/
|
|
162
|
+
* const symbols = await lsp.documentSymbols('/workspace/project/src/index.ts');
|
|
163
163
|
* symbols.forEach(symbol => {
|
|
164
164
|
* console.log(`${symbol.kind} ${symbol.name}: ${symbol.location}`);
|
|
165
165
|
* });
|
|
@@ -220,7 +220,7 @@ export declare class LspServer {
|
|
|
220
220
|
*
|
|
221
221
|
* @example
|
|
222
222
|
* // Get completions at a specific position
|
|
223
|
-
* const completions = await lsp.completions('/
|
|
223
|
+
* const completions = await lsp.completions('/workspace/project/src/index.ts', {
|
|
224
224
|
* line: 10,
|
|
225
225
|
* character: 15
|
|
226
226
|
* });
|
package/dist/LspServer.js
CHANGED
|
@@ -14,27 +14,27 @@
|
|
|
14
14
|
* const sandbox = await daytona.create();
|
|
15
15
|
*
|
|
16
16
|
* // Create and start LSP server
|
|
17
|
-
* const lsp = sandbox.createLspServer('typescript', '/
|
|
17
|
+
* const lsp = sandbox.createLspServer('typescript', '/workspace/project');
|
|
18
18
|
* await lsp.start();
|
|
19
19
|
*
|
|
20
20
|
* // Open a file for editing
|
|
21
|
-
* await lsp.didOpen('/
|
|
21
|
+
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
22
22
|
*
|
|
23
23
|
* // Get completions at a position
|
|
24
24
|
* const completions = await lsp.completions(
|
|
25
|
-
* '/
|
|
25
|
+
* '/workspace/project/src/index.ts',
|
|
26
26
|
* { line: 10, character: 15 }
|
|
27
27
|
* );
|
|
28
28
|
* console.log('Completions:', completions);
|
|
29
29
|
*
|
|
30
30
|
* // Get document symbols
|
|
31
|
-
* const symbols = await lsp.documentSymbols('/
|
|
31
|
+
* const symbols = await lsp.documentSymbols('/workspace/project/src/index.ts');
|
|
32
32
|
* symbols.forEach(symbol => {
|
|
33
33
|
* console.log(`${symbol.name}: ${symbol.kind}`);
|
|
34
34
|
* });
|
|
35
35
|
*
|
|
36
36
|
* // Clean up
|
|
37
|
-
* await lsp.didClose('/
|
|
37
|
+
* await lsp.didClose('/workspace/project/src/index.ts');
|
|
38
38
|
* await lsp.stop();
|
|
39
39
|
*
|
|
40
40
|
*/
|
|
@@ -81,7 +81,7 @@ class LspServer {
|
|
|
81
81
|
* @returns {Promise<void>}
|
|
82
82
|
*
|
|
83
83
|
* @example
|
|
84
|
-
* const lsp = sandbox.createLspServer('typescript', '/
|
|
84
|
+
* const lsp = sandbox.createLspServer('typescript', '/workspace/project');
|
|
85
85
|
* await lsp.start(); // Initialize the server
|
|
86
86
|
* // Now ready for LSP operations
|
|
87
87
|
*/
|
|
@@ -121,7 +121,7 @@ class LspServer {
|
|
|
121
121
|
*
|
|
122
122
|
* @example
|
|
123
123
|
* // When opening a file for editing
|
|
124
|
-
* await lsp.didOpen('/
|
|
124
|
+
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
125
125
|
* // Now can get completions, symbols, etc. for this file
|
|
126
126
|
*/
|
|
127
127
|
async didOpen(path) {
|
|
@@ -142,7 +142,7 @@ class LspServer {
|
|
|
142
142
|
*
|
|
143
143
|
* @example
|
|
144
144
|
* // When done editing a file
|
|
145
|
-
* await lsp.didClose('/
|
|
145
|
+
* await lsp.didClose('/workspace/project/src/index.ts');
|
|
146
146
|
*/
|
|
147
147
|
async didClose(path) {
|
|
148
148
|
await this.toolboxApi.lspDidClose(this.instance.id, {
|
|
@@ -165,7 +165,7 @@ class LspServer {
|
|
|
165
165
|
*
|
|
166
166
|
* @example
|
|
167
167
|
* // Get all symbols in a file
|
|
168
|
-
* const symbols = await lsp.documentSymbols('/
|
|
168
|
+
* const symbols = await lsp.documentSymbols('/workspace/project/src/index.ts');
|
|
169
169
|
* symbols.forEach(symbol => {
|
|
170
170
|
* console.log(`${symbol.kind} ${symbol.name}: ${symbol.location}`);
|
|
171
171
|
* });
|
|
@@ -234,7 +234,7 @@ class LspServer {
|
|
|
234
234
|
*
|
|
235
235
|
* @example
|
|
236
236
|
* // Get completions at a specific position
|
|
237
|
-
* const completions = await lsp.completions('/
|
|
237
|
+
* const completions = await lsp.completions('/workspace/project/src/index.ts', {
|
|
238
238
|
* line: 10,
|
|
239
239
|
* character: 15
|
|
240
240
|
* });
|
package/dist/Process.d.ts
CHANGED
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
*
|
|
23
23
|
* // Execute commands in the session
|
|
24
24
|
* const response = await sandbox.process.executeSessionCommand(sessionId, {
|
|
25
|
-
* command: 'cd /
|
|
25
|
+
* command: 'cd /workspace'
|
|
26
26
|
* });
|
|
27
27
|
*
|
|
28
28
|
* const response2 = await sandbox.process.executeSessionCommand(sessionId, {
|
|
29
29
|
* command: 'pwd'
|
|
30
30
|
* });
|
|
31
|
-
* console.log(response2.result); // Should print "/
|
|
31
|
+
* console.log(response2.result); // Should print "/workspace"
|
|
32
32
|
*
|
|
33
33
|
* // Clean up
|
|
34
34
|
* await sandbox.process.deleteSession(sessionId);
|
|
@@ -70,7 +70,7 @@ export declare class Process {
|
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
72
|
* // Command with working directory
|
|
73
|
-
* const result = await process.executeCommand('ls', '/
|
|
73
|
+
* const result = await process.executeCommand('ls', '/workspace/src');
|
|
74
74
|
*
|
|
75
75
|
* @example
|
|
76
76
|
* // Command with timeout
|
|
@@ -166,14 +166,14 @@ export declare class Process {
|
|
|
166
166
|
*
|
|
167
167
|
* // Change directory
|
|
168
168
|
* await process.executeSessionCommand(sessionId, {
|
|
169
|
-
* command: 'cd /
|
|
169
|
+
* command: 'cd /workspace'
|
|
170
170
|
* });
|
|
171
171
|
*
|
|
172
172
|
* // Run command in new directory
|
|
173
173
|
* const result = await process.executeSessionCommand(sessionId, {
|
|
174
174
|
* command: 'pwd'
|
|
175
175
|
* });
|
|
176
|
-
* console.log(result.output); // Prints: /
|
|
176
|
+
* console.log(result.output); // Prints: /workspace
|
|
177
177
|
*/
|
|
178
178
|
executeSessionCommand(sessionId: string, req: SessionExecuteRequest, timeout?: number): Promise<SessionExecuteResponse>;
|
|
179
179
|
/**
|
package/dist/Process.js
CHANGED
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
*
|
|
24
24
|
* // Execute commands in the session
|
|
25
25
|
* const response = await sandbox.process.executeSessionCommand(sessionId, {
|
|
26
|
-
* command: 'cd /
|
|
26
|
+
* command: 'cd /workspace'
|
|
27
27
|
* });
|
|
28
28
|
*
|
|
29
29
|
* const response2 = await sandbox.process.executeSessionCommand(sessionId, {
|
|
30
30
|
* command: 'pwd'
|
|
31
31
|
* });
|
|
32
|
-
* console.log(response2.result); // Should print "/
|
|
32
|
+
* console.log(response2.result); // Should print "/workspace"
|
|
33
33
|
*
|
|
34
34
|
* // Clean up
|
|
35
35
|
* await sandbox.process.deleteSession(sessionId);
|
|
@@ -65,7 +65,7 @@ class Process {
|
|
|
65
65
|
*
|
|
66
66
|
* @example
|
|
67
67
|
* // Command with working directory
|
|
68
|
-
* const result = await process.executeCommand('ls', '/
|
|
68
|
+
* const result = await process.executeCommand('ls', '/workspace/src');
|
|
69
69
|
*
|
|
70
70
|
* @example
|
|
71
71
|
* // Command with timeout
|
|
@@ -182,14 +182,14 @@ class Process {
|
|
|
182
182
|
*
|
|
183
183
|
* // Change directory
|
|
184
184
|
* await process.executeSessionCommand(sessionId, {
|
|
185
|
-
* command: 'cd /
|
|
185
|
+
* command: 'cd /workspace'
|
|
186
186
|
* });
|
|
187
187
|
*
|
|
188
188
|
* // Run command in new directory
|
|
189
189
|
* const result = await process.executeSessionCommand(sessionId, {
|
|
190
190
|
* command: 'pwd'
|
|
191
191
|
* });
|
|
192
|
-
* console.log(result.output); // Prints: /
|
|
192
|
+
* console.log(result.output); // Prints: /workspace
|
|
193
193
|
*/
|
|
194
194
|
async executeSessionCommand(sessionId, req, timeout) {
|
|
195
195
|
const response = await this.toolboxApi.executeSessionCommand(this.instance.id, sessionId, req, timeout ? { timeout: timeout * 1000 } : {});
|
package/dist/Sandbox.d.ts
CHANGED
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
* console.log(response.result);
|
|
30
30
|
*
|
|
31
31
|
* // LSP functionality
|
|
32
|
-
* const lsp = sandbox.createLspServer('typescript', '/
|
|
33
|
-
* await lsp.didOpen('/
|
|
34
|
-
* const completions = await lsp.completions('/
|
|
32
|
+
* const lsp = sandbox.createLspServer('typescript', '/workspace/project');
|
|
33
|
+
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
34
|
+
* const completions = await lsp.completions('/workspace/project/src/index.ts', {
|
|
35
35
|
* line: 10,
|
|
36
36
|
* character: 15
|
|
37
37
|
* });
|
|
@@ -193,14 +193,18 @@ export declare class Sandbox {
|
|
|
193
193
|
*/
|
|
194
194
|
constructor(id: string, instance: SandboxInstance, sandboxApi: SandboxApi, toolboxApi: ToolboxApi, codeToolbox: SandboxCodeToolbox);
|
|
195
195
|
/**
|
|
196
|
-
* Gets the root directory path for the logged in user inside the Sandbox.
|
|
196
|
+
* Gets the root directory path for the logged in user inside the Sandbox.
|
|
197
197
|
*
|
|
198
198
|
* @returns {Promise<string | undefined>} The absolute path to the Sandbox root directory for the logged in user
|
|
199
199
|
*
|
|
200
200
|
* @example
|
|
201
|
-
* const rootDir = await sandbox.
|
|
201
|
+
* const rootDir = await sandbox.getUserRootDir();
|
|
202
202
|
* console.log(`Sandbox root: ${rootDir}`);
|
|
203
203
|
*/
|
|
204
|
+
getUserRootDir(): Promise<string | undefined>;
|
|
205
|
+
/**
|
|
206
|
+
* @deprecated Use `getUserRootDir` instead. This method will be removed in a future version.
|
|
207
|
+
*/
|
|
204
208
|
getWorkspaceRootDir(): Promise<string | undefined>;
|
|
205
209
|
/**
|
|
206
210
|
* Creates a new Language Server Protocol (LSP) server instance.
|
|
@@ -213,7 +217,7 @@ export declare class Sandbox {
|
|
|
213
217
|
* @returns {LspServer} A new LSP server instance configured for the specified language
|
|
214
218
|
*
|
|
215
219
|
* @example
|
|
216
|
-
* const lsp = sandbox.createLspServer('typescript', '/
|
|
220
|
+
* const lsp = sandbox.createLspServer('typescript', '/workspace/project');
|
|
217
221
|
*/
|
|
218
222
|
createLspServer(languageId: LspLanguageId | string, pathToProject: string): LspServer;
|
|
219
223
|
/**
|
package/dist/Sandbox.js
CHANGED
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
* console.log(response.result);
|
|
31
31
|
*
|
|
32
32
|
* // LSP functionality
|
|
33
|
-
* const lsp = sandbox.createLspServer('typescript', '/
|
|
34
|
-
* await lsp.didOpen('/
|
|
35
|
-
* const completions = await lsp.completions('/
|
|
33
|
+
* const lsp = sandbox.createLspServer('typescript', '/workspace/project');
|
|
34
|
+
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
35
|
+
* const completions = await lsp.completions('/workspace/project/src/index.ts', {
|
|
36
36
|
* line: 10,
|
|
37
37
|
* character: 15
|
|
38
38
|
* });
|
|
@@ -83,18 +83,24 @@ class Sandbox {
|
|
|
83
83
|
this.process = new Process_1.Process(this.codeToolbox, this.toolboxApi, instance);
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
|
-
* Gets the root directory path for the logged in user inside the Sandbox.
|
|
86
|
+
* Gets the root directory path for the logged in user inside the Sandbox.
|
|
87
87
|
*
|
|
88
88
|
* @returns {Promise<string | undefined>} The absolute path to the Sandbox root directory for the logged in user
|
|
89
89
|
*
|
|
90
90
|
* @example
|
|
91
|
-
* const rootDir = await sandbox.
|
|
91
|
+
* const rootDir = await sandbox.getUserRootDir();
|
|
92
92
|
* console.log(`Sandbox root: ${rootDir}`);
|
|
93
93
|
*/
|
|
94
|
-
async
|
|
94
|
+
async getUserRootDir() {
|
|
95
95
|
const response = await this.toolboxApi.getProjectDir(this.instance.id);
|
|
96
96
|
return response.data.dir;
|
|
97
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated Use `getUserRootDir` instead. This method will be removed in a future version.
|
|
100
|
+
*/
|
|
101
|
+
async getWorkspaceRootDir() {
|
|
102
|
+
return this.getUserRootDir();
|
|
103
|
+
}
|
|
98
104
|
/**
|
|
99
105
|
* Creates a new Language Server Protocol (LSP) server instance.
|
|
100
106
|
*
|
|
@@ -106,7 +112,7 @@ class Sandbox {
|
|
|
106
112
|
* @returns {LspServer} A new LSP server instance configured for the specified language
|
|
107
113
|
*
|
|
108
114
|
* @example
|
|
109
|
-
* const lsp = sandbox.createLspServer('typescript', '/
|
|
115
|
+
* const lsp = sandbox.createLspServer('typescript', '/workspace/project');
|
|
110
116
|
*/
|
|
111
117
|
createLspServer(languageId, pathToProject) {
|
|
112
118
|
return new LspServer_1.LspServer(languageId, pathToProject, this.toolboxApi, this.instance);
|