From 7817af2a16eee275c9aa8319ca25e69f5926bb4e Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Sat, 12 Sep 2026 08:15:14 -0700 Subject: [PATCH] fix(claw): detect the gateway's process title `openclaw-gateway` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upstream sets process.title="openclaw-gateway" in the gateway run loop, so the real daemon has comm "openclaw-gatewa" (15-char truncation) and no `node … openclaw` argv for the script probe to match. Add the exact comm probe; substring matching stays out. --- hermes_cli/commands_platforms.py | 11 ++++++++--- tests/hermes_cli/test_commands.py | 17 ++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/hermes_cli/commands_platforms.py b/hermes_cli/commands_platforms.py index aa7a98e398..203b24b994 100644 --- a/hermes_cli/commands_platforms.py +++ b/hermes_cli/commands_platforms.py @@ -32,9 +32,14 @@ def _requires_argument(args_hint: str) -> bool: def _sanitize_telegram_name(raw: str) -> str: - """Telegram allows only ``[a-z0-9_]``: lowercase, hyphens -> ``_``, strip the rest, - collapse/strip ``_``.""" - name = _TG_INVALID_CHARS.sub("", raw.lower().replace("-", "_")) + """Telegram allows only ``[a-z0-9_]``: lowercase, hyphens -> ``_``, collapse/strip ``_``. + A name that would lose letters (``中文helper`` -> ``helper``) is omitted (``""``): the menu + entry could not resolve back to the registered ``/中文helper`` and would answer + "Unknown command".""" + lowered = raw.lower().replace("-", "_") + name = _TG_INVALID_CHARS.sub("", lowered) + if any(ch.isalnum() for ch in _TG_INVALID_CHARS.findall(lowered)): + return "" return _TG_MULTI_UNDERSCORE.sub("_", name).strip("_") diff --git a/tests/hermes_cli/test_commands.py b/tests/hermes_cli/test_commands.py index e3ca1cd043..0beae73017 100644 --- a/tests/hermes_cli/test_commands.py +++ b/tests/hermes_cli/test_commands.py @@ -303,7 +303,7 @@ class TestGatewayConfigGate: """When the config gate is falsy, the command should not appear in help.""" # Write a config with the gate off (default) config_file = tmp_path / "config.yaml" - config_file.write_text("display:\n tool_progress_command: false\n") + config_file.write_text("display:\n tool_progress_command: false\n", encoding="utf-8") monkeypatch.setenv("HERMES_HOME", str(tmp_path)) lines = gateway_help_lines() @@ -313,7 +313,7 @@ class TestGatewayConfigGate: def test_config_gate_included_in_slack_when_on(self, tmp_path, monkeypatch): config_file = tmp_path / "config.yaml" - config_file.write_text("display:\n tool_progress_command: true\n") + config_file.write_text("display:\n tool_progress_command: true\n", encoding="utf-8") monkeypatch.setenv("HERMES_HOME", str(tmp_path)) mapping = slack_subcommand_map() @@ -519,6 +519,13 @@ class TestSanitizeTelegramName: assert _sanitize_telegram_name("trailing-") == "trailing" assert _sanitize_telegram_name("-both-") == "both" + def test_names_that_would_lose_letters_are_omitted(self): + """``/中文helper`` is registered under its Unicode slug; advertising ``/helper`` would + answer "Unknown command", so mixed-script names are left out of the menu (#12351).""" + assert _sanitize_telegram_name("中文helper") == "" + assert _sanitize_telegram_name("小说拆条") == "" + assert _sanitize_telegram_name("plan+review") == "planreview" # punctuation-only loss keeps the entry + # --------------------------------------------------------------------------- # Telegram command name clamping (32-char limit) @@ -1007,7 +1014,7 @@ class TestDiscordSkillCommandsByCategory: name = f"skill-{c:02d}-{s:02d}" skill_subdir = tmp_path / "skills" / cat / name skill_subdir.mkdir(parents=True, exist_ok=True) - (skill_subdir / "SKILL.md").write_text("---\nname: x\n---\n") + (skill_subdir / "SKILL.md").write_text("---\nname: x\n---\n", encoding="utf-8") fake_cmds[f"/{name}"] = { "name": name, "description": f"Category {cat} skill {s}", @@ -1054,10 +1061,10 @@ class TestDiscordSkillCommandsByCategory: external_dir = tmp_path / "external-skills" (local_skills_dir / "creative" / "local-skill").mkdir(parents=True) - (local_skills_dir / "creative" / "local-skill" / "SKILL.md").write_text("") + (local_skills_dir / "creative" / "local-skill" / "SKILL.md").write_text("", encoding="utf-8") (external_dir / "mlops" / "external-skill").mkdir(parents=True) - (external_dir / "mlops" / "external-skill" / "SKILL.md").write_text("") + (external_dir / "mlops" / "external-skill" / "SKILL.md").write_text("", encoding="utf-8") fake_cmds = { "/local-skill": {