agentrun-inner-test 0.0.62__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.

Potentially problematic release.


This version of agentrun-inner-test might be problematic. Click here for more details.

Files changed (154) hide show
  1. agentrun/__init__.py +358 -0
  2. agentrun/agent_runtime/__client_async_template.py +466 -0
  3. agentrun/agent_runtime/__endpoint_async_template.py +345 -0
  4. agentrun/agent_runtime/__init__.py +53 -0
  5. agentrun/agent_runtime/__runtime_async_template.py +477 -0
  6. agentrun/agent_runtime/api/__data_async_template.py +58 -0
  7. agentrun/agent_runtime/api/__init__.py +6 -0
  8. agentrun/agent_runtime/api/control.py +1362 -0
  9. agentrun/agent_runtime/api/data.py +98 -0
  10. agentrun/agent_runtime/client.py +868 -0
  11. agentrun/agent_runtime/endpoint.py +649 -0
  12. agentrun/agent_runtime/model.py +362 -0
  13. agentrun/agent_runtime/runtime.py +904 -0
  14. agentrun/credential/__client_async_template.py +177 -0
  15. agentrun/credential/__credential_async_template.py +216 -0
  16. agentrun/credential/__init__.py +28 -0
  17. agentrun/credential/api/__init__.py +5 -0
  18. agentrun/credential/api/control.py +606 -0
  19. agentrun/credential/client.py +319 -0
  20. agentrun/credential/credential.py +381 -0
  21. agentrun/credential/model.py +248 -0
  22. agentrun/integration/__init__.py +21 -0
  23. agentrun/integration/agentscope/__init__.py +13 -0
  24. agentrun/integration/agentscope/adapter.py +17 -0
  25. agentrun/integration/agentscope/builtin.py +88 -0
  26. agentrun/integration/agentscope/message_adapter.py +185 -0
  27. agentrun/integration/agentscope/model_adapter.py +60 -0
  28. agentrun/integration/agentscope/tool_adapter.py +59 -0
  29. agentrun/integration/builtin/__init__.py +18 -0
  30. agentrun/integration/builtin/knowledgebase.py +137 -0
  31. agentrun/integration/builtin/model.py +93 -0
  32. agentrun/integration/builtin/sandbox.py +1234 -0
  33. agentrun/integration/builtin/toolset.py +47 -0
  34. agentrun/integration/crewai/__init__.py +13 -0
  35. agentrun/integration/crewai/adapter.py +9 -0
  36. agentrun/integration/crewai/builtin.py +88 -0
  37. agentrun/integration/crewai/model_adapter.py +31 -0
  38. agentrun/integration/crewai/tool_adapter.py +26 -0
  39. agentrun/integration/google_adk/__init__.py +13 -0
  40. agentrun/integration/google_adk/adapter.py +15 -0
  41. agentrun/integration/google_adk/builtin.py +88 -0
  42. agentrun/integration/google_adk/message_adapter.py +144 -0
  43. agentrun/integration/google_adk/model_adapter.py +46 -0
  44. agentrun/integration/google_adk/tool_adapter.py +235 -0
  45. agentrun/integration/langchain/__init__.py +31 -0
  46. agentrun/integration/langchain/adapter.py +15 -0
  47. agentrun/integration/langchain/builtin.py +94 -0
  48. agentrun/integration/langchain/message_adapter.py +141 -0
  49. agentrun/integration/langchain/model_adapter.py +37 -0
  50. agentrun/integration/langchain/tool_adapter.py +50 -0
  51. agentrun/integration/langgraph/__init__.py +36 -0
  52. agentrun/integration/langgraph/adapter.py +20 -0
  53. agentrun/integration/langgraph/agent_converter.py +1073 -0
  54. agentrun/integration/langgraph/builtin.py +88 -0
  55. agentrun/integration/pydantic_ai/__init__.py +13 -0
  56. agentrun/integration/pydantic_ai/adapter.py +13 -0
  57. agentrun/integration/pydantic_ai/builtin.py +88 -0
  58. agentrun/integration/pydantic_ai/model_adapter.py +44 -0
  59. agentrun/integration/pydantic_ai/tool_adapter.py +19 -0
  60. agentrun/integration/utils/__init__.py +112 -0
  61. agentrun/integration/utils/adapter.py +560 -0
  62. agentrun/integration/utils/canonical.py +164 -0
  63. agentrun/integration/utils/converter.py +134 -0
  64. agentrun/integration/utils/model.py +110 -0
  65. agentrun/integration/utils/tool.py +1759 -0
  66. agentrun/knowledgebase/__client_async_template.py +173 -0
  67. agentrun/knowledgebase/__init__.py +53 -0
  68. agentrun/knowledgebase/__knowledgebase_async_template.py +438 -0
  69. agentrun/knowledgebase/api/__data_async_template.py +414 -0
  70. agentrun/knowledgebase/api/__init__.py +19 -0
  71. agentrun/knowledgebase/api/control.py +606 -0
  72. agentrun/knowledgebase/api/data.py +624 -0
  73. agentrun/knowledgebase/client.py +311 -0
  74. agentrun/knowledgebase/knowledgebase.py +748 -0
  75. agentrun/knowledgebase/model.py +270 -0
  76. agentrun/memory_collection/__client_async_template.py +178 -0
  77. agentrun/memory_collection/__init__.py +37 -0
  78. agentrun/memory_collection/__memory_collection_async_template.py +457 -0
  79. agentrun/memory_collection/api/__init__.py +5 -0
  80. agentrun/memory_collection/api/control.py +610 -0
  81. agentrun/memory_collection/client.py +323 -0
  82. agentrun/memory_collection/memory_collection.py +844 -0
  83. agentrun/memory_collection/model.py +162 -0
  84. agentrun/model/__client_async_template.py +357 -0
  85. agentrun/model/__init__.py +57 -0
  86. agentrun/model/__model_proxy_async_template.py +270 -0
  87. agentrun/model/__model_service_async_template.py +267 -0
  88. agentrun/model/api/__init__.py +6 -0
  89. agentrun/model/api/control.py +1173 -0
  90. agentrun/model/api/data.py +196 -0
  91. agentrun/model/client.py +674 -0
  92. agentrun/model/model.py +235 -0
  93. agentrun/model/model_proxy.py +439 -0
  94. agentrun/model/model_service.py +438 -0
  95. agentrun/sandbox/__aio_sandbox_async_template.py +523 -0
  96. agentrun/sandbox/__browser_sandbox_async_template.py +110 -0
  97. agentrun/sandbox/__client_async_template.py +491 -0
  98. agentrun/sandbox/__code_interpreter_sandbox_async_template.py +463 -0
  99. agentrun/sandbox/__init__.py +69 -0
  100. agentrun/sandbox/__sandbox_async_template.py +463 -0
  101. agentrun/sandbox/__template_async_template.py +152 -0
  102. agentrun/sandbox/aio_sandbox.py +912 -0
  103. agentrun/sandbox/api/__aio_data_async_template.py +335 -0
  104. agentrun/sandbox/api/__browser_data_async_template.py +140 -0
  105. agentrun/sandbox/api/__code_interpreter_data_async_template.py +206 -0
  106. agentrun/sandbox/api/__init__.py +19 -0
  107. agentrun/sandbox/api/__sandbox_data_async_template.py +107 -0
  108. agentrun/sandbox/api/aio_data.py +551 -0
  109. agentrun/sandbox/api/browser_data.py +172 -0
  110. agentrun/sandbox/api/code_interpreter_data.py +396 -0
  111. agentrun/sandbox/api/control.py +1051 -0
  112. agentrun/sandbox/api/playwright_async.py +492 -0
  113. agentrun/sandbox/api/playwright_sync.py +492 -0
  114. agentrun/sandbox/api/sandbox_data.py +154 -0
  115. agentrun/sandbox/browser_sandbox.py +185 -0
  116. agentrun/sandbox/client.py +925 -0
  117. agentrun/sandbox/code_interpreter_sandbox.py +823 -0
  118. agentrun/sandbox/model.py +384 -0
  119. agentrun/sandbox/sandbox.py +848 -0
  120. agentrun/sandbox/template.py +217 -0
  121. agentrun/server/__init__.py +191 -0
  122. agentrun/server/agui_normalizer.py +180 -0
  123. agentrun/server/agui_protocol.py +797 -0
  124. agentrun/server/invoker.py +309 -0
  125. agentrun/server/model.py +427 -0
  126. agentrun/server/openai_protocol.py +535 -0
  127. agentrun/server/protocol.py +140 -0
  128. agentrun/server/server.py +208 -0
  129. agentrun/toolset/__client_async_template.py +62 -0
  130. agentrun/toolset/__init__.py +51 -0
  131. agentrun/toolset/__toolset_async_template.py +204 -0
  132. agentrun/toolset/api/__init__.py +17 -0
  133. agentrun/toolset/api/control.py +262 -0
  134. agentrun/toolset/api/mcp.py +100 -0
  135. agentrun/toolset/api/openapi.py +1251 -0
  136. agentrun/toolset/client.py +102 -0
  137. agentrun/toolset/model.py +321 -0
  138. agentrun/toolset/toolset.py +271 -0
  139. agentrun/utils/__data_api_async_template.py +721 -0
  140. agentrun/utils/__init__.py +5 -0
  141. agentrun/utils/__resource_async_template.py +158 -0
  142. agentrun/utils/config.py +270 -0
  143. agentrun/utils/control_api.py +105 -0
  144. agentrun/utils/data_api.py +1121 -0
  145. agentrun/utils/exception.py +151 -0
  146. agentrun/utils/helper.py +108 -0
  147. agentrun/utils/log.py +77 -0
  148. agentrun/utils/model.py +168 -0
  149. agentrun/utils/resource.py +291 -0
  150. agentrun_inner_test-0.0.62.dist-info/METADATA +265 -0
  151. agentrun_inner_test-0.0.62.dist-info/RECORD +154 -0
  152. agentrun_inner_test-0.0.62.dist-info/WHEEL +5 -0
  153. agentrun_inner_test-0.0.62.dist-info/licenses/LICENSE +201 -0
  154. agentrun_inner_test-0.0.62.dist-info/top_level.txt +1 -0
