@daytonaio/sdk 0.0.0-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +146 -0
  2. package/package.json +39 -0
  3. package/src/Daytona.d.ts +331 -0
  4. package/src/Daytona.js +400 -0
  5. package/src/Daytona.js.map +1 -0
  6. package/src/FileSystem.d.ts +270 -0
  7. package/src/FileSystem.js +302 -0
  8. package/src/FileSystem.js.map +1 -0
  9. package/src/Git.d.ts +211 -0
  10. package/src/Git.js +275 -0
  11. package/src/Git.js.map +1 -0
  12. package/src/Image.d.ts +264 -0
  13. package/src/Image.js +565 -0
  14. package/src/Image.js.map +1 -0
  15. package/src/LspServer.d.ts +173 -0
  16. package/src/LspServer.js +209 -0
  17. package/src/LspServer.js.map +1 -0
  18. package/src/ObjectStorage.d.ts +85 -0
  19. package/src/ObjectStorage.js +231 -0
  20. package/src/ObjectStorage.js.map +1 -0
  21. package/src/Process.d.ts +246 -0
  22. package/src/Process.js +290 -0
  23. package/src/Process.js.map +1 -0
  24. package/src/Sandbox.d.ts +266 -0
  25. package/src/Sandbox.js +389 -0
  26. package/src/Sandbox.js.map +1 -0
  27. package/src/Snapshot.d.ts +116 -0
  28. package/src/Snapshot.js +187 -0
  29. package/src/Snapshot.js.map +1 -0
  30. package/src/Volume.d.ts +79 -0
  31. package/src/Volume.js +97 -0
  32. package/src/Volume.js.map +1 -0
  33. package/src/code-toolbox/SandboxPythonCodeToolbox.d.ts +11 -0
  34. package/src/code-toolbox/SandboxPythonCodeToolbox.js +358 -0
  35. package/src/code-toolbox/SandboxPythonCodeToolbox.js.map +1 -0
  36. package/src/code-toolbox/SandboxTsCodeToolbox.d.ts +5 -0
  37. package/src/code-toolbox/SandboxTsCodeToolbox.js +17 -0
  38. package/src/code-toolbox/SandboxTsCodeToolbox.js.map +1 -0
  39. package/src/errors/DaytonaError.d.ts +10 -0
  40. package/src/errors/DaytonaError.js +20 -0
  41. package/src/errors/DaytonaError.js.map +1 -0
  42. package/src/index.d.ts +15 -0
  43. package/src/index.js +32 -0
  44. package/src/index.js.map +1 -0
  45. package/src/types/Charts.d.ts +151 -0
  46. package/src/types/Charts.js +46 -0
  47. package/src/types/Charts.js.map +1 -0
  48. package/src/types/ExecuteResponse.d.ts +26 -0
  49. package/src/types/ExecuteResponse.js +7 -0
  50. package/src/types/ExecuteResponse.js.map +1 -0
  51. package/src/utils/ArtifactParser.d.ts +13 -0
  52. package/src/utils/ArtifactParser.js +55 -0
  53. package/src/utils/ArtifactParser.js.map +1 -0
  54. package/src/utils/Path.d.ts +1 -0
  55. package/src/utils/Path.js +61 -0
  56. package/src/utils/Path.js.map +1 -0
  57. package/src/utils/Stream.d.ts +13 -0
  58. package/src/utils/Stream.js +82 -0
  59. package/src/utils/Stream.js.map +1 -0
