The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: a Windows Startup-folder install no longer blocks restarting a stopped owner
Teknium14cb3d32de6d
diff --git a/hermes_cli/gateway_runtime_service.py b/hermes_cli/gateway_runtime_service.pyindex 60d70a07f93..47690468ebb 100644--- a/hermes_cli/gateway_runtime_service.py+++ b/hermes_cli/gateway_runtime_service.py@@ -185,7 +185,7 @@ def _launchd(home: Path, deadline: float) -> ExistingService | None:def _windows(home: Path, deadline: float) -> ExistingService | None:- from hermes_cli.gateway_windows import _startup_dir, _schtasks_encoding+ from hermes_cli.gateway_windows import _schtasks_encodingsuffix = service_suffix(home)name = f"Hermes_Gateway{'_' + suffix if suffix else ''}"result = _run(["schtasks.exe", "/Query", "/FO", "CSV", "/NH"], deadline, encoding=_schtasks_encoding())@@ -205,10 +205,11 @@ def _windows(home: Path, deadline: float) -> ExistingService | None:raise RuntimeStartError("service_identity_unverified")_verify_binding(verify_windows_task, definition.stdout, home, *accounts[0])return ExistingService("windows", ("schtasks.exe", "/Run", "/TN", name))- # Startup-folder entries are installed persistence too, but have no independent- # start supervisor. Do not bypass them with a job-bound unmanaged child.- if any(_exists(_startup_dir() / f"{name}.{ext}") for ext in ("cmd", "vbs")):- raise RuntimeStartError("startup_service_requires_login")+ # A Startup-folder entry (the fallback when Scheduled Task install was declined/blocked) is login+ # persistence only, with no start verb or identity to verify. Starting a stopped owner is the+ # same detached direct spawn manual `hermes gateway start` uses beside it; the unmanaged path+ # pins the explicit home and refuses a job-bound (no-breakaway) child, and the runtime lock+ # plus host attach arbitrate against the entry firing again at the next login.return Nonediff --git a/tests/hermes_cli/test_gateway_runtime_service.py b/tests/hermes_cli/test_gateway_runtime_service.pyindex 06834e484cb..69031de85ca 100644--- a/tests/hermes_cli/test_gateway_runtime_service.py+++ b/tests/hermes_cli/test_gateway_runtime_service.py@@ -313,3 +313,28 @@ def test_android_python_reaches_the_unmanaged_start(tmp_path, monkeypatch):result = runtime.ensure_gateway_runtime(home, timeout=0.3)assert result.reason_code != "unsupported_supervisor_platform"assert spawned == [home.resolve()]+++def test_windows_startup_folder_entry_still_restarts_a_stopped_owner(tmp_path, monkeypatch):+ """The Startup-folder fallback is login persistence only (no start verb, no identity): with it+ present and no Scheduled Task registered, ensure takes the same detached direct spawn manual+ `hermes gateway start` uses instead of refusing until the next login."""+ from types import SimpleNamespace+ from hermes_cli import gateway_runtime as runtime, gateway_runtime_service as service, gateway_runtime_start as start+ from hermes_cli import gateway_windows++ home = tmp_path / "profile"+ home.mkdir(mode=0o700)+ startup = tmp_path / "Startup"+ startup.mkdir()+ (startup / f"Hermes_Gateway_{service.service_suffix(home)}.vbs").write_text("' fallback\r\n")+ monkeypatch.setattr(gateway_windows, "_startup_dir", lambda: startup)+ queries, spawned = [], []+ monkeypatch.setattr(service, "_run", lambda argv, *a, **k: queries.append(argv) or SimpleNamespace(returncode=0, stdout=""))+ monkeypatch.setattr(service.sys, "platform", "win32")+ monkeypatch.setattr(runtime, "discover_gateway_endpoint", lambda *a, **k: runtime.GatewayDiscovery("absent"))+ monkeypatch.setattr(start, "spawn_unmanaged_gateway", lambda target, **k: spawned.append(Path(target)))+ result = runtime.ensure_gateway_runtime(home, timeout=0.3)+ assert result.reason_code != "startup_service_requires_login"+ assert spawned == [home.resolve()]+ assert all(argv[:2] == ["schtasks.exe", "/Query"] for argv in queries) # nothing installed or run