Skip to content

The agent that grows with you

fix(gateway): /skills review verbs run the messaging handler for a local session

Teknium88d56fcd8749
diff --git a/gateway/session_commands.py b/gateway/session_commands.py
index 56db4f04236..552f69a7b30 100644
--- a/gateway/session_commands.py
+++ b/gateway/session_commands.py
@@ -16,7 +16,7 @@ from hermes_state_runtime import RuntimeStoreError
# gateway-command-parity.md); a handler that reads messaging-only state or writes config is not here.
_READ_COMMANDS = frozenset({'help', 'commands', 'status', 'context', 'version', 'whoami',
'usage', 'insights', 'profile', 'diff', 'memory', 'kanban', 'topup',
- 'suggestions', 'bundles'})
+ 'suggestions', 'bundles', 'skills'})
_CONTROL_COMMANDS = frozenset({'title'})
# Authoring/workflow commands whose messaging handler (``_command_handler_table``) runs as-is for a
# local session: goal/loop/heartbeat state on the session's row, the review/refine forks of its
@@ -58,6 +58,7 @@ def _first_token(arg):
# redeems a credit, ``/memory approve|approval`` applies writes / edits config.yaml,
# ``/suggestions accept|catalog`` schedules cron jobs delivering to this (non-messaging) chat.
_READ_ARGUMENTS = {
+ 'skills': lambda arg: _first_token(arg) in {'', 'pending', 'diff'},
'usage': lambda arg: not arg.strip(),
'memory': lambda arg: arg.strip().lower() in {'', 'pending'},
'suggestions': lambda arg: not arg.strip(),
@@ -65,10 +66,19 @@ _READ_ARGUMENTS = {
}
+# The write forms of a command whose reads are above: the messaging handler's own review verbs,
+# applied for this session's profile (`/skills approve|reject` the staged queue, `/skills approval`
+# its config.yaml switch, as main's CLI wrote it).
+_CONTROL_ARGUMENTS = {
+ 'skills': lambda arg: _first_token(arg) in {'approve', 'apply', 'reject', 'deny', 'drop', 'approval', 'mode'},
+}
+
+
def command_verdict(name, arg=''):
"""``read`` / ``control`` / ``refused`` for a canonical registry command on a local session."""
if (name in _CONTROL_COMMANDS or name in _HANDLER_CONTROLS or name in _PROMPT_COMMANDS
- or name in _SETTING_COMMANDS or name in _APPROVAL_COMMANDS):
+ or name in _SETTING_COMMANDS or name in _APPROVAL_COMMANDS
+ or _CONTROL_ARGUMENTS.get(name, lambda _a: False)(arg)):
return 'control'
if name in _INFO_READS or (name in _READ_COMMANDS and _READ_ARGUMENTS.get(name, lambda _arg: True)(arg)):
return 'read'
diff --git a/scripts/gen_gateway_command_parity.py b/scripts/gen_gateway_command_parity.py
index 07aa790c8b0..4f3a9d66446 100755
--- a/scripts/gen_gateway_command_parity.py
+++ b/scripts/gen_gateway_command_parity.py
@@ -34,10 +34,10 @@ NOT_A_LOCAL_READ = {
"save": "writes an export file on the gateway host",
"rollback": "restores filesystem checkpoints",
"resume": "switches the messaging chat's session; local clients resume by id",
- "skills": "write-approval queue; `/skills approve|approval` write",
}
# The read-only argument forms of a read whose other subcommands write.
READ_FORMS = {"usage": "bare only (`reset` refused)", "memory": "bare / `pending`",
+ "skills": "bare/`pending`/`diff`; `approve`/`reject`/`approval` control; hub refused",
"suggestions": "bare only", "kanban": "list/show/stats/assignees/context/runs/log/diagnostics"}
diff --git a/tests/gateway/test_session_read_commands.py b/tests/gateway/test_session_read_commands.py
index 6475a9b7a3e..fcf2432fba3 100644
--- a/tests/gateway/test_session_read_commands.py
+++ b/tests/gateway/test_session_read_commands.py
@@ -55,7 +55,7 @@ def test_local_session_reads_report_this_session_and_refuse_their_write_forms(tm
for command in ('usage', 'insights', 'profile', 'topup', 'diff', 'memory', 'kanban list',
'suggestions', 'bundles', 'usage reset', 'memory approval on', 'kanban create x',
'suggestions catalog', 'agents', 'sessions', 'platform',
- 'toolsets', 'platforms'):
+ 'toolsets', 'platforms', 'skills pending', 'skills reject nope', 'skills install x'):
try:
reply = await rpc(ws, 'slash.exec', session_id=sid, command=command)
except TimeoutError:
@@ -88,6 +88,10 @@ def test_local_session_reads_report_this_session_and_refuse_their_write_forms(tm
# Reports with no messaging handler: the classic CLI's text for this session's toolsets.
assert '(*) todo ' in out['toolsets'] and ' web ' in out['toolsets'], out['toolsets']
assert 'Telegram' in out['platforms'] and 'TELEGRAM_BOT_TOKEN' in out['platforms'], out['platforms']
+ # The skill write-approval queue: the messaging handler's review verbs; the hub stays refused.
+ assert 'No pending' in out['skills pending'] or 'pending' in out['skills pending'].lower(), out['skills pending']
+ assert out['skills reject nope'] != 'unsupported_command', out['skills reject nope']
+ assert out['skills install x'] == 'unsupported_command', out['skills install x']
# Write forms, messaging-model state and gateway-wide views stay refused (the per-session settings
# run: tests/gateway/test_session_setting_commands.py).
for command in ('usage reset', 'memory approval on', 'kanban create x', 'suggestions catalog',
diff --git a/website/docs/developer-guide/gateway-command-parity.md b/website/docs/developer-guide/gateway-command-parity.md
index 1a59cb280ec..36f31306a30 100644
--- a/website/docs/developer-guide/gateway-command-parity.md
+++ b/website/docs/developer-guide/gateway-command-parity.md
@@ -26,7 +26,7 @@ narrower routes (`hermes_cli/gateway_chat_commands.py`).
setting to this local session (its next turn and `config.get`), saving config.yaml only where the
handler does; `client-local (cli_only)` commands are terminal/UI features of a client.
-103 registry commands: 29 control, 17 read, 57 refused.
+103 registry commands: 29 control, 18 read, 56 refused.
| Command | Gateway (`slash.exec`) | Classic CLI | Ink | Desktop | ACP | Notes |
|---|---|---|---|---|---|---|
@@ -106,7 +106,7 @@ handler does; `client-local (cli_only)` commands are terminal/UI features of a c
| `/save` | refused | HermesCLI.save_conversation | session.save | rpc session.save | refused | writes an export file on the gateway host |
| `/sessions` | refused | HermesCLI._handle_sessions_command | local | picker: session | refused | messaging origin-scoped listing (`/sessions all` needs a messaging admin) |
| `/sethome` (/set-home) | refused | messaging-only: unknown command | slash.exec: refused | unavailable: terminal | refused | messaging-only |
-| `/skills` | refused | HermesCLI._cmd_skills | slash.exec; sidecar: skills.manage | slash.exec: refused | refused | write-approval queue; `/skills approve\|approval` write |
+| `/skills` | read (bare/`pending`/`diff`; `approve`/`reject`/`approval` control; hub refused) | HermesCLI._cmd_skills | slash.exec; sidecar: skills.manage | slash.exec | refused | client-local (cli_only) |
| `/skin` | refused | HermesCLI._handle_skin_command | config.get, config.set | action: skin | refused | client-local (cli_only) |
| `/snapshot` (/snap) | refused | HermesCLI._handle_snapshot_command | slash.exec: refused | unavailable: terminal | refused | client-local (cli_only) |
| `/start` | refused | messaging-only: unknown command | slash.exec: refused | slash.exec: refused | refused | messaging-only |