mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-02 02:01:47 +00:00
feat(plugins): bundled platform plugins auto-load by default
Platform plugins shipped in-repo under plugins/platforms/ should be
available out of the box — users shouldn't have to add 'irc-platform'
to plugins.enabled before they can pick IRC from the gateway setup menu.
Adds a new ``kind: platform`` plugin type that mirrors the existing
``kind: backend`` auto-load semantics:
- Bundled (shipped in the hermes-agent repo): auto-load unconditionally.
- User-installed (~/.hermes/plugins/): still opt-in via plugins.enabled
so untrusted code doesn't silently run.
Changes:
* hermes_cli/plugins.py: add 'platform' to _VALID_PLUGIN_KINDS, document
the new kind in the PluginManifest docstring, extend the bundled auto-
load rule from 'backend only' to 'backend or platform'.
* plugins/platforms/irc/plugin.yaml: declare kind: platform.
* hermes_cli/gateway.py: remove the now-redundant
_load_bundled_platform_plugins_for_enumeration() helper and the
_enable_plugin_for_platform() helper. The setup menu's _all_platforms()
just calls discover_plugins() and reads the registry — bundled
platforms are already loaded at that point. Drops the 'needs_enable'
flag and the 'plugin disabled — select to enable' status string.
* hermes_cli/setup.py: relax the "gateway is configured" detector used
during OpenClaw migration. Switching to _platform_status() in an
earlier commit tightened the check to require an exact "configured"
match, dropping platforms whose status is "enabled, not paired",
"partially configured", "configured + E2EE", etc. Now any non-"not
configured" status counts — the user has already started setup there
and we shouldn't force the section to rerun.
* tests/hermes_cli/test_setup_irc.py: drop the TestIRCPluginDisabledFlow
class and test_configure_platform_enables_disabled_plugin_first — the
no-longer-existent flow they were testing.
* tests/hermes_cli/test_setup_openclaw_migration.py: patch both
setup.get_env_value and gateway.get_env_value in the 4 gateway-section
tests that reach _platform_status() through the unified setup flow;
switch WHATSAPP_ENABLED to the literal "true" in the registry-parity
test so WhatsApp's value-shape validator matches.
Verified via fresh-install smoke (empty plugins.enabled, no env vars):
IRC plugin loads, Platform('irc') resolves, _all_platforms() lists IRC
with status 'not configured'. 160 targeted tests pass.
This commit is contained in:
parent
71c8ca17dc
commit
4d363499db
6 changed files with 53 additions and 190 deletions
|
|
@ -419,7 +419,12 @@ class TestGetSectionConfigSummary:
|
|||
return "disc456"
|
||||
return ""
|
||||
|
||||
with patch.object(setup_mod, "get_env_value", side_effect=env_side):
|
||||
# Also patch gateway module's binding since _platform_status()
|
||||
# reads from hermes_cli.gateway.get_env_value after the setup
|
||||
# flows were unified via platform_registry.
|
||||
import hermes_cli.gateway as gateway_mod
|
||||
with patch.object(setup_mod, "get_env_value", side_effect=env_side), \
|
||||
patch.object(gateway_mod, "get_env_value", side_effect=env_side):
|
||||
result = setup_mod._get_section_config_summary({}, "gateway")
|
||||
assert "Telegram" in result
|
||||
assert "Discord" in result
|
||||
|
|
@ -471,7 +476,9 @@ class TestGetSectionConfigSummary:
|
|||
def env_side(key):
|
||||
return "true" if key == "WHATSAPP_ENABLED" else ""
|
||||
|
||||
with patch.object(setup_mod, "get_env_value", side_effect=env_side):
|
||||
import hermes_cli.gateway as gateway_mod
|
||||
with patch.object(setup_mod, "get_env_value", side_effect=env_side), \
|
||||
patch.object(gateway_mod, "get_env_value", side_effect=env_side):
|
||||
result = setup_mod._get_section_config_summary({}, "gateway")
|
||||
assert result is not None
|
||||
assert "WhatsApp" in result
|
||||
|
|
@ -481,7 +488,9 @@ class TestGetSectionConfigSummary:
|
|||
def env_side(key):
|
||||
return "http://signal.local" if key == "SIGNAL_HTTP_URL" else ""
|
||||
|
||||
with patch.object(setup_mod, "get_env_value", side_effect=env_side):
|
||||
import hermes_cli.gateway as gateway_mod
|
||||
with patch.object(setup_mod, "get_env_value", side_effect=env_side), \
|
||||
patch.object(gateway_mod, "get_env_value", side_effect=env_side):
|
||||
result = setup_mod._get_section_config_summary({}, "gateway")
|
||||
assert result is not None
|
||||
assert "Signal" in result
|
||||
|
|
@ -539,9 +548,18 @@ class TestGetSectionConfigSummary:
|
|||
env_var = plat.get("token_var")
|
||||
if not env_var:
|
||||
continue
|
||||
# Some platforms require a specific value shape (e.g. WhatsApp
|
||||
# needs the literal "true"). Use a sentinel that satisfies every
|
||||
# real validator _platform_status() currently checks.
|
||||
def env_side(key, _target=env_var):
|
||||
return "x" if key == _target else ""
|
||||
with patch.object(setup_mod, "get_env_value", side_effect=env_side):
|
||||
if key != _target:
|
||||
return ""
|
||||
if _target == "WHATSAPP_ENABLED":
|
||||
return "true"
|
||||
return "x"
|
||||
import hermes_cli.gateway as gateway_mod
|
||||
with patch.object(setup_mod, "get_env_value", side_effect=env_side), \
|
||||
patch.object(gateway_mod, "get_env_value", side_effect=env_side):
|
||||
result = setup_mod._get_section_config_summary({}, "gateway")
|
||||
expected = setup_mod._gateway_platform_short_label(label)
|
||||
assert result is not None, f"{label} ({env_var}) not recognised"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue