The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(secrets): scope tier-3 credential reads (teams_pipeline, deepinfra models, FAL/XAI/VERCEL/DAYTONA/GITHUB presence, HERMES_API_KEY display)
Tekniumebd61ce5ac93
diff --git a/hermes_cli/tools_config.py b/hermes_cli/tools_config.pyindex 257eb0b72f6..4d3a8c47530 100644--- a/hermes_cli/tools_config.py+++ b/hermes_cli/tools_config.py@@ -189,7 +189,11 @@ def _xai_credentials_present() -> bool:return Trueexcept Exception:pass- return bool(str(os.environ.get("XAI_API_KEY") or "").strip())+ try:+ from agent.secret_scope import get_secret+ except ImportError: # pragma: no cover — secret_scope is in-repo+ return bool(str(os.environ.get("XAI_API_KEY") or "").strip())+ return bool(str(get_secret("XAI_API_KEY") or "").strip())def _homeassistant_credentials_present() -> bool:diff --git a/plugins/model-providers/deepinfra/__init__.py b/plugins/model-providers/deepinfra/__init__.pyindex afa06548db1..57c6a9c4ce0 100644--- a/plugins/model-providers/deepinfra/__init__.py+++ b/plugins/model-providers/deepinfra/__init__.py@@ -29,9 +29,9 @@ class _DeepInfraProfile(ProviderProfile):``vision`` capability) so an image-gen/edit model that merely carriesa ``vision`` tag can't be picked as a chat-completions vision backend."""- import os+ from agent.secret_scope import get_secret- if not (os.environ.get("DEEPINFRA_API_KEY") or "").strip():+ if not (get_secret("DEEPINFRA_API_KEY") or "").strip():return Nonetry:from hermes_cli.models import _fetch_deepinfra_models_by_tagdiff --git a/plugins/teams_pipeline/pipeline.py b/plugins/teams_pipeline/pipeline.pyindex a4c600b11ec..38d66717bf3 100644--- a/plugins/teams_pipeline/pipeline.py+++ b/plugins/teams_pipeline/pipeline.py@@ -15,6 +15,8 @@ from typing import Any, Awaitable, Callable, Optionalimport httpx+from agent.secret_scope import get_secret+from agent.auxiliary_client import async_call_llm, extract_content_or_reasoningfrom hermes_constants import get_hermes_homefrom plugins.teams_pipeline.meetings import (@@ -109,7 +111,7 @@ class NotionWriter:API_VERSION = "2025-09-03"def __init__(self, *, api_key: str | None = None, transport: httpx.AsyncBaseTransport | None = None) -> None:- self.api_key = (api_key or os.getenv("NOTION_API_KEY", "")).strip()+ self.api_key = (api_key or get_secret("NOTION_API_KEY", "") or "").strip()self._transport = transportasync def write_summary(@@ -205,7 +207,7 @@ class LinearWriter:API_URL = "https://api.linear.app/graphql"def __init__(self, *, api_key: str | None = None, transport: httpx.AsyncBaseTransport | None = None) -> None:- self.api_key = (api_key or os.getenv("LINEAR_API_KEY", "")).strip()+ self.api_key = (api_key or get_secret("LINEAR_API_KEY", "") or "").strip()self._transport = transportasync def write_summary(diff --git a/tools/skills_hub.py b/tools/skills_hub.pyindex a193895ca5c..56964c13256 100644--- a/tools/skills_hub.py+++ b/tools/skills_hub.py@@ -382,8 +382,9 @@ class GitHubAuth:if self._cached_method != "github-app" or time.time() < self._app_token_expiry:return self._cached_token- # 1. Environment variable- token = os.environ.get("GITHUB_TOKEN") or os.environ.get("GH_TOKEN")+ # 1. Environment variable (profile-scoped under a multiplexed gateway)+ from agent.secret_scope import get_secret+ token = get_secret("GITHUB_TOKEN") or get_secret("GH_TOKEN")if token:self._cached_token = tokenself._cached_method = "pat"@@ -424,9 +425,10 @@ class GitHubAuth:def _try_github_app(self) -> Optional[str]:"""Try GitHub App JWT authentication if credentials are configured."""- app_id = os.environ.get("GITHUB_APP_ID")- key_path = os.environ.get("GITHUB_APP_PRIVATE_KEY_PATH")- installation_id = os.environ.get("GITHUB_APP_INSTALLATION_ID")+ from agent.secret_scope import get_secret+ app_id = get_secret("GITHUB_APP_ID")+ key_path = get_secret("GITHUB_APP_PRIVATE_KEY_PATH")+ installation_id = get_secret("GITHUB_APP_INSTALLATION_ID")if not all([app_id, key_path, installation_id]):return Nonediff --git a/tools/terminal_tool.py b/tools/terminal_tool.pyindex 244449ce97b..6572174819a 100644--- a/tools/terminal_tool.py+++ b/tools/terminal_tool.py@@ -159,10 +159,12 @@ def _check_vercel_sandbox_requirements(config: dict[str, Any]) -> bool:)return False- has_oidc = bool(os.getenv("VERCEL_OIDC_TOKEN"))- has_token = bool(os.getenv("VERCEL_TOKEN"))- has_project = bool(os.getenv("VERCEL_PROJECT_ID"))- has_team = bool(os.getenv("VERCEL_TEAM_ID"))+ from agent.secret_scope import get_secret++ has_oidc = bool(get_secret("VERCEL_OIDC_TOKEN"))+ has_token = bool(get_secret("VERCEL_TOKEN"))+ has_project = bool(get_secret("VERCEL_PROJECT_ID"))+ has_team = bool(get_secret("VERCEL_TEAM_ID"))if has_oidc:return True@@ -3189,7 +3191,8 @@ def check_terminal_requirements() -> bool:elif env_type == "daytona":from daytona import Daytona # noqa: F401 — SDK presence check- return os.getenv("DAYTONA_API_KEY") is not None+ from agent.secret_scope import get_secret+ return get_secret("DAYTONA_API_KEY") is not Noneelse:logger.error(diff --git a/tools/tirith_security.py b/tools/tirith_security.pyindex 2ea2eec749d..a284c6d4007 100644--- a/tools/tirith_security.py+++ b/tools/tirith_security.py@@ -283,7 +283,8 @@ def is_platform_supported() -> bool:def _download_file(url: str, dest: str, timeout: int = 10):"""Download a URL to a local file."""req = urllib.request.Request(url)- token = os.getenv("GITHUB_TOKEN")+ from agent.secret_scope import get_secret+ token = get_secret("GITHUB_TOKEN")if token:req.add_header("Authorization", f"token {token}")with urllib.request.urlopen(req, timeout=timeout) as resp, open(dest, "wb") as f:diff --git a/tools/tool_backend_helpers.py b/tools/tool_backend_helpers.pyindex de1fec7e8c5..b00814c0ad2 100644--- a/tools/tool_backend_helpers.py+++ b/tools/tool_backend_helpers.py@@ -298,7 +298,7 @@ def fal_key_is_configured() -> bool:checks and CLI setup-time checks agree. A whitespace-only valueis treated as unset everywhere."""- value = os.getenv("FAL_KEY")+ value = _scoped_credential("FAL_KEY") or Noneif value is None:# Fall back to the .env file for CLI paths that may run before# dotenv is loaded into os.environ.diff --git a/tools/xai_http.py b/tools/xai_http.pyindex 1e4f72a7fb0..5350a27d76f 100644--- a/tools/xai_http.py+++ b/tools/xai_http.py@@ -36,8 +36,14 @@ def has_xai_credentials() -> bool:other availability scans. Truthful refresh + expiry handling happensin ``search()`` (or whichever caller actually makes the request)."""- if os.environ.get("XAI_API_KEY", "").strip():- return True+ try:+ from agent.secret_scope import get_secret+ except ImportError: # pragma: no cover — secret_scope is in-repo+ if os.environ.get("XAI_API_KEY", "").strip():+ return True+ else:+ if (get_secret("XAI_API_KEY", "") or "").strip():+ return Truetry:from hermes_constants import get_hermes_homediff --git a/tui_gateway/methods_tools.py b/tui_gateway/methods_tools.pyindex 53be0136bcc..5896f1281c7 100644--- a/tui_gateway/methods_tools.py+++ b/tui_gateway/methods_tools.py@@ -1384,7 +1384,9 @@ def _(rid, params: dict) -> dict:try:cfg = _load_cfg()model = _resolve_model()- api_key = os.environ.get("HERMES_API_KEY", "") or cfg.get("api_key", "")+ from agent.secret_scope import get_secret++ api_key = get_secret("HERMES_API_KEY", "") or cfg.get("api_key", "")masked = f"****{api_key[-4:]}" if len(api_key) > 4 else "(not set)"base_url = os.environ.get("HERMES_BASE_URL", "") or cfg.get("base_url", "")