@daytonaio/sdk 0.128.0-alpha.1 → 0.128.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.
Files changed (277) hide show
  1. package/package.json +8 -20
  2. package/{cjs → src}/CodeInterpreter.d.ts +0 -1
  3. package/src/CodeInterpreter.js.map +1 -0
  4. package/{esm → src}/ComputerUse.d.ts +0 -1
  5. package/src/ComputerUse.js.map +1 -0
  6. package/{cjs → src}/Daytona.d.ts +0 -1
  7. package/{cjs → src}/Daytona.js +0 -1
  8. package/src/Daytona.js.map +1 -0
  9. package/{esm → src}/FileSystem.d.ts +0 -1
  10. package/src/FileSystem.js.map +1 -0
  11. package/{esm → src}/Git.d.ts +0 -1
  12. package/src/Git.js.map +1 -0
  13. package/{cjs → src}/Image.d.ts +0 -21
  14. package/{cjs → src}/Image.js +91 -123
  15. package/src/Image.js.map +1 -0
  16. package/{cjs → src}/LspServer.d.ts +0 -1
  17. package/src/LspServer.js.map +1 -0
  18. package/{esm → src}/ObjectStorage.d.ts +0 -1
  19. package/src/ObjectStorage.js.map +1 -0
  20. package/{cjs → src}/Process.d.ts +0 -1
  21. package/src/Process.js.map +1 -0
  22. package/{cjs → src}/PtyHandle.d.ts +0 -1
  23. package/src/PtyHandle.js.map +1 -0
  24. package/{cjs → src}/Sandbox.d.ts +17 -2
  25. package/{cjs → src}/Sandbox.js +27 -1
  26. package/src/Sandbox.js.map +1 -0
  27. package/{cjs → src}/Snapshot.d.ts +0 -2
  28. package/{cjs → src}/Snapshot.js +1 -9
  29. package/src/Snapshot.js.map +1 -0
  30. package/{esm → src}/Volume.d.ts +0 -1
  31. package/src/Volume.js.map +1 -0
  32. package/{cjs → src}/code-toolbox/SandboxJsCodeToolbox.d.ts +0 -1
  33. package/src/code-toolbox/SandboxJsCodeToolbox.js.map +1 -0
  34. package/{cjs → src}/code-toolbox/SandboxPythonCodeToolbox.d.ts +0 -1
  35. package/src/code-toolbox/SandboxPythonCodeToolbox.js.map +1 -0
  36. package/{cjs → src}/code-toolbox/SandboxTsCodeToolbox.d.ts +0 -1
  37. package/src/code-toolbox/SandboxTsCodeToolbox.js.map +1 -0
  38. package/{esm → src}/errors/DaytonaError.d.ts +0 -1
  39. package/src/errors/DaytonaError.js.map +1 -0
  40. package/{cjs → src}/index.d.ts +0 -1
  41. package/src/index.js.map +1 -0
  42. package/{esm → src}/types/Charts.d.ts +0 -1
  43. package/src/types/Charts.js.map +1 -0
  44. package/{esm → src}/types/CodeInterpreter.d.ts +0 -1
  45. package/src/types/CodeInterpreter.js.map +1 -0
  46. package/{cjs → src}/types/ExecuteResponse.d.ts +0 -1
  47. package/src/types/ExecuteResponse.js.map +1 -0
  48. package/{cjs → src}/types/Pty.d.ts +0 -1
  49. package/src/types/Pty.js.map +1 -0
  50. package/{cjs → src}/utils/ArtifactParser.d.ts +0 -1
  51. package/src/utils/ArtifactParser.js.map +1 -0
  52. package/{esm → src}/utils/Binary.d.ts +0 -1
  53. package/src/utils/Binary.js.map +1 -0
  54. package/{cjs → src}/utils/FileTransfer.d.ts +0 -1
  55. package/src/utils/FileTransfer.js.map +1 -0
  56. package/{cjs → src}/utils/Import.d.ts +15 -2
  57. package/src/utils/Import.js +77 -0
  58. package/src/utils/Import.js.map +1 -0
  59. package/{esm → src}/utils/Multipart.d.ts +0 -1
  60. package/src/utils/Multipart.js.map +1 -0
  61. package/{cjs → src}/utils/Runtime.d.ts +0 -1
  62. package/src/utils/Runtime.js.map +1 -0
  63. package/{cjs → src}/utils/Stream.d.ts +0 -1
  64. package/src/utils/Stream.js.map +1 -0
  65. package/{esm → src}/utils/WebSocket.d.ts +0 -1
  66. package/src/utils/WebSocket.js.map +1 -0
  67. package/LICENSE +0 -190
  68. package/cjs/CodeInterpreter.d.ts.map +0 -1
  69. package/cjs/CodeInterpreter.js.map +0 -1
  70. package/cjs/ComputerUse.d.ts +0 -443
  71. package/cjs/ComputerUse.d.ts.map +0 -1
  72. package/cjs/ComputerUse.js.map +0 -1
  73. package/cjs/Daytona.d.ts.map +0 -1
  74. package/cjs/Daytona.js.map +0 -1
  75. package/cjs/FileSystem.d.ts +0 -328
  76. package/cjs/FileSystem.d.ts.map +0 -1
  77. package/cjs/FileSystem.js.map +0 -1
  78. package/cjs/Git.d.ts +0 -203
  79. package/cjs/Git.d.ts.map +0 -1
  80. package/cjs/Git.js.map +0 -1
  81. package/cjs/Image.d.ts.map +0 -1
  82. package/cjs/Image.js.map +0 -1
  83. package/cjs/LspServer.d.ts.map +0 -1
  84. package/cjs/LspServer.js.map +0 -1
  85. package/cjs/ObjectStorage.d.ts +0 -79
  86. package/cjs/ObjectStorage.d.ts.map +0 -1
  87. package/cjs/ObjectStorage.js.map +0 -1
  88. package/cjs/Process.d.ts.map +0 -1
  89. package/cjs/Process.js.map +0 -1
  90. package/cjs/PtyHandle.d.ts.map +0 -1
  91. package/cjs/PtyHandle.js.map +0 -1
  92. package/cjs/README.md +0 -147
  93. package/cjs/Sandbox.d.ts.map +0 -1
  94. package/cjs/Sandbox.js.map +0 -1
  95. package/cjs/Snapshot.d.ts.map +0 -1
  96. package/cjs/Snapshot.js.map +0 -1
  97. package/cjs/Volume.d.ts +0 -84
  98. package/cjs/Volume.d.ts.map +0 -1
  99. package/cjs/Volume.js.map +0 -1
  100. package/cjs/code-toolbox/SandboxJsCodeToolbox.d.ts.map +0 -1
  101. package/cjs/code-toolbox/SandboxJsCodeToolbox.js.map +0 -1
  102. package/cjs/code-toolbox/SandboxPythonCodeToolbox.d.ts.map +0 -1
  103. package/cjs/code-toolbox/SandboxPythonCodeToolbox.js.map +0 -1
  104. package/cjs/code-toolbox/SandboxTsCodeToolbox.d.ts.map +0 -1
  105. package/cjs/code-toolbox/SandboxTsCodeToolbox.js.map +0 -1
  106. package/cjs/errors/DaytonaError.d.ts +0 -32
  107. package/cjs/errors/DaytonaError.d.ts.map +0 -1
  108. package/cjs/errors/DaytonaError.js.map +0 -1
  109. package/cjs/index.d.ts.map +0 -1
  110. package/cjs/index.js.map +0 -1
  111. package/cjs/package.json +0 -3
  112. package/cjs/types/Charts.d.ts +0 -152
  113. package/cjs/types/Charts.d.ts.map +0 -1
  114. package/cjs/types/Charts.js.map +0 -1
  115. package/cjs/types/CodeInterpreter.d.ts +0 -77
  116. package/cjs/types/CodeInterpreter.d.ts.map +0 -1
  117. package/cjs/types/CodeInterpreter.js.map +0 -1
  118. package/cjs/types/ExecuteResponse.d.ts.map +0 -1
  119. package/cjs/types/ExecuteResponse.js.map +0 -1
  120. package/cjs/types/Pty.d.ts.map +0 -1
  121. package/cjs/types/Pty.js.map +0 -1
  122. package/cjs/utils/ArtifactParser.d.ts.map +0 -1
  123. package/cjs/utils/ArtifactParser.js.map +0 -1
  124. package/cjs/utils/Binary.d.ts +0 -39
  125. package/cjs/utils/Binary.d.ts.map +0 -1
  126. package/cjs/utils/Binary.js.map +0 -1
  127. package/cjs/utils/FileTransfer.d.ts.map +0 -1
  128. package/cjs/utils/FileTransfer.js.map +0 -1
  129. package/cjs/utils/Import.d.ts.map +0 -1
  130. package/cjs/utils/Import.js +0 -81
  131. package/cjs/utils/Import.js.map +0 -1
  132. package/cjs/utils/Multipart.d.ts +0 -27
  133. package/cjs/utils/Multipart.d.ts.map +0 -1
  134. package/cjs/utils/Multipart.js.map +0 -1
  135. package/cjs/utils/Runtime.d.ts.map +0 -1
  136. package/cjs/utils/Runtime.js.map +0 -1
  137. package/cjs/utils/Stream.d.ts.map +0 -1
  138. package/cjs/utils/Stream.js.map +0 -1
  139. package/cjs/utils/WebSocket.d.ts +0 -10
  140. package/cjs/utils/WebSocket.d.ts.map +0 -1
  141. package/cjs/utils/WebSocket.js.map +0 -1
  142. package/esm/CodeInterpreter.d.ts +0 -96
  143. package/esm/CodeInterpreter.d.ts.map +0 -1
  144. package/esm/CodeInterpreter.js +0 -295
  145. package/esm/CodeInterpreter.js.map +0 -1
  146. package/esm/ComputerUse.d.ts.map +0 -1
  147. package/esm/ComputerUse.js +0 -509
  148. package/esm/ComputerUse.js.map +0 -1
  149. package/esm/Daytona.d.ts +0 -354
  150. package/esm/Daytona.d.ts.map +0 -1
  151. package/esm/Daytona.js +0 -410
  152. package/esm/Daytona.js.map +0 -1
  153. package/esm/FileSystem.d.ts.map +0 -1
  154. package/esm/FileSystem.js +0 -331
  155. package/esm/FileSystem.js.map +0 -1
  156. package/esm/Git.d.ts.map +0 -1
  157. package/esm/Git.js +0 -260
  158. package/esm/Git.js.map +0 -1
  159. package/esm/Image.d.ts +0 -285
  160. package/esm/Image.d.ts.map +0 -1
  161. package/esm/Image.js +0 -569
  162. package/esm/Image.js.map +0 -1
  163. package/esm/LspServer.d.ts +0 -172
  164. package/esm/LspServer.d.ts.map +0 -1
  165. package/esm/LspServer.js +0 -204
  166. package/esm/LspServer.js.map +0 -1
  167. package/esm/ObjectStorage.d.ts.map +0 -1
  168. package/esm/ObjectStorage.js +0 -187
  169. package/esm/ObjectStorage.js.map +0 -1
  170. package/esm/Process.d.ts +0 -442
  171. package/esm/Process.d.ts.map +0 -1
  172. package/esm/Process.js +0 -644
  173. package/esm/Process.js.map +0 -1
  174. package/esm/PtyHandle.d.ts +0 -155
  175. package/esm/PtyHandle.d.ts.map +0 -1
  176. package/esm/PtyHandle.js +0 -374
  177. package/esm/PtyHandle.js.map +0 -1
  178. package/esm/README.md +0 -147
  179. package/esm/Sandbox.d.ts +0 -359
  180. package/esm/Sandbox.d.ts.map +0 -1
  181. package/esm/Sandbox.js +0 -532
  182. package/esm/Sandbox.js.map +0 -1
  183. package/esm/Snapshot.d.ts +0 -138
  184. package/esm/Snapshot.d.ts.map +0 -1
  185. package/esm/Snapshot.js +0 -207
  186. package/esm/Snapshot.js.map +0 -1
  187. package/esm/Volume.d.ts.map +0 -1
  188. package/esm/Volume.js +0 -95
  189. package/esm/Volume.js.map +0 -1
  190. package/esm/code-toolbox/SandboxJsCodeToolbox.d.ts +0 -6
  191. package/esm/code-toolbox/SandboxJsCodeToolbox.d.ts.map +0 -1
  192. package/esm/code-toolbox/SandboxJsCodeToolbox.js +0 -13
  193. package/esm/code-toolbox/SandboxJsCodeToolbox.js.map +0 -1
  194. package/esm/code-toolbox/SandboxPythonCodeToolbox.d.ts +0 -12
  195. package/esm/code-toolbox/SandboxPythonCodeToolbox.d.ts.map +0 -1
  196. package/esm/code-toolbox/SandboxPythonCodeToolbox.js +0 -355
  197. package/esm/code-toolbox/SandboxPythonCodeToolbox.js.map +0 -1
  198. package/esm/code-toolbox/SandboxTsCodeToolbox.d.ts +0 -6
  199. package/esm/code-toolbox/SandboxTsCodeToolbox.d.ts.map +0 -1
  200. package/esm/code-toolbox/SandboxTsCodeToolbox.js +0 -14
  201. package/esm/code-toolbox/SandboxTsCodeToolbox.js.map +0 -1
  202. package/esm/errors/DaytonaError.d.ts.map +0 -1
  203. package/esm/errors/DaytonaError.js +0 -44
  204. package/esm/errors/DaytonaError.js.map +0 -1
  205. package/esm/index.d.ts +0 -22
  206. package/esm/index.d.ts.map +0 -1
  207. package/esm/index.js +0 -22
  208. package/esm/index.js.map +0 -1
  209. package/esm/package.json +0 -3
  210. package/esm/types/Charts.d.ts.map +0 -1
  211. package/esm/types/Charts.js +0 -42
  212. package/esm/types/Charts.js.map +0 -1
  213. package/esm/types/CodeInterpreter.d.ts.map +0 -1
  214. package/esm/types/CodeInterpreter.js +0 -6
  215. package/esm/types/CodeInterpreter.js.map +0 -1
  216. package/esm/types/ExecuteResponse.d.ts +0 -26
  217. package/esm/types/ExecuteResponse.d.ts.map +0 -1
  218. package/esm/types/ExecuteResponse.js +0 -6
  219. package/esm/types/ExecuteResponse.js.map +0 -1
  220. package/esm/types/Pty.d.ts +0 -48
  221. package/esm/types/Pty.d.ts.map +0 -1
  222. package/esm/types/Pty.js +0 -6
  223. package/esm/types/Pty.js.map +0 -1
  224. package/esm/utils/ArtifactParser.d.ts +0 -14
  225. package/esm/utils/ArtifactParser.d.ts.map +0 -1
  226. package/esm/utils/ArtifactParser.js +0 -51
  227. package/esm/utils/ArtifactParser.js.map +0 -1
  228. package/esm/utils/Binary.d.ts.map +0 -1
  229. package/esm/utils/Binary.js +0 -157
  230. package/esm/utils/Binary.js.map +0 -1
  231. package/esm/utils/FileTransfer.d.ts +0 -15
  232. package/esm/utils/FileTransfer.d.ts.map +0 -1
  233. package/esm/utils/FileTransfer.js +0 -209
  234. package/esm/utils/FileTransfer.js.map +0 -1
  235. package/esm/utils/Import.d.ts +0 -211
  236. package/esm/utils/Import.d.ts.map +0 -1
  237. package/esm/utils/Import.js +0 -45
  238. package/esm/utils/Import.js.map +0 -1
  239. package/esm/utils/Multipart.d.ts.map +0 -1
  240. package/esm/utils/Multipart.js +0 -107
  241. package/esm/utils/Multipart.js.map +0 -1
  242. package/esm/utils/Runtime.d.ts +0 -37
  243. package/esm/utils/Runtime.d.ts.map +0 -1
  244. package/esm/utils/Runtime.js +0 -57
  245. package/esm/utils/Runtime.js.map +0 -1
  246. package/esm/utils/Stream.d.ts +0 -20
  247. package/esm/utils/Stream.d.ts.map +0 -1
  248. package/esm/utils/Stream.js +0 -360
  249. package/esm/utils/Stream.js.map +0 -1
  250. package/esm/utils/WebSocket.d.ts.map +0 -1
  251. package/esm/utils/WebSocket.js +0 -22
  252. package/esm/utils/WebSocket.js.map +0 -1
  253. /package/{cjs → src}/CodeInterpreter.js +0 -0
  254. /package/{cjs → src}/ComputerUse.js +0 -0
  255. /package/{cjs → src}/FileSystem.js +0 -0
  256. /package/{cjs → src}/Git.js +0 -0
  257. /package/{cjs → src}/LspServer.js +0 -0
  258. /package/{cjs → src}/ObjectStorage.js +0 -0
  259. /package/{cjs → src}/Process.js +0 -0
  260. /package/{cjs → src}/PtyHandle.js +0 -0
  261. /package/{cjs → src}/Volume.js +0 -0
  262. /package/{cjs → src}/code-toolbox/SandboxJsCodeToolbox.js +0 -0
  263. /package/{cjs → src}/code-toolbox/SandboxPythonCodeToolbox.js +0 -0
  264. /package/{cjs → src}/code-toolbox/SandboxTsCodeToolbox.js +0 -0
  265. /package/{cjs → src}/errors/DaytonaError.js +0 -0
  266. /package/{cjs → src}/index.js +0 -0
  267. /package/{cjs → src}/types/Charts.js +0 -0
  268. /package/{cjs → src}/types/CodeInterpreter.js +0 -0
  269. /package/{cjs → src}/types/ExecuteResponse.js +0 -0
  270. /package/{cjs → src}/types/Pty.js +0 -0
  271. /package/{cjs → src}/utils/ArtifactParser.js +0 -0
  272. /package/{cjs → src}/utils/Binary.js +0 -0
  273. /package/{cjs → src}/utils/FileTransfer.js +0 -0
  274. /package/{cjs → src}/utils/Multipart.js +0 -0
  275. /package/{cjs → src}/utils/Runtime.js +0 -0
  276. /package/{cjs → src}/utils/Stream.js +0 -0
  277. /package/{cjs → src}/utils/WebSocket.js +0 -0
