Skip to content

The agent that grows with you

fix(claw): detect the gateway's process title `openclaw-gateway`

teknium17817af2a16ee
diff --git a/hermes_cli/commands_platforms.py b/hermes_cli/commands_platforms.py
index aa7a98e3981..203b24b9940 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 e3ca1cd043f..0beae730175 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": {