@@ -0,0 +1,173 @@
1
+ import { CompletionList, LspSymbol, ToolboxApi } from '@daytonaio/api-client';
2
+ /**
3
+ * Supported language server types.
4
+ */
5
+ export declare enum LspLanguageId {
6
+ PYTHON = "python",
7
+ TYPESCRIPT = "typescript",
8
+ JAVASCRIPT = "javascript"
9
+ }
10
+ /**
11
+ * Represents a zero-based position within a text document,
12
+ * specified by line number and character offset.
13
+ *
14
+ * @interface
15
+ * @property {number} line - Zero-based line number in the document
16
+ * @property {number} character - Zero-based character offset on the line
17
+ *
18
+ * @example
19
+ * const position: Position = {
20
+ * line: 10, // Line 11 (zero-based)
21
+ * character: 15 // Character 16 on the line (zero-based)
22
+ * };
23
+ */
24
+ export type Position = {
25
+ /** Zero-based line number */
26
+ line: number;
27
+ /** Zero-based character offset */
28
+ character: number;
29
+ };
30
+ /**
31
+ * Provides Language Server Protocol functionality for code intelligence to provide
32
+ * IDE-like features such as code completion, symbol search, and more.
33
+ *
34
+ * @property {LspLanguageId} languageId - The language server type (e.g., "typescript")
35
+ * @property {string} pathToProject - Absolute path to the project root directory
36
+ * @property {ToolboxApi} toolboxApi - API client for Sandbox operations
37
+ * @property {SandboxInstance} instance - The Sandbox instance this server belongs to
38
+ *
39
+ * @class
40
+ */
41
+ export declare class LspServer {
42
+ private readonly languageId;
43
+ private readonly pathToProject;
44
+ private readonly toolboxApi;
45
+ private readonly sandboxId;
46
+ constructor(languageId: LspLanguageId, pathToProject: string, toolboxApi: ToolboxApi, sandboxId: string);
47
+ /**
48
+ * Starts the language server, must be called before using any other LSP functionality.
49
+ * It initializes the language server for the specified language and project.
50
+ *
51
+ * @returns {Promise<void>}
52
+ *
53
+ * @example
54
+ * const lsp = await sandbox.createLspServer('typescript', 'workspace/project');
55
+ * await lsp.start(); // Initialize the server
56
+ * // Now ready for LSP operations
57
+ */
58
+ start(): Promise<void>;
59
+ /**
60
+ * Stops the language server, should be called when the LSP server is no longer needed to
61
+ * free up system resources.
62
+ *
63
+ * @returns {Promise<void>}
64
+ *
65
+ * @example
66
+ * // When done with LSP features
67
+ * await lsp.stop(); // Clean up resources
68
+ */
69
+ stop(): Promise<void>;
70
+ /**
71
+ * Notifies the language server that a file has been opened, enabling
72
+ * language features like diagnostics and completions for that file. The server
73
+ * will begin tracking the file's contents and providing language features.
74
+ *
75
+ * @param {string} path - Path to the opened file. Relative paths are resolved based on the user's
76
+ * root directory.
77
+ * @returns {Promise<void>}
78
+ *
79
+ * @example
80
+ * // When opening a file for editing
81
+ * await lsp.didOpen('workspace/project/src/index.ts');
82
+ * // Now can get completions, symbols, etc. for this file
83
+ */
84
+ didOpen(path: string): Promise<void>;
85
+ /**
86
+ * Notifies the language server that a file has been closed, should be called when a file is closed
87
+ * in the editor to allow the language server to clean up any resources associated with that file.
88
+ *
89
+ * @param {string} path - Path to the closed file. Relative paths are resolved based on the project path
90
+ * set in the LSP server constructor.
91
+ * @returns {Promise<void>}
92
+ *
93
+ * @example
94
+ * // When done editing a file
95
+ * await lsp.didClose('workspace/project/src/index.ts');
96
+ */
97
+ didClose(path: string): Promise<void>;
98
+ /**
99
+ * Get symbol information (functions, classes, variables, etc.) from a document.
100
+ *
101
+ * @param {string} path - Path to the file to get symbols from. Relative paths are resolved based on the project path
102
+ * set in the LSP server constructor.
103
+ * @returns {Promise<LspSymbol[]>} List of symbols in the document. Each symbol includes:
104
+ * - name: The symbol's name
105
+ * - kind: The symbol's kind (function, class, variable, etc.)
106
+ * - location: The location of the symbol in the file
107
+ *
108
+ * @example
109
+ * // Get all symbols in a file
110
+ * const symbols = await lsp.documentSymbols('workspace/project/src/index.ts');
111
+ * symbols.forEach(symbol => {
112
+ * console.log(`${symbol.kind} ${symbol.name}: ${symbol.location}`);
113
+ * });
114
+ */
115
+ documentSymbols(path: string): Promise<LspSymbol[]>;
116
+ /**
117
+ * Searches for symbols matching the query string across the entire Sandbox.
118
+ *
119
+ * @param {string} query - Search query to match against symbol names
120
+ * @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
121
+ * - name: The symbol's name
122
+ * - kind: The symbol's kind (function, class, variable, etc.)
123
+ * - location: The location of the symbol in the file
124
+ *
125
+ * @deprecated Use `sandboxSymbols` instead. This method will be removed in a future version.
126
+ */
127
+ workspaceSymbols(query: string): Promise<LspSymbol[]>;
128
+ /**
129
+ * Searches for symbols matching the query string across the entire Sandbox.
130
+ *
131
+ * @param {string} query - Search query to match against symbol names
132
+ * @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
133
+ * - name: The symbol's name
134
+ * - kind: The symbol's kind (function, class, variable, etc.)
135
+ * - location: The location of the symbol in the file
136
+ *
137
+ * @example
138
+ * // Search for all symbols containing "User"
139
+ * const symbols = await lsp.sandboxSymbols('User');
140
+ * symbols.forEach(symbol => {
141
+ * console.log(`${symbol.name} (${symbol.kind}) in ${symbol.location}`);
142
+ * });
143
+ */
144
+ sandboxSymbols(query: string): Promise<LspSymbol[]>;
145
+ /**
146
+ * Gets completion suggestions at a position in a file.
147
+ *
148
+ * @param {string} path - Path to the file. Relative paths are resolved based on the project path
149
+ * set in the LSP server constructor.
150
+ * @param {Position} position - The position in the file where completion was requested
151
+ * @returns {Promise<CompletionList>} List of completion suggestions. The list includes:
152
+ * - isIncomplete: Whether more items might be available
153
+ * - items: List of completion items, each containing:
154
+ * - label: The text to insert
155
+ * - kind: The kind of completion
156
+ * - detail: Additional details about the item
157
+ * - documentation: Documentation for the item
158
+ * - sortText: Text used to sort the item in the list
159
+ * - filterText: Text used to filter the item
160
+ * - insertText: The actual text to insert (if different from label)
161
+ *
162
+ * @example
163
+ * // Get completions at a specific position
164
+ * const completions = await lsp.completions('workspace/project/src/index.ts', {
165
+ * line: 10,
166
+ * character: 15
167
+ * });
168
+ * completions.items.forEach(item => {
169
+ * console.log(`${item.label} (${item.kind}): ${item.detail}`);
170
+ * });
171
+ */
172
+ completions(path: string, position: Position): Promise<CompletionList>;
173
+ }
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2025 Daytona Platforms Inc.
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.LspServer = exports.LspLanguageId = void 0;
8
+ const Path_1 = require("./utils/Path");
9
+ /**
10
+ * Supported language server types.
11
+ */
12
+ var LspLanguageId;
13
+ (function (LspLanguageId) {
14
+ LspLanguageId["PYTHON"] = "python";
15
+ LspLanguageId["TYPESCRIPT"] = "typescript";
16
+ LspLanguageId["JAVASCRIPT"] = "javascript";
17
+ })(LspLanguageId || (exports.LspLanguageId = LspLanguageId = {}));
18
+ /**
19
+ * Provides Language Server Protocol functionality for code intelligence to provide
20
+ * IDE-like features such as code completion, symbol search, and more.
21
+ *
22
+ * @property {LspLanguageId} languageId - The language server type (e.g., "typescript")
23
+ * @property {string} pathToProject - Absolute path to the project root directory
24
+ * @property {ToolboxApi} toolboxApi - API client for Sandbox operations
25
+ * @property {SandboxInstance} instance - The Sandbox instance this server belongs to
26
+ *
27
+ * @class
28
+ */
29
+ class LspServer {
30
+ languageId;
31
+ pathToProject;
32
+ toolboxApi;
33
+ sandboxId;
34
+ constructor(languageId, pathToProject, toolboxApi, sandboxId) {
35
+ this.languageId = languageId;
36
+ this.pathToProject = pathToProject;
37
+ this.toolboxApi = toolboxApi;
38
+ this.sandboxId = sandboxId;
39
+ if (!Object.values(LspLanguageId).includes(this.languageId)) {
40
+ throw new Error(`Invalid languageId: ${this.languageId}. Supported values are: ${Object.values(LspLanguageId).join(', ')}`);
41
+ }
42
+ }
43
+ /**
44
+ * Starts the language server, must be called before using any other LSP functionality.
45
+ * It initializes the language server for the specified language and project.
46
+ *
47
+ * @returns {Promise<void>}
48
+ *
49
+ * @example
50
+ * const lsp = await sandbox.createLspServer('typescript', 'workspace/project');
51
+ * await lsp.start(); // Initialize the server
52
+ * // Now ready for LSP operations
53
+ */
54
+ async start() {
55
+ await this.toolboxApi.lspStart(this.sandboxId, {
56
+ languageId: this.languageId,
57
+ pathToProject: this.pathToProject,
58
+ });
59
+ }
60
+ /**
61
+ * Stops the language server, should be called when the LSP server is no longer needed to
62
+ * free up system resources.
63
+ *
64
+ * @returns {Promise<void>}
65
+ *
66
+ * @example
67
+ * // When done with LSP features
68
+ * await lsp.stop(); // Clean up resources
69
+ */
70
+ async stop() {
71
+ await this.toolboxApi.lspStop(this.sandboxId, {
72
+ languageId: this.languageId,
73
+ pathToProject: this.pathToProject,
74
+ });
75
+ }
76
+ /**
77
+ * Notifies the language server that a file has been opened, enabling
78
+ * language features like diagnostics and completions for that file. The server
79
+ * will begin tracking the file's contents and providing language features.
80
+ *
81
+ * @param {string} path - Path to the opened file. Relative paths are resolved based on the user's
82
+ * root directory.
83
+ * @returns {Promise<void>}
84
+ *
85
+ * @example
86
+ * // When opening a file for editing
87
+ * await lsp.didOpen('workspace/project/src/index.ts');
88
+ * // Now can get completions, symbols, etc. for this file
89
+ */
90
+ async didOpen(path) {
91
+ await this.toolboxApi.lspDidOpen(this.sandboxId, {
92
+ languageId: this.languageId,
93
+ pathToProject: this.pathToProject,
94
+ uri: 'file://' + (0, Path_1.prefixRelativePath)(this.pathToProject, path),
95
+ });
96
+ }
97
+ /**
98
+ * Notifies the language server that a file has been closed, should be called when a file is closed
99
+ * in the editor to allow the language server to clean up any resources associated with that file.
100
+ *
101
+ * @param {string} path - Path to the closed file. Relative paths are resolved based on the project path
102
+ * set in the LSP server constructor.
103
+ * @returns {Promise<void>}
104
+ *
105
+ * @example
106
+ * // When done editing a file
107
+ * await lsp.didClose('workspace/project/src/index.ts');
108
+ */
109
+ async didClose(path) {
110
+ await this.toolboxApi.lspDidClose(this.sandboxId, {
111
+ languageId: this.languageId,
112
+ pathToProject: this.pathToProject,
113
+ uri: 'file://' + (0, Path_1.prefixRelativePath)(this.pathToProject, path),
114
+ });
115
+ }
116
+ /**
117
+ * Get symbol information (functions, classes, variables, etc.) from a document.
118
+ *
119
+ * @param {string} path - Path to the file to get symbols from. Relative paths are resolved based on the project path
120
+ * set in the LSP server constructor.
121
+ * @returns {Promise<LspSymbol[]>} List of symbols in the document. Each symbol includes:
122
+ * - name: The symbol's name
123
+ * - kind: The symbol's kind (function, class, variable, etc.)
124
+ * - location: The location of the symbol in the file
125
+ *
126
+ * @example
127
+ * // Get all symbols in a file
128
+ * const symbols = await lsp.documentSymbols('workspace/project/src/index.ts');
129
+ * symbols.forEach(symbol => {
130
+ * console.log(`${symbol.kind} ${symbol.name}: ${symbol.location}`);
131
+ * });
132
+ */
133
+ async documentSymbols(path) {
134
+ const response = await this.toolboxApi.lspDocumentSymbols(this.sandboxId, this.languageId, this.pathToProject, 'file://' + (0, Path_1.prefixRelativePath)(this.pathToProject, path));
135
+ return response.data;
136
+ }
137
+ /**
138
+ * Searches for symbols matching the query string across the entire Sandbox.
139
+ *
140
+ * @param {string} query - Search query to match against symbol names
141
+ * @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
142
+ * - name: The symbol's name
143
+ * - kind: The symbol's kind (function, class, variable, etc.)
144
+ * - location: The location of the symbol in the file
145
+ *
146
+ * @deprecated Use `sandboxSymbols` instead. This method will be removed in a future version.
147
+ */
148
+ async workspaceSymbols(query) {
149
+ return await this.sandboxSymbols(query);
150
+ }
151
+ /**
152
+ * Searches for symbols matching the query string across the entire Sandbox.
153
+ *
154
+ * @param {string} query - Search query to match against symbol names
155
+ * @returns {Promise<LspSymbol[]>} List of matching symbols from all files. 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
+ * // Search for all symbols containing "User"
162
+ * const symbols = await lsp.sandboxSymbols('User');
163
+ * symbols.forEach(symbol => {
164
+ * console.log(`${symbol.name} (${symbol.kind}) in ${symbol.location}`);
165
+ * });
166
+ */
167
+ async sandboxSymbols(query) {
168
+ const response = await this.toolboxApi.lspWorkspaceSymbols(this.sandboxId, this.languageId, this.pathToProject, query);
169
+ return response.data;
170
+ }
171
+ /**
172
+ * Gets completion suggestions at a position in a file.
173
+ *
174
+ * @param {string} path - Path to the file. Relative paths are resolved based on the project path
175
+ * set in the LSP server constructor.
176
+ * @param {Position} position - The position in the file where completion was requested
177
+ * @returns {Promise<CompletionList>} List of completion suggestions. The list includes:
178
+ * - isIncomplete: Whether more items might be available
179
+ * - items: List of completion items, each containing:
180
+ * - label: The text to insert
181
+ * - kind: The kind of completion
182
+ * - detail: Additional details about the item
183
+ * - documentation: Documentation for the item
184
+ * - sortText: Text used to sort the item in the list
185
+ * - filterText: Text used to filter the item
186
+ * - insertText: The actual text to insert (if different from label)
187
+ *
188
+ * @example
189
+ * // Get completions at a specific position
190
+ * const completions = await lsp.completions('workspace/project/src/index.ts', {
191
+ * line: 10,
192
+ * character: 15
193
+ * });
194
+ * completions.items.forEach(item => {
195
+ * console.log(`${item.label} (${item.kind}): ${item.detail}`);
196
+ * });
197
+ */
198
+ async completions(path, position) {
199
+ const response = await this.toolboxApi.lspCompletions(this.sandboxId, {
200
+ languageId: this.languageId,
201
+ pathToProject: this.pathToProject,
202
+ uri: 'file://' + (0, Path_1.prefixRelativePath)(this.pathToProject, path),
203
+ position,
204
+ });
205
+ return response.data;
206
+ }
207
+ }
208
+ exports.LspServer = LspServer;
209
+ //# sourceMappingURL=LspServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LspServer.js","sourceRoot":"","sources":["../../../../libs/sdk-typescript/src/LspServer.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Configuration for the ObjectStorage class.
3
+ *
4
+ * @interface
5
+ * @property {string} endpointUrl - The endpoint URL for the object storage service.
6
+ * @property {string} accessKeyId - The access key ID for the object storage service.
7
+ * @property {string} secretAccessKey - The secret access key for the object storage service.
8
+ * @property {string} [sessionToken] - The session token for the object storage service. Used for temporary credentials.
9
+ * @property {string} [bucketName] - The name of the bucket to use.
10
+ */
11
+ export interface ObjectStorageConfig {
12
+ endpointUrl: string;
13
+ accessKeyId: string;
14
+ secretAccessKey: string;
15
+ sessionToken?: string;
16
+ bucketName?: string;
17
+ }
18
+ /**
19
+ * ObjectStorage class for interacting with object storage services.
20
+ *
21
+ * @class
22
+ * @param {ObjectStorageConfig} config - The configuration for the object storage service.
23
+ */
24
+ export declare class ObjectStorage {
25
+ private bucketName;
26
+ private s3Client;
27
+ constructor(config: ObjectStorageConfig);
28
+ /**
29
+ * Upload a file or directory to object storage.
30
+ *
31
+ * @param {string} path - The path to the file or directory to upload.
32
+ * @param {string} organizationId - The organization ID to use for the upload.
33
+ * @param {string} [archiveBasePath] - The base path to use for the archive.
34
+ * @returns {Promise<string>} The hash of the uploaded file or directory.
35
+ */
36
+ upload(path: string, organizationId: string, archiveBasePath?: string): Promise<string>;
37
+ /**
38
+ * Compute a hash for a file or directory.
39
+ *
40
+ * @param {string} pathStr - The path to the file or directory to hash.
41
+ * @param {string} [archiveBasePath] - The base path to use for the archive.
42
+ * @returns {Promise<string>} The hash of the file or directory.
43
+ */
44
+ private computeHashForPathMd5;
45
+ /**
46
+ * Recursively hash a directory and its contents.
47
+ *
48
+ * @param {string} dirPath - The path to the directory to hash.
49
+ * @param {string} basePath - The base path to use for the hash.
50
+ * @param {crypto.Hash} hasher - The hasher to use for the hash.
51
+ * @returns {Promise<void>} A promise that resolves when the directory has been hashed.
52
+ */
53
+ private hashDirectory;
54
+ /**
55
+ * Hash a file.
56
+ *
57
+ * @param {string} filePath - The path to the file to hash.
58
+ * @param {crypto.Hash} hasher - The hasher to use for the hash.
59
+ * @returns {Promise<void>} A promise that resolves when the file has been hashed.
60
+ */
61
+ private hashFile;
62
+ /**
63
+ * Check if a prefix (folder) exists in S3.
64
+ *
65
+ * @param {string} prefix - The prefix to check.
66
+ * @returns {Promise<boolean>} True if the prefix exists, false otherwise.
67
+ */
68
+ private folderExistsInS3;
69
+ /**
70
+ * Create a tar archive of the specified path and upload it to S3.
71
+ *
72
+ * @param {string} s3Key - The key to use for the uploaded file.
73
+ * @param {string} sourcePath - The path to the file or directory to upload.
74
+ * @param {string} [archiveBasePath] - The base path to use for the archive.
75
+ */
76
+ private uploadAsTar;
77
+ private extractAwsRegion;
78
+ /**
79
+ * Compute the base path for an archive. Returns normalized path without the root (drive letter or leading slash).
80
+ *
81
+ * @param {string} pathStr - The path to compute the base path for.
82
+ * @returns {string} The base path for the archive.
83
+ */
84
+ static computeArchiveBasePath(pathStr: string): string;
85
+ }