@daytonaio/sdk 0.16.0-alpha.0 → 0.16.0-alpha.3

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/dist/Git.d.ts CHANGED
@@ -18,32 +18,35 @@ export declare class Git {
18
18
  private readonly sandbox;
19
19
  private readonly toolboxApi;
20
20
  private readonly instance;
21
- constructor(sandbox: Sandbox, toolboxApi: ToolboxApi, instance: SandboxInstance);
21
+ private readonly getRootDir;
22
+ constructor(sandbox: Sandbox, toolboxApi: ToolboxApi, instance: SandboxInstance, getRootDir: () => Promise<string>);
22
23
  /**
23
24
  * Stages the specified files for the next commit, similar to
24
25
  * running 'git add' on the command line.
25
26
  *
26
- * @param {string} path - Absolute path to the Git repository root
27
+ * @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
28
+ * root directory.
27
29
  * @param {string[]} files - List of file paths or directories to stage, relative to the repository root
28
30
  * @returns {Promise<void>}
29
31
  *
30
32
  * @example
31
33
  * // Stage a single file
32
- * await git.add('/workspace/repo', ['file.txt']);
34
+ * await git.add('workspace/repo', ['file.txt']);
33
35
  *
34
36
  * @example
35
37
  * // Stage whole repository
36
- * await git.add('/workspace/repo', ['.']);
38
+ * await git.add('workspace/repo', ['.']);
37
39
  */
38
40
  add(path: string, files: string[]): Promise<void>;
39
41
  /**
40
42
  * List branches in the repository.
41
43
  *
42
- * @param {string} path - Absolute path to the Git repository root
44
+ * @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
45
+ * root directory.
43
46
  * @returns {Promise<ListBranchResponse>} List of branches in the repository
44
47
  *
45
48
  * @example
46
- * const response = await git.branches('/workspace/repo');
49
+ * const response = await git.branches('workspace/repo');
47
50
  * console.log(`Branches: ${response.branches}`);
48
51
  */
49
52
  branches(path: string): Promise<ListBranchResponse>;
@@ -53,7 +56,8 @@ export declare class Git {
53
56
  * repository if credentials are provided.
54
57
  *
55
58
  * @param {string} url - Repository URL to clone from
56
- * @param {string} path - Absolute path where the repository should be cloned
59
+ * @param {string} path - Path where the repository should be cloned. Relative paths are resolved based on the user's
60
+ * root directory.
57
61
  * @param {string} [branch] - Specific branch to clone. If not specified, clones the default branch
58
62
  * @param {string} [commitId] - Specific commit to clone. If specified, the repository will be left in a detached HEAD state at this commit
59
63
  * @param {string} [username] - Git username for authentication
@@ -64,14 +68,14 @@ export declare class Git {
64
68
  * // Clone the default branch
65
69
  * await git.clone(
66
70
  * 'https://github.com/user/repo.git',
67
- * '/workspace/repo'
71
+ * 'workspace/repo'
68
72
  * );
69
73
  *
70
74
  * @example
71
75
  * // Clone a specific branch with authentication
72
76
  * await git.clone(
73
77
  * 'https://github.com/user/private-repo.git',
74
- * '/workspace/private',
78
+ * 'workspace/private',
75
79
  * branch='develop',
76
80
  * username='user',
77
81
  * password='token'
@@ -81,7 +85,7 @@ export declare class Git {
81
85
  * // Clone a specific commit
82
86
  * await git.clone(
83
87
  * 'https://github.com/user/repo.git',
84
- * '/workspace/repo-old',
88
+ * 'workspace/repo-old',
85
89
  * commitId='abc123'
86
90
  * );
87
91
  */
@@ -89,7 +93,8 @@ export declare class Git {
89
93
  /**
90
94
  * Commits staged changes.
91
95
  *
92
- * @param {string} path - Absolute path to the Git repository root
96
+ * @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
97
+ * root directory.
93
98
  * @param {string} message - Commit message describing the changes
94
99
  * @param {string} author - Name of the commit author
95
100
  * @param {string} email - Email address of the commit author
@@ -97,9 +102,9 @@ export declare class Git {
97
102
  *
98
103
  * @example
99
104
  * // Stage and commit changes
100
- * await git.add('/workspace/repo', ['README.md']);
105
+ * await git.add('workspace/repo', ['README.md']);
101
106
  * await git.commit(
102
- * '/workspace/repo',
107
+ * 'workspace/repo',
103
108
  * 'Update documentation',
104
109
  * 'John Doe',
105
110
  * 'john@example.com'
@@ -109,19 +114,20 @@ export declare class Git {
109
114
  /**
110
115
  * Push local changes to the remote repository.
111
116
  *
112
- * @param {string} path - Absolute path to the Git repository root
117
+ * @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
118
+ * root directory.
113
119
  * @param {string} [username] - Git username for authentication
114
120
  * @param {string} [password] - Git password or token for authentication
115
121
  * @returns {Promise<void>}
116
122
  *
117
123
  * @example
118
124
  * // Push to a public repository
119
- * await git.push('/workspace/repo');
125
+ * await git.push('workspace/repo');
120
126
  *
121
127
  * @example
122
128
  * // Push to a private repository
123
129
  * await git.push(
124
- * '/workspace/repo',
130
+ * 'workspace/repo',
125
131
  * 'user',
126
132
  * 'token'
127
133
  * );
@@ -130,19 +136,20 @@ export declare class Git {
130
136
  /**
131
137
  * Pulls changes from the remote repository.
132
138
  *
133
- * @param {string} path - Absolute path to the Git repository root
139
+ * @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
140
+ * root directory.
134
141
  * @param {string} [username] - Git username for authentication
135
142
  * @param {string} [password] - Git password or token for authentication
136
143
  * @returns {Promise<void>}
137
144
  *
138
145
  * @example
139
146
  * // Pull from a public repository
140
- * await git.pull('/workspace/repo');
147
+ * await git.pull('workspace/repo');
141
148
  *
142
149
  * @example
143
150
  * // Pull from a private repository
144
151
  * await git.pull(
145
- * '/workspace/repo',
152
+ * 'workspace/repo',
146
153
  * 'user',
147
154
  * 'token'
148
155
  * );
@@ -151,7 +158,8 @@ export declare class Git {
151
158
  /**
152
159
  * Gets the current status of the Git repository.
153
160
  *
154
- * @param {string} path - Absolute path to the Git repository root
161
+ * @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
162
+ * root directory.
155
163
  * @returns {Promise<GitStatus>} Current repository status including:
156
164
  * - currentBranch: Name of the current branch
157
165
  * - ahead: Number of commits ahead of the remote branch
@@ -160,7 +168,7 @@ export declare class Git {
160
168
  * - fileStatus: List of file statuses
161
169
  *
162
170
  * @example
163
- * const status = await sandbox.git.status('/workspace/repo');
171
+ * const status = await sandbox.git.status('workspace/repo');
164
172
  * console.log(`Current branch: ${status.currentBranch}`);
165
173
  * console.log(`Commits ahead: ${status.ahead}`);
166
174
  * console.log(`Commits behind: ${status.behind}`);
package/dist/Git.js CHANGED
@@ -1,51 +1,55 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Git = void 0;
4
+ const Path_1 = require("./utils/Path");
4
5
  /**
5
6
  * Provides Git operations within a Sandbox.
6
7
  *
7
8
  * @class
8
9
  */
9
10
  class Git {
10
- constructor(sandbox, toolboxApi, instance) {
11
+ constructor(sandbox, toolboxApi, instance, getRootDir) {
11
12
  this.sandbox = sandbox;
12
13
  this.toolboxApi = toolboxApi;
13
14
  this.instance = instance;
15
+ this.getRootDir = getRootDir;
14
16
  }
15
17
  /**
16
18
  * Stages the specified files for the next commit, similar to
17
19
  * running 'git add' on the command line.
18
20
  *
19
- * @param {string} path - Absolute path to the Git repository root
21
+ * @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
22
+ * root directory.
20
23
  * @param {string[]} files - List of file paths or directories to stage, relative to the repository root
21
24
  * @returns {Promise<void>}
22
25
  *
23
26
  * @example
24
27
  * // Stage a single file
25
- * await git.add('/workspace/repo', ['file.txt']);
28
+ * await git.add('workspace/repo', ['file.txt']);
26
29
  *
27
30
  * @example
28
31
  * // Stage whole repository
29
- * await git.add('/workspace/repo', ['.']);
32
+ * await git.add('workspace/repo', ['.']);
30
33
  */
31
34
  async add(path, files) {
32
35
  await this.toolboxApi.gitAddFiles(this.instance.id, {
33
- path,
36
+ path: (0, Path_1.prefixRelativePath)(await this.getRootDir(), path),
34
37
  files,
35
38
  });
36
39
  }
37
40
  /**
38
41
  * List branches in the repository.
39
42
  *
40
- * @param {string} path - Absolute path to the Git repository root
43
+ * @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
44
+ * root directory.
41
45
  * @returns {Promise<ListBranchResponse>} List of branches in the repository
42
46
  *
43
47
  * @example
44
- * const response = await git.branches('/workspace/repo');
48
+ * const response = await git.branches('workspace/repo');
45
49
  * console.log(`Branches: ${response.branches}`);
46
50
  */
47
51
  async branches(path) {
48
- const response = await this.toolboxApi.gitListBranches(this.instance.id, path);
52
+ const response = await this.toolboxApi.gitListBranches(this.instance.id, (0, Path_1.prefixRelativePath)(await this.getRootDir(), path));
49
53
  return response.data;
50
54
  }
51
55
  /**
@@ -54,7 +58,8 @@ class Git {
54
58
  * repository if credentials are provided.
55
59
  *
56
60
  * @param {string} url - Repository URL to clone from
57
- * @param {string} path - Absolute path where the repository should be cloned
61
+ * @param {string} path - Path where the repository should be cloned. Relative paths are resolved based on the user's
62
+ * root directory.
58
63
  * @param {string} [branch] - Specific branch to clone. If not specified, clones the default branch
59
64
  * @param {string} [commitId] - Specific commit to clone. If specified, the repository will be left in a detached HEAD state at this commit
60
65
  * @param {string} [username] - Git username for authentication
@@ -65,14 +70,14 @@ class Git {
65
70
  * // Clone the default branch
66
71
  * await git.clone(
67
72
  * 'https://github.com/user/repo.git',
68
- * '/workspace/repo'
73
+ * 'workspace/repo'
69
74
  * );
70
75
  *
71
76
  * @example
72
77
  * // Clone a specific branch with authentication
73
78
  * await git.clone(
74
79
  * 'https://github.com/user/private-repo.git',
75
- * '/workspace/private',
80
+ * 'workspace/private',
76
81
  * branch='develop',
77
82
  * username='user',
78
83
  * password='token'
@@ -82,7 +87,7 @@ class Git {
82
87
  * // Clone a specific commit
83
88
  * await git.clone(
84
89
  * 'https://github.com/user/repo.git',
85
- * '/workspace/repo-old',
90
+ * 'workspace/repo-old',
86
91
  * commitId='abc123'
87
92
  * );
88
93
  */
@@ -90,7 +95,7 @@ class Git {
90
95
  await this.toolboxApi.gitCloneRepository(this.instance.id, {
91
96
  url: url,
92
97
  branch: branch,
93
- path,
98
+ path: (0, Path_1.prefixRelativePath)(await this.getRootDir(), path),
94
99
  username,
95
100
  password,
96
101
  commit_id: commitId,
@@ -99,7 +104,8 @@ class Git {
99
104
  /**
100
105
  * Commits staged changes.
101
106
  *
102
- * @param {string} path - Absolute path to the Git repository root
107
+ * @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
108
+ * root directory.
103
109
  * @param {string} message - Commit message describing the changes
104
110
  * @param {string} author - Name of the commit author
105
111
  * @param {string} email - Email address of the commit author
@@ -107,9 +113,9 @@ class Git {
107
113
  *
108
114
  * @example
109
115
  * // Stage and commit changes
110
- * await git.add('/workspace/repo', ['README.md']);
116
+ * await git.add('workspace/repo', ['README.md']);
111
117
  * await git.commit(
112
- * '/workspace/repo',
118
+ * 'workspace/repo',
113
119
  * 'Update documentation',
114
120
  * 'John Doe',
115
121
  * 'john@example.com'
@@ -117,7 +123,7 @@ class Git {
117
123
  */
118
124
  async commit(path, message, author, email) {
119
125
  const response = await this.toolboxApi.gitCommitChanges(this.instance.id, {
120
- path,
126
+ path: (0, Path_1.prefixRelativePath)(await this.getRootDir(), path),
121
127
  message,
122
128
  author,
123
129
  email,
@@ -129,26 +135,27 @@ class Git {
129
135
  /**
130
136
  * Push local changes to the remote repository.
131
137
  *
132
- * @param {string} path - Absolute path to the Git repository root
138
+ * @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
139
+ * root directory.
133
140
  * @param {string} [username] - Git username for authentication
134
141
  * @param {string} [password] - Git password or token for authentication
135
142
  * @returns {Promise<void>}
136
143
  *
137
144
  * @example
138
145
  * // Push to a public repository
139
- * await git.push('/workspace/repo');
146
+ * await git.push('workspace/repo');
140
147
  *
141
148
  * @example
142
149
  * // Push to a private repository
143
150
  * await git.push(
144
- * '/workspace/repo',
151
+ * 'workspace/repo',
145
152
  * 'user',
146
153
  * 'token'
147
154
  * );
148
155
  */
149
156
  async push(path, username, password) {
150
157
  await this.toolboxApi.gitPushChanges(this.instance.id, {
151
- path,
158
+ path: (0, Path_1.prefixRelativePath)(await this.getRootDir(), path),
152
159
  username,
153
160
  password,
154
161
  });
@@ -156,26 +163,27 @@ class Git {
156
163
  /**
157
164
  * Pulls changes from the remote repository.
158
165
  *
159
- * @param {string} path - Absolute path to the Git repository root
166
+ * @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
167
+ * root directory.
160
168
  * @param {string} [username] - Git username for authentication
161
169
  * @param {string} [password] - Git password or token for authentication
162
170
  * @returns {Promise<void>}
163
171
  *
164
172
  * @example
165
173
  * // Pull from a public repository
166
- * await git.pull('/workspace/repo');
174
+ * await git.pull('workspace/repo');
167
175
  *
168
176
  * @example
169
177
  * // Pull from a private repository
170
178
  * await git.pull(
171
- * '/workspace/repo',
179
+ * 'workspace/repo',
172
180
  * 'user',
173
181
  * 'token'
174
182
  * );
175
183
  */
176
184
  async pull(path, username, password) {
177
185
  await this.toolboxApi.gitPullChanges(this.instance.id, {
178
- path,
186
+ path: (0, Path_1.prefixRelativePath)(await this.getRootDir(), path),
179
187
  username,
180
188
  password,
181
189
  });
@@ -183,7 +191,8 @@ class Git {
183
191
  /**
184
192
  * Gets the current status of the Git repository.
185
193
  *
186
- * @param {string} path - Absolute path to the Git repository root
194
+ * @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
195
+ * root directory.
187
196
  * @returns {Promise<GitStatus>} Current repository status including:
188
197
  * - currentBranch: Name of the current branch
189
198
  * - ahead: Number of commits ahead of the remote branch
@@ -192,13 +201,13 @@ class Git {
192
201
  * - fileStatus: List of file statuses
193
202
  *
194
203
  * @example
195
- * const status = await sandbox.git.status('/workspace/repo');
204
+ * const status = await sandbox.git.status('workspace/repo');
196
205
  * console.log(`Current branch: ${status.currentBranch}`);
197
206
  * console.log(`Commits ahead: ${status.ahead}`);
198
207
  * console.log(`Commits behind: ${status.behind}`);
199
208
  */
200
209
  async status(path) {
201
- const response = await this.toolboxApi.gitGetStatus(this.instance.id, path);
210
+ const response = await this.toolboxApi.gitGetStatus(this.instance.id, (0, Path_1.prefixRelativePath)(await this.getRootDir(), path));
202
211
  return response.data;
203
212
  }
204
213
  }
@@ -52,7 +52,7 @@ export declare class LspServer {
52
52
  * @returns {Promise<void>}
53
53
  *
54
54
  * @example
55
- * const lsp = sandbox.createLspServer('typescript', '/workspace/project');
55
+ * const lsp = sandbox.createLspServer('typescript', 'workspace/project');
56
56
  * await lsp.start(); // Initialize the server
57
57
  * // Now ready for LSP operations
58
58
  */
@@ -73,12 +73,13 @@ export declare class LspServer {
73
73
  * language features like diagnostics and completions for that file. The server
74
74
  * will begin tracking the file's contents and providing language features.
75
75
  *
76
- * @param {string} path - Absolute path to the opened file
76
+ * @param {string} path - Path to the opened file. Relative paths are resolved based on the user's
77
+ * root directory.
77
78
  * @returns {Promise<void>}
78
79
  *
79
80
  * @example
80
81
  * // When opening a file for editing
81
- * await lsp.didOpen('/workspace/project/src/index.ts');
82
+ * await lsp.didOpen('workspace/project/src/index.ts');
82
83
  * // Now can get completions, symbols, etc. for this file
83
84
  */
84
85
  didOpen(path: string): Promise<void>;
@@ -86,18 +87,20 @@ export declare class LspServer {
86
87
  * Notifies the language server that a file has been closed, should be called when a file is closed
87
88
  * in the editor to allow the language server to clean up any resources associated with that file.
88
89
  *
89
- * @param {string} path - Absolute path to the closed file
90
+ * @param {string} path - Path to the closed file. Relative paths are resolved based on the project path
91
+ * set in the LSP server constructor.
90
92
  * @returns {Promise<void>}
91
93
  *
92
94
  * @example
93
95
  * // When done editing a file
94
- * await lsp.didClose('/workspace/project/src/index.ts');
96
+ * await lsp.didClose('workspace/project/src/index.ts');
95
97
  */
96
98
  didClose(path: string): Promise<void>;
97
99
  /**
98
100
  * Get symbol information (functions, classes, variables, etc.) from a document.
99
101
  *
100
- * @param {string} path - Absolute path to the file to get symbols from
102
+ * @param {string} path - Path to the file to get symbols from. Relative paths are resolved based on the project path
103
+ * set in the LSP server constructor.
101
104
  * @returns {Promise<LspSymbol[]>} List of symbols in the document. Each symbol includes:
102
105
  * - name: The symbol's name
103
106
  * - kind: The symbol's kind (function, class, variable, etc.)
@@ -105,7 +108,7 @@ export declare class LspServer {
105
108
  *
106
109
  * @example
107
110
  * // Get all symbols in a file
108
- * const symbols = await lsp.documentSymbols('/workspace/project/src/index.ts');
111
+ * const symbols = await lsp.documentSymbols('workspace/project/src/index.ts');
109
112
  * symbols.forEach(symbol => {
110
113
  * console.log(`${symbol.kind} ${symbol.name}: ${symbol.location}`);
111
114
  * });
@@ -143,7 +146,8 @@ export declare class LspServer {
143
146
  /**
144
147
  * Gets completion suggestions at a position in a file.
145
148
  *
146
- * @param {string} path - Absolute path to the file
149
+ * @param {string} path - Path to the file. Relative paths are resolved based on the project path
150
+ * set in the LSP server constructor.
147
151
  * @param {Position} position - The position in the file where completion was requested
148
152
  * @returns {Promise<CompletionList>} List of completion suggestions. The list includes:
149
153
  * - isIncomplete: Whether more items might be available
@@ -158,7 +162,7 @@ export declare class LspServer {
158
162
  *
159
163
  * @example
160
164
  * // Get completions at a specific position
161
- * const completions = await lsp.completions('/workspace/project/src/index.ts', {
165
+ * const completions = await lsp.completions('workspace/project/src/index.ts', {
162
166
  * line: 10,
163
167
  * character: 15
164
168
  * });
package/dist/LspServer.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LspServer = exports.LspLanguageId = void 0;
4
+ const Path_1 = require("./utils/Path");
4
5
  /**
5
6
  * Supported language server types.
6
7
  */
@@ -38,7 +39,7 @@ class LspServer {
38
39
  * @returns {Promise<void>}
39
40
  *
40
41
  * @example
41
- * const lsp = sandbox.createLspServer('typescript', '/workspace/project');
42
+ * const lsp = sandbox.createLspServer('typescript', 'workspace/project');
42
43
  * await lsp.start(); // Initialize the server
43
44
  * // Now ready for LSP operations
44
45
  */
@@ -69,43 +70,46 @@ class LspServer {
69
70
  * language features like diagnostics and completions for that file. The server
70
71
  * will begin tracking the file's contents and providing language features.
71
72
  *
72
- * @param {string} path - Absolute path to the opened file
73
+ * @param {string} path - Path to the opened file. Relative paths are resolved based on the user's
74
+ * root directory.
73
75
  * @returns {Promise<void>}
74
76
  *
75
77
  * @example
76
78
  * // When opening a file for editing
77
- * await lsp.didOpen('/workspace/project/src/index.ts');
79
+ * await lsp.didOpen('workspace/project/src/index.ts');
78
80
  * // Now can get completions, symbols, etc. for this file
79
81
  */
80
82
  async didOpen(path) {
81
83
  await this.toolboxApi.lspDidOpen(this.instance.id, {
82
84
  languageId: this.languageId,
83
85
  pathToProject: this.pathToProject,
84
- uri: 'file://' + path,
86
+ uri: 'file://' + (0, Path_1.prefixRelativePath)(this.pathToProject, path),
85
87
  });
86
88
  }
87
89
  /**
88
90
  * Notifies the language server that a file has been closed, should be called when a file is closed
89
91
  * in the editor to allow the language server to clean up any resources associated with that file.
90
92
  *
91
- * @param {string} path - Absolute path to the closed file
93
+ * @param {string} path - Path to the closed file. Relative paths are resolved based on the project path
94
+ * set in the LSP server constructor.
92
95
  * @returns {Promise<void>}
93
96
  *
94
97
  * @example
95
98
  * // When done editing a file
96
- * await lsp.didClose('/workspace/project/src/index.ts');
99
+ * await lsp.didClose('workspace/project/src/index.ts');
97
100
  */
98
101
  async didClose(path) {
99
102
  await this.toolboxApi.lspDidClose(this.instance.id, {
100
103
  languageId: this.languageId,
101
104
  pathToProject: this.pathToProject,
102
- uri: 'file://' + path,
105
+ uri: 'file://' + (0, Path_1.prefixRelativePath)(this.pathToProject, path),
103
106
  });
104
107
  }
105
108
  /**
106
109
  * Get symbol information (functions, classes, variables, etc.) from a document.
107
110
  *
108
- * @param {string} path - Absolute path to the file to get symbols from
111
+ * @param {string} path - Path to the file to get symbols from. Relative paths are resolved based on the project path
112
+ * set in the LSP server constructor.
109
113
  * @returns {Promise<LspSymbol[]>} List of symbols in the document. Each symbol includes:
110
114
  * - name: The symbol's name
111
115
  * - kind: The symbol's kind (function, class, variable, etc.)
@@ -113,13 +117,13 @@ class LspServer {
113
117
  *
114
118
  * @example
115
119
  * // Get all symbols in a file
116
- * const symbols = await lsp.documentSymbols('/workspace/project/src/index.ts');
120
+ * const symbols = await lsp.documentSymbols('workspace/project/src/index.ts');
117
121
  * symbols.forEach(symbol => {
118
122
  * console.log(`${symbol.kind} ${symbol.name}: ${symbol.location}`);
119
123
  * });
120
124
  */
121
125
  async documentSymbols(path) {
122
- const response = await this.toolboxApi.lspDocumentSymbols(this.instance.id, this.languageId, this.pathToProject, 'file://' + path);
126
+ const response = await this.toolboxApi.lspDocumentSymbols(this.instance.id, this.languageId, this.pathToProject, 'file://' + (0, Path_1.prefixRelativePath)(this.pathToProject, path));
123
127
  return response.data;
124
128
  }
125
129
  /**
@@ -159,7 +163,8 @@ class LspServer {
159
163
  /**
160
164
  * Gets completion suggestions at a position in a file.
161
165
  *
162
- * @param {string} path - Absolute path to the file
166
+ * @param {string} path - Path to the file. Relative paths are resolved based on the project path
167
+ * set in the LSP server constructor.
163
168
  * @param {Position} position - The position in the file where completion was requested
164
169
  * @returns {Promise<CompletionList>} List of completion suggestions. The list includes:
165
170
  * - isIncomplete: Whether more items might be available
@@ -174,7 +179,7 @@ class LspServer {
174
179
  *
175
180
  * @example
176
181
  * // Get completions at a specific position
177
- * const completions = await lsp.completions('/workspace/project/src/index.ts', {
182
+ * const completions = await lsp.completions('workspace/project/src/index.ts', {
178
183
  * line: 10,
179
184
  * character: 15
180
185
  * });
@@ -186,7 +191,7 @@ class LspServer {
186
191
  const response = await this.toolboxApi.lspCompletions(this.instance.id, {
187
192
  languageId: this.languageId,
188
193
  pathToProject: this.pathToProject,
189
- uri: 'file://' + path,
194
+ uri: 'file://' + (0, Path_1.prefixRelativePath)(this.pathToProject, path),
190
195
  position,
191
196
  });
192
197
  return response.data;
package/dist/Process.d.ts CHANGED
@@ -23,12 +23,14 @@ export declare class Process {
23
23
  private readonly codeToolbox;
24
24
  private readonly toolboxApi;
25
25
  private readonly instance;
26
- constructor(codeToolbox: SandboxCodeToolbox, toolboxApi: ToolboxApi, instance: SandboxInstance);
26
+ private readonly getRootDir;
27
+ constructor(codeToolbox: SandboxCodeToolbox, toolboxApi: ToolboxApi, instance: SandboxInstance, getRootDir: () => Promise<string>);
27
28
  /**
28
29
  * Executes a shell command in the Sandbox.
29
30
  *
30
31
  * @param {string} command - Shell command to execute
31
- * @param {string} [cwd] - Working directory for command execution. If not specified, uses the Sandbox root directory
32
+ * @param {string} [cwd] - Working directory for command execution. If not specified, uses the Sandbox root directory.
33
+ * Default is the user's root directory.
32
34
  * @param {Record<string, string>} [env] - Environment variables to set for the command
33
35
  * @param {number} [timeout] - Maximum time in seconds to wait for the command to complete. 0 means wait indefinitely.
34
36
  * @returns {Promise<ExecuteResponse>} Command execution results containing:
@@ -43,7 +45,7 @@ export declare class Process {
43
45
  *
44
46
  * @example
45
47
  * // Command with working directory
46
- * const result = await process.executeCommand('ls', '/workspace/src');
48
+ * const result = await process.executeCommand('ls', 'workspace/src');
47
49
  *
48
50
  * @example
49
51
  * // Command with timeout
@@ -166,7 +168,7 @@ export declare class Process {
166
168
  * @param {string} sessionId - Unique identifier of the session to use
167
169
  * @param {SessionExecuteRequest} req - Command execution request containing:
168
170
  * - command: The command to execute
169
- * - async: Whether to execute asynchronously
171
+ * - runAsync: Whether to execute asynchronously
170
172
  * @param {number} timeout - Timeout in seconds
171
173
  * @returns {Promise<SessionExecuteResponse>} Command execution results containing:
172
174
  * - cmdId: Unique identifier for the executed command
@@ -179,14 +181,14 @@ export declare class Process {
179
181
  *
180
182
  * // Change directory
181
183
  * await process.executeSessionCommand(sessionId, {
182
- * command: 'cd /workspace'
184
+ * command: 'cd /home/daytona'
183
185
  * });
184
186
  *
185
187
  * // Run command in new directory
186
188
  * const result = await process.executeSessionCommand(sessionId, {
187
189
  * command: 'pwd'
188
190
  * });
189
- * console.log(result.output); // Prints: /workspace
191
+ * console.log(result.output); // Prints: /home/daytona
190
192
  */
191
193
  executeSessionCommand(sessionId: string, req: SessionExecuteRequest, timeout?: number): Promise<SessionExecuteResponse>;
192
194
  /**