@@ -0,0 +1,492 @@
1
+ """Playwright异步API封装 / Playwright Async API Wrapper
2
+
3
+ 提供Playwright的异步API封装,用于浏览器沙箱操作。
4
+ Provides async API wrapper for Playwright, used for browser sandbox operations.
5
+ """
6
+
7
+ from pathlib import Path
8
+ from typing import Any, Dict, List, Literal, Optional, Sequence, Union
9
+
10
+ from playwright.async_api import (
11
+ async_playwright,
12
+ Browser,
13
+ BrowserContext,
14
+ FloatRect,
15
+ Locator,
16
+ Page,
17
+ Playwright,
18
+ Position,
19
+ Response,
20
+ )
21
+
22
+
23
+ class BrowserPlaywrightAsync:
24
+ """A small helper wrapper around Playwright's Async API.
25
+
26
+ This class connects to an existing Chromium instance over CDP and exposes a set
27
+ of common page operations. Internally it lazily ensures a `Browser`,
28
+ `BrowserContext`, and `Page` and keeps references to reuse them across calls.
29
+
30
+ Notes
31
+ -----
32
+ - Connection is established via CDP using the given `url`.
33
+ - If `auto_close_browser`/`auto_close_page` are enabled, `close()` will attempt
34
+ to close the browser/page respectively.
35
+ - Methods that act on the page automatically bring the page to the front.
36
+ """
37
+
38
+ def __init__(
39
+ self,
40
+ url: str,
41
+ browser_type: str = "chrome",
42
+ auto_close_browser: bool = False,
43
+ auto_close_page: bool = False,
44
+ headers: Optional[Dict[str, str]] = None,
45
+ ):
46
+ self.url = url
47
+ self.browser_type = browser_type
48
+ self.auto_close_browser = auto_close_browser
49
+ self.auto_close_page = auto_close_page
50
+ self.headers = headers
51
+
52
+ self._playwright = async_playwright()
53
+ self._playwright_instance: Optional[Playwright] = None
54
+ self._browser: Optional[Browser] = None
55
+ self._context: Optional[BrowserContext] = None
56
+ self._page: Optional[Page] = None
57
+
58
+ async def open(self) -> "BrowserPlaywrightAsync":
59
+ """Establish a connection to the remote browser if not already connected.
60
+
61
+ Returns
62
+ -------
63
+ BrowserPlaywrightAsync
64
+ The current instance for fluent chaining.
65
+ """
66
+ if self._browser:
67
+ return self
68
+
69
+ self._playwright_instance = await self._playwright.start()
70
+ self._browser = (
71
+ await self._playwright_instance.chromium.connect_over_cdp(
72
+ self.url, headers=self.headers
73
+ )
74
+ )
75
+
76
+ return self
77
+
78
+ async def close(self) -> None:
79
+ """Close held resources according to the auto-close flags.
80
+
81
+ Closes page and/or browser if the corresponding auto-close flags are set
82
+ and stops the Playwright driver when present.
83
+ """
84
+ if self.auto_close_page and self._page:
85
+ await self._page.close()
86
+
87
+ if self.auto_close_browser and self._browser:
88
+ await self._browser.close()
89
+
90
+ if self._playwright_instance:
91
+ await self._playwright_instance.stop()
92
+
93
+ async def __aenter__(self) -> "BrowserPlaywrightAsync":
94
+ """Enter context by ensuring the connection is open.
95
+
96
+ Returns
97
+ -------
98
+ BrowserPlaywrightAsync
99
+ The current instance.
100
+ """
101
+ return await self.open()
102
+
103
+ async def __aexit__(self, *args: Any) -> None:
104
+ """Exit context by closing resources based on auto-close flags."""
105
+ await self.close()
106
+
107
+ async def ensure_browser(self) -> Browser:
108
+ """Ensure a `Browser` instance is available.
109
+
110
+ Returns
111
+ -------
112
+ Browser
113
+ A connected Playwright `Browser` instance.
114
+ """
115
+ if self._browser:
116
+ return self._browser
117
+
118
+ await self.open()
119
+
120
+ assert self._browser is not None
121
+
122
+ return self._browser
123
+
124
+ async def ensure_context(self) -> BrowserContext:
125
+ """Ensure a `BrowserContext` is available, creating one if necessary.
126
+
127
+ Returns
128
+ -------
129
+ BrowserContext
130
+ The ensured `BrowserContext`.
131
+ """
132
+ browser = await self.ensure_browser()
133
+
134
+ if self._context:
135
+ return self._context
136
+
137
+ if len(browser.contexts) > 0:
138
+ self._context = browser.contexts[0]
139
+ else:
140
+ self._context = await browser.new_context()
141
+
142
+ return self._context
143
+
144
+ async def ensure_page(self) -> Page:
145
+ """Ensure a `Page` is available in the current context.
146
+
147
+ Returns
148
+ -------
149
+ Page
150
+ The ensured `Page` which is brought to the front.
151
+ """
152
+ ctx = await self.ensure_context()
153
+
154
+ if self._page:
155
+ await self._page.bring_to_front()
156
+ return self._page
157
+
158
+ if len(ctx.pages) > 0:
159
+ self._page = ctx.pages[0]
160
+ else:
161
+ self._page = await ctx.new_page()
162
+
163
+ await self._page.bring_to_front()
164
+ return self._page
165
+
166
+ async def _use_page(self, page: Page) -> Page:
167
+ """Set the active page and context.
168
+
169
+ Parameters
170
+ ----------
171
+ page : Page
172
+ The page to make active.
173
+
174
+ Returns
175
+ -------
176
+ Page
177
+ The provided page.
178
+ """
179
+ await page.bring_to_front()
180
+ self._page = page
181
+ self._context = page.context
182
+ return self._page
183
+
184
+ async def list_pages(self) -> List[Page]:
185
+ """List all pages across all contexts in the connected browser."""
186
+ pages: List[Page] = []
187
+
188
+ browser = await self.ensure_browser()
189
+ for context in browser.contexts:
190
+ for page in context.pages:
191
+ pages.append(page)
192
+
193
+ return pages
194
+
195
+ async def new_page(self) -> Page:
196
+ """Create and switch to a new page in the ensured context."""
197
+ context = await self.ensure_context()
198
+ page = await context.new_page()
199
+ return await self._use_page(page)
200
+
201
+ async def select_tab(self, index: int) -> Page:
202
+ """Select a page by index across all open tabs.
203
+
204
+ Parameters
205
+ ----------
206
+ index : int
207
+ Zero-based page index.
208
+
209
+ Returns
210
+ -------
211
+ Page
212
+ The selected page.
213
+
214
+ Raises
215
+ ------
216
+ IndexError
217
+ If the index is out of bounds.
218
+ """
219
+ pages = await self.list_pages()
220
+ if 0 <= index < len(pages):
221
+ return await self._use_page(pages[index])
222
+ else:
223
+ raise IndexError("Tab index out of range")
224
+
225
+ async def goto(
226
+ self,
227
+ url: str,
228
+ timeout: Optional[float] = None,
229
+ wait_until: Optional[
230
+ Literal["commit", "domcontentloaded", "load", "networkidle"]
231
+ ] = None,
232
+ referer: Optional[str] = None,
233
+ ) -> Optional[Response]:
234
+ """Navigate to a URL on the active page.
235
+
236
+ Returns
237
+ -------
238
+ Optional[Response]
239
+ The main resource response if available; otherwise `None`.
240
+ """
241
+ page = await self.ensure_page()
242
+ return await page.goto(
243
+ url, timeout=timeout, wait_until=wait_until, referer=referer
244
+ )
245
+
246
+ async def click(
247
+ self,
248
+ selector: str,
249
+ modifiers: Optional[
250
+ Sequence[
251
+ Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]
252
+ ]
253
+ ] = None,
254
+ position: Optional[Position] = None,
255
+ delay: Optional[float] = None,
256
+ button: Optional[Literal["left", "middle", "right"]] = None,
257
+ click_count: Optional[int] = None,
258
+ timeout: Optional[float] = None,
259
+ force: Optional[bool] = None,
260
+ no_wait_after: Optional[bool] = None,
261
+ trial: Optional[bool] = None,
262
+ strict: Optional[bool] = None,
263
+ ) -> None:
264
+ """Click an element matching the selector on the active page."""
265
+ page = await self.ensure_page()
266
+ return await page.click(
267
+ selector,
268
+ modifiers=modifiers,
269
+ position=position,
270
+ delay=delay,
271
+ button=button,
272
+ click_count=click_count,
273
+ timeout=timeout,
274
+ force=force,
275
+ no_wait_after=no_wait_after,
276
+ trial=trial,
277
+ strict=strict,
278
+ )
279
+
280
+ async def drag_and_drop(
281
+ self,
282
+ source: str,
283
+ target: str,
284
+ source_position: Optional[Position] = None,
285
+ target_position: Optional[Position] = None,
286
+ force: Optional[bool] = None,
287
+ no_wait_after: Optional[bool] = None,
288
+ timeout: Optional[float] = None,
289
+ strict: Optional[bool] = None,
290
+ trial: Optional[bool] = None,
291
+ ) -> None:
292
+ """Alias for `drag` using Playwright's `drag_and_drop` under the hood."""
293
+ page = await self.ensure_page()
294
+ return await page.drag_and_drop(
295
+ source=source,
296
+ target=target,
297
+ source_position=source_position,
298
+ target_position=target_position,
299
+ force=force,
300
+ no_wait_after=no_wait_after,
301
+ timeout=timeout,
302
+ strict=strict,
303
+ trial=trial,
304
+ )
305
+
306
+ async def dblclick(
307
+ self,
308
+ selector: str,
309
+ modifiers: Optional[
310
+ Sequence[
311
+ Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]
312
+ ]
313
+ ] = None,
314
+ position: Optional[Position] = None,
315
+ delay: Optional[float] = None,
316
+ button: Optional[Literal["left", "middle", "right"]] = None,
317
+ timeout: Optional[float] = None,
318
+ force: Optional[bool] = None,
319
+ no_wait_after: Optional[bool] = None,
320
+ strict: Optional[bool] = None,
321
+ trial: Optional[bool] = None,
322
+ ) -> None:
323
+ """Double-click an element matching the selector on the active page."""
324
+ page = await self.ensure_page()
325
+ return await page.dblclick(
326
+ selector=selector,
327
+ modifiers=modifiers,
328
+ position=position,
329
+ delay=delay,
330
+ button=button,
331
+ timeout=timeout,
332
+ force=force,
333
+ no_wait_after=no_wait_after,
334
+ strict=strict,
335
+ trial=trial,
336
+ )
337
+
338
+ async def fill(
339
+ self,
340
+ selector: str,
341
+ value: str,
342
+ timeout: Optional[float] = None,
343
+ no_wait_after: Optional[bool] = None,
344
+ strict: Optional[bool] = None,
345
+ force: Optional[bool] = None,
346
+ ) -> None:
347
+ """Fill an input/textarea matched by selector with the provided value."""
348
+ page = await self.ensure_page()
349
+ return await page.fill(
350
+ selector=selector,
351
+ value=value,
352
+ timeout=timeout,
353
+ no_wait_after=no_wait_after,
354
+ strict=strict,
355
+ force=force,
356
+ )
357
+
358
+ async def hover(
359
+ self,
360
+ selector: str,
361
+ modifiers: Optional[
362
+ Sequence[
363
+ Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]
364
+ ]
365
+ ] = None,
366
+ position: Optional[Position] = None,
367
+ timeout: Optional[float] = None,
368
+ no_wait_after: Optional[bool] = None,
369
+ force: Optional[bool] = None,
370
+ strict: Optional[bool] = None,
371
+ trial: Optional[bool] = None,
372
+ ) -> None:
373
+ """Hover over the element matched by the selector."""
374
+ page = await self.ensure_page()
375
+ return await page.hover(
376
+ selector=selector,
377
+ modifiers=modifiers,
378
+ position=position,
379
+ timeout=timeout,
380
+ no_wait_after=no_wait_after,
381
+ force=force,
382
+ strict=strict,
383
+ trial=trial,
384
+ )
385
+
386
+ async def type(
387
+ self,
388
+ selector: str,
389
+ text: str,
390
+ delay: Optional[float] = None,
391
+ timeout: Optional[float] = None,
392
+ no_wait_after: Optional[bool] = None,
393
+ strict: Optional[bool] = None,
394
+ ) -> None:
395
+ """Type text into an element matched by the selector."""
396
+ page = await self.ensure_page()
397
+ return await page.type(
398
+ selector=selector,
399
+ text=text,
400
+ delay=delay,
401
+ timeout=timeout,
402
+ no_wait_after=no_wait_after,
403
+ strict=strict,
404
+ )
405
+
406
+ async def go_forward(
407
+ self,
408
+ timeout: Optional[float] = None,
409
+ wait_until: Optional[
410
+ Literal["commit", "domcontentloaded", "load", "networkidle"]
411
+ ] = None,
412
+ ) -> Optional[Response]:
413
+ """Go forward in the page history if possible."""
414
+ page = await self.ensure_page()
415
+ return await page.go_forward(timeout=timeout, wait_until=wait_until)
416
+
417
+ async def go_back(
418
+ self,
419
+ timeout: Optional[float] = None,
420
+ wait_until: Optional[
421
+ Literal["commit", "domcontentloaded", "load", "networkidle"]
422
+ ] = None,
423
+ ) -> Optional[Response]:
424
+ """Go back in the page history if possible."""
425
+ page = await self.ensure_page()
426
+ return await page.go_back(timeout=timeout, wait_until=wait_until)
427
+
428
+ async def evaluate(
429
+ self,
430
+ expression: str,
431
+ arg: Optional[Any] = None,
432
+ ) -> Any:
433
+ """Evaluate a JavaScript expression in the page context."""
434
+
435
+ page = await self.ensure_page()
436
+ return await page.evaluate(expression=expression, arg=arg)
437
+
438
+ async def wait(self, timeout: float) -> None:
439
+ """Wait for the given timeout in milliseconds."""
440
+ page = await self.ensure_page()
441
+ return await page.wait_for_timeout(timeout=timeout)
442
+
443
+ async def html_content(
444
+ self,
445
+ ) -> str:
446
+ """Get the current page's HTML content as a string."""
447
+ page = await self.ensure_page()
448
+ return await page.content()
449
+
450
+ async def screenshot(
451
+ self,
452
+ timeout: Optional[float] = None,
453
+ type: Optional[Literal["jpeg", "png"]] = None,
454
+ path: Union[Path, str, None] = None,
455
+ quality: Optional[int] = None,
456
+ omit_background: Optional[bool] = None,
457
+ full_page: Optional[bool] = None,
458
+ clip: Optional[FloatRect] = None,
459
+ animations: Optional[Literal["allow", "disabled"]] = None,
460
+ caret: Optional[Literal["hide", "initial"]] = None,
461
+ scale: Optional[Literal["css", "device"]] = None,
462
+ mask: Optional[Sequence[Locator]] = None,
463
+ mask_color: Optional[str] = None,
464
+ style: Optional[str] = None,
465
+ ) -> bytes:
466
+ """Capture a screenshot of the page.
467
+
468
+ Returns
469
+ -------
470
+ bytes
471
+ The image bytes of the screenshot.
472
+ """
473
+ page = await self.ensure_page()
474
+ return await page.screenshot(
475
+ timeout=timeout,
476
+ type=type,
477
+ path=path,
478
+ quality=quality,
479
+ omit_background=omit_background,
480
+ full_page=full_page,
481
+ clip=clip,
482
+ animations=animations,
483
+ caret=caret,
484
+ scale=scale,
485
+ mask=mask,
486
+ mask_color=mask_color,
487
+ style=style,
488
+ )
489
+
490
+ async def title(self) -> str:
491
+ page = await self.ensure_page()
492
+ return await page.title()