@daytonaio/sdk 0.170.0 → 0.171.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.
Files changed (237) hide show
  1. package/LICENSE +190 -0
  2. package/cjs/CodeInterpreter.d.ts +95 -0
  3. package/cjs/CodeInterpreter.d.ts.map +1 -0
  4. package/cjs/CodeInterpreter.js +297 -0
  5. package/cjs/CodeInterpreter.js.map +1 -0
  6. package/cjs/ComputerUse.d.ts +539 -0
  7. package/cjs/ComputerUse.d.ts.map +1 -0
  8. package/cjs/ComputerUse.js +808 -0
  9. package/cjs/ComputerUse.js.map +1 -0
  10. package/cjs/Daytona.d.ts +355 -0
  11. package/cjs/Daytona.d.ts.map +1 -0
  12. package/cjs/Daytona.js +527 -0
  13. package/cjs/Daytona.js.map +1 -0
  14. package/cjs/FileSystem.d.ts +371 -0
  15. package/cjs/FileSystem.d.ts.map +1 -0
  16. package/cjs/FileSystem.js +489 -0
  17. package/cjs/FileSystem.js.map +1 -0
  18. package/cjs/Git.d.ts +203 -0
  19. package/cjs/Git.d.ts.map +1 -0
  20. package/cjs/Git.js +326 -0
  21. package/cjs/Git.js.map +1 -0
  22. package/cjs/Image.d.ts +265 -0
  23. package/cjs/Image.d.ts.map +1 -0
  24. package/cjs/Image.js +586 -0
  25. package/cjs/Image.js.map +1 -0
  26. package/cjs/LspServer.d.ts +172 -0
  27. package/cjs/LspServer.d.ts.map +1 -0
  28. package/cjs/LspServer.js +259 -0
  29. package/cjs/LspServer.js.map +1 -0
  30. package/cjs/ObjectStorage.d.ts +79 -0
  31. package/cjs/ObjectStorage.d.ts.map +1 -0
  32. package/cjs/ObjectStorage.js +199 -0
  33. package/cjs/ObjectStorage.js.map +1 -0
  34. package/cjs/Process.d.ts +490 -0
  35. package/cjs/Process.d.ts.map +1 -0
  36. package/cjs/Process.js +647 -0
  37. package/cjs/Process.js.map +1 -0
  38. package/cjs/PtyHandle.d.ts +155 -0
  39. package/cjs/PtyHandle.d.ts.map +1 -0
  40. package/cjs/PtyHandle.js +416 -0
  41. package/cjs/PtyHandle.js.map +1 -0
  42. package/cjs/README.md +180 -0
  43. package/cjs/Sandbox.d.ts +476 -0
  44. package/cjs/Sandbox.d.ts.map +1 -0
  45. package/cjs/Sandbox.js +905 -0
  46. package/cjs/Sandbox.js.map +1 -0
  47. package/cjs/Snapshot.d.ts +140 -0
  48. package/cjs/Snapshot.d.ts.map +1 -0
  49. package/cjs/Snapshot.js +248 -0
  50. package/cjs/Snapshot.js.map +1 -0
  51. package/cjs/Volume.d.ts +84 -0
  52. package/cjs/Volume.d.ts.map +1 -0
  53. package/cjs/Volume.js +119 -0
  54. package/cjs/Volume.js.map +1 -0
  55. package/cjs/__tests__/helpers.d.ts +6 -0
  56. package/cjs/__tests__/helpers.d.ts.map +1 -0
  57. package/cjs/__tests__/helpers.js +26 -0
  58. package/cjs/__tests__/helpers.js.map +1 -0
  59. package/cjs/errors/DaytonaError.d.ts +171 -0
  60. package/cjs/errors/DaytonaError.d.ts.map +1 -0
  61. package/cjs/errors/DaytonaError.js +258 -0
  62. package/cjs/errors/DaytonaError.js.map +1 -0
  63. package/cjs/index.d.ts +22 -0
  64. package/cjs/index.d.ts.map +1 -0
  65. package/cjs/index.js +49 -0
  66. package/cjs/index.js.map +1 -0
  67. package/cjs/package.json +3 -0
  68. package/cjs/types/Charts.d.ts +38 -0
  69. package/cjs/types/Charts.d.ts.map +1 -0
  70. package/cjs/types/Charts.js +37 -0
  71. package/cjs/types/Charts.js.map +1 -0
  72. package/cjs/types/CodeInterpreter.d.ts +77 -0
  73. package/cjs/types/CodeInterpreter.d.ts.map +1 -0
  74. package/cjs/types/CodeInterpreter.js +7 -0
  75. package/cjs/types/CodeInterpreter.js.map +1 -0
  76. package/cjs/types/ExecuteResponse.d.ts +26 -0
  77. package/cjs/types/ExecuteResponse.d.ts.map +1 -0
  78. package/cjs/types/ExecuteResponse.js +7 -0
  79. package/cjs/types/ExecuteResponse.js.map +1 -0
  80. package/cjs/types/Pty.d.ts +48 -0
  81. package/cjs/types/Pty.d.ts.map +1 -0
  82. package/cjs/types/Pty.js +7 -0
  83. package/cjs/types/Pty.js.map +1 -0
  84. package/cjs/utils/Binary.d.ts +39 -0
  85. package/cjs/utils/Binary.d.ts.map +1 -0
  86. package/cjs/utils/Binary.js +168 -0
  87. package/cjs/utils/Binary.js.map +1 -0
  88. package/cjs/utils/FileTransfer.d.ts +15 -0
  89. package/cjs/utils/FileTransfer.d.ts.map +1 -0
  90. package/cjs/utils/FileTransfer.js +261 -0
  91. package/cjs/utils/FileTransfer.js.map +1 -0
  92. package/cjs/utils/Import.d.ts +125 -0
  93. package/cjs/utils/Import.d.ts.map +1 -0
  94. package/cjs/utils/Import.js +112 -0
  95. package/cjs/utils/Import.js.map +1 -0
  96. package/cjs/utils/Multipart.d.ts +29 -0
  97. package/cjs/utils/Multipart.d.ts.map +1 -0
  98. package/cjs/utils/Multipart.js +115 -0
  99. package/cjs/utils/Multipart.js.map +1 -0
  100. package/cjs/utils/Runtime.d.ts +44 -0
  101. package/cjs/utils/Runtime.d.ts.map +1 -0
  102. package/cjs/utils/Runtime.js +95 -0
  103. package/cjs/utils/Runtime.js.map +1 -0
  104. package/cjs/utils/Stream.d.ts +20 -0
  105. package/cjs/utils/Stream.d.ts.map +1 -0
  106. package/cjs/utils/Stream.js +364 -0
  107. package/cjs/utils/Stream.js.map +1 -0
  108. package/cjs/utils/WebSocket.d.ts +10 -0
  109. package/cjs/utils/WebSocket.d.ts.map +1 -0
  110. package/cjs/utils/WebSocket.js +26 -0
  111. package/cjs/utils/WebSocket.js.map +1 -0
  112. package/cjs/utils/otel.decorator.d.ts +83 -0
  113. package/cjs/utils/otel.decorator.d.ts.map +1 -0
  114. package/cjs/utils/otel.decorator.js +141 -0
  115. package/cjs/utils/otel.decorator.js.map +1 -0
  116. package/esm/CodeInterpreter.d.ts +95 -0
  117. package/esm/CodeInterpreter.d.ts.map +1 -0
  118. package/esm/CodeInterpreter.js +292 -0
  119. package/esm/CodeInterpreter.js.map +1 -0
  120. package/esm/ComputerUse.d.ts +539 -0
  121. package/esm/ComputerUse.d.ts.map +1 -0
  122. package/esm/ComputerUse.js +799 -0
  123. package/esm/ComputerUse.js.map +1 -0
  124. package/esm/Daytona.d.ts +355 -0
  125. package/esm/Daytona.d.ts.map +1 -0
  126. package/esm/Daytona.js +523 -0
  127. package/esm/Daytona.js.map +1 -0
  128. package/esm/FileSystem.d.ts +371 -0
  129. package/esm/FileSystem.d.ts.map +1 -0
  130. package/esm/FileSystem.js +485 -0
  131. package/esm/FileSystem.js.map +1 -0
  132. package/esm/Git.d.ts +203 -0
  133. package/esm/Git.d.ts.map +1 -0
  134. package/esm/Git.js +322 -0
  135. package/esm/Git.js.map +1 -0
  136. package/esm/Image.d.ts +265 -0
  137. package/esm/Image.d.ts.map +1 -0
  138. package/esm/Image.js +581 -0
  139. package/esm/Image.js.map +1 -0
  140. package/esm/LspServer.d.ts +172 -0
  141. package/esm/LspServer.d.ts.map +1 -0
  142. package/esm/LspServer.js +255 -0
  143. package/esm/LspServer.js.map +1 -0
  144. package/esm/ObjectStorage.d.ts +79 -0
  145. package/esm/ObjectStorage.d.ts.map +1 -0
  146. package/esm/ObjectStorage.js +195 -0
  147. package/esm/ObjectStorage.js.map +1 -0
  148. package/esm/Process.d.ts +490 -0
  149. package/esm/Process.d.ts.map +1 -0
  150. package/esm/Process.js +642 -0
  151. package/esm/Process.js.map +1 -0
  152. package/esm/PtyHandle.d.ts +155 -0
  153. package/esm/PtyHandle.d.ts.map +1 -0
  154. package/esm/PtyHandle.js +412 -0
  155. package/esm/PtyHandle.js.map +1 -0
  156. package/esm/README.md +180 -0
  157. package/esm/Sandbox.d.ts +476 -0
  158. package/esm/Sandbox.d.ts.map +1 -0
  159. package/esm/Sandbox.js +901 -0
  160. package/esm/Sandbox.js.map +1 -0
  161. package/esm/Snapshot.d.ts +140 -0
  162. package/esm/Snapshot.d.ts.map +1 -0
  163. package/esm/Snapshot.js +244 -0
  164. package/esm/Snapshot.js.map +1 -0
  165. package/esm/Volume.d.ts +84 -0
  166. package/esm/Volume.d.ts.map +1 -0
  167. package/esm/Volume.js +115 -0
  168. package/esm/Volume.js.map +1 -0
  169. package/esm/__tests__/helpers.d.ts +6 -0
  170. package/esm/__tests__/helpers.d.ts.map +1 -0
  171. package/esm/__tests__/helpers.js +20 -0
  172. package/esm/__tests__/helpers.js.map +1 -0
  173. package/esm/errors/DaytonaError.d.ts +171 -0
  174. package/esm/errors/DaytonaError.d.ts.map +1 -0
  175. package/esm/errors/DaytonaError.js +243 -0
  176. package/esm/errors/DaytonaError.js.map +1 -0
  177. package/esm/index.d.ts +22 -0
  178. package/esm/index.d.ts.map +1 -0
  179. package/esm/index.js +21 -0
  180. package/esm/index.js.map +1 -0
  181. package/esm/package.json +3 -0
  182. package/esm/types/Charts.d.ts +38 -0
  183. package/esm/types/Charts.d.ts.map +1 -0
  184. package/esm/types/Charts.js +33 -0
  185. package/esm/types/Charts.js.map +1 -0
  186. package/esm/types/CodeInterpreter.d.ts +77 -0
  187. package/esm/types/CodeInterpreter.d.ts.map +1 -0
  188. package/esm/types/CodeInterpreter.js +6 -0
  189. package/esm/types/CodeInterpreter.js.map +1 -0
  190. package/esm/types/ExecuteResponse.d.ts +26 -0
  191. package/esm/types/ExecuteResponse.d.ts.map +1 -0
  192. package/esm/types/ExecuteResponse.js +6 -0
  193. package/esm/types/ExecuteResponse.js.map +1 -0
  194. package/esm/types/Pty.d.ts +48 -0
  195. package/esm/types/Pty.d.ts.map +1 -0
  196. package/esm/types/Pty.js +6 -0
  197. package/esm/types/Pty.js.map +1 -0
  198. package/esm/utils/Binary.d.ts +39 -0
  199. package/esm/utils/Binary.d.ts.map +1 -0
  200. package/esm/utils/Binary.js +157 -0
  201. package/esm/utils/Binary.js.map +1 -0
  202. package/esm/utils/FileTransfer.d.ts +15 -0
  203. package/esm/utils/FileTransfer.d.ts.map +1 -0
  204. package/esm/utils/FileTransfer.js +254 -0
  205. package/esm/utils/FileTransfer.js.map +1 -0
  206. package/esm/utils/Import.d.ts +95 -0
  207. package/esm/utils/Import.d.ts.map +1 -0
  208. package/esm/utils/Import.js +77 -0
  209. package/esm/utils/Import.js.map +1 -0
  210. package/esm/utils/Multipart.d.ts +29 -0
  211. package/esm/utils/Multipart.d.ts.map +1 -0
  212. package/esm/utils/Multipart.js +109 -0
  213. package/esm/utils/Multipart.js.map +1 -0
  214. package/esm/utils/Runtime.d.ts +44 -0
  215. package/esm/utils/Runtime.d.ts.map +1 -0
  216. package/esm/utils/Runtime.js +89 -0
  217. package/esm/utils/Runtime.js.map +1 -0
  218. package/esm/utils/Stream.d.ts +20 -0
  219. package/esm/utils/Stream.d.ts.map +1 -0
  220. package/esm/utils/Stream.js +360 -0
  221. package/esm/utils/Stream.js.map +1 -0
  222. package/esm/utils/WebSocket.d.ts +10 -0
  223. package/esm/utils/WebSocket.d.ts.map +1 -0
  224. package/esm/utils/WebSocket.js +22 -0
  225. package/esm/utils/WebSocket.js.map +1 -0
  226. package/esm/utils/otel.decorator.d.ts +83 -0
  227. package/esm/utils/otel.decorator.d.ts.map +1 -0
  228. package/esm/utils/otel.decorator.js +136 -0
  229. package/esm/utils/otel.decorator.js.map +1 -0
  230. package/package.json +20 -8
  231. package/src/ComputerUse.d.ts +4 -4
  232. package/src/ComputerUse.js +4 -4
  233. package/src/Sandbox.d.ts +1 -18
  234. package/src/Sandbox.js +0 -29
  235. package/src/Sandbox.js.map +1 -1
  236. package/src/__tests__/helpers.js +0 -2
  237. package/src/__tests__/helpers.js.map +1 -1
