clerk-sdk 0.4.15__tar.gz → 0.4.16.dev0__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.
- {clerk_sdk-0.4.15/clerk_sdk.egg-info → clerk_sdk-0.4.16.dev0}/PKG-INFO +1 -1
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/__init__.py +1 -1
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/decorators/gui_automation.py +15 -68
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0/clerk_sdk.egg-info}/PKG-INFO +1 -1
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/setup.py +1 -1
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/LICENSE +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/MANIFEST.in +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/README.md +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/base.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/client.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/decorator/__init__.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/decorator/models.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/decorator/task_decorator.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/exceptions/__init__.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/exceptions/exceptions.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/exceptions/remote_device.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/__init__.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/action_model/__init__.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/action_model/model.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/action_model/utils.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/client.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/client_actor/__init__.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/client_actor/client_actor.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/client_actor/exception.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/client_actor/model.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/decorators/__init__.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/exceptions/__init__.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/exceptions/agent_manager.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/exceptions/modality/__init__.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/exceptions/modality/exc.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/exceptions/websocket.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/requirements.txt +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_actions/__init__.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_actions/actions.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_actions/base.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_actions/support.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_inspector/__init__.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_inspector/gui_vision.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_inspector/models.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_machine/__init__.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_machine/ai_recovery.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_machine/decorators.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_machine/exceptions.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_machine/state_machine.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/models/__init__.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/models/document.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/models/document_statuses.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/models/file.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/models/remote_device.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/models/response_model.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/models/ui_operator.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/utils/__init__.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/utils/logger.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/utils/save_artifact.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk_sdk.egg-info/SOURCES.txt +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk_sdk.egg-info/dependency_links.txt +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk_sdk.egg-info/requires.txt +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk_sdk.egg-info/top_level.txt +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/pyproject.toml +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/requirements.txt +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/setup.cfg +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/tests/test_base.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/tests/test_client.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/tests/test_document_models.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/tests/test_exceptions.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/tests/test_file_models.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/tests/test_gui_automation.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/tests/test_task_decorator.py +0 -0
- {clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/tests/test_utils.py +0 -0
{clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/decorators/gui_automation.py
RENAMED
|
@@ -2,7 +2,7 @@ import asyncio
|
|
|
2
2
|
import functools
|
|
3
3
|
import os
|
|
4
4
|
import time
|
|
5
|
-
from typing import Callable, Union
|
|
5
|
+
from typing import Any, Callable, Dict, Sequence, Union
|
|
6
6
|
|
|
7
7
|
from websockets.asyncio.client import connect, ClientConnection
|
|
8
8
|
from websockets.protocol import State
|
|
@@ -24,13 +24,6 @@ global_ws: Union[ClientConnection, None] = None
|
|
|
24
24
|
clerk_client = RPAClerk()
|
|
25
25
|
wss_uri = "wss://agent-manager.f-one.group/action"
|
|
26
26
|
|
|
27
|
-
REMOTE_DEVICE_ALLOCATION_TIMEOUT = int(
|
|
28
|
-
os.getenv("REMOTE_DEVICE_ALLOCATION_TIMEOUT", 60)
|
|
29
|
-
)
|
|
30
|
-
REMOTE_DEVICE_ALLOCATION_MAX_TRIES = int(
|
|
31
|
-
os.getenv("REMOTE_DEVICE_ALLOCATION_MAX_TRIES", 60)
|
|
32
|
-
)
|
|
33
|
-
|
|
34
27
|
|
|
35
28
|
async def connect_to_ws(uri: str) -> ClientConnection:
|
|
36
29
|
# Same knobs as before, just via the new connect()
|
|
@@ -54,46 +47,7 @@ async def reconnect_ws():
|
|
|
54
47
|
global_ws = await connect_to_ws(uri)
|
|
55
48
|
|
|
56
49
|
|
|
57
|
-
def
|
|
58
|
-
clerk_client: RPAClerk, group_name: str, run_id: str
|
|
59
|
-
) -> RemoteDevice:
|
|
60
|
-
remote_device = None
|
|
61
|
-
retries = 0
|
|
62
|
-
|
|
63
|
-
while True:
|
|
64
|
-
try:
|
|
65
|
-
remote_device = clerk_client.allocate_remote_device(
|
|
66
|
-
group_name=group_name, run_id=run_id
|
|
67
|
-
)
|
|
68
|
-
os.environ["REMOTE_DEVICE_ID"] = remote_device.id
|
|
69
|
-
os.environ["REMOTE_DEVICE_NAME"] = remote_device.name
|
|
70
|
-
logger.debug(f"Remote device allocated: {remote_device.name}")
|
|
71
|
-
return remote_device
|
|
72
|
-
|
|
73
|
-
except NoClientsAvailable:
|
|
74
|
-
logger.warning(
|
|
75
|
-
f"No clients are available for {group_name} group. Initiating a {REMOTE_DEVICE_ALLOCATION_TIMEOUT} seconds wait. Retry count: {retries}"
|
|
76
|
-
)
|
|
77
|
-
if retries >= REMOTE_DEVICE_ALLOCATION_MAX_TRIES:
|
|
78
|
-
raise ClientAvailabilityTimeout(
|
|
79
|
-
f"No clients available for {group_name} group after {REMOTE_DEVICE_ALLOCATION_TIMEOUT * REMOTE_DEVICE_ALLOCATION_MAX_TRIES} seconds"
|
|
80
|
-
)
|
|
81
|
-
time.sleep(REMOTE_DEVICE_ALLOCATION_TIMEOUT)
|
|
82
|
-
retries += 1
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
def _deallocate_target(
|
|
86
|
-
clerk_client: RPAClerk, remote_device: RemoteDevice, run_id: str
|
|
87
|
-
):
|
|
88
|
-
clerk_client.deallocate_remote_device(remote_device=remote_device, run_id=run_id)
|
|
89
|
-
logger.debug("Remote device deallocated")
|
|
90
|
-
os.environ.pop("REMOTE_DEVICE_ID", None)
|
|
91
|
-
os.environ.pop("REMOTE_DEVICE_NAME", None)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def gui_automation(
|
|
95
|
-
reserve_client: bool = False,
|
|
96
|
-
):
|
|
50
|
+
def gui_automation():
|
|
97
51
|
"""
|
|
98
52
|
Decorator that:
|
|
99
53
|
• Allocates a remote device,
|
|
@@ -101,22 +55,22 @@ def gui_automation(
|
|
|
101
55
|
• Passes control to the wrapped function,
|
|
102
56
|
• Cleans everything up afterwards.
|
|
103
57
|
"""
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
58
|
+
remote_device_name: str | None = os.getenv("REMOTE_DEVICE_NAME")
|
|
59
|
+
|
|
60
|
+
if not remote_device_name:
|
|
61
|
+
raise ValueError("REMOTE_DEVICE_NAME environmental variable is required.")
|
|
62
|
+
|
|
63
|
+
wss_token = clerk_client.get_wss_token()
|
|
107
64
|
|
|
108
65
|
def decorator(func: Callable):
|
|
109
66
|
@functools.wraps(func)
|
|
110
|
-
def wrapper(
|
|
67
|
+
def wrapper(
|
|
68
|
+
payload: ClerkCodePayload, *args: Sequence[Any], **kwargs: Dict[str, Any]
|
|
69
|
+
):
|
|
111
70
|
global global_ws
|
|
112
71
|
|
|
113
|
-
force_deallocate = False
|
|
114
72
|
os.environ["_document_id"] = payload.document.id
|
|
115
|
-
os.environ["_run_id"] = payload.run_id
|
|
116
|
-
|
|
117
|
-
remote_device = _allocate_remote_device(
|
|
118
|
-
clerk_client, group_name, payload.run_id
|
|
119
|
-
)
|
|
73
|
+
os.environ["_run_id"] = payload.run_id or ""
|
|
120
74
|
|
|
121
75
|
# Create a dedicated loop for the WebSocket work
|
|
122
76
|
event_loop = asyncio.new_event_loop()
|
|
@@ -125,8 +79,8 @@ def gui_automation(
|
|
|
125
79
|
try:
|
|
126
80
|
task = event_loop.create_task(
|
|
127
81
|
connect_to_ws(
|
|
128
|
-
f"{wss_uri}/{
|
|
129
|
-
f"?token={
|
|
82
|
+
f"{wss_uri}/{remote_device_name}/publisher"
|
|
83
|
+
f"?token={wss_token}"
|
|
130
84
|
)
|
|
131
85
|
)
|
|
132
86
|
global_ws = event_loop.run_until_complete(task)
|
|
@@ -138,18 +92,11 @@ def gui_automation(
|
|
|
138
92
|
global_ws = None
|
|
139
93
|
raise WebSocketConnectionFailed()
|
|
140
94
|
|
|
141
|
-
except Exception
|
|
142
|
-
force_deallocate = True
|
|
95
|
+
except Exception:
|
|
143
96
|
raise
|
|
144
97
|
finally:
|
|
145
98
|
os.environ.pop("_run_id", None)
|
|
146
99
|
os.environ.pop("_document_id", None)
|
|
147
|
-
if not reserve_client or force_deallocate:
|
|
148
|
-
_deallocate_target(clerk_client, remote_device, payload.run_id)
|
|
149
|
-
else:
|
|
150
|
-
logger.warning(
|
|
151
|
-
f"The client stayed reserved for the this run id: {payload.run_id}"
|
|
152
|
-
)
|
|
153
100
|
|
|
154
101
|
if global_ws and global_ws.state is State.OPEN:
|
|
155
102
|
close_task = event_loop.create_task(close_ws_connection(global_ws))
|
|
@@ -13,7 +13,7 @@ gui_requirements = get_requirements("./clerk/gui_automation")
|
|
|
13
13
|
|
|
14
14
|
setup(
|
|
15
15
|
name="clerk-sdk",
|
|
16
|
-
version="0.4.
|
|
16
|
+
version="0.4.16.dev0",
|
|
17
17
|
description="Library for interacting with Clerk",
|
|
18
18
|
long_description=open("README.md").read(),
|
|
19
19
|
long_description_content_type="text/markdown",
|
|
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
|
{clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/client_actor/client_actor.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/exceptions/modality/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_inspector/__init__.py
RENAMED
|
File without changes
|
{clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_inspector/gui_vision.py
RENAMED
|
File without changes
|
{clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_inspector/models.py
RENAMED
|
File without changes
|
{clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_machine/__init__.py
RENAMED
|
File without changes
|
{clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_machine/ai_recovery.py
RENAMED
|
File without changes
|
{clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_machine/decorators.py
RENAMED
|
File without changes
|
{clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_machine/exceptions.py
RENAMED
|
File without changes
|
{clerk_sdk-0.4.15 → clerk_sdk-0.4.16.dev0}/clerk/gui_automation/ui_state_machine/state_machine.py
RENAMED
|
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
|