@daytonaio/sdk 0.9.2 → 0.10.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/dist/Daytona.d.ts +239 -47
- package/dist/Daytona.js +274 -63
- package/dist/FileSystem.d.ts +183 -32
- package/dist/FileSystem.js +168 -28
- package/dist/Git.d.ts +178 -30
- package/dist/Git.js +178 -30
- package/dist/LspServer.d.ts +170 -22
- package/dist/LspServer.js +162 -18
- package/dist/Process.d.ts +187 -37
- package/dist/Process.js +185 -44
- package/dist/Workspace.d.ts +252 -36
- package/dist/Workspace.js +239 -49
- package/dist/code-toolbox/WorkspacePythonCodeToolbox.d.ts +2 -1
- package/dist/code-toolbox/WorkspacePythonCodeToolbox.js +4 -2
- package/dist/code-toolbox/WorkspaceTsCodeToolbox.d.ts +2 -1
- package/dist/code-toolbox/WorkspaceTsCodeToolbox.js +4 -2
- package/dist/errors/DaytonaError.d.ts +8 -0
- package/dist/errors/DaytonaError.js +12 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -1
- package/dist/utils/Axios.d.ts +6 -0
- package/dist/utils/Axios.js +28 -0
- package/dist/utils/errors.d.ts +10 -0
- package/dist/utils/errors.js +36 -0
- package/dist/utils/timeout.d.ts +35 -0
- package/dist/utils/timeout.js +73 -0
- package/package.json +9 -8
- package/dist/client/apis/ApiKeyApi.d.ts +0 -54
- package/dist/client/apis/ApiKeyApi.js +0 -135
- package/dist/client/apis/BuildApi.d.ts +0 -95
- package/dist/client/apis/BuildApi.js +0 -228
- package/dist/client/apis/ContainerRegistryApi.d.ts +0 -68
- package/dist/client/apis/ContainerRegistryApi.js +0 -163
- package/dist/client/apis/DefaultApi.d.ts +0 -31
- package/dist/client/apis/DefaultApi.js +0 -72
- package/dist/client/apis/GitProviderApi.d.ts +0 -197
- package/dist/client/apis/GitProviderApi.js +0 -477
- package/dist/client/apis/PrebuildApi.d.ts +0 -97
- package/dist/client/apis/PrebuildApi.js +0 -241
- package/dist/client/apis/ProfileApi.d.ts +0 -51
- package/dist/client/apis/ProfileApi.js +0 -128
- package/dist/client/apis/ProjectConfigApi.d.ts +0 -94
- package/dist/client/apis/ProjectConfigApi.js +0 -220
- package/dist/client/apis/ProviderApi.d.ts +0 -71
- package/dist/client/apis/ProviderApi.js +0 -160
- package/dist/client/apis/SampleApi.d.ts +0 -28
- package/dist/client/apis/SampleApi.js +0 -73
- package/dist/client/apis/ServerApi.d.ts +0 -61
- package/dist/client/apis/ServerApi.js +0 -156
- package/dist/client/apis/TargetApi.d.ts +0 -67
- package/dist/client/apis/TargetApi.js +0 -159
- package/dist/client/apis/WorkspaceApi.d.ts +0 -141
- package/dist/client/apis/WorkspaceApi.js +0 -330
- package/dist/client/apis/WorkspaceToolboxApi.d.ts +0 -464
- package/dist/client/apis/WorkspaceToolboxApi.js +0 -1248
- package/dist/client/apis/index.d.ts +0 -14
- package/dist/client/apis/index.js +0 -32
- package/dist/client/index.d.ts +0 -3
- package/dist/client/index.js +0 -21
- package/dist/client/models/ApiKey.d.ts +0 -45
- package/dist/client/models/ApiKey.js +0 -60
- package/dist/client/models/ApikeyApiKeyType.d.ts +0 -26
- package/dist/client/models/ApikeyApiKeyType.js +0 -52
- package/dist/client/models/Build.d.ts +0 -98
- package/dist/client/models/Build.js +0 -91
- package/dist/client/models/BuildBuildState.d.ts +0 -31
- package/dist/client/models/BuildBuildState.js +0 -57
- package/dist/client/models/BuildConfig.d.ts +0 -40
- package/dist/client/models/BuildConfig.js +0 -57
- package/dist/client/models/CachedBuild.d.ts +0 -38
- package/dist/client/models/CachedBuild.js +0 -55
- package/dist/client/models/CloneTarget.d.ts +0 -25
- package/dist/client/models/CloneTarget.js +0 -51
- package/dist/client/models/CompletionContext.d.ts +0 -38
- package/dist/client/models/CompletionContext.js +0 -53
- package/dist/client/models/CompletionItem.d.ts +0 -68
- package/dist/client/models/CompletionItem.js +0 -63
- package/dist/client/models/CompletionList.d.ts +0 -39
- package/dist/client/models/CompletionList.js +0 -56
- package/dist/client/models/ContainerConfig.d.ts +0 -38
- package/dist/client/models/ContainerConfig.js +0 -55
- package/dist/client/models/ContainerRegistry.d.ts +0 -44
- package/dist/client/models/ContainerRegistry.js +0 -59
- package/dist/client/models/CreateBuildDTO.d.ts +0 -52
- package/dist/client/models/CreateBuildDTO.js +0 -62
- package/dist/client/models/CreatePrebuildDTO.d.ts +0 -56
- package/dist/client/models/CreatePrebuildDTO.js +0 -59
- package/dist/client/models/CreateProjectConfigDTO.d.ts +0 -71
- package/dist/client/models/CreateProjectConfigDTO.js +0 -72
- package/dist/client/models/CreateProjectDTO.d.ts +0 -72
- package/dist/client/models/CreateProjectDTO.js +0 -73
- package/dist/client/models/CreateProjectSourceDTO.d.ts +0 -33
- package/dist/client/models/CreateProjectSourceDTO.js +0 -52
- package/dist/client/models/CreateProviderTargetDTO.d.ts +0 -45
- package/dist/client/models/CreateProviderTargetDTO.js +0 -60
- package/dist/client/models/CreateWorkspaceDTO.d.ts +0 -51
- package/dist/client/models/CreateWorkspaceDTO.js +0 -64
- package/dist/client/models/DevcontainerConfig.d.ts +0 -32
- package/dist/client/models/DevcontainerConfig.js +0 -51
- package/dist/client/models/ExecuteRequest.d.ts +0 -38
- package/dist/client/models/ExecuteRequest.js +0 -53
- package/dist/client/models/ExecuteResponse.d.ts +0 -38
- package/dist/client/models/ExecuteResponse.js +0 -55
- package/dist/client/models/FRPSConfig.d.ts +0 -44
- package/dist/client/models/FRPSConfig.js +0 -59
- package/dist/client/models/FileInfo.d.ts +0 -74
- package/dist/client/models/FileInfo.js +0 -79
- package/dist/client/models/FileStatus.d.ts +0 -51
- package/dist/client/models/FileStatus.js +0 -64
- package/dist/client/models/GetRepositoryContext.d.ts +0 -80
- package/dist/client/models/GetRepositoryContext.js +0 -67
- package/dist/client/models/GitAddRequest.d.ts +0 -38
- package/dist/client/models/GitAddRequest.js +0 -55
- package/dist/client/models/GitBranch.d.ts +0 -38
- package/dist/client/models/GitBranch.js +0 -55
- package/dist/client/models/GitBranchRequest.d.ts +0 -38
- package/dist/client/models/GitBranchRequest.js +0 -55
- package/dist/client/models/GitCloneRequest.d.ts +0 -62
- package/dist/client/models/GitCloneRequest.js +0 -63
- package/dist/client/models/GitCommitInfo.d.ts +0 -56
- package/dist/client/models/GitCommitInfo.js +0 -67
- package/dist/client/models/GitCommitRequest.d.ts +0 -50
- package/dist/client/models/GitCommitRequest.js +0 -63
- package/dist/client/models/GitCommitResponse.d.ts +0 -32
- package/dist/client/models/GitCommitResponse.js +0 -51
- package/dist/client/models/GitNamespace.d.ts +0 -38
- package/dist/client/models/GitNamespace.js +0 -55
- package/dist/client/models/GitProvider.d.ts +0 -75
- package/dist/client/models/GitProvider.js +0 -76
- package/dist/client/models/GitPullRequest.d.ts +0 -68
- package/dist/client/models/GitPullRequest.js +0 -75
- package/dist/client/models/GitRepoRequest.d.ts +0 -44
- package/dist/client/models/GitRepoRequest.js +0 -55
- package/dist/client/models/GitRepository.d.ts +0 -87
- package/dist/client/models/GitRepository.js +0 -84
- package/dist/client/models/GitStatus.d.ts +0 -57
- package/dist/client/models/GitStatus.js +0 -62
- package/dist/client/models/GitUser.d.ts +0 -50
- package/dist/client/models/GitUser.js +0 -63
- package/dist/client/models/InstallProviderRequest.d.ts +0 -40
- package/dist/client/models/InstallProviderRequest.js +0 -55
- package/dist/client/models/ListBranchResponse.d.ts +0 -32
- package/dist/client/models/ListBranchResponse.js +0 -51
- package/dist/client/models/LogFileConfig.d.ts +0 -62
- package/dist/client/models/LogFileConfig.js +0 -67
- package/dist/client/models/LspCompletionParams.d.ts +0 -58
- package/dist/client/models/LspCompletionParams.js +0 -69
- package/dist/client/models/LspDocumentRequest.d.ts +0 -44
- package/dist/client/models/LspDocumentRequest.js +0 -59
- package/dist/client/models/LspLocation.d.ts +0 -39
- package/dist/client/models/LspLocation.js +0 -56
- package/dist/client/models/LspPosition.d.ts +0 -38
- package/dist/client/models/LspPosition.js +0 -55
- package/dist/client/models/LspRange.d.ts +0 -39
- package/dist/client/models/LspRange.js +0 -56
- package/dist/client/models/LspServerRequest.d.ts +0 -38
- package/dist/client/models/LspServerRequest.js +0 -55
- package/dist/client/models/LspSymbol.d.ts +0 -45
- package/dist/client/models/LspSymbol.js +0 -60
- package/dist/client/models/Match.d.ts +0 -44
- package/dist/client/models/Match.js +0 -59
- package/dist/client/models/NetworkKey.d.ts +0 -32
- package/dist/client/models/NetworkKey.js +0 -51
- package/dist/client/models/Position.d.ts +0 -38
- package/dist/client/models/Position.js +0 -55
- package/dist/client/models/PrebuildConfig.d.ts +0 -56
- package/dist/client/models/PrebuildConfig.js +0 -67
- package/dist/client/models/PrebuildDTO.d.ts +0 -62
- package/dist/client/models/PrebuildDTO.js +0 -68
- package/dist/client/models/ProfileData.d.ts +0 -34
- package/dist/client/models/ProfileData.js +0 -51
- package/dist/client/models/Project.d.ts +0 -91
- package/dist/client/models/Project.js +0 -88
- package/dist/client/models/ProjectConfig.d.ts +0 -84
- package/dist/client/models/ProjectConfig.js +0 -87
- package/dist/client/models/ProjectDirResponse.d.ts +0 -32
- package/dist/client/models/ProjectDirResponse.js +0 -49
- package/dist/client/models/ProjectInfo.d.ts +0 -56
- package/dist/client/models/ProjectInfo.js +0 -65
- package/dist/client/models/ProjectState.d.ts +0 -45
- package/dist/client/models/ProjectState.js +0 -60
- package/dist/client/models/Provider.d.ts +0 -44
- package/dist/client/models/Provider.js +0 -57
- package/dist/client/models/ProviderProviderInfo.d.ts +0 -44
- package/dist/client/models/ProviderProviderInfo.js +0 -57
- package/dist/client/models/ProviderProviderTargetProperty.d.ts +0 -72
- package/dist/client/models/ProviderProviderTargetProperty.js +0 -64
- package/dist/client/models/ProviderProviderTargetPropertyType.d.ts +0 -29
- package/dist/client/models/ProviderProviderTargetPropertyType.js +0 -55
- package/dist/client/models/ProviderTarget.d.ts +0 -51
- package/dist/client/models/ProviderTarget.js +0 -64
- package/dist/client/models/ReplaceRequest.d.ts +0 -44
- package/dist/client/models/ReplaceRequest.js +0 -59
- package/dist/client/models/ReplaceResult.d.ts +0 -44
- package/dist/client/models/ReplaceResult.js +0 -53
- package/dist/client/models/RepositoryUrl.d.ts +0 -32
- package/dist/client/models/RepositoryUrl.js +0 -51
- package/dist/client/models/Sample.d.ts +0 -44
- package/dist/client/models/Sample.js +0 -59
- package/dist/client/models/SearchFilesResponse.d.ts +0 -32
- package/dist/client/models/SearchFilesResponse.js +0 -51
- package/dist/client/models/ServerConfig.d.ts +0 -130
- package/dist/client/models/ServerConfig.js +0 -119
- package/dist/client/models/SetGitProviderConfig.d.ts +0 -75
- package/dist/client/models/SetGitProviderConfig.js +0 -70
- package/dist/client/models/SetProjectState.d.ts +0 -39
- package/dist/client/models/SetProjectState.js +0 -56
- package/dist/client/models/SigningMethod.d.ts +0 -25
- package/dist/client/models/SigningMethod.js +0 -51
- package/dist/client/models/Status.d.ts +0 -31
- package/dist/client/models/Status.js +0 -57
- package/dist/client/models/Workspace.d.ts +0 -51
- package/dist/client/models/Workspace.js +0 -64
- package/dist/client/models/WorkspaceDTO.d.ts +0 -58
- package/dist/client/models/WorkspaceDTO.js +0 -67
- package/dist/client/models/WorkspaceInfo.d.ts +0 -45
- package/dist/client/models/WorkspaceInfo.js +0 -58
- package/dist/client/models/index.d.ts +0 -79
- package/dist/client/models/index.js +0 -97
- package/dist/client/runtime.d.ts +0 -182
- package/dist/client/runtime.js +0 -340
package/dist/LspServer.d.ts
CHANGED
|
@@ -1,12 +1,67 @@
|
|
|
1
|
-
import { CompletionList, LspSymbol, Workspace as WorkspaceInstance, ToolboxApi } from '@daytonaio/api-client';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The Daytona SDK provides Language Server Protocol (LSP) support through Sandbox instances.
|
|
3
|
+
* This enables advanced language features like code completion, diagnostics, and more.
|
|
4
|
+
*
|
|
5
|
+
* The LSP server must be started with start() before using any other methods,
|
|
6
|
+
* and should be stopped with stop() when no longer needed to free resources.
|
|
7
|
+
*
|
|
8
|
+
* @module LspServer
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Basic LSP server usage
|
|
12
|
+
* // Create and initialize workspace
|
|
13
|
+
* const workspace = await daytona.create();
|
|
14
|
+
*
|
|
15
|
+
* // Create and start LSP server
|
|
16
|
+
* const lsp = workspace.createLspServer('typescript', '/workspace/project');
|
|
17
|
+
* await lsp.start();
|
|
18
|
+
*
|
|
19
|
+
* // Open a file for editing
|
|
20
|
+
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
21
|
+
*
|
|
22
|
+
* // Get completions at a position
|
|
23
|
+
* const completions = await lsp.completions(
|
|
24
|
+
* '/workspace/project/src/index.ts',
|
|
25
|
+
* { line: 10, character: 15 }
|
|
26
|
+
* );
|
|
27
|
+
* console.log('Completions:', completions);
|
|
28
|
+
*
|
|
29
|
+
* // Get document symbols
|
|
30
|
+
* const symbols = await lsp.documentSymbols('/workspace/project/src/index.ts');
|
|
31
|
+
* symbols.forEach(symbol => {
|
|
32
|
+
* console.log(`${symbol.name}: ${symbol.kind}`);
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // Clean up
|
|
36
|
+
* await lsp.didClose('/workspace/project/src/index.ts');
|
|
37
|
+
* await lsp.stop();
|
|
38
|
+
*
|
|
5
39
|
*/
|
|
6
|
-
|
|
40
|
+
import { CompletionList, LspSymbol, ToolboxApi } from '@daytonaio/api-client';
|
|
41
|
+
import { WorkspaceInstance } from './Workspace';
|
|
7
42
|
/**
|
|
8
|
-
*
|
|
43
|
+
* Supported language server types.
|
|
44
|
+
*/
|
|
45
|
+
export declare enum LspLanguageId {
|
|
46
|
+
PYTHON = "python",
|
|
47
|
+
TYPESCRIPT = "typescript",
|
|
48
|
+
JAVASCRIPT = "javascript"
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Represents a position in a text document.
|
|
52
|
+
*
|
|
53
|
+
* This interface represents a zero-based position within a text document,
|
|
54
|
+
* specified by line number and character offset.
|
|
55
|
+
*
|
|
9
56
|
* @interface Position
|
|
57
|
+
* @property {number} line - Zero-based line number in the document
|
|
58
|
+
* @property {number} character - Zero-based character offset on the line
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* const position: Position = {
|
|
62
|
+
* line: 10, // Line 11 (zero-based)
|
|
63
|
+
* character: 15 // Character 16 on the line (zero-based)
|
|
64
|
+
* };
|
|
10
65
|
*/
|
|
11
66
|
export type Position = {
|
|
12
67
|
/** Zero-based line number */
|
|
@@ -15,8 +70,17 @@ export type Position = {
|
|
|
15
70
|
character: number;
|
|
16
71
|
};
|
|
17
72
|
/**
|
|
18
|
-
* Provides Language Server Protocol
|
|
73
|
+
* Provides Language Server Protocol functionality for code intelligence.
|
|
74
|
+
*
|
|
75
|
+
* This class implements a subset of the Language Server Protocol (LSP) to provide
|
|
76
|
+
* IDE-like features such as code completion, symbol search, and more.
|
|
77
|
+
*
|
|
19
78
|
* @class LspServer
|
|
79
|
+
*
|
|
80
|
+
* @property {LspLanguageId} languageId - The language server type (e.g., "typescript")
|
|
81
|
+
* @property {string} pathToProject - Absolute path to the project root directory
|
|
82
|
+
* @property {ToolboxApi} toolboxApi - API client for Sandbox operations
|
|
83
|
+
* @property {WorkspaceInstance} instance - The Sandbox instance this server belongs to
|
|
20
84
|
*/
|
|
21
85
|
export declare class LspServer {
|
|
22
86
|
private readonly languageId;
|
|
@@ -25,44 +89,128 @@ export declare class LspServer {
|
|
|
25
89
|
private readonly instance;
|
|
26
90
|
constructor(languageId: LspLanguageId, pathToProject: string, toolboxApi: ToolboxApi, instance: WorkspaceInstance);
|
|
27
91
|
/**
|
|
28
|
-
* Starts the language server
|
|
92
|
+
* Starts the language server.
|
|
93
|
+
*
|
|
94
|
+
* This method must be called before using any other LSP functionality.
|
|
95
|
+
* It initializes the language server for the specified language and project.
|
|
96
|
+
*
|
|
29
97
|
* @returns {Promise<void>}
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* const lsp = workspace.createLspServer('typescript', '/workspace/project');
|
|
101
|
+
* await lsp.start(); // Initialize the server
|
|
102
|
+
* // Now ready for LSP operations
|
|
30
103
|
*/
|
|
31
104
|
start(): Promise<void>;
|
|
32
105
|
/**
|
|
33
|
-
* Stops the language server
|
|
106
|
+
* Stops the language server.
|
|
107
|
+
*
|
|
108
|
+
* This method should be called when the LSP server is no longer needed to
|
|
109
|
+
* free up system resources.
|
|
110
|
+
*
|
|
34
111
|
* @returns {Promise<void>}
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* // When done with LSP features
|
|
115
|
+
* await lsp.stop(); // Clean up resources
|
|
35
116
|
*/
|
|
36
117
|
stop(): Promise<void>;
|
|
37
118
|
/**
|
|
38
|
-
* Notifies the server that a file has been opened
|
|
39
|
-
*
|
|
119
|
+
* Notifies the language server that a file has been opened.
|
|
120
|
+
*
|
|
121
|
+
* This method should be called when a file is opened in the editor to enable
|
|
122
|
+
* language features like diagnostics and completions for that file. The server
|
|
123
|
+
* will begin tracking the file's contents and providing language features.
|
|
124
|
+
*
|
|
125
|
+
* @param {string} path - Absolute path to the opened file
|
|
40
126
|
* @returns {Promise<void>}
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* // When opening a file for editing
|
|
130
|
+
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
131
|
+
* // Now can get completions, symbols, etc. for this file
|
|
41
132
|
*/
|
|
42
133
|
didOpen(path: string): Promise<void>;
|
|
43
134
|
/**
|
|
44
|
-
* Notifies the server that a file has been closed
|
|
45
|
-
*
|
|
135
|
+
* Notifies the language server that a file has been closed.
|
|
136
|
+
*
|
|
137
|
+
* This method should be called when a file is closed in the editor to allow
|
|
138
|
+
* the language server to clean up any resources associated with that file.
|
|
139
|
+
*
|
|
140
|
+
* @param {string} path - Absolute path to the closed file
|
|
46
141
|
* @returns {Promise<void>}
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* // When done editing a file
|
|
145
|
+
* await lsp.didClose('/workspace/project/src/index.ts');
|
|
47
146
|
*/
|
|
48
147
|
didClose(path: string): Promise<void>;
|
|
49
148
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
149
|
+
* Get symbol information from a document.
|
|
150
|
+
*
|
|
151
|
+
* This method returns information about all symbols (functions, classes,
|
|
152
|
+
* variables, etc.) defined in the specified document.
|
|
153
|
+
*
|
|
154
|
+
* @param {string} path - Absolute path to the file to get symbols from
|
|
155
|
+
* @returns {Promise<LspSymbol[]>} List of symbols in the document. Each symbol includes:
|
|
156
|
+
* - name: The symbol's name
|
|
157
|
+
* - kind: The symbol's kind (function, class, variable, etc.)
|
|
158
|
+
* - location: The location of the symbol in the file
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* // Get all symbols in a file
|
|
162
|
+
* const symbols = await lsp.documentSymbols('/workspace/project/src/index.ts');
|
|
163
|
+
* symbols.forEach(symbol => {
|
|
164
|
+
* console.log(`${symbol.kind} ${symbol.name}: ${symbol.location}`);
|
|
165
|
+
* });
|
|
53
166
|
*/
|
|
54
167
|
documentSymbols(path: string): Promise<LspSymbol[]>;
|
|
55
168
|
/**
|
|
56
|
-
* Searches for symbols across the
|
|
57
|
-
*
|
|
58
|
-
*
|
|
169
|
+
* Searches for symbols across the entire Sandbox.
|
|
170
|
+
*
|
|
171
|
+
* This method searches for symbols matching the query string across all files
|
|
172
|
+
* in the Sandbox. It's useful for finding declarations and definitions
|
|
173
|
+
* without knowing which file they're in.
|
|
174
|
+
*
|
|
175
|
+
* @param {string} query - Search query to match against symbol names
|
|
176
|
+
* @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
|
|
177
|
+
* - name: The symbol's name
|
|
178
|
+
* - kind: The symbol's kind (function, class, variable, etc.)
|
|
179
|
+
* - location: The location of the symbol in the file
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* // Search for all symbols containing "User"
|
|
183
|
+
* const symbols = await lsp.workspaceSymbols('User');
|
|
184
|
+
* symbols.forEach(symbol => {
|
|
185
|
+
* console.log(`${symbol.name} (${symbol.kind}) in ${symbol.location}`);
|
|
186
|
+
* });
|
|
59
187
|
*/
|
|
60
188
|
workspaceSymbols(query: string): Promise<LspSymbol[]>;
|
|
61
189
|
/**
|
|
62
|
-
* Gets
|
|
63
|
-
*
|
|
64
|
-
* @param {
|
|
65
|
-
* @
|
|
190
|
+
* Gets completion suggestions at a position in a file.
|
|
191
|
+
*
|
|
192
|
+
* @param {string} path - Absolute path to the file
|
|
193
|
+
* @param {Position} position - The position in the file where completion was requested
|
|
194
|
+
* @returns {Promise<CompletionList>} List of completion suggestions. The list includes:
|
|
195
|
+
* - isIncomplete: Whether more items might be available
|
|
196
|
+
* - items: List of completion items, each containing:
|
|
197
|
+
* - label: The text to insert
|
|
198
|
+
* - kind: The kind of completion
|
|
199
|
+
* - detail: Additional details about the item
|
|
200
|
+
* - documentation: Documentation for the item
|
|
201
|
+
* - sortText: Text used to sort the item in the list
|
|
202
|
+
* - filterText: Text used to filter the item
|
|
203
|
+
* - insertText: The actual text to insert (if different from label)
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* // Get completions at a specific position
|
|
207
|
+
* const completions = await lsp.completions('/workspace/project/src/index.ts', {
|
|
208
|
+
* line: 10,
|
|
209
|
+
* character: 15
|
|
210
|
+
* });
|
|
211
|
+
* completions.items.forEach(item => {
|
|
212
|
+
* console.log(`${item.label} (${item.kind}): ${item.detail}`);
|
|
213
|
+
* });
|
|
66
214
|
*/
|
|
67
215
|
completions(path: string, position: Position): Promise<CompletionList>;
|
|
68
216
|
}
|
package/dist/LspServer.js
CHANGED
|
@@ -1,9 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The Daytona SDK provides Language Server Protocol (LSP) support through Sandbox instances.
|
|
4
|
+
* This enables advanced language features like code completion, diagnostics, and more.
|
|
5
|
+
*
|
|
6
|
+
* The LSP server must be started with start() before using any other methods,
|
|
7
|
+
* and should be stopped with stop() when no longer needed to free resources.
|
|
8
|
+
*
|
|
9
|
+
* @module LspServer
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Basic LSP server usage
|
|
13
|
+
* // Create and initialize workspace
|
|
14
|
+
* const workspace = await daytona.create();
|
|
15
|
+
*
|
|
16
|
+
* // Create and start LSP server
|
|
17
|
+
* const lsp = workspace.createLspServer('typescript', '/workspace/project');
|
|
18
|
+
* await lsp.start();
|
|
19
|
+
*
|
|
20
|
+
* // Open a file for editing
|
|
21
|
+
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
22
|
+
*
|
|
23
|
+
* // Get completions at a position
|
|
24
|
+
* const completions = await lsp.completions(
|
|
25
|
+
* '/workspace/project/src/index.ts',
|
|
26
|
+
* { line: 10, character: 15 }
|
|
27
|
+
* );
|
|
28
|
+
* console.log('Completions:', completions);
|
|
29
|
+
*
|
|
30
|
+
* // Get document symbols
|
|
31
|
+
* const symbols = await lsp.documentSymbols('/workspace/project/src/index.ts');
|
|
32
|
+
* symbols.forEach(symbol => {
|
|
33
|
+
* console.log(`${symbol.name}: ${symbol.kind}`);
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* // Clean up
|
|
37
|
+
* await lsp.didClose('/workspace/project/src/index.ts');
|
|
38
|
+
* await lsp.stop();
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
2
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LspServer = void 0;
|
|
42
|
+
exports.LspServer = exports.LspLanguageId = void 0;
|
|
43
|
+
/**
|
|
44
|
+
* Supported language server types.
|
|
45
|
+
*/
|
|
46
|
+
var LspLanguageId;
|
|
47
|
+
(function (LspLanguageId) {
|
|
48
|
+
LspLanguageId["PYTHON"] = "python";
|
|
49
|
+
LspLanguageId["TYPESCRIPT"] = "typescript";
|
|
50
|
+
LspLanguageId["JAVASCRIPT"] = "javascript";
|
|
51
|
+
})(LspLanguageId || (exports.LspLanguageId = LspLanguageId = {}));
|
|
4
52
|
/**
|
|
5
|
-
* Provides Language Server Protocol
|
|
53
|
+
* Provides Language Server Protocol functionality for code intelligence.
|
|
54
|
+
*
|
|
55
|
+
* This class implements a subset of the Language Server Protocol (LSP) to provide
|
|
56
|
+
* IDE-like features such as code completion, symbol search, and more.
|
|
57
|
+
*
|
|
6
58
|
* @class LspServer
|
|
59
|
+
*
|
|
60
|
+
* @property {LspLanguageId} languageId - The language server type (e.g., "typescript")
|
|
61
|
+
* @property {string} pathToProject - Absolute path to the project root directory
|
|
62
|
+
* @property {ToolboxApi} toolboxApi - API client for Sandbox operations
|
|
63
|
+
* @property {WorkspaceInstance} instance - The Sandbox instance this server belongs to
|
|
7
64
|
*/
|
|
8
65
|
class LspServer {
|
|
9
66
|
constructor(languageId, pathToProject, toolboxApi, instance) {
|
|
@@ -11,10 +68,22 @@ class LspServer {
|
|
|
11
68
|
this.pathToProject = pathToProject;
|
|
12
69
|
this.toolboxApi = toolboxApi;
|
|
13
70
|
this.instance = instance;
|
|
71
|
+
if (!Object.values(LspLanguageId).includes(this.languageId)) {
|
|
72
|
+
throw new Error(`Invalid languageId: ${this.languageId}. Supported values are: ${Object.values(LspLanguageId).join(', ')}`);
|
|
73
|
+
}
|
|
14
74
|
}
|
|
15
75
|
/**
|
|
16
|
-
* Starts the language server
|
|
76
|
+
* Starts the language server.
|
|
77
|
+
*
|
|
78
|
+
* This method must be called before using any other LSP functionality.
|
|
79
|
+
* It initializes the language server for the specified language and project.
|
|
80
|
+
*
|
|
17
81
|
* @returns {Promise<void>}
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* const lsp = workspace.createLspServer('typescript', '/workspace/project');
|
|
85
|
+
* await lsp.start(); // Initialize the server
|
|
86
|
+
* // Now ready for LSP operations
|
|
18
87
|
*/
|
|
19
88
|
async start() {
|
|
20
89
|
await this.toolboxApi.lspStart(this.instance.id, {
|
|
@@ -23,8 +92,16 @@ class LspServer {
|
|
|
23
92
|
});
|
|
24
93
|
}
|
|
25
94
|
/**
|
|
26
|
-
* Stops the language server
|
|
95
|
+
* Stops the language server.
|
|
96
|
+
*
|
|
97
|
+
* This method should be called when the LSP server is no longer needed to
|
|
98
|
+
* free up system resources.
|
|
99
|
+
*
|
|
27
100
|
* @returns {Promise<void>}
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* // When done with LSP features
|
|
104
|
+
* await lsp.stop(); // Clean up resources
|
|
28
105
|
*/
|
|
29
106
|
async stop() {
|
|
30
107
|
await this.toolboxApi.lspStop(this.instance.id, {
|
|
@@ -33,9 +110,19 @@ class LspServer {
|
|
|
33
110
|
});
|
|
34
111
|
}
|
|
35
112
|
/**
|
|
36
|
-
* Notifies the server that a file has been opened
|
|
37
|
-
*
|
|
113
|
+
* Notifies the language server that a file has been opened.
|
|
114
|
+
*
|
|
115
|
+
* This method should be called when a file is opened in the editor to enable
|
|
116
|
+
* language features like diagnostics and completions for that file. The server
|
|
117
|
+
* will begin tracking the file's contents and providing language features.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} path - Absolute path to the opened file
|
|
38
120
|
* @returns {Promise<void>}
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* // When opening a file for editing
|
|
124
|
+
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
125
|
+
* // Now can get completions, symbols, etc. for this file
|
|
39
126
|
*/
|
|
40
127
|
async didOpen(path) {
|
|
41
128
|
await this.toolboxApi.lspDidOpen(this.instance.id, {
|
|
@@ -45,9 +132,17 @@ class LspServer {
|
|
|
45
132
|
});
|
|
46
133
|
}
|
|
47
134
|
/**
|
|
48
|
-
* Notifies the server that a file has been closed
|
|
49
|
-
*
|
|
135
|
+
* Notifies the language server that a file has been closed.
|
|
136
|
+
*
|
|
137
|
+
* This method should be called when a file is closed in the editor to allow
|
|
138
|
+
* the language server to clean up any resources associated with that file.
|
|
139
|
+
*
|
|
140
|
+
* @param {string} path - Absolute path to the closed file
|
|
50
141
|
* @returns {Promise<void>}
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* // When done editing a file
|
|
145
|
+
* await lsp.didClose('/workspace/project/src/index.ts');
|
|
51
146
|
*/
|
|
52
147
|
async didClose(path) {
|
|
53
148
|
await this.toolboxApi.lspDidClose(this.instance.id, {
|
|
@@ -57,28 +152,77 @@ class LspServer {
|
|
|
57
152
|
});
|
|
58
153
|
}
|
|
59
154
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
155
|
+
* Get symbol information from a document.
|
|
156
|
+
*
|
|
157
|
+
* This method returns information about all symbols (functions, classes,
|
|
158
|
+
* variables, etc.) defined in the specified document.
|
|
159
|
+
*
|
|
160
|
+
* @param {string} path - Absolute path to the file to get symbols from
|
|
161
|
+
* @returns {Promise<LspSymbol[]>} List of symbols in the document. Each symbol includes:
|
|
162
|
+
* - name: The symbol's name
|
|
163
|
+
* - kind: The symbol's kind (function, class, variable, etc.)
|
|
164
|
+
* - location: The location of the symbol in the file
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* // Get all symbols in a file
|
|
168
|
+
* const symbols = await lsp.documentSymbols('/workspace/project/src/index.ts');
|
|
169
|
+
* symbols.forEach(symbol => {
|
|
170
|
+
* console.log(`${symbol.kind} ${symbol.name}: ${symbol.location}`);
|
|
171
|
+
* });
|
|
63
172
|
*/
|
|
64
173
|
async documentSymbols(path) {
|
|
65
174
|
const response = await this.toolboxApi.lspDocumentSymbols(this.instance.id, this.languageId, this.pathToProject, 'file://' + path);
|
|
66
175
|
return response.data;
|
|
67
176
|
}
|
|
68
177
|
/**
|
|
69
|
-
* Searches for symbols across the
|
|
70
|
-
*
|
|
71
|
-
*
|
|
178
|
+
* Searches for symbols across the entire Sandbox.
|
|
179
|
+
*
|
|
180
|
+
* This method searches for symbols matching the query string across all files
|
|
181
|
+
* in the Sandbox. It's useful for finding declarations and definitions
|
|
182
|
+
* without knowing which file they're in.
|
|
183
|
+
*
|
|
184
|
+
* @param {string} query - Search query to match against symbol names
|
|
185
|
+
* @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
|
|
186
|
+
* - name: The symbol's name
|
|
187
|
+
* - kind: The symbol's kind (function, class, variable, etc.)
|
|
188
|
+
* - location: The location of the symbol in the file
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* // Search for all symbols containing "User"
|
|
192
|
+
* const symbols = await lsp.workspaceSymbols('User');
|
|
193
|
+
* symbols.forEach(symbol => {
|
|
194
|
+
* console.log(`${symbol.name} (${symbol.kind}) in ${symbol.location}`);
|
|
195
|
+
* });
|
|
72
196
|
*/
|
|
73
197
|
async workspaceSymbols(query) {
|
|
74
198
|
const response = await this.toolboxApi.lspWorkspaceSymbols(this.instance.id, this.languageId, this.pathToProject, query);
|
|
75
199
|
return response.data;
|
|
76
200
|
}
|
|
77
201
|
/**
|
|
78
|
-
* Gets
|
|
79
|
-
*
|
|
80
|
-
* @param {
|
|
81
|
-
* @
|
|
202
|
+
* Gets completion suggestions at a position in a file.
|
|
203
|
+
*
|
|
204
|
+
* @param {string} path - Absolute path to the file
|
|
205
|
+
* @param {Position} position - The position in the file where completion was requested
|
|
206
|
+
* @returns {Promise<CompletionList>} List of completion suggestions. The list includes:
|
|
207
|
+
* - isIncomplete: Whether more items might be available
|
|
208
|
+
* - items: List of completion items, each containing:
|
|
209
|
+
* - label: The text to insert
|
|
210
|
+
* - kind: The kind of completion
|
|
211
|
+
* - detail: Additional details about the item
|
|
212
|
+
* - documentation: Documentation for the item
|
|
213
|
+
* - sortText: Text used to sort the item in the list
|
|
214
|
+
* - filterText: Text used to filter the item
|
|
215
|
+
* - insertText: The actual text to insert (if different from label)
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* // Get completions at a specific position
|
|
219
|
+
* const completions = await lsp.completions('/workspace/project/src/index.ts', {
|
|
220
|
+
* line: 10,
|
|
221
|
+
* character: 15
|
|
222
|
+
* });
|
|
223
|
+
* completions.items.forEach(item => {
|
|
224
|
+
* console.log(`${item.label} (${item.kind}): ${item.detail}`);
|
|
225
|
+
* });
|
|
82
226
|
*/
|
|
83
227
|
async completions(path, position) {
|
|
84
228
|
const response = await this.toolboxApi.lspCompletions(this.instance.id, {
|