@daytonaio/sdk 0.21.9 → 0.22.0-alpha.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daytonaio/sdk",
3
- "version": "0.21.9",
3
+ "version": "0.22.0-alpha.0",
4
4
  "description": "TypeScript SDK for Daytona",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -15,9 +15,10 @@
15
15
  },
16
16
  "homepage": "https://www.daytona.io/docs",
17
17
  "config": {
18
- "docsDir": "../../apps/docs/src/content/docs/typescript-sdk"
18
+ "docsDir": "../../apps/docs/content/sdk-typescript"
19
19
  },
20
20
  "scripts": {
21
+ "build": "tsc && tsc -p tsconfig.esm.json",
21
22
  "docs": "bash -O extglob -c 'rm -rf $npm_package_config_docsDir/!(index.mdx)' && typedoc && rm -f $npm_package_config_docsDir/readme.mdx"
22
23
  },
23
24
  "keywords": [],
@@ -36,12 +37,9 @@
36
37
  "form-data": "^4.0.0",
37
38
  "shell-quote": "^1.8.2",
38
39
  "tar": "^6.2.0",
39
- "typedoc": "0.27.9",
40
- "typedoc-plugin-markdown": "4.4.2",
41
- "typedoc-plugin-merge-modules": "6.1.0",
42
40
  "untildify": "^5.0.0",
43
41
  "uuid": "^11.0.3",
44
- "@daytonaio/api-client": "0.21.8"
42
+ "@daytonaio/api-client": "0.22.0-alpha.0"
45
43
  },
46
44
  "packageManager": "yarn@4.6.0",
47
45
  "type": "commonjs"
