The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): run every /cron form on the gateway that owns the cron store
kshitijk4poor9ca23c68400f
diff --git a/evals/cron_error_diagnostics.py b/evals/cron_error_diagnostics.pyindex c04daaa4c07..b2c65b79f0f 100644--- a/evals/cron_error_diagnostics.py+++ b/evals/cron_error_diagnostics.py@@ -28,7 +28,7 @@ def main():os.environ.update(HOME=home, HERMES_HOME=home)sys.path.insert(0, str(checkout))from cron import jobs, scheduler- from hermes_cli.cli_commands_mixin import CLICommandsMixin+ from hermes_cli.cli_cron_lines import cron_list_linesfrom openai import OpenAIfrom tools.cronjob_job_args import _format_job@@ -52,7 +52,7 @@ def main():formatted = _format_job(jobs.get_job(job["id"]))console = io.StringIO()with contextlib.redirect_stdout(console):- CLICommandsMixin._cron_list(object(), "list", {"all": False})+ print(*cron_list_lines(), sep="\n")checks = {"persisted_traceback": "Traceback (most recent call last)" in saved,"persisted_connection_cause": "Connection refused" in saved,diff --git a/gateway/session_commands.py b/gateway/session_commands.pyindex 3c0443b8141..2f3487ca781 100644--- a/gateway/session_commands.py+++ b/gateway/session_commands.py@@ -10,6 +10,7 @@ import osfrom pathlib import Pathimport shlex+from gateway.session_cron_commands import cron_readfrom hermes_state_runtime import RuntimeStoreErrorlogger = logging.getLogger(__name__)@@ -41,6 +42,14 @@ _APPROVAL_COMMANDS = frozenset({'approve', 'deny'})# Reports with no messaging handler: the classic CLI's own text, built by the owner for this# session (gateway/session_info_reads.py)._INFO_READS = frozenset({'toolsets', 'platforms'})+# The classic CLI's own handler, run by the owner (gateway/session_cron_commands.py): the profile's cron store+# belongs to the gateway whose ticker fires its jobs, so no client writes it. Bare ``/cron`` and ``list``+# read; every other form (add/edit/pause/resume/run/remove) is a control that writes the store. A write runs+# only on a connection that is not attached to the session: the classic CLI's command socket+# (GatewayConnection.call_until), which waits with no deadline. A viewer's own connection (Ink, Desktop, ACP+# send /cron there) answers its reads, prompts and interrupts one request at a time with a deadline, and a+# /cron run lasts as long as its job, so it keeps main's refusal whichever surface created the session.+_OWNER_COMMANDS = frozenset({'cron'})# Commands that move the session's goal/loop/heartbeat state: every viewer's cards repaint after them._AUTOMATION_COMMANDS = frozenset({'goal', 'subgoal', 'loop', 'heartbeat'})@@ -50,13 +59,18 @@ _KANBAN_READS = frozenset({'', 'help', '--help', '-h', '?', 'list', 'ls', 'show''context', 'runs', 'log', 'diagnostics', 'diag'})-def _first_token(arg):- """/kanban's verb as its handler parses it (shlex, hermes_cli/kanban.py ``run_slash``): an unclosed- quote can't run there either, so it is refused by name instead of failing as an internal error."""+def _split(arg):+ """``arg`` as a shlex-splitting handler parses it: an unclosed quote can't run there either, so it is+ refused by name (before ``pre_command`` fires) instead of failing as an internal error."""try:- tokens = iter(shlex.split(arg) if arg.strip() else [])+ return shlex.split(arg) if arg.strip() else []except ValueError as exc:raise RuntimeStoreError('invalid_params', field='arg', detail=str(exc)) from None+++def _first_token(arg):+ """/kanban's verb as its handler parses it (shlex, hermes_cli/kanban.py ``run_slash``)."""+ tokens = iter(_split(arg))for token in tokens:if token == '--board':next(tokens, None)@@ -120,6 +134,8 @@ def command_verdict(name, arg=''):"""``read`` / ``control`` / ``refused`` for a canonical registry command on a local session."""if _REFUSED_ARGUMENTS.get(name, lambda _a: False)(arg):return 'refused'+ if name in _OWNER_COMMANDS:+ return 'read' if cron_read(_split(arg)) is not None else 'control' # main's /cron handler shlex-splitsif (name in _CONTROL_COMMANDS or name in _HANDLER_CONTROLS or name in _PROMPT_COMMANDSor name in _SETTING_COMMANDS or name in _APPROVAL_COMMANDSor _CONTROL_ARGUMENTS.get(name, lambda _a: False)(arg)):@@ -238,7 +254,7 @@ def _skill_directive(name, arg, route):async def _tui_read(authority, actor, ref, name, arg, before):- """Main's TUI sidecar text for a TUI session's /status, /context or /cron read, else None;+ """Main's TUI sidecar text for a TUI session's /status or /context read, else None;``before`` (its ``pre_command``) runs once the read is accepted."""from gateway.session_local import authorize_local_sourcefrom gateway.session_policy import policy_for_source@@ -436,15 +452,17 @@ async def execute_command(connection, ref, params, *, dispatch=False):'session:approve' if canonical in _APPROVAL_COMMANDS else'session:control' if definition or runner_command else 'session:submit')authority.authorize(actor, ref, capability)- if verdict == 'refused':+ live = authority.sessions[ref.session_id]+ if verdict == 'refused' or (verdict == 'control' and canonical in _OWNER_COMMANDS+ and ref.session_id in connection.subscriptions):raise RuntimeStoreError('unsupported_command', detail=REFUSAL_HINTS.get(canonical))from gateway.session_local import authorize_local_source- live = authority.sessions[ref.session_id]if authorize_local_source(authority.runner, live.source) is not True:raise RuntimeStoreError('permission_denied')if capability != 'session:read':authority._require_admission_open()- if definition is not None and (canonical in _INFO_READS or authority._handle(ref).execution_state == 'idle'):+ if definition is not None and (canonical in _INFO_READS or canonical in _OWNER_COMMANDS+ or authority._handle(ref).execution_state == 'idle'):await before() # mid-run the busy dispatcher fires it once it accepts the command (``BUSY_ACCEPTED``)if runner_command is not None:with _profile_runtime_scope(home), _session_workspace(authority.runner, live.source):@@ -459,6 +477,9 @@ async def execute_command(connection, ref, params, *, dispatch=False):if canonical in _INFO_READS:from gateway.session_info_reads import run_info_readreturn await run_info_read(authority, live, canonical)+ if canonical in _OWNER_COMMANDS:+ from gateway.session_cron_commands import run_cron+ return await run_cron(authority, arg)from gateway.platforms.base import MessageEventfrom gateway.session_command_sink import capturediff --git a/gateway/session_cron_commands.py b/gateway/session_cron_commands.pynew file mode 100644index 00000000000..360a3c12283--- /dev/null+++ b/gateway/session_cron_commands.py@@ -0,0 +1,25 @@+"""``/cron`` on the shared gateway: the classic CLI's handler (hermes_cli/cli_cron_lines.py), run by the owner.++The profile's cron store belongs to the gateway whose ticker fires its jobs, so no client writes it. Bare+``/cron`` and ``list`` read, for every local session (main's TUI ran the same text in its slash worker). Every+other form writes the store: it runs here when the classic CLI sends it on its own command socket, and a+viewer's connection (Ink, Desktop, ACP) keeps main's refusal (gateway/session_commands.py).+"""+from __future__ import annotations+++def cron_read(tokens):+ """``'overview'`` / ``'list'`` / ``'list-all'`` for the read forms of the shlex-split ``/cron`` argument;+ None for a write."""+ if not tokens:+ return 'overview'+ if tokens[0].lower() == 'list' and set(tokens[1:]) <= {'--all', '-a'}:+ return 'list-all' if tokens[1:] else 'list'+ return None+++async def run_cron(authority, arg) -> dict:+ """``/cron <arg>`` off the owner loop in the owning profile: the store is written here, never by a client."""+ from gateway.session_info_reads import owner_lines+ from hermes_cli.cli_cron_lines import cron_command_lines+ return await owner_lines(authority, lambda: cron_command_lines(arg))diff --git a/gateway/session_info_reads.py b/gateway/session_info_reads.pyindex 1ec52cea2ba..787e974d531 100644--- a/gateway/session_info_reads.py+++ b/gateway/session_info_reads.py@@ -23,13 +23,18 @@ def _platforms(authority, policy):READS = {'toolsets': _toolsets, 'platforms': _platforms}-async def run_info_read(authority, live, name) -> dict:- """Render *name* off the owner loop, in the owning profile; None policy = no frozen route."""+async def owner_lines(authority, lines) -> dict:+ """``slash.exec``'s reply for ``lines()``, built off the owner loop in the owning profile."""from gateway.session_authorities import owner_scope- from gateway.session_policy import policy_for_source- policy = policy_for_source(authority.runner, live.source)def build():with owner_scope(authority):- return '\n'.join(READS[name](authority, policy)).strip('\n')+ return '\n'.join(lines()).strip('\n')return {'type': 'exec', 'output': await asyncio.to_thread(build)}+++async def run_info_read(authority, live, name) -> dict:+ """Render *name* off the owner loop, in the owning profile; None policy = no frozen route."""+ from gateway.session_policy import policy_for_source+ policy = policy_for_source(authority.runner, live.source)+ return await owner_lines(authority, lambda: READS[name](authority, policy))diff --git a/gateway/session_tui_reads.py b/gateway/session_tui_reads.pyindex a5b7b1399bc..2dd430d3912 100644--- a/gateway/session_tui_reads.py+++ b/gateway/session_tui_reads.py@@ -1,11 +1,11 @@-"""Main's TUI text for the session reads its sidecar answered itself: /status, /context, /cron.+"""Main's TUI text for the session reads its sidecar answered itself: /status, /context.On main the TUI's ``slash.exec`` never reached the messaging gateway's handlers: ``/status`` was``session.status`` (``Hermes TUI Status``), ``/context`` was ``_format_live_context_output`` (the-conversation counts, then the desktop gauge's category table) and ``/cron`` ran the classic CLI's-handler in the slash worker. A TUI session on the shared owner gets the same lines here, read-from the owner's live agent, stored row and the profile's cron store; every other surface keeps-the gateway's own handlers (``gateway/session_commands.py``).+conversation counts, then the desktop gauge's category table). A TUI session on the shared owner+gets the same lines here, read from the owner's live agent and stored row; every other surface keeps+the gateway's own handlers (``gateway/session_commands.py``). ``/cron``, the classic CLI's handler+that main's TUI ran in its slash worker, is gateway/session_cron_commands.py."""from __future__ import annotations@@ -13,20 +13,10 @@ import asyncioimport contextlibfrom collections import Counter-# The TUI surfaces whose /status, /context and /cron read as main's TUI sidecar did.+# The TUI surfaces whose /status and /context read as main's TUI sidecar did._TUI_SOURCES = frozenset({'tui'})-def _cron_read(arg: str):- """``/cron`` (overview) or ``/cron list [--all]``; None for a write (still refused)."""- tokens = arg.split()- if not tokens:- return 'overview'- if tokens[0].lower() == 'list' and set(tokens[1:]) <= {'--all', '-a'}:- return 'list-all' if tokens[1:] else 'list'- return None--def tui_read(policy, name: str, arg: str):"""The renderer for a TUI session's read of *name*, or None to keep the gateway handler."""if policy is None or policy.source not in _TUI_SOURCES:@@ -35,8 +25,6 @@ def tui_read(policy, name: str, arg: str):return _statusif name == 'context':return _context- if name == 'cron' and _cron_read(arg) is not None:- return _cronreturn None@@ -110,14 +98,6 @@ def _context(authority, ref, live, policy, agent, arg) -> str:return '\n'.join(lines)-def _cron(authority, ref, live, policy, agent, arg) -> str:- """The classic CLI's ``/cron`` / ``/cron list`` text (main's TUI ran it in the slash worker)."""- from hermes_cli.cli_cron_lines import cron_list_lines, cron_overview_lines- mode = _cron_read(arg)- lines = cron_overview_lines() if mode == 'overview' else cron_list_lines(include_disabled=mode == 'list-all')- return '\n'.join(lines).strip('\n')--async def run_tui_read(authority, ref, live, policy, render, arg) -> dict:"""Render off the owner loop, inside the owning profile and the session's workspace."""from gateway.session_authorities import owner_scopediff --git a/hermes_cli/cli_commands_mixin.py b/hermes_cli/cli_commands_mixin.pyindex 3880edffaa2..1662f9adef1 100644--- a/hermes_cli/cli_commands_mixin.py+++ b/hermes_cli/cli_commands_mixin.py@@ -80,16 +80,6 @@ def _ellipsize(text: str, limit: int) -> str:# Small data tables.-# /cron flag tables: flag -> opts key. Order-sensitive in _parse_cron_flags: bool flags never-# consume a value; --repeat is int-validated separately.-_CRON_BOOL_FLAGS = {"--clear-skills": "clear_skills", "--all": "all"}-_CRON_LIST_FLAGS = {"--skill": "skills", "--add-skill": "add_skills", "--remove-skill": "remove_skills"}-_CRON_VALUE_FLAGS = {"--name": "name", "--deliver": "deliver", "--prompt": "prompt", "--schedule": "schedule"}-# /cron subcommand -> CLICommandsMixin method name.-_CRON_SUBCOMMANDS = {- "list": "_cron_list", "add": "_cron_add", "create": "_cron_add", "edit": "_cron_edit",- **{k: "_cron_job_action" for k in ("pause", "resume", "run", "remove", "rm", "delete")}}-_ON_WORDS = {"on", "enable", "true", "1"}_OFF_WORDS = {"off", "disable", "false", "0"}@@ -185,47 +175,6 @@ def _cron_api(**kwargs) -> dict:return json.loads(cronjob_tool(**kwargs))-def _normalize_skills(values) -> list:- """Strip, drop empties, and dedupe (order-preserving)."""- normalized = []- for value in values:- text = str(value or "").strip()- if text and text not in normalized:- normalized.append(text)- return normalized---def _parse_cron_flags(tokens):- """Parse /cron flags into an opts dict (None after printing an error for a bad --repeat)."""- opts = {- "name": None, "deliver": None, "repeat": None, "prompt": None, "schedule": None,- "skills": [], "add_skills": [], "remove_skills": [],- "clear_skills": False, "all": False, "positionals": []}- i = 0- while i < len(tokens):- token = tokens[i]- has_value = i + 1 < len(tokens)- if token in _CRON_BOOL_FLAGS:- opts[_CRON_BOOL_FLAGS[token]] = True- i += 1- elif token in _CRON_LIST_FLAGS and has_value:- opts[_CRON_LIST_FLAGS[token]].append(tokens[i + 1])- i += 2- elif token == "--repeat" and has_value:- try:- opts["repeat"] = int(tokens[i + 1])- except ValueError:- return print(_t("cron.repeat_must_be_integer"))- i += 2- elif token in _CRON_VALUE_FLAGS and has_value:- opts[_CRON_VALUE_FLAGS[token]] = tokens[i + 1]- i += 2- else:- opts["positionals"].append(token)- i += 1- return opts--# Session-switch plumbing shared by /resume and /branch.def _end_current_session(cli, reason: str) -> None:"""Flush un-persisted messages, then end the current session row with ``reason``.@@ -1334,106 +1283,10 @@ class CLICommandsMixin(CLICommandsSessionToolsMixin):# ---- /cron ----------------------------------------------------------------------------def _handle_cron_command(self, cmd: str):- """Handle the /cron command to manage scheduled tasks."""- tokens = shlex.split(cmd)- if len(tokens) == 1:- return self._cron_overview()- subcommand = tokens[1].lower()- opts = _parse_cron_flags(tokens[2:])- if opts is None:- return- handler = _CRON_SUBCOMMANDS.get(subcommand)- if handler is None:- return _pr(_t("cron.unknown_command", subcommand=subcommand), f" {_t('cron.available')}")- getattr(self, handler)(subcommand, opts)-- def _cron_overview(self) -> None:- from hermes_cli.cli_cron_lines import cron_overview_lines- _pr(*cron_overview_lines())-- def _cron_list(self, subcommand: str, opts: dict) -> None:- from hermes_cli.cli_cron_lines import cron_list_lines- _pr(*cron_list_lines(include_disabled=opts["all"]))-- def _cron_add(self, subcommand: str, opts: dict) -> None:- positionals = opts["positionals"]- if not positionals:- return print(_t("cron.usage_add"))- schedule = opts["schedule"] or positionals[0]- prompt = opts["prompt"] or " ".join(positionals[1:])- skills = _normalize_skills(opts["skills"])- if not prompt and not skills:- return print(_t("cron.need_prompt_or_skill"))- result = _cron_api(- action="create", schedule=schedule, prompt=prompt or None, name=opts["name"],- deliver=opts["deliver"], repeat=opts["repeat"], skills=skills or None)- if not result.get("success"):- return print(_t("cron.create_failed", error=result.get("error")))- _pr(_t("cron.created", job_id=result["job_id"]),- f" {_t('cron.schedule', schedule=result['schedule'])}")- if result.get("skills"):- print(f" {_t('cron.skills', skills=', '.join(result['skills']))}")- print(f" {_t('cron.next_run', value=result['next_run_at'])}")-- def _cron_edit(self, subcommand: str, opts: dict) -> None:- from cron import get_job- positionals = opts["positionals"]- if not positionals:- return print(_t("cron.usage_edit"))- job_id = positionals[0]- existing = get_job(job_id)- if not existing:- return print(_t("cron.job_not_found", job_id=job_id))- # Skill edit precedence: --clear-skills > --skill (replace) > --add/--remove (merge) > untouched.- final_skills = None- replacement_skills = _normalize_skills(opts["skills"])- add_skills = _normalize_skills(opts["add_skills"])- remove_skills = set(_normalize_skills(opts["remove_skills"]))- if opts["clear_skills"]:- final_skills = []- elif replacement_skills:- final_skills = replacement_skills- elif add_skills or remove_skills:- existing_skills = list(- existing.get("skills") or ([existing["skill"]] if existing.get("skill") else []))- final_skills = [skill for skill in existing_skills if skill not in remove_skills]- final_skills += [skill for skill in add_skills if skill not in final_skills]- result = _cron_api(- action="update", job_id=job_id, schedule=opts["schedule"], prompt=opts["prompt"],- name=opts["name"], deliver=opts["deliver"], repeat=opts["repeat"], skills=final_skills)- if not result.get("success"):- return print(_t("cron.update_failed", error=result.get("error")))- job = result["job"]- _pr(_t("cron.updated", job_id=job["job_id"]), f" {_t('cron.schedule', schedule=job['schedule'])}",- f" {_t('cron.skills', skills=', '.join(job['skills']))}" if job.get("skills")- else f" {_t('cron.skills_none')}")-- def _cron_job_action(self, subcommand: str, opts: dict) -> None:- """pause / resume / run / remove (aliases rm, delete) on one job id."""- positionals = opts["positionals"]- if not positionals:- return print(_t("cron.usage_action", subcommand=subcommand))- job_id = positionals[0]- action = "remove" if subcommand in {"remove", "rm", "delete"} else subcommand- result = _cron_api(action=action, job_id=job_id,- reason="paused from /cron" if action == "pause" else None)- if not result.get("success"):- return print(_t(f"cron.{action}_failed", error=result.get("error")))- if action == "remove":- removed = result.get("removed_job", {})- return print(_t("cron.removed", name=removed.get("name", job_id), job_id=job_id))- job = result["job"]- if action == "run" and job.get("execution_skipped"):- # A refused run-now (claim lost, paused, gone) must not read as accepted.- return print(_t("cron.did_not_run", name=job["name"], job_id=job_id, reason=job["execution_skipped"]))- # One full template per action verb (cron.paused / cron.resumed / cron.triggered).- print(_t({"pause": "cron.paused", "resume": "cron.resumed", "run": "cron.triggered"}[action],- name=job["name"], job_id=job_id))- if action == "resume":- print(f" {_t('cron.next_run', value=job.get('next_run_at'))}")- elif action == "run":- from hermes_cli.cron import _run_outcome- print(f" {_run_outcome(job)}")+ """Handle the /cron command to manage scheduled tasks. Only without a gateway session: on the shared+ gateway every /cron form runs there (hermes_cli/gateway_setting_commands.py)."""+ from hermes_cli.cli_cron_lines import cron_command_lines+ _pr(*cron_command_lines(_command_arg(cmd)))# ---- delegating handlers: /suggestions, /blueprint, /curator, /kanban, /skills, /memory --def _handle_suggestions_command(self, cmd: str):diff --git a/hermes_cli/cli_cron_lines.py b/hermes_cli/cli_cron_lines.pyindex eb2a46211f6..5d48e538cb1 100644--- a/hermes_cli/cli_cron_lines.py+++ b/hermes_cli/cli_cron_lines.py@@ -1,10 +1,13 @@-"""The classic CLI's `/cron` overview and list as plain lines.+"""The classic CLI's `/cron` as plain lines: the overview, the list and every store write.-Shared by the classic CLI (`CLICommandsMixin._cron_overview` / `_cron_list`) and the shared gateway, which serves the-same lines to a TUI session (gateway/session_tui_reads.py).+Shared by the classic CLI off the gateway (`CLICommandsMixin._handle_cron_command`) and the shared gateway, which runs+`/cron` for a local session's `slash.exec` (gateway/session_commands.py, gateway/session_cron_commands.py), so the+profile's cron store has one writer: the gateway that owns it."""from __future__ import annotations+import shlex+from hermes_cli.cli_commands_session_tools import _lines, _t@@ -16,7 +19,7 @@ def _cron(**kwargs) -> dict:def cron_overview_lines() -> list[str]:"""Bare ``/cron``: the command card, then the current jobs. Plain text (the shared gateway serves- the same lines to a TUI session, gateway/session_tui_reads.py)."""+ the same lines to every local session, gateway/session_cron_commands.py)."""out = ["", "+" + "-" * 68 + "+", "|" + _t("cron.overview_title").center(68) + "|","+" + "-" * 68 + "+", "", f" {_t('cron.overview_commands')}",*_lines(_t("cron.overview_usage"), pad=" "), ""]@@ -66,3 +69,154 @@ def cron_list_lines(*, include_disabled: bool = False) -> list[str]:out.append(f" {_t('cron.last_run', when=job['last_run_at'], status=status)}")out.append("")return out+++# /cron flag tables: flag -> opts key. Order-sensitive in _parse_cron_flags: bool flags never+# consume a value; --repeat is int-validated separately.+_CRON_BOOL_FLAGS = {"--clear-skills": "clear_skills", "--all": "all"}+_CRON_LIST_FLAGS = {"--skill": "skills", "--add-skill": "add_skills", "--remove-skill": "remove_skills"}+_CRON_VALUE_FLAGS = {"--name": "name", "--deliver": "deliver", "--prompt": "prompt", "--schedule": "schedule"}+++def _normalize_skills(values) -> list:+ """Strip, drop empties, and dedupe (order-preserving)."""+ normalized = []+ for value in values:+ text = str(value or "").strip()+ if text and text not in normalized:+ normalized.append(text)+ return normalized+++def _parse_cron_flags(tokens):+ """Parse /cron flags into an opts dict (None for a bad --repeat)."""+ opts = {+ "name": None, "deliver": None, "repeat": None, "prompt": None, "schedule": None,+ "skills": [], "add_skills": [], "remove_skills": [],+ "clear_skills": False, "all": False, "positionals": []}+ i = 0+ while i < len(tokens):+ token = tokens[i]+ has_value = i + 1 < len(tokens)+ if token in _CRON_BOOL_FLAGS:+ opts[_CRON_BOOL_FLAGS[token]] = True+ i += 1+ elif token in _CRON_LIST_FLAGS and has_value:+ opts[_CRON_LIST_FLAGS[token]].append(tokens[i + 1])+ i += 2+ elif token == "--repeat" and has_value:+ try:+ opts["repeat"] = int(tokens[i + 1])+ except ValueError:+ return None+ i += 2+ elif token in _CRON_VALUE_FLAGS and has_value:+ opts[_CRON_VALUE_FLAGS[token]] = tokens[i + 1]+ i += 2+ else:+ opts["positionals"].append(token)+ i += 1+ return opts+++def _add_lines(subcommand: str, opts: dict) -> list[str]:+ positionals = opts["positionals"]+ if not positionals:+ return [_t("cron.usage_add")]+ schedule = opts["schedule"] or positionals[0]+ prompt = opts["prompt"] or " ".join(positionals[1:])+ skills = _normalize_skills(opts["skills"])+ if not prompt and not skills:+ return [_t("cron.need_prompt_or_skill")]+ result = _cron(+ action="create", schedule=schedule, prompt=prompt or None, name=opts["name"],+ deliver=opts["deliver"], repeat=opts["repeat"], skills=skills or None)+ if not result.get("success"):+ return [_t("cron.create_failed", error=result.get("error"))]+ out = [_t("cron.created", job_id=result["job_id"]), f" {_t('cron.schedule', schedule=result['schedule'])}"]+ if result.get("skills"):+ out.append(f" {_t('cron.skills', skills=', '.join(result['skills']))}")+ return [*out, f" {_t('cron.next_run', value=result['next_run_at'])}"]+++def _edit_lines(subcommand: str, opts: dict) -> list[str]:+ from cron import get_job+ positionals = opts["positionals"]+ if not positionals:+ return [_t("cron.usage_edit")]+ job_id = positionals[0]+ existing = get_job(job_id)+ if not existing:+ return [_t("cron.job_not_found", job_id=job_id)]+ # Skill edit precedence: --clear-skills > --skill (replace) > --add/--remove (merge) > untouched.+ final_skills = None+ replacement_skills = _normalize_skills(opts["skills"])+ add_skills = _normalize_skills(opts["add_skills"])+ remove_skills = set(_normalize_skills(opts["remove_skills"]))+ if opts["clear_skills"]:+ final_skills = []+ elif replacement_skills:+ final_skills = replacement_skills+ elif add_skills or remove_skills:+ existing_skills = list(existing.get("skills") or ([existing["skill"]] if existing.get("skill") else []))+ final_skills = [skill for skill in existing_skills if skill not in remove_skills]+ final_skills += [skill for skill in add_skills if skill not in final_skills]+ result = _cron(+ action="update", job_id=job_id, schedule=opts["schedule"], prompt=opts["prompt"],+ name=opts["name"], deliver=opts["deliver"], repeat=opts["repeat"], skills=final_skills)+ if not result.get("success"):+ return [_t("cron.update_failed", error=result.get("error"))]+ job = result["job"]+ return [_t("cron.updated", job_id=job["job_id"]), f" {_t('cron.schedule', schedule=job['schedule'])}",+ f" {_t('cron.skills', skills=', '.join(job['skills']))}" if job.get("skills")+ else f" {_t('cron.skills_none')}"]+++def _job_action_lines(subcommand: str, opts: dict) -> list[str]:+ """pause / resume / run / remove (aliases rm, delete) on one job id."""+ positionals = opts["positionals"]+ if not positionals:+ return [_t("cron.usage_action", subcommand=subcommand)]+ job_id = positionals[0]+ action = "remove" if subcommand in {"remove", "rm", "delete"} else subcommand+ result = _cron(action=action, job_id=job_id, reason="paused from /cron" if action == "pause" else None)+ if not result.get("success"):+ return [_t(f"cron.{action}_failed", error=result.get("error"))]+ if action == "remove":+ removed = result.get("removed_job", {})+ return [_t("cron.removed", name=removed.get("name", job_id), job_id=job_id)]+ job = result["job"]+ if action == "run" and job.get("execution_skipped"):+ # A refused run-now (claim lost, paused, gone) must not read as accepted.+ return [_t("cron.did_not_run", name=job["name"], job_id=job_id, reason=job["execution_skipped"])]+ # One full template per action verb (cron.paused / cron.resumed / cron.triggered).+ out = [_t({"pause": "cron.paused", "resume": "cron.resumed", "run": "cron.triggered"}[action],+ name=job["name"], job_id=job_id)]+ if action == "resume":+ out.append(f" {_t('cron.next_run', value=job.get('next_run_at'))}")+ elif action == "run":+ from hermes_cli.cron import _run_outcome+ out.append(f" {_run_outcome(job)}")+ return out+++# /cron subcommand -> line builder.+_CRON_SUBCOMMANDS = {+ # ``-a``: the list-all alias main's TUI read path accepted (only here, so no other form loses a ``-a`` word).+ "list": lambda _sub, opts: cron_list_lines(include_disabled=opts["all"] or "-a" in opts["positionals"]),+ "add": _add_lines, "create": _add_lines, "edit": _edit_lines,+ **{k: _job_action_lines for k in ("pause", "resume", "run", "remove", "rm", "delete")}}+++def cron_command_lines(arg: str) -> list[str]:+ """``/cron [subcommand ...]`` (the text after ``/cron``); raises ValueError on an unclosed quote."""+ tokens = shlex.split(arg)+ if not tokens:+ return cron_overview_lines()+ subcommand, opts = tokens[0].lower(), _parse_cron_flags(tokens[1:])+ if opts is None:+ return [_t("cron.repeat_must_be_integer")]+ handler = _CRON_SUBCOMMANDS.get(subcommand)+ if handler is None:+ return [_t("cron.unknown_command", subcommand=subcommand), f" {_t('cron.available')}"]+ return handler(subcommand, opts)diff --git a/hermes_cli/cli_tui_mixin.py b/hermes_cli/cli_tui_mixin.pyindex 00cedb86f5e..95a2f2b9e54 100644--- a/hermes_cli/cli_tui_mixin.py+++ b/hermes_cli/cli_tui_mixin.py@@ -915,7 +915,7 @@ class CLITuiMixin:def _tui_handle_ctrl_c(self, event):"""Ctrl+C priority: cancel voice recording → cancel foreground UI/overlay prompt or the wait for a- gateway plugin command → clear a typed draft, even mid-run (a correction must never kill the turn)+ command on its own gateway socket (a plugin command, /cron) → clear a typed draft, even mid-run (a correction must never kill the turn)→ interrupt the running agent → force exit (second press within 2s) → when idle and empty, exit."""now = time.time()if self._tui_cancel_voice_recording(event):@@ -923,7 +923,7 @@ class CLITuiMixin:if self._tui_cancel_foreground_ui(event, closers=(("_slash_confirm_state", lambda: self._submit_slash_confirm_response("cancel")),("_model_picker_state", self._close_model_picker), ("_command_palette_state", self._close_command_palette),- ("_plugin_command_wait", lambda: self._plugin_command_wait.set()))):+ ("_gateway_command_wait", lambda: self._gateway_command_wait.set()))):returnoverlay_cleared = self._tui_clear_blocking_overlays(event)if overlay_cleared and not (self._agent_running and self.agent):diff --git a/hermes_cli/gateway_plugin_commands.py b/hermes_cli/gateway_plugin_commands.pyindex 68b7d8ae0a3..17c0057f85b 100644--- a/hermes_cli/gateway_plugin_commands.py+++ b/hermes_cli/gateway_plugin_commands.py@@ -22,6 +22,7 @@ logger = logging.getLogger(__name__)_CATEGORY = "Plugin commands" # tui_gateway/command_discovery.pyGONE = object() # run(): the gateway no longer has the command; the caller dispatches the name again+STOPPED = object() # call_unbounded(): Ctrl+C stopped the wait (the stopped line is printed)_GONE_LINE = " /{}: the gateway no longer has this plugin command; nothing was run."_STOPPED_LINE = " /{}: stopped waiting. The command keeps running in the gateway and its reply will not be shown."@@ -212,6 +213,24 @@ def lookup(cli, name):raise CatalogUnavailable(name) from exc+def call_unbounded(cli, connection, name, command):+ """``slash.exec`` of *command* with no answer deadline, on a socket of its own so the session's prompts+ and interrupts never queue behind it (GatewayConnection.call_until). Ctrl+C stops waiting: the stopped+ line is printed and :data:`STOPPED` returned (a KeyboardInterrupt still propagates after it)."""+ from cli import _cprint+ from hermes_cli.gateway_connection import CallStopped+ wake = cli._gateway_command_wait = threading.Event() # set by Ctrl+C (cli_tui_mixin)+ try:+ return connection.call_until("slash.exec", wake, session_id=cli.session_id, command=command)+ except (CallStopped, KeyboardInterrupt) as exc:+ _cprint(_STOPPED_LINE.format(name))+ if isinstance(exc, KeyboardInterrupt):+ raise+ return STOPPED+ finally:+ cli._gateway_command_wait = None++def run(cli, name, arg):"""True when the gateway answered ``/name arg`` (the local handler must not run); :data:`GONE`when it no longer has that plugin command and a fresh catalog read agrees (a plugin reload, e.g.@@ -223,18 +242,9 @@ def run(cli, name, arg):return Falsefrom cli import _cprintfrom hermes_cli.gateway_client import GatewayRPCError- from hermes_cli.gateway_connection import CallStopped- # No answer deadline: main's CLI waited for the handler, which may wait minutes (ctx.call_mcp). On- # a socket of its own, so the session's prompts and interrupts never queue behind it.- wake = cli._plugin_command_wait = threading.Event() # set by Ctrl+C (cli_tui_mixin)+ # No answer deadline: main's CLI waited for the handler, which may wait minutes (ctx.call_mcp).try:- reply = connection.call_until("slash.exec", wake, session_id=cli.session_id,- command=name + (" " + arg if arg else ""))- except (CallStopped, KeyboardInterrupt) as exc:- _cprint(_STOPPED_LINE.format(name))- if isinstance(exc, KeyboardInterrupt):- raise- return True+ reply = call_unbounded(cli, connection, name, name + (" " + arg if arg else ""))except GatewayRPCError as exc:if str(exc) != "unsupported_command":_cprint(f" /{name}: {exc}")@@ -243,8 +253,8 @@ def run(cli, name, arg):except GatewayClientError as exc:_cprint(f" /{name}: {exc}")return True- finally:- cli._plugin_command_wait = None+ if reply is STOPPED:+ return Truereply = reply or {}if reply.get("type", "exec") != "exec": # it lost the plugin since lookup: a refusal or skill replyif _dropped(cli, connection, name):diff --git a/hermes_cli/gateway_setting_commands.py b/hermes_cli/gateway_setting_commands.pyindex 490fa277f5d..c216d8617c6 100644--- a/hermes_cli/gateway_setting_commands.py+++ b/hermes_cli/gateway_setting_commands.py@@ -7,6 +7,8 @@ command, every surface) and the CLI prints its reply. Client-side state the CLI(``/busy``: what Enter does while a turn runs) is mirrored locally after the owner accepts it.``/refine`` and ``/review`` take the same route: their background reviewer must run beside thesession's agent in the gateway (as on messaging), where its result is delivered back to the session.+``/cron`` too: the profile's cron store belongs to the gateway that fires its jobs, so the gateway runs+main's handler (one writer); ``/cron run`` lasts as long as the job, so it waits with no deadline."""from __future__ import annotations@@ -28,7 +30,17 @@ def _watch_reviewer(cli, _arg):GATEWAY_SETTINGS = {"personality": None, "busy": _mirror_busy, "approvals": None, "footer": None, "fast": None,- "refine": None, "review": _watch_reviewer}+ "refine": None, "review": _watch_reviewer, "cron": None}+# Answered when their work is done, however long (``/cron run`` runs the job): no deadline, on a socket of+# their own so the session's prompts never queue behind them (GatewayConnection.call_until); Ctrl+C stops waiting.+_UNBOUNDED = frozenset({"cron"})+++def _call(cli, connection, canonical, command):+ if canonical not in _UNBOUNDED:+ return connection.call("slash.exec", session_id=cli.session_id, command=command)+ from hermes_cli.gateway_plugin_commands import call_unbounded+ return call_unbounded(cli, connection, canonical, command)def run(cli, canonical, cmd):@@ -41,14 +53,16 @@ def run(cli, canonical, cmd):return Falsefrom cli import _cprintfrom hermes_cli.gateway_client import GatewayClientError+ from hermes_cli.gateway_plugin_commands import STOPPEDparts = (cmd or "").strip().split(None, 1)arg = parts[1].strip() if len(parts) > 1 else ""try:- reply = connection.call("slash.exec", session_id=cli.session_id,- command=canonical + (" " + arg if arg else ""))+ reply = _call(cli, connection, canonical, canonical + (" " + arg if arg else ""))except GatewayClientError as exc:_cprint(f" /{canonical}: {exc}")return True+ if reply is STOPPED:+ return Truefor line in str((reply or {}).get("output") or "").splitlines():_cprint(f" {line}" if line else "")mirror = GATEWAY_SETTINGS[canonical]diff --git a/scripts/gen_gateway_command_parity.py b/scripts/gen_gateway_command_parity.pyindex 7e57fcf1a94..e19ac6cae8b 100755--- a/scripts/gen_gateway_command_parity.py+++ b/scripts/gen_gateway_command_parity.py@@ -39,7 +39,8 @@ NOT_A_LOCAL_READ = {# 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"}+ "suggestions": "bare only", "kanban": "list/show/stats/assignees/context/runs/log/diagnostics",+ "cron": "bare / `list`; add/edit/pause/resume/run/remove control, from the classic CLI's own command socket only"}def _served_methods():@@ -63,8 +64,7 @@ def gateway_cell(name):# Reads a TUI session gets as main's TUI sidecar rendered them (gateway/session_tui_reads.py).TUI_READS = {"status": "TUI session: main's `Hermes TUI Status`",- "context": "TUI session: main's live /context with the category table",- "cron": "TUI session: bare `/cron` and `/cron list [--all]` read the profile's jobs"}+ "context": "TUI session: main's live /context with the category table"}def port_note(cmd):diff --git a/tests/cron/test_run_error_diagnostics.py b/tests/cron/test_run_error_diagnostics.pyindex 7f76e03d563..0f0e5563b7d 100644--- a/tests/cron/test_run_error_diagnostics.py+++ b/tests/cron/test_run_error_diagnostics.py@@ -29,7 +29,7 @@ def test_run_error_persists_redacted_cause_but_returns_summary(tmp_path, monkeypdef test_list_exposes_run_error_and_clears_it_after_success(tmp_path, capsys):- from hermes_cli.cli_commands_mixin import CLICommandsMixin+ from hermes_cli.cli_cron_lines import cron_list_linesfrom tools.cronjob_job_args import _format_jobwith jobs.use_cron_store(tmp_path):@@ -40,7 +40,7 @@ def test_list_exposes_run_error_and_clears_it_after_success(tmp_path, capsys):assert displayed["last_error"].startswith("RuntimeError:") and "localhost" in displayed["last_error"]assert "password" not in displayed["last_error"] and "secret-token" not in displayed["last_error"]assert displayed["last_delivery_error"] is None and displayed["last_fire_error"] is None- CLICommandsMixin._cron_list(object(), "list", {"all": False})+ print(*cron_list_lines(), sep="\n")console = capsys.readouterr().outassert f"error: {displayed['last_error']}" in consoleassert "password" not in console and "secret-token" not in consolediff --git a/tests/gateway/test_cli_plugin_command_own_socket.py b/tests/gateway/test_cli_plugin_command_own_socket.pyindex 7d1bdc33f10..3f8e4c8c5b1 100644--- a/tests/gateway/test_cli_plugin_command_own_socket.py+++ b/tests/gateway/test_cli_plugin_command_own_socket.py@@ -156,5 +156,5 @@ def test_a_gateway_hang_up_during_a_plugin_command_ends_the_wait_and_leaves_nothassert not alive, 'the wait outlived the gateway'assert '/ppslow: Gateway disconnected' in out and 'stopped waiting' not in out, outassert out.count('/ppslow') == 1 and 'SLOW_DONE' not in out, out- wait = getattr(c, '_plugin_command_wait', None)+ wait = getattr(c, '_gateway_command_wait', None)assert wait is None and pending == {}, (wait, pending)diff --git a/tests/gateway/test_pre_command_in_gateway.py b/tests/gateway/test_pre_command_in_gateway.pyindex 8a6dd1095b4..cb418661d2a 100644--- a/tests/gateway/test_pre_command_in_gateway.py+++ b/tests/gateway/test_pre_command_in_gateway.py@@ -256,12 +256,13 @@ def test_pre_command_fires_once_in_the_gateway_and_cli_plugins_reads_its_list(tm@pytest.mark.platforms("linux")-def test_accepted_tui_cron_reads_fire_once_and_refused_writes_fire_nothing(tmp_path):- """A TUI session's ``/cron`` reads (main's sidecar text) fire once through both RPCs; a refused- ``/cron`` write, and ``/cron`` on a classic CLI session (refused there), fire nothing."""+def test_accepted_cron_commands_fire_once_and_refused_ones_fire_nothing(tmp_path):+ """``/cron`` runs on the owner for every local session (a TUI session's reads, a write the classic CLI+ sends on its own command socket) and fires once through both RPCs; a ``/cron`` refused before it runs+ (an unclosed quote) fires nothing."""from hermes_cli.gateway_client import GatewayClientErrorwith _gateway(tmp_path) as (_proc, desc, home, work, _env, log, _peer):- wire = _Wire(home, desc)+ wire, command_socket = _Wire(home, desc), _Wire(home, desc)try:tui = wire.call('session.create', request_id='cron-tui', source='tui', toolsets=[], cwd=str(work))['session_id']cli = wire.call('session.create', request_id='cron-cli', source='cli', toolsets=[], cwd=str(work))['session_id']@@ -269,16 +270,18 @@ def test_accepted_tui_cron_reads_fire_once_and_refused_writes_fire_nothing(tmp_pwire.call('command.dispatch', session_id=tui, name='cron', arg='list')wire.call('slash.exec', session_id=tui, command='/cron list --all')wire.call('slash.exec', session_id=tui, command='/status')- for sid, command in ((tui, '/cron add 1h ping'), (cli, '/cron'), (cli, '/cron list')):+ wire.call('slash.exec', session_id=cli, command='/cron list')+ command_socket.call('command.dispatch', session_id=cli, name='cron', arg='remove job-1')+ for sid, command in ((tui, '/cron add "1h ping'), (cli, '/cron remove "job-1')):with pytest.raises(GatewayClientError):- wire.call('slash.exec', session_id=sid, command=command)- with pytest.raises(GatewayClientError):- wire.call('command.dispatch', session_id=tui, name='cron', arg='remove job-1')+ command_socket.call('slash.exec', session_id=sid, command=command)fired = _hook_lines(log)finally:+ command_socket.close()wire.close()assert [(r['command'], r['args_raw'], r['session_key']) for r in fired] == [- ('cron', '', tui), ('cron', 'list', tui), ('cron', 'list --all', tui), ('status', '', tui)], fired+ ('cron', '', tui), ('cron', 'list', tui), ('cron', 'list --all', tui), ('status', '', tui),+ ('cron', 'list', cli), ('cron', 'remove job-1', cli)], fired@pytest.mark.platforms("linux")diff --git a/tests/gateway/test_tui_session_reads.py b/tests/gateway/test_tui_session_reads.pyindex dd334f9451e..6a2faabd8b1 100644--- a/tests/gateway/test_tui_session_reads.py+++ b/tests/gateway/test_tui_session_reads.py@@ -1,4 +1,6 @@-"""A TUI session's /status, /context and /cron on the shared owner read as main's TUI sidecar did.+"""A TUI session's /status, /context and /cron on the shared owner read as main's TUI sidecar did;+every local session's /cron reads run main's handler on the owner, and its writes run there only when+the classic CLI sends them on its own command socket (a viewer's connection keeps main's refusal).Main's TUI answered these itself (``session.status``: ``Hermes TUI Status``; ``/context``:``_format_live_context_output`` with the category table; ``/cron``: the classic CLI's overview in@@ -37,7 +39,7 @@ async def owner(tmp_path, monkeypatch):reply = await connection.dispatch({'id': 1, 'method': method, 'params': params})assert 'result' in reply, replyreturn reply['result']- yield SimpleNamespace(call=call, home=home, authority=authority, workdir=tmp_path)+ yield SimpleNamespace(call=call, home=home, authority=authority, workdir=tmp_path, connection=connection)async def _exec(owner, sid, command):@@ -100,15 +102,55 @@ async def test_tui_cron_is_the_classic_overview_with_the_profile_jobs(owner):@pytest.mark.asyncio-async def test_tui_cron_writes_stay_refused(owner):- sid = (await owner.call('session.create', request_id='t', source='tui', cwd=str(owner.workdir)))['session_id']- from gateway.session_tui_reads import _cron_read- assert _cron_read('pause abc') is None and _cron_read('add "every 2h" x') is None+async def test_cron_writes_run_on_the_classic_cli_command_socket_whatever_surface_made_the_session(owner):+ """T1 (#134889): the classic CLI's /cron add|pause|remove wrote the profile's cron store from the+ CLI process. The owner runs them now (one writer) when they arrive on a connection that is not attached+ to the session, the CLI's own command socket (GatewayConnection.call_until), even for a session a TUI+ created and the CLI resumed (main's CLI wrote the store there too)."""+ import jsonfrom gateway.session_controls import AuthorityConnection- connection = AuthorityConnection(owner.authority, object(), {'user_id': 'human'})- reply = await connection.dispatch({'id': 9, 'method': 'slash.exec',- 'params': {'session_id': sid, 'command': 'cron remove abc'}})- assert reply.get('error', {}).get('message') == 'unsupported_command', reply+ jobs = owner.home / 'cron' / 'jobs.json'+ sid = (await owner.call('session.create', request_id='t', source='tui', cwd=str(owner.workdir)))['session_id']+ command_socket = AuthorityConnection(owner.authority, object(), {'user_id': 'human'})++ async def run(command):+ reply = await command_socket.dispatch({'id': 2, 'method': 'slash.exec',+ 'params': {'session_id': sid, 'command': command}})+ assert 'result' in reply, (command, reply)+ return reply['result']['output']+ added = await run('cron add "every 2h" "ping CRONPROBE" --name probe')+ assert 'Created job:' in added and 'every 120m' in added, added+ paused = await run('cron pause probe')+ assert 'Paused job: probe' in paused, paused+ assert [j['enabled'] for j in json.loads(jobs.read_text())['jobs'] if j['name'] == 'probe'] == [False]+ assert 'State: paused' in await run('cron list --all')+ assert 'Removed job: probe' in await run('cron remove probe')+ assert json.loads(jobs.read_text())['jobs'] == []+ assert 'Unknown cron command: bogus' in await run('cron bogus')+++async def test_cron_writes_stay_refused_on_a_viewer_connection_and_reads_list_all(owner):+ """A connection attached to the session (Ink, Desktop and ACP send /cron on their main connection, which+ answers one request at a time with a deadline) keeps main's refusal for /cron writes, whichever surface+ created the session, a classic CLI session included. Its reads still list, ``-a`` included (main's TUI+ alias)."""+ from cron.jobs import create_job, pause_job+ from hermes_constants import reset_hermes_home_override, set_hermes_home_override+ token = set_hermes_home_override(str(owner.home))+ try:+ pause_job(create_job('ping', 'every 2h', name='parked')['id'])+ finally:+ reset_hermes_home_override(token)+ for source in ('cli', 'tui', 'gui', 'acp'):+ sid = (await owner.call('session.create', request_id=source, source=source,+ cwd=str(owner.workdir)))['session_id']+ assert 'parked' in await _exec(owner, sid, 'cron list -a'), source+ assert 'parked' not in await _exec(owner, sid, 'cron list'), source+ reply = await owner.connection.dispatch({'id': 9, 'method': 'slash.exec',+ 'params': {'session_id': sid, 'command': 'cron resume parked'}})+ assert reply.get('error', {}).get('message') == 'unsupported_command', (source, reply)+ assert 'State: paused' in await _exec(owner, sid, 'cron list --all') # nothing resumed it@pytest.mark.asynciodiff --git a/tests/hermes_cli/test_gateway_setting_commands.py b/tests/hermes_cli/test_gateway_setting_commands.pyindex f4732a979f8..238e9610b50 100644--- a/tests/hermes_cli/test_gateway_setting_commands.py+++ b/tests/hermes_cli/test_gateway_setting_commands.py@@ -42,3 +42,38 @@ def test_refine_and_review_run_on_the_gateway_sessions_agent(monkeypatch, capsysassert conn.calls == [("slash.exec", {"session_id": "local-s", "command": "refine naming"}),("slash.exec", {"session_id": "local-s", "command": "review the diff"})]assert "Busy input mode: queue" in capsys.readouterr().out # the owner's reply is printed+++def test_cron_writes_run_on_the_gateway_not_in_the_cli(monkeypatch, capsys):+ """T1 (#134889): /cron add|pause|remove go to the gateway's handler (one writer to the profile's+ cron store), with no answer deadline (a /cron run lasts as long as its job); nothing writes here."""+ calls = []++ class _UntilConn(_Conn):+ def call_until(self, method, wake, **params):+ calls.append((method, params, wake.is_set()))+ return {"type": "exec", "output": "(^_^)b Paused job: probe (probe)"}+ monkeypatch.setattr("hermes_cli.gateway_side.connection_for", lambda cli: _UntilConn())++ def local_write(**_k):+ raise AssertionError("the CLI process must not write the cron store")+ monkeypatch.setattr("tools.cronjob_tools.cronjob", local_write)+ cli = SimpleNamespace(session_id="local-s", _gateway_command_wait=None)+ assert gateway_setting_commands.run(cli, "cron", "/cron pause probe") is True+ assert calls == [("slash.exec", {"session_id": "local-s", "command": "cron pause probe"}, False)]+ assert "Paused job: probe" in capsys.readouterr().out and cli._gateway_command_wait is None+++def test_ctrl_c_during_a_cron_wait_prints_the_stopped_line_and_propagates(monkeypatch, capsys):+ """Ctrl+C while /cron waits on the gateway (a /cron run lasts as long as its job): the same stopped line+ as a plugin command, the wait handle cleared, and the interrupt still reaches the CLI."""+ import pytest++ class _InterruptedConn(_Conn):+ def call_until(self, method, wake, **params):+ raise KeyboardInterrupt+ monkeypatch.setattr("hermes_cli.gateway_side.connection_for", lambda cli: _InterruptedConn())+ cli = SimpleNamespace(session_id="local-s", _gateway_command_wait=None)+ with pytest.raises(KeyboardInterrupt):+ gateway_setting_commands.run(cli, "cron", "/cron run probe")+ assert "/cron: stopped waiting" in capsys.readouterr().out and cli._gateway_command_wait is Nonediff --git a/website/docs/developer-guide/gateway-command-parity.md b/website/docs/developer-guide/gateway-command-parity.mdindex 794b7e36a9d..3dbfe2e671b 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 thehandler does; `client-local (cli_only)` commands are terminal/UI features of a client.-104 registry commands: 29 control, 18 read, 57 refused.+104 registry commands: 29 control, 19 read, 56 refused.| Command | Gateway (`slash.exec`) | Classic CLI | Ink | Desktop | ACP | Notes ||---|---|---|---|---|---|---|@@ -49,7 +49,7 @@ handler does; `client-local (cli_only)` commands are terminal/UI features of a c| `/config` | refused | HermesCLI.show_config | canonical route | action: config | slash.exec: refused | client-local (cli_only) || `/context` (/ctx) | read | HermesCLI._show_context_breakdown | slash.exec | slash.exec | slash.exec | TUI session: main's live /context with the category table || `/copy` | refused | HermesCLI._handle_copy_command | local | unavailable: terminal | slash.exec: refused | client-local (cli_only) |-| `/cron` | refused | HermesCLI._handle_cron_command | slash.exec | unavailable: terminal | slash.exec: refused | TUI session: bare `/cron` and `/cron list [--all]` read the profile's jobs; client-local (cli_only) |+| `/cron` | read (bare / `list`; add/edit/pause/resume/run/remove control, from the classic CLI's own command socket only) | HermesCLI._handle_cron_command | slash.exec | unavailable: terminal | slash.exec | client-local (cli_only) || `/curator` | control | HermesCLI._handle_curator_command | slash.exec | unavailable: advanced | slash.exec | || `/debug` | control | HermesCLI._handle_debug_command | slash.exec | slash.exec | slash.exec | uploads logs to a public paste || `/deny` | control | messaging-only: unknown command | slash.exec | slash.exec | slash.exec | messaging-only |