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,395 @@
1
+ # Class: Mobile
2
+
3
+ ## 📱 Related Tutorial
4
+
5
+ - [Mobile Use Guide](../../../../docs/guides/mobile-use/README.md) - Automate mobile applications
6
+
7
+ ## Overview
8
+
9
+ The Mobile module provides mobile device automation capabilities including touch gestures,
10
+ text input, app management, and screenshot capture. It supports Android device automation.
11
+
12
+
13
+ ## Requirements
14
+
15
+ - Requires `mobile_latest` image for mobile automation features
16
+
17
+ ## Table of contents
18
+
19
+
20
+ ### Methods
21
+
22
+ - [configure](#configure)
23
+ - [inputText](#inputtext)
24
+ - [screenshot](#screenshot)
25
+ - [sendKey](#sendkey)
26
+ - [setAppBlacklist](#setappblacklist)
27
+ - [setAppWhitelist](#setappwhitelist)
28
+ - [setNavigationBarVisibility](#setnavigationbarvisibility)
29
+ - [setResolutionLock](#setresolutionlock)
30
+ - [setUninstallBlacklist](#setuninstallblacklist)
31
+ - [startApp](#startapp)
32
+ - [stopAppByCmd](#stopappbycmd)
33
+ - [swipe](#swipe)
34
+ - [tap](#tap)
35
+
36
+ ## Methods
37
+
38
+ ### configure
39
+
40
+ ▸ **configure**(`config`): `Promise`\<`OperationResult`\>
41
+
42
+ Configure mobile device settings based on MobileExtraConfig.
43
+ This method applies various mobile configuration settings including
44
+ resolution lock and app access management.
45
+
46
+ #### Parameters
47
+
48
+ | Name | Type | Description |
49
+ | :------ | :------ | :------ |
50
+ | `config` | ``MobileExtraConfig`` | The mobile configuration to apply |
51
+
52
+ #### Returns
53
+
54
+ `Promise`\<`OperationResult`\>
55
+
56
+ OperationResult indicating success or failure
57
+
58
+ ### inputText
59
+
60
+ ▸ **inputText**(`text`): `Promise`\<`BoolResult`\>
61
+
62
+ Input text at the current focus position.
63
+
64
+ #### Parameters
65
+
66
+ | Name | Type | Description |
67
+ | :------ | :------ | :------ |
68
+ | `text` | `string` | Text to input |
69
+
70
+ #### Returns
71
+
72
+ `Promise`\<`BoolResult`\>
73
+
74
+ Promise resolving to BoolResult with success status
75
+
76
+ **`Example`**
77
+
78
+ ```typescript
79
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
80
+ const result = await agentBay.create({ imageId: 'mobile_latest' });
81
+ if (result.success) {
82
+ const inputResult = await result.session.mobile.inputText('Hello Mobile');
83
+ console.log('Text input successfully:', inputResult.success);
84
+ await result.session.delete();
85
+ }
86
+ ```
87
+
88
+ ___
89
+
90
+ ### screenshot
91
+
92
+ ▸ **screenshot**(): `Promise`\<`ScreenshotResult`\>
93
+
94
+ Take a screenshot of the current mobile screen.
95
+
96
+ #### Returns
97
+
98
+ `Promise`\<`ScreenshotResult`\>
99
+
100
+ Promise resolving to ScreenshotResult containing screenshot URL
101
+
102
+ **`Example`**
103
+
104
+ ```typescript
105
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
106
+ const result = await agentBay.create({ imageId: 'mobile_latest' });
107
+ if (result.success) {
108
+ const screenshotResult = await result.session.mobile.screenshot();
109
+ console.log('Screenshot URL:', screenshotResult.data);
110
+ await result.session.delete();
111
+ }
112
+ ```
113
+
114
+ ___
115
+
116
+ ### sendKey
117
+
118
+ ▸ **sendKey**(`key`): `Promise`\<`BoolResult`\>
119
+
120
+ Send Android key code.
121
+
122
+ #### Parameters
123
+
124
+ | Name | Type | Description |
125
+ | :------ | :------ | :------ |
126
+ | `key` | `number` | Android key code (e.g., 4 for BACK, 3 for HOME, 24 for VOLUME_UP) |
127
+
128
+ #### Returns
129
+
130
+ `Promise`\<`BoolResult`\>
131
+
132
+ Promise resolving to BoolResult with success status
133
+
134
+ **`Example`**
135
+
136
+ ```typescript
137
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
138
+ const result = await agentBay.create({ imageId: 'mobile_latest' });
139
+ if (result.success) {
140
+ const keyResult = await result.session.mobile.sendKey(4);
141
+ console.log('BACK key sent:', keyResult.success);
142
+ await result.session.delete();
143
+ }
144
+ ```
145
+
146
+ ___
147
+
148
+ ### setAppBlacklist
149
+
150
+ ▸ **setAppBlacklist**(`packageNames`): `Promise`\<`OperationResult`\>
151
+
152
+ Set app blacklist configuration.
153
+
154
+ #### Parameters
155
+
156
+ | Name | Type | Description |
157
+ | :------ | :------ | :------ |
158
+ | `packageNames` | `string`[] | List of package names to blacklist |
159
+
160
+ #### Returns
161
+
162
+ `Promise`\<`OperationResult`\>
163
+
164
+ OperationResult indicating success or failure
165
+
166
+ ___
167
+
168
+ ### setAppWhitelist
169
+
170
+ ▸ **setAppWhitelist**(`packageNames`): `Promise`\<`OperationResult`\>
171
+
172
+ Set app whitelist configuration.
173
+
174
+ #### Parameters
175
+
176
+ | Name | Type | Description |
177
+ | :------ | :------ | :------ |
178
+ | `packageNames` | `string`[] | List of package names to whitelist |
179
+
180
+ #### Returns
181
+
182
+ `Promise`\<`OperationResult`\>
183
+
184
+ OperationResult indicating success or failure
185
+
186
+ ___
187
+
188
+ ### setNavigationBarVisibility
189
+
190
+ ▸ **setNavigationBarVisibility**(`hide`): `Promise`\<`OperationResult`\>
191
+
192
+ Set navigation bar visibility for mobile devices.
193
+
194
+ #### Parameters
195
+
196
+ | Name | Type | Description |
197
+ | :------ | :------ | :------ |
198
+ | `hide` | `boolean` | True to hide navigation bar, false to show navigation bar |
199
+
200
+ #### Returns
201
+
202
+ `Promise`\<`OperationResult`\>
203
+
204
+ OperationResult indicating success or failure
205
+
206
+ ___
207
+
208
+ ### setResolutionLock
209
+
210
+ ▸ **setResolutionLock**(`enable`): `Promise`\<`OperationResult`\>
211
+
212
+ Set display resolution lock for mobile devices.
213
+
214
+ #### Parameters
215
+
216
+ | Name | Type | Description |
217
+ | :------ | :------ | :------ |
218
+ | `enable` | `boolean` | Whether to enable resolution lock |
219
+
220
+ #### Returns
221
+
222
+ `Promise`\<`OperationResult`\>
223
+
224
+ OperationResult indicating success or failure
225
+
226
+ ___
227
+
228
+ ### setUninstallBlacklist
229
+
230
+ ▸ **setUninstallBlacklist**(`packageNames`): `Promise`\<`OperationResult`\>
231
+
232
+ Set uninstall protection blacklist for mobile devices.
233
+
234
+ #### Parameters
235
+
236
+ | Name | Type | Description |
237
+ | :------ | :------ | :------ |
238
+ | `packageNames` | `string`[] | List of Android package names to protect from uninstallation |
239
+
240
+ #### Returns
241
+
242
+ `Promise`\<`OperationResult`\>
243
+
244
+ OperationResult indicating success or failure
245
+
246
+ ___
247
+
248
+ ### startApp
249
+
250
+ ▸ **startApp**(`startCmd`, `workDirectory?`, `activity?`): `Promise`\<`ProcessResult`\>
251
+
252
+ Start an app.
253
+
254
+ #### Parameters
255
+
256
+ | Name | Type | Default value | Description |
257
+ | :------ | :------ | :------ | :------ |
258
+ | `startCmd` | `string` | `undefined` | Start command using "monkey -p" format (e.g., 'monkey -p com.android.settings') |
259
+ | `workDirectory` | `string` | `''` | Optional working directory for the app |
260
+ | `activity` | `string` | `''` | Optional activity name to launch |
261
+
262
+ #### Returns
263
+
264
+ `Promise`\<`ProcessResult`\>
265
+
266
+ Promise resolving to ProcessResult containing launched process information
267
+
268
+ **`Example`**
269
+
270
+ ```typescript
271
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
272
+ const result = await agentBay.create({ imageId: 'mobile_latest' });
273
+ if (result.success) {
274
+ const startResult = await result.session.mobile.startApp('monkey -p com.android.settings');
275
+ console.log('App started:', startResult.success);
276
+ await result.session.delete();
277
+ }
278
+ ```
279
+
280
+ ___
281
+
282
+ ### stopAppByCmd
283
+
284
+ ▸ **stopAppByCmd**(`stopCmd`): `Promise`\<`BoolResult`\>
285
+
286
+ Stop app by command.
287
+
288
+ #### Parameters
289
+
290
+ | Name | Type | Description |
291
+ | :------ | :------ | :------ |
292
+ | `stopCmd` | `string` | Package name of the app to stop (e.g., 'com.android.settings') |
293
+
294
+ #### Returns
295
+
296
+ `Promise`\<`BoolResult`\>
297
+
298
+ Promise resolving to BoolResult with success status
299
+
300
+ **`Example`**
301
+
302
+ ```typescript
303
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
304
+ const result = await agentBay.create({ imageId: 'mobile_latest' });
305
+ if (result.success) {
306
+ await result.session.mobile.startApp('monkey -p com.android.settings');
307
+ const stopResult = await result.session.mobile.stopAppByCmd('com.android.settings');
308
+ console.log('App stopped:', stopResult.success);
309
+ await result.session.delete();
310
+ }
311
+ ```
312
+
313
+ ___
314
+
315
+ ### swipe
316
+
317
+ ▸ **swipe**(`startX`, `startY`, `endX`, `endY`, `durationMs?`): `Promise`\<`BoolResult`\>
318
+
319
+ Swipe from one position to another on the mobile screen.
320
+
321
+ #### Parameters
322
+
323
+ | Name | Type | Default value | Description |
324
+ | :------ | :------ | :------ | :------ |
325
+ | `startX` | `number` | `undefined` | Starting X coordinate |
326
+ | `startY` | `number` | `undefined` | Starting Y coordinate |
327
+ | `endX` | `number` | `undefined` | Ending X coordinate |
328
+ | `endY` | `number` | `undefined` | Ending Y coordinate |
329
+ | `durationMs` | `number` | `300` | Swipe duration in milliseconds. Default is 300 |
330
+
331
+ #### Returns
332
+
333
+ `Promise`\<`BoolResult`\>
334
+
335
+ Promise resolving to BoolResult with success status
336
+
337
+ **`Example`**
338
+
339
+ ```typescript
340
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
341
+ const result = await agentBay.create({ imageId: 'mobile_latest' });
342
+ if (result.success) {
343
+ const swipeResult = await result.session.mobile.swipe(200, 400, 200, 100, 300);
344
+ console.log('Swipe success:', swipeResult.success);
345
+ await result.session.delete();
346
+ }
347
+ ```
348
+
349
+ ___
350
+
351
+ ### tap
352
+
353
+ ▸ **tap**(`x`, `y`): `Promise`\<`BoolResult`\>
354
+
355
+ Tap at specified coordinates on the mobile screen.
356
+
357
+ #### Parameters
358
+
359
+ | Name | Type | Description |
360
+ | :------ | :------ | :------ |
361
+ | `x` | `number` | X coordinate for the tap |
362
+ | `y` | `number` | Y coordinate for the tap |
363
+
364
+ #### Returns
365
+
366
+ `Promise`\<`BoolResult`\>
367
+
368
+ Promise resolving to BoolResult with success status
369
+
370
+ **`Example`**
371
+
372
+ ```typescript
373
+ const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
374
+ const result = await agentBay.create({ imageId: 'mobile_latest' });
375
+ if (result.success) {
376
+ const tapResult = await result.session.mobile.tap(100, 100);
377
+ console.log('Tap success:', tapResult.success);
378
+ await result.session.delete();
379
+ }
380
+ ```
381
+
382
+ ## Best Practices
383
+
384
+ 1. Verify element coordinates before tap operations
385
+ 2. Use appropriate swipe durations for smooth gestures
386
+ 3. Wait for UI elements to load before interaction
387
+ 4. Take screenshots for verification and debugging
388
+ 5. Handle app installation and uninstallation properly
389
+ 6. Configure app whitelists/blacklists for security
390
+
391
+
392
+ ## Related Resources
393
+
394
+ - [Session API Reference](../common-features/basics/session.md)
395
+
@@ -0,0 +1,332 @@
1
+ # TypeScript SDK Examples
2
+
3
+ This directory contains TypeScript examples demonstrating various features and capabilities of the AgentBay SDK.
4
+
5
+ ## 📁 Directory Structure
6
+
7
+ The examples are organized by feature categories:
8
+
9
+ ```
10
+ examples/
11
+ ├── basic-usage.ts # Quick start single-file example
12
+ ├── common-features/ # Features available across all environments
13
+ │ ├── basics/ # Essential features
14
+ │ │ ├── session-creation/ # Session lifecycle management
15
+ │ │ ├── command-example/ # Command execution
16
+ │ │ ├── filesystem-example/ # File operations and monitoring
17
+ │ │ ├── context-management/ # Context creation and management
18
+ │ │ ├── data-persistence/ # Data persistence across sessions
19
+ │ │ ├── list_sessions/ # Session listing and filtering
20
+ │ │ └── get/ # Session retrieval
21
+ │ └── advanced/ # Advanced features
22
+ │ ├── agent-module-example/ # AI-powered automation
23
+ │ ├── vpc-session-example/ # Secure isolated network environments
24
+ │ └── archive-upload-mode-example/ # Archive upload mode
25
+ ├── browser-use/ # Browser automation (browser_latest)
26
+ │ ├── browser/ # Browser automation examples
27
+ │ └── extension-example/ # Browser extension management
28
+ ├── computer-use/ # Windows desktop automation (windows_latest)
29
+ │ └── ui-example/ # UI automation
30
+ ├── mobile-use/ # Mobile UI automation (mobile_latest)
31
+ │ └── mobile-get-adb-url/ # ADB URL retrieval
32
+ └── codespace/ # Code execution (code_latest)
33
+ └── automation/ # Automation workflows
34
+ ```
35
+
36
+ ## 🚀 Quick Start
37
+
38
+ ### Single-File Example
39
+
40
+ The fastest way to get started:
41
+
42
+ ```bash
43
+ # Install dependencies
44
+ npm install wuying-agentbay-sdk
45
+
46
+ # Set your API key
47
+ export AGENTBAY_API_KEY=your_api_key_here
48
+
49
+ # Run the quick start example
50
+ npx ts-node basic-usage.ts
51
+ ```
52
+
53
+ This example demonstrates:
54
+ - Initializing the AgentBay client
55
+ - Creating sessions
56
+ - Basic operations (commands, file operations)
57
+ - Session cleanup
58
+
59
+ ## 📚 Feature Categories
60
+
61
+ ### [Common Features](common-features/basics/command-example/README.md)
62
+
63
+ Features available across all environment types (browser, computer, mobile, codespace).
64
+
65
+ **Basics:**
66
+ - **Session Management**: Create, configure, and manage cloud sessions
67
+ - **Command Execution**: Execute shell commands in cloud environments
68
+ - **File Operations**: Read, write, and manage files
69
+ - **Context Management**: Persistent data storage across sessions
70
+ - **Data Persistence**: Cross-session data sharing and synchronization
71
+
72
+ **Advanced:**
73
+ - **Agent Module**: AI-powered task automation with natural language
74
+ - **VPC Sessions**: Secure isolated network environments
75
+ - **Archive Upload**: Archive upload mode configuration
76
+
77
+ ### [Browser Use](browser-use/browser/README.md)
78
+
79
+ Cloud-based browser automation with Playwright integration.
80
+
81
+ **Key Features:**
82
+ - Cookie and session persistence
83
+ - Stealth mode to avoid detection
84
+ - CAPTCHA handling capabilities
85
+ - Browser extension support
86
+ - Proxy configuration
87
+ - Custom viewport and fingerprinting
88
+
89
+
90
+ ### [Mobile Use](mobile-use/mobile-get-adb-url/README.md)
91
+
92
+ Android mobile UI automation for app testing.
93
+
94
+ **Key Features:**
95
+ - ADB URL retrieval
96
+ - Mobile device connection
97
+ - Remote debugging
98
+
99
+ ### [CodeSpace](codespace/automation/)
100
+
101
+ Cloud-based development environment for code execution.
102
+
103
+ **Key Features:**
104
+ - Automation workflows
105
+ - Shell command execution
106
+ - File system operations
107
+
108
+ ## 📋 Prerequisites
109
+
110
+ ### Basic Requirements
111
+
112
+ - Node.js 16 or later
113
+ - TypeScript 4.5 or later
114
+ - Valid `AGENTBAY_API_KEY` environment variable
115
+
116
+ ### Installation
117
+
118
+ ```bash
119
+ # Install the SDK
120
+ npm install wuying-agentbay-sdk
121
+
122
+ # For browser examples, install Playwright
123
+ npm install playwright
124
+ npx playwright install chromium
125
+
126
+ # Install TypeScript and ts-node (if not already installed)
127
+ npm install -D typescript ts-node @types/node
128
+ ```
129
+
130
+ ## 🎯 Running Examples
131
+
132
+ ```bash
133
+ # Set your API key
134
+ export AGENTBAY_API_KEY=your_api_key_here
135
+
136
+ # Run any example with ts-node
137
+ npx ts-node basic-usage.ts
138
+ npx ts-node common-features/basics/session-creation/session-creation.ts
139
+
140
+ # Or compile and run
141
+ tsc basic-usage.ts
142
+ node basic-usage.js
143
+ ```
144
+
145
+ ## 💡 Common Patterns
146
+
147
+ ### Basic Session Creation
148
+
149
+ ```typescript
150
+ import { AgentBay, CreateSessionParams } from 'wuying-agentbay-sdk';
151
+
152
+ async function main() {
153
+ // Initialize client
154
+ const apiKey = process.env.AGENTBAY_API_KEY!;
155
+ const agentBay = new AgentBay(apiKey);
156
+
157
+ // Create session
158
+ const params: CreateSessionParams = {
159
+ imageId: 'linux_latest',
160
+ };
161
+
162
+ const result = await agentBay.create(params);
163
+
164
+ if (result.success) {
165
+ const session = result.session;
166
+ console.log(`Session created: ${session.sessionId}`);
167
+
168
+ // Use session...
169
+
170
+ // Cleanup
171
+ await agentBay.delete(session);
172
+ }
173
+ }
174
+
175
+ main().catch(console.error);
176
+ ```
177
+
178
+ ### File Operations
179
+
180
+ ```typescript
181
+ // Write file
182
+ await session.fileSystem.writeFile('/tmp/test.txt', 'content');
183
+
184
+ // Read file
185
+ const result = await session.fileSystem.readFile('/tmp/test.txt');
186
+ if (result.success) {
187
+ console.log(result.content);
188
+ }
189
+ ```
190
+
191
+ ### Command Execution
192
+
193
+ ```typescript
194
+ const result = await session.command.executeCommand('ls -la');
195
+ if (result.success) {
196
+ console.log(result.output);
197
+ }
198
+ ```
199
+
200
+ ### Browser Automation
201
+
202
+ ```typescript
203
+ import { BrowserOption } from 'wuying-agentbay-sdk';
204
+ import { chromium } from 'playwright';
205
+
206
+ // Initialize browser
207
+ const option = new BrowserOption();
208
+ await session.browser.initializeAsync(option);
209
+
210
+ // Connect Playwright
211
+ const endpointUrl = session.browser.getEndpointUrl();
212
+ const browser = await chromium.connectOverCDP(endpointUrl);
213
+ const context = browser.contexts()[0];
214
+ const page = await context.newPage();
215
+
216
+ // Automate...
217
+ await page.goto('https://example.com');
218
+
219
+ await browser.close();
220
+ ```
221
+
222
+ ## 🎓 Learning Path
223
+
224
+ ### For Beginners
225
+
226
+ 1. Start with [basic-usage.ts](basic-usage.ts)
227
+ 2. Explore [Common Features - Basics](common-features/basics/)
228
+ 3. Try environment-specific examples based on your use case
229
+
230
+ ### For Experienced Developers
231
+
232
+ 1. Review [Common Features](common-features/) for SDK capabilities
233
+ 2. Jump to your specific environment:
234
+ - [Browser Use](browser-use/) for web automation
235
+ - [Mobile Use](mobile-use/) for mobile automation
236
+ - [CodeSpace](codespace/) for code execution
237
+ 3. Explore [Advanced Features](common-features/advanced/) for integrations
238
+
239
+ ## 📖 Best Practices
240
+
241
+ 1. **Always Clean Up**: Delete sessions when done to free resources
242
+ 2. **Error Handling**: Always check `result.success` before using data
243
+ 3. **Async/Await**: Use async/await for cleaner asynchronous code
244
+ 4. **Type Safety**: Leverage TypeScript's type system for better code quality
245
+ 5. **Resource Limits**: Be aware of concurrent session limits
246
+
247
+ ## 🔍 Example Index
248
+
249
+ ### By Use Case
250
+
251
+ **Web Automation:**
252
+ - Browser stealth mode: `browser-use/browser/browser-stealth.ts`
253
+ - Cookie persistence: `browser-use/browser/browser-context-cookie-persistence.ts`
254
+ - CAPTCHA handling: `browser-use/browser/captcha_tongcheng.ts`
255
+
256
+ **Desktop Automation:**
257
+ - UI automation: `computer-use/ui-example/ui-example.ts`
258
+
259
+ **Mobile Automation:**
260
+ - ADB integration: `mobile-use/mobile-get-adb-url/index.ts`
261
+
262
+ **Code Execution:**
263
+ - Automation: `codespace/automation/automation-example.ts`
264
+
265
+ **Data Management:**
266
+ - File operations: `common-features/basics/filesystem-example/filesystem-example.ts`
267
+ - Context management: `common-features/basics/context-management/context-management.ts`
268
+ - Data persistence: `common-features/basics/data-persistence/data-persistence.ts`
269
+
270
+ **Advanced Features:**
271
+ - AI Agent: `common-features/advanced/agent-module-example/agent-module-example.ts`
272
+ - VPC sessions: `common-features/advanced/vpc-session-example/vpc-session-example.ts`
273
+
274
+ ## 🆘 Troubleshooting
275
+
276
+ ### Resource Creation Delay
277
+
278
+ If you see "The system is creating resources" message:
279
+ - Wait 90 seconds and retry
280
+ - This is normal for resource initialization
281
+
282
+ ### API Key Issues
283
+
284
+ Ensure your API key is properly set:
285
+ ```bash
286
+ export AGENTBAY_API_KEY=your_api_key_here
287
+ # Verify
288
+ echo $AGENTBAY_API_KEY
289
+ ```
290
+
291
+ ### Module Issues
292
+
293
+ If you get module errors:
294
+ ```bash
295
+ # Ensure dependencies are installed
296
+ npm install
297
+
298
+ # Clear cache and reinstall
299
+ rm -rf node_modules package-lock.json
300
+ npm install
301
+ ```
302
+
303
+ ### TypeScript Compilation Errors
304
+
305
+ If you get TypeScript errors:
306
+ ```bash
307
+ # Ensure TypeScript is installed
308
+ npm install -D typescript
309
+
310
+ # Check TypeScript version
311
+ npx tsc --version
312
+
313
+ # Compile with type checking
314
+ npx tsc --noEmit
315
+ ```
316
+
317
+ ## 📚 Related Documentation
318
+
319
+ - [TypeScript SDK Documentation](../../)
320
+ - [API Reference](../api/)
321
+ - [Quick Start Guide](../../../docs/quickstart/README.md)
322
+ - [Feature Guides](../../../docs/guides/README.md)
323
+
324
+ ## 🤝 Getting Help
325
+
326
+ - [GitHub Issues](https://github.com/aliyun/wuying-agentbay-sdk/issues)
327
+ - [Documentation](../../../docs/README.md)
328
+
329
+ ---
330
+
331
+ 💡 **Tip**: Start with `basic-usage.ts` for a quick overview, then explore category-specific examples based on your needs.
332
+