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.
- package/dist/chunk-BVWUCG4J.mjs +3402 -0
- package/dist/chunk-BVWUCG4J.mjs.map +1 -0
- package/dist/chunk-SL5GCAQE.cjs +3393 -0
- package/dist/chunk-SL5GCAQE.cjs.map +1 -0
- package/dist/index.cjs +4623 -3978
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3934 -1964
- package/dist/index.d.ts +3934 -1964
- package/dist/index.mjs +4601 -3956
- package/dist/index.mjs.map +1 -1
- package/dist/key-normalizer-AF7APGQZ.cjs +136 -0
- package/dist/key-normalizer-AF7APGQZ.cjs.map +1 -0
- package/dist/key-normalizer-QDBRLFHF.mjs +145 -0
- package/dist/key-normalizer-QDBRLFHF.mjs.map +1 -0
- package/dist/model-CNCGFWJH.cjs +200 -0
- package/dist/model-CNCGFWJH.cjs.map +1 -0
- package/dist/model-LGWQJWKQ.mjs +209 -0
- package/docs/api/README.md +26 -0
- package/docs/api/browser-use/browser.md +177 -0
- package/docs/api/browser-use/extension.md +284 -0
- package/docs/api/codespace/code.md +77 -0
- package/docs/api/common-features/advanced/agent.md +84 -0
- package/docs/api/common-features/advanced/oss.md +221 -0
- package/docs/api/common-features/basics/agentbay.md +277 -0
- package/docs/api/common-features/basics/command.md +83 -0
- package/docs/api/common-features/basics/context-manager.md +149 -0
- package/docs/api/common-features/basics/context-sync.md +51 -0
- package/docs/api/common-features/basics/context.md +348 -0
- package/docs/api/common-features/basics/filesystem.md +499 -0
- package/docs/api/common-features/basics/logging.md +77 -0
- package/docs/api/common-features/basics/session.md +542 -0
- package/docs/api/computer-use/computer.md +786 -0
- package/docs/api/mobile-use/mobile.md +395 -0
- package/docs/examples/README.md +332 -0
- package/docs/examples/basic-usage.ts +86 -0
- package/docs/examples/browser-use/browser/README.md +356 -0
- package/docs/examples/browser-use/browser/basic-usage.ts +136 -0
- package/docs/examples/browser-use/browser/browser-command-args.ts +117 -0
- package/docs/examples/browser-use/browser/browser-context-cookie-persistence.ts +348 -0
- package/docs/examples/browser-use/browser/browser-fingerprint-basic-usage.ts +121 -0
- package/docs/examples/browser-use/browser/browser-fingerprint-construct.ts +114 -0
- package/docs/examples/browser-use/browser/browser-fingerprint-local-sync.ts +98 -0
- package/docs/examples/browser-use/browser/browser-fingerprint-persistence.ts +242 -0
- package/docs/examples/browser-use/browser/browser-proxies.ts +149 -0
- package/docs/examples/browser-use/browser/browser-type-example.ts +266 -0
- package/docs/examples/browser-use/browser/browser-viewport.ts +129 -0
- package/docs/examples/browser-use/browser/call_for_user_jd.ts +184 -0
- package/docs/examples/browser-use/browser/captcha_tongcheng.ts +151 -0
- package/docs/examples/browser-use/browser/run-2048.ts +209 -0
- package/docs/examples/browser-use/browser/run-sudoku.ts +150 -0
- package/docs/examples/browser-use/browser/screenshot-example.ts +132 -0
- package/docs/examples/browser-use/extension-example/README.md +252 -0
- package/docs/examples/browser-use/extension-example/extension-example.ts +381 -0
- package/docs/examples/codespace/automation/automation-example.ts +322 -0
- package/docs/examples/common-features/advanced/agent-module-example/README.md +40 -0
- package/docs/examples/common-features/advanced/agent-module-example.ts +66 -0
- package/docs/examples/common-features/advanced/archive-upload-mode-example/README.md +212 -0
- package/docs/examples/common-features/advanced/archive-upload-mode-example/archive-upload-mode-example.ts +213 -0
- package/docs/examples/common-features/advanced/vpc-session-example/README.md +47 -0
- package/docs/examples/common-features/advanced/vpc-session-example.ts +106 -0
- package/docs/examples/common-features/basics/archive-upload-mode-example/README.md +236 -0
- package/docs/examples/common-features/basics/archive-upload-mode-example/main.ts +236 -0
- package/docs/examples/common-features/basics/command-example/README.md +47 -0
- package/docs/examples/common-features/basics/command-example/command-example.ts +153 -0
- package/docs/examples/common-features/basics/context-management/README.md +55 -0
- package/docs/examples/common-features/basics/context-management/context-management.ts +140 -0
- package/docs/examples/common-features/basics/data-persistence/README.md +129 -0
- package/docs/examples/common-features/basics/data-persistence/context-sync-demo.md +144 -0
- package/docs/examples/common-features/basics/data-persistence/context-sync-demo.ts +275 -0
- package/docs/examples/common-features/basics/data-persistence/data-persistence.ts +259 -0
- package/docs/examples/common-features/basics/data-persistence/recycle-policy-example.ts +294 -0
- package/docs/examples/common-features/basics/filesystem-example/README.md +57 -0
- package/docs/examples/common-features/basics/filesystem-example/filesystem-example.ts +164 -0
- package/docs/examples/common-features/basics/filesystem-example/filesystem-filetransfer-example.ts +153 -0
- package/docs/examples/common-features/basics/filesystem-example/watch-directory-example.ts +168 -0
- package/docs/examples/common-features/basics/get/README.md +136 -0
- package/docs/examples/common-features/basics/get/main.ts +79 -0
- package/docs/examples/common-features/basics/list_sessions/README.md +54 -0
- package/docs/examples/common-features/basics/list_sessions/main.ts +258 -0
- package/docs/examples/common-features/basics/mcp_tool_direct_call/README.md +142 -0
- package/docs/examples/common-features/basics/mcp_tool_direct_call/main.ts +135 -0
- package/docs/examples/common-features/basics/session-creation/README.md +28 -0
- package/docs/examples/common-features/basics/session-creation/session-creation.ts +295 -0
- 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/README.md +92 -0
- package/docs/examples/mobile-use/mobile-get-adb-url/index.ts +80 -0
- package/docs/examples/mobile-use/mobile-get-adb-url/package-lock.json +279 -0
- package/docs/examples/mobile-use/mobile-get-adb-url/package.json +18 -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 +19 -12
- package/dist/application-KZWXH46T.mjs +0 -17
- package/dist/application-LMA7KSRH.cjs +0 -8
- package/dist/application-LMA7KSRH.cjs.map +0 -1
- package/dist/chunk-BQNGKBQF.mjs +0 -386
- package/dist/chunk-BQNGKBQF.mjs.map +0 -1
- package/dist/chunk-IOVGAAJL.cjs +0 -558
- package/dist/chunk-IOVGAAJL.cjs.map +0 -1
- package/dist/chunk-UF2TC2R4.mjs +0 -567
- package/dist/chunk-UF2TC2R4.mjs.map +0 -1
- package/dist/chunk-X6MS7Z5L.cjs +0 -377
- package/dist/chunk-X6MS7Z5L.cjs.map +0 -1
- package/dist/window-DH37ZDD5.mjs +0 -17
- package/dist/window-DH37ZDD5.mjs.map +0 -1
- package/dist/window-U7N3H735.cjs +0 -8
- package/dist/window-U7N3H735.cjs.map +0 -1
- /package/dist/{application-KZWXH46T.mjs.map → model-LGWQJWKQ.mjs.map} +0 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
(function() {
|
|
5
|
+
if (typeof OpenApi !== 'undefined' && !OpenApi.default) {
|
|
6
|
+
OpenApi.default = OpenApi;
|
|
7
|
+
}
|
|
8
|
+
})();
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
ApplyMqttTokenRequest,
|
|
12
|
+
ApplyMqttTokenResponse,
|
|
13
|
+
ApplyMqttTokenResponseBody,
|
|
14
|
+
ApplyMqttTokenResponseBodyData,
|
|
15
|
+
CallMcpToolRequest,
|
|
16
|
+
CallMcpToolResponse,
|
|
17
|
+
CallMcpToolResponseBody,
|
|
18
|
+
ClearContextRequest,
|
|
19
|
+
ClearContextResponse,
|
|
20
|
+
ClearContextResponseBody,
|
|
21
|
+
CreateMcpSessionRequest,
|
|
22
|
+
CreateMcpSessionRequestPersistenceDataList,
|
|
23
|
+
CreateMcpSessionResponse,
|
|
24
|
+
CreateMcpSessionResponseBody,
|
|
25
|
+
CreateMcpSessionResponseBodyData,
|
|
26
|
+
CreateMcpSessionShrinkRequest,
|
|
27
|
+
DeleteContextFileRequest,
|
|
28
|
+
DeleteContextFileResponse,
|
|
29
|
+
DeleteContextFileResponseBody,
|
|
30
|
+
DeleteContextRequest,
|
|
31
|
+
DeleteContextResponse,
|
|
32
|
+
DeleteContextResponseBody,
|
|
33
|
+
DescribeContextFilesRequest,
|
|
34
|
+
DescribeContextFilesResponse,
|
|
35
|
+
DescribeContextFilesResponseBody,
|
|
36
|
+
GetAdbLinkRequest,
|
|
37
|
+
GetAdbLinkResponse,
|
|
38
|
+
GetAdbLinkResponseBody,
|
|
39
|
+
GetAdbLinkResponseBodyData,
|
|
40
|
+
GetCdpLinkRequest,
|
|
41
|
+
GetCdpLinkResponse,
|
|
42
|
+
GetCdpLinkResponseBody,
|
|
43
|
+
GetCdpLinkResponseBodyData,
|
|
44
|
+
GetContextFileDownloadUrlRequest,
|
|
45
|
+
GetContextFileDownloadUrlResponse,
|
|
46
|
+
GetContextFileDownloadUrlResponseBody,
|
|
47
|
+
GetContextFileUploadUrlRequest,
|
|
48
|
+
GetContextFileUploadUrlResponse,
|
|
49
|
+
GetContextFileUploadUrlResponseBody,
|
|
50
|
+
GetContextInfoRequest,
|
|
51
|
+
GetContextInfoResponse,
|
|
52
|
+
GetContextInfoResponseBody,
|
|
53
|
+
GetContextInfoResponseBodyData,
|
|
54
|
+
GetContextRequest,
|
|
55
|
+
GetContextResponse,
|
|
56
|
+
GetContextResponseBody,
|
|
57
|
+
GetContextResponseBodyData,
|
|
58
|
+
GetLabelRequest,
|
|
59
|
+
GetLabelResponse,
|
|
60
|
+
GetLabelResponseBody,
|
|
61
|
+
GetLabelResponseBodyData,
|
|
62
|
+
GetLinkRequest,
|
|
63
|
+
GetLinkResponse,
|
|
64
|
+
GetLinkResponseBody,
|
|
65
|
+
GetLinkResponseBodyData,
|
|
66
|
+
GetMcpResourceRequest,
|
|
67
|
+
GetMcpResourceResponse,
|
|
68
|
+
GetMcpResourceResponseBody,
|
|
69
|
+
GetMcpResourceResponseBodyData,
|
|
70
|
+
GetMcpResourceResponseBodyDataDesktopInfo,
|
|
71
|
+
GetSessionRequest,
|
|
72
|
+
GetSessionResponse,
|
|
73
|
+
GetSessionResponseBody,
|
|
74
|
+
GetSessionResponseBodyData,
|
|
75
|
+
InitBrowserRequest,
|
|
76
|
+
InitBrowserResponse,
|
|
77
|
+
InitBrowserResponseBody,
|
|
78
|
+
InitBrowserResponseBodyData,
|
|
79
|
+
ListContextsRequest,
|
|
80
|
+
ListContextsResponse,
|
|
81
|
+
ListContextsResponseBody,
|
|
82
|
+
ListContextsResponseBodyData,
|
|
83
|
+
ListMcpToolsRequest,
|
|
84
|
+
ListMcpToolsResponse,
|
|
85
|
+
ListMcpToolsResponseBody,
|
|
86
|
+
ListSessionRequest,
|
|
87
|
+
ListSessionResponse,
|
|
88
|
+
ListSessionResponseBody,
|
|
89
|
+
ListSessionResponseBodyData,
|
|
90
|
+
ModifyContextRequest,
|
|
91
|
+
ModifyContextResponse,
|
|
92
|
+
ModifyContextResponseBody,
|
|
93
|
+
PauseSessionAsyncRequest,
|
|
94
|
+
PauseSessionAsyncResponse,
|
|
95
|
+
PauseSessionAsyncResponseBody,
|
|
96
|
+
ReleaseMcpSessionRequest,
|
|
97
|
+
ReleaseMcpSessionResponse,
|
|
98
|
+
ReleaseMcpSessionResponseBody,
|
|
99
|
+
ResumeSessionAsyncRequest,
|
|
100
|
+
ResumeSessionAsyncResponse,
|
|
101
|
+
ResumeSessionAsyncResponseBody,
|
|
102
|
+
SetLabelRequest,
|
|
103
|
+
SetLabelResponse,
|
|
104
|
+
SetLabelResponseBody,
|
|
105
|
+
SyncContextRequest,
|
|
106
|
+
SyncContextResponse,
|
|
107
|
+
SyncContextResponseBody
|
|
108
|
+
} from "./chunk-BVWUCG4J.mjs";
|
|
109
|
+
import "./chunk-KNEDRAP6.mjs";
|
|
110
|
+
export {
|
|
111
|
+
ApplyMqttTokenRequest,
|
|
112
|
+
ApplyMqttTokenResponse,
|
|
113
|
+
ApplyMqttTokenResponseBody,
|
|
114
|
+
ApplyMqttTokenResponseBodyData,
|
|
115
|
+
CallMcpToolRequest,
|
|
116
|
+
CallMcpToolResponse,
|
|
117
|
+
CallMcpToolResponseBody,
|
|
118
|
+
ClearContextRequest,
|
|
119
|
+
ClearContextResponse,
|
|
120
|
+
ClearContextResponseBody,
|
|
121
|
+
CreateMcpSessionRequest,
|
|
122
|
+
CreateMcpSessionRequestPersistenceDataList,
|
|
123
|
+
CreateMcpSessionResponse,
|
|
124
|
+
CreateMcpSessionResponseBody,
|
|
125
|
+
CreateMcpSessionResponseBodyData,
|
|
126
|
+
CreateMcpSessionShrinkRequest,
|
|
127
|
+
DeleteContextFileRequest,
|
|
128
|
+
DeleteContextFileResponse,
|
|
129
|
+
DeleteContextFileResponseBody,
|
|
130
|
+
DeleteContextRequest,
|
|
131
|
+
DeleteContextResponse,
|
|
132
|
+
DeleteContextResponseBody,
|
|
133
|
+
DescribeContextFilesRequest,
|
|
134
|
+
DescribeContextFilesResponse,
|
|
135
|
+
DescribeContextFilesResponseBody,
|
|
136
|
+
GetAdbLinkRequest,
|
|
137
|
+
GetAdbLinkResponse,
|
|
138
|
+
GetAdbLinkResponseBody,
|
|
139
|
+
GetAdbLinkResponseBodyData,
|
|
140
|
+
GetCdpLinkRequest,
|
|
141
|
+
GetCdpLinkResponse,
|
|
142
|
+
GetCdpLinkResponseBody,
|
|
143
|
+
GetCdpLinkResponseBodyData,
|
|
144
|
+
GetContextFileDownloadUrlRequest,
|
|
145
|
+
GetContextFileDownloadUrlResponse,
|
|
146
|
+
GetContextFileDownloadUrlResponseBody,
|
|
147
|
+
GetContextFileUploadUrlRequest,
|
|
148
|
+
GetContextFileUploadUrlResponse,
|
|
149
|
+
GetContextFileUploadUrlResponseBody,
|
|
150
|
+
GetContextInfoRequest,
|
|
151
|
+
GetContextInfoResponse,
|
|
152
|
+
GetContextInfoResponseBody,
|
|
153
|
+
GetContextInfoResponseBodyData,
|
|
154
|
+
GetContextRequest,
|
|
155
|
+
GetContextResponse,
|
|
156
|
+
GetContextResponseBody,
|
|
157
|
+
GetContextResponseBodyData,
|
|
158
|
+
GetLabelRequest,
|
|
159
|
+
GetLabelResponse,
|
|
160
|
+
GetLabelResponseBody,
|
|
161
|
+
GetLabelResponseBodyData,
|
|
162
|
+
GetLinkRequest,
|
|
163
|
+
GetLinkResponse,
|
|
164
|
+
GetLinkResponseBody,
|
|
165
|
+
GetLinkResponseBodyData,
|
|
166
|
+
GetMcpResourceRequest,
|
|
167
|
+
GetMcpResourceResponse,
|
|
168
|
+
GetMcpResourceResponseBody,
|
|
169
|
+
GetMcpResourceResponseBodyData,
|
|
170
|
+
GetMcpResourceResponseBodyDataDesktopInfo,
|
|
171
|
+
GetSessionRequest,
|
|
172
|
+
GetSessionResponse,
|
|
173
|
+
GetSessionResponseBody,
|
|
174
|
+
GetSessionResponseBodyData,
|
|
175
|
+
InitBrowserRequest,
|
|
176
|
+
InitBrowserResponse,
|
|
177
|
+
InitBrowserResponseBody,
|
|
178
|
+
InitBrowserResponseBodyData,
|
|
179
|
+
ListContextsRequest,
|
|
180
|
+
ListContextsResponse,
|
|
181
|
+
ListContextsResponseBody,
|
|
182
|
+
ListContextsResponseBodyData,
|
|
183
|
+
ListMcpToolsRequest,
|
|
184
|
+
ListMcpToolsResponse,
|
|
185
|
+
ListMcpToolsResponseBody,
|
|
186
|
+
ListSessionRequest,
|
|
187
|
+
ListSessionResponse,
|
|
188
|
+
ListSessionResponseBody,
|
|
189
|
+
ListSessionResponseBodyData,
|
|
190
|
+
ModifyContextRequest,
|
|
191
|
+
ModifyContextResponse,
|
|
192
|
+
ModifyContextResponseBody,
|
|
193
|
+
PauseSessionAsyncRequest,
|
|
194
|
+
PauseSessionAsyncResponse,
|
|
195
|
+
PauseSessionAsyncResponseBody,
|
|
196
|
+
ReleaseMcpSessionRequest,
|
|
197
|
+
ReleaseMcpSessionResponse,
|
|
198
|
+
ReleaseMcpSessionResponseBody,
|
|
199
|
+
ResumeSessionAsyncRequest,
|
|
200
|
+
ResumeSessionAsyncResponse,
|
|
201
|
+
ResumeSessionAsyncResponseBody,
|
|
202
|
+
SetLabelRequest,
|
|
203
|
+
SetLabelResponse,
|
|
204
|
+
SetLabelResponseBody,
|
|
205
|
+
SyncContextRequest,
|
|
206
|
+
SyncContextResponse,
|
|
207
|
+
SyncContextResponseBody
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=model-LGWQJWKQ.mjs.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# TypeScript SDK API Reference
|
|
2
|
+
|
|
3
|
+
These documents are generated automatically using TypeDoc. Run `npm run docs:generate` to refresh them after changing the SDK.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
- `browser-use`
|
|
7
|
+
- browser.md
|
|
8
|
+
- extension.md
|
|
9
|
+
- `codespace`
|
|
10
|
+
- code.md
|
|
11
|
+
- `common-features/advanced`
|
|
12
|
+
- agent.md
|
|
13
|
+
- oss.md
|
|
14
|
+
- `common-features/basics`
|
|
15
|
+
- agentbay.md
|
|
16
|
+
- command.md
|
|
17
|
+
- context-manager.md
|
|
18
|
+
- context-sync.md
|
|
19
|
+
- context.md
|
|
20
|
+
- filesystem.md
|
|
21
|
+
- logging.md
|
|
22
|
+
- session.md
|
|
23
|
+
- `computer-use`
|
|
24
|
+
- computer.md
|
|
25
|
+
- `mobile-use`
|
|
26
|
+
- mobile.md
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Class: Browser
|
|
2
|
+
|
|
3
|
+
## 🌐 Related Tutorial
|
|
4
|
+
|
|
5
|
+
- [Browser Use Guide](../../../../docs/guides/browser-use/README.md) - Complete guide to browser automation
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The Browser module provides comprehensive browser automation capabilities including navigation, element interaction,
|
|
10
|
+
screenshot capture, and content extraction. It enables automated testing and web scraping workflows.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
- Requires `browser_latest` image for browser automation features
|
|
16
|
+
|
|
17
|
+
## Table of contents
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Properties
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Methods
|
|
24
|
+
|
|
25
|
+
- [destroy](#destroy)
|
|
26
|
+
- [initialize](#initialize)
|
|
27
|
+
- [initializeAsync](#initializeasync)
|
|
28
|
+
- [isInitialized](#isinitialized)
|
|
29
|
+
- [screenshot](#screenshot)
|
|
30
|
+
|
|
31
|
+
## Properties
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
agent: ``BrowserAgent``
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## Methods
|
|
39
|
+
|
|
40
|
+
### destroy
|
|
41
|
+
|
|
42
|
+
▸ **destroy**(): `Promise`\<`void`\>
|
|
43
|
+
|
|
44
|
+
Destroy the browser instance.
|
|
45
|
+
|
|
46
|
+
#### Returns
|
|
47
|
+
|
|
48
|
+
`Promise`\<`void`\>
|
|
49
|
+
|
|
50
|
+
### initialize
|
|
51
|
+
|
|
52
|
+
▸ **initialize**(`option`): `boolean`
|
|
53
|
+
|
|
54
|
+
Initialize the browser instance with the given options.
|
|
55
|
+
Returns true if successful, false otherwise.
|
|
56
|
+
|
|
57
|
+
#### Parameters
|
|
58
|
+
|
|
59
|
+
| Name | Type |
|
|
60
|
+
| :------ | :------ |
|
|
61
|
+
| `option` | ``BrowserOption`` \| ``BrowserOptionClass`` |
|
|
62
|
+
|
|
63
|
+
#### Returns
|
|
64
|
+
|
|
65
|
+
`boolean`
|
|
66
|
+
|
|
67
|
+
___
|
|
68
|
+
|
|
69
|
+
### initializeAsync
|
|
70
|
+
|
|
71
|
+
▸ **initializeAsync**(`option`): `Promise`\<`boolean`\>
|
|
72
|
+
|
|
73
|
+
Initialize the browser instance with the given options asynchronously.
|
|
74
|
+
Returns true if successful, false otherwise.
|
|
75
|
+
|
|
76
|
+
#### Parameters
|
|
77
|
+
|
|
78
|
+
| Name | Type | Description |
|
|
79
|
+
| :------ | :------ | :------ |
|
|
80
|
+
| `option` | ``BrowserOption`` \| ``BrowserOptionClass`` | Browser configuration options |
|
|
81
|
+
|
|
82
|
+
#### Returns
|
|
83
|
+
|
|
84
|
+
`Promise`\<`boolean`\>
|
|
85
|
+
|
|
86
|
+
Promise resolving to true if successful, false otherwise
|
|
87
|
+
|
|
88
|
+
**`Example`**
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
|
|
92
|
+
const result = await agentBay.create({ imageId: 'browser_latest' });
|
|
93
|
+
if (result.success) {
|
|
94
|
+
const success = await result.session.browser.initializeAsync(new BrowserOptionClass());
|
|
95
|
+
console.log('Browser initialized:', success);
|
|
96
|
+
await result.session.delete();
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
___
|
|
101
|
+
|
|
102
|
+
### isInitialized
|
|
103
|
+
|
|
104
|
+
▸ **isInitialized**(): `boolean`
|
|
105
|
+
|
|
106
|
+
Returns true if the browser was initialized, false otherwise.
|
|
107
|
+
|
|
108
|
+
#### Returns
|
|
109
|
+
|
|
110
|
+
`boolean`
|
|
111
|
+
|
|
112
|
+
___
|
|
113
|
+
|
|
114
|
+
### screenshot
|
|
115
|
+
|
|
116
|
+
▸ **screenshot**(`page`, `fullPage?`, `options?`): `Promise`\<`Uint8Array`\>
|
|
117
|
+
|
|
118
|
+
Takes a screenshot of the specified page with enhanced options and error handling.
|
|
119
|
+
This method requires the caller to connect to the browser via Playwright or similar
|
|
120
|
+
and pass the page object to this method.
|
|
121
|
+
|
|
122
|
+
Note: This is a placeholder method that indicates where screenshot functionality
|
|
123
|
+
should be implemented. In a complete implementation, this would use Playwright's
|
|
124
|
+
page.screenshot() method or similar browser automation API.
|
|
125
|
+
|
|
126
|
+
#### Parameters
|
|
127
|
+
|
|
128
|
+
| Name | Type | Default value | Description |
|
|
129
|
+
| :------ | :------ | :------ | :------ |
|
|
130
|
+
| `page` | `any` | `undefined` | The Playwright Page object to take a screenshot of. This is a required parameter. |
|
|
131
|
+
| `fullPage` | `boolean` | `false` | Whether to capture the full scrollable page. Defaults to false. |
|
|
132
|
+
| `options` | `Record`\<`string`, `any`\> | `{}` | Additional screenshot options that will override defaults. Common options include: - type: Image type, either 'png' or 'jpeg' (default: 'png') - quality: Quality of the image, between 0-100 (jpeg only) - timeout: Maximum time in milliseconds (default: 60000) - animations: How to handle animations (default: 'disabled') - caret: How to handle the caret (default: 'hide') - scale: Scale setting (default: 'css') |
|
|
133
|
+
|
|
134
|
+
#### Returns
|
|
135
|
+
|
|
136
|
+
`Promise`\<`Uint8Array`\>
|
|
137
|
+
|
|
138
|
+
Screenshot data as Uint8Array.
|
|
139
|
+
|
|
140
|
+
**`Throws`**
|
|
141
|
+
|
|
142
|
+
BrowserError If browser is not initialized.
|
|
143
|
+
|
|
144
|
+
**`Throws`**
|
|
145
|
+
|
|
146
|
+
Error If screenshot capture fails.
|
|
147
|
+
|
|
148
|
+
**`Example`**
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
const agentBay = new AgentBay({ apiKey: process.env.AGENTBAY_API_KEY });
|
|
152
|
+
const result = await agentBay.create({ imageId: 'browser_latest' });
|
|
153
|
+
if (result.success) {
|
|
154
|
+
await result.session.browser.initializeAsync(new BrowserOptionClass());
|
|
155
|
+
const browser = await chromium.connectOverCDP(await result.session.browser.getEndpointUrl());
|
|
156
|
+
const page = await browser.contexts()[0].newPage();
|
|
157
|
+
await page.goto('https://example.com');
|
|
158
|
+
const screenshot = await result.session.browser.screenshot(page);
|
|
159
|
+
await writeFile('screenshot.png', Buffer.from(screenshot));
|
|
160
|
+
await browser.close();
|
|
161
|
+
await result.session.delete();
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Best Practices
|
|
166
|
+
|
|
167
|
+
1. Wait for page load completion before interacting with elements
|
|
168
|
+
2. Use appropriate selectors (CSS, XPath) for reliable element identification
|
|
169
|
+
3. Handle navigation timeouts and errors gracefully
|
|
170
|
+
4. Take screenshots for debugging and verification
|
|
171
|
+
5. Clean up browser resources after automation tasks
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
## Related Resources
|
|
175
|
+
|
|
176
|
+
- [Session API Reference](../common-features/basics/session.md)
|
|
177
|
+
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# Class: ExtensionsService
|
|
2
|
+
|
|
3
|
+
## 🧩 Related Tutorial
|
|
4
|
+
|
|
5
|
+
- [Browser Extensions Guide](../../../../docs/guides/browser-use/core-features/extension.md) - Learn how to use browser extensions
|
|
6
|
+
|
|
7
|
+
Provides methods to manage user browser extensions.
|
|
8
|
+
This service integrates with the existing context functionality for file operations.
|
|
9
|
+
|
|
10
|
+
**Usage** (Simplified - Auto-detection):
|
|
11
|
+
```typescript
|
|
12
|
+
// Service automatically detects if context exists and creates if needed
|
|
13
|
+
const extensionsService = new ExtensionsService(agentBay, "browser_extensions");
|
|
14
|
+
|
|
15
|
+
// Or use with empty contextId to auto-generate context name
|
|
16
|
+
const extensionsService = new ExtensionsService(agentBay); // Uses default generated name
|
|
17
|
+
|
|
18
|
+
// Use the service immediately - initialization happens automatically
|
|
19
|
+
const extension = await extensionsService.create("/path/to/plugin.zip");
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Integration with ExtensionOption (Simplified)**:
|
|
23
|
+
```typescript
|
|
24
|
+
// Create extensions and configure for browser sessions
|
|
25
|
+
const extensionsService = new ExtensionsService(agentBay, "my_extensions");
|
|
26
|
+
const ext1 = await extensionsService.create("/path/to/ext1.zip");
|
|
27
|
+
const ext2 = await extensionsService.create("/path/to/ext2.zip");
|
|
28
|
+
|
|
29
|
+
// Create extension option for browser integration (no contextId needed!)
|
|
30
|
+
const extOption = extensionsService.createExtensionOption([ext1.id, ext2.id]);
|
|
31
|
+
|
|
32
|
+
// Use with BrowserContext for session creation
|
|
33
|
+
const browserContext = new BrowserContext({
|
|
34
|
+
contextId: "browser_session",
|
|
35
|
+
autoUpload: true,
|
|
36
|
+
extensionOption: extOption // All extension config encapsulated
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Context Management**:
|
|
41
|
+
- If contextId provided and exists: Uses the existing context
|
|
42
|
+
- If contextId provided but doesn't exist: Creates context with provided name
|
|
43
|
+
- If contextId empty or not provided: Generates default name and creates context
|
|
44
|
+
- No need to manually manage context creation or call initialize()
|
|
45
|
+
- Context initialization happens automatically on first method call
|
|
46
|
+
|
|
47
|
+
## Table of contents
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Methods
|
|
51
|
+
|
|
52
|
+
- [cleanup](#cleanup)
|
|
53
|
+
- [create](#create)
|
|
54
|
+
- [createExtensionOption](#createextensionoption)
|
|
55
|
+
- [delete](#delete)
|
|
56
|
+
- [list](#list)
|
|
57
|
+
- [update](#update)
|
|
58
|
+
|
|
59
|
+
## Methods
|
|
60
|
+
|
|
61
|
+
### cleanup
|
|
62
|
+
|
|
63
|
+
▸ **cleanup**(): `Promise`\<`boolean`\>
|
|
64
|
+
|
|
65
|
+
Cleans up the auto-created context if it was created by this service.
|
|
66
|
+
|
|
67
|
+
#### Returns
|
|
68
|
+
|
|
69
|
+
`Promise`\<`boolean`\>
|
|
70
|
+
|
|
71
|
+
Promise that resolves to true if cleanup was successful or not needed, false if cleanup failed.
|
|
72
|
+
|
|
73
|
+
Note:
|
|
74
|
+
This method only works if the context was auto-created by this service.
|
|
75
|
+
For existing contexts, no cleanup is performed.
|
|
76
|
+
|
|
77
|
+
**`Example`**
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const agentBay = new AgentBay({ apiKey: 'your_api_key' });
|
|
81
|
+
const service = new ExtensionsService(agentBay);
|
|
82
|
+
await service.create('/path/to/my-extension.zip');
|
|
83
|
+
const success = await service.cleanup();
|
|
84
|
+
console.log('Cleanup success:', success);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
___
|
|
88
|
+
|
|
89
|
+
### create
|
|
90
|
+
|
|
91
|
+
▸ **create**(`localPath`): `Promise`\<``Extension``\>
|
|
92
|
+
|
|
93
|
+
Uploads a new browser extension from a local path into the current context.
|
|
94
|
+
|
|
95
|
+
#### Parameters
|
|
96
|
+
|
|
97
|
+
| Name | Type | Description |
|
|
98
|
+
| :------ | :------ | :------ |
|
|
99
|
+
| `localPath` | `string` | Path to the local extension file (must be a .zip file). |
|
|
100
|
+
|
|
101
|
+
#### Returns
|
|
102
|
+
|
|
103
|
+
`Promise`\<``Extension``\>
|
|
104
|
+
|
|
105
|
+
Promise that resolves to an Extension object.
|
|
106
|
+
|
|
107
|
+
**`Throws`**
|
|
108
|
+
|
|
109
|
+
If the local file doesn't exist.
|
|
110
|
+
|
|
111
|
+
**`Throws`**
|
|
112
|
+
|
|
113
|
+
If the file format is not supported (only .zip is supported).
|
|
114
|
+
|
|
115
|
+
**`Throws`**
|
|
116
|
+
|
|
117
|
+
If upload fails.
|
|
118
|
+
|
|
119
|
+
**`Example`**
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
const agentBay = new AgentBay({ apiKey: 'your_api_key' });
|
|
123
|
+
const service = new ExtensionsService(agentBay);
|
|
124
|
+
const extension = await service.create('/path/to/my-extension.zip');
|
|
125
|
+
console.log(`Extension ID: ${extension.id}`);
|
|
126
|
+
await service.cleanup();
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
___
|
|
130
|
+
|
|
131
|
+
### createExtensionOption
|
|
132
|
+
|
|
133
|
+
▸ **createExtensionOption**(`extensionIds`): ``ExtensionOption``
|
|
134
|
+
|
|
135
|
+
Create an ExtensionOption for the current context with specified extension IDs.
|
|
136
|
+
|
|
137
|
+
This is a convenience method that creates an ExtensionOption using the current
|
|
138
|
+
service's contextId and the provided extension IDs. This option can then be
|
|
139
|
+
used with BrowserContext for browser session creation.
|
|
140
|
+
|
|
141
|
+
#### Parameters
|
|
142
|
+
|
|
143
|
+
| Name | Type | Description |
|
|
144
|
+
| :------ | :------ | :------ |
|
|
145
|
+
| `extensionIds` | `string`[] | List of extension IDs to include in the option. These should be extensions that exist in the current context. |
|
|
146
|
+
|
|
147
|
+
#### Returns
|
|
148
|
+
|
|
149
|
+
``ExtensionOption``
|
|
150
|
+
|
|
151
|
+
ExtensionOption configuration object for browser extension integration.
|
|
152
|
+
|
|
153
|
+
**`Throws`**
|
|
154
|
+
|
|
155
|
+
If extensionIds is empty or invalid.
|
|
156
|
+
|
|
157
|
+
**`Example`**
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
// Create extensions
|
|
161
|
+
const ext1 = await extensionsService.create("/path/to/ext1.zip");
|
|
162
|
+
const ext2 = await extensionsService.create("/path/to/ext2.zip");
|
|
163
|
+
|
|
164
|
+
// Create extension option for browser integration
|
|
165
|
+
const extOption = extensionsService.createExtensionOption([ext1.id, ext2.id]);
|
|
166
|
+
|
|
167
|
+
// Use with BrowserContext
|
|
168
|
+
const browserContext = new BrowserContext({
|
|
169
|
+
contextId: "browser_session",
|
|
170
|
+
autoUpload: true,
|
|
171
|
+
extensionContextId: extOption.contextId,
|
|
172
|
+
extensionIds: extOption.extensionIds
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
___
|
|
177
|
+
|
|
178
|
+
### delete
|
|
179
|
+
|
|
180
|
+
▸ **delete**(`extensionId`): `Promise`\<`boolean`\>
|
|
181
|
+
|
|
182
|
+
Deletes a browser extension from the current context.
|
|
183
|
+
|
|
184
|
+
#### Parameters
|
|
185
|
+
|
|
186
|
+
| Name | Type | Description |
|
|
187
|
+
| :------ | :------ | :------ |
|
|
188
|
+
| `extensionId` | `string` | ID of the extension to delete. |
|
|
189
|
+
|
|
190
|
+
#### Returns
|
|
191
|
+
|
|
192
|
+
`Promise`\<`boolean`\>
|
|
193
|
+
|
|
194
|
+
Promise that resolves to true if deletion was successful, false otherwise.
|
|
195
|
+
|
|
196
|
+
**`Example`**
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
const agentBay = new AgentBay({ apiKey: 'your_api_key' });
|
|
200
|
+
const service = new ExtensionsService(agentBay, 'my_extensions');
|
|
201
|
+
const ext = await service.create('/path/to/my-extension.zip');
|
|
202
|
+
const success = await service.delete(ext.id);
|
|
203
|
+
console.log('Delete success:', success);
|
|
204
|
+
await service.cleanup();
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
___
|
|
208
|
+
|
|
209
|
+
### list
|
|
210
|
+
|
|
211
|
+
▸ **list**(): `Promise`\<``Extension``[]\>
|
|
212
|
+
|
|
213
|
+
Lists all available browser extensions within this context from the cloud.
|
|
214
|
+
Uses the context service to list files under the extensions directory.
|
|
215
|
+
|
|
216
|
+
#### Returns
|
|
217
|
+
|
|
218
|
+
`Promise`\<``Extension``[]\>
|
|
219
|
+
|
|
220
|
+
Promise that resolves to an array of Extension objects.
|
|
221
|
+
|
|
222
|
+
**`Throws`**
|
|
223
|
+
|
|
224
|
+
If listing extensions fails.
|
|
225
|
+
|
|
226
|
+
**`Example`**
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
const agentBay = new AgentBay({ apiKey: 'your_api_key' });
|
|
230
|
+
const service = new ExtensionsService(agentBay, 'my_extensions');
|
|
231
|
+
await service.create('/path/to/ext1.zip');
|
|
232
|
+
const extensions = await service.list();
|
|
233
|
+
console.log(`Found ${extensions.length} extensions`);
|
|
234
|
+
await service.cleanup();
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
___
|
|
238
|
+
|
|
239
|
+
### update
|
|
240
|
+
|
|
241
|
+
▸ **update**(`extensionId`, `newLocalPath`): `Promise`\<``Extension``\>
|
|
242
|
+
|
|
243
|
+
Updates an existing browser extension in the current context with a new file.
|
|
244
|
+
|
|
245
|
+
#### Parameters
|
|
246
|
+
|
|
247
|
+
| Name | Type | Description |
|
|
248
|
+
| :------ | :------ | :------ |
|
|
249
|
+
| `extensionId` | `string` | ID of the extension to update. |
|
|
250
|
+
| `newLocalPath` | `string` | Path to the new local extension file. |
|
|
251
|
+
|
|
252
|
+
#### Returns
|
|
253
|
+
|
|
254
|
+
`Promise`\<``Extension``\>
|
|
255
|
+
|
|
256
|
+
Promise that resolves to an Extension object.
|
|
257
|
+
|
|
258
|
+
**`Throws`**
|
|
259
|
+
|
|
260
|
+
If the new local file doesn't exist.
|
|
261
|
+
|
|
262
|
+
**`Throws`**
|
|
263
|
+
|
|
264
|
+
If the extension doesn't exist in the context.
|
|
265
|
+
|
|
266
|
+
**`Throws`**
|
|
267
|
+
|
|
268
|
+
If update fails.
|
|
269
|
+
|
|
270
|
+
**`Example`**
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
const agentBay = new AgentBay({ apiKey: 'your_api_key' });
|
|
274
|
+
const service = new ExtensionsService(agentBay, 'my_extensions');
|
|
275
|
+
const ext = await service.create('/path/to/ext-v1.zip');
|
|
276
|
+
const updated = await service.update(ext.id, '/path/to/ext-v2.zip');
|
|
277
|
+
console.log('Extension updated:', updated.name);
|
|
278
|
+
await service.cleanup();
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Related Resources
|
|
282
|
+
|
|
283
|
+
- [Browser API Reference](browser.md)
|
|
284
|
+
|