anchorbrowser 0.1.0__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.
- anchorbrowser/__init__.py +100 -0
- anchorbrowser/_base_client.py +1995 -0
- anchorbrowser/_client.py +440 -0
- anchorbrowser/_compat.py +219 -0
- anchorbrowser/_constants.py +14 -0
- anchorbrowser/_exceptions.py +108 -0
- anchorbrowser/_files.py +123 -0
- anchorbrowser/_models.py +829 -0
- anchorbrowser/_qs.py +150 -0
- anchorbrowser/_resource.py +43 -0
- anchorbrowser/_response.py +832 -0
- anchorbrowser/_streaming.py +333 -0
- anchorbrowser/_types.py +219 -0
- anchorbrowser/_utils/__init__.py +57 -0
- anchorbrowser/_utils/_logs.py +25 -0
- anchorbrowser/_utils/_proxy.py +65 -0
- anchorbrowser/_utils/_reflection.py +42 -0
- anchorbrowser/_utils/_resources_proxy.py +24 -0
- anchorbrowser/_utils/_streams.py +12 -0
- anchorbrowser/_utils/_sync.py +86 -0
- anchorbrowser/_utils/_transform.py +447 -0
- anchorbrowser/_utils/_typing.py +151 -0
- anchorbrowser/_utils/_utils.py +422 -0
- anchorbrowser/_version.py +4 -0
- anchorbrowser/lib/.keep +4 -0
- anchorbrowser/lib/agent.py +69 -0
- anchorbrowser/lib/browser.py +186 -0
- anchorbrowser/py.typed +0 -0
- anchorbrowser/resources/__init__.py +61 -0
- anchorbrowser/resources/agent.py +305 -0
- anchorbrowser/resources/browser.py +152 -0
- anchorbrowser/resources/extensions.py +412 -0
- anchorbrowser/resources/profiles.py +553 -0
- anchorbrowser/resources/sessions/__init__.py +89 -0
- anchorbrowser/resources/sessions/all.py +192 -0
- anchorbrowser/resources/sessions/clipboard.py +252 -0
- anchorbrowser/resources/sessions/keyboard.py +298 -0
- anchorbrowser/resources/sessions/mouse.py +651 -0
- anchorbrowser/resources/sessions/recordings/__init__.py +33 -0
- anchorbrowser/resources/sessions/recordings/primary.py +176 -0
- anchorbrowser/resources/sessions/recordings/recordings.py +357 -0
- anchorbrowser/resources/sessions/sessions.py +1122 -0
- anchorbrowser/resources/tools.py +529 -0
- anchorbrowser/types/__init__.py +32 -0
- anchorbrowser/types/extension_delete_response.py +12 -0
- anchorbrowser/types/extension_list_response.py +31 -0
- anchorbrowser/types/extension_manifest.py +28 -0
- anchorbrowser/types/extension_retrieve_response.py +27 -0
- anchorbrowser/types/extension_upload_params.py +17 -0
- anchorbrowser/types/extension_upload_response.py +31 -0
- anchorbrowser/types/profile_create_params.py +31 -0
- anchorbrowser/types/profile_list_response.py +43 -0
- anchorbrowser/types/profile_retrieve_response.py +36 -0
- anchorbrowser/types/profile_update_params.py +27 -0
- anchorbrowser/types/session_copy_response.py +12 -0
- anchorbrowser/types/session_create_params.py +196 -0
- anchorbrowser/types/session_create_response.py +22 -0
- anchorbrowser/types/session_drag_and_drop_params.py +26 -0
- anchorbrowser/types/session_drag_and_drop_response.py +11 -0
- anchorbrowser/types/session_goto_params.py +12 -0
- anchorbrowser/types/session_goto_response.py +11 -0
- anchorbrowser/types/session_paste_params.py +12 -0
- anchorbrowser/types/session_paste_response.py +11 -0
- anchorbrowser/types/session_retrieve_downloads_response.py +51 -0
- anchorbrowser/types/session_scroll_params.py +26 -0
- anchorbrowser/types/session_scroll_response.py +11 -0
- anchorbrowser/types/sessions/__init__.py +25 -0
- anchorbrowser/types/sessions/all_status_response.py +30 -0
- anchorbrowser/types/sessions/clipboard_get_response.py +16 -0
- anchorbrowser/types/sessions/clipboard_set_params.py +12 -0
- anchorbrowser/types/sessions/clipboard_set_response.py +11 -0
- anchorbrowser/types/sessions/keyboard_shortcut_params.py +18 -0
- anchorbrowser/types/sessions/keyboard_shortcut_response.py +11 -0
- anchorbrowser/types/sessions/keyboard_type_params.py +15 -0
- anchorbrowser/types/sessions/keyboard_type_response.py +11 -0
- anchorbrowser/types/sessions/mouse_click_params.py +18 -0
- anchorbrowser/types/sessions/mouse_click_response.py +11 -0
- anchorbrowser/types/sessions/mouse_double_click_params.py +18 -0
- anchorbrowser/types/sessions/mouse_double_click_response.py +11 -0
- anchorbrowser/types/sessions/mouse_down_params.py +18 -0
- anchorbrowser/types/sessions/mouse_down_response.py +11 -0
- anchorbrowser/types/sessions/mouse_move_params.py +15 -0
- anchorbrowser/types/sessions/mouse_move_response.py +11 -0
- anchorbrowser/types/sessions/mouse_up_params.py +18 -0
- anchorbrowser/types/sessions/mouse_up_response.py +11 -0
- anchorbrowser/types/sessions/recording_list_response.py +46 -0
- anchorbrowser/types/sessions/recording_pause_response.py +12 -0
- anchorbrowser/types/sessions/recording_resume_response.py +12 -0
- anchorbrowser/types/sessions/recordings/__init__.py +3 -0
- anchorbrowser/types/shared/__init__.py +3 -0
- anchorbrowser/types/shared/success_response.py +15 -0
- anchorbrowser/types/tool_fetch_webpage_params.py +26 -0
- anchorbrowser/types/tool_fetch_webpage_response.py +7 -0
- anchorbrowser/types/tool_perform_web_task_params.py +30 -0
- anchorbrowser/types/tool_perform_web_task_response.py +16 -0
- anchorbrowser/types/tool_screenshot_webpage_params.py +48 -0
- anchorbrowser-0.1.0.dist-info/METADATA +449 -0
- anchorbrowser-0.1.0.dist-info/RECORD +100 -0
- anchorbrowser-0.1.0.dist-info/WHEEL +4 -0
- anchorbrowser-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing_extensions import Literal
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from ..types import tool_fetch_webpage_params, tool_perform_web_task_params, tool_screenshot_webpage_params
|
|
10
|
+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
|
11
|
+
from .._utils import maybe_transform, async_maybe_transform
|
|
12
|
+
from .._compat import cached_property
|
|
13
|
+
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
14
|
+
from .._response import (
|
|
15
|
+
BinaryAPIResponse,
|
|
16
|
+
AsyncBinaryAPIResponse,
|
|
17
|
+
StreamedBinaryAPIResponse,
|
|
18
|
+
AsyncStreamedBinaryAPIResponse,
|
|
19
|
+
to_raw_response_wrapper,
|
|
20
|
+
to_streamed_response_wrapper,
|
|
21
|
+
async_to_raw_response_wrapper,
|
|
22
|
+
to_custom_raw_response_wrapper,
|
|
23
|
+
async_to_streamed_response_wrapper,
|
|
24
|
+
to_custom_streamed_response_wrapper,
|
|
25
|
+
async_to_custom_raw_response_wrapper,
|
|
26
|
+
async_to_custom_streamed_response_wrapper,
|
|
27
|
+
)
|
|
28
|
+
from .._base_client import make_request_options
|
|
29
|
+
from ..types.tool_perform_web_task_response import ToolPerformWebTaskResponse
|
|
30
|
+
|
|
31
|
+
__all__ = ["ToolsResource", "AsyncToolsResource"]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ToolsResource(SyncAPIResource):
|
|
35
|
+
@cached_property
|
|
36
|
+
def with_raw_response(self) -> ToolsResourceWithRawResponse:
|
|
37
|
+
"""
|
|
38
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
39
|
+
the raw response object instead of the parsed content.
|
|
40
|
+
|
|
41
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#accessing-raw-response-data-eg-headers
|
|
42
|
+
"""
|
|
43
|
+
return ToolsResourceWithRawResponse(self)
|
|
44
|
+
|
|
45
|
+
@cached_property
|
|
46
|
+
def with_streaming_response(self) -> ToolsResourceWithStreamingResponse:
|
|
47
|
+
"""
|
|
48
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
49
|
+
|
|
50
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#with_streaming_response
|
|
51
|
+
"""
|
|
52
|
+
return ToolsResourceWithStreamingResponse(self)
|
|
53
|
+
|
|
54
|
+
def fetch_webpage(
|
|
55
|
+
self,
|
|
56
|
+
*,
|
|
57
|
+
session_id: str | NotGiven = NOT_GIVEN,
|
|
58
|
+
format: Literal["html", "markdown"] | NotGiven = NOT_GIVEN,
|
|
59
|
+
url: str | NotGiven = NOT_GIVEN,
|
|
60
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
61
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
62
|
+
extra_headers: Headers | None = None,
|
|
63
|
+
extra_query: Query | None = None,
|
|
64
|
+
extra_body: Body | None = None,
|
|
65
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
66
|
+
) -> str:
|
|
67
|
+
"""
|
|
68
|
+
Retrieve the rendered content of a webpage, optionally formatted as Markdown or
|
|
69
|
+
HTML.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
session_id: An optional browser session identifier to reference an existing running browser
|
|
73
|
+
session. If provided, the tool will execute within that browser session.
|
|
74
|
+
|
|
75
|
+
format: The output format of the content.
|
|
76
|
+
|
|
77
|
+
url: The URL of the webpage to fetch content from. When left empty, the current
|
|
78
|
+
webpage is used.
|
|
79
|
+
|
|
80
|
+
extra_headers: Send extra headers
|
|
81
|
+
|
|
82
|
+
extra_query: Add additional query parameters to the request
|
|
83
|
+
|
|
84
|
+
extra_body: Add additional JSON properties to the request
|
|
85
|
+
|
|
86
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
87
|
+
"""
|
|
88
|
+
extra_headers = {"Accept": "text/plain", **(extra_headers or {})}
|
|
89
|
+
return self._post(
|
|
90
|
+
"/v1/tools/fetch-webpage",
|
|
91
|
+
body=maybe_transform(
|
|
92
|
+
{
|
|
93
|
+
"format": format,
|
|
94
|
+
"url": url,
|
|
95
|
+
},
|
|
96
|
+
tool_fetch_webpage_params.ToolFetchWebpageParams,
|
|
97
|
+
),
|
|
98
|
+
options=make_request_options(
|
|
99
|
+
extra_headers=extra_headers,
|
|
100
|
+
extra_query=extra_query,
|
|
101
|
+
extra_body=extra_body,
|
|
102
|
+
timeout=timeout,
|
|
103
|
+
query=maybe_transform({"session_id": session_id}, tool_fetch_webpage_params.ToolFetchWebpageParams),
|
|
104
|
+
),
|
|
105
|
+
cast_to=str,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
def perform_web_task(
|
|
109
|
+
self,
|
|
110
|
+
*,
|
|
111
|
+
prompt: str,
|
|
112
|
+
session_id: str | NotGiven = NOT_GIVEN,
|
|
113
|
+
output_schema: object | NotGiven = NOT_GIVEN,
|
|
114
|
+
url: str | NotGiven = NOT_GIVEN,
|
|
115
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
116
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
117
|
+
extra_headers: Headers | None = None,
|
|
118
|
+
extra_query: Query | None = None,
|
|
119
|
+
extra_body: Body | None = None,
|
|
120
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
121
|
+
) -> ToolPerformWebTaskResponse:
|
|
122
|
+
"""
|
|
123
|
+
Start from a URL and perform the given task.
|
|
124
|
+
|
|
125
|
+
Args:
|
|
126
|
+
prompt: The task to be autonomously completed.
|
|
127
|
+
|
|
128
|
+
session_id: An optional browser session identifier to reference an existing running browser
|
|
129
|
+
sessions. When passed, the tool will be executed on the provided browser
|
|
130
|
+
session.
|
|
131
|
+
|
|
132
|
+
output_schema: JSON Schema defining the expected structure of the output data.
|
|
133
|
+
|
|
134
|
+
url: The URL of the webpage. If not provided, the tool will use the current page in
|
|
135
|
+
the session.
|
|
136
|
+
|
|
137
|
+
extra_headers: Send extra headers
|
|
138
|
+
|
|
139
|
+
extra_query: Add additional query parameters to the request
|
|
140
|
+
|
|
141
|
+
extra_body: Add additional JSON properties to the request
|
|
142
|
+
|
|
143
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
144
|
+
"""
|
|
145
|
+
return self._post(
|
|
146
|
+
"/v1/tools/perform-web-task",
|
|
147
|
+
body=maybe_transform(
|
|
148
|
+
{
|
|
149
|
+
"prompt": prompt,
|
|
150
|
+
"output_schema": output_schema,
|
|
151
|
+
"url": url,
|
|
152
|
+
},
|
|
153
|
+
tool_perform_web_task_params.ToolPerformWebTaskParams,
|
|
154
|
+
),
|
|
155
|
+
options=make_request_options(
|
|
156
|
+
extra_headers=extra_headers,
|
|
157
|
+
extra_query=extra_query,
|
|
158
|
+
extra_body=extra_body,
|
|
159
|
+
timeout=timeout,
|
|
160
|
+
query=maybe_transform(
|
|
161
|
+
{"session_id": session_id}, tool_perform_web_task_params.ToolPerformWebTaskParams
|
|
162
|
+
),
|
|
163
|
+
),
|
|
164
|
+
cast_to=ToolPerformWebTaskResponse,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
def screenshot_webpage(
|
|
168
|
+
self,
|
|
169
|
+
*,
|
|
170
|
+
session_id: str | NotGiven = NOT_GIVEN,
|
|
171
|
+
capture_full_height: bool | NotGiven = NOT_GIVEN,
|
|
172
|
+
height: int | NotGiven = NOT_GIVEN,
|
|
173
|
+
image_quality: int | NotGiven = NOT_GIVEN,
|
|
174
|
+
s3_target_address: str | NotGiven = NOT_GIVEN,
|
|
175
|
+
scroll_all_content: bool | NotGiven = NOT_GIVEN,
|
|
176
|
+
url: str | NotGiven = NOT_GIVEN,
|
|
177
|
+
wait: int | NotGiven = NOT_GIVEN,
|
|
178
|
+
width: int | NotGiven = NOT_GIVEN,
|
|
179
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
180
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
181
|
+
extra_headers: Headers | None = None,
|
|
182
|
+
extra_query: Query | None = None,
|
|
183
|
+
extra_body: Body | None = None,
|
|
184
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
185
|
+
) -> BinaryAPIResponse:
|
|
186
|
+
"""
|
|
187
|
+
This endpoint captures a screenshot of the specified webpage using Chromium.
|
|
188
|
+
Users can customize the viewport dimensions and capture options.
|
|
189
|
+
|
|
190
|
+
Args:
|
|
191
|
+
session_id: An optional browser session identifier to reference an existing running browser
|
|
192
|
+
sessions. When passed, the tool will be executed on the provided browser
|
|
193
|
+
session.
|
|
194
|
+
|
|
195
|
+
capture_full_height: If true, captures the entire height of the page, ignoring the viewport height.
|
|
196
|
+
|
|
197
|
+
height: The height of the browser viewport in pixels.
|
|
198
|
+
|
|
199
|
+
image_quality: Quality of the output image, on the range 1-100. 100 will not perform any
|
|
200
|
+
compression.
|
|
201
|
+
|
|
202
|
+
s3_target_address: Presigned S3 url target to upload the image to.
|
|
203
|
+
|
|
204
|
+
scroll_all_content: If true, scrolls the page and captures all visible content.
|
|
205
|
+
|
|
206
|
+
url: The URL of the webpage to capture.
|
|
207
|
+
|
|
208
|
+
wait: Duration in milliseconds to wait after page has loaded, mainly used for sites
|
|
209
|
+
with JS animations.
|
|
210
|
+
|
|
211
|
+
width: The width of the browser viewport in pixels.
|
|
212
|
+
|
|
213
|
+
extra_headers: Send extra headers
|
|
214
|
+
|
|
215
|
+
extra_query: Add additional query parameters to the request
|
|
216
|
+
|
|
217
|
+
extra_body: Add additional JSON properties to the request
|
|
218
|
+
|
|
219
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
220
|
+
"""
|
|
221
|
+
extra_headers = {"Accept": "image/png", **(extra_headers or {})}
|
|
222
|
+
return self._post(
|
|
223
|
+
"/v1/tools/screenshot",
|
|
224
|
+
body=maybe_transform(
|
|
225
|
+
{
|
|
226
|
+
"capture_full_height": capture_full_height,
|
|
227
|
+
"height": height,
|
|
228
|
+
"image_quality": image_quality,
|
|
229
|
+
"s3_target_address": s3_target_address,
|
|
230
|
+
"scroll_all_content": scroll_all_content,
|
|
231
|
+
"url": url,
|
|
232
|
+
"wait": wait,
|
|
233
|
+
"width": width,
|
|
234
|
+
},
|
|
235
|
+
tool_screenshot_webpage_params.ToolScreenshotWebpageParams,
|
|
236
|
+
),
|
|
237
|
+
options=make_request_options(
|
|
238
|
+
extra_headers=extra_headers,
|
|
239
|
+
extra_query=extra_query,
|
|
240
|
+
extra_body=extra_body,
|
|
241
|
+
timeout=timeout,
|
|
242
|
+
query=maybe_transform(
|
|
243
|
+
{"session_id": session_id}, tool_screenshot_webpage_params.ToolScreenshotWebpageParams
|
|
244
|
+
),
|
|
245
|
+
),
|
|
246
|
+
cast_to=BinaryAPIResponse,
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
class AsyncToolsResource(AsyncAPIResource):
|
|
251
|
+
@cached_property
|
|
252
|
+
def with_raw_response(self) -> AsyncToolsResourceWithRawResponse:
|
|
253
|
+
"""
|
|
254
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
255
|
+
the raw response object instead of the parsed content.
|
|
256
|
+
|
|
257
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#accessing-raw-response-data-eg-headers
|
|
258
|
+
"""
|
|
259
|
+
return AsyncToolsResourceWithRawResponse(self)
|
|
260
|
+
|
|
261
|
+
@cached_property
|
|
262
|
+
def with_streaming_response(self) -> AsyncToolsResourceWithStreamingResponse:
|
|
263
|
+
"""
|
|
264
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
265
|
+
|
|
266
|
+
For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#with_streaming_response
|
|
267
|
+
"""
|
|
268
|
+
return AsyncToolsResourceWithStreamingResponse(self)
|
|
269
|
+
|
|
270
|
+
async def fetch_webpage(
|
|
271
|
+
self,
|
|
272
|
+
*,
|
|
273
|
+
session_id: str | NotGiven = NOT_GIVEN,
|
|
274
|
+
format: Literal["html", "markdown"] | NotGiven = NOT_GIVEN,
|
|
275
|
+
url: str | NotGiven = NOT_GIVEN,
|
|
276
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
277
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
278
|
+
extra_headers: Headers | None = None,
|
|
279
|
+
extra_query: Query | None = None,
|
|
280
|
+
extra_body: Body | None = None,
|
|
281
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
282
|
+
) -> str:
|
|
283
|
+
"""
|
|
284
|
+
Retrieve the rendered content of a webpage, optionally formatted as Markdown or
|
|
285
|
+
HTML.
|
|
286
|
+
|
|
287
|
+
Args:
|
|
288
|
+
session_id: An optional browser session identifier to reference an existing running browser
|
|
289
|
+
session. If provided, the tool will execute within that browser session.
|
|
290
|
+
|
|
291
|
+
format: The output format of the content.
|
|
292
|
+
|
|
293
|
+
url: The URL of the webpage to fetch content from. When left empty, the current
|
|
294
|
+
webpage is used.
|
|
295
|
+
|
|
296
|
+
extra_headers: Send extra headers
|
|
297
|
+
|
|
298
|
+
extra_query: Add additional query parameters to the request
|
|
299
|
+
|
|
300
|
+
extra_body: Add additional JSON properties to the request
|
|
301
|
+
|
|
302
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
303
|
+
"""
|
|
304
|
+
extra_headers = {"Accept": "text/plain", **(extra_headers or {})}
|
|
305
|
+
return await self._post(
|
|
306
|
+
"/v1/tools/fetch-webpage",
|
|
307
|
+
body=await async_maybe_transform(
|
|
308
|
+
{
|
|
309
|
+
"format": format,
|
|
310
|
+
"url": url,
|
|
311
|
+
},
|
|
312
|
+
tool_fetch_webpage_params.ToolFetchWebpageParams,
|
|
313
|
+
),
|
|
314
|
+
options=make_request_options(
|
|
315
|
+
extra_headers=extra_headers,
|
|
316
|
+
extra_query=extra_query,
|
|
317
|
+
extra_body=extra_body,
|
|
318
|
+
timeout=timeout,
|
|
319
|
+
query=await async_maybe_transform(
|
|
320
|
+
{"session_id": session_id}, tool_fetch_webpage_params.ToolFetchWebpageParams
|
|
321
|
+
),
|
|
322
|
+
),
|
|
323
|
+
cast_to=str,
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
async def perform_web_task(
|
|
327
|
+
self,
|
|
328
|
+
*,
|
|
329
|
+
prompt: str,
|
|
330
|
+
session_id: str | NotGiven = NOT_GIVEN,
|
|
331
|
+
output_schema: object | NotGiven = NOT_GIVEN,
|
|
332
|
+
url: str | NotGiven = NOT_GIVEN,
|
|
333
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
334
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
335
|
+
extra_headers: Headers | None = None,
|
|
336
|
+
extra_query: Query | None = None,
|
|
337
|
+
extra_body: Body | None = None,
|
|
338
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
339
|
+
) -> ToolPerformWebTaskResponse:
|
|
340
|
+
"""
|
|
341
|
+
Start from a URL and perform the given task.
|
|
342
|
+
|
|
343
|
+
Args:
|
|
344
|
+
prompt: The task to be autonomously completed.
|
|
345
|
+
|
|
346
|
+
session_id: An optional browser session identifier to reference an existing running browser
|
|
347
|
+
sessions. When passed, the tool will be executed on the provided browser
|
|
348
|
+
session.
|
|
349
|
+
|
|
350
|
+
output_schema: JSON Schema defining the expected structure of the output data.
|
|
351
|
+
|
|
352
|
+
url: The URL of the webpage. If not provided, the tool will use the current page in
|
|
353
|
+
the session.
|
|
354
|
+
|
|
355
|
+
extra_headers: Send extra headers
|
|
356
|
+
|
|
357
|
+
extra_query: Add additional query parameters to the request
|
|
358
|
+
|
|
359
|
+
extra_body: Add additional JSON properties to the request
|
|
360
|
+
|
|
361
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
362
|
+
"""
|
|
363
|
+
return await self._post(
|
|
364
|
+
"/v1/tools/perform-web-task",
|
|
365
|
+
body=await async_maybe_transform(
|
|
366
|
+
{
|
|
367
|
+
"prompt": prompt,
|
|
368
|
+
"output_schema": output_schema,
|
|
369
|
+
"url": url,
|
|
370
|
+
},
|
|
371
|
+
tool_perform_web_task_params.ToolPerformWebTaskParams,
|
|
372
|
+
),
|
|
373
|
+
options=make_request_options(
|
|
374
|
+
extra_headers=extra_headers,
|
|
375
|
+
extra_query=extra_query,
|
|
376
|
+
extra_body=extra_body,
|
|
377
|
+
timeout=timeout,
|
|
378
|
+
query=await async_maybe_transform(
|
|
379
|
+
{"session_id": session_id}, tool_perform_web_task_params.ToolPerformWebTaskParams
|
|
380
|
+
),
|
|
381
|
+
),
|
|
382
|
+
cast_to=ToolPerformWebTaskResponse,
|
|
383
|
+
)
|
|
384
|
+
|
|
385
|
+
async def screenshot_webpage(
|
|
386
|
+
self,
|
|
387
|
+
*,
|
|
388
|
+
session_id: str | NotGiven = NOT_GIVEN,
|
|
389
|
+
capture_full_height: bool | NotGiven = NOT_GIVEN,
|
|
390
|
+
height: int | NotGiven = NOT_GIVEN,
|
|
391
|
+
image_quality: int | NotGiven = NOT_GIVEN,
|
|
392
|
+
s3_target_address: str | NotGiven = NOT_GIVEN,
|
|
393
|
+
scroll_all_content: bool | NotGiven = NOT_GIVEN,
|
|
394
|
+
url: str | NotGiven = NOT_GIVEN,
|
|
395
|
+
wait: int | NotGiven = NOT_GIVEN,
|
|
396
|
+
width: int | NotGiven = NOT_GIVEN,
|
|
397
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
398
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
399
|
+
extra_headers: Headers | None = None,
|
|
400
|
+
extra_query: Query | None = None,
|
|
401
|
+
extra_body: Body | None = None,
|
|
402
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
403
|
+
) -> AsyncBinaryAPIResponse:
|
|
404
|
+
"""
|
|
405
|
+
This endpoint captures a screenshot of the specified webpage using Chromium.
|
|
406
|
+
Users can customize the viewport dimensions and capture options.
|
|
407
|
+
|
|
408
|
+
Args:
|
|
409
|
+
session_id: An optional browser session identifier to reference an existing running browser
|
|
410
|
+
sessions. When passed, the tool will be executed on the provided browser
|
|
411
|
+
session.
|
|
412
|
+
|
|
413
|
+
capture_full_height: If true, captures the entire height of the page, ignoring the viewport height.
|
|
414
|
+
|
|
415
|
+
height: The height of the browser viewport in pixels.
|
|
416
|
+
|
|
417
|
+
image_quality: Quality of the output image, on the range 1-100. 100 will not perform any
|
|
418
|
+
compression.
|
|
419
|
+
|
|
420
|
+
s3_target_address: Presigned S3 url target to upload the image to.
|
|
421
|
+
|
|
422
|
+
scroll_all_content: If true, scrolls the page and captures all visible content.
|
|
423
|
+
|
|
424
|
+
url: The URL of the webpage to capture.
|
|
425
|
+
|
|
426
|
+
wait: Duration in milliseconds to wait after page has loaded, mainly used for sites
|
|
427
|
+
with JS animations.
|
|
428
|
+
|
|
429
|
+
width: The width of the browser viewport in pixels.
|
|
430
|
+
|
|
431
|
+
extra_headers: Send extra headers
|
|
432
|
+
|
|
433
|
+
extra_query: Add additional query parameters to the request
|
|
434
|
+
|
|
435
|
+
extra_body: Add additional JSON properties to the request
|
|
436
|
+
|
|
437
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
438
|
+
"""
|
|
439
|
+
extra_headers = {"Accept": "image/png", **(extra_headers or {})}
|
|
440
|
+
return await self._post(
|
|
441
|
+
"/v1/tools/screenshot",
|
|
442
|
+
body=await async_maybe_transform(
|
|
443
|
+
{
|
|
444
|
+
"capture_full_height": capture_full_height,
|
|
445
|
+
"height": height,
|
|
446
|
+
"image_quality": image_quality,
|
|
447
|
+
"s3_target_address": s3_target_address,
|
|
448
|
+
"scroll_all_content": scroll_all_content,
|
|
449
|
+
"url": url,
|
|
450
|
+
"wait": wait,
|
|
451
|
+
"width": width,
|
|
452
|
+
},
|
|
453
|
+
tool_screenshot_webpage_params.ToolScreenshotWebpageParams,
|
|
454
|
+
),
|
|
455
|
+
options=make_request_options(
|
|
456
|
+
extra_headers=extra_headers,
|
|
457
|
+
extra_query=extra_query,
|
|
458
|
+
extra_body=extra_body,
|
|
459
|
+
timeout=timeout,
|
|
460
|
+
query=await async_maybe_transform(
|
|
461
|
+
{"session_id": session_id}, tool_screenshot_webpage_params.ToolScreenshotWebpageParams
|
|
462
|
+
),
|
|
463
|
+
),
|
|
464
|
+
cast_to=AsyncBinaryAPIResponse,
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
class ToolsResourceWithRawResponse:
|
|
469
|
+
def __init__(self, tools: ToolsResource) -> None:
|
|
470
|
+
self._tools = tools
|
|
471
|
+
|
|
472
|
+
self.fetch_webpage = to_raw_response_wrapper(
|
|
473
|
+
tools.fetch_webpage,
|
|
474
|
+
)
|
|
475
|
+
self.perform_web_task = to_raw_response_wrapper(
|
|
476
|
+
tools.perform_web_task,
|
|
477
|
+
)
|
|
478
|
+
self.screenshot_webpage = to_custom_raw_response_wrapper(
|
|
479
|
+
tools.screenshot_webpage,
|
|
480
|
+
BinaryAPIResponse,
|
|
481
|
+
)
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
class AsyncToolsResourceWithRawResponse:
|
|
485
|
+
def __init__(self, tools: AsyncToolsResource) -> None:
|
|
486
|
+
self._tools = tools
|
|
487
|
+
|
|
488
|
+
self.fetch_webpage = async_to_raw_response_wrapper(
|
|
489
|
+
tools.fetch_webpage,
|
|
490
|
+
)
|
|
491
|
+
self.perform_web_task = async_to_raw_response_wrapper(
|
|
492
|
+
tools.perform_web_task,
|
|
493
|
+
)
|
|
494
|
+
self.screenshot_webpage = async_to_custom_raw_response_wrapper(
|
|
495
|
+
tools.screenshot_webpage,
|
|
496
|
+
AsyncBinaryAPIResponse,
|
|
497
|
+
)
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
class ToolsResourceWithStreamingResponse:
|
|
501
|
+
def __init__(self, tools: ToolsResource) -> None:
|
|
502
|
+
self._tools = tools
|
|
503
|
+
|
|
504
|
+
self.fetch_webpage = to_streamed_response_wrapper(
|
|
505
|
+
tools.fetch_webpage,
|
|
506
|
+
)
|
|
507
|
+
self.perform_web_task = to_streamed_response_wrapper(
|
|
508
|
+
tools.perform_web_task,
|
|
509
|
+
)
|
|
510
|
+
self.screenshot_webpage = to_custom_streamed_response_wrapper(
|
|
511
|
+
tools.screenshot_webpage,
|
|
512
|
+
StreamedBinaryAPIResponse,
|
|
513
|
+
)
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
class AsyncToolsResourceWithStreamingResponse:
|
|
517
|
+
def __init__(self, tools: AsyncToolsResource) -> None:
|
|
518
|
+
self._tools = tools
|
|
519
|
+
|
|
520
|
+
self.fetch_webpage = async_to_streamed_response_wrapper(
|
|
521
|
+
tools.fetch_webpage,
|
|
522
|
+
)
|
|
523
|
+
self.perform_web_task = async_to_streamed_response_wrapper(
|
|
524
|
+
tools.perform_web_task,
|
|
525
|
+
)
|
|
526
|
+
self.screenshot_webpage = async_to_custom_streamed_response_wrapper(
|
|
527
|
+
tools.screenshot_webpage,
|
|
528
|
+
AsyncStreamedBinaryAPIResponse,
|
|
529
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from .shared import SuccessResponse as SuccessResponse
|
|
6
|
+
from .extension_manifest import ExtensionManifest as ExtensionManifest
|
|
7
|
+
from .session_goto_params import SessionGotoParams as SessionGotoParams
|
|
8
|
+
from .session_paste_params import SessionPasteParams as SessionPasteParams
|
|
9
|
+
from .profile_create_params import ProfileCreateParams as ProfileCreateParams
|
|
10
|
+
from .profile_list_response import ProfileListResponse as ProfileListResponse
|
|
11
|
+
from .profile_update_params import ProfileUpdateParams as ProfileUpdateParams
|
|
12
|
+
from .session_copy_response import SessionCopyResponse as SessionCopyResponse
|
|
13
|
+
from .session_create_params import SessionCreateParams as SessionCreateParams
|
|
14
|
+
from .session_goto_response import SessionGotoResponse as SessionGotoResponse
|
|
15
|
+
from .session_scroll_params import SessionScrollParams as SessionScrollParams
|
|
16
|
+
from .session_paste_response import SessionPasteResponse as SessionPasteResponse
|
|
17
|
+
from .extension_list_response import ExtensionListResponse as ExtensionListResponse
|
|
18
|
+
from .extension_upload_params import ExtensionUploadParams as ExtensionUploadParams
|
|
19
|
+
from .session_create_response import SessionCreateResponse as SessionCreateResponse
|
|
20
|
+
from .session_scroll_response import SessionScrollResponse as SessionScrollResponse
|
|
21
|
+
from .extension_delete_response import ExtensionDeleteResponse as ExtensionDeleteResponse
|
|
22
|
+
from .extension_upload_response import ExtensionUploadResponse as ExtensionUploadResponse
|
|
23
|
+
from .profile_retrieve_response import ProfileRetrieveResponse as ProfileRetrieveResponse
|
|
24
|
+
from .tool_fetch_webpage_params import ToolFetchWebpageParams as ToolFetchWebpageParams
|
|
25
|
+
from .extension_retrieve_response import ExtensionRetrieveResponse as ExtensionRetrieveResponse
|
|
26
|
+
from .tool_fetch_webpage_response import ToolFetchWebpageResponse as ToolFetchWebpageResponse
|
|
27
|
+
from .session_drag_and_drop_params import SessionDragAndDropParams as SessionDragAndDropParams
|
|
28
|
+
from .tool_perform_web_task_params import ToolPerformWebTaskParams as ToolPerformWebTaskParams
|
|
29
|
+
from .session_drag_and_drop_response import SessionDragAndDropResponse as SessionDragAndDropResponse
|
|
30
|
+
from .tool_perform_web_task_response import ToolPerformWebTaskResponse as ToolPerformWebTaskResponse
|
|
31
|
+
from .tool_screenshot_webpage_params import ToolScreenshotWebpageParams as ToolScreenshotWebpageParams
|
|
32
|
+
from .session_retrieve_downloads_response import SessionRetrieveDownloadsResponse as SessionRetrieveDownloadsResponse
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from .._models import BaseModel
|
|
6
|
+
from .shared.success_response import SuccessResponse
|
|
7
|
+
|
|
8
|
+
__all__ = ["ExtensionDeleteResponse"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ExtensionDeleteResponse(BaseModel):
|
|
12
|
+
data: Optional[SuccessResponse] = None
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
|
|
6
|
+
from pydantic import Field as FieldInfo
|
|
7
|
+
|
|
8
|
+
from .._models import BaseModel
|
|
9
|
+
from .extension_manifest import ExtensionManifest
|
|
10
|
+
|
|
11
|
+
__all__ = ["ExtensionListResponse", "Data"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Data(BaseModel):
|
|
15
|
+
id: Optional[str] = None
|
|
16
|
+
"""Unique identifier for the extension"""
|
|
17
|
+
|
|
18
|
+
created_at: Optional[datetime] = FieldInfo(alias="createdAt", default=None)
|
|
19
|
+
"""Timestamp when the extension was created"""
|
|
20
|
+
|
|
21
|
+
manifest: Optional[ExtensionManifest] = None
|
|
22
|
+
|
|
23
|
+
name: Optional[str] = None
|
|
24
|
+
"""Extension name"""
|
|
25
|
+
|
|
26
|
+
updated_at: Optional[datetime] = FieldInfo(alias="updatedAt", default=None)
|
|
27
|
+
"""Timestamp when the extension was last updated"""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ExtensionListResponse(BaseModel):
|
|
31
|
+
data: Optional[List[Data]] = None
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Dict, List, Optional
|
|
4
|
+
|
|
5
|
+
from pydantic import Field as FieldInfo
|
|
6
|
+
|
|
7
|
+
from .._models import BaseModel
|
|
8
|
+
|
|
9
|
+
__all__ = ["ExtensionManifest"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ExtensionManifest(BaseModel):
|
|
13
|
+
description: Optional[str] = None
|
|
14
|
+
|
|
15
|
+
manifest_version: Optional[int] = None
|
|
16
|
+
|
|
17
|
+
name: Optional[str] = None
|
|
18
|
+
|
|
19
|
+
permissions: Optional[List[str]] = None
|
|
20
|
+
|
|
21
|
+
version: Optional[str] = None
|
|
22
|
+
|
|
23
|
+
__pydantic_extra__: Dict[str, object] = FieldInfo(init=False) # pyright: ignore[reportIncompatibleVariableOverride]
|
|
24
|
+
if TYPE_CHECKING:
|
|
25
|
+
# Stub to indicate that arbitrary properties are accepted.
|
|
26
|
+
# To access properties that are not valid identifiers you can use `getattr`, e.g.
|
|
27
|
+
# `getattr(obj, '$type')`
|
|
28
|
+
def __getattr__(self, attr: str) -> object: ...
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
|
|
6
|
+
from pydantic import Field as FieldInfo
|
|
7
|
+
|
|
8
|
+
from .._models import BaseModel
|
|
9
|
+
from .extension_manifest import ExtensionManifest
|
|
10
|
+
|
|
11
|
+
__all__ = ["ExtensionRetrieveResponse"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ExtensionRetrieveResponse(BaseModel):
|
|
15
|
+
id: Optional[str] = None
|
|
16
|
+
"""Unique identifier for the extension"""
|
|
17
|
+
|
|
18
|
+
created_at: Optional[datetime] = FieldInfo(alias="createdAt", default=None)
|
|
19
|
+
"""Timestamp when the extension was created"""
|
|
20
|
+
|
|
21
|
+
manifest: Optional[ExtensionManifest] = None
|
|
22
|
+
|
|
23
|
+
name: Optional[str] = None
|
|
24
|
+
"""Extension name"""
|
|
25
|
+
|
|
26
|
+
updated_at: Optional[datetime] = FieldInfo(alias="updatedAt", default=None)
|
|
27
|
+
"""Timestamp when the extension was last updated"""
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing_extensions import Required, TypedDict
|
|
6
|
+
|
|
7
|
+
from .._types import FileTypes
|
|
8
|
+
|
|
9
|
+
__all__ = ["ExtensionUploadParams"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ExtensionUploadParams(TypedDict, total=False):
|
|
13
|
+
file: Required[FileTypes]
|
|
14
|
+
"""ZIP file containing the browser extension"""
|
|
15
|
+
|
|
16
|
+
name: Required[str]
|
|
17
|
+
"""User-friendly name for the extension (1-255 characters)"""
|