wuying-agentbay-sdk 0.10.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/chunk-BVWUCG4J.mjs +3402 -0
  2. package/dist/chunk-BVWUCG4J.mjs.map +1 -0
  3. package/dist/chunk-SL5GCAQE.cjs +3393 -0
  4. package/dist/chunk-SL5GCAQE.cjs.map +1 -0
  5. package/dist/index.cjs +4623 -3978
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.mts +3934 -1964
  8. package/dist/index.d.ts +3934 -1964
  9. package/dist/index.mjs +4601 -3956
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/key-normalizer-AF7APGQZ.cjs +136 -0
  12. package/dist/key-normalizer-AF7APGQZ.cjs.map +1 -0
  13. package/dist/key-normalizer-QDBRLFHF.mjs +145 -0
  14. package/dist/key-normalizer-QDBRLFHF.mjs.map +1 -0
  15. package/dist/model-CNCGFWJH.cjs +200 -0
  16. package/dist/model-CNCGFWJH.cjs.map +1 -0
  17. package/dist/model-LGWQJWKQ.mjs +209 -0
  18. package/docs/api/README.md +26 -0
  19. package/docs/api/browser-use/browser.md +177 -0
  20. package/docs/api/browser-use/extension.md +284 -0
  21. package/docs/api/codespace/code.md +77 -0
  22. package/docs/api/common-features/advanced/agent.md +84 -0
  23. package/docs/api/common-features/advanced/oss.md +221 -0
  24. package/docs/api/common-features/basics/agentbay.md +277 -0
  25. package/docs/api/common-features/basics/command.md +83 -0
  26. package/docs/api/common-features/basics/context-manager.md +149 -0
  27. package/docs/api/common-features/basics/context-sync.md +51 -0
  28. package/docs/api/common-features/basics/context.md +348 -0
  29. package/docs/api/common-features/basics/filesystem.md +499 -0
  30. package/docs/api/common-features/basics/logging.md +77 -0
  31. package/docs/api/common-features/basics/session.md +542 -0
  32. package/docs/api/computer-use/computer.md +786 -0
  33. package/docs/api/mobile-use/mobile.md +395 -0
  34. package/docs/examples/README.md +332 -0
  35. package/docs/examples/basic-usage.ts +86 -0
  36. package/docs/examples/browser-use/browser/README.md +356 -0
  37. package/docs/examples/browser-use/browser/basic-usage.ts +136 -0
  38. package/docs/examples/browser-use/browser/browser-command-args.ts +117 -0
  39. package/docs/examples/browser-use/browser/browser-context-cookie-persistence.ts +348 -0
  40. package/docs/examples/browser-use/browser/browser-fingerprint-basic-usage.ts +121 -0
  41. package/docs/examples/browser-use/browser/browser-fingerprint-construct.ts +114 -0
  42. package/docs/examples/browser-use/browser/browser-fingerprint-local-sync.ts +98 -0
  43. package/docs/examples/browser-use/browser/browser-fingerprint-persistence.ts +242 -0
  44. package/docs/examples/browser-use/browser/browser-proxies.ts +149 -0
  45. package/docs/examples/browser-use/browser/browser-type-example.ts +266 -0
  46. package/docs/examples/browser-use/browser/browser-viewport.ts +129 -0
  47. package/docs/examples/browser-use/browser/call_for_user_jd.ts +184 -0
  48. package/docs/examples/browser-use/browser/captcha_tongcheng.ts +151 -0
  49. package/docs/examples/browser-use/browser/run-2048.ts +209 -0
  50. package/docs/examples/browser-use/browser/run-sudoku.ts +150 -0
  51. package/docs/examples/browser-use/browser/screenshot-example.ts +132 -0
  52. package/docs/examples/browser-use/extension-example/README.md +252 -0
  53. package/docs/examples/browser-use/extension-example/extension-example.ts +381 -0
  54. package/docs/examples/codespace/automation/automation-example.ts +322 -0
  55. package/docs/examples/common-features/advanced/agent-module-example/README.md +40 -0
  56. package/docs/examples/common-features/advanced/agent-module-example.ts +66 -0
  57. package/docs/examples/common-features/advanced/archive-upload-mode-example/README.md +212 -0
  58. package/docs/examples/common-features/advanced/archive-upload-mode-example/archive-upload-mode-example.ts +213 -0
  59. package/docs/examples/common-features/advanced/vpc-session-example/README.md +47 -0
  60. package/docs/examples/common-features/advanced/vpc-session-example.ts +106 -0
  61. package/docs/examples/common-features/basics/archive-upload-mode-example/README.md +236 -0
  62. package/docs/examples/common-features/basics/archive-upload-mode-example/main.ts +236 -0
  63. package/docs/examples/common-features/basics/command-example/README.md +47 -0
  64. package/docs/examples/common-features/basics/command-example/command-example.ts +153 -0
  65. package/docs/examples/common-features/basics/context-management/README.md +55 -0
  66. package/docs/examples/common-features/basics/context-management/context-management.ts +140 -0
  67. package/docs/examples/common-features/basics/data-persistence/README.md +129 -0
  68. package/docs/examples/common-features/basics/data-persistence/context-sync-demo.md +144 -0
  69. package/docs/examples/common-features/basics/data-persistence/context-sync-demo.ts +275 -0
  70. package/docs/examples/common-features/basics/data-persistence/data-persistence.ts +259 -0
  71. package/docs/examples/common-features/basics/data-persistence/recycle-policy-example.ts +294 -0
  72. package/docs/examples/common-features/basics/filesystem-example/README.md +57 -0
  73. package/docs/examples/common-features/basics/filesystem-example/filesystem-example.ts +164 -0
  74. package/docs/examples/common-features/basics/filesystem-example/filesystem-filetransfer-example.ts +153 -0
  75. package/docs/examples/common-features/basics/filesystem-example/watch-directory-example.ts +168 -0
  76. package/docs/examples/common-features/basics/get/README.md +136 -0
  77. package/docs/examples/common-features/basics/get/main.ts +79 -0
  78. package/docs/examples/common-features/basics/list_sessions/README.md +54 -0
  79. package/docs/examples/common-features/basics/list_sessions/main.ts +258 -0
  80. package/docs/examples/common-features/basics/mcp_tool_direct_call/README.md +142 -0
  81. package/docs/examples/common-features/basics/mcp_tool_direct_call/main.ts +135 -0
  82. package/docs/examples/common-features/basics/session-creation/README.md +28 -0
  83. package/docs/examples/common-features/basics/session-creation/session-creation.ts +295 -0
  84. package/docs/examples/common-features/basics/session-pause-resume/README.md +53 -0
  85. package/docs/examples/common-features/basics/session-pause-resume/session-pause-resume.ts +237 -0
  86. package/docs/examples/mobile-use/mobile-get-adb-url/README.md +92 -0
  87. package/docs/examples/mobile-use/mobile-get-adb-url/index.ts +80 -0
  88. package/docs/examples/mobile-use/mobile-get-adb-url/package-lock.json +279 -0
  89. package/docs/examples/mobile-use/mobile-get-adb-url/package.json +18 -0
  90. package/docs/examples/mobile-use/mobile-simulate-basic-usage.ts +202 -0
  91. package/docs/examples/mobile-use/mobile-simulate-with-ctx.ts +170 -0
  92. package/package.json +19 -12
  93. package/dist/application-KZWXH46T.mjs +0 -17
  94. package/dist/application-LMA7KSRH.cjs +0 -8
  95. package/dist/application-LMA7KSRH.cjs.map +0 -1
  96. package/dist/chunk-BQNGKBQF.mjs +0 -386
  97. package/dist/chunk-BQNGKBQF.mjs.map +0 -1
  98. package/dist/chunk-IOVGAAJL.cjs +0 -558
  99. package/dist/chunk-IOVGAAJL.cjs.map +0 -1
  100. package/dist/chunk-UF2TC2R4.mjs +0 -567
  101. package/dist/chunk-UF2TC2R4.mjs.map +0 -1
  102. package/dist/chunk-X6MS7Z5L.cjs +0 -377
  103. package/dist/chunk-X6MS7Z5L.cjs.map +0 -1
  104. package/dist/window-DH37ZDD5.mjs +0 -17
  105. package/dist/window-DH37ZDD5.mjs.map +0 -1
  106. package/dist/window-U7N3H735.cjs +0 -8
  107. package/dist/window-U7N3H735.cjs.map +0 -1
  108. /package/dist/{application-KZWXH46T.mjs.map → model-LGWQJWKQ.mjs.map} +0 -0