@@ -0,0 +1,408 @@
1
+ import { ToolboxApi, MousePosition, MouseMoveResponse, MouseClickResponse, MouseDragResponse, MouseScrollResponse, KeyboardTypeResponse, KeyboardPressResponse, KeyboardHotkeyResponse, ScreenshotResponse, RegionScreenshotResponse, CompressedScreenshotResponse, DisplayInfoResponse, WindowsResponse } from '@daytonaio/api-client';
2
+ /**
3
+ * Interface for region coordinates used in screenshot operations
4
+ */
5
+ export interface ScreenshotRegion {
6
+ x: number;
7
+ y: number;
8
+ width: number;
9
+ height: number;
10
+ }
11
+ /**
12
+ * Interface for screenshot compression options
13
+ */
14
+ export interface ScreenshotOptions {
15
+ showCursor?: boolean;
16
+ format?: string;
17
+ quality?: number;
18
+ scale?: number;
19
+ }
20
+ /**
21
+ * Mouse operations for computer use functionality
22
+ */
23
+ export declare class Mouse {
24
+ private readonly sandboxId;
25
+ private readonly toolboxApi;
26
+ constructor(sandboxId: string, toolboxApi: ToolboxApi);
27
+ /**
28
+ * Gets the current mouse cursor position
29
+ *
30
+ * @returns {Promise<MousePosition>} Current mouse position with x and y coordinates
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const position = await sandbox.computerUse.mouse.getPosition();
35
+ * console.log(`Mouse is at: ${position.x}, ${position.y}`);
36
+ * ```
37
+ */
38
+ getPosition(): Promise<MousePosition>;
39
+ /**
40
+ * Moves the mouse cursor to the specified coordinates
41
+ *
42
+ * @param {number} x - The x coordinate to move to
43
+ * @param {number} y - The y coordinate to move to
44
+ * @returns {Promise<MouseMoveResponse>} Move operation result
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const result = await sandbox.computerUse.mouse.move(100, 200);
49
+ * console.log(`Mouse moved to: ${result.actual_x}, ${result.actual_y}`);
50
+ * ```
51
+ */
52
+ move(x: number, y: number): Promise<MouseMoveResponse>;
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
+ click(x: number, y: number, button?: string, double?: boolean): Promise<MouseClickResponse>;
75
+ /**
76
+ * Drags the mouse from start coordinates to end coordinates
77
+ *
78
+ * @param {number} startX - The starting x coordinate
79
+ * @param {number} startY - The starting y coordinate
80
+ * @param {number} endX - The ending x coordinate
81
+ * @param {number} endY - The ending y coordinate
82
+ * @param {string} [button='left'] - The mouse button to use for dragging
83
+ * @returns {Promise<MouseDragResponse>} Drag operation result
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const result = await sandbox.computerUse.mouse.drag(50, 50, 150, 150);
88
+ * console.log(`Dragged from ${result.from.x},${result.from.y} to ${result.to.x},${result.to.y}`);
89
+ * ```
90
+ */
91
+ drag(startX: number, startY: number, endX: number, endY: number, button?: string): Promise<MouseDragResponse>;
92
+ /**
93
+ * Scrolls the mouse wheel at the specified coordinates
94
+ *
95
+ * @param {number} x - The x coordinate to scroll at
96
+ * @param {number} y - The y coordinate to scroll at
97
+ * @param {'up' | 'down'} direction - The direction to scroll
98
+ * @param {number} [amount=1] - The amount to scroll
99
+ * @returns {Promise<MouseScrollResponse>} Scroll operation result
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * // Scroll up
104
+ * const scrollUp = await sandbox.computerUse.mouse.scroll(100, 200, 'up', 3);
105
+ *
106
+ * // Scroll down
107
+ * const scrollDown = await sandbox.computerUse.mouse.scroll(100, 200, 'down', 5);
108
+ * ```
109
+ */
110
+ scroll(x: number, y: number, direction: 'up' | 'down', amount?: number): Promise<MouseScrollResponse>;
111
+ }
112
+ /**
113
+ * Keyboard operations for computer use functionality
114
+ */
115
+ export declare class Keyboard {
116
+ private readonly sandboxId;
117
+ private readonly toolboxApi;
118
+ constructor(sandboxId: string, toolboxApi: ToolboxApi);
119
+ /**
120
+ * Types the specified text
121
+ *
122
+ * @param {string} text - The text to type
123
+ * @param {number} [delay=0] - Delay between characters in milliseconds
124
+ * @returns {Promise<KeyboardTypeResponse>} Type operation result
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * const result = await sandbox.computerUse.keyboard.type('Hello, World!');
129
+ * console.log(`Typed: ${result.typed}`);
130
+ *
131
+ * // With delay between characters
132
+ * const slowType = await sandbox.computerUse.keyboard.type('Slow typing', 100);
133
+ * ```
134
+ */
135
+ type(text: string, delay?: number): Promise<KeyboardTypeResponse>;
136
+ /**
137
+ * Presses a key with optional modifiers
138
+ *
139
+ * @param {string} key - The key to press (e.g., 'Enter', 'Escape', 'Tab', 'a', 'A')
140
+ * @param {string[]} [modifiers=[]] - Modifier keys ('ctrl', 'alt', 'meta', 'shift')
141
+ * @returns {Promise<KeyboardPressResponse>} Press operation result
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * // Press Enter
146
+ * const enter = await sandbox.computerUse.keyboard.press('Return');
147
+ *
148
+ * // Press Ctrl+C
149
+ * const copy = await sandbox.computerUse.keyboard.press('c', ['ctrl']);
150
+ *
151
+ * // Press Ctrl+Shift+T
152
+ * const newTab = await sandbox.computerUse.keyboard.press('t', ['ctrl', 'shift']);
153
+ * ```
154
+ */
155
+ press(key: string, modifiers?: string[]): Promise<KeyboardPressResponse>;
156
+ /**
157
+ * Presses a hotkey combination
158
+ *
159
+ * @param {string} keys - The hotkey combination (e.g., 'ctrl+c', 'alt+tab', 'cmd+shift+t')
160
+ * @returns {Promise<KeyboardHotkeyResponse>} Hotkey operation result
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * // Copy
165
+ * const copy = await sandbox.computerUse.keyboard.hotkey('ctrl+c');
166
+ *
167
+ * // Paste
168
+ * const paste = await sandbox.computerUse.keyboard.hotkey('ctrl+v');
169
+ *
170
+ * // Alt+Tab
171
+ * const altTab = await sandbox.computerUse.keyboard.hotkey('alt+tab');
172
+ * ```
173
+ */
174
+ hotkey(keys: string): Promise<KeyboardHotkeyResponse>;
175
+ }
176
+ /**
177
+ * Screenshot operations for computer use functionality
178
+ */
179
+ export declare class Screenshot {
180
+ private readonly sandboxId;
181
+ private readonly toolboxApi;
182
+ constructor(sandboxId: string, toolboxApi: ToolboxApi);
183
+ /**
184
+ * Takes a screenshot of the entire screen
185
+ *
186
+ * @param {boolean} [showCursor=false] - Whether to show the cursor in the screenshot
187
+ * @returns {Promise<ScreenshotResponse>} Screenshot data with base64 encoded image
188
+ *
189
+ * @example
190
+ * ```typescript
191
+ * const screenshot = await sandbox.computerUse.screenshot.takeFullScreen();
192
+ * console.log(`Screenshot size: ${screenshot.width}x${screenshot.height}`);
193
+ *
194
+ * // With cursor visible
195
+ * const withCursor = await sandbox.computerUse.screenshot.takeFullScreen(true);
196
+ * ```
197
+ */
198
+ takeFullScreen(showCursor?: boolean): Promise<ScreenshotResponse>;
199
+ /**
200
+ * Takes a screenshot of a specific region
201
+ *
202
+ * @param {ScreenshotRegion} region - The region to capture
203
+ * @param {boolean} [showCursor=false] - Whether to show the cursor in the screenshot
204
+ * @returns {Promise<RegionScreenshotResponse>} Screenshot data with base64 encoded image
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * const region = { x: 100, y: 100, width: 300, height: 200 };
209
+ * const screenshot = await sandbox.computerUse.screenshot.takeRegion(region);
210
+ * console.log(`Captured region: ${screenshot.region.width}x${screenshot.region.height}`);
211
+ * ```
212
+ */
213
+ takeRegion(region: ScreenshotRegion, showCursor?: boolean): Promise<RegionScreenshotResponse>;
214
+ /**
215
+ * Takes a compressed screenshot of the entire screen
216
+ *
217
+ * @param {ScreenshotOptions} [options={}] - Compression and display options
218
+ * @returns {Promise<CompressedScreenshotResponse>} Compressed screenshot data
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * // Default compression
223
+ * const screenshot = await sandbox.computerUse.screenshot.takeCompressed();
224
+ *
225
+ * // High quality JPEG
226
+ * const jpeg = await sandbox.computerUse.screenshot.takeCompressed({
227
+ * format: 'jpeg',
228
+ * quality: 95,
229
+ * showCursor: true
230
+ * });
231
+ *
232
+ * // Scaled down PNG
233
+ * const scaled = await sandbox.computerUse.screenshot.takeCompressed({
234
+ * format: 'png',
235
+ * scale: 0.5
236
+ * });
237
+ * ```
238
+ */
239
+ takeCompressed(options?: ScreenshotOptions): Promise<CompressedScreenshotResponse>;
240
+ /**
241
+ * Takes a compressed screenshot of a specific region
242
+ *
243
+ * @param {ScreenshotRegion} region - The region to capture
244
+ * @param {ScreenshotOptions} [options={}] - Compression and display options
245
+ * @returns {Promise<CompressedScreenshotResponse>} Compressed screenshot data
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * const region = { x: 0, y: 0, width: 800, height: 600 };
250
+ * const screenshot = await sandbox.computerUse.screenshot.takeCompressedRegion(region, {
251
+ * format: 'webp',
252
+ * quality: 80,
253
+ * showCursor: true
254
+ * });
255
+ * console.log(`Compressed size: ${screenshot.size_bytes} bytes`);
256
+ * ```
257
+ */
258
+ takeCompressedRegion(region: ScreenshotRegion, options?: ScreenshotOptions): Promise<CompressedScreenshotResponse>;
259
+ }
260
+ /**
261
+ * Display operations for computer use functionality
262
+ */
263
+ export declare class Display {
264
+ private readonly sandboxId;
265
+ private readonly toolboxApi;
266
+ constructor(sandboxId: string, toolboxApi: ToolboxApi);
267
+ /**
268
+ * Gets information about the displays
269
+ *
270
+ * @returns {Promise<DisplayInfoResponse>} Display information including primary display and all available displays
271
+ *
272
+ * @example
273
+ * ```typescript
274
+ * const info = await sandbox.computerUse.display.getInfo();
275
+ * console.log(`Primary display: ${info.primary_display.width}x${info.primary_display.height}`);
276
+ * console.log(`Total displays: ${info.total_displays}`);
277
+ * info.displays.forEach((display, index) => {
278
+ * console.log(`Display ${index}: ${display.width}x${display.height} at ${display.x},${display.y}`);
279
+ * });
280
+ * ```
281
+ */
282
+ getInfo(): Promise<DisplayInfoResponse>;
283
+ /**
284
+ * Gets the list of open windows
285
+ *
286
+ * @returns {Promise<WindowsResponse>} List of open windows with their IDs and titles
287
+ *
288
+ * @example
289
+ * ```typescript
290
+ * const windows = await sandbox.computerUse.display.getWindows();
291
+ * console.log(`Found ${windows.count} open windows:`);
292
+ * windows.windows.forEach(window => {
293
+ * console.log(`- ${window.title} (ID: ${window.id})`);
294
+ * });
295
+ * ```
296
+ */
297
+ getWindows(): Promise<WindowsResponse>;
298
+ }
299
+ /**
300
+ * Computer Use functionality for interacting with the desktop environment.
301
+ *
302
+ * Provides access to mouse, keyboard, screenshot, and display operations
303
+ * for automating desktop interactions within a sandbox.
304
+ *
305
+ * @property {Mouse} mouse - Mouse operations interface
306
+ * @property {Keyboard} keyboard - Keyboard operations interface
307
+ * @property {Screenshot} screenshot - Screenshot operations interface
308
+ * @property {Display} display - Display operations interface
309
+ *
310
+ * @class
311
+ */
312
+ export declare class ComputerUse {
313
+ private readonly sandboxId;
314
+ private readonly toolboxApi;
315
+ readonly mouse: Mouse;
316
+ readonly keyboard: Keyboard;
317
+ readonly screenshot: Screenshot;
318
+ readonly display: Display;
319
+ constructor(sandboxId: string, toolboxApi: ToolboxApi);
320
+ /**
321
+ * Starts all computer use processes (Xvfb, xfce4, x11vnc, novnc)
322
+ *
323
+ * @returns {Promise<void>}
324
+ *
325
+ * @example
326
+ * ```typescript
327
+ * await sandbox.computerUse.start();
328
+ * console.log('Computer use processes started');
329
+ * ```
330
+ */
331
+ start(): Promise<void>;
332
+ /**
333
+ * Stops all computer use processes
334
+ *
335
+ * @returns {Promise<void>}
336
+ *
337
+ * @example
338
+ * ```typescript
339
+ * await sandbox.computerUse.stop();
340
+ * console.log('Computer use processes stopped');
341
+ * ```
342
+ */
343
+ stop(): Promise<void>;
344
+ /**
345
+ * Gets the status of all computer use processes
346
+ *
347
+ * @returns {Promise<void>} Status information about all VNC desktop processes
348
+ *
349
+ * @example
350
+ * ```typescript
351
+ * const status = await sandbox.computerUse.getStatus();
352
+ * console.log('Computer use status:', status);
353
+ * ```
354
+ */
355
+ getStatus(): Promise<void>;
356
+ /**
357
+ * Gets the status of a specific VNC process
358
+ *
359
+ * @param {string} processName - Name of the process to check
360
+ * @returns {Promise<void>} Status information about the specific process
361
+ *
362
+ * @example
363
+ * ```typescript
364
+ * const xvfbStatus = await sandbox.computerUse.getProcessStatus('xvfb');
365
+ * const noVncStatus = await sandbox.computerUse.getProcessStatus('novnc');
366
+ * ```
367
+ */
368
+ getProcessStatus(processName: string): Promise<void>;
369
+ /**
370
+ * Restarts a specific VNC process
371
+ *
372
+ * @param {string} processName - Name of the process to restart
373
+ * @returns {Promise<void>}
374
+ *
375
+ * @example
376
+ * ```typescript
377
+ * await sandbox.computerUse.restartProcess('xfce4');
378
+ * console.log('XFCE4 process restarted');
379
+ * ```
380
+ */
381
+ restartProcess(processName: string): Promise<void>;
382
+ /**
383
+ * Gets logs for a specific VNC process
384
+ *
385
+ * @param {string} processName - Name of the process to get logs for
386
+ * @returns {Promise<void>} Process logs
387
+ *
388
+ * @example
389
+ * ```typescript
390
+ * const logs = await sandbox.computerUse.getProcessLogs('novnc');
391
+ * console.log('NoVNC logs:', logs);
392
+ * ```
393
+ */
394
+ getProcessLogs(processName: string): Promise<void>;
395
+ /**
396
+ * Gets error logs for a specific VNC process
397
+ *
398
+ * @param {string} processName - Name of the process to get error logs for
399
+ * @returns {Promise<void>} Process error logs
400
+ *
401
+ * @example
402
+ * ```typescript
403
+ * const errors = await sandbox.computerUse.getProcessErrors('x11vnc');
404
+ * console.log('X11VNC errors:', errors);
405
+ * ```
406
+ */
407
+ getProcessErrors(processName: string): Promise<void>;
408
+ }