wuying-agentbay-sdk 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-E7QC5S76.mjs → chunk-P2CXYF4T.mjs} +650 -154
- package/dist/chunk-P2CXYF4T.mjs.map +1 -0
- package/dist/{chunk-ZUB35HKV.cjs → chunk-WVWGLZDT.cjs} +593 -97
- package/dist/chunk-WVWGLZDT.cjs.map +1 -0
- package/dist/index.cjs +7702 -687
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +2660 -1619
- package/dist/index.d.ts +2660 -1619
- package/dist/index.mjs +7514 -499
- package/dist/index.mjs.map +1 -1
- package/dist/{model-ZFTLKEMC.mjs → model-BRLR6F3P.mjs} +28 -2
- package/dist/model-KJHN3WYY.cjs +214 -0
- package/dist/{model-2G37RFQQ.cjs.map → model-KJHN3WYY.cjs.map} +1 -1
- package/docs/api/README.md +6 -0
- package/docs/api/browser-use/browser-agent.md +188 -0
- package/docs/api/browser-use/browser.md +1 -1
- package/docs/api/browser-use/fingerprint.md +154 -0
- package/docs/api/codespace/code.md +3 -0
- package/docs/api/common-features/advanced/agent.md +7 -63
- package/docs/api/common-features/advanced/browser-use-agent.md +118 -0
- package/docs/api/common-features/advanced/computer-use-agent.md +85 -0
- package/docs/api/common-features/basics/agentbay.md +99 -2
- package/docs/api/common-features/basics/command.md +35 -18
- package/docs/api/common-features/basics/context-manager.md +21 -2
- package/docs/api/common-features/basics/filesystem.md +36 -0
- package/docs/api/common-features/basics/session-params.md +382 -0
- package/docs/api/common-features/basics/session.md +130 -2
- package/docs/api/computer-use/computer.md +25 -25
- package/docs/api/mobile-use/mobile-simulate.md +135 -0
- package/docs/examples/browser-use/browser/basic-usage.ts +31 -24
- package/docs/examples/browser-use/browser/browser-type-example.ts +3 -4
- package/docs/examples/browser-use/browser/captcha_tongcheng.ts +60 -28
- package/docs/examples/browser-use/browser/run-2048.ts +47 -37
- package/docs/examples/browser-use/browser/run-sudoku.ts +55 -36
- package/docs/examples/browser-use/browser/screenshot-example.ts +6 -6
- package/docs/examples/codespace/enhanced_code/index.ts +86 -0
- package/docs/examples/common-features/advanced/agent-module-example.ts +1 -1
- package/docs/examples/common-features/advanced/archive-upload-mode-example/README.md +1 -1
- package/docs/examples/common-features/advanced/archive-upload-mode-example/archive-upload-mode-example.ts +5 -6
- package/docs/examples/common-features/basics/archive-upload-mode-example/README.md +1 -1
- package/docs/examples/common-features/basics/archive-upload-mode-example/main.ts +1 -1
- package/docs/examples/common-features/basics/filesystem-example/filesystem-example.ts +13 -0
- package/docs/examples/common-features/basics/filesystem-example/filesystem-filetransfer-example.ts +6 -7
- package/docs/examples/common-features/basics/filesystem-example/watch-directory-example.ts +1 -1
- package/docs/examples/common-features/basics/session-pause-resume/README.md +53 -0
- package/docs/examples/common-features/basics/session-pause-resume/session-pause-resume.ts +237 -0
- package/docs/examples/mobile-use/mobile-get-adb-url/index.ts +1 -1
- package/docs/examples/mobile-use/mobile-simulate-basic-usage.ts +202 -0
- package/docs/examples/mobile-use/mobile-simulate-with-ctx.ts +170 -0
- package/package.json +5 -5
- package/dist/chunk-E7QC5S76.mjs.map +0 -1
- package/dist/chunk-ZUB35HKV.cjs.map +0 -1
- package/dist/model-2G37RFQQ.cjs +0 -188
- package/docs/examples/mobile-use/mobile-get-adb-url/package-lock.json +0 -279
- package/docs/examples/mobile-use/mobile-get-adb-url/package.json +0 -18
- /package/dist/{model-ZFTLKEMC.mjs.map → model-BRLR6F3P.mjs.map} +0 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
# Class: CreateSessionParams
|
|
2
|
+
|
|
3
|
+
CreateSessionParams provides a way to configure the parameters for creating a new session
|
|
4
|
+
in the AgentBay cloud environment.
|
|
5
|
+
|
|
6
|
+
## Implements
|
|
7
|
+
|
|
8
|
+
- ``CreateSessionParamsConfig``
|
|
9
|
+
|
|
10
|
+
## Table of contents
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Properties
|
|
14
|
+
|
|
15
|
+
- [browserContext](#browsercontext)
|
|
16
|
+
- [enableBrowserReplay](#enablebrowserreplay)
|
|
17
|
+
- [extraConfigs](#extraconfigs)
|
|
18
|
+
- [framework](#framework)
|
|
19
|
+
- [imageId](#imageid)
|
|
20
|
+
- [policyId](#policyid)
|
|
21
|
+
|
|
22
|
+
### Methods
|
|
23
|
+
|
|
24
|
+
- [addContextSync](#addcontextsync)
|
|
25
|
+
- [addContextSyncConfig](#addcontextsyncconfig)
|
|
26
|
+
- [fromJSON](#fromjson)
|
|
27
|
+
- [toJSON](#tojson)
|
|
28
|
+
- [withBrowserContext](#withbrowsercontext)
|
|
29
|
+
- [withContextSync](#withcontextsync)
|
|
30
|
+
- [withEnableBrowserReplay](#withenablebrowserreplay)
|
|
31
|
+
- [withEnableRecord](#withenablerecord)
|
|
32
|
+
- [withExtraConfigs](#withextraconfigs)
|
|
33
|
+
- [withFramework](#withframework)
|
|
34
|
+
- [withImageId](#withimageid)
|
|
35
|
+
- [withIsVpc](#withisvpc)
|
|
36
|
+
- [withLabels](#withlabels)
|
|
37
|
+
- [withPolicyId](#withpolicyid)
|
|
38
|
+
|
|
39
|
+
## Properties
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
contextSync: [`ContextSync`](context-sync.md)[]
|
|
43
|
+
isVpc: `boolean`
|
|
44
|
+
labels: `Record`<`string`, `string`>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### browserContext
|
|
49
|
+
|
|
50
|
+
• `Optional` **browserContext**: ``BrowserContext``
|
|
51
|
+
|
|
52
|
+
Optional configuration for browser data synchronization.
|
|
53
|
+
|
|
54
|
+
#### Implementation of
|
|
55
|
+
|
|
56
|
+
`CreateSessionParamsConfig`.`browserContext`
|
|
57
|
+
|
|
58
|
+
___
|
|
59
|
+
|
|
60
|
+
#### Implementation of
|
|
61
|
+
|
|
62
|
+
`CreateSessionParamsConfig`.`contextSync`
|
|
63
|
+
|
|
64
|
+
___
|
|
65
|
+
|
|
66
|
+
### enableBrowserReplay
|
|
67
|
+
|
|
68
|
+
• `Optional` **enableBrowserReplay**: `boolean`
|
|
69
|
+
|
|
70
|
+
Whether to enable browser recording for the session. Defaults to undefined (use default behavior, enabled by default).
|
|
71
|
+
|
|
72
|
+
#### Implementation of
|
|
73
|
+
|
|
74
|
+
`CreateSessionParamsConfig`.`enableBrowserReplay`
|
|
75
|
+
|
|
76
|
+
___
|
|
77
|
+
|
|
78
|
+
### extraConfigs
|
|
79
|
+
|
|
80
|
+
• `Optional` **extraConfigs**: ``ExtraConfigs``
|
|
81
|
+
|
|
82
|
+
Extra configuration settings for different session types (e.g., mobile)
|
|
83
|
+
|
|
84
|
+
#### Implementation of
|
|
85
|
+
|
|
86
|
+
`CreateSessionParamsConfig`.`extraConfigs`
|
|
87
|
+
|
|
88
|
+
___
|
|
89
|
+
|
|
90
|
+
### framework
|
|
91
|
+
|
|
92
|
+
• `Optional` **framework**: `string`
|
|
93
|
+
|
|
94
|
+
Framework name for SDK statistics tracking
|
|
95
|
+
|
|
96
|
+
#### Implementation of
|
|
97
|
+
|
|
98
|
+
`CreateSessionParamsConfig`.`framework`
|
|
99
|
+
|
|
100
|
+
___
|
|
101
|
+
|
|
102
|
+
### imageId
|
|
103
|
+
|
|
104
|
+
• `Optional` **imageId**: `string`
|
|
105
|
+
|
|
106
|
+
Image ID to use for the session.
|
|
107
|
+
|
|
108
|
+
#### Implementation of
|
|
109
|
+
|
|
110
|
+
`CreateSessionParamsConfig`.`imageId`
|
|
111
|
+
|
|
112
|
+
___
|
|
113
|
+
|
|
114
|
+
#### Implementation of
|
|
115
|
+
|
|
116
|
+
`CreateSessionParamsConfig`.`isVpc`
|
|
117
|
+
|
|
118
|
+
___
|
|
119
|
+
|
|
120
|
+
#### Implementation of
|
|
121
|
+
|
|
122
|
+
`CreateSessionParamsConfig`.`labels`
|
|
123
|
+
|
|
124
|
+
___
|
|
125
|
+
|
|
126
|
+
### policyId
|
|
127
|
+
|
|
128
|
+
• `Optional` **policyId**: `string`
|
|
129
|
+
|
|
130
|
+
Policy id to apply when creating the session.
|
|
131
|
+
|
|
132
|
+
#### Implementation of
|
|
133
|
+
|
|
134
|
+
`CreateSessionParamsConfig`.`policyId`
|
|
135
|
+
|
|
136
|
+
## Methods
|
|
137
|
+
|
|
138
|
+
### addContextSync
|
|
139
|
+
|
|
140
|
+
▸ **addContextSync**(`contextId`, `path`, `policy?`): [`CreateSessionParams`](session-params.md)
|
|
141
|
+
|
|
142
|
+
AddContextSync adds a context sync configuration to the session parameters.
|
|
143
|
+
|
|
144
|
+
#### Parameters
|
|
145
|
+
|
|
146
|
+
| Name | Type |
|
|
147
|
+
| :------ | :------ |
|
|
148
|
+
| `contextId` | `string` |
|
|
149
|
+
| `path` | `string` |
|
|
150
|
+
| `policy?` | ``SyncPolicy`` |
|
|
151
|
+
|
|
152
|
+
#### Returns
|
|
153
|
+
|
|
154
|
+
[`CreateSessionParams`](session-params.md)
|
|
155
|
+
|
|
156
|
+
___
|
|
157
|
+
|
|
158
|
+
### addContextSyncConfig
|
|
159
|
+
|
|
160
|
+
▸ **addContextSyncConfig**(`contextSync`): [`CreateSessionParams`](session-params.md)
|
|
161
|
+
|
|
162
|
+
AddContextSyncConfig adds a pre-configured context sync to the session parameters.
|
|
163
|
+
|
|
164
|
+
#### Parameters
|
|
165
|
+
|
|
166
|
+
| Name | Type |
|
|
167
|
+
| :------ | :------ |
|
|
168
|
+
| `contextSync` | [`ContextSync`](context-sync.md) |
|
|
169
|
+
|
|
170
|
+
#### Returns
|
|
171
|
+
|
|
172
|
+
[`CreateSessionParams`](session-params.md)
|
|
173
|
+
|
|
174
|
+
___
|
|
175
|
+
|
|
176
|
+
### fromJSON
|
|
177
|
+
|
|
178
|
+
▸ **fromJSON**(`config`): [`CreateSessionParams`](session-params.md)
|
|
179
|
+
|
|
180
|
+
Create from plain object
|
|
181
|
+
|
|
182
|
+
#### Parameters
|
|
183
|
+
|
|
184
|
+
| Name | Type |
|
|
185
|
+
| :------ | :------ |
|
|
186
|
+
| `config` | ``CreateSessionParamsConfig`` |
|
|
187
|
+
|
|
188
|
+
#### Returns
|
|
189
|
+
|
|
190
|
+
[`CreateSessionParams`](session-params.md)
|
|
191
|
+
|
|
192
|
+
___
|
|
193
|
+
|
|
194
|
+
### toJSON
|
|
195
|
+
|
|
196
|
+
▸ **toJSON**(): ``CreateSessionParamsConfig``
|
|
197
|
+
|
|
198
|
+
Convert to plain object for JSON serialization
|
|
199
|
+
|
|
200
|
+
#### Returns
|
|
201
|
+
|
|
202
|
+
``CreateSessionParamsConfig``
|
|
203
|
+
|
|
204
|
+
___
|
|
205
|
+
|
|
206
|
+
### withBrowserContext
|
|
207
|
+
|
|
208
|
+
▸ **withBrowserContext**(`browserContext`): [`CreateSessionParams`](session-params.md)
|
|
209
|
+
|
|
210
|
+
WithBrowserContext sets the browser context for the session parameters and returns the updated parameters.
|
|
211
|
+
|
|
212
|
+
#### Parameters
|
|
213
|
+
|
|
214
|
+
| Name | Type |
|
|
215
|
+
| :------ | :------ |
|
|
216
|
+
| `browserContext` | ``BrowserContext`` |
|
|
217
|
+
|
|
218
|
+
#### Returns
|
|
219
|
+
|
|
220
|
+
[`CreateSessionParams`](session-params.md)
|
|
221
|
+
|
|
222
|
+
___
|
|
223
|
+
|
|
224
|
+
### withContextSync
|
|
225
|
+
|
|
226
|
+
▸ **withContextSync**(`contextSyncs`): [`CreateSessionParams`](session-params.md)
|
|
227
|
+
|
|
228
|
+
WithContextSync sets the context sync configurations for the session parameters.
|
|
229
|
+
|
|
230
|
+
#### Parameters
|
|
231
|
+
|
|
232
|
+
| Name | Type |
|
|
233
|
+
| :------ | :------ |
|
|
234
|
+
| `contextSyncs` | [`ContextSync`](context-sync.md)[] |
|
|
235
|
+
|
|
236
|
+
#### Returns
|
|
237
|
+
|
|
238
|
+
[`CreateSessionParams`](session-params.md)
|
|
239
|
+
|
|
240
|
+
___
|
|
241
|
+
|
|
242
|
+
### withEnableBrowserReplay
|
|
243
|
+
|
|
244
|
+
▸ **withEnableBrowserReplay**(`enableBrowserReplay`): [`CreateSessionParams`](session-params.md)
|
|
245
|
+
|
|
246
|
+
WithenableBrowserReplay sets the browser recording flag for the session parameters and returns the updated parameters.
|
|
247
|
+
|
|
248
|
+
#### Parameters
|
|
249
|
+
|
|
250
|
+
| Name | Type |
|
|
251
|
+
| :------ | :------ |
|
|
252
|
+
| `enableBrowserReplay` | `boolean` |
|
|
253
|
+
|
|
254
|
+
#### Returns
|
|
255
|
+
|
|
256
|
+
[`CreateSessionParams`](session-params.md)
|
|
257
|
+
|
|
258
|
+
___
|
|
259
|
+
|
|
260
|
+
### withEnableRecord
|
|
261
|
+
|
|
262
|
+
▸ **withEnableRecord**(`enableRecord`): [`CreateSessionParams`](session-params.md)
|
|
263
|
+
|
|
264
|
+
Alias for withEnableBrowserReplay for backward compatibility.
|
|
265
|
+
|
|
266
|
+
#### Parameters
|
|
267
|
+
|
|
268
|
+
| Name | Type |
|
|
269
|
+
| :------ | :------ |
|
|
270
|
+
| `enableRecord` | `boolean` |
|
|
271
|
+
|
|
272
|
+
#### Returns
|
|
273
|
+
|
|
274
|
+
[`CreateSessionParams`](session-params.md)
|
|
275
|
+
|
|
276
|
+
___
|
|
277
|
+
|
|
278
|
+
### withExtraConfigs
|
|
279
|
+
|
|
280
|
+
▸ **withExtraConfigs**(`extraConfigs`): [`CreateSessionParams`](session-params.md)
|
|
281
|
+
|
|
282
|
+
WithExtraConfigs sets the extra configurations for the session parameters and returns the updated parameters.
|
|
283
|
+
|
|
284
|
+
#### Parameters
|
|
285
|
+
|
|
286
|
+
| Name | Type |
|
|
287
|
+
| :------ | :------ |
|
|
288
|
+
| `extraConfigs` | ``ExtraConfigs`` |
|
|
289
|
+
|
|
290
|
+
#### Returns
|
|
291
|
+
|
|
292
|
+
[`CreateSessionParams`](session-params.md)
|
|
293
|
+
|
|
294
|
+
___
|
|
295
|
+
|
|
296
|
+
### withFramework
|
|
297
|
+
|
|
298
|
+
▸ **withFramework**(`framework`): [`CreateSessionParams`](session-params.md)
|
|
299
|
+
|
|
300
|
+
WithFramework sets the framework name for the session parameters and returns the updated parameters.
|
|
301
|
+
|
|
302
|
+
#### Parameters
|
|
303
|
+
|
|
304
|
+
| Name | Type |
|
|
305
|
+
| :------ | :------ |
|
|
306
|
+
| `framework` | `string` |
|
|
307
|
+
|
|
308
|
+
#### Returns
|
|
309
|
+
|
|
310
|
+
[`CreateSessionParams`](session-params.md)
|
|
311
|
+
|
|
312
|
+
___
|
|
313
|
+
|
|
314
|
+
### withImageId
|
|
315
|
+
|
|
316
|
+
▸ **withImageId**(`imageId`): [`CreateSessionParams`](session-params.md)
|
|
317
|
+
|
|
318
|
+
WithImageId sets the image ID for the session parameters and returns the updated parameters.
|
|
319
|
+
|
|
320
|
+
#### Parameters
|
|
321
|
+
|
|
322
|
+
| Name | Type |
|
|
323
|
+
| :------ | :------ |
|
|
324
|
+
| `imageId` | `string` |
|
|
325
|
+
|
|
326
|
+
#### Returns
|
|
327
|
+
|
|
328
|
+
[`CreateSessionParams`](session-params.md)
|
|
329
|
+
|
|
330
|
+
___
|
|
331
|
+
|
|
332
|
+
### withIsVpc
|
|
333
|
+
|
|
334
|
+
▸ **withIsVpc**(`isVpc`): [`CreateSessionParams`](session-params.md)
|
|
335
|
+
|
|
336
|
+
WithIsVpc sets the VPC flag for the session parameters and returns the updated parameters.
|
|
337
|
+
|
|
338
|
+
#### Parameters
|
|
339
|
+
|
|
340
|
+
| Name | Type |
|
|
341
|
+
| :------ | :------ |
|
|
342
|
+
| `isVpc` | `boolean` |
|
|
343
|
+
|
|
344
|
+
#### Returns
|
|
345
|
+
|
|
346
|
+
[`CreateSessionParams`](session-params.md)
|
|
347
|
+
|
|
348
|
+
___
|
|
349
|
+
|
|
350
|
+
### withLabels
|
|
351
|
+
|
|
352
|
+
▸ **withLabels**(`labels`): [`CreateSessionParams`](session-params.md)
|
|
353
|
+
|
|
354
|
+
WithLabels sets the labels for the session parameters and returns the updated parameters.
|
|
355
|
+
|
|
356
|
+
#### Parameters
|
|
357
|
+
|
|
358
|
+
| Name | Type |
|
|
359
|
+
| :------ | :------ |
|
|
360
|
+
| `labels` | `Record`\<`string`, `string`\> |
|
|
361
|
+
|
|
362
|
+
#### Returns
|
|
363
|
+
|
|
364
|
+
[`CreateSessionParams`](session-params.md)
|
|
365
|
+
|
|
366
|
+
___
|
|
367
|
+
|
|
368
|
+
### withPolicyId
|
|
369
|
+
|
|
370
|
+
▸ **withPolicyId**(`policyId`): [`CreateSessionParams`](session-params.md)
|
|
371
|
+
|
|
372
|
+
WithPolicyId sets the policy id for the session parameters and returns the updated parameters.
|
|
373
|
+
|
|
374
|
+
#### Parameters
|
|
375
|
+
|
|
376
|
+
| Name | Type |
|
|
377
|
+
| :------ | :------ |
|
|
378
|
+
| `policyId` | `string` |
|
|
379
|
+
|
|
380
|
+
#### Returns
|
|
381
|
+
|
|
382
|
+
[`CreateSessionParams`](session-params.md)
|
|
@@ -21,6 +21,8 @@ Represents a session in the AgentBay cloud environment.
|
|
|
21
21
|
- [getLinkAsync](#getlinkasync)
|
|
22
22
|
- [info](#info)
|
|
23
23
|
- [listMcpTools](#listmcptools)
|
|
24
|
+
- [pauseAsync](#pauseasync)
|
|
25
|
+
- [resumeAsync](#resumeasync)
|
|
24
26
|
- [setLabels](#setlabels)
|
|
25
27
|
|
|
26
28
|
## Properties
|
|
@@ -34,14 +36,12 @@ computer: [`Computer`](../../computer-use/computer.md)
|
|
|
34
36
|
context: [`ContextManager`](context-manager.md)
|
|
35
37
|
enableBrowserReplay: `boolean` = `false`
|
|
36
38
|
fileSystem: [`FileSystem`](filesystem.md)
|
|
37
|
-
fileTransferContextId: ``null`` | `string` = `null`
|
|
38
39
|
httpPort: `string` = `""`
|
|
39
40
|
isVpc: `boolean` = `false`
|
|
40
41
|
mcpTools: `McpTool`[] = `[]`
|
|
41
42
|
mobile: [`Mobile`](../../mobile-use/mobile.md)
|
|
42
43
|
networkInterfaceIp: `string` = `""`
|
|
43
44
|
oss: [`Oss`](../advanced/oss.md)
|
|
44
|
-
recordContextId: ``null`` | `string` = `null`
|
|
45
45
|
resourceUrl: `string` = `""`
|
|
46
46
|
sessionId: `string`
|
|
47
47
|
token: `string` = `""`
|
|
@@ -368,6 +368,134 @@ if (result.success) {
|
|
|
368
368
|
|
|
369
369
|
___
|
|
370
370
|
|
|
371
|
+
### pauseAsync
|
|
372
|
+
|
|
373
|
+
▸ **pauseAsync**(`timeout?`, `pollInterval?`): `Promise`\<`SessionPauseResult`\>
|
|
374
|
+
|
|
375
|
+
Asynchronously pause this session, putting it into a dormant state.
|
|
376
|
+
|
|
377
|
+
This method calls the PauseSessionAsync API to initiate the pause operation and then polls
|
|
378
|
+
the GetSession API to check the session status until it becomes PAUSED or until timeout is reached.
|
|
379
|
+
During the paused state, resource usage and costs are reduced while session state is preserved.
|
|
380
|
+
|
|
381
|
+
#### Parameters
|
|
382
|
+
|
|
383
|
+
| Name | Type | Default value | Description |
|
|
384
|
+
| :------ | :------ | :------ | :------ |
|
|
385
|
+
| `timeout` | `number` | `600` | Timeout in seconds to wait for the session to pause. Defaults to 600 seconds. |
|
|
386
|
+
| `pollInterval` | `number` | `2.0` | Interval in seconds between status polls. Defaults to 2.0 seconds. |
|
|
387
|
+
|
|
388
|
+
#### Returns
|
|
389
|
+
|
|
390
|
+
`Promise`\<`SessionPauseResult`\>
|
|
391
|
+
|
|
392
|
+
Promise resolving to SessionPauseResult containing:
|
|
393
|
+
- success: Whether the pause operation succeeded
|
|
394
|
+
- requestId: Unique identifier for this API request
|
|
395
|
+
- status: Final session status (should be "PAUSED" if successful)
|
|
396
|
+
- errorMessage: Error description if pause failed
|
|
397
|
+
|
|
398
|
+
**`Throws`**
|
|
399
|
+
|
|
400
|
+
Error if the API call fails or network issues occur.
|
|
401
|
+
|
|
402
|
+
**`Example`**
|
|
403
|
+
|
|
404
|
+
```typescript
|
|
405
|
+
const agentBay = new AgentBay({ apiKey: 'your_api_key' });
|
|
406
|
+
const result = await agentBay.create();
|
|
407
|
+
if (result.success) {
|
|
408
|
+
const pauseResult = await result.session.pauseAsync();
|
|
409
|
+
if (pauseResult.success) {
|
|
410
|
+
console.log('Session paused successfully');
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
**`Remarks`**
|
|
416
|
+
|
|
417
|
+
**Behavior:**
|
|
418
|
+
- Initiates pause operation through PauseSessionAsync API
|
|
419
|
+
- Polls session status until PAUSED state or timeout
|
|
420
|
+
- Session state transitions: RUNNING -> PAUSING -> PAUSED
|
|
421
|
+
- All session state is preserved during pause
|
|
422
|
+
|
|
423
|
+
**Important Notes:**
|
|
424
|
+
- Paused sessions cannot perform operations (deletion, task execution, etc.)
|
|
425
|
+
- Use [resumeAsync](#resumeasync) to restore the session to RUNNING state
|
|
426
|
+
- During pause, both resource usage and costs are lower
|
|
427
|
+
- If timeout is exceeded, returns with success=false
|
|
428
|
+
|
|
429
|
+
**`See`**
|
|
430
|
+
|
|
431
|
+
[resumeAsync](#resumeasync)
|
|
432
|
+
|
|
433
|
+
___
|
|
434
|
+
|
|
435
|
+
### resumeAsync
|
|
436
|
+
|
|
437
|
+
▸ **resumeAsync**(`timeout?`, `pollInterval?`): `Promise`\<`SessionResumeResult`\>
|
|
438
|
+
|
|
439
|
+
Asynchronously resume this session from a paused state.
|
|
440
|
+
|
|
441
|
+
This method calls the ResumeSessionAsync API to initiate the resume operation and then polls
|
|
442
|
+
the GetSession API to check the session status until it becomes RUNNING or until timeout is reached.
|
|
443
|
+
After resuming, the session restores full functionality and can perform all operations normally.
|
|
444
|
+
|
|
445
|
+
#### Parameters
|
|
446
|
+
|
|
447
|
+
| Name | Type | Default value | Description |
|
|
448
|
+
| :------ | :------ | :------ | :------ |
|
|
449
|
+
| `timeout` | `number` | `600` | Timeout in seconds to wait for the session to resume. Defaults to 600 seconds. |
|
|
450
|
+
| `pollInterval` | `number` | `2.0` | Interval in seconds between status polls. Defaults to 2.0 seconds. |
|
|
451
|
+
|
|
452
|
+
#### Returns
|
|
453
|
+
|
|
454
|
+
`Promise`\<`SessionResumeResult`\>
|
|
455
|
+
|
|
456
|
+
Promise resolving to SessionResumeResult containing:
|
|
457
|
+
- success: Whether the resume operation succeeded
|
|
458
|
+
- requestId: Unique identifier for this API request
|
|
459
|
+
- status: Final session status (should be "RUNNING" if successful)
|
|
460
|
+
- errorMessage: Error description if resume failed
|
|
461
|
+
|
|
462
|
+
**`Throws`**
|
|
463
|
+
|
|
464
|
+
Error if the API call fails or network issues occur.
|
|
465
|
+
|
|
466
|
+
**`Example`**
|
|
467
|
+
|
|
468
|
+
```typescript
|
|
469
|
+
const agentBay = new AgentBay({ apiKey: 'your_api_key' });
|
|
470
|
+
const result = await agentBay.get('paused_session_id');
|
|
471
|
+
if (result.success) {
|
|
472
|
+
const resumeResult = await result.session.resumeAsync();
|
|
473
|
+
if (resumeResult.success) {
|
|
474
|
+
console.log('Session resumed successfully');
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
**`Remarks`**
|
|
480
|
+
|
|
481
|
+
**Behavior:**
|
|
482
|
+
- Initiates resume operation through ResumeSessionAsync API
|
|
483
|
+
- Polls session status until RUNNING state or timeout
|
|
484
|
+
- Session state transitions: PAUSED -> RESUMING -> RUNNING
|
|
485
|
+
- All previous session state is restored during resume
|
|
486
|
+
|
|
487
|
+
**Important Notes:**
|
|
488
|
+
- Only sessions in PAUSED state can be resumed
|
|
489
|
+
- After resume, the session can perform all operations normally
|
|
490
|
+
- Use [pauseAsync](#pauseasync) to put a session into PAUSED state
|
|
491
|
+
- If timeout is exceeded, returns with success=false
|
|
492
|
+
|
|
493
|
+
**`See`**
|
|
494
|
+
|
|
495
|
+
[pauseAsync](#pauseasync)
|
|
496
|
+
|
|
497
|
+
___
|
|
498
|
+
|
|
371
499
|
### setLabels
|
|
372
500
|
|
|
373
501
|
▸ **setLabels**(`labels`): `Promise`\<`OperationResult`\>
|