@@ -0,0 +1,786 @@
1
+ # Class: Computer
2
+
3
+ ## 🖥️ Related Tutorial
4
+
5
+ - [Computer Use Guide](../../../../docs/guides/computer-use/README.md) - Automate desktop applications
6
+
7
+ ## Overview
8
+
9
+ The Computer module provides comprehensive desktop automation capabilities including mouse operations,
10
+ keyboard input, screen capture, and window management. It enables automated UI testing and RPA workflows.
11
+
12
+
13
+ ## Requirements
14
+
15
+ - Requires `windows_latest` image for computer use features
16
+
17
+ ## Data Types
18
+
19
+ ### MouseButton
20
+
21
+ Mouse button constants: Left, Right, Middle
22
+
23
+ ### ScrollDirection
24
+
25
+ Scroll direction constants: Up, Down, Left, Right
26
+
27
+ ### KeyModifier
28
+
29
+ Keyboard modifier keys: Ctrl, Alt, Shift, Win
30
+
31
+ ## Important Notes
32
+
33
+ - Key names in PressKeys and ReleaseKeys are case-sensitive
34
+ - Coordinate validation: x and y must be non-negative integers
35
+ - Drag operation requires valid start and end coordinates
36
+ - Screenshot operations may have size limitations
37
+
38
+ ## Table of contents
39
+
40
+
41
+ ### Methods
42
+
43
+ - [activateWindow](#activatewindow)
44
+ - [clickMouse](#clickmouse)
45
+ - [closeWindow](#closewindow)
46
+ - [dragMouse](#dragmouse)
47
+ - [focusMode](#focusmode)
48
+ - [fullscreenWindow](#fullscreenwindow)
49
+ - [inputText](#inputtext)
50
+ - [listRootWindows](#listrootwindows)
51
+ - [listVisibleApps](#listvisibleapps)
52
+ - [maximizeWindow](#maximizewindow)
53
+ - [minimizeWindow](#minimizewindow)
54
+ - [moveMouse](#movemouse)
55
+ - [pressKeys](#presskeys)
56
+ - [releaseKeys](#releasekeys)
57
+ - [resizeWindow](#resizewindow)
58
+ - [restoreWindow](#restorewindow)
59
+ - [screenshot](#screenshot)
60
+ - [scroll](#scroll)
61
+ - [startApp](#startapp)
62
+ - [stopAppByCmd](#stopappbycmd)
63
+ - [stopAppByPID](#stopappbypid)
64
+ - [stopAppByPName](#stopappbypname)
65
+
66
+ ## Methods
67
+
68
+ ### activateWindow
69
+
70
+ ▸ **activateWindow**(`windowId`): `Promise`\<`BoolResult`\>
71
+
72
+ Activates the specified window.
73
+
74
+ #### Parameters
75
+
76
+ | Name | Type | Description |
77
+ | :------ | :------ | :------ |
78
+ | `windowId` | `number` | ID of the window to activate |
79
+
80
+ #### Returns
81
+
82
+ `Promise`\<`BoolResult`\>
83
+
84
+ Promise resolving to result with success status
85
+
86
+ **`Example`**
87
+
88
+ ```typescript
89
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
90
+ const result = await agentBay.create({ imageId: 'windows_latest' });
91
+ if (result.success) {
92
+ const windows = await result.session.computer.listRootWindows();
93
+ await result.session.computer.activateWindow(windows.windows[0].id);
94
+ await result.session.delete();
95
+ }
96
+ ```
97
+
98
+ ___
99
+
100
+ ### clickMouse
101
+
102
+ ▸ **clickMouse**(`x`, `y`, `button?`): `Promise`\<`BoolResult`\>
103
+
104
+ Click mouse at specified coordinates.
105
+
106
+ #### Parameters
107
+
108
+ | Name | Type | Default value | Description |
109
+ | :------ | :------ | :------ | :------ |
110
+ | `x` | `number` | `undefined` | X coordinate for the click |
111
+ | `y` | `number` | `undefined` | Y coordinate for the click |
112
+ | `button` | `string` | `MouseButton.LEFT` | Mouse button to click (default: 'left'). Valid values: 'left', 'right', 'middle', 'double_left' |
113
+
114
+ #### Returns
115
+
116
+ `Promise`\<`BoolResult`\>
117
+
118
+ Promise resolving to result with success status
119
+
120
+ **`Example`**
121
+
122
+ ```typescript
123
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
124
+ const result = await agentBay.create({ imageId: 'windows_latest' });
125
+ if (result.success) {
126
+ const clickResult = await result.session.computer.clickMouse(100, 100, 'left');
127
+ console.log('Clicked:', clickResult.success);
128
+ await result.session.delete();
129
+ }
130
+ ```
131
+
132
+ ___
133
+
134
+ ### closeWindow
135
+
136
+ ▸ **closeWindow**(`windowId`): `Promise`\<`BoolResult`\>
137
+
138
+ Closes the specified window.
139
+
140
+ #### Parameters
141
+
142
+ | Name | Type | Description |
143
+ | :------ | :------ | :------ |
144
+ | `windowId` | `number` | ID of the window to close |
145
+
146
+ #### Returns
147
+
148
+ `Promise`\<`BoolResult`\>
149
+
150
+ Promise resolving to result with success status
151
+
152
+ **`Example`**
153
+
154
+ ```typescript
155
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
156
+ const result = await agentBay.create({ imageId: 'windows_latest' });
157
+ if (result.success) {
158
+ await result.session.computer.startApp('notepad.exe');
159
+ const win = await result.session.computer.getActiveWindow();
160
+ await result.session.computer.closeWindow(win.window!.id);
161
+ await result.session.delete();
162
+ }
163
+ ```
164
+
165
+ ___
166
+
167
+ ### dragMouse
168
+
169
+ ▸ **dragMouse**(`fromX`, `fromY`, `toX`, `toY`, `button?`): `Promise`\<`BoolResult`\>
170
+
171
+ Drag mouse from one position to another.
172
+
173
+ #### Parameters
174
+
175
+ | Name | Type | Default value | Description |
176
+ | :------ | :------ | :------ | :------ |
177
+ | `fromX` | `number` | `undefined` | Starting X coordinate |
178
+ | `fromY` | `number` | `undefined` | Starting Y coordinate |
179
+ | `toX` | `number` | `undefined` | Ending X coordinate |
180
+ | `toY` | `number` | `undefined` | Ending Y coordinate |
181
+ | `button` | `string` | `MouseButton.LEFT` | Mouse button to use for drag (default: 'left'). Valid values: 'left', 'right', 'middle' |
182
+
183
+ #### Returns
184
+
185
+ `Promise`\<`BoolResult`\>
186
+
187
+ Promise resolving to result with success status
188
+
189
+ **`Example`**
190
+
191
+ ```typescript
192
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
193
+ const result = await agentBay.create({ imageId: 'windows_latest' });
194
+ if (result.success) {
195
+ const dragResult = await result.session.computer.dragMouse(100, 100, 300, 300, 'left');
196
+ console.log('Dragged:', dragResult.success);
197
+ await result.session.delete();
198
+ }
199
+ ```
200
+
201
+ ___
202
+
203
+ ### focusMode
204
+
205
+ ▸ **focusMode**(`on`): `Promise`\<`BoolResult`\>
206
+
207
+ Toggles focus mode on or off.
208
+
209
+ #### Parameters
210
+
211
+ | Name | Type | Description |
212
+ | :------ | :------ | :------ |
213
+ | `on` | `boolean` | Whether to enable (true) or disable (false) focus mode |
214
+
215
+ #### Returns
216
+
217
+ `Promise`\<`BoolResult`\>
218
+
219
+ Promise resolving to result with success status
220
+
221
+ **`Example`**
222
+
223
+ ```typescript
224
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
225
+ const result = await agentBay.create({ imageId: 'windows_latest' });
226
+ if (result.success) {
227
+ await result.session.computer.focusMode(true);
228
+ await result.session.computer.focusMode(false);
229
+ await result.session.delete();
230
+ }
231
+ ```
232
+
233
+ ___
234
+
235
+ ### fullscreenWindow
236
+
237
+ ▸ **fullscreenWindow**(`windowId`): `Promise`\<`BoolResult`\>
238
+
239
+ Makes the specified window fullscreen.
240
+
241
+ #### Parameters
242
+
243
+ | Name | Type | Description |
244
+ | :------ | :------ | :------ |
245
+ | `windowId` | `number` | ID of the window to make fullscreen |
246
+
247
+ #### Returns
248
+
249
+ `Promise`\<`BoolResult`\>
250
+
251
+ Promise resolving to result with success status
252
+
253
+ **`Example`**
254
+
255
+ ```typescript
256
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
257
+ const result = await agentBay.create({ imageId: 'windows_latest' });
258
+ if (result.success) {
259
+ await result.session.computer.startApp('notepad.exe');
260
+ const win = await result.session.computer.getActiveWindow();
261
+ await result.session.computer.fullscreenWindow(win.window!.id);
262
+ await result.session.delete();
263
+ }
264
+ ```
265
+
266
+ ### inputText
267
+
268
+ ▸ **inputText**(`text`): `Promise`\<`BoolResult`\>
269
+
270
+ Input text at the current cursor position.
271
+
272
+ #### Parameters
273
+
274
+ | Name | Type | Description |
275
+ | :------ | :------ | :------ |
276
+ | `text` | `string` | Text to input |
277
+
278
+ #### Returns
279
+
280
+ `Promise`\<`BoolResult`\>
281
+
282
+ Promise resolving to result with success status
283
+
284
+ **`Example`**
285
+
286
+ ```typescript
287
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
288
+ const result = await agentBay.create({ imageId: 'windows_latest' });
289
+ if (result.success) {
290
+ await result.session.computer.inputText('Hello AgentBay!');
291
+ await result.session.delete();
292
+ }
293
+ ```
294
+
295
+ ___
296
+
297
+ ### listRootWindows
298
+
299
+ ▸ **listRootWindows**(`timeoutMs?`): `Promise`\<`WindowListResult`\>
300
+
301
+ Lists all root windows.
302
+
303
+ #### Parameters
304
+
305
+ | Name | Type | Default value | Description |
306
+ | :------ | :------ | :------ | :------ |
307
+ | `timeoutMs` | `number` | `3000` | Timeout in milliseconds (default: 3000) |
308
+
309
+ #### Returns
310
+
311
+ `Promise`\<`WindowListResult`\>
312
+
313
+ Promise resolving to result containing array of root windows
314
+
315
+ **`Example`**
316
+
317
+ ```typescript
318
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
319
+ const result = await agentBay.create({ imageId: 'windows_latest' });
320
+ if (result.success) {
321
+ const windows = await result.session.computer.listRootWindows();
322
+ console.log(`Found ${windows.windows.length} windows`);
323
+ await result.session.delete();
324
+ }
325
+ ```
326
+
327
+ ___
328
+
329
+ ### listVisibleApps
330
+
331
+ ▸ **listVisibleApps**(): `Promise`\<`any`\>
332
+
333
+ Lists all visible applications.
334
+
335
+ #### Returns
336
+
337
+ `Promise`\<`any`\>
338
+
339
+ Promise resolving to result containing array of visible application processes
340
+
341
+ **`Example`**
342
+
343
+ ```typescript
344
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
345
+ const result = await agentBay.create({ imageId: 'windows_latest' });
346
+ if (result.success) {
347
+ const apps = await result.session.computer.listVisibleApps();
348
+ console.log(`Found ${apps.data.length} visible apps`);
349
+ await result.session.delete();
350
+ }
351
+ ```
352
+
353
+ ___
354
+
355
+ ### maximizeWindow
356
+
357
+ ▸ **maximizeWindow**(`windowId`): `Promise`\<`BoolResult`\>
358
+
359
+ Maximizes the specified window.
360
+
361
+ #### Parameters
362
+
363
+ | Name | Type | Description |
364
+ | :------ | :------ | :------ |
365
+ | `windowId` | `number` | ID of the window to maximize |
366
+
367
+ #### Returns
368
+
369
+ `Promise`\<`BoolResult`\>
370
+
371
+ Promise resolving to result with success status
372
+
373
+ **`Example`**
374
+
375
+ ```typescript
376
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
377
+ const result = await agentBay.create({ imageId: 'windows_latest' });
378
+ if (result.success) {
379
+ await result.session.computer.startApp('notepad.exe');
380
+ const win = await result.session.computer.getActiveWindow();
381
+ await result.session.computer.maximizeWindow(win.window!.id);
382
+ await result.session.delete();
383
+ }
384
+ ```
385
+
386
+ ___
387
+
388
+ ### minimizeWindow
389
+
390
+ ▸ **minimizeWindow**(`windowId`): `Promise`\<`BoolResult`\>
391
+
392
+ Minimizes the specified window.
393
+
394
+ #### Parameters
395
+
396
+ | Name | Type | Description |
397
+ | :------ | :------ | :------ |
398
+ | `windowId` | `number` | ID of the window to minimize |
399
+
400
+ #### Returns
401
+
402
+ `Promise`\<`BoolResult`\>
403
+
404
+ Promise resolving to result with success status
405
+
406
+ **`Example`**
407
+
408
+ ```typescript
409
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
410
+ const result = await agentBay.create({ imageId: 'windows_latest' });
411
+ if (result.success) {
412
+ await result.session.computer.startApp('notepad.exe');
413
+ const win = await result.session.computer.getActiveWindow();
414
+ await result.session.computer.minimizeWindow(win.window!.id);
415
+ await result.session.delete();
416
+ }
417
+ ```
418
+
419
+ ___
420
+
421
+ ### moveMouse
422
+
423
+ ▸ **moveMouse**(`x`, `y`): `Promise`\<`BoolResult`\>
424
+
425
+ Move mouse to specified coordinates.
426
+
427
+ #### Parameters
428
+
429
+ | Name | Type | Description |
430
+ | :------ | :------ | :------ |
431
+ | `x` | `number` | X coordinate to move to |
432
+ | `y` | `number` | Y coordinate to move to |
433
+
434
+ #### Returns
435
+
436
+ `Promise`\<`BoolResult`\>
437
+
438
+ Promise resolving to result with success status
439
+
440
+ **`Example`**
441
+
442
+ ```typescript
443
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
444
+ const result = await agentBay.create({ imageId: 'windows_latest' });
445
+ if (result.success) {
446
+ await result.session.computer.moveMouse(300, 400);
447
+ const pos = await result.session.computer.getCursorPosition();
448
+ console.log(`Position: (${pos.x}, ${pos.y})`);
449
+ await result.session.delete();
450
+ }
451
+ ```
452
+
453
+ ___
454
+
455
+ ### pressKeys
456
+
457
+ ▸ **pressKeys**(`keys`, `hold?`): `Promise`\<`BoolResult`\>
458
+
459
+ Press one or more keys.
460
+
461
+ #### Parameters
462
+
463
+ | Name | Type | Default value | Description |
464
+ | :------ | :------ | :------ | :------ |
465
+ | `keys` | `string`[] | `undefined` | Array of key names to press |
466
+ | `hold` | `boolean` | `false` | Whether to hold the keys down (default: false) |
467
+
468
+ #### Returns
469
+
470
+ `Promise`\<`BoolResult`\>
471
+
472
+ Promise resolving to result with success status
473
+
474
+ **`Example`**
475
+
476
+ ```typescript
477
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
478
+ const result = await agentBay.create({ imageId: 'windows_latest' });
479
+ if (result.success) {
480
+ await result.session.computer.pressKeys(['Ctrl', 'c'], true);
481
+ await result.session.computer.releaseKeys(['Ctrl', 'c']);
482
+ await result.session.delete();
483
+ }
484
+ ```
485
+
486
+ ___
487
+
488
+ ### releaseKeys
489
+
490
+ ▸ **releaseKeys**(`keys`): `Promise`\<`BoolResult`\>
491
+
492
+ Release previously pressed keys.
493
+
494
+ #### Parameters
495
+
496
+ | Name | Type | Description |
497
+ | :------ | :------ | :------ |
498
+ | `keys` | `string`[] | Array of key names to release |
499
+
500
+ #### Returns
501
+
502
+ `Promise`\<`BoolResult`\>
503
+
504
+ Promise resolving to result with success status
505
+
506
+ **`Example`**
507
+
508
+ ```typescript
509
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
510
+ const result = await agentBay.create({ imageId: 'windows_latest' });
511
+ if (result.success) {
512
+ await result.session.computer.pressKeys(['Ctrl'], true);
513
+ await result.session.computer.releaseKeys(['Ctrl']);
514
+ await result.session.delete();
515
+ }
516
+ ```
517
+
518
+ ___
519
+
520
+ ### resizeWindow
521
+
522
+ ▸ **resizeWindow**(`windowId`, `width`, `height`): `Promise`\<`BoolResult`\>
523
+
524
+ Resizes the specified window.
525
+
526
+ #### Parameters
527
+
528
+ | Name | Type | Description |
529
+ | :------ | :------ | :------ |
530
+ | `windowId` | `number` | ID of the window to resize |
531
+ | `width` | `number` | New width of the window |
532
+ | `height` | `number` | New height of the window |
533
+
534
+ #### Returns
535
+
536
+ `Promise`\<`BoolResult`\>
537
+
538
+ Promise resolving to result with success status
539
+
540
+ **`Example`**
541
+
542
+ ```typescript
543
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
544
+ const result = await agentBay.create({ imageId: 'windows_latest' });
545
+ if (result.success) {
546
+ await result.session.computer.startApp('notepad.exe');
547
+ const win = await result.session.computer.getActiveWindow();
548
+ await result.session.computer.resizeWindow(win.window!.id, 800, 600);
549
+ await result.session.delete();
550
+ }
551
+ ```
552
+
553
+ ___
554
+
555
+ ### restoreWindow
556
+
557
+ ▸ **restoreWindow**(`windowId`): `Promise`\<`BoolResult`\>
558
+
559
+ Restores the specified window.
560
+
561
+ #### Parameters
562
+
563
+ | Name | Type | Description |
564
+ | :------ | :------ | :------ |
565
+ | `windowId` | `number` | ID of the window to restore |
566
+
567
+ #### Returns
568
+
569
+ `Promise`\<`BoolResult`\>
570
+
571
+ Promise resolving to result with success status
572
+
573
+ **`Example`**
574
+
575
+ ```typescript
576
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
577
+ const result = await agentBay.create({ imageId: 'windows_latest' });
578
+ if (result.success) {
579
+ await result.session.computer.startApp('notepad.exe');
580
+ const win = await result.session.computer.getActiveWindow();
581
+ await result.session.computer.minimizeWindow(win.window!.id);
582
+ await result.session.computer.restoreWindow(win.window!.id);
583
+ await result.session.delete();
584
+ }
585
+ ```
586
+
587
+ ___
588
+
589
+ ### screenshot
590
+
591
+ ▸ **screenshot**(): `Promise`\<`ScreenshotResult`\>
592
+
593
+ Take a screenshot.
594
+
595
+ #### Returns
596
+
597
+ `Promise`\<`ScreenshotResult`\>
598
+
599
+ Promise resolving to result containing screenshot URL
600
+
601
+ **`Example`**
602
+
603
+ ```typescript
604
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
605
+ const result = await agentBay.create({ imageId: 'windows_latest' });
606
+ if (result.success) {
607
+ const screenshot = await result.session.computer.screenshot();
608
+ console.log('Screenshot URL:', screenshot.data);
609
+ await result.session.delete();
610
+ }
611
+ ```
612
+
613
+ ___
614
+
615
+ ### scroll
616
+
617
+ ▸ **scroll**(`x`, `y`, `direction?`, `amount?`): `Promise`\<`BoolResult`\>
618
+
619
+ Scroll at specified coordinates.
620
+
621
+ #### Parameters
622
+
623
+ | Name | Type | Default value | Description |
624
+ | :------ | :------ | :------ | :------ |
625
+ | `x` | `number` | `undefined` | X coordinate to scroll at |
626
+ | `y` | `number` | `undefined` | Y coordinate to scroll at |
627
+ | `direction` | `string` | `ScrollDirection.UP` | Scroll direction (default: 'up'). Valid values: 'up', 'down', 'left', 'right' |
628
+ | `amount` | `number` | `1` | Scroll amount (default: 1) |
629
+
630
+ #### Returns
631
+
632
+ `Promise`\<`BoolResult`\>
633
+
634
+ Promise resolving to result with success status
635
+
636
+ **`Example`**
637
+
638
+ ```typescript
639
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
640
+ const result = await agentBay.create({ imageId: 'windows_latest' });
641
+ if (result.success) {
642
+ await result.session.computer.scroll(400, 300, 'up', 3);
643
+ await result.session.delete();
644
+ }
645
+ ```
646
+
647
+ ___
648
+
649
+ ### startApp
650
+
651
+ ▸ **startApp**(`startCmd`, `workDirectory?`, `activity?`): `Promise`\<`any`\>
652
+
653
+ Starts the specified application.
654
+
655
+ #### Parameters
656
+
657
+ | Name | Type | Default value | Description |
658
+ | :------ | :------ | :------ | :------ |
659
+ | `startCmd` | `string` | `undefined` | The command to start the application (e.g., 'notepad.exe', 'calculator:') |
660
+ | `workDirectory` | `string` | `""` | The working directory for the application (optional) |
661
+ | `activity` | `string` | `""` | The activity parameter (optional, primarily for mobile use) |
662
+
663
+ #### Returns
664
+
665
+ `Promise`\<`any`\>
666
+
667
+ Promise resolving to result containing array of started processes
668
+
669
+ **`Example`**
670
+
671
+ ```typescript
672
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
673
+ const result = await agentBay.create({ imageId: 'windows_latest' });
674
+ if (result.success) {
675
+ const startResult = await result.session.computer.startApp('notepad.exe');
676
+ console.log(`Started ${startResult.data.length} process(es)`);
677
+ await result.session.delete();
678
+ }
679
+ ```
680
+
681
+ ___
682
+
683
+ ### stopAppByCmd
684
+
685
+ ▸ **stopAppByCmd**(`cmd`): `Promise`\<`any`\>
686
+
687
+ Stops an application by stop command.
688
+
689
+ #### Parameters
690
+
691
+ | Name | Type | Description |
692
+ | :------ | :------ | :------ |
693
+ | `cmd` | `string` | The command to stop the application |
694
+
695
+ #### Returns
696
+
697
+ `Promise`\<`any`\>
698
+
699
+ Promise resolving to result with success status
700
+
701
+ **`Example`**
702
+
703
+ ```typescript
704
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
705
+ const result = await agentBay.create({ imageId: 'windows_latest' });
706
+ if (result.success) {
707
+ await result.session.computer.startApp('notepad.exe');
708
+ await result.session.computer.stopAppByCmd('taskkill /IM notepad.exe /F');
709
+ await result.session.delete();
710
+ }
711
+ ```
712
+
713
+ ___
714
+
715
+ ### stopAppByPID
716
+
717
+ ▸ **stopAppByPID**(`pid`): `Promise`\<`any`\>
718
+
719
+ Stops an application by process ID.
720
+
721
+ #### Parameters
722
+
723
+ | Name | Type | Description |
724
+ | :------ | :------ | :------ |
725
+ | `pid` | `number` | The process ID to stop |
726
+
727
+ #### Returns
728
+
729
+ `Promise`\<`any`\>
730
+
731
+ Promise resolving to result with success status
732
+
733
+ **`Example`**
734
+
735
+ ```typescript
736
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
737
+ const result = await agentBay.create({ imageId: 'windows_latest' });
738
+ if (result.success) {
739
+ const startResult = await result.session.computer.startApp('notepad.exe');
740
+ const pid = startResult.data[0].pid;
741
+ await result.session.computer.stopAppByPID(pid);
742
+ await result.session.delete();
743
+ }
744
+ ```
745
+
746
+ ___
747
+
748
+ ### stopAppByPName
749
+
750
+ ▸ **stopAppByPName**(`pname`): `Promise`\<`any`\>
751
+
752
+ Stops an application by process name.
753
+
754
+ #### Parameters
755
+
756
+ | Name | Type | Description |
757
+ | :------ | :------ | :------ |
758
+ | `pname` | `string` | The process name to stop (e.g., 'notepad.exe', 'chrome.exe') |
759
+
760
+ #### Returns
761
+
762
+ `Promise`\<`any`\>
763
+
764
+ Promise resolving to result with success status
765
+
766
+ **`Example`**
767
+
768
+ ```typescript
769
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
770
+ const result = await agentBay.create({ imageId: 'windows_latest' });
771
+ if (result.success) {
772
+ await result.session.computer.startApp('notepad.exe');
773
+ await result.session.computer.stopAppByPName('notepad.exe');
774
+ await result.session.delete();
775
+ }
776
+ ```
777
+
778
+ ## Best Practices
779
+
780
+ 1. Verify screen coordinates before mouse operations
781
+ 2. Use appropriate delays between UI interactions
782
+ 3. Handle window focus changes properly
783
+ 4. Take screenshots for verification and debugging
784
+ 5. Use keyboard shortcuts for efficient automation
785
+ 6. Clean up windows and applications after automation
786
+