forgexa-cli 1.98.4__tar.gz → 1.98.6__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.
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/PKG-INFO +1 -1
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/__init__.py +1 -1
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/agent_core.py +1 -1
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/component_runtime.py +65 -9
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/daemon.py +1 -1
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/zcode_protocol.py +34 -16
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli.egg-info/PKG-INFO +1 -1
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/pyproject.toml +1 -1
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/README.md +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/_build_config.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/_local_bind.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/autoupgrade.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/aws_evidence.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/aws_logs_evidence.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/main.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/observability_contract.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/observability_evidence.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/ocr_adapter.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/py.typed +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/runtime_evidence.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli/workspace_storage.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli.egg-info/SOURCES.txt +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli.egg-info/dependency_links.txt +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli.egg-info/entry_points.txt +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli.egg-info/requires.txt +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/forgexa_cli.egg-info/top_level.txt +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/setup.cfg +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/tests/test_auth_and_runtime_commands.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/tests/test_autoupgrade.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/tests/test_check_command.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/tests/test_expiry_warnings_and_revoke.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/tests/test_local_bind_commands.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/tests/test_publish_script.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/tests/test_runtime_credentials.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/tests/test_session_credentials.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/tests/test_silent_install.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/tests/test_upgrade_observability.py +0 -0
- {forgexa_cli-1.98.4 → forgexa_cli-1.98.6}/tests/test_workspace_storage.py +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""forgexa-cli — Forgexa command-line client."""
|
|
2
|
-
__version__ = "1.98.
|
|
2
|
+
__version__ = "1.98.6"
|
|
@@ -2096,7 +2096,7 @@ class AgentDiscovery:
|
|
|
2096
2096
|
current_set = set(current.split(os.pathsep))
|
|
2097
2097
|
additions = [str(d) for d in extra_dirs if d.is_dir() and str(d) not in current_set]
|
|
2098
2098
|
if additions:
|
|
2099
|
-
os.environ["PATH"] = os.pathsep.join(additions)
|
|
2099
|
+
os.environ["PATH"] = os.pathsep.join(filter(None, (current, *additions)))
|
|
2100
2100
|
logger.debug("Expanded PATH with: %s", ", ".join(additions))
|
|
2101
2101
|
for component in (*AgentDiscovery.AGENT_REGISTRY, "forgexa.ocr"):
|
|
2102
2102
|
official_base = home / ".forgexa" / "official" / component
|
|
@@ -931,6 +931,27 @@ def _valid_external_selection_path(path: Any) -> bool:
|
|
|
931
931
|
)
|
|
932
932
|
|
|
933
933
|
|
|
934
|
+
def _wsl_external_selection(component_id: str) -> dict[str, Any] | None:
|
|
935
|
+
base = Path.home() / ".forgexa" / "wsl-workspace"
|
|
936
|
+
path = base / f"component-{component_id}.json"
|
|
937
|
+
try:
|
|
938
|
+
path.lstat()
|
|
939
|
+
except FileNotFoundError:
|
|
940
|
+
return None
|
|
941
|
+
for directory, private in ((base.parent, False), (base, True)):
|
|
942
|
+
metadata = directory.lstat()
|
|
943
|
+
if (not stat.S_ISDIR(metadata.st_mode) or metadata.st_uid != os.getuid()
|
|
944
|
+
or metadata.st_mode & (0o077 if private else 0o022)):
|
|
945
|
+
raise ComponentRuntimeError("component_storage_invalid")
|
|
946
|
+
selection = _record(path, {"schema_version", "component_id", "revision", "enabled", "external_path"})
|
|
947
|
+
if (selection is None or selection["component_id"] != component_id
|
|
948
|
+
or type(selection["revision"]) is not int or not 1 <= selection["revision"] <= 9_007_199_254_740_991
|
|
949
|
+
or type(selection["enabled"]) is not bool
|
|
950
|
+
or (selection["external_path"] is not None and not _valid_external_selection_path(selection["external_path"]))):
|
|
951
|
+
raise ComponentRuntimeError("component_selection_invalid")
|
|
952
|
+
return selection
|
|
953
|
+
|
|
954
|
+
|
|
934
955
|
def _acquire_component(
|
|
935
956
|
component_id: str, root: Path | None = None, override: str | None = None,
|
|
936
957
|
kind: str = "agent",
|
|
@@ -941,9 +962,17 @@ def _acquire_component(
|
|
|
941
962
|
root = default_store_root() if root is None else root
|
|
942
963
|
if root.is_symlink():
|
|
943
964
|
raise ComponentRuntimeError("component_storage_invalid")
|
|
965
|
+
if os.name == "posix" and os.environ.get("WSL_DISTRO_NAME"):
|
|
966
|
+
if root.exists():
|
|
967
|
+
_require_absent_unverified_selection(root, component_id)
|
|
968
|
+
if kind == "agent":
|
|
969
|
+
selection = _wsl_external_selection(component_id)
|
|
970
|
+
if selection is not None and not selection["enabled"]:
|
|
971
|
+
raise ComponentRuntimeError("component_disabled")
|
|
972
|
+
return None
|
|
944
973
|
if not root.exists():
|
|
945
974
|
return None
|
|
946
|
-
if os.name != "posix"
|
|
975
|
+
if os.name != "posix":
|
|
947
976
|
_require_absent_unverified_selection(root, component_id)
|
|
948
977
|
return None
|
|
949
978
|
import fcntl
|
|
@@ -1117,10 +1146,19 @@ def selected_external_agent_selection(component_id: str, root: Path | None = Non
|
|
|
1117
1146
|
root = default_store_root() if root is None else root
|
|
1118
1147
|
if root.is_symlink():
|
|
1119
1148
|
raise ComponentRuntimeError("component_storage_invalid")
|
|
1120
|
-
if not root.exists():
|
|
1121
|
-
return None, None
|
|
1122
1149
|
try:
|
|
1123
|
-
if os.name
|
|
1150
|
+
if os.name == "posix" and os.environ.get("WSL_DISTRO_NAME"):
|
|
1151
|
+
if root.exists():
|
|
1152
|
+
_require_absent_unverified_selection(root, component_id)
|
|
1153
|
+
selection = _wsl_external_selection(component_id)
|
|
1154
|
+
if selection is not None:
|
|
1155
|
+
if not selection["enabled"]:
|
|
1156
|
+
raise ComponentRuntimeError("component_disabled")
|
|
1157
|
+
return selection["external_path"], selection["revision"]
|
|
1158
|
+
return None, None
|
|
1159
|
+
if not root.exists():
|
|
1160
|
+
return None, None
|
|
1161
|
+
if os.name != "posix":
|
|
1124
1162
|
_require_absent_unverified_selection(root, component_id)
|
|
1125
1163
|
return None, None
|
|
1126
1164
|
with _ComponentManagerLock(root):
|
|
@@ -1155,9 +1193,18 @@ def require_unselected_component(component_id: str, root: Path | None = None) ->
|
|
|
1155
1193
|
root = default_store_root() if root is None else root
|
|
1156
1194
|
if root.is_symlink():
|
|
1157
1195
|
raise ComponentRuntimeError("component_storage_invalid")
|
|
1196
|
+
if os.name == "posix" and os.environ.get("WSL_DISTRO_NAME"):
|
|
1197
|
+
try:
|
|
1198
|
+
if root.exists():
|
|
1199
|
+
_require_absent_unverified_selection(root, component_id)
|
|
1200
|
+
if _wsl_external_selection(component_id) is not None:
|
|
1201
|
+
raise ComponentRuntimeError("component_selection_changed")
|
|
1202
|
+
except OSError as error:
|
|
1203
|
+
raise ComponentRuntimeError("component_storage_unavailable") from error
|
|
1204
|
+
return
|
|
1158
1205
|
if not root.exists():
|
|
1159
1206
|
return
|
|
1160
|
-
if os.name != "posix"
|
|
1207
|
+
if os.name != "posix":
|
|
1161
1208
|
try:
|
|
1162
1209
|
_require_absent_unverified_selection(root, component_id)
|
|
1163
1210
|
except OSError as error:
|
|
@@ -1188,11 +1235,20 @@ def require_external_selection(
|
|
|
1188
1235
|
root = default_store_root() if root is None else root
|
|
1189
1236
|
if root.is_symlink():
|
|
1190
1237
|
raise ComponentRuntimeError("component_storage_invalid")
|
|
1191
|
-
if not root.exists():
|
|
1192
|
-
raise ComponentRuntimeError("component_selection_changed")
|
|
1193
|
-
if os.name != "posix" or os.environ.get("WSL_DISTRO_NAME"):
|
|
1194
|
-
raise ComponentRuntimeError("component_platform_unverified")
|
|
1195
1238
|
try:
|
|
1239
|
+
if os.name == "posix" and os.environ.get("WSL_DISTRO_NAME"):
|
|
1240
|
+
if root.exists():
|
|
1241
|
+
_require_absent_unverified_selection(root, component_id)
|
|
1242
|
+
selection = _wsl_external_selection(component_id)
|
|
1243
|
+
if component_id != "forgexa.ocr" or selection is None or selection["revision"] != revision:
|
|
1244
|
+
raise ComponentRuntimeError("component_selection_changed")
|
|
1245
|
+
if not selection["enabled"] and not allow_disabled:
|
|
1246
|
+
raise ComponentRuntimeError("component_disabled")
|
|
1247
|
+
return selection["external_path"]
|
|
1248
|
+
if not root.exists():
|
|
1249
|
+
raise ComponentRuntimeError("component_selection_changed")
|
|
1250
|
+
if os.name != "posix":
|
|
1251
|
+
raise ComponentRuntimeError("component_platform_unverified")
|
|
1196
1252
|
with _ComponentManagerLock(root):
|
|
1197
1253
|
target = _component_target(root)
|
|
1198
1254
|
selection = _record(
|
|
@@ -1412,7 +1412,7 @@ except (ImportError, ModuleNotFoundError):
|
|
|
1412
1412
|
# DAEMON_VERSION is the protocol/logic version of the daemon code.
|
|
1413
1413
|
# Kept in sync with pyproject.toml version via bump-version.sh.
|
|
1414
1414
|
# CLIENT_TYPE identifies which packaging/distribution this daemon runs in.
|
|
1415
|
-
DAEMON_VERSION = "1.98.
|
|
1415
|
+
DAEMON_VERSION = "1.98.6"
|
|
1416
1416
|
|
|
1417
1417
|
|
|
1418
1418
|
def _detect_client_type() -> str:
|
|
@@ -149,13 +149,19 @@ class ZCodeProtocolSession:
|
|
|
149
149
|
on_event: EventHandler | None = None,
|
|
150
150
|
permission_handler: PermissionHandler | None = None,
|
|
151
151
|
component_lease: agent_core.component_runtime.ManagedComponentLease | None = None,
|
|
152
|
+
spawn_process: Callable[[list[str], dict[str, str] | None], Awaitable[Any]] | None = None,
|
|
153
|
+
stop_process: Callable[[Any], Awaitable[str]] | None = None,
|
|
152
154
|
) -> None:
|
|
155
|
+
if (spawn_process is None) != (stop_process is None) or (spawn_process is not None and component_lease is not None):
|
|
156
|
+
raise ValueError("ZCode process supervision is incomplete")
|
|
153
157
|
self.command = list(command)
|
|
154
158
|
self.cwd = str(cwd)
|
|
155
159
|
self.env = dict(env) if env is not None else None
|
|
156
160
|
self.on_event = on_event
|
|
157
161
|
self.permission_handler = permission_handler
|
|
158
162
|
self.component_lease = component_lease
|
|
163
|
+
self._spawn_process = spawn_process
|
|
164
|
+
self._stop_process = stop_process
|
|
159
165
|
self.session_id: str | None = None
|
|
160
166
|
self.protocol_version: int | None = None
|
|
161
167
|
self._process: asyncio.subprocess.Process | None = None
|
|
@@ -198,16 +204,19 @@ class ZCodeProtocolSession:
|
|
|
198
204
|
process_env = {**(process_env if process_env is not None else os.environ),
|
|
199
205
|
"DISABLE_UPDATES": "1", "DISABLE_AUTOUPDATER": "1"}
|
|
200
206
|
await asyncio.to_thread(self.component_lease.begin_spawn)
|
|
201
|
-
self.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
if self._spawn_process is not None:
|
|
208
|
+
self._process = await self._spawn_process(command, process_env)
|
|
209
|
+
else:
|
|
210
|
+
self._process = await asyncio.create_subprocess_exec(
|
|
211
|
+
*command,
|
|
212
|
+
stdin=asyncio.subprocess.PIPE,
|
|
213
|
+
stdout=asyncio.subprocess.PIPE,
|
|
214
|
+
stderr=asyncio.subprocess.PIPE,
|
|
215
|
+
cwd=self.cwd,
|
|
216
|
+
env=process_env,
|
|
217
|
+
limit=1_048_576,
|
|
218
|
+
**agent_core._agent_process_group_kwargs(),
|
|
219
|
+
)
|
|
211
220
|
if self.component_lease is not None:
|
|
212
221
|
await asyncio.to_thread(self.component_lease.record_process, self._process.pid)
|
|
213
222
|
self._reader_task = asyncio.create_task(self._read_loop())
|
|
@@ -399,15 +408,24 @@ class ZCodeProtocolSession:
|
|
|
399
408
|
self._active_turn.set_exception(ZCodeProtocolError("ZCode Protocol session closed"))
|
|
400
409
|
self._fail_pending(ZCodeProtocolError("ZCode Protocol session closed"))
|
|
401
410
|
process = self._process
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
411
|
+
cleanup_confirmed = True
|
|
412
|
+
if process is not None:
|
|
413
|
+
if self._stop_process is not None:
|
|
414
|
+
try:
|
|
415
|
+
cleanup_confirmed = await self._stop_process(process) == "terminated"
|
|
416
|
+
except (OSError, ValueError, RuntimeError, asyncio.TimeoutError):
|
|
417
|
+
cleanup_confirmed = False
|
|
418
|
+
elif process.returncode is None:
|
|
419
|
+
agent_core._kill_proc(process)
|
|
420
|
+
try:
|
|
421
|
+
await asyncio.wait_for(process.wait(), timeout=5)
|
|
422
|
+
except (asyncio.TimeoutError, ProcessLookupError):
|
|
423
|
+
pass
|
|
408
424
|
for task in (self._reader_task, self._stderr_task):
|
|
409
425
|
if task is not None and not task.done():
|
|
410
426
|
task.cancel()
|
|
427
|
+
if not cleanup_confirmed:
|
|
428
|
+
raise ZCodeProtocolError("ZCode process cleanup is unconfirmed")
|
|
411
429
|
if self.component_lease is not None and process is not None and process.returncode is None:
|
|
412
430
|
raise agent_core.component_runtime.ComponentRuntimeError(
|
|
413
431
|
"component_process_cleanup_unconfirmed"
|
|
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
|