Removed. A search for callers by name, attribute and string (Python, TypeScript, docs, the plugin API list and the frozen old-updater list) finds no supported path that reaches any of them: - tools/send_message_tool.py: _handle_list, _handle_react and the action dispatch in send_message_tool (every caller, including the external hermes-snooze plugin, passes action="send") - tools/bot_failure_reasons.py: is_auto_retryable - tools/clarify_gateway.py: _notify_cbs, _coerce_text_response, attempt_text_response_for_session, resolve_text_response_for_session - tools/cronjob_tools.py: the unused task_id parameter of cronjob() - tools/interrupt.py: is_thread_yield_requested - toolsets.py: create_custom_toolset - tools/tool_backend_helpers.py: prefers_gateway, REMOVED_BACKENDS, removed_backend_note, normalize_modal_mode (callers use coerce_modal_mode) - hermes_cli/config_value_checks.py: _validate_web_backends (only read the always-empty REMOVED_BACKENDS map) Tests that existed only for these symbols are deleted; tests that also cover live behaviour now call the canonical live names (attempt_text_response, _coerce_text_response_detailed, consume_yield). The shared-bot route-gate tests that reached the gate through the deleted react action now call _shared_bot_target_allowed directly, so the origin rules (guild-only, thread-under-channel and user_id routes, Telegram topics, the turn's sender in a shared channel) keep their coverage. The two error hints and one comment that named send_message(action='list') now name `hermes send --list`; the stale send_message row in the zh-Hans tools reference goes. Also: - test_messaging_slash_command_fifo spies on clarify_gateway.attempt_text_response, the name gateway/run_inbound.py calls, so its [clarify] case can fail again - send_message_tool: an action other than 'send' returns an error that names `hermes send --list` for listing targets - multi-profile-gateways.md no longer says send_message sends reactions; the zh-Hans simplex.md and tools-reference.md match the English pages
106 lines
5.0 KiB
Python
106 lines
5.0 KiB
Python
"""Value checks for single config sections (voice, timezone, quoted containers), run by
|
|
``hermes_cli.config.validate_config_structure`` for doctor and the startup warnings."""
|
|
|
|
from typing import Any
|
|
|
|
from hermes_cli.config_issues import ConfigIssue, _issue
|
|
|
|
|
|
def _validate_voice(config: dict[str, Any], issues: list[ConfigIssue]) -> None:
|
|
voice_cfg = config.get("voice")
|
|
if isinstance(voice_cfg, dict) and "auto_tts_mode" in voice_cfg:
|
|
auto_tts_mode = voice_cfg.get("auto_tts_mode")
|
|
normalized_mode = auto_tts_mode.strip().lower() if isinstance(auto_tts_mode, str) else None
|
|
if normalized_mode not in {"all", "voice_only"}:
|
|
_issue(issues, "error",
|
|
f"voice.auto_tts_mode must be 'all' or 'voice_only', got {auto_tts_mode!r}",
|
|
"Set voice.auto_tts_mode to all (audio with every reply) or "
|
|
"voice_only (audio only after voice input)")
|
|
if not (isinstance(voice_cfg, dict) and "submit_mode" in voice_cfg):
|
|
return
|
|
submit_mode = voice_cfg.get("submit_mode")
|
|
normalized = submit_mode.strip().lower() if isinstance(submit_mode, str) else None
|
|
if normalized not in {"direct", "draft"}:
|
|
_issue(issues, "error", f"voice.submit_mode must be 'direct' or 'draft', got {submit_mode!r}",
|
|
"Set voice.submit_mode to direct (submit immediately) or draft (edit before sending)")
|
|
|
|
|
|
def _validate_timezone(config: dict[str, Any], issues: list[ConfigIssue]) -> None:
|
|
"""``timezone`` must be an IANA name the runtime can load.
|
|
|
|
``hermes_time._get_zoneinfo()`` swallows an invalid name behind a single WARNING in the
|
|
gateway log, then runs the agent clock AND every cron schedule on server-local time.
|
|
Surface it here, where doctor and the startup check both look. Silent when the
|
|
interpreter has no tz database at all (bare Windows without ``tzdata``) — nothing can be
|
|
judged there.
|
|
"""
|
|
if "timezone" not in config:
|
|
return
|
|
tz = config.get("timezone")
|
|
hint = ("Use an IANA zone name such as America/New_York or Asia/Tokyo (see "
|
|
"`timedatectl list-timezones`). With an invalid value the agent clock and cron "
|
|
"schedules silently fall back to server-local time. HERMES_TIMEZONE overrides "
|
|
"this key when set.")
|
|
if tz is not None and not isinstance(tz, str):
|
|
_issue(issues, "error", f"timezone must be an IANA zone name string, got {tz!r}", hint)
|
|
return
|
|
if not (isinstance(tz, str) and tz.strip()):
|
|
return
|
|
name = tz.strip()
|
|
try:
|
|
import zoneinfo
|
|
zoneinfo.ZoneInfo("UTC") # is a tz database available at all?
|
|
except Exception:
|
|
return
|
|
try:
|
|
zoneinfo.ZoneInfo(name)
|
|
except Exception:
|
|
_issue(issues, "error", f"timezone {name!r} is not a valid IANA zone name", hint)
|
|
|
|
|
|
def _container_slots() -> dict[str, str]:
|
|
"""Dotted key -> ``"list"``/``"mapping"`` for every slot the schema fixes to a container:
|
|
``DEFAULT_CONFIG`` (sections included) plus the known-container table for roots it omits."""
|
|
from hermes_cli.config import _KNOWN_CONTAINER_TYPES, DEFAULT_CONFIG # late: the facade imports this module
|
|
slots: dict[str, str] = {}
|
|
|
|
def walk(node: dict[str, Any], prefix: str) -> None:
|
|
for key, value in node.items():
|
|
path = f"{prefix}.{key}" if prefix else key
|
|
if isinstance(value, dict):
|
|
slots[path] = "mapping"
|
|
walk(value, path)
|
|
elif isinstance(value, list):
|
|
slots[path] = "list"
|
|
|
|
walk(DEFAULT_CONFIG, "")
|
|
slots.update(_KNOWN_CONTAINER_TYPES)
|
|
return slots
|
|
|
|
|
|
def _validate_quoted_containers(config: dict[str, Any], issues: list[ConfigIssue]) -> None:
|
|
"""A container slot holding ONE quoted string (``enabled: '["a","b"]'``) is skipped by every
|
|
isinstance-gated reader while ``config get`` echoes it back, so plugins silently unmount and
|
|
exclusions silently lapse (#83308, #105706). Finding only — the file is never rewritten."""
|
|
import shlex
|
|
|
|
import hermes_yaml as yaml
|
|
from hermes_cli.config import _SCALAR_AS_ONE_ITEM_LIST_KEYS, _looks_structured_value, cfg_get
|
|
for key, kind in _container_slots().items():
|
|
# ``parse_config_string_list`` readers accept the quoted form; nothing is ignored there.
|
|
if key in _SCALAR_AS_ONE_ITEM_LIST_KEYS:
|
|
continue
|
|
value = cfg_get(config, *key.split("."))
|
|
if not isinstance(value, str) or not _looks_structured_value(value):
|
|
continue
|
|
try:
|
|
parsed = yaml.safe_load(value)
|
|
except yaml.YAMLError:
|
|
continue
|
|
if isinstance(parsed, (list, dict)):
|
|
_issue(issues, "warning",
|
|
f"{key} is the quoted string {value!r} — Hermes expects a YAML {kind} here "
|
|
"and every reader ignores the string",
|
|
f"Run: hermes config set {key} {shlex.quote(value)} (stores a real {kind}), "
|
|
"or remove the quotes in config.yaml")
|