hyperbrowser 0.35.0__py3-none-any.whl → 0.37.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.

Potentially problematic release.


This version of hyperbrowser might be problematic. Click here for more details.

@@ -1,6 +1,8 @@
1
1
  from .browser_use import BrowserUseManager
2
+ from .cua import CuaManager
2
3
 
3
4
 
4
5
  class Agents:
5
6
  def __init__(self, client):
6
7
  self.browser_use = BrowserUseManager(client)
8
+ self.cua = CuaManager(client)
@@ -0,0 +1,67 @@
1
+ import asyncio
2
+
3
+ from hyperbrowser.exceptions import HyperbrowserError
4
+
5
+ from .....models import (
6
+ POLLING_ATTEMPTS,
7
+ BasicResponse,
8
+ CuaTaskResponse,
9
+ CuaTaskStatusResponse,
10
+ StartCuaTaskParams,
11
+ StartCuaTaskResponse,
12
+ )
13
+
14
+
15
+ class CuaManager:
16
+ def __init__(self, client):
17
+ self._client = client
18
+
19
+ async def start(self, params: StartCuaTaskParams) -> StartCuaTaskResponse:
20
+ response = await self._client.transport.post(
21
+ self._client._build_url("/task/cua"),
22
+ data=params.model_dump(exclude_none=True, by_alias=True),
23
+ )
24
+ return StartCuaTaskResponse(**response.data)
25
+
26
+ async def get(self, job_id: str) -> CuaTaskResponse:
27
+ response = await self._client.transport.get(
28
+ self._client._build_url(f"/task/cua/{job_id}")
29
+ )
30
+ return CuaTaskResponse(**response.data)
31
+
32
+ async def get_status(self, job_id: str) -> CuaTaskStatusResponse:
33
+ response = await self._client.transport.get(
34
+ self._client._build_url(f"/task/cua/{job_id}/status")
35
+ )
36
+ return CuaTaskStatusResponse(**response.data)
37
+
38
+ async def stop(self, job_id: str) -> BasicResponse:
39
+ response = await self._client.transport.put(
40
+ self._client._build_url(f"/task/cua/{job_id}/stop")
41
+ )
42
+ return BasicResponse(**response.data)
43
+
44
+ async def start_and_wait(self, params: StartCuaTaskParams) -> CuaTaskResponse:
45
+ job_start_resp = await self.start(params)
46
+ job_id = job_start_resp.job_id
47
+ if not job_id:
48
+ raise HyperbrowserError("Failed to start CUA task job")
49
+
50
+ failures = 0
51
+ while True:
52
+ try:
53
+ job_response = await self.get_status(job_id)
54
+ if (
55
+ job_response.status == "completed"
56
+ or job_response.status == "failed"
57
+ or job_response.status == "stopped"
58
+ ):
59
+ return await self.get(job_id)
60
+ failures = 0
61
+ except Exception as e:
62
+ failures += 1
63
+ if failures >= POLLING_ATTEMPTS:
64
+ raise HyperbrowserError(
65
+ f"Failed to poll CUA task job {job_id} after {POLLING_ATTEMPTS} attempts: {e}"
66
+ )
67
+ await asyncio.sleep(2)
@@ -1,6 +1,8 @@
1
1
  from .browser_use import BrowserUseManager
2
+ from .cua import CuaManager
2
3
 
3
4
 
4
5
  class Agents:
5
6
  def __init__(self, client):
6
7
  self.browser_use = BrowserUseManager(client)
