mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-29 06:31:32 +00:00
refactor(restructure): rewrite all imports for hermes_agent package
Rewrite all import statements, patch() targets, sys.modules keys, importlib.import_module() strings, and subprocess -m references to use hermes_agent.* paths. Strip sys.path.insert hacks from production code (rely on editable install). Update COMPONENT_PREFIXES for logger filtering. Fix 3 hardcoded getLogger() calls to use __name__. Update transport and tool registry discovery paths. Update plugin module path strings. Add legacy process-name patterns for gateway PID detection. Add main() to skills_sync for console_script entry point. Fix _get_bundled_dir() path traversal after move. Part of #14182, #14183
This commit is contained in:
parent
65ca3ba93b
commit
4b16341975
898 changed files with 12494 additions and 12019 deletions
|
|
@ -16,7 +16,7 @@ import pytest
|
|||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from tools.process_registry import (
|
||||
from hermes_agent.tools.process_registry import (
|
||||
ProcessRegistry,
|
||||
ProcessSession,
|
||||
)
|
||||
|
|
@ -184,7 +184,7 @@ class TestCompletionQueue:
|
|||
|
||||
class TestCheckpointNotify:
|
||||
def test_checkpoint_includes_notify(self, registry, tmp_path):
|
||||
with patch("tools.process_registry.CHECKPOINT_PATH", tmp_path / "procs.json"):
|
||||
with patch("hermes_agent.tools.process_registry.CHECKPOINT_PATH", tmp_path / "procs.json"):
|
||||
s = _make_session(notify_on_complete=True)
|
||||
registry._running[s.id] = s
|
||||
registry._write_checkpoint()
|
||||
|
|
@ -194,7 +194,7 @@ class TestCheckpointNotify:
|
|||
assert data[0]["notify_on_complete"] is True
|
||||
|
||||
def test_checkpoint_without_notify(self, registry, tmp_path):
|
||||
with patch("tools.process_registry.CHECKPOINT_PATH", tmp_path / "procs.json"):
|
||||
with patch("hermes_agent.tools.process_registry.CHECKPOINT_PATH", tmp_path / "procs.json"):
|
||||
s = _make_session(notify_on_complete=False)
|
||||
registry._running[s.id] = s
|
||||
registry._write_checkpoint()
|
||||
|
|
@ -211,7 +211,7 @@ class TestCheckpointNotify:
|
|||
"task_id": "t1",
|
||||
"notify_on_complete": True,
|
||||
}]))
|
||||
with patch("tools.process_registry.CHECKPOINT_PATH", checkpoint):
|
||||
with patch("hermes_agent.tools.process_registry.CHECKPOINT_PATH", checkpoint):
|
||||
recovered = registry.recover_from_checkpoint()
|
||||
assert recovered == 1
|
||||
s = registry.get("proc_live")
|
||||
|
|
@ -233,7 +233,7 @@ class TestCheckpointNotify:
|
|||
"watcher_interval": 5,
|
||||
"notify_on_complete": True,
|
||||
}]))
|
||||
with patch("tools.process_registry.CHECKPOINT_PATH", checkpoint):
|
||||
with patch("hermes_agent.tools.process_registry.CHECKPOINT_PATH", checkpoint):
|
||||
recovered = registry.recover_from_checkpoint()
|
||||
assert recovered == 1
|
||||
assert len(registry.pending_watchers) == 1
|
||||
|
|
@ -250,7 +250,7 @@ class TestCheckpointNotify:
|
|||
"pid": os.getpid(),
|
||||
"task_id": "t1",
|
||||
}]))
|
||||
with patch("tools.process_registry.CHECKPOINT_PATH", checkpoint):
|
||||
with patch("hermes_agent.tools.process_registry.CHECKPOINT_PATH", checkpoint):
|
||||
recovered = registry.recover_from_checkpoint()
|
||||
assert recovered == 1
|
||||
s = registry.get("proc_live")
|
||||
|
|
@ -263,7 +263,7 @@ class TestCheckpointNotify:
|
|||
|
||||
class TestTerminalSchema:
|
||||
def test_schema_has_notify_on_complete(self):
|
||||
from tools.terminal_tool import TERMINAL_SCHEMA
|
||||
from hermes_agent.tools.terminal import TERMINAL_SCHEMA
|
||||
props = TERMINAL_SCHEMA["parameters"]["properties"]
|
||||
assert "notify_on_complete" in props
|
||||
assert props["notify_on_complete"]["type"] == "boolean"
|
||||
|
|
@ -271,8 +271,8 @@ class TestTerminalSchema:
|
|||
|
||||
def test_handler_passes_notify(self):
|
||||
"""_handle_terminal passes notify_on_complete to terminal_tool."""
|
||||
from tools.terminal_tool import _handle_terminal
|
||||
with patch("tools.terminal_tool.terminal_tool", return_value='{"ok":true}') as mock_tt:
|
||||
from hermes_agent.tools.terminal import _handle_terminal
|
||||
with patch("hermes_agent.tools.terminal.terminal_tool", return_value='{"ok":true}') as mock_tt:
|
||||
_handle_terminal(
|
||||
{"command": "echo hi", "background": True, "notify_on_complete": True},
|
||||
task_id="t1",
|
||||
|
|
@ -287,7 +287,7 @@ class TestTerminalSchema:
|
|||
|
||||
class TestCodeExecutionBlocked:
|
||||
def test_notify_on_complete_blocked_in_sandbox(self):
|
||||
from tools.code_execution_tool import _TERMINAL_BLOCKED_PARAMS
|
||||
from hermes_agent.tools.code_execution import _TERMINAL_BLOCKED_PARAMS
|
||||
assert "notify_on_complete" in _TERMINAL_BLOCKED_PARAMS
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue