@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,808 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Daytona Platforms Inc.
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ComputerUse = exports.RecordingService = exports.Display = exports.Screenshot = exports.Keyboard = exports.Mouse = void 0;
8
+ const tslib_1 = require("tslib");
9
+ const pathe = tslib_1.__importStar(require("pathe"));
10
+ const Import_1 = require("./utils/Import");
11
+ const otel_decorator_1 = require("./utils/otel.decorator");
12
+ /**
13
+ * Mouse operations for computer use functionality
14
+ */
15
+ class Mouse {
16
+ apiClient;
17
+ constructor(apiClient) {
18
+ this.apiClient = apiClient;
19
+ }
20
+ /**
21
+ * Gets the current mouse cursor position
22
+ *
23
+ * @returns {Promise<MousePositionResponse>} Current mouse position with x and y coordinates
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const position = await sandbox.computerUse.mouse.getPosition();
28
+ * console.log(`Mouse is at: ${position.x}, ${position.y}`);
29
+ * ```
30
+ */
31
+ async getPosition() {
32
+ const response = await this.apiClient.getMousePosition();
33
+ return response.data;
34
+ }
35
+ /**
36
+ * Moves the mouse cursor to the specified coordinates
37
+ *
38
+ * @param {number} x - The x coordinate to move to
39
+ * @param {number} y - The y coordinate to move to
40
+ * @returns {Promise<MousePositionResponse>} Position after move
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const result = await sandbox.computerUse.mouse.move(100, 200);
45
+ * console.log(`Mouse moved to: ${result.x}, ${result.y}`);
46
+ * ```
47
+ */
48
+ async move(x, y) {
49
+ const request = { x, y };
50
+ const response = await this.apiClient.moveMouse(request);
51
+ return response.data;
52
+ }
53
+ /**
54
+ * Clicks the mouse at the specified coordinates
55
+ *
56
+ * @param {number} x - The x coordinate to click at
57
+ * @param {number} y - The y coordinate to click at
58
+ * @param {string} [button='left'] - The mouse button to click ('left', 'right', 'middle')
59
+ * @param {boolean} [double=false] - Whether to perform a double-click
60
+ * @returns {Promise<MouseClickResponse>} Click operation result
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * // Single left click
65
+ * const result = await sandbox.computerUse.mouse.click(100, 200);
66
+ *
67
+ * // Double click
68
+ * const doubleClick = await sandbox.computerUse.mouse.click(100, 200, 'left', true);
69
+ *
70
+ * // Right click
71
+ * const rightClick = await sandbox.computerUse.mouse.click(100, 200, 'right');
72
+ * ```
73
+ */
74
+ async click(x, y, button = 'left', double = false) {
75
+ const request = { x, y, button, double };
76
+ const response = await this.apiClient.click(request);
77
+ return response.data;
78
+ }
79
+ /**
80
+ * Drags the mouse from start coordinates to end coordinates
81
+ *
82
+ * @param {number} startX - The starting x coordinate
83
+ * @param {number} startY - The starting y coordinate
84
+ * @param {number} endX - The ending x coordinate
85
+ * @param {number} endY - The ending y coordinate
86
+ * @param {string} [button='left'] - The mouse button to use for dragging
87
+ * @returns {Promise<MouseDragResponse>} Drag operation result
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const result = await sandbox.computerUse.mouse.drag(50, 50, 150, 150);
92
+ * console.log(`Drag ended at: ${result.x}, ${result.y}`);
93
+ * ```
94
+ */
95
+ async drag(startX, startY, endX, endY, button = 'left') {
96
+ const request = { startX, startY, endX, endY, button };
97
+ const response = await this.apiClient.drag(request);
98
+ return response.data;
99
+ }
100
+ /**
101
+ * Scrolls the mouse wheel at the specified coordinates
102
+ *
103
+ * @param {number} x - The x coordinate to scroll at
104
+ * @param {number} y - The y coordinate to scroll at
105
+ * @param {'up' | 'down'} direction - The direction to scroll
106
+ * @param {number} [amount=1] - The amount to scroll
107
+ * @returns {Promise<boolean>} Whether the scroll operation was successful
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * // Scroll up
112
+ * const scrollUp = await sandbox.computerUse.mouse.scroll(100, 200, 'up', 3);
113
+ *
114
+ * // Scroll down
115
+ * const scrollDown = await sandbox.computerUse.mouse.scroll(100, 200, 'down', 5);
116
+ * ```
117
+ */
118
+ async scroll(x, y, direction, amount = 1) {
119
+ const request = { x, y, direction, amount };
120
+ const response = await this.apiClient.scroll(request);
121
+ return response.data.success;
122
+ }
123
+ }
124
+ exports.Mouse = Mouse;
125
+ tslib_1.__decorate([
126
+ (0, otel_decorator_1.WithInstrumentation)(),
127
+ tslib_1.__metadata("design:type", Function),
128
+ tslib_1.__metadata("design:paramtypes", []),
129
+ tslib_1.__metadata("design:returntype", Promise)
130
+ ], Mouse.prototype, "getPosition", null);
131
+ tslib_1.__decorate([
132
+ (0, otel_decorator_1.WithInstrumentation)(),
133
+ tslib_1.__metadata("design:type", Function),
134
+ tslib_1.__metadata("design:paramtypes", [Number, Number]),
135
+ tslib_1.__metadata("design:returntype", Promise)
136
+ ], Mouse.prototype, "move", null);
137
+ tslib_1.__decorate([
138
+ (0, otel_decorator_1.WithInstrumentation)(),
139
+ tslib_1.__metadata("design:type", Function),
140
+ tslib_1.__metadata("design:paramtypes", [Number, Number, Object, Object]),
141
+ tslib_1.__metadata("design:returntype", Promise)
142
+ ], Mouse.prototype, "click", null);
143
+ tslib_1.__decorate([
144
+ (0, otel_decorator_1.WithInstrumentation)(),
145
+ tslib_1.__metadata("design:type", Function),
146
+ tslib_1.__metadata("design:paramtypes", [Number, Number, Number, Number, Object]),
147
+ tslib_1.__metadata("design:returntype", Promise)
148
+ ], Mouse.prototype, "drag", null);
149
+ tslib_1.__decorate([
150
+ (0, otel_decorator_1.WithInstrumentation)(),
151
+ tslib_1.__metadata("design:type", Function),
152
+ tslib_1.__metadata("design:paramtypes", [Number, Number, String, Object]),
153
+ tslib_1.__metadata("design:returntype", Promise)
154
+ ], Mouse.prototype, "scroll", null);
155
+ /**
156
+ * Keyboard operations for computer use functionality
157
+ */
158
+ class Keyboard {
159
+ apiClient;
160
+ constructor(apiClient) {
161
+ this.apiClient = apiClient;
162
+ }
163
+ /**
164
+ * Types the specified text
165
+ *
166
+ * @param {string} text - The text to type
167
+ * @param {number} [delay=0] - Delay between characters in milliseconds
168
+ * @throws {DaytonaError} If the type operation fails
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * try {
173
+ * await sandbox.computerUse.keyboard.type('Hello, World!');
174
+ * console.log('Operation success');
175
+ * } catch (e) {
176
+ * console.log('Operation failed:', e);
177
+ * }
178
+ *
179
+ * // With delay between characters
180
+ * try {
181
+ * await sandbox.computerUse.keyboard.type('Slow typing', 100);
182
+ * console.log('Operation success');
183
+ * } catch (e) {
184
+ * console.log('Operation failed:', e);
185
+ * }
186
+ * ```
187
+ */
188
+ async type(text, delay) {
189
+ const request = { text, delay };
190
+ await this.apiClient.typeText(request);
191
+ }
192
+ /**
193
+ * Presses a key with optional modifiers
194
+ *
195
+ * @param {string} key - The key to press. Canonical names include 'enter', 'escape', 'tab', letters, digits, unshifted punctuation, function keys, and grammar-safe numpad names such as 'num_plus'. Named keys are case-insensitive, and common aliases such as 'Return' and 'Escape' are normalized.
196
+ * @param {string[]} [modifiers=[]] - Canonical modifier names are 'ctrl', 'alt', 'shift', and 'cmd'. Common aliases such as 'control', 'option', 'meta', and 'win' are normalized.
197
+ * @throws {DaytonaError} If the press operation fails
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * // Press Enter
202
+ * try {
203
+ * await sandbox.computerUse.keyboard.press('enter');
204
+ * console.log('Operation success');
205
+ * } catch (e) {
206
+ * console.log('Operation failed:', e);
207
+ * }
208
+ *
209
+ * // Press Ctrl+C
210
+ * try {
211
+ * await sandbox.computerUse.keyboard.press('c', ['ctrl']);
212
+ * console.log('Operation success');
213
+ * } catch (e) {
214
+ * console.log('Operation failed:', e);
215
+ * }
216
+ *
217
+ * // Press Ctrl+Shift+T
218
+ * try {
219
+ * await sandbox.computerUse.keyboard.press('t', ['ctrl', 'shift']);
220
+ * console.log('Operation success');
221
+ * } catch (e) {
222
+ * console.log('Operation failed:', e);
223
+ * }
224
+ * ```
225
+ */
226
+ async press(key, modifiers = []) {
227
+ const request = { key, modifiers };
228
+ await this.apiClient.pressKey(request);
229
+ }
230
+ /**
231
+ * Presses a hotkey combination
232
+ *
233
+ * @param {string} keys - A single atomic hotkey chord (e.g., 'ctrl+c', 'alt+tab', 'cmd+shift+t', 'ctrl + c', 'shift'). Uses the same normalized key contract as `press()`.
234
+ * @throws {DaytonaError} If the hotkey operation fails
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * // Copy
239
+ * try {
240
+ * await sandbox.computerUse.keyboard.hotkey('ctrl+c');
241
+ * console.log('Operation success');
242
+ * } catch (e) {
243
+ * console.log('Operation failed:', e);
244
+ * }
245
+ *
246
+ * // Paste
247
+ * try {
248
+ * await sandbox.computerUse.keyboard.hotkey('ctrl+v');
249
+ * console.log('Operation success');
250
+ * } catch (e) {
251
+ * console.log('Operation failed:', e);
252
+ * }
253
+ *
254
+ * // Alt+Tab
255
+ * try {
256
+ * await sandbox.computerUse.keyboard.hotkey('alt+tab');
257
+ * console.log('Operation success');
258
+ * } catch (e) {
259
+ * console.log('Operation failed:', e);
260
+ * }
261
+ * ```
262
+ */
263
+ async hotkey(keys) {
264
+ const request = { keys };
265
+ await this.apiClient.pressHotkey(request);
266
+ }
267
+ }
268
+ exports.Keyboard = Keyboard;
269
+ tslib_1.__decorate([
270
+ (0, otel_decorator_1.WithInstrumentation)(),
271
+ tslib_1.__metadata("design:type", Function),
272
+ tslib_1.__metadata("design:paramtypes", [String, Number]),
273
+ tslib_1.__metadata("design:returntype", Promise)
274
+ ], Keyboard.prototype, "type", null);
275
+ tslib_1.__decorate([
276
+ (0, otel_decorator_1.WithInstrumentation)(),
277
+ tslib_1.__metadata("design:type", Function),
278
+ tslib_1.__metadata("design:paramtypes", [String, Array]),
279
+ tslib_1.__metadata("design:returntype", Promise)
280
+ ], Keyboard.prototype, "press", null);
281
+ tslib_1.__decorate([
282
+ (0, otel_decorator_1.WithInstrumentation)(),
283
+ tslib_1.__metadata("design:type", Function),
284
+ tslib_1.__metadata("design:paramtypes", [String]),
285
+ tslib_1.__metadata("design:returntype", Promise)
286
+ ], Keyboard.prototype, "hotkey", null);
287
+ /**
288
+ * Screenshot operations for computer use functionality
289
+ */
290
+ class Screenshot {
291
+ apiClient;
292
+ constructor(apiClient) {
293
+ this.apiClient = apiClient;
294
+ }
295
+ /**
296
+ * Takes a screenshot of the entire screen
297
+ *
298
+ * @param {boolean} [showCursor=false] - Whether to show the cursor in the screenshot
299
+ * @returns {Promise<ScreenshotResponse>} Screenshot data with base64 encoded image
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * const screenshot = await sandbox.computerUse.screenshot.takeFullScreen();
304
+ * console.log(`Screenshot size: ${screenshot.width}x${screenshot.height}`);
305
+ *
306
+ * // With cursor visible
307
+ * const withCursor = await sandbox.computerUse.screenshot.takeFullScreen(true);
308
+ * ```
309
+ */
310
+ async takeFullScreen(showCursor = false) {
311
+ const response = await this.apiClient.takeScreenshot(showCursor);
312
+ return response.data;
313
+ }
314
+ /**
315
+ * Takes a screenshot of a specific region
316
+ *
317
+ * @param {ScreenshotRegion} region - The region to capture
318
+ * @param {boolean} [showCursor=false] - Whether to show the cursor in the screenshot
319
+ * @returns {Promise<RegionScreenshotResponse>} Screenshot data with base64 encoded image
320
+ *
321
+ * @example
322
+ * ```typescript
323
+ * const region = { x: 100, y: 100, width: 300, height: 200 };
324
+ * const screenshot = await sandbox.computerUse.screenshot.takeRegion(region);
325
+ * console.log(`Captured region: ${screenshot.region.width}x${screenshot.region.height}`);
326
+ * ```
327
+ */
328
+ async takeRegion(region, showCursor = false) {
329
+ const response = await this.apiClient.takeRegionScreenshot(region.height, region.width, region.y, region.x, showCursor);
330
+ return response.data;
331
+ }
332
+ /**
333
+ * Takes a compressed screenshot of the entire screen
334
+ *
335
+ * @param {ScreenshotOptions} [options={}] - Compression and display options
336
+ * @returns {Promise<CompressedScreenshotResponse>} Compressed screenshot data
337
+ *
338
+ * @example
339
+ * ```typescript
340
+ * // Default compression
341
+ * const screenshot = await sandbox.computerUse.screenshot.takeCompressed();
342
+ *
343
+ * // High quality JPEG
344
+ * const jpeg = await sandbox.computerUse.screenshot.takeCompressed({
345
+ * format: 'jpeg',
346
+ * quality: 95,
347
+ * showCursor: true
348
+ * });
349
+ *
350
+ * // Scaled down PNG
351
+ * const scaled = await sandbox.computerUse.screenshot.takeCompressed({
352
+ * format: 'png',
353
+ * scale: 0.5
354
+ * });
355
+ * ```
356
+ */
357
+ async takeCompressed(options = {}) {
358
+ const response = await this.apiClient.takeCompressedScreenshot(options.showCursor, options.format, options.quality, options.scale);
359
+ return response.data;
360
+ }
361
+ /**
362
+ * Takes a compressed screenshot of a specific region
363
+ *
364
+ * @param {ScreenshotRegion} region - The region to capture
365
+ * @param {ScreenshotOptions} [options={}] - Compression and display options
366
+ * @returns {Promise<CompressedScreenshotResponse>} Compressed screenshot data
367
+ *
368
+ * @example
369
+ * ```typescript
370
+ * const region = { x: 0, y: 0, width: 800, height: 600 };
371
+ * const screenshot = await sandbox.computerUse.screenshot.takeCompressedRegion(region, {
372
+ * format: 'webp',
373
+ * quality: 80,
374
+ * showCursor: true
375
+ * });
376
+ * console.log(`Compressed size: ${screenshot.size_bytes} bytes`);
377
+ * ```
378
+ */
379
+ async takeCompressedRegion(region, options = {}) {
380
+ const response = await this.apiClient.takeCompressedRegionScreenshot(region.x, region.y, region.width, region.height, options.showCursor, options.format, options.quality, options.scale);
381
+ return response.data;
382
+ }
383
+ }
384
+ exports.Screenshot = Screenshot;
385
+ tslib_1.__decorate([
386
+ (0, otel_decorator_1.WithInstrumentation)(),
387
+ tslib_1.__metadata("design:type", Function),
388
+ tslib_1.__metadata("design:paramtypes", [Object]),
389
+ tslib_1.__metadata("design:returntype", Promise)
390
+ ], Screenshot.prototype, "takeFullScreen", null);
391
+ tslib_1.__decorate([
392
+ (0, otel_decorator_1.WithInstrumentation)(),
393
+ tslib_1.__metadata("design:type", Function),
394
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
395
+ tslib_1.__metadata("design:returntype", Promise)
396
+ ], Screenshot.prototype, "takeRegion", null);
397
+ tslib_1.__decorate([
398
+ (0, otel_decorator_1.WithInstrumentation)(),
399
+ tslib_1.__metadata("design:type", Function),
400
+ tslib_1.__metadata("design:paramtypes", [Object]),
401
+ tslib_1.__metadata("design:returntype", Promise)
402
+ ], Screenshot.prototype, "takeCompressed", null);
403
+ tslib_1.__decorate([
404
+ (0, otel_decorator_1.WithInstrumentation)(),
405
+ tslib_1.__metadata("design:type", Function),
406
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
407
+ tslib_1.__metadata("design:returntype", Promise)
408
+ ], Screenshot.prototype, "takeCompressedRegion", null);
409
+ /**
410
+ * Display operations for computer use functionality
411
+ */
412
+ class Display {
413
+ apiClient;
414
+ constructor(apiClient) {
415
+ this.apiClient = apiClient;
416
+ }
417
+ /**
418
+ * Gets information about the displays
419
+ *
420
+ * @returns {Promise<DisplayInfoResponse>} Display information including primary display and all available displays
421
+ *
422
+ * @example
423
+ * ```typescript
424
+ * const info = await sandbox.computerUse.display.getInfo();
425
+ * console.log(`Primary display: ${info.primary_display.width}x${info.primary_display.height}`);
426
+ * console.log(`Total displays: ${info.total_displays}`);
427
+ * info.displays.forEach((display, index) => {
428
+ * console.log(`Display ${index}: ${display.width}x${display.height} at ${display.x},${display.y}`);
429
+ * });
430
+ * ```
431
+ */
432
+ async getInfo() {
433
+ const response = await this.apiClient.getDisplayInfo();
434
+ return response.data;
435
+ }
436
+ /**
437
+ * Gets the list of open windows
438
+ *
439
+ * @returns {Promise<WindowsResponse>} List of open windows with their IDs and titles
440
+ *
441
+ * @example
442
+ * ```typescript
443
+ * const windows = await sandbox.computerUse.display.getWindows();
444
+ * console.log(`Found ${windows.count} open windows:`);
445
+ * windows.windows.forEach(window => {
446
+ * console.log(`- ${window.title} (ID: ${window.id})`);
447
+ * });
448
+ * ```
449
+ */
450
+ async getWindows() {
451
+ const response = await this.apiClient.getWindows();
452
+ return response.data;
453
+ }
454
+ }
455
+ exports.Display = Display;
456
+ tslib_1.__decorate([
457
+ (0, otel_decorator_1.WithInstrumentation)(),
458
+ tslib_1.__metadata("design:type", Function),
459
+ tslib_1.__metadata("design:paramtypes", []),
460
+ tslib_1.__metadata("design:returntype", Promise)
461
+ ], Display.prototype, "getInfo", null);
462
+ tslib_1.__decorate([
463
+ (0, otel_decorator_1.WithInstrumentation)(),
464
+ tslib_1.__metadata("design:type", Function),
465
+ tslib_1.__metadata("design:paramtypes", []),
466
+ tslib_1.__metadata("design:returntype", Promise)
467
+ ], Display.prototype, "getWindows", null);
468
+ /**
469
+ * Recording operations for computer use functionality.
470
+ */
471
+ class RecordingService {
472
+ apiClient;
473
+ constructor(apiClient) {
474
+ this.apiClient = apiClient;
475
+ }
476
+ /**
477
+ * Starts a new screen recording session
478
+ *
479
+ * @param {string} [label] - Optional custom label for the recording
480
+ * @returns {Promise<Recording>} Started recording details
481
+ *
482
+ * @example
483
+ * ```typescript
484
+ * // Start a recording with a label
485
+ * const recording = await sandbox.computerUse.recording.start('my-test-recording');
486
+ * console.log(`Recording started: ${recording.id}`);
487
+ * console.log(`File: ${recording.filePath}`);
488
+ * ```
489
+ */
490
+ async start(label) {
491
+ return (await this.apiClient.startRecording({ label })).data;
492
+ }
493
+ /**
494
+ * Stops an active screen recording session
495
+ *
496
+ * @param {string} id - The ID of the recording to stop
497
+ * @returns {Promise<Recording>} Stopped recording details
498
+ *
499
+ * @example
500
+ * ```typescript
501
+ * const result = await sandbox.computerUse.recording.stop(recording.id);
502
+ * console.log(`Recording stopped: ${result.durationSeconds} seconds`);
503
+ * console.log(`Saved to: ${result.filePath}`);
504
+ * ```
505
+ */
506
+ async stop(id) {
507
+ return (await this.apiClient.stopRecording({ id })).data;
508
+ }
509
+ /**
510
+ * Lists all recordings (active and completed)
511
+ *
512
+ * @returns {Promise<ListRecordingsResponse>} List of all recordings
513
+ *
514
+ * @example
515
+ * ```typescript
516
+ * const recordings = await sandbox.computerUse.recording.list();
517
+ * console.log(`Found ${recordings.recordings.length} recordings`);
518
+ * recordings.recordings.forEach(rec => {
519
+ * console.log(`- ${rec.fileName}: ${rec.status}`);
520
+ * });
521
+ * ```
522
+ */
523
+ async list() {
524
+ return (await this.apiClient.listRecordings()).data;
525
+ }
526
+ /**
527
+ * Gets details of a specific recording by ID
528
+ *
529
+ * @param {string} id - The ID of the recording to retrieve
530
+ * @returns {Promise<Recording>} Recording details
531
+ *
532
+ * @example
533
+ * ```typescript
534
+ * const recording = await sandbox.computerUse.recording.get(recordingId);
535
+ * console.log(`Recording: ${recording.fileName}`);
536
+ * console.log(`Status: ${recording.status}`);
537
+ * console.log(`Duration: ${recording.durationSeconds} seconds`);
538
+ * ```
539
+ */
540
+ async get(id) {
541
+ return (await this.apiClient.getRecording(id)).data;
542
+ }
543
+ /**
544
+ * Deletes a recording by ID
545
+ *
546
+ * @param {string} id - The ID of the recording to delete
547
+ *
548
+ * @example
549
+ * ```typescript
550
+ * await sandbox.computerUse.recording.delete(recordingId);
551
+ * console.log('Recording deleted');
552
+ * ```
553
+ */
554
+ async delete(id) {
555
+ await this.apiClient.deleteRecording(id);
556
+ }
557
+ /**
558
+ * Downloads a recording file and saves it to a local path
559
+ *
560
+ * The file is streamed directly to disk without loading the entire content into memory.
561
+ *
562
+ * @param {string} id - The ID of the recording to download
563
+ * @param {string} localPath - Path to save the recording file locally
564
+ *
565
+ * @example
566
+ * ```typescript
567
+ * // Download recording to file
568
+ * await sandbox.computerUse.recording.download(recordingId, 'local_recording.mp4');
569
+ * console.log('Recording downloaded');
570
+ * ```
571
+ */
572
+ async download(id, localPath) {
573
+ const response = await this.apiClient.downloadRecording(id, { responseType: 'stream' });
574
+ const importErrPrefix = 'Recording download failed: ';
575
+ const fs = await (0, Import_1.dynamicImport)('fs', importErrPrefix);
576
+ const stream = await (0, Import_1.dynamicImport)('stream', importErrPrefix);
577
+ const util = await (0, Import_1.dynamicImport)('util', importErrPrefix);
578
+ const pipeline = util.promisify(stream.pipeline);
579
+ // Create parent directory if it doesn't exist
580
+ const parentDir = pathe.dirname(localPath);
581
+ if (parentDir) {
582
+ await fs.promises.mkdir(parentDir, { recursive: true });
583
+ }
584
+ // Stream the download directly to file
585
+ const writer = fs.createWriteStream(localPath);
586
+ await pipeline(response.data, writer);
587
+ }
588
+ }
589
+ exports.RecordingService = RecordingService;
590
+ tslib_1.__decorate([
591
+ (0, otel_decorator_1.WithInstrumentation)(),
592
+ tslib_1.__metadata("design:type", Function),
593
+ tslib_1.__metadata("design:paramtypes", [String]),
594
+ tslib_1.__metadata("design:returntype", Promise)
595
+ ], RecordingService.prototype, "start", null);
596
+ tslib_1.__decorate([
597
+ (0, otel_decorator_1.WithInstrumentation)(),
598
+ tslib_1.__metadata("design:type", Function),
599
+ tslib_1.__metadata("design:paramtypes", [String]),
600
+ tslib_1.__metadata("design:returntype", Promise)
601
+ ], RecordingService.prototype, "stop", null);
602
+ tslib_1.__decorate([
603
+ (0, otel_decorator_1.WithInstrumentation)(),
604
+ tslib_1.__metadata("design:type", Function),
605
+ tslib_1.__metadata("design:paramtypes", []),
606
+ tslib_1.__metadata("design:returntype", Promise)
607
+ ], RecordingService.prototype, "list", null);
608
+ tslib_1.__decorate([
609
+ (0, otel_decorator_1.WithInstrumentation)(),
610
+ tslib_1.__metadata("design:type", Function),
611
+ tslib_1.__metadata("design:paramtypes", [String]),
612
+ tslib_1.__metadata("design:returntype", Promise)
613
+ ], RecordingService.prototype, "get", null);
614
+ tslib_1.__decorate([
615
+ (0, otel_decorator_1.WithInstrumentation)(),
616
+ tslib_1.__metadata("design:type", Function),
617
+ tslib_1.__metadata("design:paramtypes", [String]),
618
+ tslib_1.__metadata("design:returntype", Promise)
619
+ ], RecordingService.prototype, "delete", null);
620
+ tslib_1.__decorate([
621
+ (0, otel_decorator_1.WithInstrumentation)(),
622
+ tslib_1.__metadata("design:type", Function),
623
+ tslib_1.__metadata("design:paramtypes", [String, String]),
624
+ tslib_1.__metadata("design:returntype", Promise)
625
+ ], RecordingService.prototype, "download", null);
626
+ /**
627
+ * Computer Use functionality for interacting with the desktop environment.
628
+ *
629
+ * Provides access to mouse, keyboard, screenshot, display, and recording operations
630
+ * for automating desktop interactions within a sandbox.
631
+ *
632
+ * @property {Mouse} mouse - Mouse operations interface
633
+ * @property {Keyboard} keyboard - Keyboard operations interface
634
+ * @property {Screenshot} screenshot - Screenshot operations interface
635
+ * @property {Display} display - Display operations interface
636
+ * @property {RecordingService} recording - Screen recording operations interface
637
+ *
638
+ * @class
639
+ */
640
+ class ComputerUse {
641
+ apiClient;
642
+ mouse;
643
+ keyboard;
644
+ screenshot;
645
+ display;
646
+ recording;
647
+ constructor(apiClient) {
648
+ this.apiClient = apiClient;
649
+ this.mouse = new Mouse(apiClient);
650
+ this.keyboard = new Keyboard(apiClient);
651
+ this.screenshot = new Screenshot(apiClient);
652
+ this.display = new Display(apiClient);
653
+ this.recording = new RecordingService(apiClient);
654
+ }
655
+ /**
656
+ * Starts all computer use processes (Xvfb, xfce4, x11vnc, novnc)
657
+ *
658
+ * @returns {Promise<ComputerUseStartResponse>} Computer use start response
659
+ *
660
+ * @example
661
+ * ```typescript
662
+ * const result = await sandbox.computerUse.start();
663
+ * console.log('Computer use processes started:', result.message);
664
+ * ```
665
+ */
666
+ async start() {
667
+ const response = await this.apiClient.startComputerUse();
668
+ return response.data;
669
+ }
670
+ /**
671
+ * Stops all computer use processes
672
+ *
673
+ * @returns {Promise<ComputerUseStopResponse>} Computer use stop response
674
+ *
675
+ * @example
676
+ * ```typescript
677
+ * const result = await sandbox.computerUse.stop();
678
+ * console.log('Computer use processes stopped:', result.message);
679
+ * ```
680
+ */
681
+ async stop() {
682
+ const response = await this.apiClient.stopComputerUse();
683
+ return response.data;
684
+ }
685
+ /**
686
+ * Gets the status of all computer use processes
687
+ *
688
+ * @returns {Promise<ComputerUseStatusResponse>} Status information about all VNC desktop processes
689
+ *
690
+ * @example
691
+ * ```typescript
692
+ * const status = await sandbox.computerUse.getStatus();
693
+ * console.log('Computer use status:', status.status);
694
+ * ```
695
+ */
696
+ async getStatus() {
697
+ const response = await this.apiClient.getComputerUseStatus();
698
+ return response.data;
699
+ }
700
+ /**
701
+ * Gets the status of a specific VNC process
702
+ *
703
+ * @param {string} processName - Name of the process to check
704
+ * @returns {Promise<ProcessStatusResponse>} Status information about the specific process
705
+ *
706
+ * @example
707
+ * ```typescript
708
+ * const xvfbStatus = await sandbox.computerUse.getProcessStatus('xvfb');
709
+ * const noVncStatus = await sandbox.computerUse.getProcessStatus('novnc');
710
+ * ```
711
+ */
712
+ async getProcessStatus(processName) {
713
+ const response = await this.apiClient.getProcessStatus(processName);
714
+ return response.data;
715
+ }
716
+ /**
717
+ * Restarts a specific VNC process
718
+ *
719
+ * @param {string} processName - Name of the process to restart
720
+ * @returns {Promise<ProcessRestartResponse>} Process restart response
721
+ *
722
+ * @example
723
+ * ```typescript
724
+ * const result = await sandbox.computerUse.restartProcess('xfce4');
725
+ * console.log('XFCE4 process restarted:', result.message);
726
+ * ```
727
+ */
728
+ async restartProcess(processName) {
729
+ const response = await this.apiClient.restartProcess(processName);
730
+ return response.data;
731
+ }
732
+ /**
733
+ * Gets logs for a specific VNC process
734
+ *
735
+ * @param {string} processName - Name of the process to get logs for
736
+ * @returns {Promise<ProcessLogsResponse>} Process logs
737
+ *
738
+ * @example
739
+ * ```typescript
740
+ * const logsResp = await sandbox.computerUse.getProcessLogs('novnc');
741
+ * console.log('NoVNC logs:', logsResp.logs);
742
+ * ```
743
+ */
744
+ async getProcessLogs(processName) {
745
+ const response = await this.apiClient.getProcessLogs(processName);
746
+ return response.data;
747
+ }
748
+ /**
749
+ * Gets error logs for a specific VNC process
750
+ *
751
+ * @param {string} processName - Name of the process to get error logs for
752
+ * @returns {Promise<ProcessErrorsResponse>} Process error logs
753
+ *
754
+ * @example
755
+ * ```typescript
756
+ * const errorsResp = await sandbox.computerUse.getProcessErrors('x11vnc');
757
+ * console.log('X11VNC errors:', errorsResp.errors);
758
+ * ```
759
+ */
760
+ async getProcessErrors(processName) {
761
+ const response = await this.apiClient.getProcessErrors(processName);
762
+ return response.data;
763
+ }
764
+ }
765
+ exports.ComputerUse = ComputerUse;
766
+ tslib_1.__decorate([
767
+ (0, otel_decorator_1.WithInstrumentation)(),
768
+ tslib_1.__metadata("design:type", Function),
769
+ tslib_1.__metadata("design:paramtypes", []),
770
+ tslib_1.__metadata("design:returntype", Promise)
771
+ ], ComputerUse.prototype, "start", null);
772
+ tslib_1.__decorate([
773
+ (0, otel_decorator_1.WithInstrumentation)(),
774
+ tslib_1.__metadata("design:type", Function),
775
+ tslib_1.__metadata("design:paramtypes", []),
776
+ tslib_1.__metadata("design:returntype", Promise)
777
+ ], ComputerUse.prototype, "stop", null);
778
+ tslib_1.__decorate([
779
+ (0, otel_decorator_1.WithInstrumentation)(),
780
+ tslib_1.__metadata("design:type", Function),
781
+ tslib_1.__metadata("design:paramtypes", []),
782
+ tslib_1.__metadata("design:returntype", Promise)
783
+ ], ComputerUse.prototype, "getStatus", null);
784
+ tslib_1.__decorate([
785
+ (0, otel_decorator_1.WithInstrumentation)(),
786
+ tslib_1.__metadata("design:type", Function),
787
+ tslib_1.__metadata("design:paramtypes", [String]),
788
+ tslib_1.__metadata("design:returntype", Promise)
789
+ ], ComputerUse.prototype, "getProcessStatus", null);
790
+ tslib_1.__decorate([
791
+ (0, otel_decorator_1.WithInstrumentation)(),
792
+ tslib_1.__metadata("design:type", Function),
793
+ tslib_1.__metadata("design:paramtypes", [String]),
794
+ tslib_1.__metadata("design:returntype", Promise)
795
+ ], ComputerUse.prototype, "restartProcess", null);
796
+ tslib_1.__decorate([
797
+ (0, otel_decorator_1.WithInstrumentation)(),
798
+ tslib_1.__metadata("design:type", Function),
799
+ tslib_1.__metadata("design:paramtypes", [String]),
800
+ tslib_1.__metadata("design:returntype", Promise)
801
+ ], ComputerUse.prototype, "getProcessLogs", null);
802
+ tslib_1.__decorate([
803
+ (0, otel_decorator_1.WithInstrumentation)(),
804
+ tslib_1.__metadata("design:type", Function),
805
+ tslib_1.__metadata("design:paramtypes", [String]),
806
+ tslib_1.__metadata("design:returntype", Promise)
807
+ ], ComputerUse.prototype, "getProcessErrors", null);
808
+ //# sourceMappingURL=ComputerUse.js.map