8
+ self.cua = CuaManager(client)
@@ -0,0 +1,67 @@
1
+ import time
2
+
3
+ from hyperbrowser.exceptions import HyperbrowserError
4
+
5
+ from .....models import (
6
+ POLLING_ATTEMPTS,
7
+ BasicResponse,
8
+ CuaTaskResponse,
9
+ CuaTaskStatusResponse,
10
+ StartCuaTaskParams,
11
+ StartCuaTaskResponse,
12
+ )
13
+
14
+
15
+ class CuaManager:
16
+ def __init__(self, client):
17
+ self._client = client
18
+
19
+ def start(self, params: StartCuaTaskParams) -> StartCuaTaskResponse:
20
+ response = self._client.transport.post(
21
+ self._client._build_url("/task/cua"),
22
+ data=params.model_dump(exclude_none=True, by_alias=True),
23
+ )
24
+ return StartCuaTaskResponse(**response.data)
25
+
26
+ def get(self, job_id: str) -> CuaTaskResponse:
27
+ response = self._client.transport.get(
28
+ self._client._build_url(f"/task/cua/{job_id}")
29
+ )
30
+ return CuaTaskResponse(**response.data)
31
+
32
+ def get_status(self, job_id: str) -> CuaTaskStatusResponse:
33
+ response = self._client.transport.get(
34
+ self._client._build_url(f"/task/cua/{job_id}/status")
35
+ )
36
+ return CuaTaskStatusResponse(**response.data)
37
+
38
+ def stop(self, job_id: str) -> BasicResponse:
39
+ response = self._client.transport.put(
40
+ self._client._build_url(f"/task/cua/{job_id}/stop")
41
+ )
42
+ return BasicResponse(**response.data)
43
+
44
+ def start_and_wait(self, params: StartCuaTaskParams) -> CuaTaskResponse:
45
+ job_start_resp = self.start(params)
46
+ job_id = job_start_resp.job_id
47
+ if not job_id:
48
+ raise HyperbrowserError("Failed to start CUA task job")
49
+
50
+ failures = 0
51
+ while True:
52
+ try:
53
+ job_response = self.get_status(job_id)
54
+ if (
55
+ job_response.status == "completed"
56
+ or job_response.status == "failed"
57
+ or job_response.status == "stopped"
58
+ ):
59
+ return self.get(job_id)
60
+ failures = 0
61
+ except Exception as e:
62
+ failures += 1
63
+ if failures >= POLLING_ATTEMPTS:
64
+ raise HyperbrowserError(
65
+ f"Failed to poll CUA task job {job_id} after {POLLING_ATTEMPTS} attempts: {e}"
66
+ )
67
+ time.sleep(2)
@@ -5,6 +5,13 @@ from .agents.browser_use import (
5
5
  StartBrowserUseTaskParams,
6
6
  StartBrowserUseTaskResponse,
7
7
  )
