mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-03 01:07:31 +08:00
fix(plugins): await async handlers in CLI and TUI dispatch
This commit is contained in:
@@ -21,6 +21,7 @@ from hermes_cli.plugins import (
|
||||
get_plugin_command_handler,
|
||||
get_plugin_commands,
|
||||
get_pre_tool_call_block_message,
|
||||
resolve_plugin_command_result,
|
||||
discover_plugins,
|
||||
invoke_hook,
|
||||
)
|
||||
@@ -1061,6 +1062,27 @@ class TestPluginCommands:
|
||||
assert mgr._plugin_commands["cmd-b"]["plugin"] == "plugin-b"
|
||||
|
||||
|
||||
class TestPluginCommandResultResolution:
|
||||
def test_returns_sync_values_unchanged(self):
|
||||
assert resolve_plugin_command_result("ok") == "ok"
|
||||
|
||||
def test_awaits_async_result_without_running_loop(self):
|
||||
async def _handler():
|
||||
return "async-ok"
|
||||
|
||||
assert resolve_plugin_command_result(_handler()) == "async-ok"
|
||||
|
||||
def test_awaits_async_result_with_running_loop(self, monkeypatch):
|
||||
class _Loop:
|
||||
pass
|
||||
|
||||
async def _handler():
|
||||
return "threaded-ok"
|
||||
|
||||
monkeypatch.setattr("hermes_cli.plugins.asyncio.get_running_loop", lambda: _Loop())
|
||||
assert resolve_plugin_command_result(_handler()) == "threaded-ok"
|
||||
|
||||
|
||||
# ── TestPluginDispatchTool ────────────────────────────────────────────────
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user