Skip to content

The agent that grows with you

fix(gateway): a launch-profile quick command no longer refuses a session's plugin command

unsupportedpastelsff5a49a89e7e
diff --git a/gateway/run_inbound_hooks.py b/gateway/run_inbound_hooks.py
index 22d81e326fb..553ab83cec1 100644
--- a/gateway/run_inbound_hooks.py
+++ b/gateway/run_inbound_hooks.py
@@ -198,8 +198,17 @@ class GatewayInboundHooksMixin:
return True, t("gateway.quick_command.no_target", command=command), command
command = new_command # Fall through to normal command dispatch below
- # Plugin-registered slash commands. Underscores normalize to hyphens so Telegram's
- # underscored autocomplete form matches plugin commands registered with hyphens.
+ if not command:
+ return False, None, command
+ return await self._hm_dispatch_plugin_command(event, source, command)
+
+ async def _hm_dispatch_plugin_command(
+ self, event: MessageEvent, source: SessionSource, command: str
+ ) -> tuple[bool, Optional[str], Optional[str]]:
+ """Plugin-registered slash command *command* → ``(handled, result, command)``. No quick
+ commands: a local session resolves those in its own profile before calling this."""
+ # Underscores normalize to hyphens so Telegram's underscored autocomplete form matches
+ # plugin commands registered with hyphens.
if command:
try:
from hermes_cli.plugins import get_plugin_command_handler
diff --git a/gateway/session_commands.py b/gateway/session_commands.py
index 0aa09127138..0b9f6babdfd 100644
--- a/gateway/session_commands.py
+++ b/gateway/session_commands.py
@@ -150,12 +150,10 @@ async def _run_runner_command(runner, live, name, arg, kind, shell):
# Never fall back to the gateway's own folder: a relative command would act there.
raise RuntimeStoreError('cwd_unavailable')
return await runner._hm_run_exec_quick_command(name, shell, cwd=cwd)
- if runner._hm_quick_commands().get(name) is not None:
- # The runner's quick commands come first in its dispatch; under multiplex they are the launch
- # profile's, which must never answer for this session's profile.
- raise RuntimeStoreError('unsupported_command')
+ # Plugin-only: the runner's quick commands are the launch profile's under multiplex, and this
+ # session's own were already resolved above in its profile (``_resolve_alias``/``_runner_command``).
event = MessageEvent(text='/' + name + (' ' + arg if arg else ''), source=live.source)
- _handled, output, _command = await runner._hm_dispatch_quick_and_plugin_commands(event, live.source, name)
+ _handled, output, _command = await runner._hm_dispatch_plugin_command(event, live.source, name)
return output
diff --git a/tests/gateway/fixtures/tui_desktop_routes_peer.py b/tests/gateway/fixtures/tui_desktop_routes_peer.py
index 082535a55dd..825d70c5d81 100644
--- a/tests/gateway/fixtures/tui_desktop_routes_peer.py
+++ b/tests/gateway/fixtures/tui_desktop_routes_peer.py
@@ -170,6 +170,12 @@ async def _commands(authority, ws, reader, sid, marker, receipt):
typed = await rpc(ws, 'slash.exec', session_id=sid, command='probe_plugin THREE')
assert typed.get('result', {}).get('output', '').startswith('PLUGIN_OK THREE'), typed
assert calls == ['ARG_ONE two', 'THREE']
+ # Under multiplex the runner's own quick commands are the LAUNCH profile's; one sharing the plugin's
+ # name must neither shadow nor refuse this session's plugin command.
+ authority.runner.config.quick_commands['probe-plugin'] = {'type': 'exec', 'command': 'echo LAUNCH_QUICK'}
+ shadowed = await rpc(ws, 'command.dispatch', session_id=sid, name='probe-plugin', arg='FOUR')
+ assert shadowed.get('result', {}).get('output', '').startswith('PLUGIN_OK FOUR'), shadowed
+ assert calls[-1] == 'FOUR'
unknown = await rpc(ws, 'slash.exec', session_id=sid, command='no-such-command')
assert _error(unknown) == 'unsupported_command', unknown
assert not authority.db.get_messages(sid), 'a command started a turn'