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

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.
This commit is contained in:
teknium1
2026-09-12 08:15:14 -07:00
committed by Teknium
parent a340710389
commit 7817af2a16
2 changed files with 20 additions and 8 deletions

View File

@@ -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("_")

View File

@@ -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": {