browser-agent-protocol 0.1.0a1__py3-none-any.whl
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.
- browser_agent_protocol-0.1.0a1.dist-info/METADATA +306 -0
- browser_agent_protocol-0.1.0a1.dist-info/RECORD +20 -0
- browser_agent_protocol-0.1.0a1.dist-info/WHEEL +4 -0
- browser_agent_protocol-0.1.0a1.dist-info/entry_points.txt +2 -0
- browseragentprotocol/__init__.py +335 -0
- browseragentprotocol/cli.py +149 -0
- browseragentprotocol/client.py +1497 -0
- browseragentprotocol/context.py +123 -0
- browseragentprotocol/errors.py +595 -0
- browseragentprotocol/py.typed +0 -0
- browseragentprotocol/sse.py +152 -0
- browseragentprotocol/sync_client.py +613 -0
- browseragentprotocol/transport.py +191 -0
- browseragentprotocol/types/__init__.py +247 -0
- browseragentprotocol/types/agent.py +372 -0
- browseragentprotocol/types/common.py +294 -0
- browseragentprotocol/types/events.py +190 -0
- browseragentprotocol/types/methods.py +385 -0
- browseragentprotocol/types/protocol.py +231 -0
- browseragentprotocol/types/selectors.py +246 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: browser-agent-protocol
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Python SDK for the Browser Agent Protocol (BAP) - control browsers with AI agents
|
|
5
|
+
Project-URL: Homepage, https://github.com/anthropics/browser-agent-protocol
|
|
6
|
+
Project-URL: Documentation, https://github.com/anthropics/browser-agent-protocol#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/anthropics/browser-agent-protocol
|
|
8
|
+
Project-URL: Issues, https://github.com/anthropics/browser-agent-protocol/issues
|
|
9
|
+
Author: BAP Contributors
|
|
10
|
+
License: Apache-2.0
|
|
11
|
+
Keywords: agent,ai,automation,browser,json-rpc,llm,mcp,playwright,puppeteer,websocket
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Framework :: AsyncIO
|
|
14
|
+
Classifier: Framework :: Pydantic :: 2
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Software Development :: Testing
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
28
|
+
Requires-Dist: anyio>=4.0.0
|
|
29
|
+
Requires-Dist: httpx-sse>=0.4.0
|
|
30
|
+
Requires-Dist: httpx>=0.27.0
|
|
31
|
+
Requires-Dist: pydantic>=2.0.0
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: mypy>=1.8.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# browser-agent-protocol
|
|
40
|
+
|
|
41
|
+
Python SDK for the Browser Agent Protocol (BAP) - control browsers with AI agents.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install browser-agent-protocol
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
### Async API (recommended)
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
import asyncio
|
|
55
|
+
from browseragentprotocol import BAPClient, role, text, label
|
|
56
|
+
|
|
57
|
+
async def main():
|
|
58
|
+
async with BAPClient("ws://localhost:9222") as client:
|
|
59
|
+
# Launch browser
|
|
60
|
+
await client.launch(browser="chromium", headless=True)
|
|
61
|
+
|
|
62
|
+
# Create page and navigate
|
|
63
|
+
await client.create_page(url="https://example.com")
|
|
64
|
+
|
|
65
|
+
# Click using semantic selectors
|
|
66
|
+
await client.click(role("button", "Submit"))
|
|
67
|
+
|
|
68
|
+
# Fill form fields
|
|
69
|
+
await client.fill(label("Email"), "user@example.com")
|
|
70
|
+
|
|
71
|
+
# Take screenshot
|
|
72
|
+
screenshot = await client.screenshot()
|
|
73
|
+
print(f"Screenshot: {len(screenshot.data)} bytes")
|
|
74
|
+
|
|
75
|
+
# Get accessibility tree (ideal for AI agents)
|
|
76
|
+
tree = await client.accessibility()
|
|
77
|
+
print(f"Found {len(tree.tree)} nodes")
|
|
78
|
+
|
|
79
|
+
asyncio.run(main())
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### High-Level Session Helper
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from browseragentprotocol.context import bap_session, role
|
|
86
|
+
|
|
87
|
+
async with bap_session(
|
|
88
|
+
"ws://localhost:9222",
|
|
89
|
+
start_url="https://example.com"
|
|
90
|
+
) as client:
|
|
91
|
+
await client.click(role("button", "Accept"))
|
|
92
|
+
content = await client.content()
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Sync API (for scripts and notebooks)
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from browseragentprotocol import BAPClientSync, role
|
|
99
|
+
|
|
100
|
+
with BAPClientSync("ws://localhost:9222") as client:
|
|
101
|
+
client.launch(browser="chromium", headless=True)
|
|
102
|
+
client.create_page(url="https://example.com")
|
|
103
|
+
|
|
104
|
+
client.click(role("button", "Submit"))
|
|
105
|
+
screenshot = client.screenshot()
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### CLI
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Test connection to a BAP server
|
|
112
|
+
bap connect ws://localhost:9222
|
|
113
|
+
|
|
114
|
+
# Get server info (with JSON output)
|
|
115
|
+
bap info ws://localhost:9222 --json
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Semantic Selectors
|
|
119
|
+
|
|
120
|
+
BAP uses semantic selectors instead of brittle CSS selectors:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from browseragentprotocol import role, text, label, css, xpath, test_id, ref
|
|
124
|
+
|
|
125
|
+
# Recommended: Semantic selectors
|
|
126
|
+
role("button", "Submit") # ARIA role + accessible name
|
|
127
|
+
text("Sign in") # Visible text content
|
|
128
|
+
label("Email address") # Associated label
|
|
129
|
+
|
|
130
|
+
# Developer-controlled identifiers
|
|
131
|
+
test_id("submit-button") # data-testid attribute
|
|
132
|
+
|
|
133
|
+
# Stable element references
|
|
134
|
+
ref("@submitBtn") # Element ref from agent/observe
|
|
135
|
+
|
|
136
|
+
# Fallback: CSS/XPath
|
|
137
|
+
css(".btn-primary")
|
|
138
|
+
xpath("//button[@type='submit']")
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## AI Agent Methods
|
|
142
|
+
|
|
143
|
+
BAP provides three composite methods optimized for AI agents:
|
|
144
|
+
|
|
145
|
+
### agent/observe - Get AI-optimized page snapshots
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
observation = await client.observe(
|
|
149
|
+
include_accessibility=True,
|
|
150
|
+
include_interactive_elements=True,
|
|
151
|
+
include_screenshot=True,
|
|
152
|
+
max_elements=50,
|
|
153
|
+
annotate_screenshot=True, # Set-of-Marks style annotation
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
# Interactive elements with stable refs
|
|
157
|
+
for element in observation.interactive_elements:
|
|
158
|
+
print(f"{element.ref}: {element.role} - {element.name}")
|
|
159
|
+
# @e1: button - Submit
|
|
160
|
+
# @e2: textbox - Email
|
|
161
|
+
|
|
162
|
+
# Screenshot with numbered badges linking to elements
|
|
163
|
+
if observation.annotation_map:
|
|
164
|
+
for annotation in observation.annotation_map:
|
|
165
|
+
print(f"[{annotation.label}] -> {annotation.ref}")
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### agent/act - Execute multi-step sequences atomically
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from browseragentprotocol import BAPClient
|
|
172
|
+
|
|
173
|
+
result = await client.act([
|
|
174
|
+
BAPClient.step("action/fill", {"selector": label("Email"), "value": "user@example.com"}),
|
|
175
|
+
BAPClient.step("action/fill", {"selector": label("Password"), "value": "secret123"}),
|
|
176
|
+
BAPClient.step("action/click", {"selector": role("button", "Sign In")}),
|
|
177
|
+
])
|
|
178
|
+
|
|
179
|
+
print(f"Completed {result.completed}/{result.total} steps")
|
|
180
|
+
print(f"Success: {result.success}")
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### agent/extract - Extract structured data
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
data = await client.extract(
|
|
187
|
+
instruction="Extract all product names and prices",
|
|
188
|
+
schema={
|
|
189
|
+
"type": "array",
|
|
190
|
+
"items": {
|
|
191
|
+
"type": "object",
|
|
192
|
+
"properties": {
|
|
193
|
+
"name": {"type": "string"},
|
|
194
|
+
"price": {"type": "number"},
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
if data.success:
|
|
201
|
+
for product in data.data:
|
|
202
|
+
print(f"{product['name']}: ${product['price']}")
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Multi-Context Support
|
|
206
|
+
|
|
207
|
+
Create isolated browser contexts with separate cookies/storage:
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
# Create isolated context
|
|
211
|
+
context = await client.create_context(
|
|
212
|
+
context_id="user-session",
|
|
213
|
+
options={
|
|
214
|
+
"viewport": {"width": 1920, "height": 1080},
|
|
215
|
+
"locale": "en-US",
|
|
216
|
+
},
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
# Create page in specific context
|
|
220
|
+
page = await client.create_page(
|
|
221
|
+
url="https://example.com",
|
|
222
|
+
context_id=context.context_id,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
# Clean up
|
|
226
|
+
await client.destroy_context(context.context_id)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Frame Support
|
|
230
|
+
|
|
231
|
+
Navigate iframes and cross-origin frames:
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
# List frames
|
|
235
|
+
frames = await client.list_frames()
|
|
236
|
+
for frame in frames.frames:
|
|
237
|
+
print(f"{frame.frame_id}: {frame.url}")
|
|
238
|
+
|
|
239
|
+
# Switch to iframe
|
|
240
|
+
await client.switch_frame(selector=css("iframe#payment"))
|
|
241
|
+
|
|
242
|
+
# Interact within frame
|
|
243
|
+
await client.fill(label("Card number"), "4242424242424242")
|
|
244
|
+
|
|
245
|
+
# Return to main frame
|
|
246
|
+
await client.main_frame()
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Human-in-the-Loop Approval
|
|
250
|
+
|
|
251
|
+
Handle approval requests for sensitive actions:
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
def handle_approval(params):
|
|
255
|
+
print(f"Approval needed: {params.rule}")
|
|
256
|
+
print(f"Action: {params.original_request}")
|
|
257
|
+
# In a real app, show UI to user
|
|
258
|
+
return "approve"
|
|
259
|
+
|
|
260
|
+
client.on_approval_required(handle_approval)
|
|
261
|
+
|
|
262
|
+
# Respond to approval request
|
|
263
|
+
await client.respond_to_approval(
|
|
264
|
+
request_id="...",
|
|
265
|
+
decision="approve", # or "deny", "approve-session"
|
|
266
|
+
reason="User approved the action",
|
|
267
|
+
)
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Error Handling
|
|
271
|
+
|
|
272
|
+
```python
|
|
273
|
+
from browseragentprotocol import (
|
|
274
|
+
BAPError,
|
|
275
|
+
BAPTimeoutError,
|
|
276
|
+
BAPElementNotFoundError,
|
|
277
|
+
BAPApprovalDeniedError,
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
try:
|
|
281
|
+
await client.click(role("button", "Missing"))
|
|
282
|
+
except BAPTimeoutError as e:
|
|
283
|
+
print(f"Timeout: {e.message}")
|
|
284
|
+
if e.retryable:
|
|
285
|
+
# Retry the operation
|
|
286
|
+
pass
|
|
287
|
+
except BAPElementNotFoundError as e:
|
|
288
|
+
print(f"Element not found: {e.details}")
|
|
289
|
+
except BAPApprovalDeniedError as e:
|
|
290
|
+
print(f"Action denied: {e.message}")
|
|
291
|
+
except BAPError as e:
|
|
292
|
+
print(f"Error {e.code}: {e.message}")
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Requirements
|
|
296
|
+
|
|
297
|
+
- Python 3.10+
|
|
298
|
+
- aiohttp >= 3.9.0
|
|
299
|
+
- pydantic >= 2.0.0
|
|
300
|
+
- anyio >= 4.0.0
|
|
301
|
+
- httpx >= 0.27.0
|
|
302
|
+
- httpx-sse >= 0.4.0
|
|
303
|
+
|
|
304
|
+
## License
|
|
305
|
+
|
|
306
|
+
Apache-2.0
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
browseragentprotocol/__init__.py,sha256=PWyVlexYL0Q4Ox8DGvCYndEl2MN-ZknsSwUINXL5bQY,7669
|
|
2
|
+
browseragentprotocol/cli.py,sha256=TpYhJKrz1ScvlHHfXvWs41AIm2yqXMTG1ATwviTmKq8,4414
|
|
3
|
+
browseragentprotocol/client.py,sha256=m39pP3mGF8DvEVC0qEe3ao2kc_0eQWqOB1Airvk1c1c,51669
|
|
4
|
+
browseragentprotocol/context.py,sha256=7RWsX3VhoNWG3qN4DWCqTRfHaMy8SlbJ_nUOGnZJvzE,3666
|
|
5
|
+
browseragentprotocol/errors.py,sha256=35U5zqDB9RjYRrS3iBfNxENxyJW66Y2eKtHMRag103s,19235
|
|
6
|
+
browseragentprotocol/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
browseragentprotocol/sse.py,sha256=FrrXvGhWDOhFGNy9HW-tKPKrpyg-GXcWWqV94dAvCVA,4567
|
|
8
|
+
browseragentprotocol/sync_client.py,sha256=xsgLTCjl1msEbTOUqnpax2inz-5DXdkZ0-FlCZH-S-o,20652
|
|
9
|
+
browseragentprotocol/transport.py,sha256=fyzIsBXozFV3tmz3Mmxjghg04xugBwC3-wFdm_MqW6U,5934
|
|
10
|
+
browseragentprotocol/types/__init__.py,sha256=FUc9GMiQ8dH1aHx1GlS_9HLbQrkXyyv1ySrW9u63FC4,5336
|
|
11
|
+
browseragentprotocol/types/agent.py,sha256=VjUO_MHW5Xt_7DgG4QgX7_LESGp2YAuDQV0Wdm3M3D0,10681
|
|
12
|
+
browseragentprotocol/types/common.py,sha256=umeZZFUPEDv69zHAusB7AY25DH_xBuQm78tpLfmk_PE,6853
|
|
13
|
+
browseragentprotocol/types/events.py,sha256=eL5zKKSWMX3-fFgnOjQrf20iYm_H1jaIP2qkd4loSP0,4665
|
|
14
|
+
browseragentprotocol/types/methods.py,sha256=cnMPL7VVMaJ9t6xr4_CmDULMyDlNle3bIucwVxZn9Aw,9494
|
|
15
|
+
browseragentprotocol/types/protocol.py,sha256=oHhtgbZAL-b-AfNlCz_iEZu6ZQ9I88_2aV8_3R8WC4E,6085
|
|
16
|
+
browseragentprotocol/types/selectors.py,sha256=5Ytq3xDBkgB85aYDsEDykFi7YygahmPChrknC8EhJ5E,6044
|
|
17
|
+
browser_agent_protocol-0.1.0a1.dist-info/METADATA,sha256=ztJZ2unzKZCUTEnKfX5zMJjfzFo7jRURowHnMq4_VKY,8143
|
|
18
|
+
browser_agent_protocol-0.1.0a1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
19
|
+
browser_agent_protocol-0.1.0a1.dist-info/entry_points.txt,sha256=MK4MD5NAXwu4DzlZ42y4kTi8RJKiUEawPdCvEGUjYYs,54
|
|
20
|
+
browser_agent_protocol-0.1.0a1.dist-info/RECORD,,
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Browser Agent Protocol (BAP) Python SDK
|
|
3
|
+
|
|
4
|
+
A Python client for controlling browsers via the Browser Agent Protocol.
|
|
5
|
+
Designed for AI agents and automation tasks, with both async and sync APIs.
|
|
6
|
+
|
|
7
|
+
Example (async context manager):
|
|
8
|
+
```python
|
|
9
|
+
from browseragentprotocol import BAPClient, role
|
|
10
|
+
|
|
11
|
+
async def main():
|
|
12
|
+
async with BAPClient("ws://localhost:9222") as client:
|
|
13
|
+
await client.launch(browser="chromium", headless=True)
|
|
14
|
+
await client.create_page(url="https://example.com")
|
|
15
|
+
|
|
16
|
+
await client.click(role("button", "Submit"))
|
|
17
|
+
screenshot = await client.screenshot()
|
|
18
|
+
|
|
19
|
+
import asyncio
|
|
20
|
+
asyncio.run(main())
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Example (high-level session helper):
|
|
24
|
+
```python
|
|
25
|
+
from browseragentprotocol.context import bap_session
|
|
26
|
+
|
|
27
|
+
async with bap_session(
|
|
28
|
+
"ws://localhost:9222",
|
|
29
|
+
start_url="https://example.com"
|
|
30
|
+
) as client:
|
|
31
|
+
await client.click(role("button", "Accept"))
|
|
32
|
+
content = await client.content()
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
For synchronous usage:
|
|
36
|
+
```python
|
|
37
|
+
from browseragentprotocol import BAPClientSync, role
|
|
38
|
+
|
|
39
|
+
with BAPClientSync("ws://localhost:9222") as client:
|
|
40
|
+
client.launch(browser="chromium", headless=True)
|
|
41
|
+
client.create_page(url="https://example.com")
|
|
42
|
+
|
|
43
|
+
client.click(role("button", "Submit"))
|
|
44
|
+
screenshot = client.screenshot()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
CLI usage:
|
|
48
|
+
```bash
|
|
49
|
+
# Test connection
|
|
50
|
+
bap connect ws://localhost:9222
|
|
51
|
+
|
|
52
|
+
# Get server info
|
|
53
|
+
bap info ws://localhost:9222 --json
|
|
54
|
+
```
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
__version__ = "0.1.0a1"
|
|
58
|
+
|
|
59
|
+
# Main client classes
|
|
60
|
+
from browseragentprotocol.client import BAPClient
|
|
61
|
+
from browseragentprotocol.sync_client import BAPClientSync
|
|
62
|
+
|
|
63
|
+
# Transport layers
|
|
64
|
+
from browseragentprotocol.transport import WebSocketTransport
|
|
65
|
+
from browseragentprotocol.sse import SSETransport
|
|
66
|
+
|
|
67
|
+
# Context managers
|
|
68
|
+
from browseragentprotocol.context import bap_client, bap_session
|
|
69
|
+
|
|
70
|
+
# Errors
|
|
71
|
+
from browseragentprotocol.errors import (
|
|
72
|
+
BAPError,
|
|
73
|
+
BAPConnectionError,
|
|
74
|
+
BAPParseError,
|
|
75
|
+
BAPInvalidRequestError,
|
|
76
|
+
BAPMethodNotFoundError,
|
|
77
|
+
BAPInvalidParamsError,
|
|
78
|
+
BAPNotInitializedError,
|
|
79
|
+
BAPAlreadyInitializedError,
|
|
80
|
+
BAPBrowserNotLaunchedError,
|
|
81
|
+
BAPPageNotFoundError,
|
|
82
|
+
BAPElementNotFoundError,
|
|
83
|
+
BAPElementNotVisibleError,
|
|
84
|
+
BAPElementNotEnabledError,
|
|
85
|
+
BAPSelectorAmbiguousError,
|
|
86
|
+
BAPNavigationError,
|
|
87
|
+
BAPTimeoutError,
|
|
88
|
+
BAPActionError,
|
|
89
|
+
BAPTargetClosedError,
|
|
90
|
+
BAPExecutionContextDestroyedError,
|
|
91
|
+
BAPContextNotFoundError,
|
|
92
|
+
BAPResourceLimitExceededError,
|
|
93
|
+
BAPApprovalDeniedError,
|
|
94
|
+
BAPApprovalTimeoutError,
|
|
95
|
+
BAPApprovalRequiredError,
|
|
96
|
+
BAPFrameNotFoundError,
|
|
97
|
+
BAPDomainNotAllowedError,
|
|
98
|
+
BAPStreamNotFoundError,
|
|
99
|
+
BAPStreamCancelledError,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# Selector factory functions
|
|
103
|
+
from browseragentprotocol.types.selectors import (
|
|
104
|
+
css,
|
|
105
|
+
xpath,
|
|
106
|
+
role,
|
|
107
|
+
text,
|
|
108
|
+
label,
|
|
109
|
+
placeholder,
|
|
110
|
+
test_id,
|
|
111
|
+
semantic,
|
|
112
|
+
coords,
|
|
113
|
+
ref,
|
|
114
|
+
# Selector types
|
|
115
|
+
AriaRole,
|
|
116
|
+
BAPSelector,
|
|
117
|
+
CSSSelector,
|
|
118
|
+
XPathSelector,
|
|
119
|
+
RoleSelector,
|
|
120
|
+
TextSelector,
|
|
121
|
+
LabelSelector,
|
|
122
|
+
PlaceholderSelector,
|
|
123
|
+
TestIdSelector,
|
|
124
|
+
SemanticSelector,
|
|
125
|
+
CoordinatesSelector,
|
|
126
|
+
RefSelector,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
# Protocol types
|
|
130
|
+
from browseragentprotocol.types.protocol import (
|
|
131
|
+
BAP_VERSION,
|
|
132
|
+
ErrorCodes,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Common types
|
|
136
|
+
from browseragentprotocol.types.common import (
|
|
137
|
+
AccessibilityNode,
|
|
138
|
+
ActionOptions,
|
|
139
|
+
BoundingBox,
|
|
140
|
+
ClickOptions,
|
|
141
|
+
ContentFormat,
|
|
142
|
+
Cookie,
|
|
143
|
+
Page,
|
|
144
|
+
PageStatus,
|
|
145
|
+
ScreenshotFormat,
|
|
146
|
+
ScreenshotOptions,
|
|
147
|
+
ScrollDirection,
|
|
148
|
+
ScrollOptions,
|
|
149
|
+
StorageState,
|
|
150
|
+
TypeOptions,
|
|
151
|
+
Viewport,
|
|
152
|
+
WaitUntilState,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
# Agent types
|
|
156
|
+
from browseragentprotocol.types.agent import (
|
|
157
|
+
ActionHint,
|
|
158
|
+
AgentActParams,
|
|
159
|
+
AgentActResult,
|
|
160
|
+
AgentExtractParams,
|
|
161
|
+
AgentExtractResult,
|
|
162
|
+
AgentObserveParams,
|
|
163
|
+
AgentObserveResult,
|
|
164
|
+
AnnotationOptions,
|
|
165
|
+
ExecutionStep,
|
|
166
|
+
InteractiveElement,
|
|
167
|
+
StepCondition,
|
|
168
|
+
StepErrorHandling,
|
|
169
|
+
StepResult,
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
# Method types
|
|
173
|
+
from browseragentprotocol.types.methods import (
|
|
174
|
+
ApprovalRequiredParams,
|
|
175
|
+
ApprovalRespondParams,
|
|
176
|
+
BrowserLaunchParams,
|
|
177
|
+
BrowserLaunchResult,
|
|
178
|
+
ContextCreateParams,
|
|
179
|
+
ContextCreateResult,
|
|
180
|
+
ContextListResult,
|
|
181
|
+
FrameInfo,
|
|
182
|
+
FrameListResult,
|
|
183
|
+
FrameSwitchParams,
|
|
184
|
+
FrameSwitchResult,
|
|
185
|
+
InitializeResult,
|
|
186
|
+
ObserveAccessibilityResult,
|
|
187
|
+
ObserveAriaSnapshotResult,
|
|
188
|
+
ObserveContentResult,
|
|
189
|
+
ObserveDOMResult,
|
|
190
|
+
ObserveElementResult,
|
|
191
|
+
ObservePDFResult,
|
|
192
|
+
ObserveScreenshotResult,
|
|
193
|
+
PageNavigateResult,
|
|
194
|
+
StreamChunkParams,
|
|
195
|
+
StreamEndParams,
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
# Event types
|
|
199
|
+
from browseragentprotocol.types.events import (
|
|
200
|
+
ConsoleEvent,
|
|
201
|
+
DialogEvent,
|
|
202
|
+
DownloadEvent,
|
|
203
|
+
NetworkEvent,
|
|
204
|
+
PageEvent,
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
__all__ = [
|
|
208
|
+
# Version
|
|
209
|
+
"__version__",
|
|
210
|
+
# Main classes
|
|
211
|
+
"BAPClient",
|
|
212
|
+
"BAPClientSync",
|
|
213
|
+
# Transport layers
|
|
214
|
+
"WebSocketTransport",
|
|
215
|
+
"SSETransport",
|
|
216
|
+
# Context managers
|
|
217
|
+
"bap_client",
|
|
218
|
+
"bap_session",
|
|
219
|
+
# Errors
|
|
220
|
+
"BAPError",
|
|
221
|
+
"BAPConnectionError",
|
|
222
|
+
"BAPParseError",
|
|
223
|
+
"BAPInvalidRequestError",
|
|
224
|
+
"BAPMethodNotFoundError",
|
|
225
|
+
"BAPInvalidParamsError",
|
|
226
|
+
"BAPNotInitializedError",
|
|
227
|
+
"BAPAlreadyInitializedError",
|
|
228
|
+
"BAPBrowserNotLaunchedError",
|
|
229
|
+
"BAPPageNotFoundError",
|
|
230
|
+
"BAPElementNotFoundError",
|
|
231
|
+
"BAPElementNotVisibleError",
|
|
232
|
+
"BAPElementNotEnabledError",
|
|
233
|
+
"BAPSelectorAmbiguousError",
|
|
234
|
+
"BAPNavigationError",
|
|
235
|
+
"BAPTimeoutError",
|
|
236
|
+
"BAPActionError",
|
|
237
|
+
"BAPTargetClosedError",
|
|
238
|
+
"BAPExecutionContextDestroyedError",
|
|
239
|
+
"BAPContextNotFoundError",
|
|
240
|
+
"BAPResourceLimitExceededError",
|
|
241
|
+
"BAPApprovalDeniedError",
|
|
242
|
+
"BAPApprovalTimeoutError",
|
|
243
|
+
"BAPApprovalRequiredError",
|
|
244
|
+
"BAPFrameNotFoundError",
|
|
245
|
+
"BAPDomainNotAllowedError",
|
|
246
|
+
"BAPStreamNotFoundError",
|
|
247
|
+
"BAPStreamCancelledError",
|
|
248
|
+
# Selector factories
|
|
249
|
+
"css",
|
|
250
|
+
"xpath",
|
|
251
|
+
"role",
|
|
252
|
+
"text",
|
|
253
|
+
"label",
|
|
254
|
+
"placeholder",
|
|
255
|
+
"test_id",
|
|
256
|
+
"semantic",
|
|
257
|
+
"coords",
|
|
258
|
+
"ref",
|
|
259
|
+
# Selector types
|
|
260
|
+
"AriaRole",
|
|
261
|
+
"BAPSelector",
|
|
262
|
+
"CSSSelector",
|
|
263
|
+
"XPathSelector",
|
|
264
|
+
"RoleSelector",
|
|
265
|
+
"TextSelector",
|
|
266
|
+
"LabelSelector",
|
|
267
|
+
"PlaceholderSelector",
|
|
268
|
+
"TestIdSelector",
|
|
269
|
+
"SemanticSelector",
|
|
270
|
+
"CoordinatesSelector",
|
|
271
|
+
"RefSelector",
|
|
272
|
+
# Protocol
|
|
273
|
+
"BAP_VERSION",
|
|
274
|
+
"ErrorCodes",
|
|
275
|
+
# Common types
|
|
276
|
+
"AccessibilityNode",
|
|
277
|
+
"ActionOptions",
|
|
278
|
+
"BoundingBox",
|
|
279
|
+
"ClickOptions",
|
|
280
|
+
"ContentFormat",
|
|
281
|
+
"Cookie",
|
|
282
|
+
"Page",
|
|
283
|
+
"PageStatus",
|
|
284
|
+
"ScreenshotFormat",
|
|
285
|
+
"ScreenshotOptions",
|
|
286
|
+
"ScrollDirection",
|
|
287
|
+
"ScrollOptions",
|
|
288
|
+
"StorageState",
|
|
289
|
+
"TypeOptions",
|
|
290
|
+
"Viewport",
|
|
291
|
+
"WaitUntilState",
|
|
292
|
+
# Agent types
|
|
293
|
+
"ActionHint",
|
|
294
|
+
"AgentActParams",
|
|
295
|
+
"AgentActResult",
|
|
296
|
+
"AgentExtractParams",
|
|
297
|
+
"AgentExtractResult",
|
|
298
|
+
"AgentObserveParams",
|
|
299
|
+
"AgentObserveResult",
|
|
300
|
+
"AnnotationOptions",
|
|
301
|
+
"ExecutionStep",
|
|
302
|
+
"InteractiveElement",
|
|
303
|
+
"StepCondition",
|
|
304
|
+
"StepErrorHandling",
|
|
305
|
+
"StepResult",
|
|
306
|
+
# Method types
|
|
307
|
+
"ApprovalRequiredParams",
|
|
308
|
+
"ApprovalRespondParams",
|
|
309
|
+
"BrowserLaunchParams",
|
|
310
|
+
"BrowserLaunchResult",
|
|
311
|
+
"ContextCreateParams",
|
|
312
|
+
"ContextCreateResult",
|
|
313
|
+
"ContextListResult",
|
|
314
|
+
"FrameInfo",
|
|
315
|
+
"FrameListResult",
|
|
316
|
+
"FrameSwitchParams",
|
|
317
|
+
"FrameSwitchResult",
|
|
318
|
+
"InitializeResult",
|
|
319
|
+
"ObserveAccessibilityResult",
|
|
320
|
+
"ObserveAriaSnapshotResult",
|
|
321
|
+
"ObserveContentResult",
|
|
322
|
+
"ObserveDOMResult",
|
|
323
|
+
"ObserveElementResult",
|
|
324
|
+
"ObservePDFResult",
|
|
325
|
+
"ObserveScreenshotResult",
|
|
326
|
+
"PageNavigateResult",
|
|
327
|
+
"StreamChunkParams",
|
|
328
|
+
"StreamEndParams",
|
|
329
|
+
# Event types
|
|
330
|
+
"ConsoleEvent",
|
|
331
|
+
"DialogEvent",
|
|
332
|
+
"DownloadEvent",
|
|
333
|
+
"NetworkEvent",
|
|
334
|
+
"PageEvent",
|
|
335
|
+
]
|