@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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
+ import { __decorate, __metadata } from "tslib";
6
+ import { DaytonaValidationError } from './errors/DaytonaError.js';
7
+ import { WithInstrumentation } from './utils/otel.decorator.js';
8
+ /**
9
+ * Supported language server types.
10
+ */
11
+ export var LspLanguageId;
12
+ (function (LspLanguageId) {
13
+ LspLanguageId["PYTHON"] = "python";
14
+ LspLanguageId["TYPESCRIPT"] = "typescript";
15
+ LspLanguageId["JAVASCRIPT"] = "javascript";
16
+ })(LspLanguageId || (LspLanguageId = {}));
17
+ /**
18
+ * Provides Language Server Protocol functionality for code intelligence to provide
19
+ * IDE-like features such as code completion, symbol search, and more.
20
+ *
21
+ * @property {LspLanguageId} languageId - The language server type (e.g., "typescript")
22
+ * @property {string} pathToProject - Path to the project root directory. Relative paths are resolved based on the sandbox working directory.
23
+ * @property {LspApi} apiClient - API client for Sandbox lsp operations
24
+ * @property {SandboxInstance} instance - The Sandbox instance this server belongs to
25
+ *
26
+ * @class
27
+ */
28
+ export class LspServer {
29
+ languageId;
30
+ pathToProject;
31
+ apiClient;
32
+ constructor(languageId, pathToProject, apiClient) {
33
+ this.languageId = languageId;
34
+ this.pathToProject = pathToProject;
35
+ this.apiClient = apiClient;
36
+ if (!Object.values(LspLanguageId).includes(this.languageId)) {
37
+ throw new DaytonaValidationError(`Invalid languageId: ${this.languageId}. Supported values are: ${Object.values(LspLanguageId).join(', ')}`);
38
+ }
39
+ }
40
+ /**
41
+ * Starts the language server, must be called before using any other LSP functionality.
42
+ * It initializes the language server for the specified language and project.
43
+ *
44
+ * @returns {Promise<void>}
45
+ *
46
+ * @example
47
+ * const lsp = await sandbox.createLspServer('typescript', 'workspace/project');
48
+ * await lsp.start(); // Initialize the server
49
+ * // Now ready for LSP operations
50
+ */
51
+ async start() {
52
+ await this.apiClient.start({
53
+ languageId: this.languageId,
54
+ pathToProject: this.pathToProject,
55
+ });
56
+ }
57
+ /**
58
+ * Stops the language server, should be called when the LSP server is no longer needed to
59
+ * free up system resources.
60
+ *
61
+ * @returns {Promise<void>}
62
+ *
63
+ * @example
64
+ * // When done with LSP features
65
+ * await lsp.stop(); // Clean up resources
66
+ */
67
+ async stop() {
68
+ await this.apiClient.stop({
69
+ languageId: this.languageId,
70
+ pathToProject: this.pathToProject,
71
+ });
72
+ }
73
+ /**
74
+ * Notifies the language server that a file has been opened, enabling
75
+ * language features like diagnostics and completions for that file. The server
76
+ * will begin tracking the file's contents and providing language features.
77
+ *
78
+ * @param {string} path - Path to the opened file. Relative paths are resolved based on the sandbox working directory.
79
+ * @returns {Promise<void>}
80
+ *
81
+ * @example
82
+ * // When opening a file for editing
83
+ * await lsp.didOpen('workspace/project/src/index.ts');
84
+ * // Now can get completions, symbols, etc. for this file
85
+ */
86
+ async didOpen(path) {
87
+ await this.apiClient.didOpen({
88
+ languageId: this.languageId,
89
+ pathToProject: this.pathToProject,
90
+ uri: 'file://' + path,
91
+ });
92
+ }
93
+ /**
94
+ * Notifies the language server that a file has been closed, should be called when a file is closed
95
+ * in the editor to allow the language server to clean up any resources associated with that file.
96
+ *
97
+ * @param {string} path - Path to the closed file. Relative paths are resolved based on the project path
98
+ * set in the LSP server constructor.
99
+ * @returns {Promise<void>}
100
+ *
101
+ * @example
102
+ * // When done editing a file
103
+ * await lsp.didClose('workspace/project/src/index.ts');
104
+ */
105
+ async didClose(path) {
106
+ await this.apiClient.didClose({
107
+ languageId: this.languageId,
108
+ pathToProject: this.pathToProject,
109
+ uri: 'file://' + path,
110
+ });
111
+ }
112
+ /**
113
+ * Get symbol information (functions, classes, variables, etc.) from a document.
114
+ *
115
+ * @param {string} path - Path to the file to get symbols from. Relative paths are resolved based on the project path
116
+ * set in the LSP server constructor.
117
+ * @returns {Promise<LspSymbol[]>} List of symbols in the document. Each symbol includes:
118
+ * - name: The symbol's name
119
+ * - kind: The symbol's kind (function, class, variable, etc.)
120
+ * - location: The location of the symbol in the file
121
+ *
122
+ * @example
123
+ * // Get all symbols in a file
124
+ * const symbols = await lsp.documentSymbols('workspace/project/src/index.ts');
125
+ * symbols.forEach(symbol => {
126
+ * console.log(`${symbol.kind} ${symbol.name}: ${symbol.location}`);
127
+ * });
128
+ */
129
+ async documentSymbols(path) {
130
+ const response = await this.apiClient.documentSymbols(this.languageId, this.pathToProject, 'file://' + path);
131
+ return response.data;
132
+ }
133
+ /**
134
+ * Searches for symbols matching the query string across the entire Sandbox.
135
+ *
136
+ * @param {string} query - Search query to match against symbol names
137
+ * @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
138
+ * - name: The symbol's name
139
+ * - kind: The symbol's kind (function, class, variable, etc.)
140
+ * - location: The location of the symbol in the file
141
+ *
142
+ * @deprecated Use `sandboxSymbols` instead. This method will be removed in a future version.
143
+ */
144
+ async workspaceSymbols(query) {
145
+ return await this.sandboxSymbols(query);
146
+ }
147
+ /**
148
+ * Searches for symbols matching the query string across the entire Sandbox.
149
+ *
150
+ * @param {string} query - Search query to match against symbol names
151
+ * @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
152
+ * - name: The symbol's name
153
+ * - kind: The symbol's kind (function, class, variable, etc.)
154
+ * - location: The location of the symbol in the file
155
+ *
156
+ * @example
157
+ * // Search for all symbols containing "User"
158
+ * const symbols = await lsp.sandboxSymbols('User');
159
+ * symbols.forEach(symbol => {
160
+ * console.log(`${symbol.name} (${symbol.kind}) in ${symbol.location}`);
161
+ * });
162
+ */
163
+ async sandboxSymbols(query) {
164
+ const response = await this.apiClient.workspaceSymbols(query, this.languageId, this.pathToProject);
165
+ return response.data;
166
+ }
167
+ /**
168
+ * Gets completion suggestions at a position in a file.
169
+ *
170
+ * @param {string} path - Path to the file. Relative paths are resolved based on the project path
171
+ * set in the LSP server constructor.
172
+ * @param {Position} position - The position in the file where completion was requested
173
+ * @returns {Promise<CompletionList>} List of completion suggestions. The list includes:
174
+ * - isIncomplete: Whether more items might be available
175
+ * - items: List of completion items, each containing:
176
+ * - label: The text to insert
177
+ * - kind: The kind of completion
178
+ * - detail: Additional details about the item
179
+ * - documentation: Documentation for the item
180
+ * - sortText: Text used to sort the item in the list
181
+ * - filterText: Text used to filter the item
182
+ * - insertText: The actual text to insert (if different from label)
183
+ *
184
+ * @example
185
+ * // Get completions at a specific position
186
+ * const completions = await lsp.completions('workspace/project/src/index.ts', {
187
+ * line: 10,
188
+ * character: 15
189
+ * });
190
+ * completions.items.forEach(item => {
191
+ * console.log(`${item.label} (${item.kind}): ${item.detail}`);
192
+ * });
193
+ */
194
+ async completions(path, position) {
195
+ const response = await this.apiClient.completions({
196
+ languageId: this.languageId,
197
+ pathToProject: this.pathToProject,
198
+ uri: 'file://' + path,
199
+ position: {
200
+ line: position.line,
201
+ character: position.character,
202
+ },
203
+ });
204
+ return response.data;
205
+ }
206
+ }
207
+ __decorate([
208
+ WithInstrumentation(),
209
+ __metadata("design:type", Function),
210
+ __metadata("design:paramtypes", []),
211
+ __metadata("design:returntype", Promise)
212
+ ], LspServer.prototype, "start", null);
213
+ __decorate([
214
+ WithInstrumentation(),
215
+ __metadata("design:type", Function),
216
+ __metadata("design:paramtypes", []),
217
+ __metadata("design:returntype", Promise)
218
+ ], LspServer.prototype, "stop", null);
219
+ __decorate([
220
+ WithInstrumentation(),
221
+ __metadata("design:type", Function),
222
+ __metadata("design:paramtypes", [String]),
223
+ __metadata("design:returntype", Promise)
224
+ ], LspServer.prototype, "didOpen", null);
225
+ __decorate([
226
+ WithInstrumentation(),
227
+ __metadata("design:type", Function),
228
+ __metadata("design:paramtypes", [String]),
229
+ __metadata("design:returntype", Promise)
230
+ ], LspServer.prototype, "didClose", null);
231
+ __decorate([
232
+ WithInstrumentation(),
233
+ __metadata("design:type", Function),
234
+ __metadata("design:paramtypes", [String]),
235
+ __metadata("design:returntype", Promise)
236
+ ], LspServer.prototype, "documentSymbols", null);
237
+ __decorate([
238
+ WithInstrumentation(),
239
+ __metadata("design:type", Function),
240
+ __metadata("design:paramtypes", [String]),
241
+ __metadata("design:returntype", Promise)
242
+ ], LspServer.prototype, "workspaceSymbols", null);
243
+ __decorate([
244
+ WithInstrumentation(),
245
+ __metadata("design:type", Function),
246
+ __metadata("design:paramtypes", [String]),
247
+ __metadata("design:returntype", Promise)
248
+ ], LspServer.prototype, "sandboxSymbols", null);
249
+ __decorate([
250
+ WithInstrumentation(),
251
+ __metadata("design:type", Function),
252
+ __metadata("design:paramtypes", [String, Object]),
253
+ __metadata("design:returntype", Promise)
254
+ ], LspServer.prototype, "completions", null);
255
+ //# 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,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAE5D;;GAEG;AACH,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,0CAAyB,CAAA;IACzB,0CAAyB,CAAA;AAC3B,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAuBD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,SAAS;IAED;IACA;IACA;IAHnB,YACmB,UAAyB,EACzB,aAAqB,EACrB,SAAiB;QAFjB,eAAU,GAAV,UAAU,CAAe;QACzB,kBAAa,GAAb,aAAa,CAAQ;QACrB,cAAS,GAAT,SAAS,CAAQ;QAElC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC5D,MAAM,IAAI,sBAAsB,CAC9B,uBAAuB,IAAI,CAAC,UAAU,2BAA2B,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC3G,CAAA;QACH,CAAC;IACH,CAAC;IAED;;;;;;;;;;OAUG;IAEU,AAAN,KAAK,CAAC,KAAK;QAChB,MAAM,I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,CAAC,CAAA;IACzC,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IAEU,AAAN,KAAK,CAAC,cAAc,CAAC,KAAa;QACvC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;QAClG,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,AAAN,KAAK,CAAC,WAAW,CAAC,IAAY,EAAE,QAAkB;QACvD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;YAChD,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,GAAG,EAAE,SAAS,GAAG,IAAI;YACrB,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,SAAS,EAAE,QAAQ,CAAC,SAAS;aAC9B;SACF,CAAC,CAAA;QACF,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;CACF;AAzKc;IADZ,mBAAmB,EAAE;;;;sCAMrB;AAaY;IADZ,mBAAmB,EAAE;;;;qCAMrB;AAgBY;IADZ,mBAAmB,EAAE;;;;wCAOrB;AAeY;IADZ,mBAAmB,EAAE;;;;yCAOrB;AAoBY;IADZ,mBAAmB,EAAE;;;;gDAIrB;AAcY;IADZ,mBAAmB,EAAE;;;;iDAGrB;AAmBY;IADZ,mBAAmB,EAAE;;;;+CAIrB;AA8BY;IADZ,mBAAmB,EAAE;;;;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"}