@@ -1,155 +0,0 @@
1
- import WebSocket from 'isomorphic-ws';
2
- import { PtyResult } from './types/Pty.js';
3
- import { PtySessionInfo } from '@daytonaio/toolbox-api-client';
4
- /**
5
- * PTY session handle for managing a single PTY session.
6
- *
7
- * Provides methods for sending input, resizing the terminal, waiting for completion,
8
- * and managing the WebSocket connection to a PTY session.
9
- *
10
- * @example
11
- * ```typescript
12
- * // Create a PTY session
13
- * const ptyHandle = await process.createPty({
14
- * id: 'my-session',
15
- * cols: 120,
16
- * rows: 30,
17
- * onData: (data) => {
18
- * const text = new TextDecoder().decode(data);
19
- * process.stdout.write(text);
20
- * },
21
- * });
22
- *
23
- *
24
- * // Send commands
25
- * await ptyHandle.sendInput('ls -la\n');
26
- * await ptyHandle.sendInput('exit\n');
27
- *
28
- * // Wait for completion
29
- * const result = await ptyHandle.wait();
30
- * console.log(`PTY exited with code: ${result.exitCode}`);
31
- *
32
- * // Clean up
33
- * await ptyHandle.disconnect();
34
- * ```
35
- */
36
- export declare class PtyHandle {
37
- private readonly ws;
38
- private readonly handleResize;
39
- private readonly handleKill;
40
- private readonly onPty;
41
- readonly sessionId: string;
42
- private _exitCode?;
43
- private _error?;
44
- private connected;
45
- private connectionEstablished;
46
- constructor(ws: WebSocket, handleResize: (cols: number, rows: number) => Promise<PtySessionInfo>, handleKill: () => Promise<void>, onPty: (data: Uint8Array) => void | Promise<void>, sessionId: string);
47
- /**
48
- * Exit code of the PTY process (if terminated)
49
- */
50
- get exitCode(): number | undefined;
51
- /**
52
- * Error message if the PTY failed
53
- */
54
- get error(): string | undefined;
55
- /**
56
- * Check if connected to the PTY session
57
- */
58
- isConnected(): boolean;
59
- /**
60
- * Wait for the WebSocket connection to be established.
61
- *
62
- * This method ensures the PTY session is ready to receive input and send output.
63
- * It waits for the server to confirm the connection is established.
64
- *
65
- * @throws {Error} If connection times out (10 seconds) or connection fails
66
- */
67
- waitForConnection(): Promise<void>;
68
- /**
69
- * Send input data to the PTY session.
70
- *
71
- * Sends keyboard input or commands to the terminal session. The data will be
72
- * processed as if it was typed in the terminal.
73
- *
74
- * @param {string | Uint8Array} data - Input data to send (commands, keystrokes, etc.)
75
- * @throws {Error} If PTY is not connected or sending fails
76
- *
77
- * @example
78
- * // Send a command
79
- * await ptyHandle.sendInput('ls -la\n');
80
- *
81
- * // Send raw bytes
82
- * await ptyHandle.sendInput(new Uint8Array([3])); // Ctrl+C
83
- */
84
- sendInput(data: string | Uint8Array): Promise<void>;
85
- /**
86
- * Resize the PTY terminal dimensions.
87
- *
88
- * Changes the terminal size which will notify terminal applications
89
- * about the new dimensions via SIGWINCH signal.
90
- *
91
- * @param {number} cols - New number of terminal columns
92
- * @param {number} rows - New number of terminal rows
93
- *
94
- * @example
95
- * // Resize to 120x30
96
- * await ptyHandle.resize(120, 30);
97
- */
98
- resize(cols: number, rows: number): Promise<PtySessionInfo>;
99
- /**
100
- * Disconnect from the PTY session and clean up resources.
101
- *
102
- * Closes the WebSocket connection and releases any associated resources.
103
- * Should be called when done with the PTY session.
104
- *
105
- * @example
106
- * // Always clean up when done
107
- * try {
108
- * // ... use PTY session
109
- * } finally {
110
- * await ptyHandle.disconnect();
111
- * }
112
- */
113
- disconnect(): Promise<void>;
114
- /**
115
- * Wait for the PTY process to exit and return the result.
116
- *
117
- * This method blocks until the PTY process terminates and returns
118
- * information about how it exited.
119
- *
120
- * @returns {Promise<PtyResult>} Result containing exit code and error information
121
- *
122
- * @example
123
- * // Wait for process to complete
124
- * const result = await ptyHandle.wait();
125
- *
126
- * if (result.exitCode === 0) {
127
- * console.log('Process completed successfully');
128
- * } else {
129
- * console.log(`Process failed with code: ${result.exitCode}`);
130
- * if (result.error) {
131
- * console.log(`Error: ${result.error}`);
132
- * }
133
- * }
134
- */
135
- wait(): Promise<PtyResult>;
136
- /**
137
- * Kill the PTY process and terminate the session.
138
- *
139
- * Forcefully terminates the PTY session and its associated process.
140
- * This operation is irreversible and will cause the PTY to exit immediately.
141
- *
142
- * @throws {Error} If the kill operation fails
143
- *
144
- * @example
145
- * // Kill a long-running process
146
- * await ptyHandle.kill();
147
- *
148
- * // Wait to confirm termination
149
- * const result = await ptyHandle.wait();
150
- * console.log(`Process terminated with exit code: ${result.exitCode}`);
151
- */
152
- kill(): Promise<void>;
153
- private setupWebSocketHandlers;
154
- }
155
- //# sourceMappingURL=PtyHandle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PtyHandle.d.ts","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/PtyHandle.ts"],"names":[],"mappings":"AAKA,OAAO,SAAS,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,SAAS;IAOlB,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM;IAV5B,OAAO,CAAC,SAAS,CAAC,CAAQ;IAC1B,OAAO,CAAC,MAAM,CAAC,CAAQ;IACvB,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,qBAAqB,CAAQ;gBAGlB,EAAE,EAAE,SAAS,EACb,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,EACrE,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC/B,KAAK,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EACzD,SAAS,EAAE,MAAM;IAK5B;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,GAAG,SAAS,CAEjC;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;;;;;;OAOG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IA0BxC;;;;;;;;;;;;;;;OAeG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBzD;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAIjE;;;;;;;;;;;;;OAaG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAUjC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,IAAI,IAAI,OAAO,CAAC,SAAS,CAAC;IA2BhC;;;;;;;;;;;;;;;OAeG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,OAAO,CAAC,sBAAsB;CA+H/B"}
package/esm/PtyHandle.js DELETED
@@ -1,374 +0,0 @@
1
- /*
2
- * Copyright 2025 Daytona Platforms Inc.
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- import WebSocket from 'isomorphic-ws';
6
- import { DaytonaError } from './errors/DaytonaError.js';
7
- /**
8
- * PTY session handle for managing a single PTY session.
9
- *
10
- * Provides methods for sending input, resizing the terminal, waiting for completion,
11
- * and managing the WebSocket connection to a PTY session.
12
- *
13
- * @example
14
- * ```typescript
15
- * // Create a PTY session
16
- * const ptyHandle = await process.createPty({
17
- * id: 'my-session',
18
- * cols: 120,
19
- * rows: 30,
20
- * onData: (data) => {
21
- * const text = new TextDecoder().decode(data);
22
- * process.stdout.write(text);
23
- * },
24
- * });
25
- *
26
- *
27
- * // Send commands
28
- * await ptyHandle.sendInput('ls -la\n');
29
- * await ptyHandle.sendInput('exit\n');
30
- *
31
- * // Wait for completion
32
- * const result = await ptyHandle.wait();
33
- * console.log(`PTY exited with code: ${result.exitCode}`);
34
- *
35
- * // Clean up
36
- * await ptyHandle.disconnect();
37
- * ```
38
- */
39
- export class PtyHandle {
40
- ws;
41
- handleResize;
42
- handleKill;
43
- onPty;
44
- sessionId;
45
- _exitCode;
46
- _error;
47
- connected = false;
48
- connectionEstablished = false; // Track control message received
49
- constructor(ws, handleResize, handleKill, onPty, sessionId) {
50
- this.ws = ws;
51
- this.handleResize = handleResize;
52
- this.handleKill = handleKill;
53
- this.onPty = onPty;
54
- this.sessionId = sessionId;
55
- this.setupWebSocketHandlers();
56
- }
57
- /**
58
- * Exit code of the PTY process (if terminated)
59
- */
60
- get exitCode() {
61
- return this._exitCode;
62
- }
63
- /**
64
- * Error message if the PTY failed
65
- */
66
- get error() {
67
- return this._error;
68
- }
69
- /**
70
- * Check if connected to the PTY session
71
- */
72
- isConnected() {
73
- return this.connected && this.ws.readyState === WebSocket.OPEN;
74
- }
75
- /**
76
- * Wait for the WebSocket connection to be established.
77
- *
78
- * This method ensures the PTY session is ready to receive input and send output.
79
- * It waits for the server to confirm the connection is established.
80
- *
81
- * @throws {Error} If connection times out (10 seconds) or connection fails
82
- */
83
- async waitForConnection() {
84
- if (this.connectionEstablished) {
85
- return;
86
- }
87
- return new Promise((resolve, reject) => {
88
- const timeout = setTimeout(() => {
89
- reject(new DaytonaError('PTY connection timeout'));
90
- }, 10000); // 10 second timeout
91
- const checkConnection = () => {
92
- if (this.connectionEstablished) {
93
- clearTimeout(timeout);
94
- resolve();
95
- }
96
- else if (this.ws.readyState === WebSocket.CLOSED || this._error) {
97
- clearTimeout(timeout);
98
- reject(new DaytonaError(this._error || 'Connection failed'));
99
- }
100
- else {
101
- setTimeout(checkConnection, 100);
102
- }
103
- };
104
- checkConnection();
105
- });
106
- }
107
- /**
108
- * Send input data to the PTY session.
109
- *
110
- * Sends keyboard input or commands to the terminal session. The data will be
111
- * processed as if it was typed in the terminal.
112
- *
113
- * @param {string | Uint8Array} data - Input data to send (commands, keystrokes, etc.)
114
- * @throws {Error} If PTY is not connected or sending fails
115
- *
116
- * @example
117
- * // Send a command
118
- * await ptyHandle.sendInput('ls -la\n');
119
- *
120
- * // Send raw bytes
121
- * await ptyHandle.sendInput(new Uint8Array([3])); // Ctrl+C
122
- */
123
- async sendInput(data) {
124
- if (!this.isConnected()) {
125
- throw new DaytonaError('PTY is not connected');
126
- }
127
- try {
128
- if (typeof data === 'string') {
129
- this.ws.send(new TextEncoder().encode(data));
130
- }
131
- else {
132
- this.ws.send(data);
133
- }
134
- }
135
- catch (error) {
136
- const errorMessage = error instanceof Error ? error.message : String(error);
137
- throw new DaytonaError(`Failed to send input to PTY: ${errorMessage}`);
138
- }
139
- }
140
- /**
141
- * Resize the PTY terminal dimensions.
142
- *
143
- * Changes the terminal size which will notify terminal applications
144
- * about the new dimensions via SIGWINCH signal.
145
- *
146
- * @param {number} cols - New number of terminal columns
147
- * @param {number} rows - New number of terminal rows
148
- *
149
- * @example
150
- * // Resize to 120x30
151
- * await ptyHandle.resize(120, 30);
152
- */
153
- async resize(cols, rows) {
154
- return await this.handleResize(cols, rows);
155
- }
156
- /**
157
- * Disconnect from the PTY session and clean up resources.
158
- *
159
- * Closes the WebSocket connection and releases any associated resources.
160
- * Should be called when done with the PTY session.
161
- *
162
- * @example
163
- * // Always clean up when done
164
- * try {
165
- * // ... use PTY session
166
- * } finally {
167
- * await ptyHandle.disconnect();
168
- * }
169
- */
170
- async disconnect() {
171
- if (this.ws) {
172
- try {
173
- this.ws.close();
174
- }
175
- catch {
176
- // Ignore close errors
177
- }
178
- }
179
- }
180
- /**
181
- * Wait for the PTY process to exit and return the result.
182
- *
183
- * This method blocks until the PTY process terminates and returns
184
- * information about how it exited.
185
- *
186
- * @returns {Promise<PtyResult>} Result containing exit code and error information
187
- *
188
- * @example
189
- * // Wait for process to complete
190
- * const result = await ptyHandle.wait();
191
- *
192
- * if (result.exitCode === 0) {
193
- * console.log('Process completed successfully');
194
- * } else {
195
- * console.log(`Process failed with code: ${result.exitCode}`);
196
- * if (result.error) {
197
- * console.log(`Error: ${result.error}`);
198
- * }
199
- * }
200
- */
201
- async wait() {
202
- return new Promise((resolve, reject) => {
203
- if (this._exitCode !== undefined) {
204
- resolve({
205
- exitCode: this._exitCode,
206
- error: this._error,
207
- });
208
- return;
209
- }
210
- const checkExit = () => {
211
- if (this._exitCode !== undefined) {
212
- resolve({
213
- exitCode: this._exitCode,
214
- error: this._error,
215
- });
216
- }
217
- else if (this._error) {
218
- reject(new DaytonaError(this._error));
219
- }
220
- else {
221
- setTimeout(checkExit, 100);
222
- }
223
- };
224
- checkExit();
225
- });
226
- }
227
- /**
228
- * Kill the PTY process and terminate the session.
229
- *
230
- * Forcefully terminates the PTY session and its associated process.
231
- * This operation is irreversible and will cause the PTY to exit immediately.
232
- *
233
- * @throws {Error} If the kill operation fails
234
- *
235
- * @example
236
- * // Kill a long-running process
237
- * await ptyHandle.kill();
238
- *
239
- * // Wait to confirm termination
240
- * const result = await ptyHandle.wait();
241
- * console.log(`Process terminated with exit code: ${result.exitCode}`);
242
- */
243
- async kill() {
244
- return await this.handleKill();
245
- }
246
- setupWebSocketHandlers() {
247
- // Set binary type for binary data handling
248
- if ('binaryType' in this.ws) {
249
- this.ws.binaryType = 'arraybuffer';
250
- }
251
- // Handle WebSocket open
252
- const handleOpen = async () => {
253
- this.connected = true;
254
- };
255
- // Handle WebSocket messages - control messages and PTY data
256
- const handleMessage = async (event) => {
257
- try {
258
- const data = event && typeof event === 'object' && 'data' in event ? event.data : event;
259
- if (typeof data === 'string') {
260
- // Try to parse as control message first
261
- try {
262
- const controlMsg = JSON.parse(data);
263
- if (controlMsg.type === 'control') {
264
- if (controlMsg.status === 'connected') {
265
- this.connectionEstablished = true;
266
- return;
267
- }
268
- else if (controlMsg.status === 'error') {
269
- this._error = controlMsg.error || 'Unknown connection error';
270
- this.connected = false;
271
- return;
272
- }
273
- }
274
- }
275
- catch {
276
- // Not a control message, treat as PTY output
277
- }
278
- // Regular PTY text output
279
- if (this.onPty) {
280
- await this.onPty(new TextEncoder().encode(data));
281
- }
282
- }
283
- else {
284
- // Handle binary data (terminal output)
285
- let bytes;
286
- if (data instanceof ArrayBuffer) {
287
- bytes = new Uint8Array(data);
288
- }
289
- else if (ArrayBuffer.isView(data)) {
290
- bytes = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
291
- }
292
- else if (data instanceof Blob) {
293
- const buffer = await data.arrayBuffer();
294
- bytes = new Uint8Array(buffer);
295
- }
296
- else {
297
- throw new DaytonaError(`Unsupported message data type: ${Object.prototype.toString.call(data)}`);
298
- }
299
- if (this.onPty) {
300
- await this.onPty(bytes);
301
- }
302
- }
303
- }
304
- catch (error) {
305
- const errorMessage = error instanceof Error ? error.message : String(error);
306
- throw new DaytonaError(`Error handling PTY message: ${errorMessage}`);
307
- }
308
- };
309
- // Handle WebSocket errors
310
- const handleError = async (error) => {
311
- let errorMessage;
312
- if (error instanceof Error) {
313
- errorMessage = error.message;
314
- }
315
- else if (error && error instanceof Event) {
316
- errorMessage = 'WebSocket connection error';
317
- }
318
- else {
319
- errorMessage = String(error);
320
- }
321
- this._error = errorMessage;
322
- this.connected = false;
323
- };
324
- // Handle WebSocket close - parse structured exit data
325
- const handleClose = async (event) => {
326
- this.connected = false;
327
- // Parse structured exit data from close reason
328
- if (event && event.reason) {
329
- try {
330
- const exitData = JSON.parse(event.reason);
331
- if (typeof exitData.exitCode === 'number') {
332
- this._exitCode = exitData.exitCode;
333
- // Store exit reason if provided (undefined for exitCode 0)
334
- if (exitData.exitReason) {
335
- this._error = exitData.exitReason;
336
- }
337
- }
338
- // Handle error messages from server (e.g., "PTY session not found")
339
- if (exitData.error) {
340
- this._error = exitData.error;
341
- }
342
- }
343
- catch {
344
- if (event.code === 1000) {
345
- this._exitCode = 0;
346
- }
347
- }
348
- }
349
- // Default to exit code 0 if we can't parse it and it was a normal close
350
- if (this._exitCode === undefined && event && event.code === 1000) {
351
- this._exitCode = 0;
352
- }
353
- };
354
- // Attach event listeners based on WebSocket implementation
355
- if (this.ws.addEventListener) {
356
- // Browser WebSocket
357
- this.ws.addEventListener('open', handleOpen);
358
- this.ws.addEventListener('message', handleMessage);
359
- this.ws.addEventListener('error', handleError);
360
- this.ws.addEventListener('close', handleClose);
361
- }
362
- else if ('on' in this.ws && typeof this.ws.on === 'function') {
363
- // Node.js WebSocket
364
- this.ws.on('open', handleOpen);
365
- this.ws.on('message', handleMessage);
366
- this.ws.on('error', handleError);
367
- this.ws.on('close', handleClose);
368
- }
369
- else {
370
- throw new DaytonaError('Unsupported WebSocket implementation');
371
- }
372
- }
373
- }
374
- //# sourceMappingURL=PtyHandle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PtyHandle.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/PtyHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,SAAS,MAAM,eAAe,CAAA;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAGpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,OAAO,SAAS;IAOD;IACA;IACA;IACA;IACR;IAVH,SAAS,CAAS;IAClB,MAAM,CAAS;IACf,SAAS,GAAG,KAAK,CAAA;IACjB,qBAAqB,GAAG,KAAK,CAAA,CAAC,iCAAiC;IAEvE,YACmB,EAA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B;YACpB,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;YAC5C,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;YAClD,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;YAC9C,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;QAChD,CAAC;aAAM,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,UAAU,EAAE,CAAC;YAC/D,oBAAoB;YACpB,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;YAC9B,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;YACpC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;YAChC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;QAClC,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,YAAY,CAAC,sCAAsC,CAAC,CAAA;QAChE,CAAC;IACH,CAAC;CACF"}
package/esm/README.md DELETED
@@ -1,147 +0,0 @@
1
- # Daytona SDK for TypeScript
2
-
3
- A TypeScript SDK for interacting with the Daytona API, providing a simple interface for Daytona Sandbox management, Git operations, file system operations, and language server protocol support.
4
-
5
- ## Installation
6
-
7
- You can install the package using npm:
8
-
9
- ```bash
10
- npm install @daytonaio/sdk
11
- ```
12
-
13
- Or using yarn:
14
-
15
- ```bash
16
- yarn add @daytonaio/sdk
17
- ```
18
-
19
- ## Quick Start
20
-
21
- Here's a simple example of using the SDK:
22
-
23
- ```typescript
24
- import { Daytona } from '@daytonaio/sdk'
25
-
26
- // Initialize using environment variables
27
- const daytona = new Daytona()
28
-
29
- // Create a sandbox
30
- const sandbox = await daytona.create()
31
-
32
- // Run code in the sandbox
33
- const response = await sandbox.process.codeRun('console.log("Hello World!")')
34
- console.log(response.result)
35
-
36
- // Clean up when done
37
- await daytona.delete(sandbox)
38
- ```
39
-
40
- ## Configuration
41
-
42
- The SDK can be configured using environment variables or by passing a configuration object:
43
-
44
- ```typescript
45
- import { Daytona } from '@daytonaio/sdk'
46
-
47
- // Initialize with configuration
48
- const daytona = new Daytona({
49
- apiKey: 'your-api-key',
50
- apiUrl: 'your-api-url',
51
- target: 'us',
52
- })
53
- ```
54
-
55
- Or using environment variables:
56
-
57
- - `DAYTONA_API_KEY`: Your Daytona API key
58
- - `DAYTONA_API_URL`: The Daytona API URL
59
- - `DAYTONA_TARGET`: Your target environment
60
-
61
- You can also customize sandbox creation:
62
-
63
- ```typescript
64
- const sandbox = await daytona.create({
65
- language: 'typescript',
66
- envVars: { NODE_ENV: 'development' },
67
- autoStopInterval: 60, // Auto-stop after 1 hour of inactivity,
68
- autoArchiveInterval: 60, // Auto-archive after a Sandbox has been stopped for 1 hour
69
- autoDeleteInterval: 120, // Auto-delete after a Sandbox has been stopped for 2 hours
70
- })
71
- ```
72
-
73
- ## Features
74
-
75
- - **Sandbox Management**: Create, manage and remove sandboxes
76
- - **Git Operations**: Clone repositories, manage branches, and more
77
- - **File System Operations**: Upload, download, search and manipulate files
78
- - **Language Server Protocol**: Interact with language servers for code intelligence
79
- - **Process Management**: Execute code and commands in sandboxes
80
-
81
- ## Examples
82
-
83
- ### Execute Commands
84
-
85
- ```typescript
86
- // Execute a shell command
87
- const response = await sandbox.process.executeCommand('echo "Hello, World!"')
88
- console.log(response.result)
89
-
90
- // Run TypeScript code
91
- const response = await sandbox.process.codeRun(`
92
- const x = 10
93
- const y = 20
94
- console.log(\`Sum: \${x + y}\`)
95
- `)
96
- console.log(response.result)
97
- ```
98
-
99
- ### File Operations
100
-
101
- ```typescript
102
- // Upload a file
103
- await sandbox.fs.uploadFile(Buffer.from('Hello, World!'), 'path/to/file.txt')
104
-
105
- // Download a file
106
- const content = await sandbox.fs.downloadFile('path/to/file.txt')
107
-
108
- // Search for files
109
- const matches = await sandbox.fs.findFiles(root_dir, 'search_pattern')
110
- ```
111
-
112
- ### Git Operations
113
-
114
- ```typescript
115
- // Clone a repository
116
- await sandbox.git.clone('https://github.com/example/repo', 'path/to/clone')
117
-
118
- // List branches
119
- const branches = await sandbox.git.branches('path/to/repo')
120
-
121
- // Add files
122
- await sandbox.git.add('path/to/repo', ['file1.txt', 'file2.txt'])
123
- ```
124
-
125
- ### Language Server Protocol
126
-
127
- ```typescript
128
- // Create and start a language server
129
- const lsp = await sandbox.createLspServer('typescript', 'path/to/project')
130
- await lsp.start()
131
-
132
- // Notify the lsp for the file
133
- await lsp.didOpen('path/to/file.ts')
134
-
135
- // Get document symbols
136
- const symbols = await lsp.documentSymbols('path/to/file.ts')
137
-
138
- // Get completions
139
- const completions = await lsp.completions('path/to/file.ts', {
140
- line: 10,
141
- character: 15,
142
- })
143
- ```
144
-
145
- ## Contributing
146
-
147
- Daytona is Open Source under the [Apache License 2.0](/libs/sdk-typescript//LICENSE), and is the [copyright of its contributors](/NOTICE). If you would like to contribute to the software, read the Developer Certificate of Origin Version 1.1 (https://developercertificate.org/). Afterwards, navigate to the [contributing guide](/CONTRIBUTING.md) to get started.