|
1 | 1 | import pathlib |
2 | | -import sys |
3 | 2 | from functools import cached_property |
4 | 3 |
|
| 4 | +from askui_agent_os import AgentOS |
5 | 5 | from pydantic import BaseModel, Field, field_validator |
6 | 6 | from pydantic_settings import BaseSettings, SettingsConfigDict |
7 | 7 |
|
@@ -32,21 +32,6 @@ class AskUiControllerSettings(BaseSettings): |
32 | 32 | env_prefix="ASKUI_", |
33 | 33 | ) |
34 | 34 |
|
35 | | - component_registry_file: pathlib.Path | None = None |
36 | | - installation_directory: pathlib.Path | None = Field( |
37 | | - None, |
38 | | - deprecated="ASKUI_INSTALLATION_DIRECTORY has been deprecated in favor of " |
39 | | - "ASKUI_COMPONENT_REGISTRY_FILE and ASKUI_CONTROLLER_PATH. You may be using an " |
40 | | - "outdated AskUI Suite. If you think so, reinstall to upgrade the AskUI Suite " |
41 | | - "(see https://docs.askui.com/01-tutorials/00-installation).", |
42 | | - ) |
43 | | - controller_path_setting: pathlib.Path | None = Field( |
44 | | - None, |
45 | | - validation_alias="ASKUI_CONTROLLER_PATH", |
46 | | - description="Path to the AskUI Remote Device Controller executable. Takes " |
47 | | - "precedence over ASKUI_COMPONENT_REGISTRY_FILE and ASKUI_INSTALLATION_DIRECTORY" |
48 | | - ".", |
49 | | - ) |
50 | 35 | controller_args: str | None = Field( |
51 | 36 | default="--showOverlay false", |
52 | 37 | description=( |
@@ -92,89 +77,9 @@ def validate_controller_args(cls, value: str) -> str: |
92 | 77 |
|
93 | 78 | return value |
94 | 79 |
|
95 | | - def _find_remote_device_controller_by_installation_directory( |
96 | | - self, |
97 | | - ) -> pathlib.Path | None: |
98 | | - if self.installation_directory is None: |
99 | | - return None |
100 | | - |
101 | | - return self._build_controller_path(self.installation_directory) |
102 | | - |
103 | | - def _build_controller_path( |
104 | | - self, installation_directory: pathlib.Path |
105 | | - ) -> pathlib.Path: |
106 | | - match sys.platform: |
107 | | - case "win32": |
108 | | - return ( |
109 | | - installation_directory |
110 | | - / "Binaries" |
111 | | - / "resources" |
112 | | - / "assets" |
113 | | - / "binaries" |
114 | | - / "AskuiRemoteDeviceController.exe" |
115 | | - ) |
116 | | - case "darwin": |
117 | | - return ( |
118 | | - installation_directory |
119 | | - / "Binaries" |
120 | | - / "askui-ui-controller.app" |
121 | | - / "Contents" |
122 | | - / "Resources" |
123 | | - / "assets" |
124 | | - / "binaries" |
125 | | - / "AskuiRemoteDeviceController" |
126 | | - ) |
127 | | - case "linux": |
128 | | - return ( |
129 | | - installation_directory |
130 | | - / "Binaries" |
131 | | - / "resources" |
132 | | - / "assets" |
133 | | - / "binaries" |
134 | | - / "AskuiRemoteDeviceController" |
135 | | - ) |
136 | | - case _: |
137 | | - error_msg = ( |
138 | | - f'Platform "{sys.platform}" not supported by ' |
139 | | - "AskUI Remote Device Controller" |
140 | | - ) |
141 | | - raise NotImplementedError(error_msg) |
142 | | - |
143 | | - def _find_remote_device_controller_by_component_registry_file( |
144 | | - self, |
145 | | - ) -> pathlib.Path | None: |
146 | | - if self.component_registry_file is None: |
147 | | - return None |
148 | | - |
149 | | - component_registry = AskUiComponentRegistry.model_validate_json( |
150 | | - self.component_registry_file.read_text(encoding="utf-8") |
151 | | - ) |
152 | | - return ( |
153 | | - component_registry.installed_packages.remote_device_controller_uuid.executables.askui_remote_device_controller # noqa: E501 |
154 | | - ) |
155 | | - |
156 | 80 | @cached_property |
157 | 81 | def controller_path(self) -> pathlib.Path: |
158 | | - result = ( |
159 | | - self.controller_path_setting |
160 | | - or self._find_remote_device_controller_by_component_registry_file() |
161 | | - or self._find_remote_device_controller_by_installation_directory() |
162 | | - ) |
163 | | - if result is None: |
164 | | - error_msg = ( |
165 | | - "No AskUI Remote Device Controller found. Please set the " |
166 | | - "ASKUI_COMPONENT_REGISTRY_FILE, ASKUI_INSTALLATION_DIRECTORY, or " |
167 | | - "ASKUI_CONTROLLER_PATH environment variable." |
168 | | - ) |
169 | | - raise ValueError(error_msg) |
170 | | - |
171 | | - if not result.is_file(): |
172 | | - error_msg = ( |
173 | | - "AskUIRemoteDeviceController executable does not exist under " |
174 | | - f"`{result}`" |
175 | | - ) |
176 | | - raise FileNotFoundError(error_msg) |
177 | | - return result |
| 82 | + return AgentOS.controller_path() |
178 | 83 |
|
179 | 84 |
|
180 | 85 | __all__ = ["AskUiControllerSettings"] |
0 commit comments