Behavior-neutral structural pass over tools/*: god-file extractions into sibling modules (file_operations_common/lint/search, file_tools_paths/ read_tracking/write, code_execution_env/rpc, tool_search_catalog/names/ validation, tts_command_provider, ...), duplicate helper unification, if/elif -> dispatch tables, dead-code removal, docstring compaction. Tool schemas (get_tool_definitions) verified byte-identical to base.
22 lines
590 B
Python
22 lines
590 B
Python
"""OpenRouter API key probe shared by Hermes tools."""
|
|
|
|
import os
|
|
|
|
|
|
def check_api_key() -> bool:
|
|
"""Return True if OPENROUTER_API_KEY is present.
|
|
|
|
Scope-aware: an installed profile secret scope is authoritative under
|
|
multiplex; unscoped CLI probes fall back to the plain env read.
|
|
"""
|
|
try:
|
|
from agent.secret_scope import UnscopedSecretError, get_secret
|
|
|
|
try:
|
|
return bool(get_secret("OPENROUTER_API_KEY"))
|
|
except UnscopedSecretError:
|
|
pass
|
|
except Exception:
|
|
pass
|
|
return bool(os.getenv("OPENROUTER_API_KEY"))
|