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,542 @@
1
+ # Class: Session
2
+
3
+ ## 🔧 Related Tutorial
4
+
5
+ - [Session Management Guide](../../../../../docs/guides/common-features/basics/session-management.md) - Detailed tutorial on session lifecycle and management
6
+
7
+ Represents a session in the AgentBay cloud environment.
8
+
9
+ ## Table of contents
10
+
11
+
12
+ ### Properties
13
+
14
+
15
+ ### Methods
16
+
17
+ - [callMcpTool](#callmcptool)
18
+ - [delete](#delete)
19
+ - [getLabels](#getlabels)
20
+ - [getLink](#getlink)
21
+ - [getLinkAsync](#getlinkasync)
22
+ - [info](#info)
23
+ - [listMcpTools](#listmcptools)
24
+ - [pauseAsync](#pauseasync)
25
+ - [resumeAsync](#resumeasync)
26
+ - [setLabels](#setlabels)
27
+
28
+ ## Properties
29
+
30
+ ```typescript
31
+ agent: [`Agent`](../advanced/agent.md)
32
+ browser: [`Browser`](../../browser-use/browser.md)
33
+ code: [`Code`](../../codespace/code.md)
34
+ command: [`Command`](command.md)
35
+ computer: [`Computer`](../../computer-use/computer.md)
36
+ context: [`ContextManager`](context-manager.md)
37
+ enableBrowserReplay: `boolean` = `false`
38
+ fileSystem: [`FileSystem`](filesystem.md)
39
+ fileTransferContextId: ``null`` | `string` = `null`
40
+ httpPort: `string` = `""`
41
+ isVpc: `boolean` = `false`
42
+ mcpTools: `McpTool`[] = `[]`
43
+ mobile: [`Mobile`](../../mobile-use/mobile.md)
44
+ networkInterfaceIp: `string` = `""`
45
+ oss: [`Oss`](../advanced/oss.md)
46
+ recordContextId: ``null`` | `string` = `null`
47
+ resourceUrl: `string` = `""`
48
+ sessionId: `string`
49
+ token: `string` = `""`
50
+ ```
51
+
52
+
53
+ ## Methods
54
+
55
+ ### callMcpTool
56
+
57
+ ▸ **callMcpTool**(`toolName`, `args`, `autoGenSession?`): `Promise`\<``McpToolResult``\>
58
+
59
+ Call an MCP tool and return the result in a format compatible with Agent.
60
+
61
+ #### Parameters
62
+
63
+ | Name | Type | Default value | Description |
64
+ | :------ | :------ | :------ | :------ |
65
+ | `toolName` | `string` | `undefined` | Name of the MCP tool to call |
66
+ | `args` | `any` | `undefined` | Arguments to pass to the tool |
67
+ | `autoGenSession` | `boolean` | `false` | Whether to automatically generate session if not exists (default: false) |
68
+
69
+ #### Returns
70
+
71
+ `Promise`\<``McpToolResult``\>
72
+
73
+ McpToolResult containing the response data
74
+
75
+ **`Example`**
76
+
77
+ ```typescript
78
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
79
+ const result = await agentBay.create();
80
+ if (result.success) {
81
+ const shellResult = await result.session.callMcpTool('shell', { command: "echo 'Hello'" });
82
+ console.log(`Output: ${shellResult.data}`);
83
+ await result.session.delete();
84
+ }
85
+ ```
86
+
87
+ **`Remarks`**
88
+
89
+ For press_keys tool, key names are automatically normalized to correct case format.
90
+ This improves case compatibility (e.g., "CTRL" -> "Ctrl", "tab" -> "Tab").
91
+
92
+ ___
93
+
94
+ ### delete
95
+
96
+ ▸ **delete**(`syncContext?`): `Promise`\<``DeleteResult``\>
97
+
98
+ Deletes the session and releases all associated resources.
99
+
100
+ #### Parameters
101
+
102
+ | Name | Type | Default value | Description |
103
+ | :------ | :------ | :------ | :------ |
104
+ | `syncContext` | `boolean` | `false` | Whether to synchronize context data before deletion. If true, uploads all context data to OSS. If false but browser replay is enabled, syncs only the recording context. Defaults to false. |
105
+
106
+ #### Returns
107
+
108
+ `Promise`\<``DeleteResult``\>
109
+
110
+ Promise resolving to DeleteResult containing:
111
+ - success: Whether deletion succeeded
112
+ - requestId: Unique identifier for this API request
113
+ - errorMessage: Error description if deletion failed
114
+
115
+ **`Throws`**
116
+
117
+ Error if the API call fails or network issues occur.
118
+
119
+ **`Example`**
120
+
121
+ ```typescript
122
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
123
+ const result = await agentBay.create();
124
+ if (result.success) {
125
+ await result.session.fileSystem.writeFile('/tmp/data.txt', 'data');
126
+ const deleteResult = await result.session.delete(true);
127
+ console.log('Session deleted:', deleteResult.success);
128
+ }
129
+ ```
130
+
131
+ **`Remarks`**
132
+
133
+ **Behavior:**
134
+ - If `syncContext=true`: Uploads all context data to OSS before deletion
135
+ - If `syncContext=false` but browser replay enabled: Syncs only recording context
136
+ - If `syncContext=false` and no browser replay: Deletes immediately without sync
137
+ - Continues with deletion even if context sync fails
138
+ - Releases all associated resources (browser, computer, mobile, etc.)
139
+
140
+ **Best Practices:**
141
+ - Use `syncContext=true` when you need to preserve context data for later retrieval
142
+ - For temporary sessions, use `syncContext=false` for faster cleanup
143
+ - Always call `delete()` when done to avoid resource leaks
144
+ - Handle deletion errors gracefully in production code
145
+
146
+ **`See`**
147
+
148
+ [info](#info), [ContextManager.sync](context-manager.md#sync)
149
+
150
+ ___
151
+
152
+ ### getLabels
153
+
154
+ ▸ **getLabels**(): `Promise`\<`OperationResult`\>
155
+
156
+ Gets the labels for this session.
157
+
158
+ #### Returns
159
+
160
+ `Promise`\<`OperationResult`\>
161
+
162
+ OperationResult containing the labels as data and request ID
163
+
164
+ **`Throws`**
165
+
166
+ Error if the operation fails (matching Python SessionError)
167
+
168
+ **`Example`**
169
+
170
+ ```typescript
171
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
172
+ const result = await agentBay.create();
173
+ if (result.success) {
174
+ await result.session.setLabels({ project: 'demo', env: 'test' });
175
+ const getResult = await result.session.getLabels();
176
+ console.log('Labels:', JSON.stringify(getResult.data));
177
+ await result.session.delete();
178
+ }
179
+ ```
180
+
181
+ ___
182
+
183
+ ### getLink
184
+
185
+ ▸ **getLink**(`protocolType?`, `port?`, `options?`): `Promise`\<`OperationResult`\>
186
+
187
+ Retrieves an access link for the session.
188
+
189
+ #### Parameters
190
+
191
+ | Name | Type | Description |
192
+ | :------ | :------ | :------ |
193
+ | `protocolType?` | `string` | Protocol type for the link (optional, reserved for future use) |
194
+ | `port?` | `number` | Specific port number to access (must be in range [30100, 30199]). If not specified, returns the default session link. |
195
+ | `options?` | `string` | - |
196
+
197
+ #### Returns
198
+
199
+ `Promise`\<`OperationResult`\>
200
+
201
+ Promise resolving to OperationResult containing:
202
+ - success: Whether the operation succeeded
203
+ - data: String URL for accessing the session
204
+ - requestId: Unique identifier for this API request
205
+ - errorMessage: Error description if operation failed
206
+
207
+ **`Throws`**
208
+
209
+ Error if the API call fails or port is out of valid range.
210
+
211
+ **`Example`**
212
+
213
+ ```typescript
214
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
215
+ const result = await agentBay.create();
216
+ if (result.success) {
217
+ const linkResult = await result.session.getLink();
218
+ console.log(`Session link: ${linkResult.data}`);
219
+ await result.session.delete();
220
+ }
221
+ ```
222
+
223
+ **`Remarks`**
224
+
225
+ **Behavior:**
226
+ - Without port: Returns the default session access URL
227
+ - With port: Returns URL for accessing specific port-mapped service
228
+ - Port must be in range [30100, 30199] for port forwarding
229
+ - For ADB connections, use `session.mobile.getAdbUrl()` with appropriate ADB public key
230
+
231
+ **Best Practices:**
232
+ - Use default link for general session access
233
+ - Use port-specific links when you've started services on specific ports
234
+ - Validate port range before calling to avoid errors
235
+
236
+ **`See`**
237
+
238
+ [info](#info)
239
+
240
+ ___
241
+
242
+ ### getLinkAsync
243
+
244
+ ▸ **getLinkAsync**(`protocolType?`, `port?`, `options?`): `Promise`\<`OperationResult`\>
245
+
246
+ Asynchronously get a link associated with the current session.
247
+
248
+ #### Parameters
249
+
250
+ | Name | Type | Description |
251
+ | :------ | :------ | :------ |
252
+ | `protocolType?` | `string` | Optional protocol type to use for the link |
253
+ | `port?` | `number` | Optional port to use for the link (must be in range [30100, 30199]) |
254
+ | `options?` | `string` | - |
255
+
256
+ #### Returns
257
+
258
+ `Promise`\<`OperationResult`\>
259
+
260
+ OperationResult containing the link as data and request ID
261
+
262
+ **`Throws`**
263
+
264
+ Error if the operation fails (matching Python SessionError)
265
+
266
+ **`Example`**
267
+
268
+ ```typescript
269
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
270
+ const result = await agentBay.create();
271
+ if (result.success) {
272
+ const linkResult = await result.session.getLinkAsync(undefined, 30150);
273
+ console.log(`Port link: ${linkResult.data}`);
274
+ await result.session.delete();
275
+ }
276
+ ```
277
+
278
+ ___
279
+
280
+ ### info
281
+
282
+ ▸ **info**(): `Promise`\<`OperationResult`\>
283
+
284
+ Retrieves detailed information about the current session.
285
+
286
+ #### Returns
287
+
288
+ `Promise`\<`OperationResult`\>
289
+
290
+ Promise resolving to OperationResult containing:
291
+ - success: Whether the operation succeeded (always true if no exception)
292
+ - data: SessionInfo object with the following fields:
293
+ - sessionId (string): The session identifier
294
+ - resourceUrl (string): URL for accessing the session
295
+ - appId (string): Application ID (for desktop sessions)
296
+ - authCode (string): Authentication code
297
+ - connectionProperties (string): Connection configuration
298
+ - resourceId (string): Resource identifier
299
+ - resourceType (string): Type of resource (e.g., "Desktop")
300
+ - ticket (string): Access ticket
301
+ - requestId: Unique identifier for this API request
302
+ - errorMessage: Error description if operation failed
303
+
304
+ **`Throws`**
305
+
306
+ Error if the API request fails or response is invalid.
307
+
308
+ **`Example`**
309
+
310
+ ```typescript
311
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
312
+ const result = await agentBay.create();
313
+ if (result.success) {
314
+ const infoResult = await result.session.info();
315
+ console.log(`Session ID: ${infoResult.data.sessionId}`);
316
+ console.log(`Resource URL: ${infoResult.data.resourceUrl}`);
317
+ await result.session.delete();
318
+ }
319
+ ```
320
+
321
+ **`Remarks`**
322
+
323
+ **Behavior:**
324
+ - This method calls the GetMcpResource API to retrieve session metadata
325
+ - The returned SessionInfo contains:
326
+ - sessionId: The session identifier
327
+ - resourceUrl: URL for accessing the session
328
+ - Desktop-specific fields (appId, authCode, connectionProperties, etc.)
329
+ are populated from the DesktopInfo section of the API response
330
+ - Session info is retrieved from the AgentBay API in real-time
331
+ - The resourceUrl can be used for browser-based access
332
+ - Desktop-specific fields (appId, authCode) are only populated for desktop sessions
333
+ - This method does not modify the session state
334
+
335
+ **`See`**
336
+
337
+ [delete](#delete), [getLink](#getlink)
338
+
339
+ ___
340
+
341
+ ### listMcpTools
342
+
343
+ ▸ **listMcpTools**(`imageId?`): `Promise`\<`McpToolsResult`\>
344
+
345
+ List MCP tools available for this session.
346
+
347
+ #### Parameters
348
+
349
+ | Name | Type | Description |
350
+ | :------ | :------ | :------ |
351
+ | `imageId?` | `string` | Optional image ID, defaults to session's imageId or "linux_latest" |
352
+
353
+ #### Returns
354
+
355
+ `Promise`\<`McpToolsResult`\>
356
+
357
+ McpToolsResult containing tools list and request ID
358
+
359
+ **`Example`**
360
+
361
+ ```typescript
362
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
363
+ const result = await agentBay.create();
364
+ if (result.success) {
365
+ const toolsResult = await result.session.listMcpTools();
366
+ console.log(`Found ${toolsResult.tools.length} MCP tools`);
367
+ await result.session.delete();
368
+ }
369
+ ```
370
+
371
+ ___
372
+
373
+ ### pauseAsync
374
+
375
+ ▸ **pauseAsync**(`timeout?`, `pollInterval?`): `Promise`\<`SessionPauseResult`\>
376
+
377
+ Asynchronously pause this session, putting it into a dormant state.
378
+
379
+ This method calls the PauseSessionAsync API to initiate the pause operation and then polls
380
+ the GetSession API to check the session status until it becomes PAUSED or until timeout is reached.
381
+ During the paused state, resource usage and costs are reduced while session state is preserved.
382
+
383
+ #### Parameters
384
+
385
+ | Name | Type | Default value | Description |
386
+ | :------ | :------ | :------ | :------ |
387
+ | `timeout` | `number` | `600` | Timeout in seconds to wait for the session to pause. Defaults to 600 seconds. |
388
+ | `pollInterval` | `number` | `2.0` | Interval in seconds between status polls. Defaults to 2.0 seconds. |
389
+
390
+ #### Returns
391
+
392
+ `Promise`\<`SessionPauseResult`\>
393
+
394
+ Promise resolving to SessionPauseResult containing:
395
+ - success: Whether the pause operation succeeded
396
+ - requestId: Unique identifier for this API request
397
+ - status: Final session status (should be "PAUSED" if successful)
398
+ - errorMessage: Error description if pause failed
399
+
400
+ **`Throws`**
401
+
402
+ Error if the API call fails or network issues occur.
403
+
404
+ **`Example`**
405
+
406
+ ```typescript
407
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
408
+ const result = await agentBay.create();
409
+ if (result.success) {
410
+ const pauseResult = await result.session.pauseAsync();
411
+ if (pauseResult.success) {
412
+ console.log('Session paused successfully');
413
+ }
414
+ }
415
+ ```
416
+
417
+ **`Remarks`**
418
+
419
+ **Behavior:**
420
+ - Initiates pause operation through PauseSessionAsync API
421
+ - Polls session status until PAUSED state or timeout
422
+ - Session state transitions: RUNNING -> PAUSING -> PAUSED
423
+ - All session state is preserved during pause
424
+
425
+ **Important Notes:**
426
+ - Paused sessions cannot perform operations (deletion, task execution, etc.)
427
+ - Use [resumeAsync](#resumeasync) to restore the session to RUNNING state
428
+ - During pause, both resource usage and costs are lower
429
+ - If timeout is exceeded, returns with success=false
430
+
431
+ **`See`**
432
+
433
+ [resumeAsync](#resumeasync)
434
+
435
+ ___
436
+
437
+ ### resumeAsync
438
+
439
+ ▸ **resumeAsync**(`timeout?`, `pollInterval?`): `Promise`\<`SessionResumeResult`\>
440
+
441
+ Asynchronously resume this session from a paused state.
442
+
443
+ This method calls the ResumeSessionAsync API to initiate the resume operation and then polls
444
+ the GetSession API to check the session status until it becomes RUNNING or until timeout is reached.
445
+ After resuming, the session restores full functionality and can perform all operations normally.
446
+
447
+ #### Parameters
448
+
449
+ | Name | Type | Default value | Description |
450
+ | :------ | :------ | :------ | :------ |
451
+ | `timeout` | `number` | `600` | Timeout in seconds to wait for the session to resume. Defaults to 600 seconds. |
452
+ | `pollInterval` | `number` | `2.0` | Interval in seconds between status polls. Defaults to 2.0 seconds. |
453
+
454
+ #### Returns
455
+
456
+ `Promise`\<`SessionResumeResult`\>
457
+
458
+ Promise resolving to SessionResumeResult containing:
459
+ - success: Whether the resume operation succeeded
460
+ - requestId: Unique identifier for this API request
461
+ - status: Final session status (should be "RUNNING" if successful)
462
+ - errorMessage: Error description if resume failed
463
+
464
+ **`Throws`**
465
+
466
+ Error if the API call fails or network issues occur.
467
+
468
+ **`Example`**
469
+
470
+ ```typescript
471
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
472
+ const result = await agentBay.get('paused_session_id');
473
+ if (result.success) {
474
+ const resumeResult = await result.session.resumeAsync();
475
+ if (resumeResult.success) {
476
+ console.log('Session resumed successfully');
477
+ }
478
+ }
479
+ ```
480
+
481
+ **`Remarks`**
482
+
483
+ **Behavior:**
484
+ - Initiates resume operation through ResumeSessionAsync API
485
+ - Polls session status until RUNNING state or timeout
486
+ - Session state transitions: PAUSED -> RESUMING -> RUNNING
487
+ - All previous session state is restored during resume
488
+
489
+ **Important Notes:**
490
+ - Only sessions in PAUSED state can be resumed
491
+ - After resume, the session can perform all operations normally
492
+ - Use [pauseAsync](#pauseasync) to put a session into PAUSED state
493
+ - If timeout is exceeded, returns with success=false
494
+
495
+ **`See`**
496
+
497
+ [pauseAsync](#pauseasync)
498
+
499
+ ___
500
+
501
+ ### setLabels
502
+
503
+ ▸ **setLabels**(`labels`): `Promise`\<`OperationResult`\>
504
+
505
+ Sets the labels for this session.
506
+
507
+ #### Parameters
508
+
509
+ | Name | Type | Description |
510
+ | :------ | :------ | :------ |
511
+ | `labels` | `Record`\<`string`, `string`\> | The labels to set for the session. |
512
+
513
+ #### Returns
514
+
515
+ `Promise`\<`OperationResult`\>
516
+
517
+ OperationResult indicating success or failure with request ID
518
+
519
+ **`Throws`**
520
+
521
+ Error if the operation fails (matching Python SessionError)
522
+
523
+ **`Example`**
524
+
525
+ ```typescript
526
+ const agentBay = new AgentBay({ apiKey: 'your_api_key' });
527
+ const result = await agentBay.create();
528
+ if (result.success) {
529
+ const setResult = await result.session.setLabels({ project: 'demo', env: 'test' });
530
+ console.log('Labels set:', setResult.success);
531
+ await result.session.delete();
532
+ }
533
+ ```
534
+
535
+ ## Related Resources
536
+
537
+ - [FileSystem API Reference](filesystem.md)
538
+ - [Command API Reference](command.md)
539
+ - [Context API Reference](context.md)
540
+ - [Context Manager API Reference](context-manager.md)
541
+ - [OSS API Reference](../../common-features/advanced/oss.md)
542
+