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