8
+ from .agents.cua import (
9
+ CuaTaskData,
10
+ CuaTaskResponse,
11
+ CuaTaskStatusResponse,
12
+ StartCuaTaskParams,
13
+ StartCuaTaskResponse,
14
+ )
8
15
  from .consts import (
9
16
  ISO639_1,
10
17
  POLLING_ATTEMPTS,
@@ -97,6 +104,12 @@ __all__ = [
97
104
  "BrowserUseTaskStatusResponse",
98
105
  "StartBrowserUseTaskParams",
99
106
  "StartBrowserUseTaskResponse",
107
+ "CuaTaskStatus",
108
+ "CuaTaskData",
109
+ "CuaTaskResponse",
110
+ "CuaTaskStatusResponse",
111
+ "StartCuaTaskParams",
112
+ "StartCuaTaskResponse",
100
113
  # crawl
101
114
  "CrawledPage",
102
115
  "CrawlJobResponse",
@@ -183,4 +183,3 @@ class BrowserUseTaskResponse(BaseModel):
183
183
  data: Optional[BrowserUseTaskData] = Field(default=None, alias="data")
184
184
  error: Optional[str] = Field(default=None, alias="error")
185
185
  live_url: Optional[str] = Field(default=None, alias="liveUrl")
186
- live_url: Optional[str] = Field(default=None, alias="liveUrl")
@@ -0,0 +1,131 @@
1
+ from typing import Any, Literal, Optional
2
+
3
+ from pydantic import BaseModel, ConfigDict, Field
4
+
5
+ from ..session import CreateSessionParams
6
+
7
+ CuaTaskStatus = Literal["pending", "running", "completed", "failed", "stopped"]
8
+
9
+
10
+ class StartCuaTaskParams(BaseModel):
11
+ """
12
+ Parameters for creating a new CUA task.
13
+ """
14
+
15
+ model_config = ConfigDict(
16
+ populate_by_alias=True,
17
+ )
18
+
19
+ task: str
20
+ session_id: Optional[str] = Field(default=None, serialization_alias="sessionId")
21
+ max_failures: Optional[int] = Field(default=None, serialization_alias="maxFailures")
22
+ max_steps: Optional[int] = Field(default=None, serialization_alias="maxSteps")
23
+ keep_browser_open: Optional[bool] = Field(
24
+ default=None, serialization_alias="keepBrowserOpen"
25
+ )
26
+ session_options: Optional[CreateSessionParams] = Field(
27
+ default=None, serialization_alias="sessionOptions"
28
+ )
29
+
30
+
31
+ class StartCuaTaskResponse(BaseModel):
32
+ """
33
+ Response from starting a CUA task.
34
+ """
35
+
36
+ model_config = ConfigDict(
37
+ populate_by_alias=True,
38
+ )
39
+
40
+ job_id: str = Field(alias="jobId")
41
+ live_url: Optional[str] = Field(default=None, alias="liveUrl")
42
+
43
+
44
+ class CuaTaskStatusResponse(BaseModel):
45
+ """
46
+ Response from getting a CUA task status.
47
+ """
48
+
49
+ model_config = ConfigDict(
50
+ populate_by_alias=True,
51
+ )
52
+
53
+ status: CuaTaskStatus
54
+
55
+
56
+ class CuaStepResponseError(BaseModel):
57
+ """
58
+ Error details for a CUA step response.
59
+ """
60
+
61
+ model_config = ConfigDict(
62
+ populate_by_alias=True,
63
+ )
64
+
65
+ code: str
66
+ message: str
67
+
68
+
69
+ class CuaStepIncompleteDetails(BaseModel):
70
+ """
71
+ Details about why a CUA step is incomplete.
72
+ """
73
+
74
+ model_config = ConfigDict(
75
+ populate_by_alias=True,
76
+ )
77
+
78
+ reason: Optional[str] = Field(default=None)
79
+
80
+
81
+ class CuaStepReasoning(BaseModel):
82
+ """
83
+ Reasoning information for a CUA step.
84
+ """
85
+
86
+ model_config = ConfigDict(
87
+ populate_by_alias=True,
88
+ )
89
+
90
+ effort: Optional[str] = Field(default=None)
91
+ generate_summary: Optional[str] = Field(default=None)
92
+
93
+
94
+ class CuaStepResponse(BaseModel):
95
+ """
96
+ Response from a single CUA step.
97
+ """
98
+
99
+ created_at: int
100
+ output_text: str
101
+ error: Optional[CuaStepResponseError] = None
102
+ incomplete_details: Optional[CuaStepIncompleteDetails] = None
103
+ model: str
104
+ output: list[Any]
105
+ reasoning: Optional[CuaStepReasoning] = None
106
+ status: Optional[str] = None
107
+
108
+
109
+ class CuaTaskData(BaseModel):
110
+ model_config = ConfigDict(
111
+ populate_by_alias=True,
112
+ )
113
+
114
+ steps: list[CuaStepResponse]
115
+ final_result: Optional[str] = Field(default=None, alias="finalResult")
116
+
117
+
118
+ class CuaTaskResponse(BaseModel):
119
+ """
120
+ Response from a CUA task.
121
+ """
122
+
123
+ model_config = ConfigDict(
124
+ populate_by_alias=True,
125
+ )
126
+
127
+ job_id: str = Field(alias="jobId")
128
+ status: CuaTaskStatus
129
+ data: Optional[CuaTaskData] = Field(default=None, alias="data")
130
+ error: Optional[str] = Field(default=None, alias="error")
131
+ live_url: Optional[str] = Field(default=None, alias="liveUrl")
@@ -8,23 +8,22 @@ def get_scrape_options(formats: List[scrape_types] = ["markdown"]):
8
8
  "type": "object",
9
9
  "description": "The options for the scrape",
10
10
  "properties": {
11
- "format": {
12
- "type": "string",
13
- "description": "The format of the content to scrape",
14
- "enum": formats,
15
- },
16
- "include_tags": {
11
+ "formats": {
17
12
  "type": "array",
13
+ "description": "The format of the content to scrape",
18
14
  "items": {
19
15
  "type": "string",
16
+ "enum": formats,
20
17
  },
18
+ },
19
+ "include_tags": {
20
+ "type": "array",
21
+ "items": {"type": "string"},
21
22
  "description": "An array of HTML tags, classes, or IDs to include in the scraped content. Only elements matching these selectors will be returned.",
22
23
  },
23
24
  "exclude_tags": {
24
25
  "type": "array",
25
- "items": {
26
- "type": "string",
27
- },
26
+ "items": {"type": "string"},
28
27
  "description": "An array of HTML tags, classes, or IDs to exclude from the scraped content. Elements matching these selectors will be omitted from the response.",
29
28
  },
30
29
  "only_main_content": {
@@ -32,7 +31,12 @@ def get_scrape_options(formats: List[scrape_types] = ["markdown"]):
32
31
  "description": "Whether to only return the main content of the page. If true, only the main content of the page will be returned, excluding any headers, navigation menus,footers, or other non-main content.",
33
32
  },
34
33
  },
35
- "required": ["include_tags", "exclude_tags", "only_main_content", "format"],
34
+ "required": [
35
+ "include_tags",
36
+ "exclude_tags",
37
+ "only_main_content",
38
+ "formats",
39
+ ],
36
40
  "additionalProperties": False,
37
41
  }
38
42
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hyperbrowser
3
- Version: 0.35.0
3
+ Version: 0.37.0
4
4
  Summary: Python SDK for hyperbrowser
5
5
  License: MIT
6
6
  Author: Nikhil Shahi
@@ -1,16 +1,18 @@
1
1
  hyperbrowser/__init__.py,sha256=zWGcLhqhvWy6BTwuNpzWK1-0LpIn311ks-4U9nrsb7Y,187
2
2
  hyperbrowser/client/async_client.py,sha256=TfDVCO0AxgUI5mB4bmnP0mvWdDR_C6yvMpo24KIkaDc,1474
3
3
  hyperbrowser/client/base.py,sha256=9gFma7RdvJBUlDCqr8tZd315UPrjn4ldU4B0-Y-L4O4,1268
4
- hyperbrowser/client/managers/async_manager/agents/__init__.py,sha256=0Y8zZWzcBQidam5kMKy6nm2r_zwX_0pMZ2TQvd0zkLA,144
4
+ hyperbrowser/client/managers/async_manager/agents/__init__.py,sha256=4kfpZt3DvpWMFGFEtsyzaFr-7iNvFwUhTKVsYl3Ntjs,210
5
5
  hyperbrowser/client/managers/async_manager/agents/browser_use.py,sha256=DLRcQfmM8LKBJsaFCx8cYn0L4UjCd0I3egoX5ytVoTg,2511
6
+ hyperbrowser/client/managers/async_manager/agents/cua.py,sha256=e43QgSLi0LvGd9cOirsRETcit0MXvvtLA2cNv16xH0s,2337
6
7
  hyperbrowser/client/managers/async_manager/crawl.py,sha256=fzaF6cK5HZej2C6FwXxnrRt4OpJ5qYxMktaQGVYTlWE,4357
7
8
  hyperbrowser/client/managers/async_manager/extension.py,sha256=a-xYtXXdCspukYtsguRgjEoQ8E_kzzA2tQAJtIyCtAs,1439
8
9
  hyperbrowser/client/managers/async_manager/extract.py,sha256=wZO696_3Mse3tnsHgpSXibo6IfwcO5K1lWstcO_2GjQ,2492
9
10
  hyperbrowser/client/managers/async_manager/profile.py,sha256=fuNgZ5KFy6Jzy2fcjlF0yi2g8dudD_nTMkk5Coz06wE,1293
10
11
  hyperbrowser/client/managers/async_manager/scrape.py,sha256=U8oa5QNOfLfYxd31BmcLE2dqJbOK60cmoLDGoHzJnAI,6500
11
12
  hyperbrowser/client/managers/async_manager/session.py,sha256=4DTBbup-fK_uHNhgjZ4K7oqmTNtVH8tZtVQUpXzHyD8,2379
12
- hyperbrowser/client/managers/sync_manager/agents/__init__.py,sha256=0Y8zZWzcBQidam5kMKy6nm2r_zwX_0pMZ2TQvd0zkLA,144
13
+ hyperbrowser/client/managers/sync_manager/agents/__init__.py,sha256=4kfpZt3DvpWMFGFEtsyzaFr-7iNvFwUhTKVsYl3Ntjs,210
13
14
  hyperbrowser/client/managers/sync_manager/agents/browser_use.py,sha256=DX2Z5k6B_oA3wm4iYHCOq3l8B0ZyspdKlJhzf592-bw,2413
15
+ hyperbrowser/client/managers/sync_manager/agents/cua.py,sha256=rh3JyXWzh9SvSLkDBtWGVUd2KMx27MyLMuNPnRwvbxk,2253
14
16
  hyperbrowser/client/managers/sync_manager/crawl.py,sha256=gwLtEX-qGNvqxA7IhCIKYTF3QV3_gX7nOpMWZ2s7HzA,4289
15
17
  hyperbrowser/client/managers/sync_manager/extension.py,sha256=1YoyTZtMo43trl9jAsXv95aor0nBHiJEmLva39jFW-k,1415
16
18
  hyperbrowser/client/managers/sync_manager/extract.py,sha256=rNSxAMR95_nL4qHuatPSzXrYFUGbLQE1xm9Us1myy9s,2391
@@ -20,8 +22,9 @@ hyperbrowser/client/managers/sync_manager/session.py,sha256=ipPv6uesN8Y7gDF8YL0X
20
22
  hyperbrowser/client/sync.py,sha256=LjBkuXGhGJaMbDPEZbF9mzonb2UBw_I9d6xk2MDQqIU,1297
21
23
  hyperbrowser/config.py,sha256=6xtUiVXy7MQMiARAsadP62U46tL0wzVMDuGmQBcH_LQ,623
22
24
  hyperbrowser/exceptions.py,sha256=SUUkptK2OL36xDORYmSicaTYR7pMbxeWAjAgz35xnM8,1171
23
- hyperbrowser/models/__init__.py,sha256=NU9UcRQUK7DX-Dkz3T2dEI-dFEPC8vguvKdyKgBpakA,3468
24
- hyperbrowser/models/agents/browser_use.py,sha256=EnnIyAFJzIG2eZTbCKW_jgNYnWbsH15Jy7PDzOIgDY4,5114
25
+ hyperbrowser/models/__init__.py,sha256=8K2Yzvj5809FVxV-7o5N56juh2WoEQPqCI9Ie_xyTJ8,3757
26
+ hyperbrowser/models/agents/browser_use.py,sha256=Wi-w0pTn33lDwfuleEre83vVfTc2oQDIoyuxgiHL3nA,5047
27
+ hyperbrowser/models/agents/cua.py,sha256=ao7AA6NBet31duCZLI5aiWydNiiHvgQTPxkxHR5r2Cw,3061
25
28
  hyperbrowser/models/consts.py,sha256=KdwLaRPMXv1U_oWwfGv8Kmml7Nygy-d1qH-IvAT2U_E,6601
26
29
  hyperbrowser/models/crawl.py,sha256=XUS5Ja-Abl8gMyDtLIsRaEKa_taSOORMLOFCdAPgGaI,2820
27
30
  hyperbrowser/models/extension.py,sha256=nXjKXKt9R7RxyZ4hd3EvfqZsEGy_ufh1r5j2mqCLykQ,804
@@ -32,11 +35,11 @@ hyperbrowser/models/session.py,sha256=i1NkrQWNlKziDd98ySdrUUH7XSv6qOa2cmiK5vV7Ve
32
35
  hyperbrowser/tools/__init__.py,sha256=L-2xveBbSuIBQBQhJmXGCLNYEUq_XHDdgz_gBAsmQZo,4605
33
36
  hyperbrowser/tools/anthropic.py,sha256=bo8jn2ROHCp_hpX1_cjkCk7qU0LmuBr_gvlvM0f5OMc,2699
34
37
  hyperbrowser/tools/openai.py,sha256=YkdONf2CYuuJei2019a5cpCcZGn8g5bH-PnZ4YY7c4U,3514
35
- hyperbrowser/tools/schema.py,sha256=mRaPmDncJt7j84kz9ssNZdbjRDDjKVM6wL3sXz_83gE,7197
38
+ hyperbrowser/tools/schema.py,sha256=YFUAoQjx_SpjezS3UQdTCCn4xMdN3CgEeKAlulkIATc,7267
36
39
  hyperbrowser/transport/async_transport.py,sha256=6HKoeM5TutIqraEscEWobvSPWF3iVKh2hPflGNKwykw,4128
37
40
  hyperbrowser/transport/base.py,sha256=ildpMrDiM8nvrSGrH2LTOafmB17T7PQB_NQ1ODA378U,1703
38
41
  hyperbrowser/transport/sync.py,sha256=aUVpxWF8sqSycLNKxVNEZvlsZSoqc1eHgPK1Y1QA1u8,3422
39
- hyperbrowser-0.35.0.dist-info/LICENSE,sha256=6rUGKlyKb_1ZAH7h7YITYAAUNFN3MNGGKCyfrw49NLE,1071
40
- hyperbrowser-0.35.0.dist-info/METADATA,sha256=_cCONtcpaLWQmn1tyaGEeoYd0bxWz12az58hF9eJbcY,3471
41
- hyperbrowser-0.35.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
42
- hyperbrowser-0.35.0.dist-info/RECORD,,
42
+ hyperbrowser-0.37.0.dist-info/LICENSE,sha256=6rUGKlyKb_1ZAH7h7YITYAAUNFN3MNGGKCyfrw49NLE,1071
43
+ hyperbrowser-0.37.0.dist-info/METADATA,sha256=1zTwQupkHDgZkoFo-vVLCs77izhXOf0HWxmeKY0zQU4,3471
44
+ hyperbrowser-0.37.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
45
+ hyperbrowser-0.37.0.dist-info/RECORD,,