@@ -0,0 +1,172 @@
1
+ import { CompletionList, LspSymbol, LspApi } from '@daytona/toolbox-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 - Path to the project root directory. Relative paths are resolved based on the sandbox working directory.
36
+ * @property {LspApi} apiClient - API client for Sandbox lsp 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 apiClient;
45
+ constructor(languageId: LspLanguageId, pathToProject: string, apiClient: LspApi);
46
+ /**
47
+ * Starts the language server, must be called before using any other LSP functionality.
48
+ * It initializes the language server for the specified language and project.
49
+ *
50
+ * @returns {Promise<void>}
51
+ *
52
+ * @example
53
+ * const lsp = await sandbox.createLspServer('typescript', 'workspace/project');
54
+ * await lsp.start(); // Initialize the server
55
+ * // Now ready for LSP operations
56
+ */
57
+ start(): Promise<void>;
58
+ /**
59
+ * Stops the language server, should be called when the LSP server is no longer needed to
60
+ * free up system resources.
61
+ *
62
+ * @returns {Promise<void>}
63
+ *
64
+ * @example
65
+ * // When done with LSP features
66
+ * await lsp.stop(); // Clean up resources
67
+ */
68
+ stop(): Promise<void>;
69
+ /**
70
+ * Notifies the language server that a file has been opened, enabling
71
+ * language features like diagnostics and completions for that file. The server
72
+ * will begin tracking the file's contents and providing language features.
73
+ *
74
+ * @param {string} path - Path to the opened file. Relative paths are resolved based on the sandbox working directory.
75
+ * @returns {Promise<void>}
76
+ *
77
+ * @example
78
+ * // When opening a file for editing
79
+ * await lsp.didOpen('workspace/project/src/index.ts');
80
+ * // Now can get completions, symbols, etc. for this file
81
+ */
82
+ didOpen(path: string): Promise<void>;
83
+ /**
84
+ * Notifies the language server that a file has been closed, should be called when a file is closed
85
+ * in the editor to allow the language server to clean up any resources associated with that file.
86
+ *
87
+ * @param {string} path - Path to the closed file. Relative paths are resolved based on the project path
88
+ * set in the LSP server constructor.
89
+ * @returns {Promise<void>}
90
+ *
91
+ * @example
92
+ * // When done editing a file
93
+ * await lsp.didClose('workspace/project/src/index.ts');
94
+ */
95
+ didClose(path: string): Promise<void>;
96
+ /**
97
+ * Get symbol information (functions, classes, variables, etc.) from a document.
98
+ *
99
+ * @param {string} path - Path to the file to get symbols from. Relative paths are resolved based on the project path
100
+ * set in the LSP server constructor.
101
+ * @returns {Promise<LspSymbol[]>} List of symbols in the document. Each symbol includes:
102
+ * - name: The symbol's name
103
+ * - kind: The symbol's kind (function, class, variable, etc.)
104
+ * - location: The location of the symbol in the file
105
+ *
106
+ * @example
107
+ * // Get all symbols in a file
108
+ * const symbols = await lsp.documentSymbols('workspace/project/src/index.ts');
109
+ * symbols.forEach(symbol => {
110
+ * console.log(`${symbol.kind} ${symbol.name}: ${symbol.location}`);
111
+ * });
112
+ */
113
+ documentSymbols(path: string): Promise<LspSymbol[]>;
114
+ /**
115
+ * Searches for symbols matching the query string across the entire Sandbox.
116
+ *
117
+ * @param {string} query - Search query to match against symbol names
118
+ * @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
119
+ * - name: The symbol's name
120
+ * - kind: The symbol's kind (function, class, variable, etc.)
121
+ * - location: The location of the symbol in the file
122
+ *
123
+ * @deprecated Use `sandboxSymbols` instead. This method will be removed in a future version.
124
+ */
125
+ workspaceSymbols(query: string): Promise<LspSymbol[]>;
126
+ /**
127
+ * Searches for symbols matching the query string across the entire Sandbox.
128
+ *
129
+ * @param {string} query - Search query to match against symbol names
130
+ * @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
131
+ * - name: The symbol's name
132
+ * - kind: The symbol's kind (function, class, variable, etc.)
133
+ * - location: The location of the symbol in the file
134
+ *
135
+ * @example
136
+ * // Search for all symbols containing "User"
137
+ * const symbols = await lsp.sandboxSymbols('User');
138
+ * symbols.forEach(symbol => {
139
+ * console.log(`${symbol.name} (${symbol.kind}) in ${symbol.location}`);
140
+ * });
141
+ */
142
+ sandboxSymbols(query: string): Promise<LspSymbol[]>;
143
+ /**
144
+ * Gets completion suggestions at a position in a file.
145
+ *
146
+ * @param {string} path - Path to the file. Relative paths are resolved based on the project path
147
+ * set in the LSP server constructor.
148
+ * @param {Position} position - The position in the file where completion was requested
149
+ * @returns {Promise<CompletionList>} List of completion suggestions. The list includes:
150
+ * - isIncomplete: Whether more items might be available
151
+ * - items: List of completion items, each containing:
152
+ * - label: The text to insert
153
+ * - kind: The kind of completion
154
+ * - detail: Additional details about the item
155
+ * - documentation: Documentation for the item
156
+ * - sortText: Text used to sort the item in the list
157
+ * - filterText: Text used to filter the item
158
+ * - insertText: The actual text to insert (if different from label)
159
+ *
160
+ * @example
161
+ * // Get completions at a specific position
162
+ * const completions = await lsp.completions('workspace/project/src/index.ts', {
163
+ * line: 10,
164
+ * character: 15
165
+ * });
166
+ * completions.items.forEach(item => {
167
+ * console.log(`${item.label} (${item.kind}): ${item.detail}`);
168
+ * });
169
+ */
170
+ completions(path: string, position: Position): Promise<CompletionList>;
171
+ }
172
+ //# sourceMappingURL=LspServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LspServer.d.ts","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/LspServer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAA;AAI/E;;GAEG;AACH,oBAAY,aAAa;IACvB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,UAAU,eAAe;CAC1B;AAED;;;;;;;;;;;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.0
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.LspServer = exports.LspLanguageId = void 0;
8
+ const tslib_1 = require("tslib");
9
+ const DaytonaError_1 = require("./errors/DaytonaError");
10
+ const otel_decorator_1 = require("./utils/otel.decorator");
11
+ /**
12
+ * Supported language server types.
13
+ */
14
+ var LspLanguageId;
15
+ (function (LspLanguageId) {
16
+ LspLanguageId["PYTHON"] = "python";
17
+ LspLanguageId["TYPESCRIPT"] = "typescript";
18
+ LspLanguageId["JAVASCRIPT"] = "javascript";
19
+ })(LspLanguageId || (exports.LspLanguageId = LspLanguageId = {}));
20
+ /**
21
+ * Provides Language Server Protocol functionality for code intelligence to provide
22
+ * IDE-like features such as code completion, symbol search, and more.
23
+ *
24
+ * @property {LspLanguageId} languageId - The language server type (e.g., "typescript")
25
+ * @property {string} pathToProject - Path to the project root directory. Relative paths are resolved based on the sandbox working directory.
26
+ * @property {LspApi} apiClient - API client for Sandbox lsp operations
27
+ * @property {SandboxInstance} instance - The Sandbox instance this server belongs to
28
+ *
29
+ * @class
30
+ */
31
+ class LspServer {
32
+ languageId;
33
+ pathToProject;
34
+ apiClient;
35
+ constructor(languageId, pathToProject, apiClient) {
36
+ this.languageId = languageId;
37
+ this.pathToProject = pathToProject;
38
+ this.apiClient = apiClient;
39
+ if (!Object.values(LspLanguageId).includes(this.languageId)) {
40
+ throw new DaytonaError_1.DaytonaValidationError(`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.apiClient.start({
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.apiClient.stop({
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 sandbox working directory.
82
+ * @returns {Promise<void>}
83
+ *
84
+ * @example
85
+ * // When opening a file for editing
86
+ * await lsp.didOpen('workspace/project/src/index.ts');
87
+ * // Now can get completions, symbols, etc. for this file
88
+ */
89
+ async didOpen(path) {
90
+ await this.apiClient.didOpen({
91
+ languageId: this.languageId,
92
+ pathToProject: this.pathToProject,
93
+ uri: 'file://' + path,
94
+ });
95
+ }
96
+ /**
97
+ * Notifies the language server that a file has been closed, should be called when a file is closed
98
+ * in the editor to allow the language server to clean up any resources associated with that file.
99
+ *
100
+ * @param {string} path - Path to the closed file. Relative paths are resolved based on the project path
101
+ * set in the LSP server constructor.
102
+ * @returns {Promise<void>}
103
+ *
104
+ * @example
105
+ * // When done editing a file
106
+ * await lsp.didClose('workspace/project/src/index.ts');
107
+ */
108
+ async didClose(path) {
109
+ await this.apiClient.didClose({
110
+ languageId: this.languageId,
111
+ pathToProject: this.pathToProject,
112
+ uri: 'file://' + path,
113
+ });
114
+ }
115
+ /**
116
+ * Get symbol information (functions, classes, variables, etc.) from a document.
117
+ *
118
+ * @param {string} path - Path to the file to get symbols from. Relative paths are resolved based on the project path
119
+ * set in the LSP server constructor.
120
+ * @returns {Promise<LspSymbol[]>} List of symbols in the document. 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
+ * @example
126
+ * // Get all symbols in a file
127
+ * const symbols = await lsp.documentSymbols('workspace/project/src/index.ts');
128
+ * symbols.forEach(symbol => {
129
+ * console.log(`${symbol.kind} ${symbol.name}: ${symbol.location}`);
130
+ * });
131
+ */
132
+ async documentSymbols(path) {
133
+ const response = await this.apiClient.documentSymbols(this.languageId, this.pathToProject, 'file://' + path);
134
+ return response.data;
135
+ }
136
+ /**
137
+ * Searches for symbols matching the query string across the entire Sandbox.
138
+ *
139
+ * @param {string} query - Search query to match against symbol names
140
+ * @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
141
+ * - name: The symbol's name
142
+ * - kind: The symbol's kind (function, class, variable, etc.)
143
+ * - location: The location of the symbol in the file
144
+ *
145
+ * @deprecated Use `sandboxSymbols` instead. This method will be removed in a future version.
146
+ */
147
+ async workspaceSymbols(query) {
148
+ return await this.sandboxSymbols(query);
149
+ }
150
+ /**
151
+ * Searches for symbols matching the query string across the entire Sandbox.
152
+ *
153
+ * @param {string} query - Search query to match against symbol names
154
+ * @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
155
+ * - name: The symbol's name
156
+ * - kind: The symbol's kind (function, class, variable, etc.)
157
+ * - location: The location of the symbol in the file
158
+ *
159
+ * @example
160
+ * // Search for all symbols containing "User"
161
+ * const symbols = await lsp.sandboxSymbols('User');
162
+ * symbols.forEach(symbol => {
163
+ * console.log(`${symbol.name} (${symbol.kind}) in ${symbol.location}`);
164
+ * });
165
+ */
166
+ async sandboxSymbols(query) {
167
+ const response = await this.apiClient.workspaceSymbols(query, this.languageId, this.pathToProject);
168
+ return response.data;
169
+ }
170
+ /**
171
+ * Gets completion suggestions at a position in a file.
172
+ *
173
+ * @param {string} path - Path to the file. Relative paths are resolved based on the project path
174
+ * set in the LSP server constructor.
175
+ * @param {Position} position - The position in the file where completion was requested
176
+ * @returns {Promise<CompletionList>} List of completion suggestions. The list includes:
177
+ * - isIncomplete: Whether more items might be available
178
+ * - items: List of completion items, each containing:
179
+ * - label: The text to insert
180
+ * - kind: The kind of completion
181
+ * - detail: Additional details about the item
182
+ * - documentation: Documentation for the item
183
+ * - sortText: Text used to sort the item in the list
184
+ * - filterText: Text used to filter the item
185
+ * - insertText: The actual text to insert (if different from label)
186
+ *
187
+ * @example
188
+ * // Get completions at a specific position
189
+ * const completions = await lsp.completions('workspace/project/src/index.ts', {
190
+ * line: 10,
191
+ * character: 15
192
+ * });
193
+ * completions.items.forEach(item => {
194
+ * console.log(`${item.label} (${item.kind}): ${item.detail}`);
195
+ * });
196
+ */
197
+ async completions(path, position) {
198
+ const response = await this.apiClient.completions({
199
+ languageId: this.languageId,
200
+ pathToProject: this.pathToProject,
201
+ uri: 'file://' + path,
202
+ position: {
203
+ line: position.line,
204
+ character: position.character,
205
+ },
206
+ });
207
+ return response.data;
208
+ }
209
+ }
210
+ exports.LspServer = LspServer;
211
+ tslib_1.__decorate([
212
+ (0, otel_decorator_1.WithInstrumentation)(),
213
+ tslib_1.__metadata("design:type", Function),
214
+ tslib_1.__metadata("design:paramtypes", []),
215
+ tslib_1.__metadata("design:returntype", Promise)
216
+ ], LspServer.prototype, "start", null);
217
+ tslib_1.__decorate([
218
+ (0, otel_decorator_1.WithInstrumentation)(),
219
+ tslib_1.__metadata("design:type", Function),
220
+ tslib_1.__metadata("design:paramtypes", []),
221
+ tslib_1.__metadata("design:returntype", Promise)
222
+ ], LspServer.prototype, "stop", null);
223
+ tslib_1.__decorate([
224
+ (0, otel_decorator_1.WithInstrumentation)(),
225
+ tslib_1.__metadata("design:type", Function),
226
+ tslib_1.__metadata("design:paramtypes", [String]),
227
+ tslib_1.__metadata("design:returntype", Promise)
228
+ ], LspServer.prototype, "didOpen", null);
229
+ tslib_1.__decorate([
230
+ (0, otel_decorator_1.WithInstrumentation)(),
231
+ tslib_1.__metadata("design:type", Function),
232
+ tslib_1.__metadata("design:paramtypes", [String]),
233
+ tslib_1.__metadata("design:returntype", Promise)
234
+ ], LspServer.prototype, "didClose", null);
235
+ tslib_1.__decorate([
236
+ (0, otel_decorator_1.WithInstrumentation)(),
237
+ tslib_1.__metadata("design:type", Function),
238
+ tslib_1.__metadata("design:paramtypes", [String]),
239
+ tslib_1.__metadata("design:returntype", Promise)
240
+ ], LspServer.prototype, "documentSymbols", null);
241
+ tslib_1.__decorate([
242
+ (0, otel_decorator_1.WithInstrumentation)(),
243
+ tslib_1.__metadata("design:type", Function),
244
+ tslib_1.__metadata("design:paramtypes", [String]),
245
+ tslib_1.__metadata("design:returntype", Promise)
246
+ ], LspServer.prototype, "workspaceSymbols", null);
247
+ tslib_1.__decorate([
248
+ (0, otel_decorator_1.WithInstrumentation)(),
249
+ tslib_1.__metadata("design:type", Function),
250
+ tslib_1.__metadata("design:paramtypes", [String]),
251
+ tslib_1.__metadata("design:returntype", Promise)
252
+ ], LspServer.prototype, "sandboxSymbols", null);
253
+ tslib_1.__decorate([
254
+ (0, otel_decorator_1.WithInstrumentation)(),
255
+ tslib_1.__metadata("design:type", Function),
256
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
257
+ tslib_1.__metadata("design:returntype", Promise)
258
+ ], LspServer.prototype, "completions", null);
259
+ //# sourceMappingURL=LspServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LspServer.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/LspServer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAGH,wDAA8D;AAC9D,2DAA4D;AAE5D;;GAEG;AACH,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,0CAAyB,CAAA;IACzB,0CAAyB,CAAA;AAC3B,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AAuBD;;;;;;;;;;GAUG;AACH,MAAa,SAAS;IAED;IACA;IACA;IAHnB,YACmB,UAAyB,EACzB,aAAqB,EACrB,SAAiB;QAFjB,eAAU,GAAV,UAAU,CAAe;QACzB,kBAAa,GAAb,aAAa,CAAQ;QACr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CAAmB,GAAE;;;;wCAOrB;AAeY;IADZ,IAAA,oCAAmB,GAAE;;;;yCAOrB;AAoBY;IADZ,IAAA,oCAAmB,GAAE;;;;gDAIrB;AAcY;IADZ,IAAA,oCAAmB,GAAE;;;;iDAGrB;AAmBY;IADZ,IAAA,oCAAmB,GAAE;;;;+CAIrB;AA8BY;IADZ,IAAA,oCAAmB,GAAE;;;;4CAYrB"}
@@ -0,0 +1,79 @@
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
+ //# sourceMappingURL=ObjectStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectStorage.d.ts","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/ObjectStorage.ts"],"names":[],"mappings":"AAaA;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,QAAQ,CAAU;gBAEd,MAAM,EAAE,mBAAmB;IAcvC;;;;;;;OAOG;IAEG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA0B5F;;;;;;OAMG;YACW,qBAAqB;IAmBnC;;;;;;;OAOG;YACW,aAAa;IA2B3B;;;;;;OAMG;YACW,QAAQ;IAWtB;;;;;OAKG;YACW,gBAAgB;IAY9B;;;;;;OAMG;YACW,WAAW;IA2CzB,OAAO,CAAC,gBAAgB;CAIzB"}