wuying-agentbay-sdk 0.11.0 → 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.
- package/dist/{chunk-E7QC5S76.mjs → chunk-BVWUCG4J.mjs} +264 -5
- package/dist/chunk-BVWUCG4J.mjs.map +1 -0
- package/dist/{chunk-ZUB35HKV.cjs → chunk-SL5GCAQE.cjs} +265 -6
- package/dist/chunk-SL5GCAQE.cjs.map +1 -0
- package/dist/index.cjs +1295 -317
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1694 -1125
- package/dist/index.d.ts +1694 -1125
- package/dist/index.mjs +1228 -250
- package/dist/index.mjs.map +1 -1
- package/dist/model-CNCGFWJH.cjs +200 -0
- package/dist/{model-2G37RFQQ.cjs.map → model-CNCGFWJH.cjs.map} +1 -1
- package/dist/{model-ZFTLKEMC.mjs → model-LGWQJWKQ.mjs} +14 -2
- package/docs/api/common-features/basics/agentbay.md +96 -0
- package/docs/api/common-features/basics/context-manager.md +21 -2
- package/docs/api/common-features/basics/session.md +130 -0
- package/docs/examples/browser-use/extension-example/extension-example.ts +2 -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-simulate-basic-usage.ts +202 -0
- package/docs/examples/mobile-use/mobile-simulate-with-ctx.ts +170 -0
- package/package.json +2 -2
- package/dist/chunk-E7QC5S76.mjs.map +0 -1
- package/dist/chunk-ZUB35HKV.cjs.map +0 -1
- package/dist/model-2G37RFQQ.cjs +0 -188
- /package/dist/{model-ZFTLKEMC.mjs.map → model-LGWQJWKQ.mjs.map} +0 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
var _chunkSL5GCAQEcjs = require('./chunk-SL5GCAQE.cjs');
|
|
100
|
+
require('./chunk-4IPTHWLM.cjs');
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
exports.ApplyMqttTokenRequest = _chunkSL5GCAQEcjs.ApplyMqttTokenRequest; exports.ApplyMqttTokenResponse = _chunkSL5GCAQEcjs.ApplyMqttTokenResponse; exports.ApplyMqttTokenResponseBody = _chunkSL5GCAQEcjs.ApplyMqttTokenResponseBody; exports.ApplyMqttTokenResponseBodyData = _chunkSL5GCAQEcjs.ApplyMqttTokenResponseBodyData; exports.CallMcpToolRequest = _chunkSL5GCAQEcjs.CallMcpToolRequest; exports.CallMcpToolResponse = _chunkSL5GCAQEcjs.CallMcpToolResponse; exports.CallMcpToolResponseBody = _chunkSL5GCAQEcjs.CallMcpToolResponseBody; exports.ClearContextRequest = _chunkSL5GCAQEcjs.ClearContextRequest; exports.ClearContextResponse = _chunkSL5GCAQEcjs.ClearContextResponse; exports.ClearContextResponseBody = _chunkSL5GCAQEcjs.ClearContextResponseBody; exports.CreateMcpSessionRequest = _chunkSL5GCAQEcjs.CreateMcpSessionRequest; exports.CreateMcpSessionRequestPersistenceDataList = _chunkSL5GCAQEcjs.CreateMcpSessionRequestPersistenceDataList; exports.CreateMcpSessionResponse = _chunkSL5GCAQEcjs.CreateMcpSessionResponse; exports.CreateMcpSessionResponseBody = _chunkSL5GCAQEcjs.CreateMcpSessionResponseBody; exports.CreateMcpSessionResponseBodyData = _chunkSL5GCAQEcjs.CreateMcpSessionResponseBodyData; exports.CreateMcpSessionShrinkRequest = _chunkSL5GCAQEcjs.CreateMcpSessionShrinkRequest; exports.DeleteContextFileRequest = _chunkSL5GCAQEcjs.DeleteContextFileRequest; exports.DeleteContextFileResponse = _chunkSL5GCAQEcjs.DeleteContextFileResponse; exports.DeleteContextFileResponseBody = _chunkSL5GCAQEcjs.DeleteContextFileResponseBody; exports.DeleteContextRequest = _chunkSL5GCAQEcjs.DeleteContextRequest; exports.DeleteContextResponse = _chunkSL5GCAQEcjs.DeleteContextResponse; exports.DeleteContextResponseBody = _chunkSL5GCAQEcjs.DeleteContextResponseBody; exports.DescribeContextFilesRequest = _chunkSL5GCAQEcjs.DescribeContextFilesRequest; exports.DescribeContextFilesResponse = _chunkSL5GCAQEcjs.DescribeContextFilesResponse; exports.DescribeContextFilesResponseBody = _chunkSL5GCAQEcjs.DescribeContextFilesResponseBody; exports.GetAdbLinkRequest = _chunkSL5GCAQEcjs.GetAdbLinkRequest; exports.GetAdbLinkResponse = _chunkSL5GCAQEcjs.GetAdbLinkResponse; exports.GetAdbLinkResponseBody = _chunkSL5GCAQEcjs.GetAdbLinkResponseBody; exports.GetAdbLinkResponseBodyData = _chunkSL5GCAQEcjs.GetAdbLinkResponseBodyData; exports.GetCdpLinkRequest = _chunkSL5GCAQEcjs.GetCdpLinkRequest; exports.GetCdpLinkResponse = _chunkSL5GCAQEcjs.GetCdpLinkResponse; exports.GetCdpLinkResponseBody = _chunkSL5GCAQEcjs.GetCdpLinkResponseBody; exports.GetCdpLinkResponseBodyData = _chunkSL5GCAQEcjs.GetCdpLinkResponseBodyData; exports.GetContextFileDownloadUrlRequest = _chunkSL5GCAQEcjs.GetContextFileDownloadUrlRequest; exports.GetContextFileDownloadUrlResponse = _chunkSL5GCAQEcjs.GetContextFileDownloadUrlResponse; exports.GetContextFileDownloadUrlResponseBody = _chunkSL5GCAQEcjs.GetContextFileDownloadUrlResponseBody; exports.GetContextFileUploadUrlRequest = _chunkSL5GCAQEcjs.GetContextFileUploadUrlRequest; exports.GetContextFileUploadUrlResponse = _chunkSL5GCAQEcjs.GetContextFileUploadUrlResponse; exports.GetContextFileUploadUrlResponseBody = _chunkSL5GCAQEcjs.GetContextFileUploadUrlResponseBody; exports.GetContextInfoRequest = _chunkSL5GCAQEcjs.GetContextInfoRequest; exports.GetContextInfoResponse = _chunkSL5GCAQEcjs.GetContextInfoResponse; exports.GetContextInfoResponseBody = _chunkSL5GCAQEcjs.GetContextInfoResponseBody; exports.GetContextInfoResponseBodyData = _chunkSL5GCAQEcjs.GetContextInfoResponseBodyData; exports.GetContextRequest = _chunkSL5GCAQEcjs.GetContextRequest; exports.GetContextResponse = _chunkSL5GCAQEcjs.GetContextResponse; exports.GetContextResponseBody = _chunkSL5GCAQEcjs.GetContextResponseBody; exports.GetContextResponseBodyData = _chunkSL5GCAQEcjs.GetContextResponseBodyData; exports.GetLabelRequest = _chunkSL5GCAQEcjs.GetLabelRequest; exports.GetLabelResponse = _chunkSL5GCAQEcjs.GetLabelResponse; exports.GetLabelResponseBody = _chunkSL5GCAQEcjs.GetLabelResponseBody; exports.GetLabelResponseBodyData = _chunkSL5GCAQEcjs.GetLabelResponseBodyData; exports.GetLinkRequest = _chunkSL5GCAQEcjs.GetLinkRequest; exports.GetLinkResponse = _chunkSL5GCAQEcjs.GetLinkResponse; exports.GetLinkResponseBody = _chunkSL5GCAQEcjs.GetLinkResponseBody; exports.GetLinkResponseBodyData = _chunkSL5GCAQEcjs.GetLinkResponseBodyData; exports.GetMcpResourceRequest = _chunkSL5GCAQEcjs.GetMcpResourceRequest; exports.GetMcpResourceResponse = _chunkSL5GCAQEcjs.GetMcpResourceResponse; exports.GetMcpResourceResponseBody = _chunkSL5GCAQEcjs.GetMcpResourceResponseBody; exports.GetMcpResourceResponseBodyData = _chunkSL5GCAQEcjs.GetMcpResourceResponseBodyData; exports.GetMcpResourceResponseBodyDataDesktopInfo = _chunkSL5GCAQEcjs.GetMcpResourceResponseBodyDataDesktopInfo; exports.GetSessionRequest = _chunkSL5GCAQEcjs.GetSessionRequest; exports.GetSessionResponse = _chunkSL5GCAQEcjs.GetSessionResponse; exports.GetSessionResponseBody = _chunkSL5GCAQEcjs.GetSessionResponseBody; exports.GetSessionResponseBodyData = _chunkSL5GCAQEcjs.GetSessionResponseBodyData; exports.InitBrowserRequest = _chunkSL5GCAQEcjs.InitBrowserRequest; exports.InitBrowserResponse = _chunkSL5GCAQEcjs.InitBrowserResponse; exports.InitBrowserResponseBody = _chunkSL5GCAQEcjs.InitBrowserResponseBody; exports.InitBrowserResponseBodyData = _chunkSL5GCAQEcjs.InitBrowserResponseBodyData; exports.ListContextsRequest = _chunkSL5GCAQEcjs.ListContextsRequest; exports.ListContextsResponse = _chunkSL5GCAQEcjs.ListContextsResponse; exports.ListContextsResponseBody = _chunkSL5GCAQEcjs.ListContextsResponseBody; exports.ListContextsResponseBodyData = _chunkSL5GCAQEcjs.ListContextsResponseBodyData; exports.ListMcpToolsRequest = _chunkSL5GCAQEcjs.ListMcpToolsRequest; exports.ListMcpToolsResponse = _chunkSL5GCAQEcjs.ListMcpToolsResponse; exports.ListMcpToolsResponseBody = _chunkSL5GCAQEcjs.ListMcpToolsResponseBody; exports.ListSessionRequest = _chunkSL5GCAQEcjs.ListSessionRequest; exports.ListSessionResponse = _chunkSL5GCAQEcjs.ListSessionResponse; exports.ListSessionResponseBody = _chunkSL5GCAQEcjs.ListSessionResponseBody; exports.ListSessionResponseBodyData = _chunkSL5GCAQEcjs.ListSessionResponseBodyData; exports.ModifyContextRequest = _chunkSL5GCAQEcjs.ModifyContextRequest; exports.ModifyContextResponse = _chunkSL5GCAQEcjs.ModifyContextResponse; exports.ModifyContextResponseBody = _chunkSL5GCAQEcjs.ModifyContextResponseBody; exports.PauseSessionAsyncRequest = _chunkSL5GCAQEcjs.PauseSessionAsyncRequest; exports.PauseSessionAsyncResponse = _chunkSL5GCAQEcjs.PauseSessionAsyncResponse; exports.PauseSessionAsyncResponseBody = _chunkSL5GCAQEcjs.PauseSessionAsyncResponseBody; exports.ReleaseMcpSessionRequest = _chunkSL5GCAQEcjs.ReleaseMcpSessionRequest; exports.ReleaseMcpSessionResponse = _chunkSL5GCAQEcjs.ReleaseMcpSessionResponse; exports.ReleaseMcpSessionResponseBody = _chunkSL5GCAQEcjs.ReleaseMcpSessionResponseBody; exports.ResumeSessionAsyncRequest = _chunkSL5GCAQEcjs.ResumeSessionAsyncRequest; exports.ResumeSessionAsyncResponse = _chunkSL5GCAQEcjs.ResumeSessionAsyncResponse; exports.ResumeSessionAsyncResponseBody = _chunkSL5GCAQEcjs.ResumeSessionAsyncResponseBody; exports.SetLabelRequest = _chunkSL5GCAQEcjs.SetLabelRequest; exports.SetLabelResponse = _chunkSL5GCAQEcjs.SetLabelResponse; exports.SetLabelResponseBody = _chunkSL5GCAQEcjs.SetLabelResponseBody; exports.SyncContextRequest = _chunkSL5GCAQEcjs.SyncContextRequest; exports.SyncContextResponse = _chunkSL5GCAQEcjs.SyncContextResponse; exports.SyncContextResponseBody = _chunkSL5GCAQEcjs.SyncContextResponseBody;
|
|
200
|
+
//# sourceMappingURL=model-CNCGFWJH.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/wuying-agentbay-sdk/wuying-agentbay-sdk/typescript/dist/model-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/wuying-agentbay-sdk/wuying-agentbay-sdk/typescript/dist/model-CNCGFWJH.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,85OAAC","file":"/home/runner/work/wuying-agentbay-sdk/wuying-agentbay-sdk/typescript/dist/model-CNCGFWJH.cjs"}
|
|
@@ -90,16 +90,22 @@ import {
|
|
|
90
90
|
ModifyContextRequest,
|
|
91
91
|
ModifyContextResponse,
|
|
92
92
|
ModifyContextResponseBody,
|
|
93
|
+
PauseSessionAsyncRequest,
|
|
94
|
+
PauseSessionAsyncResponse,
|
|
95
|
+
PauseSessionAsyncResponseBody,
|
|
93
96
|
ReleaseMcpSessionRequest,
|
|
94
97
|
ReleaseMcpSessionResponse,
|
|
95
98
|
ReleaseMcpSessionResponseBody,
|
|
99
|
+
ResumeSessionAsyncRequest,
|
|
100
|
+
ResumeSessionAsyncResponse,
|
|
101
|
+
ResumeSessionAsyncResponseBody,
|
|
96
102
|
SetLabelRequest,
|
|
97
103
|
SetLabelResponse,
|
|
98
104
|
SetLabelResponseBody,
|
|
99
105
|
SyncContextRequest,
|
|
100
106
|
SyncContextResponse,
|
|
101
107
|
SyncContextResponseBody
|
|
102
|
-
} from "./chunk-
|
|
108
|
+
} from "./chunk-BVWUCG4J.mjs";
|
|
103
109
|
import "./chunk-KNEDRAP6.mjs";
|
|
104
110
|
export {
|
|
105
111
|
ApplyMqttTokenRequest,
|
|
@@ -184,9 +190,15 @@ export {
|
|
|
184
190
|
ModifyContextRequest,
|
|
185
191
|
ModifyContextResponse,
|
|
186
192
|
ModifyContextResponseBody,
|
|
193
|
+
PauseSessionAsyncRequest,
|
|
194
|
+
PauseSessionAsyncResponse,
|
|
195
|
+
PauseSessionAsyncResponseBody,
|
|
187
196
|
ReleaseMcpSessionRequest,
|
|
188
197
|
ReleaseMcpSessionResponse,
|
|
189
198
|
ReleaseMcpSessionResponseBody,
|
|
199
|
+
ResumeSessionAsyncRequest,
|
|
200
|
+
ResumeSessionAsyncResponse,
|
|
201
|
+
ResumeSessionAsyncResponseBody,
|
|
190
202
|
SetLabelRequest,
|
|
191
203
|
SetLabelResponse,
|
|
192
204
|
SetLabelResponseBody,
|
|
@@ -194,4 +206,4 @@ export {
|
|
|
194
206
|
SyncContextResponse,
|
|
195
207
|
SyncContextResponseBody
|
|
196
208
|
};
|
|
197
|
-
//# sourceMappingURL=model-
|
|
209
|
+
//# sourceMappingURL=model-LGWQJWKQ.mjs.map
|
|
@@ -18,6 +18,8 @@ Main class for interacting with the AgentBay cloud runtime environment.
|
|
|
18
18
|
- [delete](#delete)
|
|
19
19
|
- [get](#get)
|
|
20
20
|
- [list](#list)
|
|
21
|
+
- [pauseAsync](#pauseasync)
|
|
22
|
+
- [resumeAsync](#resumeasync)
|
|
21
23
|
|
|
22
24
|
## Properties
|
|
23
25
|
|
|
@@ -174,6 +176,100 @@ if (result.success) {
|
|
|
174
176
|
}
|
|
175
177
|
```
|
|
176
178
|
|
|
179
|
+
___
|
|
180
|
+
|
|
181
|
+
### pauseAsync
|
|
182
|
+
|
|
183
|
+
▸ **pauseAsync**(`session`, `timeout?`, `pollInterval?`): `Promise`\<`SessionPauseResult`\>
|
|
184
|
+
|
|
185
|
+
Asynchronously pause a session, putting it into a dormant state.
|
|
186
|
+
|
|
187
|
+
This method directly calls the PauseSessionAsync API without waiting for the session
|
|
188
|
+
to reach the PAUSED state.
|
|
189
|
+
|
|
190
|
+
#### Parameters
|
|
191
|
+
|
|
192
|
+
| Name | Type | Default value | Description |
|
|
193
|
+
| :------ | :------ | :------ | :------ |
|
|
194
|
+
| `session` | [`Session`](session.md) | `undefined` | The session to pause. |
|
|
195
|
+
| `timeout` | `number` | `600` | Timeout in seconds to wait for the session to pause. Defaults to 600 seconds. |
|
|
196
|
+
| `pollInterval` | `number` | `2.0` | Interval in seconds between status polls. Defaults to 2.0 seconds. |
|
|
197
|
+
|
|
198
|
+
#### Returns
|
|
199
|
+
|
|
200
|
+
`Promise`\<`SessionPauseResult`\>
|
|
201
|
+
|
|
202
|
+
SessionPauseResult indicating success or failure and request ID
|
|
203
|
+
|
|
204
|
+
**`Example`**
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
const agentBay = new AgentBay({ apiKey: 'your_api_key' });
|
|
208
|
+
const session = (await agentBay.create()).session;
|
|
209
|
+
const pauseResult = await agentBay.pauseAsync(session);
|
|
210
|
+
await agentBay.resumeAsync(session);
|
|
211
|
+
await session.delete();
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**`Remarks`**
|
|
215
|
+
|
|
216
|
+
**Behavior:**
|
|
217
|
+
- This method does not wait for the session to reach the PAUSED state
|
|
218
|
+
- It only submits the pause request to the API
|
|
219
|
+
- The session state transitions from RUNNING -> PAUSING -> PAUSED
|
|
220
|
+
- Paused sessions consume fewer resources but maintain their state
|
|
221
|
+
|
|
222
|
+
**`See`**
|
|
223
|
+
|
|
224
|
+
[resumeAsync](#resumeasync), [Session.pauseAsync](session.md#pauseasync)
|
|
225
|
+
|
|
226
|
+
___
|
|
227
|
+
|
|
228
|
+
### resumeAsync
|
|
229
|
+
|
|
230
|
+
▸ **resumeAsync**(`session`, `timeout?`, `pollInterval?`): `Promise`\<`SessionResumeResult`\>
|
|
231
|
+
|
|
232
|
+
Asynchronously resume a session from a paused state.
|
|
233
|
+
|
|
234
|
+
This method directly calls the ResumeSessionAsync API without waiting for the session
|
|
235
|
+
to reach the RUNNING state.
|
|
236
|
+
|
|
237
|
+
#### Parameters
|
|
238
|
+
|
|
239
|
+
| Name | Type | Default value | Description |
|
|
240
|
+
| :------ | :------ | :------ | :------ |
|
|
241
|
+
| `session` | [`Session`](session.md) | `undefined` | The session to resume. |
|
|
242
|
+
| `timeout` | `number` | `600` | Timeout in seconds to wait for the session to resume. Defaults to 600 seconds. |
|
|
243
|
+
| `pollInterval` | `number` | `2.0` | Interval in seconds between status polls. Defaults to 2.0 seconds. |
|
|
244
|
+
|
|
245
|
+
#### Returns
|
|
246
|
+
|
|
247
|
+
`Promise`\<`SessionResumeResult`\>
|
|
248
|
+
|
|
249
|
+
SessionResumeResult indicating success or failure and request ID
|
|
250
|
+
|
|
251
|
+
**`Example`**
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
const agentBay = new AgentBay({ apiKey: 'your_api_key' });
|
|
255
|
+
const session = (await agentBay.create()).session;
|
|
256
|
+
await agentBay.pauseAsync(session);
|
|
257
|
+
const resumeResult = await agentBay.resumeAsync(session);
|
|
258
|
+
await session.delete();
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
**`Remarks`**
|
|
262
|
+
|
|
263
|
+
**Behavior:**
|
|
264
|
+
- This method does not wait for the session to reach the RUNNING state
|
|
265
|
+
- It only submits the resume request to the API
|
|
266
|
+
- The session state transitions from PAUSED -> RESUMING -> RUNNING
|
|
267
|
+
- Only sessions in PAUSED state can be resumed
|
|
268
|
+
|
|
269
|
+
**`See`**
|
|
270
|
+
|
|
271
|
+
[pauseAsync](#pauseasync), [Session.resumeAsync](session.md#resumeasync)
|
|
272
|
+
|
|
177
273
|
## Related Resources
|
|
178
274
|
|
|
179
275
|
- [Session API Reference](session.md)
|
|
@@ -93,8 +93,8 @@ Synchronizes a context with the session. Supports both async and callback modes.
|
|
|
93
93
|
|
|
94
94
|
| Name | Type | Default value | Description |
|
|
95
95
|
| :------ | :------ | :------ | :------ |
|
|
96
|
-
| `contextId?` | `string` | `undefined` | Optional context ID to synchronize |
|
|
97
|
-
| `path?` | `string` | `undefined` | Optional path where the context should be mounted |
|
|
96
|
+
| `contextId?` | `string` | `undefined` | Optional context ID to synchronize. If provided, `path` must also be provided. |
|
|
97
|
+
| `path?` | `string` | `undefined` | Optional path where the context should be mounted. If provided, `contextId` must also be provided. |
|
|
98
98
|
| `mode?` | `string` | `undefined` | Optional synchronization mode (e.g., "upload", "download") |
|
|
99
99
|
| `callback?` | ``SyncCallback`` | `undefined` | Optional callback function. If provided, runs in background and calls callback when complete |
|
|
100
100
|
| `maxRetries` | `number` | `150` | Maximum number of retries for polling completion status (default: 150) |
|
|
@@ -110,8 +110,27 @@ Promise resolving to ContextSyncResult with success status and request ID
|
|
|
110
110
|
|
|
111
111
|
Error if the API call fails
|
|
112
112
|
|
|
113
|
+
**`Throws`**
|
|
114
|
+
|
|
115
|
+
Error if `contextId` or `path` is provided without the other parameter.
|
|
116
|
+
Both must be provided together, or both must be omitted.
|
|
117
|
+
|
|
118
|
+
**`Example`**
|
|
119
|
+
|
|
120
|
+
Sync all contexts (no parameters):
|
|
121
|
+
```typescript
|
|
122
|
+
const agentBay = new AgentBay({ apiKey: 'your_api_key' });
|
|
123
|
+
const result = await agentBay.create();
|
|
124
|
+
if (result.success) {
|
|
125
|
+
const syncResult = await result.session.context.sync();
|
|
126
|
+
console.log(`Sync: ${syncResult.success}`);
|
|
127
|
+
await result.session.delete();
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
113
131
|
**`Example`**
|
|
114
132
|
|
|
133
|
+
Sync specific context with path:
|
|
115
134
|
```typescript
|
|
116
135
|
const agentBay = new AgentBay({ apiKey: 'your_api_key' });
|
|
117
136
|
const result = await agentBay.create();
|
|
@@ -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
|
|
@@ -368,6 +370,134 @@ if (result.success) {
|
|
|
368
370
|
|
|
369
371
|
___
|
|
370
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
|
+
|
|
371
501
|
### setLabels
|
|
372
502
|
|
|
373
503
|
▸ **setLabels**(`labels`): `Promise`\<`OperationResult`\>
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* - Error handling and cleanup
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
// @ts-nocheck
|
|
15
16
|
import { AgentBay, ExtensionsService, Extension, ExtensionOption, BrowserContext } from "wuying-agentbay-sdk";
|
|
16
17
|
import * as fs from "fs";
|
|
17
18
|
|
|
@@ -32,7 +33,7 @@ async function basicExtensionExample(): Promise<boolean> {
|
|
|
32
33
|
|
|
33
34
|
try {
|
|
34
35
|
// Example extension path (update with your actual extension)
|
|
35
|
-
const extensionPath = "/
|
|
36
|
+
const extensionPath = "/Users/shiwen/extension/welcome_extension.zip";
|
|
36
37
|
|
|
37
38
|
if (!fs.existsSync(extensionPath)) {
|
|
38
39
|
console.log(`❌ Extension file not found: ${extensionPath}`);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Session Pause and Resume Example
|
|
2
|
+
|
|
3
|
+
This example demonstrates how to pause and resume sessions using the Wuying AgentBay SDK. Pausing a session puts it into a dormant state, consuming fewer resources while maintaining its state. Resuming a session brings it back to an active state.
|
|
4
|
+
|
|
5
|
+
## Features Demonstrated
|
|
6
|
+
|
|
7
|
+
- Pausing and resuming sessions
|
|
8
|
+
- Handling non-existent session operations
|
|
9
|
+
- Using custom timeout and polling interval parameters
|
|
10
|
+
- Checking session status before and after operations
|
|
11
|
+
- Performing work in sessions before and after pause/resume cycles
|
|
12
|
+
|
|
13
|
+
## Running the Example
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cd session-pause-resume
|
|
17
|
+
npx ts-node session-pause-resume.ts
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Make sure you have set the `AGENTBAY_API_KEY` environment variable or replace the placeholder in the code with your actual API key.
|
|
21
|
+
|
|
22
|
+
## Prerequisites
|
|
23
|
+
|
|
24
|
+
- Node.js installed
|
|
25
|
+
- TypeScript installed
|
|
26
|
+
- ts-node installed (`npm install -g ts-node`)
|
|
27
|
+
- Required dependencies installed (`npm install`)
|
|
28
|
+
|
|
29
|
+
## Understanding Session States
|
|
30
|
+
|
|
31
|
+
When working with pause and resume operations, sessions can be in different states:
|
|
32
|
+
|
|
33
|
+
1. **RUNNING**: Session is active and ready to accept commands
|
|
34
|
+
2. **PAUSING**: Session is transitioning to paused state
|
|
35
|
+
3. **PAUSED**: Session is in dormant state, consuming fewer resources
|
|
36
|
+
4. **RESUMING**: Session is transitioning back to running state
|
|
37
|
+
|
|
38
|
+
The pause and resume operations are asynchronous, meaning they initiate the state transition and then poll for completion.
|
|
39
|
+
|
|
40
|
+
## Best Practices
|
|
41
|
+
|
|
42
|
+
1. **Always check operation results**: Verify that pause and resume operations succeeded
|
|
43
|
+
2. **Handle errors gracefully**: Non-existent sessions and other errors should be handled appropriately
|
|
44
|
+
3. **Use appropriate timeouts**: Custom timeout values can be used based on your specific requirements
|
|
45
|
+
4. **Verify session state**: Check session status before and after operations to ensure expected behavior
|
|
46
|
+
5. **Clean up resources**: Always delete sessions when done to avoid resource leaks
|
|
47
|
+
|
|
48
|
+
## Use Cases
|
|
49
|
+
|
|
50
|
+
- **Cost optimization**: Pause sessions during idle periods to reduce resource consumption
|
|
51
|
+
- **Long-running workflows**: Suspend sessions overnight or during maintenance windows
|
|
52
|
+
- **Development and testing**: Pause test environments when not actively working on them
|
|
53
|
+
- **Batch processing**: Pause and resume processing jobs based on system load
|