anchorbrowser 0.1.0a3__py3-none-any.whl → 0.2.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.
Files changed (80) hide show
  1. anchorbrowser/__init__.py +3 -1
  2. anchorbrowser/_base_client.py +16 -13
  3. anchorbrowser/_client.py +38 -9
  4. anchorbrowser/_compat.py +48 -48
  5. anchorbrowser/_files.py +4 -4
  6. anchorbrowser/_models.py +54 -45
  7. anchorbrowser/_qs.py +7 -7
  8. anchorbrowser/_types.py +53 -12
  9. anchorbrowser/_utils/__init__.py +9 -2
  10. anchorbrowser/_utils/_compat.py +45 -0
  11. anchorbrowser/_utils/_datetime_parse.py +136 -0
  12. anchorbrowser/_utils/_transform.py +13 -3
  13. anchorbrowser/_utils/_typing.py +6 -1
  14. anchorbrowser/_utils/_utils.py +4 -5
  15. anchorbrowser/_version.py +1 -1
  16. anchorbrowser/lib/browser.py +1 -1
  17. anchorbrowser/resources/__init__.py +42 -0
  18. anchorbrowser/resources/batch_sessions.py +288 -0
  19. anchorbrowser/resources/events.py +270 -0
  20. anchorbrowser/resources/extensions.py +9 -9
  21. anchorbrowser/resources/profiles.py +24 -150
  22. anchorbrowser/resources/sessions/__init__.py +14 -0
  23. anchorbrowser/resources/sessions/agent/__init__.py +33 -0
  24. anchorbrowser/resources/sessions/agent/agent.py +273 -0
  25. anchorbrowser/resources/sessions/agent/files.py +280 -0
  26. anchorbrowser/resources/sessions/all.py +5 -5
  27. anchorbrowser/resources/sessions/clipboard.py +5 -5
  28. anchorbrowser/resources/sessions/keyboard.py +11 -13
  29. anchorbrowser/resources/sessions/mouse.py +12 -244
  30. anchorbrowser/resources/sessions/recordings/primary.py +3 -3
  31. anchorbrowser/resources/sessions/recordings/recordings.py +7 -7
  32. anchorbrowser/resources/sessions/sessions.py +345 -30
  33. anchorbrowser/resources/task/__init__.py +33 -0
  34. anchorbrowser/resources/task/run.py +225 -0
  35. anchorbrowser/resources/task/task.py +358 -0
  36. anchorbrowser/resources/tools.py +107 -37
  37. anchorbrowser/types/__init__.py +14 -1
  38. anchorbrowser/types/batch_session_create_params.py +487 -0
  39. anchorbrowser/types/batch_session_create_response.py +27 -0
  40. anchorbrowser/types/batch_session_retrieve_response.py +90 -0
  41. anchorbrowser/types/event_signal_params.py +13 -0
  42. anchorbrowser/types/event_wait_for_params.py +14 -0
  43. anchorbrowser/types/event_wait_for_response.py +12 -0
  44. anchorbrowser/types/extension_manifest.py +6 -1
  45. anchorbrowser/types/profile_create_params.py +3 -6
  46. anchorbrowser/types/profile_list_response.py +0 -3
  47. anchorbrowser/types/profile_retrieve_response.py +0 -3
  48. anchorbrowser/types/session_create_params.py +308 -29
  49. anchorbrowser/types/session_list_pages_response.py +25 -0
  50. anchorbrowser/types/session_retrieve_response.py +46 -0
  51. anchorbrowser/types/session_scroll_params.py +3 -0
  52. anchorbrowser/types/session_upload_file_params.py +14 -0
  53. anchorbrowser/types/session_upload_file_response.py +17 -0
  54. anchorbrowser/types/sessions/__init__.py +0 -4
  55. anchorbrowser/types/sessions/agent/__init__.py +7 -0
  56. anchorbrowser/types/sessions/agent/file_list_response.py +32 -0
  57. anchorbrowser/types/sessions/agent/file_upload_params.py +14 -0
  58. anchorbrowser/types/sessions/agent/file_upload_response.py +17 -0
  59. anchorbrowser/types/sessions/keyboard_shortcut_params.py +2 -2
  60. anchorbrowser/types/sessions/recording_list_response.py +4 -8
  61. anchorbrowser/types/task/__init__.py +6 -0
  62. anchorbrowser/types/task/run_execute_params.py +324 -0
  63. anchorbrowser/types/task/run_execute_response.py +33 -0
  64. anchorbrowser/types/task_create_params.py +317 -0
  65. anchorbrowser/types/task_create_response.py +345 -0
  66. anchorbrowser/types/task_list_params.py +15 -0
  67. anchorbrowser/types/task_list_response.py +361 -0
  68. anchorbrowser/types/tool_fetch_webpage_params.py +15 -0
  69. anchorbrowser/types/tool_perform_web_task_params.py +17 -1
  70. anchorbrowser/types/tool_perform_web_task_response.py +3 -3
  71. {anchorbrowser-0.1.0a3.dist-info → anchorbrowser-0.2.0.dist-info}/METADATA +13 -14
  72. anchorbrowser-0.2.0.dist-info/RECORD +126 -0
  73. anchorbrowser/types/profile_update_params.py +0 -27
  74. anchorbrowser/types/sessions/mouse_down_params.py +0 -18
  75. anchorbrowser/types/sessions/mouse_down_response.py +0 -11
  76. anchorbrowser/types/sessions/mouse_up_params.py +0 -18
  77. anchorbrowser/types/sessions/mouse_up_response.py +0 -11
  78. anchorbrowser-0.1.0a3.dist-info/RECORD +0 -100
  79. {anchorbrowser-0.1.0a3.dist-info → anchorbrowser-0.2.0.dist-info}/WHEEL +0 -0
  80. {anchorbrowser-0.1.0a3.dist-info → anchorbrowser-0.2.0.dist-info}/licenses/LICENSE +0 -0
