tzafon 2.0.0__py3-none-any.whl → 2.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.
Potentially problematic release.
This version of tzafon might be problematic. Click here for more details.
- tzafon/_streaming.py +4 -6
- tzafon/_version.py +1 -1
- tzafon/resources/computers.py +18 -10
- tzafon/types/action_result.py +2 -0
- {tzafon-2.0.0.dist-info → tzafon-2.1.0.dist-info}/METADATA +33 -37
- {tzafon-2.0.0.dist-info → tzafon-2.1.0.dist-info}/RECORD +8 -8
- {tzafon-2.0.0.dist-info → tzafon-2.1.0.dist-info}/WHEEL +0 -0
- {tzafon-2.0.0.dist-info → tzafon-2.1.0.dist-info}/licenses/LICENSE +0 -0
tzafon/_streaming.py
CHANGED
|
@@ -57,9 +57,8 @@ class Stream(Generic[_T]):
|
|
|
57
57
|
for sse in iterator:
|
|
58
58
|
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
|
|
59
59
|
|
|
60
|
-
#
|
|
61
|
-
|
|
62
|
-
...
|
|
60
|
+
# As we might not fully consume the response stream, we need to close it explicitly
|
|
61
|
+
response.close()
|
|
63
62
|
|
|
64
63
|
def __enter__(self) -> Self:
|
|
65
64
|
return self
|
|
@@ -121,9 +120,8 @@ class AsyncStream(Generic[_T]):
|
|
|
121
120
|
async for sse in iterator:
|
|
122
121
|
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
|
|
123
122
|
|
|
124
|
-
#
|
|
125
|
-
|
|
126
|
-
...
|
|
123
|
+
# As we might not fully consume the response stream, we need to close it explicitly
|
|
124
|
+
await response.aclose()
|
|
127
125
|
|
|
128
126
|
async def __aenter__(self) -> Self:
|
|
129
127
|
return self
|
tzafon/_version.py
CHANGED
tzafon/resources/computers.py
CHANGED
|
@@ -66,7 +66,9 @@ class ComputersResource(SyncAPIResource):
|
|
|
66
66
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
67
67
|
) -> ComputerResponse:
|
|
68
68
|
"""
|
|
69
|
-
Create a new browser or desktop automation session
|
|
69
|
+
Create a new browser or desktop automation session with configurable timeout.
|
|
70
|
+
Returns endpoints for executing actions, streaming events, and viewing
|
|
71
|
+
screencast.
|
|
70
72
|
|
|
71
73
|
Args:
|
|
72
74
|
display: TODO: implement
|
|
@@ -113,7 +115,7 @@ class ComputersResource(SyncAPIResource):
|
|
|
113
115
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
114
116
|
) -> ComputerResponse:
|
|
115
117
|
"""
|
|
116
|
-
Get the current status of a computer instance
|
|
118
|
+
Get the current status and metadata of a computer instance
|
|
117
119
|
|
|
118
120
|
Args:
|
|
119
121
|
extra_headers: Send extra headers
|
|
@@ -166,7 +168,8 @@ class ComputersResource(SyncAPIResource):
|
|
|
166
168
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
167
169
|
) -> ActionResult:
|
|
168
170
|
"""
|
|
169
|
-
Execute a single action
|
|
171
|
+
Execute a single action such as screenshot, click, type, navigate, scroll, debug
|
|
172
|
+
or other computer use actions
|
|
170
173
|
|
|
171
174
|
Args:
|
|
172
175
|
extra_headers: Send extra headers
|
|
@@ -235,7 +238,7 @@ class ComputersResource(SyncAPIResource):
|
|
|
235
238
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
236
239
|
) -> ComputerKeepAliveResponse:
|
|
237
240
|
"""
|
|
238
|
-
Extend the timeout for a computer session
|
|
241
|
+
Extend the timeout for a computer session and verify it is still running
|
|
239
242
|
|
|
240
243
|
Args:
|
|
241
244
|
extra_headers: Send extra headers
|
|
@@ -337,7 +340,8 @@ class ComputersResource(SyncAPIResource):
|
|
|
337
340
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
338
341
|
) -> None:
|
|
339
342
|
"""
|
|
340
|
-
Terminate and clean up a computer instance
|
|
343
|
+
Terminate and clean up a computer instance, stopping the session and recording
|
|
344
|
+
metrics
|
|
341
345
|
|
|
342
346
|
Args:
|
|
343
347
|
extra_headers: Send extra headers
|
|
@@ -396,7 +400,9 @@ class AsyncComputersResource(AsyncAPIResource):
|
|
|
396
400
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
397
401
|
) -> ComputerResponse:
|
|
398
402
|
"""
|
|
399
|
-
Create a new browser or desktop automation session
|
|
403
|
+
Create a new browser or desktop automation session with configurable timeout.
|
|
404
|
+
Returns endpoints for executing actions, streaming events, and viewing
|
|
405
|
+
screencast.
|
|
400
406
|
|
|
401
407
|
Args:
|
|
402
408
|
display: TODO: implement
|
|
@@ -443,7 +449,7 @@ class AsyncComputersResource(AsyncAPIResource):
|
|
|
443
449
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
444
450
|
) -> ComputerResponse:
|
|
445
451
|
"""
|
|
446
|
-
Get the current status of a computer instance
|
|
452
|
+
Get the current status and metadata of a computer instance
|
|
447
453
|
|
|
448
454
|
Args:
|
|
449
455
|
extra_headers: Send extra headers
|
|
@@ -496,7 +502,8 @@ class AsyncComputersResource(AsyncAPIResource):
|
|
|
496
502
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
497
503
|
) -> ActionResult:
|
|
498
504
|
"""
|
|
499
|
-
Execute a single action
|
|
505
|
+
Execute a single action such as screenshot, click, type, navigate, scroll, debug
|
|
506
|
+
or other computer use actions
|
|
500
507
|
|
|
501
508
|
Args:
|
|
502
509
|
extra_headers: Send extra headers
|
|
@@ -565,7 +572,7 @@ class AsyncComputersResource(AsyncAPIResource):
|
|
|
565
572
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
566
573
|
) -> ComputerKeepAliveResponse:
|
|
567
574
|
"""
|
|
568
|
-
Extend the timeout for a computer session
|
|
575
|
+
Extend the timeout for a computer session and verify it is still running
|
|
569
576
|
|
|
570
577
|
Args:
|
|
571
578
|
extra_headers: Send extra headers
|
|
@@ -667,7 +674,8 @@ class AsyncComputersResource(AsyncAPIResource):
|
|
|
667
674
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
668
675
|
) -> None:
|
|
669
676
|
"""
|
|
670
|
-
Terminate and clean up a computer instance
|
|
677
|
+
Terminate and clean up a computer instance, stopping the session and recording
|
|
678
|
+
metrics
|
|
671
679
|
|
|
672
680
|
Args:
|
|
673
681
|
extra_headers: Send extra headers
|
tzafon/types/action_result.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: tzafon
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: The official Python library for the computer API
|
|
5
5
|
Project-URL: Homepage, https://github.com/tzafon/computer-python
|
|
6
6
|
Project-URL: Repository, https://github.com/tzafon/computer-python
|
|
@@ -33,20 +33,22 @@ Requires-Dist: aiohttp; extra == 'aiohttp'
|
|
|
33
33
|
Requires-Dist: httpx-aiohttp>=0.1.9; extra == 'aiohttp'
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
35
|
|
|
36
|
-
#
|
|
36
|
+
# Tzafon Python SDK
|
|
37
37
|
|
|
38
38
|
<!-- prettier-ignore -->
|
|
39
39
|
[)](https://pypi.org/project/tzafon/)
|
|
40
40
|
|
|
41
|
-
The
|
|
42
|
-
application. The library includes type definitions for all request params and response fields,
|
|
43
|
-
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
|
|
41
|
+
The Tzafon Python SDK provides programmatic control of Chromium browsers and Linux desktop environments. Automate web interactions with simple method calls - navigate, click, type, and capture screenshots.
|
|
44
42
|
|
|
45
|
-
|
|
43
|
+
**Key Features:**
|
|
44
|
+
- Browser and desktop automation
|
|
45
|
+
- Synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx)
|
|
46
|
+
- Type-safe API with full type definitions
|
|
47
|
+
- Context manager support for automatic cleanup
|
|
46
48
|
|
|
47
49
|
## Documentation
|
|
48
50
|
|
|
49
|
-
The REST API documentation can be found
|
|
51
|
+
The REST API documentation can be found at [docs.tzafon.ai](https://docs.tzafon.ai). The full API of this library can be found in [api.md](https://github.com/tzafon/computer-python/tree/main/api.md).
|
|
50
52
|
|
|
51
53
|
## Installation
|
|
52
54
|
|
|
@@ -57,53 +59,47 @@ pip install tzafon
|
|
|
57
59
|
|
|
58
60
|
## Usage
|
|
59
61
|
|
|
60
|
-
The full API of this library can be found in [api.md](https://github.com/tzafon/computer-python/tree/main/api.md).
|
|
61
|
-
|
|
62
62
|
```python
|
|
63
|
-
import os
|
|
64
63
|
from tzafon import Computer
|
|
65
64
|
|
|
66
|
-
client = Computer(
|
|
67
|
-
api_key=os.environ.get("TZAFON_API_KEY"), # This is the default and can be omitted
|
|
68
|
-
)
|
|
65
|
+
client = Computer() # Reads TZAFON_API_KEY from environment
|
|
69
66
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
)
|
|
73
|
-
|
|
67
|
+
# Create and control a browser instance
|
|
68
|
+
with client.create(kind="browser") as computer:
|
|
69
|
+
computer.navigate("https://google.com")
|
|
70
|
+
computer.type("Tzafon AI")
|
|
71
|
+
computer.click(100, 200)
|
|
72
|
+
screenshot = computer.screenshot()
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The client automatically reads `TZAFON_API_KEY` from your environment. You can also pass it explicitly:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
client = Computer(api_key="your-api-key")
|
|
74
79
|
```
|
|
75
80
|
|
|
76
|
-
|
|
77
|
-
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
|
|
78
|
-
to add `TZAFON_API_KEY="My API Key"` to your `.env` file
|
|
79
|
-
so that your API Key is not stored in source control.
|
|
81
|
+
We recommend using [python-dotenv](https://pypi.org/project/python-dotenv/) to manage your API key in a `.env` file.
|
|
80
82
|
|
|
81
|
-
## Async
|
|
83
|
+
## Async Usage
|
|
82
84
|
|
|
83
|
-
|
|
85
|
+
Import `AsyncComputer` and use `await` with each action:
|
|
84
86
|
|
|
85
87
|
```python
|
|
86
|
-
import os
|
|
87
88
|
import asyncio
|
|
88
89
|
from tzafon import AsyncComputer
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
)
|
|
99
|
-
print(computer_response.id)
|
|
100
|
-
|
|
91
|
+
async def main():
|
|
92
|
+
client = AsyncComputer()
|
|
93
|
+
|
|
94
|
+
async with client.create(kind="browser") as computer:
|
|
95
|
+
await computer.navigate("https://google.com")
|
|
96
|
+
await computer.type("Tzafon AI")
|
|
97
|
+
await computer.click(100, 200)
|
|
98
|
+
screenshot = await computer.screenshot()
|
|
101
99
|
|
|
102
100
|
asyncio.run(main())
|
|
103
101
|
```
|
|
104
102
|
|
|
105
|
-
Functionality between the synchronous and asynchronous clients is otherwise identical.
|
|
106
|
-
|
|
107
103
|
### With aiohttp
|
|
108
104
|
|
|
109
105
|
By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.
|
|
@@ -9,9 +9,9 @@ tzafon/_models.py,sha256=lKnskYPONAWDvWo8tmbbVk7HmG7UOsI0Nve0vSMmkRc,30452
|
|
|
9
9
|
tzafon/_qs.py,sha256=craIKyvPktJ94cvf9zn8j8ekG9dWJzhWv0ob34lIOv4,4828
|
|
10
10
|
tzafon/_resource.py,sha256=EseuwN0R4kKBVcQnyF4NgCeRtc6-OrR8yWVI5fOYGHM,1112
|
|
11
11
|
tzafon/_response.py,sha256=Gaq-HHLZ76rKv515pCAMkfW4rbz_ManOH-7R640hrDE,28792
|
|
12
|
-
tzafon/_streaming.py,sha256=
|
|
12
|
+
tzafon/_streaming.py,sha256=HIbrsW_WdZZmR-vQP1ZJUHFluu4t90Zx0xa7y055CBo,10157
|
|
13
13
|
tzafon/_types.py,sha256=1kStHPi-XwmomGBE0xKVtz0mdRF4Svxb8NWZR4FaSiY,7236
|
|
14
|
-
tzafon/_version.py,sha256=
|
|
14
|
+
tzafon/_version.py,sha256=tys3ArnimnJ53ajKXZ3n_wgNFp5pTo6RH7-niTxiEn4,158
|
|
15
15
|
tzafon/batch_wrapper.py,sha256=ESJGxScFZzdPwDTiCjCz6-QRsoB-_nxoZuHbN9HKbUE,3509
|
|
16
16
|
tzafon/client_extensions.py,sha256=Tn3SkDYNl0B8M3U8eE39KNLsazKpbztAQSmBVVmzgCQ,1964
|
|
17
17
|
tzafon/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -29,9 +29,9 @@ tzafon/_utils/_transform.py,sha256=NjCzmnfqYrsAikUHQig6N9QfuTVbKipuP3ur9mcNF-E,1
|
|
|
29
29
|
tzafon/_utils/_typing.py,sha256=N_5PPuFNsaygbtA_npZd98SVN1LQQvFTKL6bkWPBZGU,4786
|
|
30
30
|
tzafon/_utils/_utils.py,sha256=0dDqauUbVZEXV0NVl7Bwu904Wwo5eyFCZpQThhFNhyA,12253
|
|
31
31
|
tzafon/resources/__init__.py,sha256=2tbxQpPYxwl6BYAmWlSblYFfmeBEasXs9oxh3vXRG2M,591
|
|
32
|
-
tzafon/resources/computers.py,sha256=
|
|
32
|
+
tzafon/resources/computers.py,sha256=XmpC0lLK1nUYHXt66BtTmCZkHDqHHY-Zcr1Ng7Wo2v8,32106
|
|
33
33
|
tzafon/types/__init__.py,sha256=kb0H5ErFRI_4U_KF2ElDt45ZTid6K1dyDjq5_VL_FKs,902
|
|
34
|
-
tzafon/types/action_result.py,sha256=
|
|
34
|
+
tzafon/types/action_result.py,sha256=50zhorxTnftv-I4AO1598DmBZJPGFFYFXRolJNbjBqQ,412
|
|
35
35
|
tzafon/types/computer_create_params.py,sha256=G9rhhm8ckcLbG5tM-vHrgG19-jmfUVN0KMcHodjNs4g,553
|
|
36
36
|
tzafon/types/computer_execute_action_params.py,sha256=-s1B9iUBavL2R2MvQXDxixdYbzr-l24wqjPP9LDo-xQ,304
|
|
37
37
|
tzafon/types/computer_execute_batch_params.py,sha256=hg5xchXjFmXv-I04hfygZYq5_TrkjmfhpmdWWsE3Axw,302
|
|
@@ -40,7 +40,7 @@ tzafon/types/computer_keep_alive_response.py,sha256=H75ugeXG2CetcGgwwKE_cYmr_ujD
|
|
|
40
40
|
tzafon/types/computer_list_response.py,sha256=ABykSdzQgm_bNISk_F7GQaXWRB3WidA9tXuMjmNWZps,294
|
|
41
41
|
tzafon/types/computer_navigate_params.py,sha256=mK4JWt0fqafLuoXHdOh_I6j-hJY0Ub0nAUkadA20v38,294
|
|
42
42
|
tzafon/types/computer_response.py,sha256=agc6iysQzQR22edcoz84CuUpzQ7WLwsxEuo8ccwIbYc,404
|
|
43
|
-
tzafon-2.
|
|
44
|
-
tzafon-2.
|
|
45
|
-
tzafon-2.
|
|
46
|
-
tzafon-2.
|
|
43
|
+
tzafon-2.1.0.dist-info/METADATA,sha256=8CKg_mQZfKkm-cuStZatkurlM84RdSwb1GFCpDGMJRY,13873
|
|
44
|
+
tzafon-2.1.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
45
|
+
tzafon-2.1.0.dist-info/licenses/LICENSE,sha256=ciLXi9zfEehb4Tnhy-M9I2WSRUpZjx-FK1TEChVqlDo,1048
|
|
46
|
+
tzafon-2.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|