simplify(compat): repoint the last stragglers (run_agent computer_use import, 8 test files patching old facade paths)
This commit is contained in:
@@ -931,7 +931,7 @@ class AIAgent(
|
||||
process_registry.kill_all(task_id=task_id)
|
||||
|
||||
def release_computer_use() -> None:
|
||||
from tools.computer_use import release_computer_use_session
|
||||
from tools.computer_use.tool import release_computer_use_session
|
||||
release_computer_use_session(task_id)
|
||||
|
||||
for step in (kill_processes, lambda: cleanup_vm(task_id), lambda: cleanup_browser(task_id), release_computer_use):
|
||||
|
||||
@@ -127,7 +127,7 @@ def test_try_dispatch_background_run_calls_recovery_before_claiming(monkeypatch)
|
||||
"gateway.session_context.async_delivery_supported", lambda: True
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"tools.approval.get_current_session_key", lambda default="": ""
|
||||
"tools.approval_context.get_current_session_key", lambda default="": ""
|
||||
)
|
||||
|
||||
job = {"id": "unit-test-job", "name": "unit test job", "deliver": "local"}
|
||||
|
||||
@@ -82,7 +82,7 @@ def _patch_update_deps(monkeypatch, tmp_path, run_side_effect):
|
||||
"_get_origin_url",
|
||||
lambda *a, **k: "https://github.com/NousResearch/hermes-agent.git",
|
||||
)
|
||||
monkeypatch.setattr(hermes_main, "_is_fork", lambda *a, **k: False)
|
||||
monkeypatch.setattr(update_cmd, "_is_fork", lambda *a, **k: False)
|
||||
monkeypatch.setattr(
|
||||
hermes_main, "_stash_local_changes_if_needed", lambda *a, **k: None
|
||||
)
|
||||
@@ -99,8 +99,7 @@ def _patch_update_deps(monkeypatch, tmp_path, run_side_effect):
|
||||
)
|
||||
monkeypatch.setattr(hermes_main, "_write_update_incomplete_marker", lambda: None)
|
||||
monkeypatch.setattr(hermes_main, "_clear_update_incomplete_marker", lambda: None)
|
||||
monkeypatch.setattr(
|
||||
hermes_main, "_finish_dashboard_update_cleanup", lambda *a, **k: None
|
||||
monkeypatch.setattr(update_cmd, "_finish_dashboard_update_cleanup", lambda *a, **k: None
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
update_cmd, "_finish_dashboard_update_cleanup", lambda *a, **k: None
|
||||
|
||||
@@ -21,6 +21,7 @@ from types import SimpleNamespace
|
||||
import pytest
|
||||
|
||||
import hermes_cli.main as main_mod
|
||||
from hermes_cli import update_cmd
|
||||
from hermes_cli.main import cmd_update
|
||||
|
||||
|
||||
@@ -62,7 +63,7 @@ def _run_cmd_update(monkeypatch, impl, *, reexec: bool):
|
||||
monkeypatch.setattr("hermes_cli.config.is_managed", lambda: False)
|
||||
monkeypatch.setattr("hermes_cli.config.detect_install_method", lambda root: "git")
|
||||
monkeypatch.setattr("hermes_cli.update_lock.UpdateLock", lambda: _FakeLock(events["order"]))
|
||||
monkeypatch.setattr(main_mod, "_cmd_update_impl", fake_impl)
|
||||
monkeypatch.setattr(update_cmd, "_cmd_update_impl", fake_impl)
|
||||
monkeypatch.setattr(main_mod, "_install_hangup_protection", lambda gateway_mode=False: None)
|
||||
monkeypatch.setattr(main_mod, "_finalize_update_output", fake_finalize_io)
|
||||
monkeypatch.setattr("hermes_cli.update_receipt.finalize_pending_update_receipt", fake_receipt)
|
||||
|
||||
@@ -14,6 +14,7 @@ from types import SimpleNamespace
|
||||
import pytest
|
||||
|
||||
from hermes_cli import main as hermes_main
|
||||
from hermes_cli import update_cmd
|
||||
|
||||
|
||||
def _make_head_moved_side_effect(pre_sha="abc123", post_sha="def456"):
|
||||
@@ -83,7 +84,7 @@ def _patch_update_deps(monkeypatch, tmp_path, run_side_effect):
|
||||
hermes_main, "_get_origin_url",
|
||||
lambda *a, **k: "https://github.com/NousResearch/hermes-agent.git",
|
||||
)
|
||||
monkeypatch.setattr(hermes_main, "_is_fork", lambda *a, **k: False)
|
||||
monkeypatch.setattr(update_cmd, "_is_fork", lambda *a, **k: False)
|
||||
monkeypatch.setattr(
|
||||
hermes_main, "_stash_local_changes_if_needed", lambda *a, **k: None
|
||||
)
|
||||
@@ -104,7 +105,7 @@ def _patch_update_deps(monkeypatch, tmp_path, run_side_effect):
|
||||
monkeypatch.setattr(hermes_main, "_write_update_incomplete_marker", lambda: None)
|
||||
monkeypatch.setattr(hermes_main, "_clear_update_incomplete_marker", lambda: None)
|
||||
# Gateway restart path (called after a successful update).
|
||||
monkeypatch.setattr(hermes_main, "_finish_dashboard_update_cleanup", lambda *a: None)
|
||||
monkeypatch.setattr(update_cmd, "_finish_dashboard_update_cleanup", lambda *a: None)
|
||||
# Keep the (now surfaced — #78574) gateway auto-restart phase away from
|
||||
# this machine's real gateways: discovery returns nothing, systemd is
|
||||
# unsupported, so the phase is a clean no-op for both snapshots.
|
||||
|
||||
@@ -255,8 +255,8 @@ def _patch_update_flow(monkeypatch, repo, run_real_git=True):
|
||||
hermes_main, "_get_origin_url",
|
||||
lambda *a, **k: "https://github.com/NousResearch/hermes-agent.git",
|
||||
)
|
||||
monkeypatch.setattr(hermes_main, "_is_fork", lambda *a, **k: False)
|
||||
monkeypatch.setattr(hermes_main, "_discard_lockfile_churn", lambda *a, **k: None)
|
||||
monkeypatch.setattr(update_cmd, "_is_fork", lambda *a, **k: False)
|
||||
monkeypatch.setattr(update_cmd, "_discard_lockfile_churn", lambda *a, **k: None)
|
||||
monkeypatch.setattr(update_cmd, "_discard_lockfile_churn", lambda *a, **k: None)
|
||||
monkeypatch.setattr(update_cmd, "_normalize_managed_eol", lambda *a, **k: None)
|
||||
monkeypatch.setattr(hermes_main, "_clear_bytecode_cache", lambda *a, **k: 0)
|
||||
|
||||
@@ -17,6 +17,7 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
import hermes_cli.update_receipt as ur
|
||||
from hermes_cli import update_cmd
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@@ -217,7 +218,7 @@ class TestCommandBoundaryFinalization:
|
||||
ur.record_step("windows_preflight", False, "hermes.exe holds venv")
|
||||
sys.exit(2)
|
||||
|
||||
monkeypatch.setattr(hermes_main, "_cmd_update_impl", _fake_impl)
|
||||
monkeypatch.setattr(update_cmd, "_cmd_update_impl", _fake_impl)
|
||||
monkeypatch.setattr(
|
||||
hermes_main, "detect_install_method", lambda *a, **k: "git", raising=False
|
||||
)
|
||||
|
||||
@@ -11,6 +11,8 @@ from types import SimpleNamespace
|
||||
import pytest
|
||||
|
||||
from hermes_cli import resource_limits
|
||||
from hermes_cli import dashboard_procs
|
||||
from hermes_cli import main_dashboard
|
||||
|
||||
|
||||
class _FakeResource:
|
||||
@@ -270,7 +272,7 @@ def test_named_profile_reroute_defers_limit_to_final_process(monkeypatch, tmp_pa
|
||||
"get_active_profile_name",
|
||||
lambda: "worker",
|
||||
)
|
||||
monkeypatch.setattr(cli_main, "_dashboard_listening", lambda *args: False)
|
||||
monkeypatch.setattr(main_dashboard, "_dashboard_listening", lambda *args: False)
|
||||
monkeypatch.setattr(
|
||||
local_environment,
|
||||
"build_subprocess_env",
|
||||
@@ -325,7 +327,7 @@ def test_dashboard_lifecycle_flags_skip_limit_adjustment(monkeypatch, lifecycle_
|
||||
"apply_nofile_soft_limit",
|
||||
lambda: calls.append("limit"),
|
||||
)
|
||||
monkeypatch.setattr(cli_main, "_scan_dashboard_processes", lambda: [])
|
||||
monkeypatch.setattr(dashboard_procs, "_scan_dashboard_processes", lambda: [])
|
||||
monkeypatch.setattr(cli_main, "_find_stale_dashboard_pids", lambda: [])
|
||||
|
||||
args = SimpleNamespace(
|
||||
|
||||
@@ -95,8 +95,8 @@ def test_shell_exec_uses_utf8_replace():
|
||||
handler = server._methods["shell.exec"]
|
||||
with patch("subprocess.run", return_value=_make_completed_process()) as mock_run:
|
||||
# A harmless, non-dangerous command that passes the approval gate.
|
||||
with patch("tools.approval.detect_hardline_command", return_value=(False, "")), \
|
||||
patch("tools.approval.detect_dangerous_command", return_value=(False, None, "")):
|
||||
with patch("tools.approval_detection.detect_hardline_command", return_value=(False, "")), \
|
||||
patch("tools.approval_detection.detect_dangerous_command", return_value=(False, None, "")):
|
||||
resp = handler(1, {"command": "echo hello"})
|
||||
assert mock_run.called, "subprocess.run was not invoked"
|
||||
kwargs = mock_run.call_args[1]
|
||||
|
||||
Reference in New Issue
Block a user