@@ -8,6 +8,14 @@ from .all import (
8
8
  AllResourceWithStreamingResponse,
9
9
  AsyncAllResourceWithStreamingResponse,
10
10
  )
11
+ from .agent import (
12
+ AgentResource,
13
+ AsyncAgentResource,
14
+ AgentResourceWithRawResponse,
15
+ AsyncAgentResourceWithRawResponse,
16
+ AgentResourceWithStreamingResponse,
17
+ AsyncAgentResourceWithStreamingResponse,
18
+ )
11
19
  from .mouse import (
12
20
  MouseResource,
13
21
  AsyncMouseResource,
@@ -78,6 +86,12 @@ __all__ = [
78
86
  "AsyncClipboardResource",
79
87
  "ClipboardResourceWithRawResponse",
80
88
  "AsyncClipboardResourceWithRawResponse",
89
+ "AgentResource",
90
+ "AsyncAgentResource",
91
+ "AgentResourceWithRawResponse",
92
+ "AsyncAgentResourceWithRawResponse",
93
+ "AgentResourceWithStreamingResponse",
94
+ "AsyncAgentResourceWithStreamingResponse",
81
95
  "ClipboardResourceWithStreamingResponse",
82
96
  "AsyncClipboardResourceWithStreamingResponse",
83
97
  "SessionsResource",
@@ -0,0 +1,33 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from .agent import (
4
+ AgentResource,
5
+ AsyncAgentResource,
6
+ AgentResourceWithRawResponse,
7
+ AsyncAgentResourceWithRawResponse,
8
+ AgentResourceWithStreamingResponse,
9
+ AsyncAgentResourceWithStreamingResponse,
10
+ )
11
+ from .files import (
12
+ FilesResource,
13
+ AsyncFilesResource,
14
+ FilesResourceWithRawResponse,
15
+ AsyncFilesResourceWithRawResponse,
16
+ FilesResourceWithStreamingResponse,
17
+ AsyncFilesResourceWithStreamingResponse,
18
+ )
19
+
20
+ __all__ = [
21
+ "FilesResource",
22
+ "AsyncFilesResource",
23
+ "FilesResourceWithRawResponse",
24
+ "AsyncFilesResourceWithRawResponse",
25
+ "FilesResourceWithStreamingResponse",
26
+ "AsyncFilesResourceWithStreamingResponse",
27
+ "AgentResource",
28
+ "AsyncAgentResource",
29
+ "AgentResourceWithRawResponse",
30
+ "AsyncAgentResourceWithRawResponse",
31
+ "AgentResourceWithStreamingResponse",
32
+ "AsyncAgentResourceWithStreamingResponse",
33
+ ]
@@ -0,0 +1,273 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import httpx
6
+
7
+ from .files import (
8
+ FilesResource,
9
+ AsyncFilesResource,
10
+ FilesResourceWithRawResponse,
11
+ AsyncFilesResourceWithRawResponse,
12
+ FilesResourceWithStreamingResponse,
13
+ AsyncFilesResourceWithStreamingResponse,
14
+ )
15
+ from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
16
+ from ...._compat import cached_property
17
+ from ...._resource import SyncAPIResource, AsyncAPIResource
18
+ from ...._response import (
19
+ to_raw_response_wrapper,
20
+ to_streamed_response_wrapper,
21
+ async_to_raw_response_wrapper,
22
+ async_to_streamed_response_wrapper,
23
+ )
24
+ from ...._base_client import make_request_options
25
+ from ....types.shared.success_response import SuccessResponse
26
+
27
+ __all__ = ["AgentResource", "AsyncAgentResource"]
28
+
29
+
30
+ class AgentResource(SyncAPIResource):
31
+ @cached_property
32
+ def files(self) -> FilesResource:
33
+ return FilesResource(self._client)
34
+
35
+ @cached_property
36
+ def with_raw_response(self) -> AgentResourceWithRawResponse:
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 AgentResourceWithRawResponse(self)
44
+
45
+ @cached_property
46
+ def with_streaming_response(self) -> AgentResourceWithStreamingResponse:
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 AgentResourceWithStreamingResponse(self)
53
+
54
+ def pause(
55
+ self,
56
+ session_id: str,
57
+ *,
58
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
59
+ # The extra values given here take precedence over values defined on the client or passed to this method.
60
+ extra_headers: Headers | None = None,
61
+ extra_query: Query | None = None,
62
+ extra_body: Body | None = None,
63
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
64
+ ) -> SuccessResponse:
65
+ """
66
+ Pauses the AI agent for the specified browser session.
67
+
68
+ Args:
69
+ extra_headers: Send extra headers
70
+
71
+ extra_query: Add additional query parameters to the request
72
+
73
+ extra_body: Add additional JSON properties to the request
74
+
75
+ timeout: Override the client-level default timeout for this request, in seconds
76
+ """
77
+ if not session_id:
78
+ raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
79
+ return self._post(
80
+ f"/v1/sessions/{session_id}/agent/pause",
81
+ options=make_request_options(
82
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
83
+ ),
84
+ cast_to=SuccessResponse,
85
+ )
86
+
87
+ def resume(
88
+ self,
89
+ session_id: str,
90
+ *,
91
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
92
+ # The extra values given here take precedence over values defined on the client or passed to this method.
93
+ extra_headers: Headers | None = None,
94
+ extra_query: Query | None = None,
95
+ extra_body: Body | None = None,
96
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
97
+ ) -> SuccessResponse:
98
+ """
99
+ Resumes the AI agent for the specified browser session.
100
+
101
+ Args:
102
+ extra_headers: Send extra headers
103
+
104
+ extra_query: Add additional query parameters to the request
105
+
106
+ extra_body: Add additional JSON properties to the request
107
+
108
+ timeout: Override the client-level default timeout for this request, in seconds
109
+ """
110
+ if not session_id:
111
+ raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
112
+ return self._post(
113
+ f"/v1/sessions/{session_id}/agent/resume",
114
+ options=make_request_options(
115
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
116
+ ),
117
+ cast_to=SuccessResponse,
118
+ )
119
+
120
+
121
+ class AsyncAgentResource(AsyncAPIResource):
122
+ @cached_property
123
+ def files(self) -> AsyncFilesResource:
124
+ return AsyncFilesResource(self._client)
125
+
126
+ @cached_property
127
+ def with_raw_response(self) -> AsyncAgentResourceWithRawResponse:
128
+ """
129
+ This property can be used as a prefix for any HTTP method call to return
130
+ the raw response object instead of the parsed content.
131
+
132
+ For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#accessing-raw-response-data-eg-headers
133
+ """
134
+ return AsyncAgentResourceWithRawResponse(self)
135
+
136
+ @cached_property
137
+ def with_streaming_response(self) -> AsyncAgentResourceWithStreamingResponse:
138
+ """
139
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
140
+
141
+ For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#with_streaming_response
142
+ """
143
+ return AsyncAgentResourceWithStreamingResponse(self)
144
+
145
+ async def pause(
146
+ self,
147
+ session_id: str,
148
+ *,
149
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
150
+ # The extra values given here take precedence over values defined on the client or passed to this method.
151
+ extra_headers: Headers | None = None,
152
+ extra_query: Query | None = None,
153
+ extra_body: Body | None = None,
154
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
155
+ ) -> SuccessResponse:
156
+ """
157
+ Pauses the AI agent for the specified browser session.
158
+
159
+ Args:
160
+ extra_headers: Send extra headers
161
+
162
+ extra_query: Add additional query parameters to the request
163
+
164
+ extra_body: Add additional JSON properties to the request
165
+
166
+ timeout: Override the client-level default timeout for this request, in seconds
167
+ """
168
+ if not session_id:
169
+ raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
170
+ return await self._post(
171
+ f"/v1/sessions/{session_id}/agent/pause",
172
+ options=make_request_options(
173
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
174
+ ),
175
+ cast_to=SuccessResponse,
176
+ )
177
+
178
+ async def resume(
179
+ self,
180
+ session_id: str,
181
+ *,
182
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
183
+ # The extra values given here take precedence over values defined on the client or passed to this method.
184
+ extra_headers: Headers | None = None,
185
+ extra_query: Query | None = None,
186
+ extra_body: Body | None = None,
187
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
188
+ ) -> SuccessResponse:
189
+ """
190
+ Resumes the AI agent for the specified browser session.
191
+
192
+ Args:
193
+ extra_headers: Send extra headers
194
+
195
+ extra_query: Add additional query parameters to the request
196
+
197
+ extra_body: Add additional JSON properties to the request
198
+
199
+ timeout: Override the client-level default timeout for this request, in seconds
200
+ """
201
+ if not session_id:
202
+ raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
203
+ return await self._post(
204
+ f"/v1/sessions/{session_id}/agent/resume",
205
+ options=make_request_options(
206
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
207
+ ),
208
+ cast_to=SuccessResponse,
209
+ )
210
+
211
+
212
+ class AgentResourceWithRawResponse:
213
+ def __init__(self, agent: AgentResource) -> None:
214
+ self._agent = agent
215
+
216
+ self.pause = to_raw_response_wrapper(
217
+ agent.pause,
218
+ )
219
+ self.resume = to_raw_response_wrapper(
220
+ agent.resume,
221
+ )
222
+
223
+ @cached_property
224
+ def files(self) -> FilesResourceWithRawResponse:
225
+ return FilesResourceWithRawResponse(self._agent.files)
226
+
227
+
228
+ class AsyncAgentResourceWithRawResponse:
229
+ def __init__(self, agent: AsyncAgentResource) -> None:
230
+ self._agent = agent
231
+
232
+ self.pause = async_to_raw_response_wrapper(
233
+ agent.pause,
234
+ )
235
+ self.resume = async_to_raw_response_wrapper(
236
+ agent.resume,
237
+ )
238
+
239
+ @cached_property
240
+ def files(self) -> AsyncFilesResourceWithRawResponse:
241
+ return AsyncFilesResourceWithRawResponse(self._agent.files)
242
+
243
+
244
+ class AgentResourceWithStreamingResponse:
245
+ def __init__(self, agent: AgentResource) -> None:
246
+ self._agent = agent
247
+
248
+ self.pause = to_streamed_response_wrapper(
249
+ agent.pause,
250
+ )
251
+ self.resume = to_streamed_response_wrapper(
252
+ agent.resume,
253
+ )
254
+
255
+ @cached_property
256
+ def files(self) -> FilesResourceWithStreamingResponse:
257
+ return FilesResourceWithStreamingResponse(self._agent.files)
258
+
259
+
260
+ class AsyncAgentResourceWithStreamingResponse:
261
+ def __init__(self, agent: AsyncAgentResource) -> None:
262
+ self._agent = agent
263
+
264
+ self.pause = async_to_streamed_response_wrapper(
265
+ agent.pause,
266
+ )
267
+ self.resume = async_to_streamed_response_wrapper(
268
+ agent.resume,
269
+ )
270
+
271
+ @cached_property
272
+ def files(self) -> AsyncFilesResourceWithStreamingResponse:
273
+ return AsyncFilesResourceWithStreamingResponse(self._agent.files)
@@ -0,0 +1,280 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Mapping, cast
6
+
7
+ import httpx
8
+
9
+ from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
10
+ from ...._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
11
+ from ...._compat import cached_property
12
+ from ...._resource import SyncAPIResource, AsyncAPIResource
13
+ from ...._response import (
14
+ to_raw_response_wrapper,
15
+ to_streamed_response_wrapper,
16
+ async_to_raw_response_wrapper,
17
+ async_to_streamed_response_wrapper,
18
+ )
19
+ from ...._base_client import make_request_options
20
+ from ....types.sessions.agent import file_upload_params
21
+ from ....types.sessions.agent.file_list_response import FileListResponse
22
+ from ....types.sessions.agent.file_upload_response import FileUploadResponse
23
+
24
+ __all__ = ["FilesResource", "AsyncFilesResource"]
25
+
26
+
27
+ class FilesResource(SyncAPIResource):
28
+ @cached_property
29
+ def with_raw_response(self) -> FilesResourceWithRawResponse:
30
+ """
31
+ This property can be used as a prefix for any HTTP method call to return
32
+ the raw response object instead of the parsed content.
33
+
34
+ For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#accessing-raw-response-data-eg-headers
35
+ """
36
+ return FilesResourceWithRawResponse(self)
37
+
38
+ @cached_property
39
+ def with_streaming_response(self) -> FilesResourceWithStreamingResponse:
40
+ """
41
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
42
+
43
+ For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#with_streaming_response
44
+ """
45
+ return FilesResourceWithStreamingResponse(self)
46
+
47
+ def list(
48
+ self,
49
+ session_id: str,
50
+ *,
51
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
52
+ # The extra values given here take precedence over values defined on the client or passed to this method.
53
+ extra_headers: Headers | None = None,
54
+ extra_query: Query | None = None,
55
+ extra_body: Body | None = None,
56
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
57
+ ) -> FileListResponse:
58
+ """
59
+ List all resources that have been uploaded to the browser session for agent use.
60
+ Returns resource metadata including name, size, type, and last modified
61
+ timestamp.
62
+
63
+ Args:
64
+ extra_headers: Send extra headers
65
+
66
+ extra_query: Add additional query parameters to the request
67
+
68
+ extra_body: Add additional JSON properties to the request
69
+
70
+ timeout: Override the client-level default timeout for this request, in seconds
71
+ """
72
+ if not session_id:
73
+ raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
74
+ return self._get(
75
+ f"/v1/sessions/{session_id}/agent/files",
76
+ options=make_request_options(
77
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
78
+ ),
79
+ cast_to=FileListResponse,
80
+ )
81
+
82
+ def upload(
83
+ self,
84
+ session_id: str,
85
+ *,
86
+ file: FileTypes,
87
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
88
+ # The extra values given here take precedence over values defined on the client or passed to this method.
89
+ extra_headers: Headers | None = None,
90
+ extra_query: Query | None = None,
91
+ extra_body: Body | None = None,
92
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
93
+ ) -> FileUploadResponse:
94
+ """
95
+ Upload files as agent resources to a browser session using multipart/form-data.
96
+ If you upload a ZIP file, it will be automatically extracted and the files will
97
+ be made available as agent resources. If you upload a single file, it will be
98
+ saved directly as an agent resource. Resources are then accessible to AI agents
99
+ for task completion and automation.
100
+
101
+ Args:
102
+ file: File to upload as agent resource (ZIP files will be extracted automatically)
103
+
104
+ extra_headers: Send extra headers
105
+
106
+ extra_query: Add additional query parameters to the request
107
+
108
+ extra_body: Add additional JSON properties to the request
109
+
110
+ timeout: Override the client-level default timeout for this request, in seconds
111
+ """
112
+ if not session_id:
113
+ raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
114
+ body = deepcopy_minimal({"file": file})
115
+ files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
116
+ # It should be noted that the actual Content-Type header that will be
117
+ # sent to the server will contain a `boundary` parameter, e.g.
118
+ # multipart/form-data; boundary=---abc--
119
+ extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
120
+ return self._post(
121
+ f"/v1/sessions/{session_id}/agent/files",
122
+ body=maybe_transform(body, file_upload_params.FileUploadParams),
123
+ files=files,
124
+ options=make_request_options(
125
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
126
+ ),
127
+ cast_to=FileUploadResponse,
128
+ )
129
+
130
+
131
+ class AsyncFilesResource(AsyncAPIResource):
132
+ @cached_property
133
+ def with_raw_response(self) -> AsyncFilesResourceWithRawResponse:
134
+ """
135
+ This property can be used as a prefix for any HTTP method call to return
136
+ the raw response object instead of the parsed content.
137
+
138
+ For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#accessing-raw-response-data-eg-headers
139
+ """
140
+ return AsyncFilesResourceWithRawResponse(self)
141
+
142
+ @cached_property
143
+ def with_streaming_response(self) -> AsyncFilesResourceWithStreamingResponse:
144
+ """
145
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
146
+
147
+ For more information, see https://www.github.com/anchorbrowser/AnchorBrowser-SDK-Python#with_streaming_response
148
+ """
149
+ return AsyncFilesResourceWithStreamingResponse(self)
150
+
151
+ async def list(
152
+ self,
153
+ session_id: str,
154
+ *,
155
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
156
+ # The extra values given here take precedence over values defined on the client or passed to this method.
157
+ extra_headers: Headers | None = None,
158
+ extra_query: Query | None = None,
159
+ extra_body: Body | None = None,
160
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
161
+ ) -> FileListResponse:
162
+ """
163
+ List all resources that have been uploaded to the browser session for agent use.
164
+ Returns resource metadata including name, size, type, and last modified
165
+ timestamp.
166
+
167
+ Args:
168
+ extra_headers: Send extra headers
169
+
170
+ extra_query: Add additional query parameters to the request
171
+
172
+ extra_body: Add additional JSON properties to the request
173
+
174
+ timeout: Override the client-level default timeout for this request, in seconds
175
+ """
176
+ if not session_id:
177
+ raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
178
+ return await self._get(
179
+ f"/v1/sessions/{session_id}/agent/files",
180
+ options=make_request_options(
181
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
182
+ ),
183
+ cast_to=FileListResponse,
184
+ )
185
+
186
+ async def upload(
187
+ self,
188
+ session_id: str,
189
+ *,
190
+ file: FileTypes,
191
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
192
+ # The extra values given here take precedence over values defined on the client or passed to this method.
193
+ extra_headers: Headers | None = None,
194
+ extra_query: Query | None = None,
195
+ extra_body: Body | None = None,
196
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
197
+ ) -> FileUploadResponse:
198
+ """
199
+ Upload files as agent resources to a browser session using multipart/form-data.
200
+ If you upload a ZIP file, it will be automatically extracted and the files will
201
+ be made available as agent resources. If you upload a single file, it will be
202
+ saved directly as an agent resource. Resources are then accessible to AI agents
203
+ for task completion and automation.
204
+
205
+ Args:
206
+ file: File to upload as agent resource (ZIP files will be extracted automatically)
207
+
208
+ extra_headers: Send extra headers
209
+
210
+ extra_query: Add additional query parameters to the request
211
+
212
+ extra_body: Add additional JSON properties to the request
213
+
214
+ timeout: Override the client-level default timeout for this request, in seconds
215
+ """
216
+ if not session_id:
217
+ raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
218
+ body = deepcopy_minimal({"file": file})
219
+ files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
220
+ # It should be noted that the actual Content-Type header that will be
221
+ # sent to the server will contain a `boundary` parameter, e.g.
222
+ # multipart/form-data; boundary=---abc--
223
+ extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
224
+ return await self._post(
225
+ f"/v1/sessions/{session_id}/agent/files",
226
+ body=await async_maybe_transform(body, file_upload_params.FileUploadParams),
227
+ files=files,
228
+ options=make_request_options(
229
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
230
+ ),
231
+ cast_to=FileUploadResponse,
232
+ )
233
+
234
+
235
+ class FilesResourceWithRawResponse:
236
+ def __init__(self, files: FilesResource) -> None:
237
+ self._files = files
238
+
239
+ self.list = to_raw_response_wrapper(
240
+ files.list,
241
+ )
242
+ self.upload = to_raw_response_wrapper(
243
+ files.upload,
244
+ )
245
+
246
+
247
+ class AsyncFilesResourceWithRawResponse:
248
+ def __init__(self, files: AsyncFilesResource) -> None:
249
+ self._files = files
250
+
251
+ self.list = async_to_raw_response_wrapper(
252
+ files.list,
253
+ )
254
+ self.upload = async_to_raw_response_wrapper(
255
+ files.upload,
256
+ )
257
+
258
+
259
+ class FilesResourceWithStreamingResponse:
260
+ def __init__(self, files: FilesResource) -> None:
261
+ self._files = files
262
+
263
+ self.list = to_streamed_response_wrapper(
264
+ files.list,
265
+ )
266
+ self.upload = to_streamed_response_wrapper(
267
+ files.upload,
268
+ )
269
+
270
+
271
+ class AsyncFilesResourceWithStreamingResponse:
272
+ def __init__(self, files: AsyncFilesResource) -> None:
273
+ self._files = files
274
+
275
+ self.list = async_to_streamed_response_wrapper(
276
+ files.list,
277
+ )
278
+ self.upload = async_to_streamed_response_wrapper(
279
+ files.upload,
280
+ )
@@ -4,7 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  import httpx
6
6
 
7
- from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
7
+ from ..._types import Body, Query, Headers, NotGiven, not_given
8
8
  from ..._compat import cached_property
9
9
  from ..._resource import SyncAPIResource, AsyncAPIResource
10
10
  from ..._response import (
@@ -48,7 +48,7 @@ class AllResource(SyncAPIResource):
48
48
  extra_headers: Headers | None = None,
49
49
  extra_query: Query | None = None,
50
50
  extra_body: Body | None = None,
51
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
51
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
52
52
  ) -> SuccessResponse:
53
53
  """Terminates all active browser sessions associated with the provided API key."""
54
54
  return self._delete(
@@ -67,7 +67,7 @@ class AllResource(SyncAPIResource):
67
67
  extra_headers: Headers | None = None,
68
68
  extra_query: Query | None = None,
69
69
  extra_body: Body | None = None,
70
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
70
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
71
71
  ) -> AllStatusResponse:
72
72
  """
73
73
  Retrieves status information for all browser sessions associated with the API
@@ -110,7 +110,7 @@ class AsyncAllResource(AsyncAPIResource):
110
110
  extra_headers: Headers | None = None,
111
111
  extra_query: Query | None = None,
112
112
  extra_body: Body | None = None,
113
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
113
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
114
114
  ) -> SuccessResponse:
115
115
  """Terminates all active browser sessions associated with the provided API key."""
116
116
  return await self._delete(
@@ -129,7 +129,7 @@ class AsyncAllResource(AsyncAPIResource):
129
129
  extra_headers: Headers | None = None,
130
130
  extra_query: Query | None = None,
131
131
  extra_body: Body | None = None,
132
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
132
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
133
133
  ) -> AllStatusResponse:
134
134
  """
135
135
  Retrieves status information for all browser sessions associated with the API