tinyfish 0.8.0__tar.gz → 0.9.0__tar.gz
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.
- {tinyfish-0.8.0 → tinyfish-0.9.0}/CHANGELOG.md +19 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/PKG-INFO +1 -1
- {tinyfish-0.8.0 → tinyfish-0.9.0}/docs/proxy-and-browser-profiles.md +23 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/pyproject.toml +1 -1
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/__init__.py +2 -1
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/_utils/client/_base.py +13 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/browser/__init__.py +9 -3
- tinyfish-0.9.0/src/tinyfish/browser/types.py +52 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/tests/test_browser.py +51 -1
- {tinyfish-0.8.0 → tinyfish-0.9.0}/tests/test_client.py +13 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/tests/test_vault.py +37 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/uv.lock +8 -8
- tinyfish-0.8.0/src/tinyfish/browser/types.py +0 -24
- {tinyfish-0.8.0 → tinyfish-0.9.0}/.gitignore +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/.pre-commit-config.yaml +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/AGENTS.md +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/CLAUDE.md +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/README.md +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/RELEASE.md +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/docs/exceptions-and-errors-guide.md +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/docs/internal/api-integration-header.md +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/docs/internal/exceptions-and-errors-guide.md +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/docs/internal/publishing-private-guide.md +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/docs/pagination-guide.md +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/docs/streaming-guide.md +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/_utils/__init__.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/_utils/client/__init__.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/_utils/client/async_.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/_utils/client/sync.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/_utils/exceptions.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/_utils/resource.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/_utils/sse_parser.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/agent/__init__.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/agent/types.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/client.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/fetch/__init__.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/fetch/types.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/py.typed +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/runs/__init__.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/runs/types.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/search/__init__.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/search/types.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/vault/__init__.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/vault/types.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/wallet/__init__.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/src/tinyfish/wallet/types.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/tests/__init__.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/tests/conftest.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/tests/test_agent.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/tests/test_errors.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/tests/test_fetch.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/tests/test_runs.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/tests/test_search.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/tests/test_wallet.py +0 -0
- {tinyfish-0.8.0 → tinyfish-0.9.0}/tests/testing_guide.md +0 -0
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.0](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.8.1...sdk-py/v0.9.0) (2026-09-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **sdk:** add proxy_config to browser session create ([#5593](https://github.com/tinyfish-io/ux-labs/issues/5593)) ([f7333f8](https://github.com/tinyfish-io/ux-labs/commit/f7333f82c9b8c366edf4656f2885ea98cdfc5def))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **security:** upgrade anyio to 4.14.2+ across Python lockfiles ([#5213](https://github.com/tinyfish-io/ux-labs/issues/5213)) ([c65a598](https://github.com/tinyfish-io/ux-labs/commit/c65a598ea0971b44155b8cea6be3f39b955603b6))
|
|
14
|
+
|
|
15
|
+
## [0.8.1](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.8.0...sdk-py/v0.8.1) (2026-09-16)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **vault:** Make reconnection safe across dashboard and API clients ([#4971](https://github.com/tinyfish-io/ux-labs/issues/4971)) ([3fbd712](https://github.com/tinyfish-io/ux-labs/commit/3fbd712a31fd3c565919103b904f691e3b9a0cd0))
|
|
21
|
+
|
|
3
22
|
## [0.8.0](https://github.com/tinyfish-io/ux-labs/compare/sdk-py/v0.7.0...sdk-py/v0.8.0) (2026-09-02)
|
|
4
23
|
|
|
5
24
|
|
|
@@ -121,3 +121,26 @@ run = client.runs.get("run_abc123")
|
|
|
121
121
|
print(run.browser_config.proxy_enabled) # True/False
|
|
122
122
|
print(run.browser_config.proxy_country_code) # "US" or None
|
|
123
123
|
```
|
|
124
|
+
|
|
125
|
+
## Browser API sessions
|
|
126
|
+
|
|
127
|
+
`client.browser.sessions.create()` takes its own `proxy_config` (`BrowserProxyConfig`). Omit it to use the TinyFish residential proxy in the US; the session keeps the same exit IP across its connections.
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from tinyfish import BrowserProxyConfig, TinyFish
|
|
131
|
+
|
|
132
|
+
client = TinyFish()
|
|
133
|
+
|
|
134
|
+
# Another country (any ISO 3166-1 alpha-2 code)
|
|
135
|
+
session = client.browser.sessions.create(proxy_config=BrowserProxyConfig(country_code="DE"))
|
|
136
|
+
|
|
137
|
+
# Your own HTTP(S) proxy
|
|
138
|
+
session = client.browser.sessions.create(
|
|
139
|
+
proxy_config=BrowserProxyConfig(
|
|
140
|
+
type="custom", url="http://proxy.example.com:8080", username="user", password="pass"
|
|
141
|
+
)
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
# No proxy
|
|
145
|
+
session = client.browser.sessions.create(proxy_config=BrowserProxyConfig(enabled=False))
|
|
146
|
+
```
|
|
@@ -46,7 +46,7 @@ from .agent.types import (
|
|
|
46
46
|
)
|
|
47
47
|
|
|
48
48
|
# Browser types
|
|
49
|
-
from .browser.types import BrowserSession, BrowserSessionCreateParams
|
|
49
|
+
from .browser.types import BrowserProxyConfig, BrowserSession, BrowserSessionCreateParams
|
|
50
50
|
from .client import AsyncTinyFish, TinyFish
|
|
51
51
|
from .fetch.types import (
|
|
52
52
|
FetchError,
|
|
@@ -123,6 +123,7 @@ __all__ = [
|
|
|
123
123
|
"AsyncAgentStream",
|
|
124
124
|
# Browser types
|
|
125
125
|
"BrowserSession",
|
|
126
|
+
"BrowserProxyConfig",
|
|
126
127
|
"BrowserSessionCreateParams",
|
|
127
128
|
# Agent types
|
|
128
129
|
"EventType",
|
|
@@ -5,6 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
import os
|
|
6
6
|
from importlib.metadata import version as _pkg_version
|
|
7
7
|
from typing import Any, Literal, TypeVar
|
|
8
|
+
from uuid import UUID
|
|
8
9
|
|
|
9
10
|
import httpx
|
|
10
11
|
from pydantic import BaseModel
|
|
@@ -37,6 +38,13 @@ def _sanitize_client_header(value: str) -> str:
|
|
|
37
38
|
return "".join(ch for ch in value if 32 <= ord(ch) <= 126).strip()[:128]
|
|
38
39
|
|
|
39
40
|
|
|
41
|
+
def _connect_attempt_id(value: str) -> str:
|
|
42
|
+
try:
|
|
43
|
+
return str(UUID(value))
|
|
44
|
+
except ValueError:
|
|
45
|
+
return ""
|
|
46
|
+
|
|
47
|
+
|
|
40
48
|
DEFAULT_BASE_URL = "https://agent.tinyfish.ai"
|
|
41
49
|
|
|
42
50
|
# Search and Fetch have their own hostnames, which serve the API at the root path. They are
|
|
@@ -109,10 +117,15 @@ class _BaseClient:
|
|
|
109
117
|
}
|
|
110
118
|
client_name = _sanitize_client_header(os.environ.get("TF_CLIENT_NAME", ""))
|
|
111
119
|
client_version = _sanitize_client_header(os.environ.get("TF_CLIENT_VERSION", ""))
|
|
120
|
+
connect_attempt_id = _connect_attempt_id(os.environ.get("TINYFISH_RUNTIME_ATTEMPT_ID", ""))
|
|
112
121
|
if client_name:
|
|
113
122
|
headers["X-TF-Client-Name"] = client_name
|
|
114
123
|
if client_version:
|
|
115
124
|
headers["X-TF-Client-Version"] = client_version
|
|
125
|
+
if connect_attempt_id:
|
|
126
|
+
headers["X-TF-Connect-Source"] = "setup_page"
|
|
127
|
+
headers["X-TF-Connect-Client"] = "python"
|
|
128
|
+
headers["X-TF-Connect-Attempt-Id"] = connect_attempt_id
|
|
116
129
|
return headers
|
|
117
130
|
|
|
118
131
|
@staticmethod
|
|
@@ -5,7 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
from tinyfish._utils.client import BaseAsyncAPIClient, BaseSyncAPIClient
|
|
6
6
|
from tinyfish._utils.resource import BaseAsyncAPIResource, BaseSyncAPIResource
|
|
7
7
|
|
|
8
|
-
from .types import BrowserSession, BrowserSessionCreateParams
|
|
8
|
+
from .types import BrowserProxyConfig, BrowserSession, BrowserSessionCreateParams
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class BrowserSessionsResource(BaseSyncAPIResource):
|
|
@@ -16,6 +16,7 @@ class BrowserSessionsResource(BaseSyncAPIResource):
|
|
|
16
16
|
*,
|
|
17
17
|
url: str | None = None,
|
|
18
18
|
timeout_seconds: int | None = None,
|
|
19
|
+
proxy_config: BrowserProxyConfig | None = None,
|
|
19
20
|
) -> BrowserSession:
|
|
20
21
|
"""Create a new remote browser session.
|
|
21
22
|
|
|
@@ -23,6 +24,8 @@ class BrowserSessionsResource(BaseSyncAPIResource):
|
|
|
23
24
|
url: Target URL for the browser session. If omitted, browser starts at about:blank.
|
|
24
25
|
timeout_seconds: Inactivity timeout in seconds. If omitted or exceeds plan max,
|
|
25
26
|
the plan max is used.
|
|
27
|
+
proxy_config: Proxy for the session (country, custom proxy, or disabled). If omitted,
|
|
28
|
+
the TinyFish residential proxy in the US is used, with one exit IP per session.
|
|
26
29
|
|
|
27
30
|
Returns:
|
|
28
31
|
BrowserSession with session_id, cdp_url, and base_url.
|
|
@@ -31,7 +34,7 @@ class BrowserSessionsResource(BaseSyncAPIResource):
|
|
|
31
34
|
BadRequestError: Invalid parameters.
|
|
32
35
|
AuthenticationError: Invalid API key.
|
|
33
36
|
"""
|
|
34
|
-
params = BrowserSessionCreateParams(url=url, timeout_seconds=timeout_seconds)
|
|
37
|
+
params = BrowserSessionCreateParams(url=url, timeout_seconds=timeout_seconds, proxy_config=proxy_config)
|
|
35
38
|
body = params.model_dump(exclude_none=True)
|
|
36
39
|
return self._post("/v1/browser", json=body, cast_to=BrowserSession)
|
|
37
40
|
|
|
@@ -44,6 +47,7 @@ class AsyncBrowserSessionsResource(BaseAsyncAPIResource):
|
|
|
44
47
|
*,
|
|
45
48
|
url: str | None = None,
|
|
46
49
|
timeout_seconds: int | None = None,
|
|
50
|
+
proxy_config: BrowserProxyConfig | None = None,
|
|
47
51
|
) -> BrowserSession:
|
|
48
52
|
"""Create a new remote browser session.
|
|
49
53
|
|
|
@@ -53,6 +57,8 @@ class AsyncBrowserSessionsResource(BaseAsyncAPIResource):
|
|
|
53
57
|
url: Target URL for the browser session. If omitted, browser starts at about:blank.
|
|
54
58
|
timeout_seconds: Inactivity timeout in seconds. If omitted or exceeds plan max,
|
|
55
59
|
the plan max is used.
|
|
60
|
+
proxy_config: Proxy for the session (country, custom proxy, or disabled). If omitted,
|
|
61
|
+
the TinyFish residential proxy in the US is used, with one exit IP per session.
|
|
56
62
|
|
|
57
63
|
Returns:
|
|
58
64
|
BrowserSession with session_id, cdp_url, and base_url.
|
|
@@ -61,7 +67,7 @@ class AsyncBrowserSessionsResource(BaseAsyncAPIResource):
|
|
|
61
67
|
BadRequestError: Invalid parameters.
|
|
62
68
|
AuthenticationError: Invalid API key.
|
|
63
69
|
"""
|
|
64
|
-
params = BrowserSessionCreateParams(url=url, timeout_seconds=timeout_seconds)
|
|
70
|
+
params = BrowserSessionCreateParams(url=url, timeout_seconds=timeout_seconds, proxy_config=proxy_config)
|
|
65
71
|
body = params.model_dump(exclude_none=True)
|
|
66
72
|
return await self._post("/v1/browser", json=body, cast_to=BrowserSession)
|
|
67
73
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Browser API request/response types."""
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BrowserProxyConfig(BaseModel):
|
|
9
|
+
"""How a browser session connects to the internet.
|
|
10
|
+
|
|
11
|
+
Omit entirely to use the TinyFish residential proxy in the US, pinned to one exit IP per session.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
model_config = ConfigDict(extra="forbid")
|
|
15
|
+
|
|
16
|
+
enabled: bool = True
|
|
17
|
+
"""Set False to connect directly, with no proxy. Other fields are then ignored."""
|
|
18
|
+
type: Literal["tinyfish", "custom"] = "tinyfish"
|
|
19
|
+
""""tinyfish" uses the TinyFish residential proxy; "custom" routes through your own proxy."""
|
|
20
|
+
country_code: str | None = None
|
|
21
|
+
"""Exit country for the tinyfish proxy (ISO 3166-1 alpha-2). Defaults to US server-side."""
|
|
22
|
+
url: str | None = None
|
|
23
|
+
"""Your HTTP or HTTPS proxy URL. Required when type is "custom"."""
|
|
24
|
+
username: str | None = None
|
|
25
|
+
"""Username for your custom proxy."""
|
|
26
|
+
password: str | None = None
|
|
27
|
+
"""Password for your custom proxy."""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class BrowserSessionCreateParams(BaseModel):
|
|
31
|
+
"""Parameters for `browser.sessions.create()`."""
|
|
32
|
+
|
|
33
|
+
url: str | None = Field(
|
|
34
|
+
None,
|
|
35
|
+
description="Target URL for the browser session. If omitted, browser starts at about:blank.",
|
|
36
|
+
)
|
|
37
|
+
timeout_seconds: int | None = Field(
|
|
38
|
+
None,
|
|
39
|
+
description="Inactivity timeout in seconds. If omitted or exceeds plan max, the plan max is used.",
|
|
40
|
+
)
|
|
41
|
+
proxy_config: BrowserProxyConfig | None = Field(
|
|
42
|
+
None,
|
|
43
|
+
description="Proxy for the session. If omitted, the TinyFish residential proxy in the US is used.",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class BrowserSession(BaseModel):
|
|
48
|
+
"""Response from creating a browser session."""
|
|
49
|
+
|
|
50
|
+
session_id: str = Field(..., description="Unique session identifier")
|
|
51
|
+
cdp_url: str = Field(..., description="CDP WebSocket URL for direct browser connection")
|
|
52
|
+
base_url: str = Field(..., description="HTTPS base URL for the browser session")
|
|
@@ -11,7 +11,7 @@ from respx import MockRouter
|
|
|
11
11
|
|
|
12
12
|
from tests.conftest import BASE_URL
|
|
13
13
|
from tinyfish import AsyncTinyFish, AuthenticationError, BadRequestError, InternalServerError, TinyFish
|
|
14
|
-
from tinyfish.browser.types import BrowserSession
|
|
14
|
+
from tinyfish.browser.types import BrowserProxyConfig, BrowserSession
|
|
15
15
|
|
|
16
16
|
# ─── Constants ────────────────────────────────────────────────────────────────
|
|
17
17
|
|
|
@@ -40,6 +40,33 @@ _PARAM_CASES: list[tuple[str, dict[str, Any], dict[str, Any]]] = [
|
|
|
40
40
|
{"url": "https://example.com", "timeout_seconds": 600},
|
|
41
41
|
{"url": "https://example.com", "timeout_seconds": 600},
|
|
42
42
|
),
|
|
43
|
+
(
|
|
44
|
+
"proxy_country",
|
|
45
|
+
{"proxy_config": BrowserProxyConfig(country_code="DE")},
|
|
46
|
+
{"proxy_config": {"enabled": True, "type": "tinyfish", "country_code": "DE"}},
|
|
47
|
+
),
|
|
48
|
+
(
|
|
49
|
+
"proxy_custom",
|
|
50
|
+
{
|
|
51
|
+
"proxy_config": BrowserProxyConfig(
|
|
52
|
+
type="custom", url="http://proxy.example.com:8080", username="u", password="p"
|
|
53
|
+
)
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"proxy_config": {
|
|
57
|
+
"enabled": True,
|
|
58
|
+
"type": "custom",
|
|
59
|
+
"url": "http://proxy.example.com:8080",
|
|
60
|
+
"username": "u",
|
|
61
|
+
"password": "p",
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
),
|
|
65
|
+
(
|
|
66
|
+
"proxy_disabled",
|
|
67
|
+
{"proxy_config": BrowserProxyConfig(enabled=False)},
|
|
68
|
+
{"proxy_config": {"enabled": False, "type": "tinyfish"}},
|
|
69
|
+
),
|
|
43
70
|
]
|
|
44
71
|
|
|
45
72
|
_ERROR_CASES: list[tuple[int, type[Exception]]] = [
|
|
@@ -81,6 +108,7 @@ def test_create_omits_none_values(client: TinyFish, respx_mock: MockRouter):
|
|
|
81
108
|
parsed = json.loads(route.calls[0].request.content)
|
|
82
109
|
assert "url" not in parsed
|
|
83
110
|
assert "timeout_seconds" not in parsed
|
|
111
|
+
assert "proxy_config" not in parsed
|
|
84
112
|
|
|
85
113
|
|
|
86
114
|
@pytest.mark.parametrize("status,error_class", _ERROR_CASES, ids=[str(c[0]) for c in _ERROR_CASES])
|
|
@@ -128,6 +156,7 @@ async def test_async_create_omits_none_values(async_client: AsyncTinyFish, respx
|
|
|
128
156
|
parsed = json.loads(route.calls[0].request.content)
|
|
129
157
|
assert "url" not in parsed
|
|
130
158
|
assert "timeout_seconds" not in parsed
|
|
159
|
+
assert "proxy_config" not in parsed
|
|
131
160
|
|
|
132
161
|
|
|
133
162
|
@pytest.mark.parametrize("status,error_class", _ERROR_CASES, ids=[str(c[0]) for c in _ERROR_CASES])
|
|
@@ -139,3 +168,24 @@ async def test_async_create_error_status(
|
|
|
139
168
|
async with async_client as c:
|
|
140
169
|
with pytest.raises(error_class):
|
|
141
170
|
await c.browser.sessions.create()
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
# ═══════════════════════════════════════════════════════════════════════════════
|
|
174
|
+
# BrowserProxyConfig
|
|
175
|
+
# ═══════════════════════════════════════════════════════════════════════════════
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def test_proxy_config_rejects_unknown_fields():
|
|
179
|
+
with pytest.raises(ValueError):
|
|
180
|
+
BrowserProxyConfig(countryCode="DE") # type: ignore[call-arg]
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def test_proxy_config_rejects_internal_type_name():
|
|
184
|
+
with pytest.raises(ValueError):
|
|
185
|
+
BrowserProxyConfig(type="tetra") # type: ignore[arg-type]
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def test_proxy_config_exported_from_package():
|
|
189
|
+
from tinyfish import BrowserProxyConfig as Exported
|
|
190
|
+
|
|
191
|
+
assert Exported is BrowserProxyConfig
|
|
@@ -244,6 +244,19 @@ def test_client_headers_via_env(respx_mock: MockRouter):
|
|
|
244
244
|
assert headers["x-tf-client-version"] == "1.2.3"
|
|
245
245
|
|
|
246
246
|
|
|
247
|
+
@pytest.mark.respx(base_url=BASE_URL)
|
|
248
|
+
def test_setup_page_connect_headers_via_env(respx_mock: MockRouter):
|
|
249
|
+
attempt_id = "11111111-1111-4111-8111-111111111111"
|
|
250
|
+
with mock.patch.dict(os.environ, {"TINYFISH_RUNTIME_ATTEMPT_ID": attempt_id}):
|
|
251
|
+
c = TinyFish(api_key=API_KEY, base_url=BASE_URL, max_retries=0)
|
|
252
|
+
route = respx_mock.post(_PATH).mock(return_value=httpx.Response(200, json=_RUN_OK))
|
|
253
|
+
c.agent.run(**_BODY)
|
|
254
|
+
headers = route.calls[0].request.headers
|
|
255
|
+
assert headers["x-tf-connect-source"] == "setup_page"
|
|
256
|
+
assert headers["x-tf-connect-client"] == "python"
|
|
257
|
+
assert headers["x-tf-connect-attempt-id"] == attempt_id
|
|
258
|
+
|
|
259
|
+
|
|
247
260
|
# Without TF_CLIENT_NAME / TF_CLIENT_VERSION, client headers are absent
|
|
248
261
|
@pytest.mark.respx(base_url=BASE_URL)
|
|
249
262
|
def test_no_client_headers_by_default(respx_mock: MockRouter):
|
|
@@ -296,6 +296,24 @@ def test_sync_items_returns_response(client: TinyFish, respx_mock: MockRouter):
|
|
|
296
296
|
assert result.sync_summary.removed == 0
|
|
297
297
|
|
|
298
298
|
|
|
299
|
+
@pytest.mark.respx(base_url=BASE_URL)
|
|
300
|
+
def test_sync_items_preserves_reconnect_required_code(client: TinyFish, respx_mock: MockRouter):
|
|
301
|
+
respx_mock.post(_SYNC_PATH).mock(
|
|
302
|
+
return_value=httpx.Response(
|
|
303
|
+
401,
|
|
304
|
+
json={
|
|
305
|
+
"error": {
|
|
306
|
+
"code": "VAULT_RECONNECT_REQUIRED",
|
|
307
|
+
"message": "Vault connection expired. Please reconnect your vault.",
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
)
|
|
311
|
+
)
|
|
312
|
+
with pytest.raises(AuthenticationError) as exc:
|
|
313
|
+
client.vault.items.sync()
|
|
314
|
+
assert exc.value.code == "VAULT_RECONNECT_REQUIRED"
|
|
315
|
+
|
|
316
|
+
|
|
299
317
|
# ═══════════════════════════════════════════════════════════════════════════════
|
|
300
318
|
# vault.connections.connect_1password — async
|
|
301
319
|
# ═══════════════════════════════════════════════════════════════════════════════
|
|
@@ -415,6 +433,25 @@ async def test_async_sync_items_returns_response(async_client: AsyncTinyFish, re
|
|
|
415
433
|
assert len(result.items) == 1
|
|
416
434
|
|
|
417
435
|
|
|
436
|
+
@pytest.mark.respx(base_url=BASE_URL)
|
|
437
|
+
async def test_async_sync_items_preserves_reconnect_required_code(async_client: AsyncTinyFish, respx_mock: MockRouter):
|
|
438
|
+
respx_mock.post(_SYNC_PATH).mock(
|
|
439
|
+
return_value=httpx.Response(
|
|
440
|
+
401,
|
|
441
|
+
json={
|
|
442
|
+
"error": {
|
|
443
|
+
"code": "VAULT_RECONNECT_REQUIRED",
|
|
444
|
+
"message": "Vault connection expired. Please reconnect your vault.",
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
)
|
|
448
|
+
)
|
|
449
|
+
async with async_client as c:
|
|
450
|
+
with pytest.raises(AuthenticationError) as exc:
|
|
451
|
+
await c.vault.items.sync()
|
|
452
|
+
assert exc.value.code == "VAULT_RECONNECT_REQUIRED"
|
|
453
|
+
|
|
454
|
+
|
|
418
455
|
# ═══════════════════════════════════════════════════════════════════════════════
|
|
419
456
|
# vault — error handling (async)
|
|
420
457
|
# ═══════════════════════════════════════════════════════════════════════════════
|
|
@@ -20,15 +20,15 @@ wheels = [
|
|
|
20
20
|
|
|
21
21
|
[[package]]
|
|
22
22
|
name = "anyio"
|
|
23
|
-
version = "4.
|
|
23
|
+
version = "4.15.1"
|
|
24
24
|
source = { registry = "https://pypi.org/simple" }
|
|
25
25
|
dependencies = [
|
|
26
26
|
{ name = "idna" },
|
|
27
|
-
{ name = "typing-extensions", marker = "python_full_version < '3.
|
|
27
|
+
{ name = "typing-extensions", marker = "python_full_version < '3.15'" },
|
|
28
28
|
]
|
|
29
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
|
29
|
+
sdist = { url = "https://files.pythonhosted.org/packages/a9/d2/f4d173e22df740bc37b1db102b386ba719b66e95b0f0d751f556b387e6d2/anyio-4.15.1.tar.gz", hash = "sha256:9f28306018cbd6d329e64a36d58256edff76dd996fe423bc957326e578b82a94", size = 276966, upload-time = "2026-09-05T10:42:39.44Z" }
|
|
30
30
|
wheels = [
|
|
31
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
31
|
+
{ url = "https://files.pythonhosted.org/packages/12/b8/4bd346e22b28902df4d651910f5242c28d84e4a5c2435ca5c3f797ed7e2e/anyio-4.15.1-py3-none-any.whl", hash = "sha256:6152fdbbf9a77fdec97731721bebf7c4c44f7c29b424b0065826173efc7ed101", size = 132079, upload-time = "2026-09-05T10:42:37.923Z" },
|
|
32
32
|
]
|
|
33
33
|
|
|
34
34
|
[[package]]
|
|
@@ -329,7 +329,7 @@ wheels = [
|
|
|
329
329
|
|
|
330
330
|
[[package]]
|
|
331
331
|
name = "tinyfish"
|
|
332
|
-
version = "0.
|
|
332
|
+
version = "0.8.1"
|
|
333
333
|
source = { editable = "." }
|
|
334
334
|
dependencies = [
|
|
335
335
|
{ name = "httpx" },
|
|
@@ -364,11 +364,11 @@ dev = [
|
|
|
364
364
|
|
|
365
365
|
[[package]]
|
|
366
366
|
name = "typing-extensions"
|
|
367
|
-
version = "4.
|
|
367
|
+
version = "4.16.0"
|
|
368
368
|
source = { registry = "https://pypi.org/simple" }
|
|
369
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
|
369
|
+
sdist = { url = "https://files.pythonhosted.org/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5", size = 113555, upload-time = "2026-07-02T08:40:05.92Z" }
|
|
370
370
|
wheels = [
|
|
371
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
371
|
+
{ url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" },
|
|
372
372
|
]
|
|
373
373
|
|
|
374
374
|
[[package]]
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"""Browser API request/response types."""
|
|
2
|
-
|
|
3
|
-
from pydantic import BaseModel, Field
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class BrowserSessionCreateParams(BaseModel):
|
|
7
|
-
"""Parameters for `browser.sessions.create()`."""
|
|
8
|
-
|
|
9
|
-
url: str | None = Field(
|
|
10
|
-
None,
|
|
11
|
-
description="Target URL for the browser session. If omitted, browser starts at about:blank.",
|
|
12
|
-
)
|
|
13
|
-
timeout_seconds: int | None = Field(
|
|
14
|
-
None,
|
|
15
|
-
description="Inactivity timeout in seconds. If omitted or exceeds plan max, the plan max is used.",
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class BrowserSession(BaseModel):
|
|
20
|
-
"""Response from creating a browser session."""
|
|
21
|
-
|
|
22
|
-
session_id: str = Field(..., description="Unique session identifier")
|
|
23
|
-
cdp_url: str = Field(..., description="CDP WebSocket URL for direct browser connection")
|
|
24
|
-
base_url: str = Field(..., description="HTTPS base URL for the browser session")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|