2026-02-23 23:52:07 +00:00
|
|
|
"""
|
2026-03-06 18:11:35 -08:00
|
|
|
Unified tool configuration for Hermes Agent.
|
|
|
|
|
|
|
|
|
|
`hermes tools` and `hermes setup tools` both enter this module.
|
|
|
|
|
Select a platform → toggle toolsets on/off → for newly enabled tools
|
|
|
|
|
that need API keys, run through provider-aware configuration.
|
2026-02-23 23:52:07 +00:00
|
|
|
|
|
|
|
|
Saves per-platform tool configuration to ~/.hermes/config.yaml under
|
|
|
|
|
the `platform_toolsets` key.
|
|
|
|
|
"""
|
|
|
|
|
|
feat: show estimated tool token context in hermes tools checklist (#3805)
* feat: show estimated tool token context in hermes tools checklist
Adds a live token estimate indicator to the bottom of the interactive
tool configuration checklist (hermes tools / hermes setup). As users
toggle toolsets on/off, the total estimated context cost updates in
real time.
Implementation:
- tools/registry.py: Add get_schema() for check_fn-free schema access
- hermes_cli/curses_ui.py: Add optional status_fn callback to
curses_checklist — renders at bottom-right of terminal, stays fixed
while items scroll
- hermes_cli/tools_config.py: Add _estimate_tool_tokens() using
tiktoken (cl100k_base, already installed) to count tokens in the
JSON-serialised OpenAI-format tool schemas. Results are cached
per-process. The status function deduplicates overlapping tools
(e.g. browser includes web_search) for accurate totals.
- 12 new tests covering estimation, caching, graceful degradation
when tiktoken is unavailable, status_fn wiring, deduplication,
and the numbered fallback display
* fix: use effective toolsets (includes plugins) for token estimation index mapping
The status_fn closure built ts_keys from CONFIGURABLE_TOOLSETS but the
checklist uses _get_effective_configurable_toolsets() which appends plugin
toolsets. With plugins present, the indices would mismatch, causing
IndexError when selecting a plugin toolset.
2026-03-29 15:36:56 -07:00
|
|
|
import json as _json
|
|
|
|
|
import logging
|
2026-02-23 23:52:07 +00:00
|
|
|
import sys
|
|
|
|
|
from pathlib import Path
|
2026-03-11 00:47:26 -07:00
|
|
|
from typing import Dict, List, Optional, Set
|
2026-02-23 23:52:07 +00:00
|
|
|
|
2026-02-24 00:01:39 +00:00
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
from hermes_cli.config import (
|
|
|
|
|
load_config, save_config, get_env_value, save_env_value,
|
|
|
|
|
)
|
2026-02-23 23:52:07 +00:00
|
|
|
from hermes_cli.colors import Colors, color
|
2026-03-26 15:27:27 -07:00
|
|
|
from hermes_cli.nous_subscription import (
|
|
|
|
|
apply_nous_managed_defaults,
|
|
|
|
|
get_nous_subscription_features,
|
|
|
|
|
)
|
2026-04-21 01:59:15 -07:00
|
|
|
from tools.tool_backend_helpers import fal_key_is_configured, managed_nous_tools_enabled
|
fix: extend hostname-match provider detection across remaining call sites
Aslaaen's fix in the original PR covered _detect_api_mode_for_url and the
two openai/xai sites in run_agent.py. This finishes the sweep: the same
substring-match false-positive class (e.g. https://api.openai.com.evil/v1,
https://proxy/api.openai.com/v1, https://api.anthropic.com.example/v1)
existed in eight more call sites, and the hostname helper was duplicated
in two modules.
- utils: add shared base_url_hostname() (single source of truth).
- hermes_cli/runtime_provider, run_agent: drop local duplicates, import
from utils. Reuse the cached AIAgent._base_url_hostname attribute
everywhere it's already populated.
- agent/auxiliary_client: switch codex-wrap auto-detect, max_completion_tokens
gate (auxiliary_max_tokens_param), and custom-endpoint max_tokens kwarg
selection to hostname equality.
- run_agent: native-anthropic check in the Claude-style model branch
and in the AIAgent init provider-auto-detect branch.
- agent/model_metadata: Anthropic /v1/models context-length lookup.
- hermes_cli/providers.determine_api_mode: anthropic / openai URL
heuristics for custom/unknown providers (the /anthropic path-suffix
convention for third-party gateways is preserved).
- tools/delegate_tool: anthropic detection for delegated subagent
runtimes.
- hermes_cli/setup, hermes_cli/tools_config: setup-wizard vision-endpoint
native-OpenAI detection (paired with deduping the repeated check into
a single is_native_openai boolean per branch).
Tests:
- tests/test_base_url_hostname.py covers the helper directly
(path-containing-host, host-suffix, trailing dot, port, case).
- tests/hermes_cli/test_determine_api_mode_hostname.py adds the same
regression class for determine_api_mode, plus a test that the
/anthropic third-party gateway convention still wins.
Also: add asslaenn5@gmail.com → Aslaaen to scripts/release.py AUTHOR_MAP.
2026-04-20 20:58:01 -07:00
|
|
|
from utils import base_url_hostname
|
2026-02-23 23:52:07 +00:00
|
|
|
|
feat: show estimated tool token context in hermes tools checklist (#3805)
* feat: show estimated tool token context in hermes tools checklist
Adds a live token estimate indicator to the bottom of the interactive
tool configuration checklist (hermes tools / hermes setup). As users
toggle toolsets on/off, the total estimated context cost updates in
real time.
Implementation:
- tools/registry.py: Add get_schema() for check_fn-free schema access
- hermes_cli/curses_ui.py: Add optional status_fn callback to
curses_checklist — renders at bottom-right of terminal, stays fixed
while items scroll
- hermes_cli/tools_config.py: Add _estimate_tool_tokens() using
tiktoken (cl100k_base, already installed) to count tokens in the
JSON-serialised OpenAI-format tool schemas. Results are cached
per-process. The status function deduplicates overlapping tools
(e.g. browser includes web_search) for accurate totals.
- 12 new tests covering estimation, caching, graceful degradation
when tiktoken is unavailable, status_fn wiring, deduplication,
and the numbered fallback display
* fix: use effective toolsets (includes plugins) for token estimation index mapping
The status_fn closure built ts_keys from CONFIGURABLE_TOOLSETS but the
checklist uses _get_effective_configurable_toolsets() which appends plugin
toolsets. With plugins present, the indices would mismatch, causing
IndexError when selecting a plugin toolset.
2026-03-29 15:36:56 -07:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
PROJECT_ROOT = Path(__file__).parent.parent.resolve()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ─── UI Helpers (shared with setup.py) ────────────────────────────────────────
|
|
|
|
|
|
refactor: extract shared helpers to deduplicate repeated code patterns (#7917)
* refactor: add shared helper modules for code deduplication
New modules:
- gateway/platforms/helpers.py: MessageDeduplicator, TextBatchAggregator,
strip_markdown, ThreadParticipationTracker, redact_phone
- hermes_cli/cli_output.py: print_info/success/warning/error, prompt helpers
- tools/path_security.py: validate_within_dir, has_traversal_component
- utils.py additions: safe_json_loads, read_json_file, read_jsonl,
append_jsonl, env_str/lower/int/bool helpers
- hermes_constants.py additions: get_config_path, get_skills_dir,
get_logs_dir, get_env_path
* refactor: migrate gateway adapters to shared helpers
- MessageDeduplicator: discord, slack, dingtalk, wecom, weixin, mattermost
- strip_markdown: bluebubbles, feishu, sms
- redact_phone: sms, signal
- ThreadParticipationTracker: discord, matrix
- _acquire/_release_platform_lock: telegram, discord, slack, whatsapp,
signal, weixin
Net -316 lines across 19 files.
* refactor: migrate CLI modules to shared helpers
- tools_config.py: use cli_output print/prompt + curses_radiolist (-117 lines)
- setup.py: use cli_output print helpers + curses_radiolist (-101 lines)
- mcp_config.py: use cli_output prompt (-15 lines)
- memory_setup.py: use curses_radiolist (-86 lines)
Net -263 lines across 5 files.
* refactor: migrate to shared utility helpers
- safe_json_loads: agent/display.py (4 sites)
- get_config_path: skill_utils.py, hermes_logging.py, hermes_time.py
- get_skills_dir: skill_utils.py, prompt_builder.py
- Token estimation dedup: skills_tool.py imports from model_metadata
- Path security: skills_tool, cronjob_tools, skill_manager_tool, credential_files
- Non-atomic YAML writes: doctor.py, config.py now use atomic_yaml_write
- Platform dict: new platforms.py, skills_config + tools_config derive from it
- Anthropic key: new get_anthropic_key() in auth.py, used by doctor/status/config/main
* test: update tests for shared helper migrations
- test_dingtalk: use _dedup.is_duplicate() instead of _is_duplicate()
- test_mattermost: use _dedup instead of _seen_posts/_prune_seen
- test_signal: import redact_phone from helpers instead of signal
- test_discord_connect: _platform_lock_identity instead of _token_lock_identity
- test_telegram_conflict: updated lock error message format
- test_skill_manager_tool: 'escapes' instead of 'boundary' in error msgs
2026-04-11 13:59:52 -07:00
|
|
|
from hermes_cli.cli_output import ( # noqa: E402 — late import block
|
|
|
|
|
print_error as _print_error,
|
|
|
|
|
print_info as _print_info,
|
|
|
|
|
print_success as _print_success,
|
|
|
|
|
print_warning as _print_warning,
|
|
|
|
|
prompt as _prompt,
|
|
|
|
|
)
|
2026-03-06 18:11:35 -08:00
|
|
|
|
|
|
|
|
# ─── Toolset Registry ─────────────────────────────────────────────────────────
|
|
|
|
|
|
2026-02-23 23:52:07 +00:00
|
|
|
# Toolsets shown in the configurator, grouped for display.
|
|
|
|
|
# Each entry: (toolset_name, label, description)
|
|
|
|
|
# These map to keys in toolsets.py TOOLSETS dict.
|
|
|
|
|
CONFIGURABLE_TOOLSETS = [
|
|
|
|
|
("web", "🔍 Web Search & Scraping", "web_search, web_extract"),
|
|
|
|
|
("browser", "🌐 Browser Automation", "navigate, click, type, scroll"),
|
|
|
|
|
("terminal", "💻 Terminal & Processes", "terminal, process"),
|
|
|
|
|
("file", "📁 File Operations", "read, write, patch, search"),
|
|
|
|
|
("code_execution", "⚡ Code Execution", "execute_code"),
|
|
|
|
|
("vision", "👁️ Vision / Image Analysis", "vision_analyze"),
|
|
|
|
|
("image_gen", "🎨 Image Generation", "image_generate"),
|
|
|
|
|
("moa", "🧠 Mixture of Agents", "mixture_of_agents"),
|
|
|
|
|
("tts", "🔊 Text-to-Speech", "text_to_speech"),
|
|
|
|
|
("skills", "📚 Skills", "list, view, manage"),
|
|
|
|
|
("todo", "📋 Task Planning", "todo"),
|
|
|
|
|
("memory", "💾 Memory", "persistent memory across sessions"),
|
|
|
|
|
("session_search", "🔎 Session Search", "search past conversations"),
|
|
|
|
|
("clarify", "❓ Clarifying Questions", "clarify"),
|
|
|
|
|
("delegation", "👥 Task Delegation", "delegate_task"),
|
2026-03-14 19:18:10 -07:00
|
|
|
("cronjob", "⏰ Cron Jobs", "create/list/update/pause/resume/run, with optional attached skills"),
|
2026-04-13 10:32:31 +00:00
|
|
|
("messaging", "📨 Cross-Platform Messaging", "send_message"),
|
2026-02-23 23:52:07 +00:00
|
|
|
("rl", "🧪 RL Training", "Tinker-Atropos training tools"),
|
2026-03-03 05:16:53 -08:00
|
|
|
("homeassistant", "🏠 Home Assistant", "smart home device control"),
|
2026-04-24 05:15:06 -07:00
|
|
|
("spotify", "🎵 Spotify", "playback, search, playlists, library"),
|
2026-02-23 23:52:07 +00:00
|
|
|
]
|
|
|
|
|
|
2026-03-08 22:54:11 -07:00
|
|
|
# Toolsets that are OFF by default for new installs.
|
|
|
|
|
# They're still in _HERMES_CORE_TOOLS (available at runtime if enabled),
|
|
|
|
|
# but the setup checklist won't pre-select them for first-time users.
|
2026-04-24 05:15:06 -07:00
|
|
|
_DEFAULT_OFF_TOOLSETS = {"moa", "homeassistant", "rl", "spotify"}
|
2026-03-08 22:54:11 -07:00
|
|
|
|
2026-03-22 04:55:34 -07:00
|
|
|
|
|
|
|
|
def _get_effective_configurable_toolsets():
|
|
|
|
|
"""Return CONFIGURABLE_TOOLSETS + any plugin-provided toolsets.
|
|
|
|
|
|
|
|
|
|
Plugin toolsets are appended at the end so they appear after the
|
|
|
|
|
built-in toolsets in the TUI checklist.
|
|
|
|
|
"""
|
|
|
|
|
result = list(CONFIGURABLE_TOOLSETS)
|
|
|
|
|
try:
|
2026-03-27 15:31:17 -07:00
|
|
|
from hermes_cli.plugins import discover_plugins, get_plugin_toolsets
|
|
|
|
|
discover_plugins() # idempotent — ensures plugins are loaded
|
2026-03-22 04:55:34 -07:00
|
|
|
result.extend(get_plugin_toolsets())
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_plugin_toolset_keys() -> set:
|
|
|
|
|
"""Return the set of toolset keys provided by plugins."""
|
|
|
|
|
try:
|
2026-03-27 15:31:17 -07:00
|
|
|
from hermes_cli.plugins import discover_plugins, get_plugin_toolsets
|
|
|
|
|
discover_plugins() # idempotent — ensures plugins are loaded
|
2026-03-22 04:55:34 -07:00
|
|
|
return {ts_key for ts_key, _, _ in get_plugin_toolsets()}
|
|
|
|
|
except Exception:
|
|
|
|
|
return set()
|
|
|
|
|
|
refactor: extract shared helpers to deduplicate repeated code patterns (#7917)
* refactor: add shared helper modules for code deduplication
New modules:
- gateway/platforms/helpers.py: MessageDeduplicator, TextBatchAggregator,
strip_markdown, ThreadParticipationTracker, redact_phone
- hermes_cli/cli_output.py: print_info/success/warning/error, prompt helpers
- tools/path_security.py: validate_within_dir, has_traversal_component
- utils.py additions: safe_json_loads, read_json_file, read_jsonl,
append_jsonl, env_str/lower/int/bool helpers
- hermes_constants.py additions: get_config_path, get_skills_dir,
get_logs_dir, get_env_path
* refactor: migrate gateway adapters to shared helpers
- MessageDeduplicator: discord, slack, dingtalk, wecom, weixin, mattermost
- strip_markdown: bluebubbles, feishu, sms
- redact_phone: sms, signal
- ThreadParticipationTracker: discord, matrix
- _acquire/_release_platform_lock: telegram, discord, slack, whatsapp,
signal, weixin
Net -316 lines across 19 files.
* refactor: migrate CLI modules to shared helpers
- tools_config.py: use cli_output print/prompt + curses_radiolist (-117 lines)
- setup.py: use cli_output print helpers + curses_radiolist (-101 lines)
- mcp_config.py: use cli_output prompt (-15 lines)
- memory_setup.py: use curses_radiolist (-86 lines)
Net -263 lines across 5 files.
* refactor: migrate to shared utility helpers
- safe_json_loads: agent/display.py (4 sites)
- get_config_path: skill_utils.py, hermes_logging.py, hermes_time.py
- get_skills_dir: skill_utils.py, prompt_builder.py
- Token estimation dedup: skills_tool.py imports from model_metadata
- Path security: skills_tool, cronjob_tools, skill_manager_tool, credential_files
- Non-atomic YAML writes: doctor.py, config.py now use atomic_yaml_write
- Platform dict: new platforms.py, skills_config + tools_config derive from it
- Anthropic key: new get_anthropic_key() in auth.py, used by doctor/status/config/main
* test: update tests for shared helper migrations
- test_dingtalk: use _dedup.is_duplicate() instead of _is_duplicate()
- test_mattermost: use _dedup instead of _seen_posts/_prune_seen
- test_signal: import redact_phone from helpers instead of signal
- test_discord_connect: _platform_lock_identity instead of _token_lock_identity
- test_telegram_conflict: updated lock error message format
- test_skill_manager_tool: 'escapes' instead of 'boundary' in error msgs
2026-04-11 13:59:52 -07:00
|
|
|
# Platform display config — derived from the canonical registry so every
|
|
|
|
|
# module shares the same data. Kept as dict-of-dicts for backward
|
|
|
|
|
# compatibility with existing ``PLATFORMS[key]["label"]`` access patterns.
|
|
|
|
|
from hermes_cli.platforms import PLATFORMS as _PLATFORMS_REGISTRY
|
|
|
|
|
|
2026-02-23 23:52:07 +00:00
|
|
|
PLATFORMS = {
|
refactor: extract shared helpers to deduplicate repeated code patterns (#7917)
* refactor: add shared helper modules for code deduplication
New modules:
- gateway/platforms/helpers.py: MessageDeduplicator, TextBatchAggregator,
strip_markdown, ThreadParticipationTracker, redact_phone
- hermes_cli/cli_output.py: print_info/success/warning/error, prompt helpers
- tools/path_security.py: validate_within_dir, has_traversal_component
- utils.py additions: safe_json_loads, read_json_file, read_jsonl,
append_jsonl, env_str/lower/int/bool helpers
- hermes_constants.py additions: get_config_path, get_skills_dir,
get_logs_dir, get_env_path
* refactor: migrate gateway adapters to shared helpers
- MessageDeduplicator: discord, slack, dingtalk, wecom, weixin, mattermost
- strip_markdown: bluebubbles, feishu, sms
- redact_phone: sms, signal
- ThreadParticipationTracker: discord, matrix
- _acquire/_release_platform_lock: telegram, discord, slack, whatsapp,
signal, weixin
Net -316 lines across 19 files.
* refactor: migrate CLI modules to shared helpers
- tools_config.py: use cli_output print/prompt + curses_radiolist (-117 lines)
- setup.py: use cli_output print helpers + curses_radiolist (-101 lines)
- mcp_config.py: use cli_output prompt (-15 lines)
- memory_setup.py: use curses_radiolist (-86 lines)
Net -263 lines across 5 files.
* refactor: migrate to shared utility helpers
- safe_json_loads: agent/display.py (4 sites)
- get_config_path: skill_utils.py, hermes_logging.py, hermes_time.py
- get_skills_dir: skill_utils.py, prompt_builder.py
- Token estimation dedup: skills_tool.py imports from model_metadata
- Path security: skills_tool, cronjob_tools, skill_manager_tool, credential_files
- Non-atomic YAML writes: doctor.py, config.py now use atomic_yaml_write
- Platform dict: new platforms.py, skills_config + tools_config derive from it
- Anthropic key: new get_anthropic_key() in auth.py, used by doctor/status/config/main
* test: update tests for shared helper migrations
- test_dingtalk: use _dedup.is_duplicate() instead of _is_duplicate()
- test_mattermost: use _dedup instead of _seen_posts/_prune_seen
- test_signal: import redact_phone from helpers instead of signal
- test_discord_connect: _platform_lock_identity instead of _token_lock_identity
- test_telegram_conflict: updated lock error message format
- test_skill_manager_tool: 'escapes' instead of 'boundary' in error msgs
2026-04-11 13:59:52 -07:00
|
|
|
k: {"label": info.label, "default_toolset": info.default_toolset}
|
|
|
|
|
for k, info in _PLATFORMS_REGISTRY.items()
|
2026-02-23 23:52:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
# ─── Tool Categories (provider-aware configuration) ──────────────────────────
|
|
|
|
|
# Maps toolset keys to their provider options. When a toolset is newly enabled,
|
|
|
|
|
# we use this to show provider selection and prompt for the right API keys.
|
|
|
|
|
# Toolsets not in this map either need no config or use the simple fallback.
|
|
|
|
|
|
|
|
|
|
TOOL_CATEGORIES = {
|
|
|
|
|
"tts": {
|
|
|
|
|
"name": "Text-to-Speech",
|
|
|
|
|
"icon": "🔊",
|
|
|
|
|
"providers": [
|
2026-03-26 15:27:27 -07:00
|
|
|
{
|
|
|
|
|
"name": "Nous Subscription",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "subscription",
|
2026-03-26 15:27:27 -07:00
|
|
|
"tag": "Managed OpenAI TTS billed to your subscription",
|
|
|
|
|
"env_vars": [],
|
|
|
|
|
"tts_provider": "openai",
|
|
|
|
|
"requires_nous_auth": True,
|
|
|
|
|
"managed_nous_feature": "tts",
|
|
|
|
|
"override_env_vars": ["VOICE_TOOLS_OPENAI_KEY", "OPENAI_API_KEY"],
|
|
|
|
|
},
|
2026-03-06 18:11:35 -08:00
|
|
|
{
|
|
|
|
|
"name": "Microsoft Edge TTS",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "★ recommended · free",
|
|
|
|
|
"tag": "Good quality, no API key needed",
|
2026-03-06 18:11:35 -08:00
|
|
|
"env_vars": [],
|
|
|
|
|
"tts_provider": "edge",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "OpenAI TTS",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "paid",
|
|
|
|
|
"tag": "High quality voices",
|
2026-03-06 18:11:35 -08:00
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "VOICE_TOOLS_OPENAI_KEY", "prompt": "OpenAI API key", "url": "https://platform.openai.com/api-keys"},
|
|
|
|
|
],
|
|
|
|
|
"tts_provider": "openai",
|
|
|
|
|
},
|
feat(xai): upgrade to Responses API, add TTS provider
Cherry-picked and trimmed from PR #10600 by Jaaneek.
- Switch xAI transport from openai_chat to codex_responses (Responses API)
- Add codex_responses detection for xAI in all runtime_provider resolution paths
- Add xAI api_mode detection in AIAgent.__init__ (provider name + URL auto-detect)
- Add extra_headers passthrough for codex_responses requests
- Add x-grok-conv-id session header for xAI prompt caching
- Add xAI reasoning support (encrypted_content include, no effort param)
- Move x-grok-conv-id from chat_completions path to codex_responses path
- Add xAI TTS provider (dedicated /v1/tts endpoint with Opus conversion)
- Add xAI provider aliases (grok, x-ai, x.ai) across auth, models, providers, auxiliary
- Trim xAI model list to agentic models (grok-4.20-reasoning, grok-4-1-fast-reasoning)
- Add XAI_API_KEY/XAI_BASE_URL to OPTIONAL_ENV_VARS
- Add xAI TTS config section, setup wizard entry, tools_config provider option
- Add shared xai_http.py helper for User-Agent string
Co-authored-by: Jaaneek <Jaaneek@users.noreply.github.com>
2026-04-15 22:27:26 -07:00
|
|
|
{
|
|
|
|
|
"name": "xAI TTS",
|
|
|
|
|
"tag": "Grok voices - requires xAI API key",
|
|
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "XAI_API_KEY", "prompt": "xAI API key", "url": "https://console.x.ai/"},
|
|
|
|
|
],
|
|
|
|
|
"tts_provider": "xai",
|
|
|
|
|
},
|
2026-03-06 18:11:35 -08:00
|
|
|
{
|
|
|
|
|
"name": "ElevenLabs",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "paid",
|
|
|
|
|
"tag": "Most natural voices",
|
2026-03-06 18:11:35 -08:00
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "ELEVENLABS_API_KEY", "prompt": "ElevenLabs API key", "url": "https://elevenlabs.io/app/settings/api-keys"},
|
|
|
|
|
],
|
|
|
|
|
"tts_provider": "elevenlabs",
|
|
|
|
|
},
|
2026-04-06 19:04:00 +01:00
|
|
|
{
|
|
|
|
|
"name": "Mistral (Voxtral TTS)",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "paid",
|
|
|
|
|
"tag": "Multilingual, native Opus",
|
2026-04-06 19:04:00 +01:00
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "MISTRAL_API_KEY", "prompt": "Mistral API key", "url": "https://console.mistral.ai/"},
|
|
|
|
|
],
|
|
|
|
|
"tts_provider": "mistral",
|
|
|
|
|
},
|
feat(tts): add Google Gemini TTS provider (#11229)
Adds Google Gemini TTS as the seventh voice provider, with 30 prebuilt
voices (Zephyr, Puck, Kore, Enceladus, Gacrux, etc.) and natural-language
prompt control. Integrates through the existing provider chain:
- tools/tts_tool.py: new _generate_gemini_tts() calls the
generativelanguage REST endpoint with responseModalities=[AUDIO],
wraps the returned 24kHz mono 16-bit PCM (L16) in a WAV RIFF header,
then ffmpeg-converts to MP3 or Opus depending on output extension.
For .ogg output, libopus is forced explicitly so Telegram voice
bubbles get Opus (ffmpeg defaults to Vorbis for .ogg).
- hermes_cli/tools_config.py: exposes 'Google Gemini TTS' as a provider
option in the curses-based 'hermes tools' UI.
- hermes_cli/setup.py: adds gemini to the setup wizard picker, tool
status display, and API key prompt branch (accepts existing
GEMINI_API_KEY or GOOGLE_API_KEY, falls back to Edge if neither set).
- tests/tools/test_tts_gemini.py: 15 unit tests covering WAV header
wrap correctness, env var fallback (GEMINI/GOOGLE), voice/model
overrides, snake_case vs camelCase inlineData handling, HTTP error
surfacing, and empty-audio edge cases.
- docs: TTS features page updated to list seven providers with the new
gemini config block and ffmpeg notes.
Live-tested against api key against gemini-2.5-flash-preview-tts: .wav,
.mp3, and Telegram-compatible .ogg (Opus codec) all produce valid
playable audio.
2026-04-16 14:23:16 -07:00
|
|
|
{
|
|
|
|
|
"name": "Google Gemini TTS",
|
|
|
|
|
"badge": "preview",
|
|
|
|
|
"tag": "30 prebuilt voices, controllable via prompts",
|
|
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "GEMINI_API_KEY", "prompt": "Gemini API key", "url": "https://aistudio.google.com/app/apikey"},
|
|
|
|
|
],
|
|
|
|
|
"tts_provider": "gemini",
|
|
|
|
|
},
|
feat(tts): complete KittenTTS integration (tools/setup/docs/tests)
Builds on @AxDSan's PR #2109 to finish the KittenTTS wiring so the
provider behaves like every other TTS backend end to end.
- tools/tts_tool.py: `_check_kittentts_available()` helper and wire
into `check_tts_requirements()`; extend Opus-conversion list to
include kittentts (WAV → Opus for Telegram voice bubbles); point the
missing-package error at `hermes setup tts`.
- hermes_cli/tools_config.py: add KittenTTS entry to the "Text-to-Speech"
toolset picker, with a `kittentts` post_setup hook that auto-installs
the wheel + soundfile via pip.
- hermes_cli/setup.py: `_install_kittentts_deps()`, new choice + install
flow in `_setup_tts_provider()`, provider_labels entry, and status row
in the `hermes setup` summary.
- website/docs/user-guide/features/tts.md: add KittenTTS to the provider
table, config example, ffmpeg note, and the zero-config voice-bubble tip.
- tests/tools/test_tts_kittentts.py: 10 unit tests covering generation,
model caching, config passthrough, ffmpeg conversion, availability
detection, and the missing-package dispatcher branch.
E2E verified against the real `kittentts` wheel:
- WAV direct output (pcm_s16le, 24kHz mono)
- MP3 conversion via ffmpeg (from WAV)
- Telegram flow (provider in Opus-conversion list) produces
`codec_name=opus`, 48kHz mono, `voice_compatible=True`, and the
`[[audio_as_voice]]` marker
- check_tts_requirements() returns True when kittentts is installed
2026-04-21 00:44:37 -07:00
|
|
|
{
|
|
|
|
|
"name": "KittenTTS",
|
|
|
|
|
"badge": "local · free",
|
|
|
|
|
"tag": "Lightweight local ONNX TTS (~25MB), no API key",
|
|
|
|
|
"env_vars": [],
|
|
|
|
|
"tts_provider": "kittentts",
|
|
|
|
|
"post_setup": "kittentts",
|
|
|
|
|
},
|
2026-03-06 18:11:35 -08:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
"web": {
|
|
|
|
|
"name": "Web Search & Extract",
|
2026-03-08 23:15:14 -07:00
|
|
|
"setup_title": "Select Search Provider",
|
feat(web): add Parallel as alternative web search/extract backend (#1696)
* feat(web): add Parallel as alternative web search/extract backend
Adds Parallel (parallel.ai) as a drop-in alternative to Firecrawl for
web_search and web_extract tools using the official parallel-web SDK.
- Backend selection via WEB_SEARCH_BACKEND env var (auto/parallel/firecrawl)
- Auto mode prefers Firecrawl when both keys present; Parallel when sole backend
- web_crawl remains Firecrawl-only with clear error when unavailable
- Lazy SDK imports, interrupt support, singleton clients
- 16 new unit tests for backend selection and client config
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
* fix: add PARALLEL_API_KEY to config registry and fix web_crawl policy tests
Follow-up for Parallel backend integration:
- Add PARALLEL_API_KEY to OPTIONAL_ENV_VARS (hermes doctor, env blocklist)
- Add to set_config_value api_keys list (hermes config set)
- Add to doctor keys display
- Fix 2 web_crawl policy tests that didn't set FIRECRAWL_API_KEY
(needed now that web_crawl has a Firecrawl availability guard)
* refactor: explicit backend selection via hermes tools, not auto-detect
Replace the auto-detect backend selection with explicit user choice:
- hermes tools saves WEB_SEARCH_BACKEND to .env when user picks a provider
- _get_backend() reads the explicit choice first
- Fallback only for manual/legacy config (uses whichever key is present)
- _is_provider_active() shows [active] for the selected web backend
- Updated tests, docs, and .env.example to remove 'auto' mode language
* refactor: use config.yaml for web backend, not env var
Match the TTS/browser pattern — web.backend is stored in config.yaml
(set by hermes tools), not as a WEB_SEARCH_BACKEND env var.
- _load_web_config() reads web: section from config.yaml
- _get_backend() reads web.backend from config, falls back to key detection
- _configure_provider() saves to config dict (saved to config.yaml)
- _is_provider_active() reads from config dict
- Removed WEB_SEARCH_BACKEND from .env.example, set_config_value, docs
- Updated all tests to mock _load_web_config instead of env vars
---------
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
2026-03-17 04:02:02 -07:00
|
|
|
"setup_note": "A free DuckDuckGo search skill is also included — skip this if you don't need a premium provider.",
|
2026-03-06 18:11:35 -08:00
|
|
|
"icon": "🔍",
|
|
|
|
|
"providers": [
|
2026-03-26 15:27:27 -07:00
|
|
|
{
|
|
|
|
|
"name": "Nous Subscription",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "subscription",
|
2026-03-26 15:27:27 -07:00
|
|
|
"tag": "Managed Firecrawl billed to your subscription",
|
|
|
|
|
"web_backend": "firecrawl",
|
|
|
|
|
"env_vars": [],
|
|
|
|
|
"requires_nous_auth": True,
|
|
|
|
|
"managed_nous_feature": "web",
|
|
|
|
|
"override_env_vars": ["FIRECRAWL_API_KEY", "FIRECRAWL_API_URL"],
|
|
|
|
|
},
|
2026-03-06 18:11:35 -08:00
|
|
|
{
|
|
|
|
|
"name": "Firecrawl Cloud",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "★ recommended",
|
|
|
|
|
"tag": "Full-featured search, extract, and crawl",
|
feat(web): add Parallel as alternative web search/extract backend (#1696)
* feat(web): add Parallel as alternative web search/extract backend
Adds Parallel (parallel.ai) as a drop-in alternative to Firecrawl for
web_search and web_extract tools using the official parallel-web SDK.
- Backend selection via WEB_SEARCH_BACKEND env var (auto/parallel/firecrawl)
- Auto mode prefers Firecrawl when both keys present; Parallel when sole backend
- web_crawl remains Firecrawl-only with clear error when unavailable
- Lazy SDK imports, interrupt support, singleton clients
- 16 new unit tests for backend selection and client config
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
* fix: add PARALLEL_API_KEY to config registry and fix web_crawl policy tests
Follow-up for Parallel backend integration:
- Add PARALLEL_API_KEY to OPTIONAL_ENV_VARS (hermes doctor, env blocklist)
- Add to set_config_value api_keys list (hermes config set)
- Add to doctor keys display
- Fix 2 web_crawl policy tests that didn't set FIRECRAWL_API_KEY
(needed now that web_crawl has a Firecrawl availability guard)
* refactor: explicit backend selection via hermes tools, not auto-detect
Replace the auto-detect backend selection with explicit user choice:
- hermes tools saves WEB_SEARCH_BACKEND to .env when user picks a provider
- _get_backend() reads the explicit choice first
- Fallback only for manual/legacy config (uses whichever key is present)
- _is_provider_active() shows [active] for the selected web backend
- Updated tests, docs, and .env.example to remove 'auto' mode language
* refactor: use config.yaml for web backend, not env var
Match the TTS/browser pattern — web.backend is stored in config.yaml
(set by hermes tools), not as a WEB_SEARCH_BACKEND env var.
- _load_web_config() reads web: section from config.yaml
- _get_backend() reads web.backend from config, falls back to key detection
- _configure_provider() saves to config dict (saved to config.yaml)
- _is_provider_active() reads from config dict
- Removed WEB_SEARCH_BACKEND from .env.example, set_config_value, docs
- Updated all tests to mock _load_web_config instead of env vars
---------
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
2026-03-17 04:02:02 -07:00
|
|
|
"web_backend": "firecrawl",
|
2026-03-06 18:11:35 -08:00
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "FIRECRAWL_API_KEY", "prompt": "Firecrawl API key", "url": "https://firecrawl.dev"},
|
|
|
|
|
],
|
|
|
|
|
},
|
2026-03-28 17:35:53 -07:00
|
|
|
{
|
|
|
|
|
"name": "Exa",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "paid",
|
|
|
|
|
"tag": "Neural search with semantic understanding",
|
2026-03-28 17:35:53 -07:00
|
|
|
"web_backend": "exa",
|
|
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "EXA_API_KEY", "prompt": "Exa API key", "url": "https://exa.ai"},
|
|
|
|
|
],
|
|
|
|
|
},
|
feat(web): add Parallel as alternative web search/extract backend (#1696)
* feat(web): add Parallel as alternative web search/extract backend
Adds Parallel (parallel.ai) as a drop-in alternative to Firecrawl for
web_search and web_extract tools using the official parallel-web SDK.
- Backend selection via WEB_SEARCH_BACKEND env var (auto/parallel/firecrawl)
- Auto mode prefers Firecrawl when both keys present; Parallel when sole backend
- web_crawl remains Firecrawl-only with clear error when unavailable
- Lazy SDK imports, interrupt support, singleton clients
- 16 new unit tests for backend selection and client config
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
* fix: add PARALLEL_API_KEY to config registry and fix web_crawl policy tests
Follow-up for Parallel backend integration:
- Add PARALLEL_API_KEY to OPTIONAL_ENV_VARS (hermes doctor, env blocklist)
- Add to set_config_value api_keys list (hermes config set)
- Add to doctor keys display
- Fix 2 web_crawl policy tests that didn't set FIRECRAWL_API_KEY
(needed now that web_crawl has a Firecrawl availability guard)
* refactor: explicit backend selection via hermes tools, not auto-detect
Replace the auto-detect backend selection with explicit user choice:
- hermes tools saves WEB_SEARCH_BACKEND to .env when user picks a provider
- _get_backend() reads the explicit choice first
- Fallback only for manual/legacy config (uses whichever key is present)
- _is_provider_active() shows [active] for the selected web backend
- Updated tests, docs, and .env.example to remove 'auto' mode language
* refactor: use config.yaml for web backend, not env var
Match the TTS/browser pattern — web.backend is stored in config.yaml
(set by hermes tools), not as a WEB_SEARCH_BACKEND env var.
- _load_web_config() reads web: section from config.yaml
- _get_backend() reads web.backend from config, falls back to key detection
- _configure_provider() saves to config dict (saved to config.yaml)
- _is_provider_active() reads from config dict
- Removed WEB_SEARCH_BACKEND from .env.example, set_config_value, docs
- Updated all tests to mock _load_web_config instead of env vars
---------
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
2026-03-17 04:02:02 -07:00
|
|
|
{
|
|
|
|
|
"name": "Parallel",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "paid",
|
|
|
|
|
"tag": "AI-powered search and extract",
|
feat(web): add Parallel as alternative web search/extract backend (#1696)
* feat(web): add Parallel as alternative web search/extract backend
Adds Parallel (parallel.ai) as a drop-in alternative to Firecrawl for
web_search and web_extract tools using the official parallel-web SDK.
- Backend selection via WEB_SEARCH_BACKEND env var (auto/parallel/firecrawl)
- Auto mode prefers Firecrawl when both keys present; Parallel when sole backend
- web_crawl remains Firecrawl-only with clear error when unavailable
- Lazy SDK imports, interrupt support, singleton clients
- 16 new unit tests for backend selection and client config
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
* fix: add PARALLEL_API_KEY to config registry and fix web_crawl policy tests
Follow-up for Parallel backend integration:
- Add PARALLEL_API_KEY to OPTIONAL_ENV_VARS (hermes doctor, env blocklist)
- Add to set_config_value api_keys list (hermes config set)
- Add to doctor keys display
- Fix 2 web_crawl policy tests that didn't set FIRECRAWL_API_KEY
(needed now that web_crawl has a Firecrawl availability guard)
* refactor: explicit backend selection via hermes tools, not auto-detect
Replace the auto-detect backend selection with explicit user choice:
- hermes tools saves WEB_SEARCH_BACKEND to .env when user picks a provider
- _get_backend() reads the explicit choice first
- Fallback only for manual/legacy config (uses whichever key is present)
- _is_provider_active() shows [active] for the selected web backend
- Updated tests, docs, and .env.example to remove 'auto' mode language
* refactor: use config.yaml for web backend, not env var
Match the TTS/browser pattern — web.backend is stored in config.yaml
(set by hermes tools), not as a WEB_SEARCH_BACKEND env var.
- _load_web_config() reads web: section from config.yaml
- _get_backend() reads web.backend from config, falls back to key detection
- _configure_provider() saves to config dict (saved to config.yaml)
- _is_provider_active() reads from config dict
- Removed WEB_SEARCH_BACKEND from .env.example, set_config_value, docs
- Updated all tests to mock _load_web_config instead of env vars
---------
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
2026-03-17 04:02:02 -07:00
|
|
|
"web_backend": "parallel",
|
|
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "PARALLEL_API_KEY", "prompt": "Parallel API key", "url": "https://parallel.ai"},
|
|
|
|
|
],
|
|
|
|
|
},
|
2026-03-17 04:28:03 -07:00
|
|
|
{
|
|
|
|
|
"name": "Tavily",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "free tier",
|
|
|
|
|
"tag": "Search, extract, and crawl — 1000 free searches/mo",
|
2026-03-17 04:28:03 -07:00
|
|
|
"web_backend": "tavily",
|
|
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "TAVILY_API_KEY", "prompt": "Tavily API key", "url": "https://app.tavily.com/home"},
|
|
|
|
|
],
|
|
|
|
|
},
|
2026-03-06 18:11:35 -08:00
|
|
|
{
|
|
|
|
|
"name": "Firecrawl Self-Hosted",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "free · self-hosted",
|
|
|
|
|
"tag": "Run your own Firecrawl instance (Docker)",
|
feat(web): add Parallel as alternative web search/extract backend (#1696)
* feat(web): add Parallel as alternative web search/extract backend
Adds Parallel (parallel.ai) as a drop-in alternative to Firecrawl for
web_search and web_extract tools using the official parallel-web SDK.
- Backend selection via WEB_SEARCH_BACKEND env var (auto/parallel/firecrawl)
- Auto mode prefers Firecrawl when both keys present; Parallel when sole backend
- web_crawl remains Firecrawl-only with clear error when unavailable
- Lazy SDK imports, interrupt support, singleton clients
- 16 new unit tests for backend selection and client config
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
* fix: add PARALLEL_API_KEY to config registry and fix web_crawl policy tests
Follow-up for Parallel backend integration:
- Add PARALLEL_API_KEY to OPTIONAL_ENV_VARS (hermes doctor, env blocklist)
- Add to set_config_value api_keys list (hermes config set)
- Add to doctor keys display
- Fix 2 web_crawl policy tests that didn't set FIRECRAWL_API_KEY
(needed now that web_crawl has a Firecrawl availability guard)
* refactor: explicit backend selection via hermes tools, not auto-detect
Replace the auto-detect backend selection with explicit user choice:
- hermes tools saves WEB_SEARCH_BACKEND to .env when user picks a provider
- _get_backend() reads the explicit choice first
- Fallback only for manual/legacy config (uses whichever key is present)
- _is_provider_active() shows [active] for the selected web backend
- Updated tests, docs, and .env.example to remove 'auto' mode language
* refactor: use config.yaml for web backend, not env var
Match the TTS/browser pattern — web.backend is stored in config.yaml
(set by hermes tools), not as a WEB_SEARCH_BACKEND env var.
- _load_web_config() reads web: section from config.yaml
- _get_backend() reads web.backend from config, falls back to key detection
- _configure_provider() saves to config dict (saved to config.yaml)
- _is_provider_active() reads from config dict
- Removed WEB_SEARCH_BACKEND from .env.example, set_config_value, docs
- Updated all tests to mock _load_web_config instead of env vars
---------
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
2026-03-17 04:02:02 -07:00
|
|
|
"web_backend": "firecrawl",
|
2026-03-06 18:11:35 -08:00
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "FIRECRAWL_API_URL", "prompt": "Your Firecrawl instance URL (e.g., http://localhost:3002)"},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
"image_gen": {
|
|
|
|
|
"name": "Image Generation",
|
|
|
|
|
"icon": "🎨",
|
|
|
|
|
"providers": [
|
2026-03-26 15:27:27 -07:00
|
|
|
{
|
|
|
|
|
"name": "Nous Subscription",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "subscription",
|
2026-03-26 15:27:27 -07:00
|
|
|
"tag": "Managed FAL image generation billed to your subscription",
|
|
|
|
|
"env_vars": [],
|
|
|
|
|
"requires_nous_auth": True,
|
|
|
|
|
"managed_nous_feature": "image_gen",
|
|
|
|
|
"override_env_vars": ["FAL_KEY"],
|
feat(image_gen): multi-model FAL support with picker in hermes tools (#11265)
* feat(image_gen): multi-model FAL support with picker in hermes tools
Adds 8 FAL text-to-image models selectable via `hermes tools` →
Image Generation → (FAL.ai | Nous Subscription) → model picker.
Models supported:
- fal-ai/flux-2/klein/9b (new default, <1s, $0.006/MP)
- fal-ai/flux-2-pro (previous default, kept backward-compat upscaling)
- fal-ai/z-image/turbo (Tongyi-MAI, bilingual EN/CN)
- fal-ai/nano-banana (Gemini 2.5 Flash Image)
- fal-ai/gpt-image-1.5 (with quality tier: low/medium/high)
- fal-ai/ideogram/v3 (best typography)
- fal-ai/recraft-v3 (vector, brand styles)
- fal-ai/qwen-image (LLM-based)
Architecture:
- FAL_MODELS catalog declares per-model size family, defaults, supports
whitelist, and upscale flag. Three size families handled uniformly:
image_size_preset (flux family), aspect_ratio (nano-banana), and
gpt_literal (gpt-image-1.5).
- _build_fal_payload() translates unified inputs (prompt + aspect_ratio)
into model-specific payloads, merges defaults, applies caller overrides,
wires GPT quality_setting, then filters to the supports whitelist — so
models never receive rejected keys.
- IMAGEGEN_BACKENDS registry in tools_config prepares for future imagegen
providers (Replicate, Stability, etc.); each provider entry tags itself
with imagegen_backend: 'fal' to select the right catalog.
- Upscaler (Clarity) defaults off for new models (preserves <1s value
prop), on for flux-2-pro (backward-compat). Per-model via FAL_MODELS.
Config:
image_gen.model = fal-ai/flux-2/klein/9b (new)
image_gen.quality_setting = medium (new, GPT only)
image_gen.use_gateway = bool (existing)
Agent-facing schema unchanged (prompt + aspect_ratio only) — model
choice is a user-level config decision, not an agent-level arg.
Picker uses curses_radiolist (arrow keys, auto numbered-fallback on
non-TTY). Column-aligned: Model / Speed / Strengths / Price.
Docs: image-generation.md rewritten with the model table and picker
walkthrough. tools-reference, tool-gateway, overview updated to drop
the stale "FLUX 2 Pro" wording.
Tests: 42 new in tests/tools/test_image_generation.py covering catalog
integrity, all 3 size families, supports filter, default merging, GPT
quality wiring, model resolution fallback. 8 new in
tests/hermes_cli/test_tools_config.py for picker wiring (registry,
config writes, GPT quality follow-up prompt, corrupt-config repair).
* feat(image_gen): translate managed-gateway 4xx to actionable error
When the Nous Subscription managed FAL proxy rejects a model with 4xx
(likely portal-side allowlist miss or billing gate), surface a clear
message explaining:
1. The rejected model ID + HTTP status
2. Two remediation paths: set FAL_KEY for direct access, or
pick a different model via `hermes tools`
5xx, connection errors, and direct-FAL errors pass through unchanged
(those have different root causes and reasonable native messages).
Motivation: new FAL models added to this release (flux-2-klein-9b,
z-image-turbo, nano-banana, gpt-image-1.5, ideogram-v3, recraft-v3,
qwen-image) are untested against the Nous Portal proxy. If the portal
allowlists model IDs, users on Nous Subscription will hit cryptic
4xx errors without guidance on how to work around it.
Tests: 8 new cases covering status extraction across httpx/fal error
shapes and 4xx-vs-5xx-vs-ConnectionError translation policy.
Docs: brief note in image-generation.md for Nous subscribers.
Operator action (Nous Portal side): verify that fal-queue-gateway
passes through these 7 new FAL model IDs. If the proxy has an
allowlist, add them; otherwise Nous Subscription users will see the
new translated error and fall back to direct FAL.
* feat(image_gen): pin GPT-Image quality to medium (no user choice)
Previously the tools picker asked a follow-up question for GPT-Image
quality tier (low / medium / high) and persisted the answer to
`image_gen.quality_setting`. This created two problems:
1. Nous Portal billing complexity — the 22x cost spread between tiers
($0.009 low / $0.20 high) forces the gateway to meter per-tier per
user, which the portal team can't easily support at launch.
2. User footgun — anyone picking `high` by mistake burns through
credit ~6x faster than `medium`.
This commit pins quality at medium by baking it into FAL_MODELS
defaults for gpt-image-1.5 and removes all user-facing override paths:
- Removed `_resolve_gpt_quality()` runtime lookup
- Removed `honors_quality_setting` flag on the model entry
- Removed `_configure_gpt_quality_setting()` picker helper
- Removed `_GPT_QUALITY_CHOICES` constant
- Removed the follow-up prompt call in `_configure_imagegen_model()`
- Even if a user manually edits `image_gen.quality_setting` in
config.yaml, no code path reads it — always sends medium.
Tests:
- Replaced TestGptQualitySetting (6 tests) with TestGptQualityPinnedToMedium
(5 tests) — proves medium is baked in, config is ignored, flag is
removed, helper is removed, non-gpt models never get quality.
- Replaced test_picker_with_gpt_image_also_prompts_quality with
test_picker_with_gpt_image_does_not_prompt_quality — proves only 1
picker call fires when gpt-image is selected (no quality follow-up).
Docs updated: image-generation.md replaces the quality-tier table
with a short note explaining the pinning decision.
* docs(image_gen): drop stale 'wires GPT quality tier' line from internals section
Caught in a cleanup sweep after pinning quality to medium. The
"How It Works Internally" walkthrough still described the removed
quality-wiring step.
2026-04-16 20:19:53 -07:00
|
|
|
"imagegen_backend": "fal",
|
2026-03-26 15:27:27 -07:00
|
|
|
},
|
2026-03-06 18:11:35 -08:00
|
|
|
{
|
|
|
|
|
"name": "FAL.ai",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "paid",
|
feat(image_gen): multi-model FAL support with picker in hermes tools (#11265)
* feat(image_gen): multi-model FAL support with picker in hermes tools
Adds 8 FAL text-to-image models selectable via `hermes tools` →
Image Generation → (FAL.ai | Nous Subscription) → model picker.
Models supported:
- fal-ai/flux-2/klein/9b (new default, <1s, $0.006/MP)
- fal-ai/flux-2-pro (previous default, kept backward-compat upscaling)
- fal-ai/z-image/turbo (Tongyi-MAI, bilingual EN/CN)
- fal-ai/nano-banana (Gemini 2.5 Flash Image)
- fal-ai/gpt-image-1.5 (with quality tier: low/medium/high)
- fal-ai/ideogram/v3 (best typography)
- fal-ai/recraft-v3 (vector, brand styles)
- fal-ai/qwen-image (LLM-based)
Architecture:
- FAL_MODELS catalog declares per-model size family, defaults, supports
whitelist, and upscale flag. Three size families handled uniformly:
image_size_preset (flux family), aspect_ratio (nano-banana), and
gpt_literal (gpt-image-1.5).
- _build_fal_payload() translates unified inputs (prompt + aspect_ratio)
into model-specific payloads, merges defaults, applies caller overrides,
wires GPT quality_setting, then filters to the supports whitelist — so
models never receive rejected keys.
- IMAGEGEN_BACKENDS registry in tools_config prepares for future imagegen
providers (Replicate, Stability, etc.); each provider entry tags itself
with imagegen_backend: 'fal' to select the right catalog.
- Upscaler (Clarity) defaults off for new models (preserves <1s value
prop), on for flux-2-pro (backward-compat). Per-model via FAL_MODELS.
Config:
image_gen.model = fal-ai/flux-2/klein/9b (new)
image_gen.quality_setting = medium (new, GPT only)
image_gen.use_gateway = bool (existing)
Agent-facing schema unchanged (prompt + aspect_ratio only) — model
choice is a user-level config decision, not an agent-level arg.
Picker uses curses_radiolist (arrow keys, auto numbered-fallback on
non-TTY). Column-aligned: Model / Speed / Strengths / Price.
Docs: image-generation.md rewritten with the model table and picker
walkthrough. tools-reference, tool-gateway, overview updated to drop
the stale "FLUX 2 Pro" wording.
Tests: 42 new in tests/tools/test_image_generation.py covering catalog
integrity, all 3 size families, supports filter, default merging, GPT
quality wiring, model resolution fallback. 8 new in
tests/hermes_cli/test_tools_config.py for picker wiring (registry,
config writes, GPT quality follow-up prompt, corrupt-config repair).
* feat(image_gen): translate managed-gateway 4xx to actionable error
When the Nous Subscription managed FAL proxy rejects a model with 4xx
(likely portal-side allowlist miss or billing gate), surface a clear
message explaining:
1. The rejected model ID + HTTP status
2. Two remediation paths: set FAL_KEY for direct access, or
pick a different model via `hermes tools`
5xx, connection errors, and direct-FAL errors pass through unchanged
(those have different root causes and reasonable native messages).
Motivation: new FAL models added to this release (flux-2-klein-9b,
z-image-turbo, nano-banana, gpt-image-1.5, ideogram-v3, recraft-v3,
qwen-image) are untested against the Nous Portal proxy. If the portal
allowlists model IDs, users on Nous Subscription will hit cryptic
4xx errors without guidance on how to work around it.
Tests: 8 new cases covering status extraction across httpx/fal error
shapes and 4xx-vs-5xx-vs-ConnectionError translation policy.
Docs: brief note in image-generation.md for Nous subscribers.
Operator action (Nous Portal side): verify that fal-queue-gateway
passes through these 7 new FAL model IDs. If the proxy has an
allowlist, add them; otherwise Nous Subscription users will see the
new translated error and fall back to direct FAL.
* feat(image_gen): pin GPT-Image quality to medium (no user choice)
Previously the tools picker asked a follow-up question for GPT-Image
quality tier (low / medium / high) and persisted the answer to
`image_gen.quality_setting`. This created two problems:
1. Nous Portal billing complexity — the 22x cost spread between tiers
($0.009 low / $0.20 high) forces the gateway to meter per-tier per
user, which the portal team can't easily support at launch.
2. User footgun — anyone picking `high` by mistake burns through
credit ~6x faster than `medium`.
This commit pins quality at medium by baking it into FAL_MODELS
defaults for gpt-image-1.5 and removes all user-facing override paths:
- Removed `_resolve_gpt_quality()` runtime lookup
- Removed `honors_quality_setting` flag on the model entry
- Removed `_configure_gpt_quality_setting()` picker helper
- Removed `_GPT_QUALITY_CHOICES` constant
- Removed the follow-up prompt call in `_configure_imagegen_model()`
- Even if a user manually edits `image_gen.quality_setting` in
config.yaml, no code path reads it — always sends medium.
Tests:
- Replaced TestGptQualitySetting (6 tests) with TestGptQualityPinnedToMedium
(5 tests) — proves medium is baked in, config is ignored, flag is
removed, helper is removed, non-gpt models never get quality.
- Replaced test_picker_with_gpt_image_also_prompts_quality with
test_picker_with_gpt_image_does_not_prompt_quality — proves only 1
picker call fires when gpt-image is selected (no quality follow-up).
Docs updated: image-generation.md replaces the quality-tier table
with a short note explaining the pinning decision.
* docs(image_gen): drop stale 'wires GPT quality tier' line from internals section
Caught in a cleanup sweep after pinning quality to medium. The
"How It Works Internally" walkthrough still described the removed
quality-wiring step.
2026-04-16 20:19:53 -07:00
|
|
|
"tag": "Pick from flux-2-klein, flux-2-pro, gpt-image, nano-banana, etc.",
|
2026-03-06 18:11:35 -08:00
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "FAL_KEY", "prompt": "FAL API key", "url": "https://fal.ai/dashboard/keys"},
|
|
|
|
|
],
|
feat(image_gen): multi-model FAL support with picker in hermes tools (#11265)
* feat(image_gen): multi-model FAL support with picker in hermes tools
Adds 8 FAL text-to-image models selectable via `hermes tools` →
Image Generation → (FAL.ai | Nous Subscription) → model picker.
Models supported:
- fal-ai/flux-2/klein/9b (new default, <1s, $0.006/MP)
- fal-ai/flux-2-pro (previous default, kept backward-compat upscaling)
- fal-ai/z-image/turbo (Tongyi-MAI, bilingual EN/CN)
- fal-ai/nano-banana (Gemini 2.5 Flash Image)
- fal-ai/gpt-image-1.5 (with quality tier: low/medium/high)
- fal-ai/ideogram/v3 (best typography)
- fal-ai/recraft-v3 (vector, brand styles)
- fal-ai/qwen-image (LLM-based)
Architecture:
- FAL_MODELS catalog declares per-model size family, defaults, supports
whitelist, and upscale flag. Three size families handled uniformly:
image_size_preset (flux family), aspect_ratio (nano-banana), and
gpt_literal (gpt-image-1.5).
- _build_fal_payload() translates unified inputs (prompt + aspect_ratio)
into model-specific payloads, merges defaults, applies caller overrides,
wires GPT quality_setting, then filters to the supports whitelist — so
models never receive rejected keys.
- IMAGEGEN_BACKENDS registry in tools_config prepares for future imagegen
providers (Replicate, Stability, etc.); each provider entry tags itself
with imagegen_backend: 'fal' to select the right catalog.
- Upscaler (Clarity) defaults off for new models (preserves <1s value
prop), on for flux-2-pro (backward-compat). Per-model via FAL_MODELS.
Config:
image_gen.model = fal-ai/flux-2/klein/9b (new)
image_gen.quality_setting = medium (new, GPT only)
image_gen.use_gateway = bool (existing)
Agent-facing schema unchanged (prompt + aspect_ratio only) — model
choice is a user-level config decision, not an agent-level arg.
Picker uses curses_radiolist (arrow keys, auto numbered-fallback on
non-TTY). Column-aligned: Model / Speed / Strengths / Price.
Docs: image-generation.md rewritten with the model table and picker
walkthrough. tools-reference, tool-gateway, overview updated to drop
the stale "FLUX 2 Pro" wording.
Tests: 42 new in tests/tools/test_image_generation.py covering catalog
integrity, all 3 size families, supports filter, default merging, GPT
quality wiring, model resolution fallback. 8 new in
tests/hermes_cli/test_tools_config.py for picker wiring (registry,
config writes, GPT quality follow-up prompt, corrupt-config repair).
* feat(image_gen): translate managed-gateway 4xx to actionable error
When the Nous Subscription managed FAL proxy rejects a model with 4xx
(likely portal-side allowlist miss or billing gate), surface a clear
message explaining:
1. The rejected model ID + HTTP status
2. Two remediation paths: set FAL_KEY for direct access, or
pick a different model via `hermes tools`
5xx, connection errors, and direct-FAL errors pass through unchanged
(those have different root causes and reasonable native messages).
Motivation: new FAL models added to this release (flux-2-klein-9b,
z-image-turbo, nano-banana, gpt-image-1.5, ideogram-v3, recraft-v3,
qwen-image) are untested against the Nous Portal proxy. If the portal
allowlists model IDs, users on Nous Subscription will hit cryptic
4xx errors without guidance on how to work around it.
Tests: 8 new cases covering status extraction across httpx/fal error
shapes and 4xx-vs-5xx-vs-ConnectionError translation policy.
Docs: brief note in image-generation.md for Nous subscribers.
Operator action (Nous Portal side): verify that fal-queue-gateway
passes through these 7 new FAL model IDs. If the proxy has an
allowlist, add them; otherwise Nous Subscription users will see the
new translated error and fall back to direct FAL.
* feat(image_gen): pin GPT-Image quality to medium (no user choice)
Previously the tools picker asked a follow-up question for GPT-Image
quality tier (low / medium / high) and persisted the answer to
`image_gen.quality_setting`. This created two problems:
1. Nous Portal billing complexity — the 22x cost spread between tiers
($0.009 low / $0.20 high) forces the gateway to meter per-tier per
user, which the portal team can't easily support at launch.
2. User footgun — anyone picking `high` by mistake burns through
credit ~6x faster than `medium`.
This commit pins quality at medium by baking it into FAL_MODELS
defaults for gpt-image-1.5 and removes all user-facing override paths:
- Removed `_resolve_gpt_quality()` runtime lookup
- Removed `honors_quality_setting` flag on the model entry
- Removed `_configure_gpt_quality_setting()` picker helper
- Removed `_GPT_QUALITY_CHOICES` constant
- Removed the follow-up prompt call in `_configure_imagegen_model()`
- Even if a user manually edits `image_gen.quality_setting` in
config.yaml, no code path reads it — always sends medium.
Tests:
- Replaced TestGptQualitySetting (6 tests) with TestGptQualityPinnedToMedium
(5 tests) — proves medium is baked in, config is ignored, flag is
removed, helper is removed, non-gpt models never get quality.
- Replaced test_picker_with_gpt_image_also_prompts_quality with
test_picker_with_gpt_image_does_not_prompt_quality — proves only 1
picker call fires when gpt-image is selected (no quality follow-up).
Docs updated: image-generation.md replaces the quality-tier table
with a short note explaining the pinning decision.
* docs(image_gen): drop stale 'wires GPT quality tier' line from internals section
Caught in a cleanup sweep after pinning quality to medium. The
"How It Works Internally" walkthrough still described the removed
quality-wiring step.
2026-04-16 20:19:53 -07:00
|
|
|
"imagegen_backend": "fal",
|
2026-03-06 18:11:35 -08:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
"browser": {
|
|
|
|
|
"name": "Browser Automation",
|
|
|
|
|
"icon": "🌐",
|
|
|
|
|
"providers": [
|
2026-03-26 15:27:27 -07:00
|
|
|
{
|
feat: switch managed browser provider from Browserbase to Browser Use (#5750)
* feat: switch managed browser provider from Browserbase to Browser Use
The Nous subscription tool gateway now routes browser automation through
Browser Use instead of Browserbase. This commit:
- Adds managed Nous gateway support to BrowserUseProvider (idempotency
keys, X-BB-API-Key auth header, external_call_id persistence)
- Removes managed gateway support from BrowserbaseProvider (now
direct-only via BROWSERBASE_API_KEY/BROWSERBASE_PROJECT_ID)
- Updates browser_tool.py fallback: prefers Browser Use over Browserbase
- Updates nous_subscription.py: gateway vendor 'browser-use', auto-config
sets cloud_provider='browser-use' for new subscribers
- Updates tools_config.py: Nous Subscription entry now uses Browser Use
- Updates setup.py, cli.py, status.py, prompt_builder.py display strings
- Updates all affected tests to match new behavior
Browserbase remains fully functional for users with direct API credentials.
The change only affects the managed/subscription path.
* chore: remove redundant Browser Use hint from system prompt
* fix: upgrade Browser Use provider to v3 API
- Base URL: api/v2 -> api/v3 (v2 is legacy)
- Unified all endpoints to use native Browser Use paths:
- POST /browsers (create session, returns cdpUrl)
- PATCH /browsers/{id} with {action: stop} (close session)
- Removed managed-mode branching that used Browserbase-style
/v1/sessions paths — v3 gateway now supports /browsers directly
- Removed unused managed_mode variable in close_session
* fix(browser-use): use X-Browser-Use-API-Key header for managed mode
The managed gateway expects X-Browser-Use-API-Key, not X-BB-API-Key
(which is a Browserbase-specific header). Using the wrong header caused
a 401 AUTH_ERROR on every managed-mode browser session create.
Simplified _headers() to always use X-Browser-Use-API-Key regardless
of direct vs managed mode.
* fix(nous_subscription): browserbase explicit provider is direct-only
Since managed Nous gateway now routes through Browser Use, the
browserbase explicit provider path should not check managed_browser_available
(which resolves against the browser-use gateway). Simplified to direct-only
with managed=False.
* fix(browser-use): port missing improvements from PR #5605
- CDP URL normalization: resolve HTTP discovery URLs to websocket after
cloud provider create_session() (prevents agent-browser failures)
- Managed session payload: send timeout=5 and proxyCountryCode=us for
gateway-backed sessions (prevents billing overruns)
- Update prompt builder, browser_close schema, and module docstring to
replace remaining Browserbase references with Browser Use
- Dynamic /browser status detection via _get_cloud_provider() instead
of hardcoded env var checks (future-proof for new providers)
- Rename post_setup key from 'browserbase' to 'agent_browser'
- Update setup hint to mention Browser Use alongside Browserbase
- Add tests: CDP normalization, browserbase direct-only guard,
managed browser-use gateway, direct browserbase fallback
---------
Co-authored-by: rob-maron <132852777+rob-maron@users.noreply.github.com>
2026-04-07 22:40:22 +10:00
|
|
|
"name": "Nous Subscription (Browser Use cloud)",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "subscription",
|
feat: switch managed browser provider from Browserbase to Browser Use (#5750)
* feat: switch managed browser provider from Browserbase to Browser Use
The Nous subscription tool gateway now routes browser automation through
Browser Use instead of Browserbase. This commit:
- Adds managed Nous gateway support to BrowserUseProvider (idempotency
keys, X-BB-API-Key auth header, external_call_id persistence)
- Removes managed gateway support from BrowserbaseProvider (now
direct-only via BROWSERBASE_API_KEY/BROWSERBASE_PROJECT_ID)
- Updates browser_tool.py fallback: prefers Browser Use over Browserbase
- Updates nous_subscription.py: gateway vendor 'browser-use', auto-config
sets cloud_provider='browser-use' for new subscribers
- Updates tools_config.py: Nous Subscription entry now uses Browser Use
- Updates setup.py, cli.py, status.py, prompt_builder.py display strings
- Updates all affected tests to match new behavior
Browserbase remains fully functional for users with direct API credentials.
The change only affects the managed/subscription path.
* chore: remove redundant Browser Use hint from system prompt
* fix: upgrade Browser Use provider to v3 API
- Base URL: api/v2 -> api/v3 (v2 is legacy)
- Unified all endpoints to use native Browser Use paths:
- POST /browsers (create session, returns cdpUrl)
- PATCH /browsers/{id} with {action: stop} (close session)
- Removed managed-mode branching that used Browserbase-style
/v1/sessions paths — v3 gateway now supports /browsers directly
- Removed unused managed_mode variable in close_session
* fix(browser-use): use X-Browser-Use-API-Key header for managed mode
The managed gateway expects X-Browser-Use-API-Key, not X-BB-API-Key
(which is a Browserbase-specific header). Using the wrong header caused
a 401 AUTH_ERROR on every managed-mode browser session create.
Simplified _headers() to always use X-Browser-Use-API-Key regardless
of direct vs managed mode.
* fix(nous_subscription): browserbase explicit provider is direct-only
Since managed Nous gateway now routes through Browser Use, the
browserbase explicit provider path should not check managed_browser_available
(which resolves against the browser-use gateway). Simplified to direct-only
with managed=False.
* fix(browser-use): port missing improvements from PR #5605
- CDP URL normalization: resolve HTTP discovery URLs to websocket after
cloud provider create_session() (prevents agent-browser failures)
- Managed session payload: send timeout=5 and proxyCountryCode=us for
gateway-backed sessions (prevents billing overruns)
- Update prompt builder, browser_close schema, and module docstring to
replace remaining Browserbase references with Browser Use
- Dynamic /browser status detection via _get_cloud_provider() instead
of hardcoded env var checks (future-proof for new providers)
- Rename post_setup key from 'browserbase' to 'agent_browser'
- Update setup hint to mention Browser Use alongside Browserbase
- Add tests: CDP normalization, browserbase direct-only guard,
managed browser-use gateway, direct browserbase fallback
---------
Co-authored-by: rob-maron <132852777+rob-maron@users.noreply.github.com>
2026-04-07 22:40:22 +10:00
|
|
|
"tag": "Managed Browser Use billed to your subscription",
|
2026-03-26 15:27:27 -07:00
|
|
|
"env_vars": [],
|
feat: switch managed browser provider from Browserbase to Browser Use (#5750)
* feat: switch managed browser provider from Browserbase to Browser Use
The Nous subscription tool gateway now routes browser automation through
Browser Use instead of Browserbase. This commit:
- Adds managed Nous gateway support to BrowserUseProvider (idempotency
keys, X-BB-API-Key auth header, external_call_id persistence)
- Removes managed gateway support from BrowserbaseProvider (now
direct-only via BROWSERBASE_API_KEY/BROWSERBASE_PROJECT_ID)
- Updates browser_tool.py fallback: prefers Browser Use over Browserbase
- Updates nous_subscription.py: gateway vendor 'browser-use', auto-config
sets cloud_provider='browser-use' for new subscribers
- Updates tools_config.py: Nous Subscription entry now uses Browser Use
- Updates setup.py, cli.py, status.py, prompt_builder.py display strings
- Updates all affected tests to match new behavior
Browserbase remains fully functional for users with direct API credentials.
The change only affects the managed/subscription path.
* chore: remove redundant Browser Use hint from system prompt
* fix: upgrade Browser Use provider to v3 API
- Base URL: api/v2 -> api/v3 (v2 is legacy)
- Unified all endpoints to use native Browser Use paths:
- POST /browsers (create session, returns cdpUrl)
- PATCH /browsers/{id} with {action: stop} (close session)
- Removed managed-mode branching that used Browserbase-style
/v1/sessions paths — v3 gateway now supports /browsers directly
- Removed unused managed_mode variable in close_session
* fix(browser-use): use X-Browser-Use-API-Key header for managed mode
The managed gateway expects X-Browser-Use-API-Key, not X-BB-API-Key
(which is a Browserbase-specific header). Using the wrong header caused
a 401 AUTH_ERROR on every managed-mode browser session create.
Simplified _headers() to always use X-Browser-Use-API-Key regardless
of direct vs managed mode.
* fix(nous_subscription): browserbase explicit provider is direct-only
Since managed Nous gateway now routes through Browser Use, the
browserbase explicit provider path should not check managed_browser_available
(which resolves against the browser-use gateway). Simplified to direct-only
with managed=False.
* fix(browser-use): port missing improvements from PR #5605
- CDP URL normalization: resolve HTTP discovery URLs to websocket after
cloud provider create_session() (prevents agent-browser failures)
- Managed session payload: send timeout=5 and proxyCountryCode=us for
gateway-backed sessions (prevents billing overruns)
- Update prompt builder, browser_close schema, and module docstring to
replace remaining Browserbase references with Browser Use
- Dynamic /browser status detection via _get_cloud_provider() instead
of hardcoded env var checks (future-proof for new providers)
- Rename post_setup key from 'browserbase' to 'agent_browser'
- Update setup hint to mention Browser Use alongside Browserbase
- Add tests: CDP normalization, browserbase direct-only guard,
managed browser-use gateway, direct browserbase fallback
---------
Co-authored-by: rob-maron <132852777+rob-maron@users.noreply.github.com>
2026-04-07 22:40:22 +10:00
|
|
|
"browser_provider": "browser-use",
|
2026-03-26 15:27:27 -07:00
|
|
|
"requires_nous_auth": True,
|
|
|
|
|
"managed_nous_feature": "browser",
|
feat: switch managed browser provider from Browserbase to Browser Use (#5750)
* feat: switch managed browser provider from Browserbase to Browser Use
The Nous subscription tool gateway now routes browser automation through
Browser Use instead of Browserbase. This commit:
- Adds managed Nous gateway support to BrowserUseProvider (idempotency
keys, X-BB-API-Key auth header, external_call_id persistence)
- Removes managed gateway support from BrowserbaseProvider (now
direct-only via BROWSERBASE_API_KEY/BROWSERBASE_PROJECT_ID)
- Updates browser_tool.py fallback: prefers Browser Use over Browserbase
- Updates nous_subscription.py: gateway vendor 'browser-use', auto-config
sets cloud_provider='browser-use' for new subscribers
- Updates tools_config.py: Nous Subscription entry now uses Browser Use
- Updates setup.py, cli.py, status.py, prompt_builder.py display strings
- Updates all affected tests to match new behavior
Browserbase remains fully functional for users with direct API credentials.
The change only affects the managed/subscription path.
* chore: remove redundant Browser Use hint from system prompt
* fix: upgrade Browser Use provider to v3 API
- Base URL: api/v2 -> api/v3 (v2 is legacy)
- Unified all endpoints to use native Browser Use paths:
- POST /browsers (create session, returns cdpUrl)
- PATCH /browsers/{id} with {action: stop} (close session)
- Removed managed-mode branching that used Browserbase-style
/v1/sessions paths — v3 gateway now supports /browsers directly
- Removed unused managed_mode variable in close_session
* fix(browser-use): use X-Browser-Use-API-Key header for managed mode
The managed gateway expects X-Browser-Use-API-Key, not X-BB-API-Key
(which is a Browserbase-specific header). Using the wrong header caused
a 401 AUTH_ERROR on every managed-mode browser session create.
Simplified _headers() to always use X-Browser-Use-API-Key regardless
of direct vs managed mode.
* fix(nous_subscription): browserbase explicit provider is direct-only
Since managed Nous gateway now routes through Browser Use, the
browserbase explicit provider path should not check managed_browser_available
(which resolves against the browser-use gateway). Simplified to direct-only
with managed=False.
* fix(browser-use): port missing improvements from PR #5605
- CDP URL normalization: resolve HTTP discovery URLs to websocket after
cloud provider create_session() (prevents agent-browser failures)
- Managed session payload: send timeout=5 and proxyCountryCode=us for
gateway-backed sessions (prevents billing overruns)
- Update prompt builder, browser_close schema, and module docstring to
replace remaining Browserbase references with Browser Use
- Dynamic /browser status detection via _get_cloud_provider() instead
of hardcoded env var checks (future-proof for new providers)
- Rename post_setup key from 'browserbase' to 'agent_browser'
- Update setup hint to mention Browser Use alongside Browserbase
- Add tests: CDP normalization, browserbase direct-only guard,
managed browser-use gateway, direct browserbase fallback
---------
Co-authored-by: rob-maron <132852777+rob-maron@users.noreply.github.com>
2026-04-07 22:40:22 +10:00
|
|
|
"override_env_vars": ["BROWSER_USE_API_KEY"],
|
|
|
|
|
"post_setup": "agent_browser",
|
2026-03-26 15:27:27 -07:00
|
|
|
},
|
2026-03-07 01:23:27 -08:00
|
|
|
{
|
|
|
|
|
"name": "Local Browser",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "★ recommended · free",
|
|
|
|
|
"tag": "Headless Chromium, no API key needed",
|
2026-03-07 01:23:27 -08:00
|
|
|
"env_vars": [],
|
2026-03-26 15:27:27 -07:00
|
|
|
"browser_provider": "local",
|
feat: switch managed browser provider from Browserbase to Browser Use (#5750)
* feat: switch managed browser provider from Browserbase to Browser Use
The Nous subscription tool gateway now routes browser automation through
Browser Use instead of Browserbase. This commit:
- Adds managed Nous gateway support to BrowserUseProvider (idempotency
keys, X-BB-API-Key auth header, external_call_id persistence)
- Removes managed gateway support from BrowserbaseProvider (now
direct-only via BROWSERBASE_API_KEY/BROWSERBASE_PROJECT_ID)
- Updates browser_tool.py fallback: prefers Browser Use over Browserbase
- Updates nous_subscription.py: gateway vendor 'browser-use', auto-config
sets cloud_provider='browser-use' for new subscribers
- Updates tools_config.py: Nous Subscription entry now uses Browser Use
- Updates setup.py, cli.py, status.py, prompt_builder.py display strings
- Updates all affected tests to match new behavior
Browserbase remains fully functional for users with direct API credentials.
The change only affects the managed/subscription path.
* chore: remove redundant Browser Use hint from system prompt
* fix: upgrade Browser Use provider to v3 API
- Base URL: api/v2 -> api/v3 (v2 is legacy)
- Unified all endpoints to use native Browser Use paths:
- POST /browsers (create session, returns cdpUrl)
- PATCH /browsers/{id} with {action: stop} (close session)
- Removed managed-mode branching that used Browserbase-style
/v1/sessions paths — v3 gateway now supports /browsers directly
- Removed unused managed_mode variable in close_session
* fix(browser-use): use X-Browser-Use-API-Key header for managed mode
The managed gateway expects X-Browser-Use-API-Key, not X-BB-API-Key
(which is a Browserbase-specific header). Using the wrong header caused
a 401 AUTH_ERROR on every managed-mode browser session create.
Simplified _headers() to always use X-Browser-Use-API-Key regardless
of direct vs managed mode.
* fix(nous_subscription): browserbase explicit provider is direct-only
Since managed Nous gateway now routes through Browser Use, the
browserbase explicit provider path should not check managed_browser_available
(which resolves against the browser-use gateway). Simplified to direct-only
with managed=False.
* fix(browser-use): port missing improvements from PR #5605
- CDP URL normalization: resolve HTTP discovery URLs to websocket after
cloud provider create_session() (prevents agent-browser failures)
- Managed session payload: send timeout=5 and proxyCountryCode=us for
gateway-backed sessions (prevents billing overruns)
- Update prompt builder, browser_close schema, and module docstring to
replace remaining Browserbase references with Browser Use
- Dynamic /browser status detection via _get_cloud_provider() instead
of hardcoded env var checks (future-proof for new providers)
- Rename post_setup key from 'browserbase' to 'agent_browser'
- Update setup hint to mention Browser Use alongside Browserbase
- Add tests: CDP normalization, browserbase direct-only guard,
managed browser-use gateway, direct browserbase fallback
---------
Co-authored-by: rob-maron <132852777+rob-maron@users.noreply.github.com>
2026-04-07 22:40:22 +10:00
|
|
|
"post_setup": "agent_browser",
|
2026-03-07 01:23:27 -08:00
|
|
|
},
|
2026-03-06 18:11:35 -08:00
|
|
|
{
|
|
|
|
|
"name": "Browserbase",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "paid",
|
|
|
|
|
"tag": "Cloud browser with stealth and proxies",
|
2026-03-06 18:11:35 -08:00
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "BROWSERBASE_API_KEY", "prompt": "Browserbase API key", "url": "https://browserbase.com"},
|
|
|
|
|
{"key": "BROWSERBASE_PROJECT_ID", "prompt": "Browserbase project ID"},
|
|
|
|
|
],
|
2026-03-17 00:16:34 -07:00
|
|
|
"browser_provider": "browserbase",
|
feat: switch managed browser provider from Browserbase to Browser Use (#5750)
* feat: switch managed browser provider from Browserbase to Browser Use
The Nous subscription tool gateway now routes browser automation through
Browser Use instead of Browserbase. This commit:
- Adds managed Nous gateway support to BrowserUseProvider (idempotency
keys, X-BB-API-Key auth header, external_call_id persistence)
- Removes managed gateway support from BrowserbaseProvider (now
direct-only via BROWSERBASE_API_KEY/BROWSERBASE_PROJECT_ID)
- Updates browser_tool.py fallback: prefers Browser Use over Browserbase
- Updates nous_subscription.py: gateway vendor 'browser-use', auto-config
sets cloud_provider='browser-use' for new subscribers
- Updates tools_config.py: Nous Subscription entry now uses Browser Use
- Updates setup.py, cli.py, status.py, prompt_builder.py display strings
- Updates all affected tests to match new behavior
Browserbase remains fully functional for users with direct API credentials.
The change only affects the managed/subscription path.
* chore: remove redundant Browser Use hint from system prompt
* fix: upgrade Browser Use provider to v3 API
- Base URL: api/v2 -> api/v3 (v2 is legacy)
- Unified all endpoints to use native Browser Use paths:
- POST /browsers (create session, returns cdpUrl)
- PATCH /browsers/{id} with {action: stop} (close session)
- Removed managed-mode branching that used Browserbase-style
/v1/sessions paths — v3 gateway now supports /browsers directly
- Removed unused managed_mode variable in close_session
* fix(browser-use): use X-Browser-Use-API-Key header for managed mode
The managed gateway expects X-Browser-Use-API-Key, not X-BB-API-Key
(which is a Browserbase-specific header). Using the wrong header caused
a 401 AUTH_ERROR on every managed-mode browser session create.
Simplified _headers() to always use X-Browser-Use-API-Key regardless
of direct vs managed mode.
* fix(nous_subscription): browserbase explicit provider is direct-only
Since managed Nous gateway now routes through Browser Use, the
browserbase explicit provider path should not check managed_browser_available
(which resolves against the browser-use gateway). Simplified to direct-only
with managed=False.
* fix(browser-use): port missing improvements from PR #5605
- CDP URL normalization: resolve HTTP discovery URLs to websocket after
cloud provider create_session() (prevents agent-browser failures)
- Managed session payload: send timeout=5 and proxyCountryCode=us for
gateway-backed sessions (prevents billing overruns)
- Update prompt builder, browser_close schema, and module docstring to
replace remaining Browserbase references with Browser Use
- Dynamic /browser status detection via _get_cloud_provider() instead
of hardcoded env var checks (future-proof for new providers)
- Rename post_setup key from 'browserbase' to 'agent_browser'
- Update setup hint to mention Browser Use alongside Browserbase
- Add tests: CDP normalization, browserbase direct-only guard,
managed browser-use gateway, direct browserbase fallback
---------
Co-authored-by: rob-maron <132852777+rob-maron@users.noreply.github.com>
2026-04-07 22:40:22 +10:00
|
|
|
"post_setup": "agent_browser",
|
2026-03-17 00:16:34 -07:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "Browser Use",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "paid",
|
2026-03-17 00:16:34 -07:00
|
|
|
"tag": "Cloud browser with remote execution",
|
|
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "BROWSER_USE_API_KEY", "prompt": "Browser Use API key", "url": "https://browser-use.com"},
|
|
|
|
|
],
|
|
|
|
|
"browser_provider": "browser-use",
|
feat: switch managed browser provider from Browserbase to Browser Use (#5750)
* feat: switch managed browser provider from Browserbase to Browser Use
The Nous subscription tool gateway now routes browser automation through
Browser Use instead of Browserbase. This commit:
- Adds managed Nous gateway support to BrowserUseProvider (idempotency
keys, X-BB-API-Key auth header, external_call_id persistence)
- Removes managed gateway support from BrowserbaseProvider (now
direct-only via BROWSERBASE_API_KEY/BROWSERBASE_PROJECT_ID)
- Updates browser_tool.py fallback: prefers Browser Use over Browserbase
- Updates nous_subscription.py: gateway vendor 'browser-use', auto-config
sets cloud_provider='browser-use' for new subscribers
- Updates tools_config.py: Nous Subscription entry now uses Browser Use
- Updates setup.py, cli.py, status.py, prompt_builder.py display strings
- Updates all affected tests to match new behavior
Browserbase remains fully functional for users with direct API credentials.
The change only affects the managed/subscription path.
* chore: remove redundant Browser Use hint from system prompt
* fix: upgrade Browser Use provider to v3 API
- Base URL: api/v2 -> api/v3 (v2 is legacy)
- Unified all endpoints to use native Browser Use paths:
- POST /browsers (create session, returns cdpUrl)
- PATCH /browsers/{id} with {action: stop} (close session)
- Removed managed-mode branching that used Browserbase-style
/v1/sessions paths — v3 gateway now supports /browsers directly
- Removed unused managed_mode variable in close_session
* fix(browser-use): use X-Browser-Use-API-Key header for managed mode
The managed gateway expects X-Browser-Use-API-Key, not X-BB-API-Key
(which is a Browserbase-specific header). Using the wrong header caused
a 401 AUTH_ERROR on every managed-mode browser session create.
Simplified _headers() to always use X-Browser-Use-API-Key regardless
of direct vs managed mode.
* fix(nous_subscription): browserbase explicit provider is direct-only
Since managed Nous gateway now routes through Browser Use, the
browserbase explicit provider path should not check managed_browser_available
(which resolves against the browser-use gateway). Simplified to direct-only
with managed=False.
* fix(browser-use): port missing improvements from PR #5605
- CDP URL normalization: resolve HTTP discovery URLs to websocket after
cloud provider create_session() (prevents agent-browser failures)
- Managed session payload: send timeout=5 and proxyCountryCode=us for
gateway-backed sessions (prevents billing overruns)
- Update prompt builder, browser_close schema, and module docstring to
replace remaining Browserbase references with Browser Use
- Dynamic /browser status detection via _get_cloud_provider() instead
of hardcoded env var checks (future-proof for new providers)
- Rename post_setup key from 'browserbase' to 'agent_browser'
- Update setup hint to mention Browser Use alongside Browserbase
- Add tests: CDP normalization, browserbase direct-only guard,
managed browser-use gateway, direct browserbase fallback
---------
Co-authored-by: rob-maron <132852777+rob-maron@users.noreply.github.com>
2026-04-07 22:40:22 +10:00
|
|
|
"post_setup": "agent_browser",
|
2026-03-06 18:11:35 -08:00
|
|
|
},
|
2026-04-06 14:05:26 -07:00
|
|
|
{
|
|
|
|
|
"name": "Firecrawl",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "paid",
|
2026-04-06 14:05:26 -07:00
|
|
|
"tag": "Cloud browser with remote execution",
|
|
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "FIRECRAWL_API_KEY", "prompt": "Firecrawl API key", "url": "https://firecrawl.dev"},
|
|
|
|
|
],
|
|
|
|
|
"browser_provider": "firecrawl",
|
feat: switch managed browser provider from Browserbase to Browser Use (#5750)
* feat: switch managed browser provider from Browserbase to Browser Use
The Nous subscription tool gateway now routes browser automation through
Browser Use instead of Browserbase. This commit:
- Adds managed Nous gateway support to BrowserUseProvider (idempotency
keys, X-BB-API-Key auth header, external_call_id persistence)
- Removes managed gateway support from BrowserbaseProvider (now
direct-only via BROWSERBASE_API_KEY/BROWSERBASE_PROJECT_ID)
- Updates browser_tool.py fallback: prefers Browser Use over Browserbase
- Updates nous_subscription.py: gateway vendor 'browser-use', auto-config
sets cloud_provider='browser-use' for new subscribers
- Updates tools_config.py: Nous Subscription entry now uses Browser Use
- Updates setup.py, cli.py, status.py, prompt_builder.py display strings
- Updates all affected tests to match new behavior
Browserbase remains fully functional for users with direct API credentials.
The change only affects the managed/subscription path.
* chore: remove redundant Browser Use hint from system prompt
* fix: upgrade Browser Use provider to v3 API
- Base URL: api/v2 -> api/v3 (v2 is legacy)
- Unified all endpoints to use native Browser Use paths:
- POST /browsers (create session, returns cdpUrl)
- PATCH /browsers/{id} with {action: stop} (close session)
- Removed managed-mode branching that used Browserbase-style
/v1/sessions paths — v3 gateway now supports /browsers directly
- Removed unused managed_mode variable in close_session
* fix(browser-use): use X-Browser-Use-API-Key header for managed mode
The managed gateway expects X-Browser-Use-API-Key, not X-BB-API-Key
(which is a Browserbase-specific header). Using the wrong header caused
a 401 AUTH_ERROR on every managed-mode browser session create.
Simplified _headers() to always use X-Browser-Use-API-Key regardless
of direct vs managed mode.
* fix(nous_subscription): browserbase explicit provider is direct-only
Since managed Nous gateway now routes through Browser Use, the
browserbase explicit provider path should not check managed_browser_available
(which resolves against the browser-use gateway). Simplified to direct-only
with managed=False.
* fix(browser-use): port missing improvements from PR #5605
- CDP URL normalization: resolve HTTP discovery URLs to websocket after
cloud provider create_session() (prevents agent-browser failures)
- Managed session payload: send timeout=5 and proxyCountryCode=us for
gateway-backed sessions (prevents billing overruns)
- Update prompt builder, browser_close schema, and module docstring to
replace remaining Browserbase references with Browser Use
- Dynamic /browser status detection via _get_cloud_provider() instead
of hardcoded env var checks (future-proof for new providers)
- Rename post_setup key from 'browserbase' to 'agent_browser'
- Update setup hint to mention Browser Use alongside Browserbase
- Add tests: CDP normalization, browserbase direct-only guard,
managed browser-use gateway, direct browserbase fallback
---------
Co-authored-by: rob-maron <132852777+rob-maron@users.noreply.github.com>
2026-04-07 22:40:22 +10:00
|
|
|
"post_setup": "agent_browser",
|
2026-04-06 14:05:26 -07:00
|
|
|
},
|
feat(browser): add Camofox local anti-detection browser backend (#4008)
Camofox-browser is a self-hosted Node.js server wrapping Camoufox
(Firefox fork with C++ fingerprint spoofing). When CAMOFOX_URL is set,
all 11 browser tools route through the Camofox REST API instead of
the agent-browser CLI.
Maps 1:1 to the existing browser tool interface:
- Navigate, snapshot, click, type, scroll, back, press, close
- Get images, vision (screenshot + LLM analysis)
- Console (returns empty with note — camofox limitation)
Setup: npm start in camofox-browser dir, or docker run -p 9377:9377
Then: CAMOFOX_URL=http://localhost:9377 in ~/.hermes/.env
Advantages over Browserbase (cloud):
- Free (no per-session API costs)
- Local (zero network latency for browser ops)
- Anti-detection at C++ level (bypasses Cloudflare/Google bot detection)
- Works offline, Docker-ready
Files:
- tools/browser_camofox.py: Full REST backend (~400 lines)
- tools/browser_tool.py: Routing at each tool function
- hermes_cli/config.py: CAMOFOX_URL env var entry
- tests/tools/test_browser_camofox.py: 20 tests
2026-03-30 13:18:42 -07:00
|
|
|
{
|
|
|
|
|
"name": "Camofox",
|
2026-04-14 16:58:10 -07:00
|
|
|
"badge": "free · local",
|
|
|
|
|
"tag": "Anti-detection browser (Firefox/Camoufox)",
|
feat(browser): add Camofox local anti-detection browser backend (#4008)
Camofox-browser is a self-hosted Node.js server wrapping Camoufox
(Firefox fork with C++ fingerprint spoofing). When CAMOFOX_URL is set,
all 11 browser tools route through the Camofox REST API instead of
the agent-browser CLI.
Maps 1:1 to the existing browser tool interface:
- Navigate, snapshot, click, type, scroll, back, press, close
- Get images, vision (screenshot + LLM analysis)
- Console (returns empty with note — camofox limitation)
Setup: npm start in camofox-browser dir, or docker run -p 9377:9377
Then: CAMOFOX_URL=http://localhost:9377 in ~/.hermes/.env
Advantages over Browserbase (cloud):
- Free (no per-session API costs)
- Local (zero network latency for browser ops)
- Anti-detection at C++ level (bypasses Cloudflare/Google bot detection)
- Works offline, Docker-ready
Files:
- tools/browser_camofox.py: Full REST backend (~400 lines)
- tools/browser_tool.py: Routing at each tool function
- hermes_cli/config.py: CAMOFOX_URL env var entry
- tests/tools/test_browser_camofox.py: 20 tests
2026-03-30 13:18:42 -07:00
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "CAMOFOX_URL", "prompt": "Camofox server URL", "default": "http://localhost:9377",
|
|
|
|
|
"url": "https://github.com/jo-inc/camofox-browser"},
|
|
|
|
|
],
|
|
|
|
|
"browser_provider": "camofox",
|
|
|
|
|
"post_setup": "camofox",
|
|
|
|
|
},
|
2026-03-06 18:11:35 -08:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
"homeassistant": {
|
|
|
|
|
"name": "Smart Home",
|
|
|
|
|
"icon": "🏠",
|
|
|
|
|
"providers": [
|
|
|
|
|
{
|
|
|
|
|
"name": "Home Assistant",
|
|
|
|
|
"tag": "REST API integration",
|
|
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "HASS_TOKEN", "prompt": "Home Assistant Long-Lived Access Token"},
|
|
|
|
|
{"key": "HASS_URL", "prompt": "Home Assistant URL", "default": "http://homeassistant.local:8123"},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2026-04-24 05:15:06 -07:00
|
|
|
"spotify": {
|
|
|
|
|
"name": "Spotify",
|
|
|
|
|
"icon": "🎵",
|
|
|
|
|
"providers": [
|
|
|
|
|
{
|
|
|
|
|
"name": "Spotify Web API",
|
2026-04-24 07:24:28 -07:00
|
|
|
"tag": "PKCE OAuth — opens the setup wizard",
|
|
|
|
|
"env_vars": [],
|
|
|
|
|
"post_setup": "spotify",
|
2026-04-24 05:15:06 -07:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2026-03-06 18:11:35 -08:00
|
|
|
"rl": {
|
|
|
|
|
"name": "RL Training",
|
|
|
|
|
"icon": "🧪",
|
|
|
|
|
"requires_python": (3, 11),
|
|
|
|
|
"providers": [
|
|
|
|
|
{
|
|
|
|
|
"name": "Tinker / Atropos",
|
|
|
|
|
"tag": "RL training platform",
|
|
|
|
|
"env_vars": [
|
|
|
|
|
{"key": "TINKER_API_KEY", "prompt": "Tinker API key", "url": "https://tinker-console.thinkingmachines.ai/keys"},
|
|
|
|
|
{"key": "WANDB_API_KEY", "prompt": "WandB API key", "url": "https://wandb.ai/authorize"},
|
|
|
|
|
],
|
|
|
|
|
"post_setup": "rl_training",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Simple env-var requirements for toolsets NOT in TOOL_CATEGORIES.
|
|
|
|
|
# Used as a fallback for tools like vision/moa that just need an API key.
|
|
|
|
|
TOOLSET_ENV_REQUIREMENTS = {
|
|
|
|
|
"vision": [("OPENROUTER_API_KEY", "https://openrouter.ai/keys")],
|
|
|
|
|
"moa": [("OPENROUTER_API_KEY", "https://openrouter.ai/keys")],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ─── Post-Setup Hooks ─────────────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
def _run_post_setup(post_setup_key: str):
|
|
|
|
|
"""Run post-setup hooks for tools that need extra installation steps."""
|
|
|
|
|
import shutil
|
feat: switch managed browser provider from Browserbase to Browser Use (#5750)
* feat: switch managed browser provider from Browserbase to Browser Use
The Nous subscription tool gateway now routes browser automation through
Browser Use instead of Browserbase. This commit:
- Adds managed Nous gateway support to BrowserUseProvider (idempotency
keys, X-BB-API-Key auth header, external_call_id persistence)
- Removes managed gateway support from BrowserbaseProvider (now
direct-only via BROWSERBASE_API_KEY/BROWSERBASE_PROJECT_ID)
- Updates browser_tool.py fallback: prefers Browser Use over Browserbase
- Updates nous_subscription.py: gateway vendor 'browser-use', auto-config
sets cloud_provider='browser-use' for new subscribers
- Updates tools_config.py: Nous Subscription entry now uses Browser Use
- Updates setup.py, cli.py, status.py, prompt_builder.py display strings
- Updates all affected tests to match new behavior
Browserbase remains fully functional for users with direct API credentials.
The change only affects the managed/subscription path.
* chore: remove redundant Browser Use hint from system prompt
* fix: upgrade Browser Use provider to v3 API
- Base URL: api/v2 -> api/v3 (v2 is legacy)
- Unified all endpoints to use native Browser Use paths:
- POST /browsers (create session, returns cdpUrl)
- PATCH /browsers/{id} with {action: stop} (close session)
- Removed managed-mode branching that used Browserbase-style
/v1/sessions paths — v3 gateway now supports /browsers directly
- Removed unused managed_mode variable in close_session
* fix(browser-use): use X-Browser-Use-API-Key header for managed mode
The managed gateway expects X-Browser-Use-API-Key, not X-BB-API-Key
(which is a Browserbase-specific header). Using the wrong header caused
a 401 AUTH_ERROR on every managed-mode browser session create.
Simplified _headers() to always use X-Browser-Use-API-Key regardless
of direct vs managed mode.
* fix(nous_subscription): browserbase explicit provider is direct-only
Since managed Nous gateway now routes through Browser Use, the
browserbase explicit provider path should not check managed_browser_available
(which resolves against the browser-use gateway). Simplified to direct-only
with managed=False.
* fix(browser-use): port missing improvements from PR #5605
- CDP URL normalization: resolve HTTP discovery URLs to websocket after
cloud provider create_session() (prevents agent-browser failures)
- Managed session payload: send timeout=5 and proxyCountryCode=us for
gateway-backed sessions (prevents billing overruns)
- Update prompt builder, browser_close schema, and module docstring to
replace remaining Browserbase references with Browser Use
- Dynamic /browser status detection via _get_cloud_provider() instead
of hardcoded env var checks (future-proof for new providers)
- Rename post_setup key from 'browserbase' to 'agent_browser'
- Update setup hint to mention Browser Use alongside Browserbase
- Add tests: CDP normalization, browserbase direct-only guard,
managed browser-use gateway, direct browserbase fallback
---------
Co-authored-by: rob-maron <132852777+rob-maron@users.noreply.github.com>
2026-04-07 22:40:22 +10:00
|
|
|
if post_setup_key in ("agent_browser", "browserbase"):
|
2026-03-06 18:11:35 -08:00
|
|
|
node_modules = PROJECT_ROOT / "node_modules" / "agent-browser"
|
|
|
|
|
if not node_modules.exists() and shutil.which("npm"):
|
|
|
|
|
_print_info(" Installing Node.js dependencies for browser tools...")
|
|
|
|
|
import subprocess
|
|
|
|
|
result = subprocess.run(
|
|
|
|
|
["npm", "install", "--silent"],
|
|
|
|
|
capture_output=True, text=True, cwd=str(PROJECT_ROOT)
|
|
|
|
|
)
|
|
|
|
|
if result.returncode == 0:
|
|
|
|
|
_print_success(" Node.js dependencies installed")
|
|
|
|
|
else:
|
2026-03-28 23:47:21 -07:00
|
|
|
from hermes_constants import display_hermes_home
|
|
|
|
|
_print_warning(f" npm install failed - run manually: cd {display_hermes_home()}/hermes-agent && npm install")
|
2026-03-06 18:11:35 -08:00
|
|
|
elif not node_modules.exists():
|
|
|
|
|
_print_warning(" Node.js not found - browser tools require: npm install (in hermes-agent directory)")
|
|
|
|
|
|
feat(browser): add Camofox local anti-detection browser backend (#4008)
Camofox-browser is a self-hosted Node.js server wrapping Camoufox
(Firefox fork with C++ fingerprint spoofing). When CAMOFOX_URL is set,
all 11 browser tools route through the Camofox REST API instead of
the agent-browser CLI.
Maps 1:1 to the existing browser tool interface:
- Navigate, snapshot, click, type, scroll, back, press, close
- Get images, vision (screenshot + LLM analysis)
- Console (returns empty with note — camofox limitation)
Setup: npm start in camofox-browser dir, or docker run -p 9377:9377
Then: CAMOFOX_URL=http://localhost:9377 in ~/.hermes/.env
Advantages over Browserbase (cloud):
- Free (no per-session API costs)
- Local (zero network latency for browser ops)
- Anti-detection at C++ level (bypasses Cloudflare/Google bot detection)
- Works offline, Docker-ready
Files:
- tools/browser_camofox.py: Full REST backend (~400 lines)
- tools/browser_tool.py: Routing at each tool function
- hermes_cli/config.py: CAMOFOX_URL env var entry
- tests/tools/test_browser_camofox.py: 20 tests
2026-03-30 13:18:42 -07:00
|
|
|
elif post_setup_key == "camofox":
|
2026-04-14 10:21:54 -07:00
|
|
|
camofox_dir = PROJECT_ROOT / "node_modules" / "@askjo" / "camofox-browser"
|
feat(browser): add Camofox local anti-detection browser backend (#4008)
Camofox-browser is a self-hosted Node.js server wrapping Camoufox
(Firefox fork with C++ fingerprint spoofing). When CAMOFOX_URL is set,
all 11 browser tools route through the Camofox REST API instead of
the agent-browser CLI.
Maps 1:1 to the existing browser tool interface:
- Navigate, snapshot, click, type, scroll, back, press, close
- Get images, vision (screenshot + LLM analysis)
- Console (returns empty with note — camofox limitation)
Setup: npm start in camofox-browser dir, or docker run -p 9377:9377
Then: CAMOFOX_URL=http://localhost:9377 in ~/.hermes/.env
Advantages over Browserbase (cloud):
- Free (no per-session API costs)
- Local (zero network latency for browser ops)
- Anti-detection at C++ level (bypasses Cloudflare/Google bot detection)
- Works offline, Docker-ready
Files:
- tools/browser_camofox.py: Full REST backend (~400 lines)
- tools/browser_tool.py: Routing at each tool function
- hermes_cli/config.py: CAMOFOX_URL env var entry
- tests/tools/test_browser_camofox.py: 20 tests
2026-03-30 13:18:42 -07:00
|
|
|
if not camofox_dir.exists() and shutil.which("npm"):
|
|
|
|
|
_print_info(" Installing Camofox browser server...")
|
|
|
|
|
import subprocess
|
|
|
|
|
result = subprocess.run(
|
|
|
|
|
["npm", "install", "--silent"],
|
|
|
|
|
capture_output=True, text=True, cwd=str(PROJECT_ROOT)
|
|
|
|
|
)
|
|
|
|
|
if result.returncode == 0:
|
|
|
|
|
_print_success(" Camofox installed")
|
|
|
|
|
else:
|
|
|
|
|
_print_warning(" npm install failed - run manually: npm install")
|
|
|
|
|
if camofox_dir.exists():
|
|
|
|
|
_print_info(" Start the Camofox server:")
|
2026-04-14 10:21:54 -07:00
|
|
|
_print_info(" npx @askjo/camofox-browser")
|
feat(browser): add Camofox local anti-detection browser backend (#4008)
Camofox-browser is a self-hosted Node.js server wrapping Camoufox
(Firefox fork with C++ fingerprint spoofing). When CAMOFOX_URL is set,
all 11 browser tools route through the Camofox REST API instead of
the agent-browser CLI.
Maps 1:1 to the existing browser tool interface:
- Navigate, snapshot, click, type, scroll, back, press, close
- Get images, vision (screenshot + LLM analysis)
- Console (returns empty with note — camofox limitation)
Setup: npm start in camofox-browser dir, or docker run -p 9377:9377
Then: CAMOFOX_URL=http://localhost:9377 in ~/.hermes/.env
Advantages over Browserbase (cloud):
- Free (no per-session API costs)
- Local (zero network latency for browser ops)
- Anti-detection at C++ level (bypasses Cloudflare/Google bot detection)
- Works offline, Docker-ready
Files:
- tools/browser_camofox.py: Full REST backend (~400 lines)
- tools/browser_tool.py: Routing at each tool function
- hermes_cli/config.py: CAMOFOX_URL env var entry
- tests/tools/test_browser_camofox.py: 20 tests
2026-03-30 13:18:42 -07:00
|
|
|
_print_info(" First run downloads the Camoufox engine (~300MB)")
|
2026-03-31 13:38:22 -07:00
|
|
|
_print_info(" Or use Docker: docker run -p 9377:9377 -e CAMOFOX_PORT=9377 jo-inc/camofox-browser")
|
feat(browser): add Camofox local anti-detection browser backend (#4008)
Camofox-browser is a self-hosted Node.js server wrapping Camoufox
(Firefox fork with C++ fingerprint spoofing). When CAMOFOX_URL is set,
all 11 browser tools route through the Camofox REST API instead of
the agent-browser CLI.
Maps 1:1 to the existing browser tool interface:
- Navigate, snapshot, click, type, scroll, back, press, close
- Get images, vision (screenshot + LLM analysis)
- Console (returns empty with note — camofox limitation)
Setup: npm start in camofox-browser dir, or docker run -p 9377:9377
Then: CAMOFOX_URL=http://localhost:9377 in ~/.hermes/.env
Advantages over Browserbase (cloud):
- Free (no per-session API costs)
- Local (zero network latency for browser ops)
- Anti-detection at C++ level (bypasses Cloudflare/Google bot detection)
- Works offline, Docker-ready
Files:
- tools/browser_camofox.py: Full REST backend (~400 lines)
- tools/browser_tool.py: Routing at each tool function
- hermes_cli/config.py: CAMOFOX_URL env var entry
- tests/tools/test_browser_camofox.py: 20 tests
2026-03-30 13:18:42 -07:00
|
|
|
elif not shutil.which("npm"):
|
|
|
|
|
_print_warning(" Node.js not found. Install Camofox via Docker:")
|
2026-03-31 13:38:22 -07:00
|
|
|
_print_info(" docker run -p 9377:9377 -e CAMOFOX_PORT=9377 jo-inc/camofox-browser")
|
feat(browser): add Camofox local anti-detection browser backend (#4008)
Camofox-browser is a self-hosted Node.js server wrapping Camoufox
(Firefox fork with C++ fingerprint spoofing). When CAMOFOX_URL is set,
all 11 browser tools route through the Camofox REST API instead of
the agent-browser CLI.
Maps 1:1 to the existing browser tool interface:
- Navigate, snapshot, click, type, scroll, back, press, close
- Get images, vision (screenshot + LLM analysis)
- Console (returns empty with note — camofox limitation)
Setup: npm start in camofox-browser dir, or docker run -p 9377:9377
Then: CAMOFOX_URL=http://localhost:9377 in ~/.hermes/.env
Advantages over Browserbase (cloud):
- Free (no per-session API costs)
- Local (zero network latency for browser ops)
- Anti-detection at C++ level (bypasses Cloudflare/Google bot detection)
- Works offline, Docker-ready
Files:
- tools/browser_camofox.py: Full REST backend (~400 lines)
- tools/browser_tool.py: Routing at each tool function
- hermes_cli/config.py: CAMOFOX_URL env var entry
- tests/tools/test_browser_camofox.py: 20 tests
2026-03-30 13:18:42 -07:00
|
|
|
|
feat(tts): complete KittenTTS integration (tools/setup/docs/tests)
Builds on @AxDSan's PR #2109 to finish the KittenTTS wiring so the
provider behaves like every other TTS backend end to end.
- tools/tts_tool.py: `_check_kittentts_available()` helper and wire
into `check_tts_requirements()`; extend Opus-conversion list to
include kittentts (WAV → Opus for Telegram voice bubbles); point the
missing-package error at `hermes setup tts`.
- hermes_cli/tools_config.py: add KittenTTS entry to the "Text-to-Speech"
toolset picker, with a `kittentts` post_setup hook that auto-installs
the wheel + soundfile via pip.
- hermes_cli/setup.py: `_install_kittentts_deps()`, new choice + install
flow in `_setup_tts_provider()`, provider_labels entry, and status row
in the `hermes setup` summary.
- website/docs/user-guide/features/tts.md: add KittenTTS to the provider
table, config example, ffmpeg note, and the zero-config voice-bubble tip.
- tests/tools/test_tts_kittentts.py: 10 unit tests covering generation,
model caching, config passthrough, ffmpeg conversion, availability
detection, and the missing-package dispatcher branch.
E2E verified against the real `kittentts` wheel:
- WAV direct output (pcm_s16le, 24kHz mono)
- MP3 conversion via ffmpeg (from WAV)
- Telegram flow (provider in Opus-conversion list) produces
`codec_name=opus`, 48kHz mono, `voice_compatible=True`, and the
`[[audio_as_voice]]` marker
- check_tts_requirements() returns True when kittentts is installed
2026-04-21 00:44:37 -07:00
|
|
|
elif post_setup_key == "kittentts":
|
|
|
|
|
try:
|
|
|
|
|
__import__("kittentts")
|
|
|
|
|
_print_success(" kittentts is already installed")
|
|
|
|
|
return
|
|
|
|
|
except ImportError:
|
|
|
|
|
pass
|
|
|
|
|
import subprocess
|
|
|
|
|
_print_info(" Installing kittentts (~25-80MB model, CPU-only)...")
|
|
|
|
|
wheel_url = (
|
|
|
|
|
"https://github.com/KittenML/KittenTTS/releases/download/"
|
|
|
|
|
"0.8.1/kittentts-0.8.1-py3-none-any.whl"
|
|
|
|
|
)
|
|
|
|
|
try:
|
|
|
|
|
result = subprocess.run(
|
|
|
|
|
[sys.executable, "-m", "pip", "install", "-U", wheel_url, "soundfile", "--quiet"],
|
|
|
|
|
capture_output=True, text=True, timeout=300,
|
|
|
|
|
)
|
|
|
|
|
if result.returncode == 0:
|
|
|
|
|
_print_success(" kittentts installed")
|
|
|
|
|
_print_info(" Voices: Jasper, Bella, Luna, Bruno, Rosie, Hugo, Kiki, Leo")
|
|
|
|
|
_print_info(" Models: KittenML/kitten-tts-nano-0.8-int8 (25MB), micro (41MB), mini (80MB)")
|
|
|
|
|
else:
|
|
|
|
|
_print_warning(" kittentts install failed:")
|
|
|
|
|
_print_info(f" {result.stderr.strip()[:300]}")
|
|
|
|
|
_print_info(f" Run manually: python -m pip install -U '{wheel_url}' soundfile")
|
|
|
|
|
except subprocess.TimeoutExpired:
|
|
|
|
|
_print_warning(" kittentts install timed out (>5min)")
|
|
|
|
|
_print_info(f" Run manually: python -m pip install -U '{wheel_url}' soundfile")
|
|
|
|
|
|
2026-04-24 07:24:28 -07:00
|
|
|
elif post_setup_key == "spotify":
|
|
|
|
|
# Run the full `hermes auth spotify` flow — if the user has no
|
|
|
|
|
# client_id yet, this drops them into the interactive wizard
|
|
|
|
|
# (opens the Spotify dashboard, prompts for client_id, persists
|
|
|
|
|
# to ~/.hermes/.env), then continues straight into PKCE. If they
|
|
|
|
|
# already have an app, it skips the wizard and just does OAuth.
|
|
|
|
|
from types import SimpleNamespace
|
|
|
|
|
try:
|
|
|
|
|
from hermes_cli.auth import login_spotify_command
|
|
|
|
|
except Exception as exc:
|
|
|
|
|
_print_warning(f" Could not load Spotify auth: {exc}")
|
|
|
|
|
_print_info(" Run manually: hermes auth spotify")
|
|
|
|
|
return
|
|
|
|
|
_print_info(" Starting Spotify login...")
|
|
|
|
|
try:
|
|
|
|
|
login_spotify_command(SimpleNamespace(
|
|
|
|
|
client_id=None, redirect_uri=None, scope=None,
|
|
|
|
|
no_browser=False, timeout=None,
|
|
|
|
|
))
|
|
|
|
|
_print_success(" Spotify authenticated")
|
|
|
|
|
except SystemExit as exc:
|
|
|
|
|
# User aborted the wizard, or OAuth failed — don't fail the
|
|
|
|
|
# toolset enable; they can retry with `hermes auth spotify`.
|
|
|
|
|
_print_warning(f" Spotify login did not complete: {exc}")
|
|
|
|
|
_print_info(" Run later: hermes auth spotify")
|
|
|
|
|
except Exception as exc:
|
|
|
|
|
_print_warning(f" Spotify login failed: {exc}")
|
|
|
|
|
_print_info(" Run manually: hermes auth spotify")
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
elif post_setup_key == "rl_training":
|
|
|
|
|
try:
|
|
|
|
|
__import__("tinker_atropos")
|
|
|
|
|
except ImportError:
|
|
|
|
|
tinker_dir = PROJECT_ROOT / "tinker-atropos"
|
|
|
|
|
if tinker_dir.exists() and (tinker_dir / "pyproject.toml").exists():
|
|
|
|
|
_print_info(" Installing tinker-atropos submodule...")
|
|
|
|
|
import subprocess
|
|
|
|
|
uv_bin = shutil.which("uv")
|
|
|
|
|
if uv_bin:
|
|
|
|
|
result = subprocess.run(
|
2026-03-06 21:55:33 -08:00
|
|
|
[uv_bin, "pip", "install", "--python", sys.executable, "-e", str(tinker_dir)],
|
2026-03-06 18:11:35 -08:00
|
|
|
capture_output=True, text=True
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
result = subprocess.run(
|
|
|
|
|
[sys.executable, "-m", "pip", "install", "-e", str(tinker_dir)],
|
|
|
|
|
capture_output=True, text=True
|
|
|
|
|
)
|
|
|
|
|
if result.returncode == 0:
|
|
|
|
|
_print_success(" tinker-atropos installed")
|
|
|
|
|
else:
|
|
|
|
|
_print_warning(" tinker-atropos install failed - run manually:")
|
|
|
|
|
_print_info(' uv pip install -e "./tinker-atropos"')
|
|
|
|
|
else:
|
|
|
|
|
_print_warning(" tinker-atropos submodule not found - run:")
|
|
|
|
|
_print_info(" git submodule update --init --recursive")
|
|
|
|
|
_print_info(' uv pip install -e "./tinker-atropos"')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ─── Platform / Toolset Helpers ───────────────────────────────────────────────
|
|
|
|
|
|
2026-02-23 23:52:07 +00:00
|
|
|
def _get_enabled_platforms() -> List[str]:
|
|
|
|
|
"""Return platform keys that are configured (have tokens or are CLI)."""
|
|
|
|
|
enabled = ["cli"]
|
|
|
|
|
if get_env_value("TELEGRAM_BOT_TOKEN"):
|
|
|
|
|
enabled.append("telegram")
|
|
|
|
|
if get_env_value("DISCORD_BOT_TOKEN"):
|
|
|
|
|
enabled.append("discord")
|
|
|
|
|
if get_env_value("SLACK_BOT_TOKEN"):
|
|
|
|
|
enabled.append("slack")
|
|
|
|
|
if get_env_value("WHATSAPP_ENABLED"):
|
|
|
|
|
enabled.append("whatsapp")
|
feat: add QQ Bot platform adapter (Official API v2)
Add full QQ Bot integration via the Official QQ Bot API (v2):
- WebSocket gateway for inbound events (C2C, group, guild, DM)
- REST API for outbound text/markdown/media messages
- Voice transcription (Tencent ASR + configurable STT provider)
- Attachment processing (images, voice, files)
- User authorization (allowlist + allow-all + DM pairing)
Integration points:
- gateway: Platform.QQ enum, adapter factory, allowlist maps
- CLI: setup wizard, gateway config, status display, tools config
- tools: send_message cross-platform routing, toolsets
- cron: delivery platform support
- docs: QQ Bot setup guide
2026-04-13 21:56:38 +08:00
|
|
|
if get_env_value("QQ_APP_ID"):
|
2026-04-14 01:33:06 +08:00
|
|
|
enabled.append("qqbot")
|
2026-02-23 23:52:07 +00:00
|
|
|
return enabled
|
|
|
|
|
|
|
|
|
|
|
2026-03-11 00:47:26 -07:00
|
|
|
def _platform_toolset_summary(config: dict, platforms: Optional[List[str]] = None) -> Dict[str, Set[str]]:
|
2026-03-09 16:50:53 +03:00
|
|
|
"""Return a summary of enabled toolsets per platform.
|
|
|
|
|
|
|
|
|
|
When ``platforms`` is None, this uses ``_get_enabled_platforms`` to
|
|
|
|
|
auto-detect platforms. Tests can pass an explicit list to avoid relying
|
|
|
|
|
on environment variables.
|
|
|
|
|
"""
|
|
|
|
|
if platforms is None:
|
|
|
|
|
platforms = _get_enabled_platforms()
|
|
|
|
|
|
|
|
|
|
summary: Dict[str, Set[str]] = {}
|
|
|
|
|
for pkey in platforms:
|
|
|
|
|
summary[pkey] = _get_platform_tools(config, pkey)
|
|
|
|
|
return summary
|
|
|
|
|
|
|
|
|
|
|
2026-03-26 13:39:41 -07:00
|
|
|
def _parse_enabled_flag(value, default: bool = True) -> bool:
|
|
|
|
|
"""Parse bool-like config values used by tool/platform settings."""
|
|
|
|
|
if value is None:
|
|
|
|
|
return default
|
|
|
|
|
if isinstance(value, bool):
|
|
|
|
|
return value
|
|
|
|
|
if isinstance(value, int):
|
|
|
|
|
return value != 0
|
|
|
|
|
if isinstance(value, str):
|
|
|
|
|
lowered = value.strip().lower()
|
|
|
|
|
if lowered in {"true", "1", "yes", "on"}:
|
|
|
|
|
return True
|
|
|
|
|
if lowered in {"false", "0", "no", "off"}:
|
|
|
|
|
return False
|
|
|
|
|
return default
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_platform_tools(
|
|
|
|
|
config: dict,
|
|
|
|
|
platform: str,
|
|
|
|
|
*,
|
|
|
|
|
include_default_mcp_servers: bool = True,
|
|
|
|
|
) -> Set[str]:
|
2026-02-23 23:52:07 +00:00
|
|
|
"""Resolve which individual toolset names are enabled for a platform."""
|
chore: remove ~100 unused imports across 55 files (#3016)
Automated cleanup via pyflakes + autoflake with manual review.
Changes:
- Removed unused stdlib imports (os, sys, json, pathlib.Path, etc.)
- Removed unused typing imports (List, Dict, Any, Optional, Tuple, Set, etc.)
- Removed unused internal imports (hermes_cli.auth, hermes_cli.config, etc.)
- Fixed cli.py: removed 8 shadowed banner imports (imported from hermes_cli.banner
then immediately redefined locally — only build_welcome_banner is actually used)
- Added noqa comments to imports that appear unused but serve a purpose:
- Re-exports (gateway/session.py SessionResetPolicy, tools/terminal_tool.py
is_interrupted/_interrupt_event)
- SDK presence checks in try/except (daytona, fal_client, discord)
- Test mock targets (auxiliary_client.py Path, mcp_config.py get_hermes_home)
Zero behavioral changes. Full test suite passes (6162/6162, 2 pre-existing
streaming test failures unrelated to this change).
2026-03-25 15:02:03 -07:00
|
|
|
from toolsets import resolve_toolset
|
2026-02-23 23:52:07 +00:00
|
|
|
|
2026-04-17 05:40:44 -07:00
|
|
|
platform_toolsets = config.get("platform_toolsets") or {}
|
2026-02-23 23:52:07 +00:00
|
|
|
toolset_names = platform_toolsets.get(platform)
|
|
|
|
|
|
2026-03-07 18:18:37 -08:00
|
|
|
if toolset_names is None or not isinstance(toolset_names, list):
|
2026-02-23 23:52:07 +00:00
|
|
|
default_ts = PLATFORMS[platform]["default_toolset"]
|
|
|
|
|
toolset_names = [default_ts]
|
|
|
|
|
|
2026-04-10 13:10:22 +08:00
|
|
|
# YAML may parse bare numeric names (e.g. ``12306:``) as int.
|
|
|
|
|
# Normalise to str so downstream sorted() never mixes types.
|
|
|
|
|
toolset_names = [str(ts) for ts in toolset_names]
|
|
|
|
|
|
2026-03-23 07:06:51 -07:00
|
|
|
configurable_keys = {ts_key for ts_key, _, _ in CONFIGURABLE_TOOLSETS}
|
|
|
|
|
|
|
|
|
|
# If the saved list contains any configurable keys directly, the user
|
|
|
|
|
# has explicitly configured this platform — use direct membership.
|
|
|
|
|
# This avoids the subset-inference bug where composite toolsets like
|
|
|
|
|
# "hermes-cli" (which include all _HERMES_CORE_TOOLS) cause disabled
|
|
|
|
|
# toolsets to re-appear as enabled.
|
|
|
|
|
has_explicit_config = any(ts in configurable_keys for ts in toolset_names)
|
|
|
|
|
|
|
|
|
|
if has_explicit_config:
|
|
|
|
|
enabled_toolsets = {ts for ts in toolset_names if ts in configurable_keys}
|
|
|
|
|
else:
|
|
|
|
|
# No explicit config — fall back to resolving composite toolset names
|
|
|
|
|
# (e.g. "hermes-cli") to individual tool names and reverse-mapping.
|
|
|
|
|
all_tool_names = set()
|
|
|
|
|
for ts_name in toolset_names:
|
|
|
|
|
all_tool_names.update(resolve_toolset(ts_name))
|
|
|
|
|
|
|
|
|
|
enabled_toolsets = set()
|
|
|
|
|
for ts_key, _, _ in CONFIGURABLE_TOOLSETS:
|
|
|
|
|
ts_tools = set(resolve_toolset(ts_key))
|
|
|
|
|
if ts_tools and ts_tools.issubset(all_tool_names):
|
|
|
|
|
enabled_toolsets.add(ts_key)
|
2026-04-20 00:50:19 +01:00
|
|
|
default_off = set(_DEFAULT_OFF_TOOLSETS)
|
|
|
|
|
if platform in default_off:
|
|
|
|
|
default_off.remove(platform)
|
|
|
|
|
enabled_toolsets -= default_off
|
2026-02-23 23:52:07 +00:00
|
|
|
|
refactor(spotify): convert to built-in bundled plugin under plugins/spotify (#15174)
Moves the Spotify integration from tools/ into plugins/spotify/,
matching the existing pattern established by plugins/image_gen/ for
third-party service integrations.
Why:
- tools/ should be reserved for foundational capabilities (terminal,
read_file, web_search, etc.). tools/providers/ was a one-off
directory created solely for spotify_client.py.
- plugins/ is already the home for image_gen backends, memory
providers, context engines, and standalone hook-based plugins.
Spotify is a third-party service integration and belongs alongside
those, not in tools/.
- Future service integrations (eventually: Deezer, Apple Music, etc.)
now have a pattern to copy.
Changes:
- tools/spotify_tool.py → plugins/spotify/tools.py (handlers + schemas)
- tools/providers/spotify_client.py → plugins/spotify/client.py
- tools/providers/ removed (was only used for Spotify)
- New plugins/spotify/__init__.py with register(ctx) calling
ctx.register_tool() × 7. The handler/check_fn wiring is unchanged.
- New plugins/spotify/plugin.yaml (kind: backend, bundled, auto-load).
- tests/tools/test_spotify_client.py: import paths updated.
tools_config fix — _DEFAULT_OFF_TOOLSETS now wins over plugin auto-enable:
- _get_platform_tools() previously auto-enabled unknown plugin
toolsets for new platforms. That was fine for image_gen (which has
no toolset of its own) but bad for Spotify, which explicitly
requires opt-in (don't ship 7 tool schemas to users who don't use
it). Added a check: if a plugin toolset is in _DEFAULT_OFF_TOOLSETS,
it stays off until the user picks it in 'hermes tools'.
Pre-existing test bug fix:
- tests/hermes_cli/test_plugins.py::test_list_returns_sorted
asserted names were sorted, but list_plugins() sorts by key
(path-derived, e.g. image_gen/openai). With only image_gen plugins
bundled, name and key order happened to agree. Adding plugins/spotify
broke that coincidence (spotify sorts between openai-codex and xai
by name but after xai by key). Updated test to assert key order,
which is what the code actually documents.
Validation:
- scripts/run_tests.sh tests/hermes_cli/test_plugins.py \
tests/hermes_cli/test_tools_config.py \
tests/hermes_cli/test_spotify_auth.py \
tests/tools/test_spotify_client.py \
tests/tools/test_registry.py
→ 143 passed
- E2E plugin load: 'spotify' appears in loaded plugins, all 7 tools
register into the spotify toolset, check_fn gating intact.
2026-04-24 07:06:11 -07:00
|
|
|
# Plugin toolsets: enabled by default unless explicitly disabled, or
|
|
|
|
|
# unless the toolset is in _DEFAULT_OFF_TOOLSETS (e.g. spotify —
|
|
|
|
|
# shipped as a bundled plugin but user must opt in via `hermes tools`
|
|
|
|
|
# so we don't ship 7 Spotify tool schemas to users who don't use it).
|
2026-03-22 04:55:34 -07:00
|
|
|
# A plugin toolset is "known" for a platform once `hermes tools`
|
|
|
|
|
# has been saved for that platform (tracked via known_plugin_toolsets).
|
|
|
|
|
# Unknown plugins default to enabled; known-but-absent = disabled.
|
|
|
|
|
plugin_ts_keys = _get_plugin_toolset_keys()
|
|
|
|
|
if plugin_ts_keys:
|
|
|
|
|
known_map = config.get("known_plugin_toolsets", {})
|
|
|
|
|
known_for_platform = set(known_map.get(platform, []))
|
|
|
|
|
for pts in plugin_ts_keys:
|
|
|
|
|
if pts in toolset_names:
|
|
|
|
|
# Explicitly listed in config — enabled
|
|
|
|
|
enabled_toolsets.add(pts)
|
refactor(spotify): convert to built-in bundled plugin under plugins/spotify (#15174)
Moves the Spotify integration from tools/ into plugins/spotify/,
matching the existing pattern established by plugins/image_gen/ for
third-party service integrations.
Why:
- tools/ should be reserved for foundational capabilities (terminal,
read_file, web_search, etc.). tools/providers/ was a one-off
directory created solely for spotify_client.py.
- plugins/ is already the home for image_gen backends, memory
providers, context engines, and standalone hook-based plugins.
Spotify is a third-party service integration and belongs alongside
those, not in tools/.
- Future service integrations (eventually: Deezer, Apple Music, etc.)
now have a pattern to copy.
Changes:
- tools/spotify_tool.py → plugins/spotify/tools.py (handlers + schemas)
- tools/providers/spotify_client.py → plugins/spotify/client.py
- tools/providers/ removed (was only used for Spotify)
- New plugins/spotify/__init__.py with register(ctx) calling
ctx.register_tool() × 7. The handler/check_fn wiring is unchanged.
- New plugins/spotify/plugin.yaml (kind: backend, bundled, auto-load).
- tests/tools/test_spotify_client.py: import paths updated.
tools_config fix — _DEFAULT_OFF_TOOLSETS now wins over plugin auto-enable:
- _get_platform_tools() previously auto-enabled unknown plugin
toolsets for new platforms. That was fine for image_gen (which has
no toolset of its own) but bad for Spotify, which explicitly
requires opt-in (don't ship 7 tool schemas to users who don't use
it). Added a check: if a plugin toolset is in _DEFAULT_OFF_TOOLSETS,
it stays off until the user picks it in 'hermes tools'.
Pre-existing test bug fix:
- tests/hermes_cli/test_plugins.py::test_list_returns_sorted
asserted names were sorted, but list_plugins() sorts by key
(path-derived, e.g. image_gen/openai). With only image_gen plugins
bundled, name and key order happened to agree. Adding plugins/spotify
broke that coincidence (spotify sorts between openai-codex and xai
by name but after xai by key). Updated test to assert key order,
which is what the code actually documents.
Validation:
- scripts/run_tests.sh tests/hermes_cli/test_plugins.py \
tests/hermes_cli/test_tools_config.py \
tests/hermes_cli/test_spotify_auth.py \
tests/tools/test_spotify_client.py \
tests/tools/test_registry.py
→ 143 passed
- E2E plugin load: 'spotify' appears in loaded plugins, all 7 tools
register into the spotify toolset, check_fn gating intact.
2026-04-24 07:06:11 -07:00
|
|
|
elif pts in _DEFAULT_OFF_TOOLSETS:
|
|
|
|
|
# Opt-in plugin toolset — stay off until user picks it
|
|
|
|
|
continue
|
2026-03-22 04:55:34 -07:00
|
|
|
elif pts not in known_for_platform:
|
|
|
|
|
# New plugin not yet seen by hermes tools — default enabled
|
|
|
|
|
enabled_toolsets.add(pts)
|
|
|
|
|
# else: known but not in config = user disabled it
|
|
|
|
|
|
2026-03-26 13:39:41 -07:00
|
|
|
# Preserve any explicit non-configurable toolset entries (for example,
|
|
|
|
|
# custom toolsets or MCP server names saved in platform_toolsets).
|
|
|
|
|
platform_default_keys = {p["default_toolset"] for p in PLATFORMS.values()}
|
|
|
|
|
explicit_passthrough = {
|
|
|
|
|
ts
|
|
|
|
|
for ts in toolset_names
|
|
|
|
|
if ts not in configurable_keys
|
|
|
|
|
and ts not in plugin_ts_keys
|
|
|
|
|
and ts not in platform_default_keys
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# MCP servers are expected to be available on all platforms by default.
|
|
|
|
|
# If the platform explicitly lists one or more MCP server names, treat that
|
|
|
|
|
# as an allowlist. Otherwise include every globally enabled MCP server.
|
2026-04-06 23:03:14 -05:00
|
|
|
# Special sentinel: "no_mcp" in the toolset list disables all MCP servers.
|
2026-04-03 09:07:50 -07:00
|
|
|
mcp_servers = config.get("mcp_servers") or {}
|
2026-03-26 13:39:41 -07:00
|
|
|
enabled_mcp_servers = {
|
2026-04-10 13:10:22 +08:00
|
|
|
str(name)
|
2026-03-26 13:39:41 -07:00
|
|
|
for name, server_cfg in mcp_servers.items()
|
|
|
|
|
if isinstance(server_cfg, dict)
|
|
|
|
|
and _parse_enabled_flag(server_cfg.get("enabled", True), default=True)
|
|
|
|
|
}
|
2026-04-06 23:03:14 -05:00
|
|
|
# Allow "no_mcp" sentinel to opt out of all MCP servers for this platform
|
|
|
|
|
if "no_mcp" in toolset_names:
|
|
|
|
|
explicit_mcp_servers = set()
|
|
|
|
|
enabled_toolsets.update(explicit_passthrough - enabled_mcp_servers - {"no_mcp"})
|
|
|
|
|
else:
|
|
|
|
|
explicit_mcp_servers = explicit_passthrough & enabled_mcp_servers
|
|
|
|
|
enabled_toolsets.update(explicit_passthrough - enabled_mcp_servers)
|
2026-03-26 13:39:41 -07:00
|
|
|
if include_default_mcp_servers:
|
2026-04-06 23:03:14 -05:00
|
|
|
if explicit_mcp_servers or "no_mcp" in toolset_names:
|
2026-03-26 13:39:41 -07:00
|
|
|
enabled_toolsets.update(explicit_mcp_servers)
|
|
|
|
|
else:
|
|
|
|
|
enabled_toolsets.update(enabled_mcp_servers)
|
|
|
|
|
else:
|
|
|
|
|
enabled_toolsets.update(explicit_mcp_servers)
|
|
|
|
|
|
2026-02-23 23:52:07 +00:00
|
|
|
return enabled_toolsets
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _save_platform_tools(config: dict, platform: str, enabled_toolset_keys: Set[str]):
|
2026-03-14 07:58:03 +01:00
|
|
|
"""Save the selected toolset keys for a platform to config.
|
|
|
|
|
|
2026-03-22 04:55:34 -07:00
|
|
|
Preserves any non-configurable toolset entries (like MCP server names)
|
|
|
|
|
that were already in the config for this platform.
|
2026-03-14 07:58:03 +01:00
|
|
|
"""
|
2026-02-23 23:52:07 +00:00
|
|
|
config.setdefault("platform_toolsets", {})
|
2026-03-14 07:58:03 +01:00
|
|
|
|
2026-03-22 04:55:34 -07:00
|
|
|
# Get the set of all configurable toolset keys (built-in + plugin)
|
2026-03-14 07:58:03 +01:00
|
|
|
configurable_keys = {ts_key for ts_key, _, _ in CONFIGURABLE_TOOLSETS}
|
2026-03-22 04:55:34 -07:00
|
|
|
plugin_keys = _get_plugin_toolset_keys()
|
|
|
|
|
configurable_keys |= plugin_keys
|
2026-03-20 21:11:54 -07:00
|
|
|
|
2026-03-23 07:06:51 -07:00
|
|
|
# Also exclude platform default toolsets (hermes-cli, hermes-telegram, etc.)
|
|
|
|
|
# These are "super" toolsets that resolve to ALL tools, so preserving them
|
|
|
|
|
# would silently override the user's unchecked selections on the next read.
|
|
|
|
|
platform_default_keys = {p["default_toolset"] for p in PLATFORMS.values()}
|
|
|
|
|
|
2026-03-14 07:58:03 +01:00
|
|
|
# Get existing toolsets for this platform
|
|
|
|
|
existing_toolsets = config.get("platform_toolsets", {}).get(platform, [])
|
|
|
|
|
if not isinstance(existing_toolsets, list):
|
|
|
|
|
existing_toolsets = []
|
2026-04-24 15:55:51 +05:30
|
|
|
existing_toolsets = [str(ts) for ts in existing_toolsets]
|
2026-03-14 07:58:03 +01:00
|
|
|
|
2026-03-23 07:06:51 -07:00
|
|
|
# Preserve any entries that are NOT configurable toolsets and NOT platform
|
|
|
|
|
# defaults (i.e. only MCP server names should be preserved)
|
2026-03-14 07:58:03 +01:00
|
|
|
preserved_entries = {
|
|
|
|
|
entry for entry in existing_toolsets
|
2026-03-23 07:06:51 -07:00
|
|
|
if entry not in configurable_keys and entry not in platform_default_keys
|
2026-03-14 07:58:03 +01:00
|
|
|
}
|
2026-04-24 15:55:51 +05:30
|
|
|
# Opening `hermes tools` is the user's opt-in to reconfigure tools, so treat
|
|
|
|
|
# saving from the picker as consent to clear the "no_mcp" sentinel. The
|
|
|
|
|
# picker has no checkbox for no_mcp, so without this users who once set it
|
|
|
|
|
# by hand could never re-enable MCP servers through the UI.
|
|
|
|
|
preserved_entries.discard("no_mcp")
|
2026-03-14 07:58:03 +01:00
|
|
|
|
|
|
|
|
# Merge preserved entries with new enabled toolsets
|
|
|
|
|
config["platform_toolsets"][platform] = sorted(enabled_toolset_keys | preserved_entries)
|
2026-03-22 04:55:34 -07:00
|
|
|
|
|
|
|
|
# Track which plugin toolsets are "known" for this platform so we can
|
|
|
|
|
# distinguish "new plugin, default enabled" from "user disabled it".
|
|
|
|
|
if plugin_keys:
|
|
|
|
|
config.setdefault("known_plugin_toolsets", {})
|
|
|
|
|
config["known_plugin_toolsets"][platform] = sorted(plugin_keys)
|
|
|
|
|
|
2026-02-23 23:52:07 +00:00
|
|
|
save_config(config)
|
|
|
|
|
|
|
|
|
|
|
2026-03-26 15:27:27 -07:00
|
|
|
def _toolset_has_keys(ts_key: str, config: dict = None) -> bool:
|
2026-03-06 18:11:35 -08:00
|
|
|
"""Check if a toolset's required API keys are configured."""
|
2026-03-26 15:27:27 -07:00
|
|
|
if config is None:
|
|
|
|
|
config = load_config()
|
|
|
|
|
|
2026-03-14 20:22:13 -07:00
|
|
|
if ts_key == "vision":
|
|
|
|
|
try:
|
|
|
|
|
from agent.auxiliary_client import resolve_vision_provider_client
|
|
|
|
|
|
|
|
|
|
_provider, client, _model = resolve_vision_provider_client()
|
|
|
|
|
return client is not None
|
|
|
|
|
except Exception:
|
|
|
|
|
return False
|
|
|
|
|
|
2026-03-26 15:27:27 -07:00
|
|
|
if ts_key in {"web", "image_gen", "tts", "browser"}:
|
|
|
|
|
features = get_nous_subscription_features(config)
|
|
|
|
|
feature = features.features.get(ts_key)
|
|
|
|
|
if feature and (feature.available or feature.managed_by_nous):
|
|
|
|
|
return True
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
# Check TOOL_CATEGORIES first (provider-aware)
|
|
|
|
|
cat = TOOL_CATEGORIES.get(ts_key)
|
|
|
|
|
if cat:
|
2026-03-26 15:27:27 -07:00
|
|
|
for provider in _visible_providers(cat, config):
|
2026-03-06 18:11:35 -08:00
|
|
|
env_vars = provider.get("env_vars", [])
|
2026-03-30 14:11:39 -07:00
|
|
|
if not env_vars:
|
|
|
|
|
return True # No-key provider (e.g. Local Browser, Edge TTS)
|
|
|
|
|
if all(get_env_value(e["key"]) for e in env_vars):
|
2026-03-06 18:11:35 -08:00
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# Fallback to simple requirements
|
|
|
|
|
requirements = TOOLSET_ENV_REQUIREMENTS.get(ts_key, [])
|
|
|
|
|
if not requirements:
|
|
|
|
|
return True
|
|
|
|
|
return all(get_env_value(var) for var, _ in requirements)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ─── Menu Helpers ─────────────────────────────────────────────────────────────
|
|
|
|
|
|
2026-02-23 23:52:07 +00:00
|
|
|
def _prompt_choice(question: str, choices: list, default: int = 0) -> int:
|
refactor: extract shared helpers to deduplicate repeated code patterns (#7917)
* refactor: add shared helper modules for code deduplication
New modules:
- gateway/platforms/helpers.py: MessageDeduplicator, TextBatchAggregator,
strip_markdown, ThreadParticipationTracker, redact_phone
- hermes_cli/cli_output.py: print_info/success/warning/error, prompt helpers
- tools/path_security.py: validate_within_dir, has_traversal_component
- utils.py additions: safe_json_loads, read_json_file, read_jsonl,
append_jsonl, env_str/lower/int/bool helpers
- hermes_constants.py additions: get_config_path, get_skills_dir,
get_logs_dir, get_env_path
* refactor: migrate gateway adapters to shared helpers
- MessageDeduplicator: discord, slack, dingtalk, wecom, weixin, mattermost
- strip_markdown: bluebubbles, feishu, sms
- redact_phone: sms, signal
- ThreadParticipationTracker: discord, matrix
- _acquire/_release_platform_lock: telegram, discord, slack, whatsapp,
signal, weixin
Net -316 lines across 19 files.
* refactor: migrate CLI modules to shared helpers
- tools_config.py: use cli_output print/prompt + curses_radiolist (-117 lines)
- setup.py: use cli_output print helpers + curses_radiolist (-101 lines)
- mcp_config.py: use cli_output prompt (-15 lines)
- memory_setup.py: use curses_radiolist (-86 lines)
Net -263 lines across 5 files.
* refactor: migrate to shared utility helpers
- safe_json_loads: agent/display.py (4 sites)
- get_config_path: skill_utils.py, hermes_logging.py, hermes_time.py
- get_skills_dir: skill_utils.py, prompt_builder.py
- Token estimation dedup: skills_tool.py imports from model_metadata
- Path security: skills_tool, cronjob_tools, skill_manager_tool, credential_files
- Non-atomic YAML writes: doctor.py, config.py now use atomic_yaml_write
- Platform dict: new platforms.py, skills_config + tools_config derive from it
- Anthropic key: new get_anthropic_key() in auth.py, used by doctor/status/config/main
* test: update tests for shared helper migrations
- test_dingtalk: use _dedup.is_duplicate() instead of _is_duplicate()
- test_mattermost: use _dedup instead of _seen_posts/_prune_seen
- test_signal: import redact_phone from helpers instead of signal
- test_discord_connect: _platform_lock_identity instead of _token_lock_identity
- test_telegram_conflict: updated lock error message format
- test_skill_manager_tool: 'escapes' instead of 'boundary' in error msgs
2026-04-11 13:59:52 -07:00
|
|
|
"""Single-select menu (arrow keys). Delegates to curses_radiolist."""
|
|
|
|
|
from hermes_cli.curses_ui import curses_radiolist
|
|
|
|
|
return curses_radiolist(question, choices, selected=default, cancel_returns=default)
|
2026-02-27 13:56:43 -08:00
|
|
|
|
|
|
|
|
|
feat: show estimated tool token context in hermes tools checklist (#3805)
* feat: show estimated tool token context in hermes tools checklist
Adds a live token estimate indicator to the bottom of the interactive
tool configuration checklist (hermes tools / hermes setup). As users
toggle toolsets on/off, the total estimated context cost updates in
real time.
Implementation:
- tools/registry.py: Add get_schema() for check_fn-free schema access
- hermes_cli/curses_ui.py: Add optional status_fn callback to
curses_checklist — renders at bottom-right of terminal, stays fixed
while items scroll
- hermes_cli/tools_config.py: Add _estimate_tool_tokens() using
tiktoken (cl100k_base, already installed) to count tokens in the
JSON-serialised OpenAI-format tool schemas. Results are cached
per-process. The status function deduplicates overlapping tools
(e.g. browser includes web_search) for accurate totals.
- 12 new tests covering estimation, caching, graceful degradation
when tiktoken is unavailable, status_fn wiring, deduplication,
and the numbered fallback display
* fix: use effective toolsets (includes plugins) for token estimation index mapping
The status_fn closure built ts_keys from CONFIGURABLE_TOOLSETS but the
checklist uses _get_effective_configurable_toolsets() which appends plugin
toolsets. With plugins present, the indices would mismatch, causing
IndexError when selecting a plugin toolset.
2026-03-29 15:36:56 -07:00
|
|
|
# ─── Token Estimation ────────────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
# Module-level cache so discovery + tokenization runs at most once per process.
|
|
|
|
|
_tool_token_cache: Optional[Dict[str, int]] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _estimate_tool_tokens() -> Dict[str, int]:
|
|
|
|
|
"""Return estimated token counts per individual tool name.
|
|
|
|
|
|
|
|
|
|
Uses tiktoken (cl100k_base) to count tokens in the JSON-serialised
|
|
|
|
|
OpenAI-format tool schema. Triggers tool discovery on first call,
|
|
|
|
|
then caches the result for the rest of the process.
|
|
|
|
|
|
|
|
|
|
Returns an empty dict when tiktoken or the registry is unavailable.
|
|
|
|
|
"""
|
|
|
|
|
global _tool_token_cache
|
|
|
|
|
if _tool_token_cache is not None:
|
|
|
|
|
return _tool_token_cache
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
import tiktoken
|
|
|
|
|
enc = tiktoken.get_encoding("cl100k_base")
|
|
|
|
|
except Exception:
|
|
|
|
|
logger.debug("tiktoken unavailable; skipping tool token estimation")
|
|
|
|
|
_tool_token_cache = {}
|
|
|
|
|
return _tool_token_cache
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
# Trigger full tool discovery (imports all tool modules).
|
|
|
|
|
import model_tools # noqa: F401
|
|
|
|
|
from tools.registry import registry
|
|
|
|
|
except Exception:
|
|
|
|
|
logger.debug("Tool registry unavailable; skipping token estimation")
|
|
|
|
|
_tool_token_cache = {}
|
|
|
|
|
return _tool_token_cache
|
|
|
|
|
|
|
|
|
|
counts: Dict[str, int] = {}
|
|
|
|
|
for name in registry.get_all_tool_names():
|
|
|
|
|
schema = registry.get_schema(name)
|
|
|
|
|
if schema:
|
|
|
|
|
# Mirror what gets sent to the API:
|
|
|
|
|
# {"type": "function", "function": <schema>}
|
|
|
|
|
text = _json.dumps({"type": "function", "function": schema})
|
|
|
|
|
counts[name] = len(enc.encode(text))
|
|
|
|
|
_tool_token_cache = counts
|
|
|
|
|
return _tool_token_cache
|
|
|
|
|
|
|
|
|
|
|
2026-02-23 23:52:07 +00:00
|
|
|
def _prompt_toolset_checklist(platform_label: str, enabled: Set[str]) -> Set[str]:
|
|
|
|
|
"""Multi-select checklist of toolsets. Returns set of selected toolset keys."""
|
2026-03-11 03:06:15 -07:00
|
|
|
from hermes_cli.curses_ui import curses_checklist
|
feat: show estimated tool token context in hermes tools checklist (#3805)
* feat: show estimated tool token context in hermes tools checklist
Adds a live token estimate indicator to the bottom of the interactive
tool configuration checklist (hermes tools / hermes setup). As users
toggle toolsets on/off, the total estimated context cost updates in
real time.
Implementation:
- tools/registry.py: Add get_schema() for check_fn-free schema access
- hermes_cli/curses_ui.py: Add optional status_fn callback to
curses_checklist — renders at bottom-right of terminal, stays fixed
while items scroll
- hermes_cli/tools_config.py: Add _estimate_tool_tokens() using
tiktoken (cl100k_base, already installed) to count tokens in the
JSON-serialised OpenAI-format tool schemas. Results are cached
per-process. The status function deduplicates overlapping tools
(e.g. browser includes web_search) for accurate totals.
- 12 new tests covering estimation, caching, graceful degradation
when tiktoken is unavailable, status_fn wiring, deduplication,
and the numbered fallback display
* fix: use effective toolsets (includes plugins) for token estimation index mapping
The status_fn closure built ts_keys from CONFIGURABLE_TOOLSETS but the
checklist uses _get_effective_configurable_toolsets() which appends plugin
toolsets. With plugins present, the indices would mismatch, causing
IndexError when selecting a plugin toolset.
2026-03-29 15:36:56 -07:00
|
|
|
from toolsets import resolve_toolset
|
|
|
|
|
|
|
|
|
|
# Pre-compute per-tool token counts (cached after first call).
|
|
|
|
|
tool_tokens = _estimate_tool_tokens()
|
2026-02-23 23:52:07 +00:00
|
|
|
|
2026-03-22 04:55:34 -07:00
|
|
|
effective = _get_effective_configurable_toolsets()
|
|
|
|
|
|
2026-02-23 23:52:07 +00:00
|
|
|
labels = []
|
2026-03-22 04:55:34 -07:00
|
|
|
for ts_key, ts_label, ts_desc in effective:
|
2026-02-27 13:56:43 -08:00
|
|
|
suffix = ""
|
2026-03-06 18:11:35 -08:00
|
|
|
if not _toolset_has_keys(ts_key) and (TOOL_CATEGORIES.get(ts_key) or TOOLSET_ENV_REQUIREMENTS.get(ts_key)):
|
|
|
|
|
suffix = " [no API key]"
|
2026-02-27 13:56:43 -08:00
|
|
|
labels.append(f"{ts_label} ({ts_desc}){suffix}")
|
2026-02-23 23:52:07 +00:00
|
|
|
|
2026-03-11 03:06:15 -07:00
|
|
|
pre_selected = {
|
2026-03-22 04:55:34 -07:00
|
|
|
i for i, (ts_key, _, _) in enumerate(effective)
|
2026-02-23 23:52:07 +00:00
|
|
|
if ts_key in enabled
|
2026-03-11 03:06:15 -07:00
|
|
|
}
|
|
|
|
|
|
feat: show estimated tool token context in hermes tools checklist (#3805)
* feat: show estimated tool token context in hermes tools checklist
Adds a live token estimate indicator to the bottom of the interactive
tool configuration checklist (hermes tools / hermes setup). As users
toggle toolsets on/off, the total estimated context cost updates in
real time.
Implementation:
- tools/registry.py: Add get_schema() for check_fn-free schema access
- hermes_cli/curses_ui.py: Add optional status_fn callback to
curses_checklist — renders at bottom-right of terminal, stays fixed
while items scroll
- hermes_cli/tools_config.py: Add _estimate_tool_tokens() using
tiktoken (cl100k_base, already installed) to count tokens in the
JSON-serialised OpenAI-format tool schemas. Results are cached
per-process. The status function deduplicates overlapping tools
(e.g. browser includes web_search) for accurate totals.
- 12 new tests covering estimation, caching, graceful degradation
when tiktoken is unavailable, status_fn wiring, deduplication,
and the numbered fallback display
* fix: use effective toolsets (includes plugins) for token estimation index mapping
The status_fn closure built ts_keys from CONFIGURABLE_TOOLSETS but the
checklist uses _get_effective_configurable_toolsets() which appends plugin
toolsets. With plugins present, the indices would mismatch, causing
IndexError when selecting a plugin toolset.
2026-03-29 15:36:56 -07:00
|
|
|
# Build a live status function that shows deduplicated total token cost.
|
|
|
|
|
status_fn = None
|
|
|
|
|
if tool_tokens:
|
|
|
|
|
ts_keys = [ts_key for ts_key, _, _ in effective]
|
|
|
|
|
|
|
|
|
|
def status_fn(chosen: set) -> str:
|
|
|
|
|
# Collect unique tool names across all selected toolsets
|
|
|
|
|
all_tools: set = set()
|
|
|
|
|
for idx in chosen:
|
|
|
|
|
all_tools.update(resolve_toolset(ts_keys[idx]))
|
|
|
|
|
total = sum(tool_tokens.get(name, 0) for name in all_tools)
|
|
|
|
|
if total >= 1000:
|
|
|
|
|
return f"Est. tool context: ~{total / 1000:.1f}k tokens"
|
|
|
|
|
return f"Est. tool context: ~{total} tokens"
|
|
|
|
|
|
2026-03-11 03:06:15 -07:00
|
|
|
chosen = curses_checklist(
|
|
|
|
|
f"Tools for {platform_label}",
|
|
|
|
|
labels,
|
|
|
|
|
pre_selected,
|
|
|
|
|
cancel_returns=pre_selected,
|
feat: show estimated tool token context in hermes tools checklist (#3805)
* feat: show estimated tool token context in hermes tools checklist
Adds a live token estimate indicator to the bottom of the interactive
tool configuration checklist (hermes tools / hermes setup). As users
toggle toolsets on/off, the total estimated context cost updates in
real time.
Implementation:
- tools/registry.py: Add get_schema() for check_fn-free schema access
- hermes_cli/curses_ui.py: Add optional status_fn callback to
curses_checklist — renders at bottom-right of terminal, stays fixed
while items scroll
- hermes_cli/tools_config.py: Add _estimate_tool_tokens() using
tiktoken (cl100k_base, already installed) to count tokens in the
JSON-serialised OpenAI-format tool schemas. Results are cached
per-process. The status function deduplicates overlapping tools
(e.g. browser includes web_search) for accurate totals.
- 12 new tests covering estimation, caching, graceful degradation
when tiktoken is unavailable, status_fn wiring, deduplication,
and the numbered fallback display
* fix: use effective toolsets (includes plugins) for token estimation index mapping
The status_fn closure built ts_keys from CONFIGURABLE_TOOLSETS but the
checklist uses _get_effective_configurable_toolsets() which appends plugin
toolsets. With plugins present, the indices would mismatch, causing
IndexError when selecting a plugin toolset.
2026-03-29 15:36:56 -07:00
|
|
|
status_fn=status_fn,
|
2026-03-11 03:06:15 -07:00
|
|
|
)
|
2026-03-22 04:55:34 -07:00
|
|
|
return {effective[i][0] for i in chosen}
|
2026-02-23 23:52:07 +00:00
|
|
|
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
# ─── Provider-Aware Configuration ────────────────────────────────────────────
|
2026-02-24 00:01:39 +00:00
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
def _configure_toolset(ts_key: str, config: dict):
|
|
|
|
|
"""Configure a toolset - provider selection + API keys.
|
|
|
|
|
|
|
|
|
|
Uses TOOL_CATEGORIES for provider-aware config, falls back to simple
|
|
|
|
|
env var prompts for toolsets not in TOOL_CATEGORIES.
|
|
|
|
|
"""
|
|
|
|
|
cat = TOOL_CATEGORIES.get(ts_key)
|
2026-02-24 00:01:39 +00:00
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
if cat:
|
|
|
|
|
_configure_tool_category(ts_key, cat, config)
|
|
|
|
|
else:
|
|
|
|
|
# Simple fallback for vision, moa, etc.
|
|
|
|
|
_configure_simple_requirements(ts_key)
|
2026-02-24 00:01:39 +00:00
|
|
|
|
|
|
|
|
|
feat(plugins): pluggable image_gen backends + OpenAI provider (#13799)
* feat(plugins): pluggable image_gen backends + OpenAI provider
Adds a ImageGenProvider ABC so image generation backends register as
bundled plugins under `plugins/image_gen/<name>/`. The plugin scanner
gains three primitives to make this work generically:
- `kind:` manifest field (`standalone` | `backend` | `exclusive`).
Bundled `kind: backend` plugins auto-load — no `plugins.enabled`
incantation. User-installed backends stay opt-in.
- Path-derived keys: `plugins/image_gen/openai/` gets key
`image_gen/openai`, so a future `tts/openai` cannot collide.
- Depth-2 recursion into category namespaces (parent dirs without a
`plugin.yaml` of their own).
Includes `OpenAIImageGenProvider` as the first consumer (gpt-image-1.5
default, plus gpt-image-1, gpt-image-1-mini, DALL-E 3/2). Base64
responses save to `$HERMES_HOME/cache/images/`; URL responses pass
through.
FAL stays in-tree for this PR — a follow-up ports it into
`plugins/image_gen/fal/` so the in-tree `image_generation_tool.py`
slims down. The dispatch shim in `_handle_image_generate` only fires
when `image_gen.provider` is explicitly set to a non-FAL value, so
existing FAL setups are untouched.
- 41 unit tests (scanner recursion, kind parsing, gate logic,
registry, OpenAI payload shapes)
- E2E smoke verified: bundled plugin autoloads, registers, and
`_handle_image_generate` routes to OpenAI when configured
* fix(image_gen/openai): don't send response_format to gpt-image-*
The live API rejects it: 'Unknown parameter: response_format'
(verified 2026-04-21 with gpt-image-1.5). gpt-image-* models return
b64_json unconditionally, so the parameter was both unnecessary and
actively broken.
* feat(image_gen/openai): gpt-image-2 only, drop legacy catalog
gpt-image-2 is the latest/best OpenAI image model (released 2026-04-21)
and there's no reason to expose the older gpt-image-1.5 / gpt-image-1 /
dall-e-3 / dall-e-2 alongside it — slower, lower quality, or awkward
(dall-e-2 squares only). Trim the catalog down to a single model.
Live-verified end-to-end: landscape 1536x1024 render of a Moog-style
synth matches prompt exactly, 2.4MB PNG saved to cache.
* feat(image_gen/openai): expose gpt-image-2 as three quality tiers
Users pick speed/fidelity via the normal model picker instead of a
hidden quality knob. All three tier IDs resolve to the single underlying
gpt-image-2 API model with a different quality parameter:
gpt-image-2-low ~15s fast iteration
gpt-image-2-medium ~40s default
gpt-image-2-high ~2min highest fidelity
Live-measured on OpenAI's API today: 15.4s / 40.8s / 116.9s for the
same 1024x1024 prompt.
Config:
image_gen.openai.model: gpt-image-2-high
# or
image_gen.model: gpt-image-2-low
# or env var for scripts/tests
OPENAI_IMAGE_MODEL=gpt-image-2-medium
Live-verified end-to-end with the low tier: 18.8s landscape render of a
golden retriever in wildflowers, vision-confirmed exact match.
* feat(tools_config): plugin image_gen providers inject themselves into picker
'hermes tools' → Image Generation now shows plugin-registered backends
alongside Nous Subscription and FAL.ai without tools_config.py needing
to know about them. OpenAI appears as a third option today; future
backends appear automatically as they're added.
Mechanism:
- ImageGenProvider gains an optional get_setup_schema() hook
(name, badge, tag, env_vars). Default derived from display_name.
- tools_config._plugin_image_gen_providers() pulls the schemas from
every registered non-FAL plugin provider.
- _visible_providers() appends those rows when rendering the Image
Generation category.
- _configure_provider() handles the new image_gen_plugin_name marker:
writes image_gen.provider and routes to the plugin's list_models()
catalog for the model picker.
- _toolset_needs_configuration_prompt('image_gen') stops demanding a
FAL key when any plugin provider reports is_available().
FAL is skipped in the plugin path because it already has hardcoded
TOOL_CATEGORIES rows — when it gets ported to a plugin in a follow-up
PR the hardcoded rows go away and it surfaces through the same path
as OpenAI.
Verified live: picker shows Nous Subscription / FAL.ai / OpenAI.
Picking OpenAI prompts for OPENAI_API_KEY, then shows the
gpt-image-2-low/medium/high model picker sourced from the plugin.
397 tests pass across plugins/, tools_config, registry, and picker.
* fix(image_gen): close final gaps for plugin-backend parity with FAL
Two small places that still hardcoded FAL:
- hermes_cli/setup.py status line: an OpenAI-only setup showed
'Image Generation: missing FAL_KEY'. Now probes plugin providers
and reports '(OpenAI)' when one is_available() — or falls back to
'missing FAL_KEY or OPENAI_API_KEY' if nothing is configured.
- image_generate tool schema description: said 'using FAL.ai, default
FLUX 2 Klein 9B'. Rewrote provider-neutral — 'backend and model are
user-configured' — and notes the 'image' field can be a URL or an
absolute path, which the gateway delivers either way via
extract_local_files().
2026-04-21 21:30:10 -07:00
|
|
|
def _plugin_image_gen_providers() -> list[dict]:
|
|
|
|
|
"""Build picker-row dicts from plugin-registered image gen providers.
|
|
|
|
|
|
|
|
|
|
Each returned dict looks like a regular ``TOOL_CATEGORIES`` provider
|
|
|
|
|
row but carries an ``image_gen_plugin_name`` marker so downstream
|
|
|
|
|
code (config writing, model picker) knows to route through the
|
|
|
|
|
plugin registry instead of the in-tree FAL backend.
|
|
|
|
|
|
|
|
|
|
FAL is skipped — it's already exposed by the hardcoded
|
|
|
|
|
``TOOL_CATEGORIES["image_gen"]`` entries. When FAL gets ported to
|
|
|
|
|
a plugin in a follow-up PR, the hardcoded entries go away and this
|
|
|
|
|
function surfaces it alongside OpenAI automatically.
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
from agent.image_gen_registry import list_providers
|
|
|
|
|
from hermes_cli.plugins import _ensure_plugins_discovered
|
|
|
|
|
|
|
|
|
|
_ensure_plugins_discovered()
|
|
|
|
|
providers = list_providers()
|
|
|
|
|
except Exception:
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
rows: list[dict] = []
|
|
|
|
|
for provider in providers:
|
|
|
|
|
if getattr(provider, "name", None) == "fal":
|
|
|
|
|
# FAL has its own hardcoded rows today.
|
|
|
|
|
continue
|
|
|
|
|
try:
|
|
|
|
|
schema = provider.get_setup_schema()
|
|
|
|
|
except Exception:
|
|
|
|
|
continue
|
|
|
|
|
if not isinstance(schema, dict):
|
|
|
|
|
continue
|
|
|
|
|
rows.append(
|
|
|
|
|
{
|
|
|
|
|
"name": schema.get("name", provider.display_name),
|
|
|
|
|
"badge": schema.get("badge", ""),
|
|
|
|
|
"tag": schema.get("tag", ""),
|
|
|
|
|
"env_vars": schema.get("env_vars", []),
|
|
|
|
|
"image_gen_plugin_name": provider.name,
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
return rows
|
|
|
|
|
|
|
|
|
|
|
2026-03-26 15:27:27 -07:00
|
|
|
def _visible_providers(cat: dict, config: dict) -> list[dict]:
|
|
|
|
|
"""Return provider entries visible for the current auth/config state."""
|
|
|
|
|
features = get_nous_subscription_features(config)
|
|
|
|
|
visible = []
|
|
|
|
|
for provider in cat.get("providers", []):
|
2026-03-30 13:28:10 +09:00
|
|
|
if provider.get("managed_nous_feature") and not managed_nous_tools_enabled():
|
|
|
|
|
continue
|
2026-03-26 15:27:27 -07:00
|
|
|
if provider.get("requires_nous_auth") and not features.nous_auth_present:
|
|
|
|
|
continue
|
|
|
|
|
visible.append(provider)
|
feat(plugins): pluggable image_gen backends + OpenAI provider (#13799)
* feat(plugins): pluggable image_gen backends + OpenAI provider
Adds a ImageGenProvider ABC so image generation backends register as
bundled plugins under `plugins/image_gen/<name>/`. The plugin scanner
gains three primitives to make this work generically:
- `kind:` manifest field (`standalone` | `backend` | `exclusive`).
Bundled `kind: backend` plugins auto-load — no `plugins.enabled`
incantation. User-installed backends stay opt-in.
- Path-derived keys: `plugins/image_gen/openai/` gets key
`image_gen/openai`, so a future `tts/openai` cannot collide.
- Depth-2 recursion into category namespaces (parent dirs without a
`plugin.yaml` of their own).
Includes `OpenAIImageGenProvider` as the first consumer (gpt-image-1.5
default, plus gpt-image-1, gpt-image-1-mini, DALL-E 3/2). Base64
responses save to `$HERMES_HOME/cache/images/`; URL responses pass
through.
FAL stays in-tree for this PR — a follow-up ports it into
`plugins/image_gen/fal/` so the in-tree `image_generation_tool.py`
slims down. The dispatch shim in `_handle_image_generate` only fires
when `image_gen.provider` is explicitly set to a non-FAL value, so
existing FAL setups are untouched.
- 41 unit tests (scanner recursion, kind parsing, gate logic,
registry, OpenAI payload shapes)
- E2E smoke verified: bundled plugin autoloads, registers, and
`_handle_image_generate` routes to OpenAI when configured
* fix(image_gen/openai): don't send response_format to gpt-image-*
The live API rejects it: 'Unknown parameter: response_format'
(verified 2026-04-21 with gpt-image-1.5). gpt-image-* models return
b64_json unconditionally, so the parameter was both unnecessary and
actively broken.
* feat(image_gen/openai): gpt-image-2 only, drop legacy catalog
gpt-image-2 is the latest/best OpenAI image model (released 2026-04-21)
and there's no reason to expose the older gpt-image-1.5 / gpt-image-1 /
dall-e-3 / dall-e-2 alongside it — slower, lower quality, or awkward
(dall-e-2 squares only). Trim the catalog down to a single model.
Live-verified end-to-end: landscape 1536x1024 render of a Moog-style
synth matches prompt exactly, 2.4MB PNG saved to cache.
* feat(image_gen/openai): expose gpt-image-2 as three quality tiers
Users pick speed/fidelity via the normal model picker instead of a
hidden quality knob. All three tier IDs resolve to the single underlying
gpt-image-2 API model with a different quality parameter:
gpt-image-2-low ~15s fast iteration
gpt-image-2-medium ~40s default
gpt-image-2-high ~2min highest fidelity
Live-measured on OpenAI's API today: 15.4s / 40.8s / 116.9s for the
same 1024x1024 prompt.
Config:
image_gen.openai.model: gpt-image-2-high
# or
image_gen.model: gpt-image-2-low
# or env var for scripts/tests
OPENAI_IMAGE_MODEL=gpt-image-2-medium
Live-verified end-to-end with the low tier: 18.8s landscape render of a
golden retriever in wildflowers, vision-confirmed exact match.
* feat(tools_config): plugin image_gen providers inject themselves into picker
'hermes tools' → Image Generation now shows plugin-registered backends
alongside Nous Subscription and FAL.ai without tools_config.py needing
to know about them. OpenAI appears as a third option today; future
backends appear automatically as they're added.
Mechanism:
- ImageGenProvider gains an optional get_setup_schema() hook
(name, badge, tag, env_vars). Default derived from display_name.
- tools_config._plugin_image_gen_providers() pulls the schemas from
every registered non-FAL plugin provider.
- _visible_providers() appends those rows when rendering the Image
Generation category.
- _configure_provider() handles the new image_gen_plugin_name marker:
writes image_gen.provider and routes to the plugin's list_models()
catalog for the model picker.
- _toolset_needs_configuration_prompt('image_gen') stops demanding a
FAL key when any plugin provider reports is_available().
FAL is skipped in the plugin path because it already has hardcoded
TOOL_CATEGORIES rows — when it gets ported to a plugin in a follow-up
PR the hardcoded rows go away and it surfaces through the same path
as OpenAI.
Verified live: picker shows Nous Subscription / FAL.ai / OpenAI.
Picking OpenAI prompts for OPENAI_API_KEY, then shows the
gpt-image-2-low/medium/high model picker sourced from the plugin.
397 tests pass across plugins/, tools_config, registry, and picker.
* fix(image_gen): close final gaps for plugin-backend parity with FAL
Two small places that still hardcoded FAL:
- hermes_cli/setup.py status line: an OpenAI-only setup showed
'Image Generation: missing FAL_KEY'. Now probes plugin providers
and reports '(OpenAI)' when one is_available() — or falls back to
'missing FAL_KEY or OPENAI_API_KEY' if nothing is configured.
- image_generate tool schema description: said 'using FAL.ai, default
FLUX 2 Klein 9B'. Rewrote provider-neutral — 'backend and model are
user-configured' — and notes the 'image' field can be a URL or an
absolute path, which the gateway delivers either way via
extract_local_files().
2026-04-21 21:30:10 -07:00
|
|
|
|
|
|
|
|
# Inject plugin-registered image_gen backends (OpenAI today, more
|
|
|
|
|
# later) so the picker lists them alongside FAL / Nous Subscription.
|
|
|
|
|
if cat.get("name") == "Image Generation":
|
|
|
|
|
visible.extend(_plugin_image_gen_providers())
|
|
|
|
|
|
2026-03-26 15:27:27 -07:00
|
|
|
return visible
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _toolset_needs_configuration_prompt(ts_key: str, config: dict) -> bool:
|
|
|
|
|
"""Return True when enabling this toolset should open provider setup."""
|
|
|
|
|
cat = TOOL_CATEGORIES.get(ts_key)
|
|
|
|
|
if not cat:
|
|
|
|
|
return not _toolset_has_keys(ts_key, config)
|
|
|
|
|
|
|
|
|
|
if ts_key == "tts":
|
|
|
|
|
tts_cfg = config.get("tts", {})
|
|
|
|
|
return not isinstance(tts_cfg, dict) or "provider" not in tts_cfg
|
|
|
|
|
if ts_key == "web":
|
|
|
|
|
web_cfg = config.get("web", {})
|
|
|
|
|
return not isinstance(web_cfg, dict) or "backend" not in web_cfg
|
|
|
|
|
if ts_key == "browser":
|
|
|
|
|
browser_cfg = config.get("browser", {})
|
|
|
|
|
return not isinstance(browser_cfg, dict) or "cloud_provider" not in browser_cfg
|
|
|
|
|
if ts_key == "image_gen":
|
feat(plugins): pluggable image_gen backends + OpenAI provider (#13799)
* feat(plugins): pluggable image_gen backends + OpenAI provider
Adds a ImageGenProvider ABC so image generation backends register as
bundled plugins under `plugins/image_gen/<name>/`. The plugin scanner
gains three primitives to make this work generically:
- `kind:` manifest field (`standalone` | `backend` | `exclusive`).
Bundled `kind: backend` plugins auto-load — no `plugins.enabled`
incantation. User-installed backends stay opt-in.
- Path-derived keys: `plugins/image_gen/openai/` gets key
`image_gen/openai`, so a future `tts/openai` cannot collide.
- Depth-2 recursion into category namespaces (parent dirs without a
`plugin.yaml` of their own).
Includes `OpenAIImageGenProvider` as the first consumer (gpt-image-1.5
default, plus gpt-image-1, gpt-image-1-mini, DALL-E 3/2). Base64
responses save to `$HERMES_HOME/cache/images/`; URL responses pass
through.
FAL stays in-tree for this PR — a follow-up ports it into
`plugins/image_gen/fal/` so the in-tree `image_generation_tool.py`
slims down. The dispatch shim in `_handle_image_generate` only fires
when `image_gen.provider` is explicitly set to a non-FAL value, so
existing FAL setups are untouched.
- 41 unit tests (scanner recursion, kind parsing, gate logic,
registry, OpenAI payload shapes)
- E2E smoke verified: bundled plugin autoloads, registers, and
`_handle_image_generate` routes to OpenAI when configured
* fix(image_gen/openai): don't send response_format to gpt-image-*
The live API rejects it: 'Unknown parameter: response_format'
(verified 2026-04-21 with gpt-image-1.5). gpt-image-* models return
b64_json unconditionally, so the parameter was both unnecessary and
actively broken.
* feat(image_gen/openai): gpt-image-2 only, drop legacy catalog
gpt-image-2 is the latest/best OpenAI image model (released 2026-04-21)
and there's no reason to expose the older gpt-image-1.5 / gpt-image-1 /
dall-e-3 / dall-e-2 alongside it — slower, lower quality, or awkward
(dall-e-2 squares only). Trim the catalog down to a single model.
Live-verified end-to-end: landscape 1536x1024 render of a Moog-style
synth matches prompt exactly, 2.4MB PNG saved to cache.
* feat(image_gen/openai): expose gpt-image-2 as three quality tiers
Users pick speed/fidelity via the normal model picker instead of a
hidden quality knob. All three tier IDs resolve to the single underlying
gpt-image-2 API model with a different quality parameter:
gpt-image-2-low ~15s fast iteration
gpt-image-2-medium ~40s default
gpt-image-2-high ~2min highest fidelity
Live-measured on OpenAI's API today: 15.4s / 40.8s / 116.9s for the
same 1024x1024 prompt.
Config:
image_gen.openai.model: gpt-image-2-high
# or
image_gen.model: gpt-image-2-low
# or env var for scripts/tests
OPENAI_IMAGE_MODEL=gpt-image-2-medium
Live-verified end-to-end with the low tier: 18.8s landscape render of a
golden retriever in wildflowers, vision-confirmed exact match.
* feat(tools_config): plugin image_gen providers inject themselves into picker
'hermes tools' → Image Generation now shows plugin-registered backends
alongside Nous Subscription and FAL.ai without tools_config.py needing
to know about them. OpenAI appears as a third option today; future
backends appear automatically as they're added.
Mechanism:
- ImageGenProvider gains an optional get_setup_schema() hook
(name, badge, tag, env_vars). Default derived from display_name.
- tools_config._plugin_image_gen_providers() pulls the schemas from
every registered non-FAL plugin provider.
- _visible_providers() appends those rows when rendering the Image
Generation category.
- _configure_provider() handles the new image_gen_plugin_name marker:
writes image_gen.provider and routes to the plugin's list_models()
catalog for the model picker.
- _toolset_needs_configuration_prompt('image_gen') stops demanding a
FAL key when any plugin provider reports is_available().
FAL is skipped in the plugin path because it already has hardcoded
TOOL_CATEGORIES rows — when it gets ported to a plugin in a follow-up
PR the hardcoded rows go away and it surfaces through the same path
as OpenAI.
Verified live: picker shows Nous Subscription / FAL.ai / OpenAI.
Picking OpenAI prompts for OPENAI_API_KEY, then shows the
gpt-image-2-low/medium/high model picker sourced from the plugin.
397 tests pass across plugins/, tools_config, registry, and picker.
* fix(image_gen): close final gaps for plugin-backend parity with FAL
Two small places that still hardcoded FAL:
- hermes_cli/setup.py status line: an OpenAI-only setup showed
'Image Generation: missing FAL_KEY'. Now probes plugin providers
and reports '(OpenAI)' when one is_available() — or falls back to
'missing FAL_KEY or OPENAI_API_KEY' if nothing is configured.
- image_generate tool schema description: said 'using FAL.ai, default
FLUX 2 Klein 9B'. Rewrote provider-neutral — 'backend and model are
user-configured' — and notes the 'image' field can be a URL or an
absolute path, which the gateway delivers either way via
extract_local_files().
2026-04-21 21:30:10 -07:00
|
|
|
# Satisfied when the in-tree FAL backend is configured OR any
|
|
|
|
|
# plugin-registered image gen provider is available.
|
|
|
|
|
if fal_key_is_configured():
|
|
|
|
|
return False
|
|
|
|
|
try:
|
|
|
|
|
from agent.image_gen_registry import list_providers
|
|
|
|
|
from hermes_cli.plugins import _ensure_plugins_discovered
|
|
|
|
|
|
|
|
|
|
_ensure_plugins_discovered()
|
|
|
|
|
for provider in list_providers():
|
|
|
|
|
try:
|
|
|
|
|
if provider.is_available():
|
|
|
|
|
return False
|
|
|
|
|
except Exception:
|
|
|
|
|
continue
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
return True
|
2026-03-26 15:27:27 -07:00
|
|
|
|
|
|
|
|
return not _toolset_has_keys(ts_key, config)
|
|
|
|
|
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
def _configure_tool_category(ts_key: str, cat: dict, config: dict):
|
|
|
|
|
"""Configure a tool category with provider selection."""
|
|
|
|
|
icon = cat.get("icon", "")
|
|
|
|
|
name = cat["name"]
|
2026-03-26 15:27:27 -07:00
|
|
|
providers = _visible_providers(cat, config)
|
2026-03-06 18:11:35 -08:00
|
|
|
|
|
|
|
|
# Check Python version requirement
|
|
|
|
|
if cat.get("requires_python"):
|
|
|
|
|
req = cat["requires_python"]
|
|
|
|
|
if sys.version_info < req:
|
|
|
|
|
print()
|
|
|
|
|
_print_error(f" {name} requires Python {req[0]}.{req[1]}+ (current: {sys.version_info.major}.{sys.version_info.minor})")
|
|
|
|
|
_print_info(" Upgrade Python and reinstall to enable this tool.")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if len(providers) == 1:
|
|
|
|
|
# Single provider - configure directly
|
|
|
|
|
provider = providers[0]
|
|
|
|
|
print()
|
|
|
|
|
print(color(f" --- {icon} {name} ({provider['name']}) ---", Colors.CYAN))
|
|
|
|
|
if provider.get("tag"):
|
|
|
|
|
_print_info(f" {provider['tag']}")
|
2026-03-08 23:15:14 -07:00
|
|
|
# For single-provider tools, show a note if available
|
|
|
|
|
if cat.get("setup_note"):
|
|
|
|
|
_print_info(f" {cat['setup_note']}")
|
2026-03-06 18:11:35 -08:00
|
|
|
_configure_provider(provider, config)
|
|
|
|
|
else:
|
|
|
|
|
# Multiple providers - let user choose
|
2026-02-24 00:01:39 +00:00
|
|
|
print()
|
2026-03-08 23:15:14 -07:00
|
|
|
# Use custom title if provided (e.g. "Select Search Provider")
|
chore: fix 154 f-strings, simplify getattr/URL patterns, remove dead code (#3119)
Three categories of cleanup, all zero-behavioral-change:
1. F-strings without placeholders (154 fixes across 29 files)
- Converted f'...' to '...' where no {expression} was present
- Heaviest files: run_agent.py (24), cli.py (20), honcho_integration/cli.py (34)
2. Simplify defensive patterns in run_agent.py
- Added explicit self._is_anthropic_oauth = False in __init__ (before
the api_mode branch that conditionally sets it)
- Replaced 7x getattr(self, '_is_anthropic_oauth', False) with direct
self._is_anthropic_oauth (attribute always initialized now)
- Added _is_openrouter_url() and _is_anthropic_url() helper methods
- Replaced 3 inline 'openrouter' in self._base_url_lower checks
3. Remove dead code in small files
- hermes_cli/claw.py: removed unused 'total' computation
- tools/fuzzy_match.py: removed unused strip_indent() function and
pattern_stripped variable
Full test suite: 6184 passed, 0 failures
E2E PTY: banner clean, tool calls work, zero garbled ANSI
2026-03-25 19:47:58 -07:00
|
|
|
title = cat.get("setup_title", "Choose a provider")
|
2026-03-08 23:15:14 -07:00
|
|
|
print(color(f" --- {icon} {name} - {title} ---", Colors.CYAN))
|
|
|
|
|
if cat.get("setup_note"):
|
|
|
|
|
_print_info(f" {cat['setup_note']}")
|
2026-03-06 18:11:35 -08:00
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
# Plain text labels only (no ANSI codes in menu items)
|
|
|
|
|
provider_choices = []
|
|
|
|
|
for p in providers:
|
2026-04-14 16:58:10 -07:00
|
|
|
badge = f" [{p['badge']}]" if p.get("badge") else ""
|
|
|
|
|
tag = f" — {p['tag']}" if p.get("tag") else ""
|
2026-03-06 18:11:35 -08:00
|
|
|
configured = ""
|
|
|
|
|
env_vars = p.get("env_vars", [])
|
|
|
|
|
if not env_vars or all(get_env_value(v["key"]) for v in env_vars):
|
2026-03-17 00:16:34 -07:00
|
|
|
if _is_provider_active(p, config):
|
2026-03-06 18:11:35 -08:00
|
|
|
configured = " [active]"
|
|
|
|
|
elif not env_vars:
|
2026-03-17 00:16:34 -07:00
|
|
|
configured = ""
|
2026-03-06 18:11:35 -08:00
|
|
|
else:
|
|
|
|
|
configured = " [configured]"
|
2026-04-14 16:58:10 -07:00
|
|
|
provider_choices.append(f"{p['name']}{badge}{tag}{configured}")
|
2026-03-06 18:11:35 -08:00
|
|
|
|
2026-03-08 23:15:14 -07:00
|
|
|
# Add skip option
|
|
|
|
|
provider_choices.append("Skip — keep defaults / configure later")
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
# Detect current provider as default
|
2026-03-17 00:16:34 -07:00
|
|
|
default_idx = _detect_active_provider_index(providers, config)
|
2026-03-06 18:11:35 -08:00
|
|
|
|
2026-03-08 23:15:14 -07:00
|
|
|
provider_idx = _prompt_choice(f" {title}:", provider_choices, default_idx)
|
|
|
|
|
|
|
|
|
|
# Skip selected
|
|
|
|
|
if provider_idx >= len(providers):
|
|
|
|
|
_print_info(f" Skipped {name}")
|
|
|
|
|
return
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
_configure_provider(providers[provider_idx], config)
|
2026-02-24 00:01:39 +00:00
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
|
2026-03-17 00:16:34 -07:00
|
|
|
def _is_provider_active(provider: dict, config: dict) -> bool:
|
|
|
|
|
"""Check if a provider entry matches the currently active config."""
|
2026-04-22 22:50:38 -06:00
|
|
|
plugin_name = provider.get("image_gen_plugin_name")
|
|
|
|
|
if plugin_name:
|
|
|
|
|
image_cfg = config.get("image_gen", {})
|
|
|
|
|
return isinstance(image_cfg, dict) and image_cfg.get("provider") == plugin_name
|
|
|
|
|
|
2026-03-26 15:27:27 -07:00
|
|
|
managed_feature = provider.get("managed_nous_feature")
|
|
|
|
|
if managed_feature:
|
|
|
|
|
features = get_nous_subscription_features(config)
|
|
|
|
|
feature = features.features.get(managed_feature)
|
|
|
|
|
if feature is None:
|
|
|
|
|
return False
|
|
|
|
|
if managed_feature == "image_gen":
|
2026-04-22 22:50:38 -06:00
|
|
|
image_cfg = config.get("image_gen", {})
|
|
|
|
|
if isinstance(image_cfg, dict):
|
|
|
|
|
configured_provider = image_cfg.get("provider")
|
|
|
|
|
if configured_provider not in (None, "", "fal"):
|
|
|
|
|
return False
|
|
|
|
|
if image_cfg.get("use_gateway") is False:
|
|
|
|
|
return False
|
2026-03-26 15:27:27 -07:00
|
|
|
return feature.managed_by_nous
|
|
|
|
|
if provider.get("tts_provider"):
|
|
|
|
|
return (
|
|
|
|
|
feature.managed_by_nous
|
|
|
|
|
and config.get("tts", {}).get("provider") == provider["tts_provider"]
|
|
|
|
|
)
|
|
|
|
|
if "browser_provider" in provider:
|
|
|
|
|
current = config.get("browser", {}).get("cloud_provider")
|
|
|
|
|
return feature.managed_by_nous and provider["browser_provider"] == current
|
|
|
|
|
if provider.get("web_backend"):
|
|
|
|
|
current = config.get("web", {}).get("backend")
|
|
|
|
|
return feature.managed_by_nous and current == provider["web_backend"]
|
|
|
|
|
return feature.managed_by_nous
|
|
|
|
|
|
2026-03-17 00:16:34 -07:00
|
|
|
if provider.get("tts_provider"):
|
|
|
|
|
return config.get("tts", {}).get("provider") == provider["tts_provider"]
|
|
|
|
|
if "browser_provider" in provider:
|
|
|
|
|
current = config.get("browser", {}).get("cloud_provider")
|
|
|
|
|
return provider["browser_provider"] == current
|
feat(web): add Parallel as alternative web search/extract backend (#1696)
* feat(web): add Parallel as alternative web search/extract backend
Adds Parallel (parallel.ai) as a drop-in alternative to Firecrawl for
web_search and web_extract tools using the official parallel-web SDK.
- Backend selection via WEB_SEARCH_BACKEND env var (auto/parallel/firecrawl)
- Auto mode prefers Firecrawl when both keys present; Parallel when sole backend
- web_crawl remains Firecrawl-only with clear error when unavailable
- Lazy SDK imports, interrupt support, singleton clients
- 16 new unit tests for backend selection and client config
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
* fix: add PARALLEL_API_KEY to config registry and fix web_crawl policy tests
Follow-up for Parallel backend integration:
- Add PARALLEL_API_KEY to OPTIONAL_ENV_VARS (hermes doctor, env blocklist)
- Add to set_config_value api_keys list (hermes config set)
- Add to doctor keys display
- Fix 2 web_crawl policy tests that didn't set FIRECRAWL_API_KEY
(needed now that web_crawl has a Firecrawl availability guard)
* refactor: explicit backend selection via hermes tools, not auto-detect
Replace the auto-detect backend selection with explicit user choice:
- hermes tools saves WEB_SEARCH_BACKEND to .env when user picks a provider
- _get_backend() reads the explicit choice first
- Fallback only for manual/legacy config (uses whichever key is present)
- _is_provider_active() shows [active] for the selected web backend
- Updated tests, docs, and .env.example to remove 'auto' mode language
* refactor: use config.yaml for web backend, not env var
Match the TTS/browser pattern — web.backend is stored in config.yaml
(set by hermes tools), not as a WEB_SEARCH_BACKEND env var.
- _load_web_config() reads web: section from config.yaml
- _get_backend() reads web.backend from config, falls back to key detection
- _configure_provider() saves to config dict (saved to config.yaml)
- _is_provider_active() reads from config dict
- Removed WEB_SEARCH_BACKEND from .env.example, set_config_value, docs
- Updated all tests to mock _load_web_config instead of env vars
---------
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
2026-03-17 04:02:02 -07:00
|
|
|
if provider.get("web_backend"):
|
|
|
|
|
current = config.get("web", {}).get("backend")
|
|
|
|
|
return current == provider["web_backend"]
|
2026-04-22 22:50:38 -06:00
|
|
|
if provider.get("imagegen_backend"):
|
|
|
|
|
image_cfg = config.get("image_gen", {})
|
|
|
|
|
if not isinstance(image_cfg, dict):
|
|
|
|
|
return False
|
|
|
|
|
configured_provider = image_cfg.get("provider")
|
|
|
|
|
return (
|
|
|
|
|
provider["imagegen_backend"] == "fal"
|
|
|
|
|
and configured_provider in (None, "", "fal")
|
|
|
|
|
and not image_cfg.get("use_gateway")
|
|
|
|
|
)
|
2026-03-17 00:16:34 -07:00
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _detect_active_provider_index(providers: list, config: dict) -> int:
|
|
|
|
|
"""Return the index of the currently active provider, or 0."""
|
|
|
|
|
for i, p in enumerate(providers):
|
|
|
|
|
if _is_provider_active(p, config):
|
|
|
|
|
return i
|
|
|
|
|
# Fallback: env vars present → likely configured
|
|
|
|
|
env_vars = p.get("env_vars", [])
|
|
|
|
|
if env_vars and all(get_env_value(v["key"]) for v in env_vars):
|
|
|
|
|
return i
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
feat(image_gen): multi-model FAL support with picker in hermes tools (#11265)
* feat(image_gen): multi-model FAL support with picker in hermes tools
Adds 8 FAL text-to-image models selectable via `hermes tools` →
Image Generation → (FAL.ai | Nous Subscription) → model picker.
Models supported:
- fal-ai/flux-2/klein/9b (new default, <1s, $0.006/MP)
- fal-ai/flux-2-pro (previous default, kept backward-compat upscaling)
- fal-ai/z-image/turbo (Tongyi-MAI, bilingual EN/CN)
- fal-ai/nano-banana (Gemini 2.5 Flash Image)
- fal-ai/gpt-image-1.5 (with quality tier: low/medium/high)
- fal-ai/ideogram/v3 (best typography)
- fal-ai/recraft-v3 (vector, brand styles)
- fal-ai/qwen-image (LLM-based)
Architecture:
- FAL_MODELS catalog declares per-model size family, defaults, supports
whitelist, and upscale flag. Three size families handled uniformly:
image_size_preset (flux family), aspect_ratio (nano-banana), and
gpt_literal (gpt-image-1.5).
- _build_fal_payload() translates unified inputs (prompt + aspect_ratio)
into model-specific payloads, merges defaults, applies caller overrides,
wires GPT quality_setting, then filters to the supports whitelist — so
models never receive rejected keys.
- IMAGEGEN_BACKENDS registry in tools_config prepares for future imagegen
providers (Replicate, Stability, etc.); each provider entry tags itself
with imagegen_backend: 'fal' to select the right catalog.
- Upscaler (Clarity) defaults off for new models (preserves <1s value
prop), on for flux-2-pro (backward-compat). Per-model via FAL_MODELS.
Config:
image_gen.model = fal-ai/flux-2/klein/9b (new)
image_gen.quality_setting = medium (new, GPT only)
image_gen.use_gateway = bool (existing)
Agent-facing schema unchanged (prompt + aspect_ratio only) — model
choice is a user-level config decision, not an agent-level arg.
Picker uses curses_radiolist (arrow keys, auto numbered-fallback on
non-TTY). Column-aligned: Model / Speed / Strengths / Price.
Docs: image-generation.md rewritten with the model table and picker
walkthrough. tools-reference, tool-gateway, overview updated to drop
the stale "FLUX 2 Pro" wording.
Tests: 42 new in tests/tools/test_image_generation.py covering catalog
integrity, all 3 size families, supports filter, default merging, GPT
quality wiring, model resolution fallback. 8 new in
tests/hermes_cli/test_tools_config.py for picker wiring (registry,
config writes, GPT quality follow-up prompt, corrupt-config repair).
* feat(image_gen): translate managed-gateway 4xx to actionable error
When the Nous Subscription managed FAL proxy rejects a model with 4xx
(likely portal-side allowlist miss or billing gate), surface a clear
message explaining:
1. The rejected model ID + HTTP status
2. Two remediation paths: set FAL_KEY for direct access, or
pick a different model via `hermes tools`
5xx, connection errors, and direct-FAL errors pass through unchanged
(those have different root causes and reasonable native messages).
Motivation: new FAL models added to this release (flux-2-klein-9b,
z-image-turbo, nano-banana, gpt-image-1.5, ideogram-v3, recraft-v3,
qwen-image) are untested against the Nous Portal proxy. If the portal
allowlists model IDs, users on Nous Subscription will hit cryptic
4xx errors without guidance on how to work around it.
Tests: 8 new cases covering status extraction across httpx/fal error
shapes and 4xx-vs-5xx-vs-ConnectionError translation policy.
Docs: brief note in image-generation.md for Nous subscribers.
Operator action (Nous Portal side): verify that fal-queue-gateway
passes through these 7 new FAL model IDs. If the proxy has an
allowlist, add them; otherwise Nous Subscription users will see the
new translated error and fall back to direct FAL.
* feat(image_gen): pin GPT-Image quality to medium (no user choice)
Previously the tools picker asked a follow-up question for GPT-Image
quality tier (low / medium / high) and persisted the answer to
`image_gen.quality_setting`. This created two problems:
1. Nous Portal billing complexity — the 22x cost spread between tiers
($0.009 low / $0.20 high) forces the gateway to meter per-tier per
user, which the portal team can't easily support at launch.
2. User footgun — anyone picking `high` by mistake burns through
credit ~6x faster than `medium`.
This commit pins quality at medium by baking it into FAL_MODELS
defaults for gpt-image-1.5 and removes all user-facing override paths:
- Removed `_resolve_gpt_quality()` runtime lookup
- Removed `honors_quality_setting` flag on the model entry
- Removed `_configure_gpt_quality_setting()` picker helper
- Removed `_GPT_QUALITY_CHOICES` constant
- Removed the follow-up prompt call in `_configure_imagegen_model()`
- Even if a user manually edits `image_gen.quality_setting` in
config.yaml, no code path reads it — always sends medium.
Tests:
- Replaced TestGptQualitySetting (6 tests) with TestGptQualityPinnedToMedium
(5 tests) — proves medium is baked in, config is ignored, flag is
removed, helper is removed, non-gpt models never get quality.
- Replaced test_picker_with_gpt_image_also_prompts_quality with
test_picker_with_gpt_image_does_not_prompt_quality — proves only 1
picker call fires when gpt-image is selected (no quality follow-up).
Docs updated: image-generation.md replaces the quality-tier table
with a short note explaining the pinning decision.
* docs(image_gen): drop stale 'wires GPT quality tier' line from internals section
Caught in a cleanup sweep after pinning quality to medium. The
"How It Works Internally" walkthrough still described the removed
quality-wiring step.
2026-04-16 20:19:53 -07:00
|
|
|
# ─── Image Generation Model Pickers ───────────────────────────────────────────
|
|
|
|
|
#
|
|
|
|
|
# IMAGEGEN_BACKENDS is a per-backend catalog. Each entry exposes:
|
|
|
|
|
# - config_key: top-level config.yaml key for this backend's settings
|
|
|
|
|
# - model_catalog_fn: returns an OrderedDict-like {model_id: metadata}
|
|
|
|
|
# - default_model: fallback when nothing is configured
|
|
|
|
|
#
|
|
|
|
|
# This prepares for future imagegen backends (Replicate, Stability, etc.):
|
|
|
|
|
# each new backend registers its own entry; the FAL provider entry in
|
|
|
|
|
# TOOL_CATEGORIES tags itself with `imagegen_backend: "fal"` to select the
|
|
|
|
|
# right catalog at picker time.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _fal_model_catalog():
|
|
|
|
|
"""Lazy-load the FAL model catalog from the tool module."""
|
|
|
|
|
from tools.image_generation_tool import FAL_MODELS, DEFAULT_MODEL
|
|
|
|
|
return FAL_MODELS, DEFAULT_MODEL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMAGEGEN_BACKENDS = {
|
|
|
|
|
"fal": {
|
|
|
|
|
"display": "FAL.ai",
|
|
|
|
|
"config_key": "image_gen",
|
|
|
|
|
"catalog_fn": _fal_model_catalog,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _format_imagegen_model_row(model_id: str, meta: dict, widths: dict) -> str:
|
|
|
|
|
"""Format a single picker row with column-aligned speed / strengths / price."""
|
|
|
|
|
return (
|
|
|
|
|
f"{model_id:<{widths['model']}} "
|
|
|
|
|
f"{meta.get('speed', ''):<{widths['speed']}} "
|
|
|
|
|
f"{meta.get('strengths', ''):<{widths['strengths']}} "
|
|
|
|
|
f"{meta.get('price', '')}"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _configure_imagegen_model(backend_name: str, config: dict) -> None:
|
|
|
|
|
"""Prompt the user to pick a model for the given imagegen backend.
|
|
|
|
|
|
|
|
|
|
Writes selection to ``config[backend_config_key]["model"]``. Safe to
|
|
|
|
|
call even when stdin is not a TTY — curses_radiolist falls back to
|
|
|
|
|
keeping the current selection.
|
|
|
|
|
"""
|
|
|
|
|
backend = IMAGEGEN_BACKENDS.get(backend_name)
|
|
|
|
|
if not backend:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
catalog, default_model = backend["catalog_fn"]()
|
|
|
|
|
if not catalog:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
cfg_key = backend["config_key"]
|
|
|
|
|
cur_cfg = config.setdefault(cfg_key, {})
|
|
|
|
|
if not isinstance(cur_cfg, dict):
|
|
|
|
|
cur_cfg = {}
|
|
|
|
|
config[cfg_key] = cur_cfg
|
|
|
|
|
current_model = cur_cfg.get("model") or default_model
|
|
|
|
|
if current_model not in catalog:
|
|
|
|
|
current_model = default_model
|
|
|
|
|
|
|
|
|
|
model_ids = list(catalog.keys())
|
|
|
|
|
# Put current model at the top so the cursor lands on it by default.
|
|
|
|
|
ordered = [current_model] + [m for m in model_ids if m != current_model]
|
|
|
|
|
|
|
|
|
|
# Column widths
|
|
|
|
|
widths = {
|
|
|
|
|
"model": max(len(m) for m in model_ids),
|
|
|
|
|
"speed": max((len(catalog[m].get("speed", "")) for m in model_ids), default=6),
|
|
|
|
|
"strengths": max((len(catalog[m].get("strengths", "")) for m in model_ids), default=0),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
header = (
|
|
|
|
|
f" {'Model':<{widths['model']}} "
|
|
|
|
|
f"{'Speed':<{widths['speed']}} "
|
|
|
|
|
f"{'Strengths':<{widths['strengths']}} "
|
|
|
|
|
f"Price"
|
|
|
|
|
)
|
|
|
|
|
print(color(header, Colors.CYAN))
|
|
|
|
|
|
|
|
|
|
rows = []
|
|
|
|
|
for mid in ordered:
|
|
|
|
|
row = _format_imagegen_model_row(mid, catalog[mid], widths)
|
|
|
|
|
if mid == current_model:
|
|
|
|
|
row += " ← currently in use"
|
|
|
|
|
rows.append(row)
|
|
|
|
|
|
|
|
|
|
idx = _prompt_choice(
|
|
|
|
|
f" Choose {backend['display']} model:",
|
|
|
|
|
rows,
|
|
|
|
|
default=0,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
chosen = ordered[idx]
|
|
|
|
|
cur_cfg["model"] = chosen
|
|
|
|
|
_print_success(f" Model set to: {chosen}")
|
|
|
|
|
|
|
|
|
|
|
feat(plugins): pluggable image_gen backends + OpenAI provider (#13799)
* feat(plugins): pluggable image_gen backends + OpenAI provider
Adds a ImageGenProvider ABC so image generation backends register as
bundled plugins under `plugins/image_gen/<name>/`. The plugin scanner
gains three primitives to make this work generically:
- `kind:` manifest field (`standalone` | `backend` | `exclusive`).
Bundled `kind: backend` plugins auto-load — no `plugins.enabled`
incantation. User-installed backends stay opt-in.
- Path-derived keys: `plugins/image_gen/openai/` gets key
`image_gen/openai`, so a future `tts/openai` cannot collide.
- Depth-2 recursion into category namespaces (parent dirs without a
`plugin.yaml` of their own).
Includes `OpenAIImageGenProvider` as the first consumer (gpt-image-1.5
default, plus gpt-image-1, gpt-image-1-mini, DALL-E 3/2). Base64
responses save to `$HERMES_HOME/cache/images/`; URL responses pass
through.
FAL stays in-tree for this PR — a follow-up ports it into
`plugins/image_gen/fal/` so the in-tree `image_generation_tool.py`
slims down. The dispatch shim in `_handle_image_generate` only fires
when `image_gen.provider` is explicitly set to a non-FAL value, so
existing FAL setups are untouched.
- 41 unit tests (scanner recursion, kind parsing, gate logic,
registry, OpenAI payload shapes)
- E2E smoke verified: bundled plugin autoloads, registers, and
`_handle_image_generate` routes to OpenAI when configured
* fix(image_gen/openai): don't send response_format to gpt-image-*
The live API rejects it: 'Unknown parameter: response_format'
(verified 2026-04-21 with gpt-image-1.5). gpt-image-* models return
b64_json unconditionally, so the parameter was both unnecessary and
actively broken.
* feat(image_gen/openai): gpt-image-2 only, drop legacy catalog
gpt-image-2 is the latest/best OpenAI image model (released 2026-04-21)
and there's no reason to expose the older gpt-image-1.5 / gpt-image-1 /
dall-e-3 / dall-e-2 alongside it — slower, lower quality, or awkward
(dall-e-2 squares only). Trim the catalog down to a single model.
Live-verified end-to-end: landscape 1536x1024 render of a Moog-style
synth matches prompt exactly, 2.4MB PNG saved to cache.
* feat(image_gen/openai): expose gpt-image-2 as three quality tiers
Users pick speed/fidelity via the normal model picker instead of a
hidden quality knob. All three tier IDs resolve to the single underlying
gpt-image-2 API model with a different quality parameter:
gpt-image-2-low ~15s fast iteration
gpt-image-2-medium ~40s default
gpt-image-2-high ~2min highest fidelity
Live-measured on OpenAI's API today: 15.4s / 40.8s / 116.9s for the
same 1024x1024 prompt.
Config:
image_gen.openai.model: gpt-image-2-high
# or
image_gen.model: gpt-image-2-low
# or env var for scripts/tests
OPENAI_IMAGE_MODEL=gpt-image-2-medium
Live-verified end-to-end with the low tier: 18.8s landscape render of a
golden retriever in wildflowers, vision-confirmed exact match.
* feat(tools_config): plugin image_gen providers inject themselves into picker
'hermes tools' → Image Generation now shows plugin-registered backends
alongside Nous Subscription and FAL.ai without tools_config.py needing
to know about them. OpenAI appears as a third option today; future
backends appear automatically as they're added.
Mechanism:
- ImageGenProvider gains an optional get_setup_schema() hook
(name, badge, tag, env_vars). Default derived from display_name.
- tools_config._plugin_image_gen_providers() pulls the schemas from
every registered non-FAL plugin provider.
- _visible_providers() appends those rows when rendering the Image
Generation category.
- _configure_provider() handles the new image_gen_plugin_name marker:
writes image_gen.provider and routes to the plugin's list_models()
catalog for the model picker.
- _toolset_needs_configuration_prompt('image_gen') stops demanding a
FAL key when any plugin provider reports is_available().
FAL is skipped in the plugin path because it already has hardcoded
TOOL_CATEGORIES rows — when it gets ported to a plugin in a follow-up
PR the hardcoded rows go away and it surfaces through the same path
as OpenAI.
Verified live: picker shows Nous Subscription / FAL.ai / OpenAI.
Picking OpenAI prompts for OPENAI_API_KEY, then shows the
gpt-image-2-low/medium/high model picker sourced from the plugin.
397 tests pass across plugins/, tools_config, registry, and picker.
* fix(image_gen): close final gaps for plugin-backend parity with FAL
Two small places that still hardcoded FAL:
- hermes_cli/setup.py status line: an OpenAI-only setup showed
'Image Generation: missing FAL_KEY'. Now probes plugin providers
and reports '(OpenAI)' when one is_available() — or falls back to
'missing FAL_KEY or OPENAI_API_KEY' if nothing is configured.
- image_generate tool schema description: said 'using FAL.ai, default
FLUX 2 Klein 9B'. Rewrote provider-neutral — 'backend and model are
user-configured' — and notes the 'image' field can be a URL or an
absolute path, which the gateway delivers either way via
extract_local_files().
2026-04-21 21:30:10 -07:00
|
|
|
def _plugin_image_gen_catalog(plugin_name: str):
|
|
|
|
|
"""Return ``(catalog_dict, default_model_id)`` for a plugin provider.
|
|
|
|
|
|
|
|
|
|
``catalog_dict`` is shaped like the legacy ``FAL_MODELS`` table —
|
|
|
|
|
``{model_id: {"display", "speed", "strengths", "price", ...}}`` —
|
|
|
|
|
so the existing picker code paths work without change. Returns
|
|
|
|
|
``({}, None)`` if the provider isn't registered or has no models.
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
from agent.image_gen_registry import get_provider
|
|
|
|
|
from hermes_cli.plugins import _ensure_plugins_discovered
|
|
|
|
|
|
|
|
|
|
_ensure_plugins_discovered()
|
|
|
|
|
provider = get_provider(plugin_name)
|
|
|
|
|
except Exception:
|
|
|
|
|
return {}, None
|
|
|
|
|
if provider is None:
|
|
|
|
|
return {}, None
|
|
|
|
|
try:
|
|
|
|
|
models = provider.list_models() or []
|
|
|
|
|
default = provider.default_model()
|
|
|
|
|
except Exception:
|
|
|
|
|
return {}, None
|
|
|
|
|
catalog = {m["id"]: m for m in models if isinstance(m, dict) and "id" in m}
|
|
|
|
|
return catalog, default
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _configure_imagegen_model_for_plugin(plugin_name: str, config: dict) -> None:
|
|
|
|
|
"""Prompt the user to pick a model for a plugin-registered backend.
|
|
|
|
|
|
|
|
|
|
Writes selection to ``image_gen.model``. Mirrors
|
|
|
|
|
:func:`_configure_imagegen_model` but sources its catalog from the
|
|
|
|
|
plugin registry instead of :data:`IMAGEGEN_BACKENDS`.
|
|
|
|
|
"""
|
|
|
|
|
catalog, default_model = _plugin_image_gen_catalog(plugin_name)
|
|
|
|
|
if not catalog:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
cur_cfg = config.setdefault("image_gen", {})
|
|
|
|
|
if not isinstance(cur_cfg, dict):
|
|
|
|
|
cur_cfg = {}
|
|
|
|
|
config["image_gen"] = cur_cfg
|
|
|
|
|
current_model = cur_cfg.get("model") or default_model
|
|
|
|
|
if current_model not in catalog:
|
|
|
|
|
current_model = default_model
|
|
|
|
|
|
|
|
|
|
model_ids = list(catalog.keys())
|
|
|
|
|
ordered = [current_model] + [m for m in model_ids if m != current_model]
|
|
|
|
|
|
|
|
|
|
widths = {
|
|
|
|
|
"model": max(len(m) for m in model_ids),
|
|
|
|
|
"speed": max((len(catalog[m].get("speed", "")) for m in model_ids), default=6),
|
|
|
|
|
"strengths": max((len(catalog[m].get("strengths", "")) for m in model_ids), default=0),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
header = (
|
|
|
|
|
f" {'Model':<{widths['model']}} "
|
|
|
|
|
f"{'Speed':<{widths['speed']}} "
|
|
|
|
|
f"{'Strengths':<{widths['strengths']}} "
|
|
|
|
|
f"Price"
|
|
|
|
|
)
|
|
|
|
|
print(color(header, Colors.CYAN))
|
|
|
|
|
|
|
|
|
|
rows = []
|
|
|
|
|
for mid in ordered:
|
|
|
|
|
row = _format_imagegen_model_row(mid, catalog[mid], widths)
|
|
|
|
|
if mid == current_model:
|
|
|
|
|
row += " ← currently in use"
|
|
|
|
|
rows.append(row)
|
|
|
|
|
|
|
|
|
|
idx = _prompt_choice(
|
|
|
|
|
f" Choose {plugin_name} model:",
|
|
|
|
|
rows,
|
|
|
|
|
default=0,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
chosen = ordered[idx]
|
|
|
|
|
cur_cfg["model"] = chosen
|
|
|
|
|
_print_success(f" Model set to: {chosen}")
|
|
|
|
|
|
|
|
|
|
|
2026-04-22 22:50:38 -06:00
|
|
|
def _select_plugin_image_gen_provider(plugin_name: str, config: dict) -> None:
|
|
|
|
|
"""Persist a plugin-backed image generation provider selection."""
|
|
|
|
|
img_cfg = config.setdefault("image_gen", {})
|
|
|
|
|
if not isinstance(img_cfg, dict):
|
|
|
|
|
img_cfg = {}
|
|
|
|
|
config["image_gen"] = img_cfg
|
|
|
|
|
img_cfg["provider"] = plugin_name
|
|
|
|
|
img_cfg["use_gateway"] = False
|
|
|
|
|
_print_success(f" image_gen.provider set to: {plugin_name}")
|
|
|
|
|
_configure_imagegen_model_for_plugin(plugin_name, config)
|
|
|
|
|
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
def _configure_provider(provider: dict, config: dict):
|
|
|
|
|
"""Configure a single provider - prompt for API keys and set config."""
|
|
|
|
|
env_vars = provider.get("env_vars", [])
|
2026-03-26 15:27:27 -07:00
|
|
|
managed_feature = provider.get("managed_nous_feature")
|
|
|
|
|
|
|
|
|
|
if provider.get("requires_nous_auth"):
|
|
|
|
|
features = get_nous_subscription_features(config)
|
|
|
|
|
if not features.nous_auth_present:
|
|
|
|
|
_print_warning(" Nous Subscription is only available after logging into Nous Portal.")
|
|
|
|
|
return
|
2026-03-06 18:11:35 -08:00
|
|
|
|
|
|
|
|
# Set TTS provider in config if applicable
|
|
|
|
|
if provider.get("tts_provider"):
|
feat: ungate Tool Gateway — subscription-based access with per-tool opt-in
Replace the HERMES_ENABLE_NOUS_MANAGED_TOOLS env-var feature flag with
subscription-based detection. The Tool Gateway is now available to any
paid Nous subscriber without needing a hidden env var.
Core changes:
- managed_nous_tools_enabled() checks get_nous_auth_status() +
check_nous_free_tier() instead of an env var
- New use_gateway config flag per tool section (web, tts, browser,
image_gen) records explicit user opt-in and overrides direct API
keys at runtime
- New prefers_gateway(section) shared helper in tool_backend_helpers.py
used by all 4 tool runtimes (web, tts, image gen, browser)
UX flow:
- hermes model: after Nous login/model selection, shows a curses
prompt listing all gateway-eligible tools with current status.
User chooses to enable all, enable only unconfigured tools, or skip.
Defaults to Enable for new users, Skip when direct keys exist.
- hermes tools: provider selection now manages use_gateway flag —
selecting Nous Subscription sets it, selecting any other provider
clears it
- hermes status: renamed section to Nous Tool Gateway, added
free-tier upgrade nudge for logged-in free users
- curses_radiolist: new description parameter for multi-line context
that survives the screen clear
Runtime behavior:
- Each tool runtime (web_tools, tts_tool, image_generation_tool,
browser_use) checks prefers_gateway() before falling back to
direct env-var credentials
- get_nous_subscription_features() respects use_gateway flags,
suppressing direct credential detection when the user opted in
Removed:
- HERMES_ENABLE_NOUS_MANAGED_TOOLS env var and all references
- apply_nous_provider_defaults() silent TTS auto-set
- get_nous_subscription_explainer_lines() static text
- Override env var warnings (use_gateway handles this properly now)
2026-04-16 01:59:51 -04:00
|
|
|
tts_cfg = config.setdefault("tts", {})
|
|
|
|
|
tts_cfg["provider"] = provider["tts_provider"]
|
|
|
|
|
tts_cfg["use_gateway"] = bool(managed_feature)
|
2026-03-06 18:11:35 -08:00
|
|
|
|
2026-03-17 00:16:34 -07:00
|
|
|
# Set browser cloud provider in config if applicable
|
|
|
|
|
if "browser_provider" in provider:
|
|
|
|
|
bp = provider["browser_provider"]
|
feat: ungate Tool Gateway — subscription-based access with per-tool opt-in
Replace the HERMES_ENABLE_NOUS_MANAGED_TOOLS env-var feature flag with
subscription-based detection. The Tool Gateway is now available to any
paid Nous subscriber without needing a hidden env var.
Core changes:
- managed_nous_tools_enabled() checks get_nous_auth_status() +
check_nous_free_tier() instead of an env var
- New use_gateway config flag per tool section (web, tts, browser,
image_gen) records explicit user opt-in and overrides direct API
keys at runtime
- New prefers_gateway(section) shared helper in tool_backend_helpers.py
used by all 4 tool runtimes (web, tts, image gen, browser)
UX flow:
- hermes model: after Nous login/model selection, shows a curses
prompt listing all gateway-eligible tools with current status.
User chooses to enable all, enable only unconfigured tools, or skip.
Defaults to Enable for new users, Skip when direct keys exist.
- hermes tools: provider selection now manages use_gateway flag —
selecting Nous Subscription sets it, selecting any other provider
clears it
- hermes status: renamed section to Nous Tool Gateway, added
free-tier upgrade nudge for logged-in free users
- curses_radiolist: new description parameter for multi-line context
that survives the screen clear
Runtime behavior:
- Each tool runtime (web_tools, tts_tool, image_generation_tool,
browser_use) checks prefers_gateway() before falling back to
direct env-var credentials
- get_nous_subscription_features() respects use_gateway flags,
suppressing direct credential detection when the user opted in
Removed:
- HERMES_ENABLE_NOUS_MANAGED_TOOLS env var and all references
- apply_nous_provider_defaults() silent TTS auto-set
- get_nous_subscription_explainer_lines() static text
- Override env var warnings (use_gateway handles this properly now)
2026-04-16 01:59:51 -04:00
|
|
|
browser_cfg = config.setdefault("browser", {})
|
2026-03-26 15:27:27 -07:00
|
|
|
if bp == "local":
|
feat: ungate Tool Gateway — subscription-based access with per-tool opt-in
Replace the HERMES_ENABLE_NOUS_MANAGED_TOOLS env-var feature flag with
subscription-based detection. The Tool Gateway is now available to any
paid Nous subscriber without needing a hidden env var.
Core changes:
- managed_nous_tools_enabled() checks get_nous_auth_status() +
check_nous_free_tier() instead of an env var
- New use_gateway config flag per tool section (web, tts, browser,
image_gen) records explicit user opt-in and overrides direct API
keys at runtime
- New prefers_gateway(section) shared helper in tool_backend_helpers.py
used by all 4 tool runtimes (web, tts, image gen, browser)
UX flow:
- hermes model: after Nous login/model selection, shows a curses
prompt listing all gateway-eligible tools with current status.
User chooses to enable all, enable only unconfigured tools, or skip.
Defaults to Enable for new users, Skip when direct keys exist.
- hermes tools: provider selection now manages use_gateway flag —
selecting Nous Subscription sets it, selecting any other provider
clears it
- hermes status: renamed section to Nous Tool Gateway, added
free-tier upgrade nudge for logged-in free users
- curses_radiolist: new description parameter for multi-line context
that survives the screen clear
Runtime behavior:
- Each tool runtime (web_tools, tts_tool, image_generation_tool,
browser_use) checks prefers_gateway() before falling back to
direct env-var credentials
- get_nous_subscription_features() respects use_gateway flags,
suppressing direct credential detection when the user opted in
Removed:
- HERMES_ENABLE_NOUS_MANAGED_TOOLS env var and all references
- apply_nous_provider_defaults() silent TTS auto-set
- get_nous_subscription_explainer_lines() static text
- Override env var warnings (use_gateway handles this properly now)
2026-04-16 01:59:51 -04:00
|
|
|
browser_cfg["cloud_provider"] = "local"
|
2026-03-26 15:27:27 -07:00
|
|
|
_print_success(" Browser set to local mode")
|
|
|
|
|
elif bp:
|
feat: ungate Tool Gateway — subscription-based access with per-tool opt-in
Replace the HERMES_ENABLE_NOUS_MANAGED_TOOLS env-var feature flag with
subscription-based detection. The Tool Gateway is now available to any
paid Nous subscriber without needing a hidden env var.
Core changes:
- managed_nous_tools_enabled() checks get_nous_auth_status() +
check_nous_free_tier() instead of an env var
- New use_gateway config flag per tool section (web, tts, browser,
image_gen) records explicit user opt-in and overrides direct API
keys at runtime
- New prefers_gateway(section) shared helper in tool_backend_helpers.py
used by all 4 tool runtimes (web, tts, image gen, browser)
UX flow:
- hermes model: after Nous login/model selection, shows a curses
prompt listing all gateway-eligible tools with current status.
User chooses to enable all, enable only unconfigured tools, or skip.
Defaults to Enable for new users, Skip when direct keys exist.
- hermes tools: provider selection now manages use_gateway flag —
selecting Nous Subscription sets it, selecting any other provider
clears it
- hermes status: renamed section to Nous Tool Gateway, added
free-tier upgrade nudge for logged-in free users
- curses_radiolist: new description parameter for multi-line context
that survives the screen clear
Runtime behavior:
- Each tool runtime (web_tools, tts_tool, image_generation_tool,
browser_use) checks prefers_gateway() before falling back to
direct env-var credentials
- get_nous_subscription_features() respects use_gateway flags,
suppressing direct credential detection when the user opted in
Removed:
- HERMES_ENABLE_NOUS_MANAGED_TOOLS env var and all references
- apply_nous_provider_defaults() silent TTS auto-set
- get_nous_subscription_explainer_lines() static text
- Override env var warnings (use_gateway handles this properly now)
2026-04-16 01:59:51 -04:00
|
|
|
browser_cfg["cloud_provider"] = bp
|
2026-03-17 00:16:34 -07:00
|
|
|
_print_success(f" Browser cloud provider set to: {bp}")
|
feat: ungate Tool Gateway — subscription-based access with per-tool opt-in
Replace the HERMES_ENABLE_NOUS_MANAGED_TOOLS env-var feature flag with
subscription-based detection. The Tool Gateway is now available to any
paid Nous subscriber without needing a hidden env var.
Core changes:
- managed_nous_tools_enabled() checks get_nous_auth_status() +
check_nous_free_tier() instead of an env var
- New use_gateway config flag per tool section (web, tts, browser,
image_gen) records explicit user opt-in and overrides direct API
keys at runtime
- New prefers_gateway(section) shared helper in tool_backend_helpers.py
used by all 4 tool runtimes (web, tts, image gen, browser)
UX flow:
- hermes model: after Nous login/model selection, shows a curses
prompt listing all gateway-eligible tools with current status.
User chooses to enable all, enable only unconfigured tools, or skip.
Defaults to Enable for new users, Skip when direct keys exist.
- hermes tools: provider selection now manages use_gateway flag —
selecting Nous Subscription sets it, selecting any other provider
clears it
- hermes status: renamed section to Nous Tool Gateway, added
free-tier upgrade nudge for logged-in free users
- curses_radiolist: new description parameter for multi-line context
that survives the screen clear
Runtime behavior:
- Each tool runtime (web_tools, tts_tool, image_generation_tool,
browser_use) checks prefers_gateway() before falling back to
direct env-var credentials
- get_nous_subscription_features() respects use_gateway flags,
suppressing direct credential detection when the user opted in
Removed:
- HERMES_ENABLE_NOUS_MANAGED_TOOLS env var and all references
- apply_nous_provider_defaults() silent TTS auto-set
- get_nous_subscription_explainer_lines() static text
- Override env var warnings (use_gateway handles this properly now)
2026-04-16 01:59:51 -04:00
|
|
|
browser_cfg["use_gateway"] = bool(managed_feature)
|
2026-03-17 00:16:34 -07:00
|
|
|
|
feat(web): add Parallel as alternative web search/extract backend (#1696)
* feat(web): add Parallel as alternative web search/extract backend
Adds Parallel (parallel.ai) as a drop-in alternative to Firecrawl for
web_search and web_extract tools using the official parallel-web SDK.
- Backend selection via WEB_SEARCH_BACKEND env var (auto/parallel/firecrawl)
- Auto mode prefers Firecrawl when both keys present; Parallel when sole backend
- web_crawl remains Firecrawl-only with clear error when unavailable
- Lazy SDK imports, interrupt support, singleton clients
- 16 new unit tests for backend selection and client config
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
* fix: add PARALLEL_API_KEY to config registry and fix web_crawl policy tests
Follow-up for Parallel backend integration:
- Add PARALLEL_API_KEY to OPTIONAL_ENV_VARS (hermes doctor, env blocklist)
- Add to set_config_value api_keys list (hermes config set)
- Add to doctor keys display
- Fix 2 web_crawl policy tests that didn't set FIRECRAWL_API_KEY
(needed now that web_crawl has a Firecrawl availability guard)
* refactor: explicit backend selection via hermes tools, not auto-detect
Replace the auto-detect backend selection with explicit user choice:
- hermes tools saves WEB_SEARCH_BACKEND to .env when user picks a provider
- _get_backend() reads the explicit choice first
- Fallback only for manual/legacy config (uses whichever key is present)
- _is_provider_active() shows [active] for the selected web backend
- Updated tests, docs, and .env.example to remove 'auto' mode language
* refactor: use config.yaml for web backend, not env var
Match the TTS/browser pattern — web.backend is stored in config.yaml
(set by hermes tools), not as a WEB_SEARCH_BACKEND env var.
- _load_web_config() reads web: section from config.yaml
- _get_backend() reads web.backend from config, falls back to key detection
- _configure_provider() saves to config dict (saved to config.yaml)
- _is_provider_active() reads from config dict
- Removed WEB_SEARCH_BACKEND from .env.example, set_config_value, docs
- Updated all tests to mock _load_web_config instead of env vars
---------
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
2026-03-17 04:02:02 -07:00
|
|
|
# Set web search backend in config if applicable
|
|
|
|
|
if provider.get("web_backend"):
|
feat: ungate Tool Gateway — subscription-based access with per-tool opt-in
Replace the HERMES_ENABLE_NOUS_MANAGED_TOOLS env-var feature flag with
subscription-based detection. The Tool Gateway is now available to any
paid Nous subscriber without needing a hidden env var.
Core changes:
- managed_nous_tools_enabled() checks get_nous_auth_status() +
check_nous_free_tier() instead of an env var
- New use_gateway config flag per tool section (web, tts, browser,
image_gen) records explicit user opt-in and overrides direct API
keys at runtime
- New prefers_gateway(section) shared helper in tool_backend_helpers.py
used by all 4 tool runtimes (web, tts, image gen, browser)
UX flow:
- hermes model: after Nous login/model selection, shows a curses
prompt listing all gateway-eligible tools with current status.
User chooses to enable all, enable only unconfigured tools, or skip.
Defaults to Enable for new users, Skip when direct keys exist.
- hermes tools: provider selection now manages use_gateway flag —
selecting Nous Subscription sets it, selecting any other provider
clears it
- hermes status: renamed section to Nous Tool Gateway, added
free-tier upgrade nudge for logged-in free users
- curses_radiolist: new description parameter for multi-line context
that survives the screen clear
Runtime behavior:
- Each tool runtime (web_tools, tts_tool, image_generation_tool,
browser_use) checks prefers_gateway() before falling back to
direct env-var credentials
- get_nous_subscription_features() respects use_gateway flags,
suppressing direct credential detection when the user opted in
Removed:
- HERMES_ENABLE_NOUS_MANAGED_TOOLS env var and all references
- apply_nous_provider_defaults() silent TTS auto-set
- get_nous_subscription_explainer_lines() static text
- Override env var warnings (use_gateway handles this properly now)
2026-04-16 01:59:51 -04:00
|
|
|
web_cfg = config.setdefault("web", {})
|
|
|
|
|
web_cfg["backend"] = provider["web_backend"]
|
|
|
|
|
web_cfg["use_gateway"] = bool(managed_feature)
|
feat(web): add Parallel as alternative web search/extract backend (#1696)
* feat(web): add Parallel as alternative web search/extract backend
Adds Parallel (parallel.ai) as a drop-in alternative to Firecrawl for
web_search and web_extract tools using the official parallel-web SDK.
- Backend selection via WEB_SEARCH_BACKEND env var (auto/parallel/firecrawl)
- Auto mode prefers Firecrawl when both keys present; Parallel when sole backend
- web_crawl remains Firecrawl-only with clear error when unavailable
- Lazy SDK imports, interrupt support, singleton clients
- 16 new unit tests for backend selection and client config
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
* fix: add PARALLEL_API_KEY to config registry and fix web_crawl policy tests
Follow-up for Parallel backend integration:
- Add PARALLEL_API_KEY to OPTIONAL_ENV_VARS (hermes doctor, env blocklist)
- Add to set_config_value api_keys list (hermes config set)
- Add to doctor keys display
- Fix 2 web_crawl policy tests that didn't set FIRECRAWL_API_KEY
(needed now that web_crawl has a Firecrawl availability guard)
* refactor: explicit backend selection via hermes tools, not auto-detect
Replace the auto-detect backend selection with explicit user choice:
- hermes tools saves WEB_SEARCH_BACKEND to .env when user picks a provider
- _get_backend() reads the explicit choice first
- Fallback only for manual/legacy config (uses whichever key is present)
- _is_provider_active() shows [active] for the selected web backend
- Updated tests, docs, and .env.example to remove 'auto' mode language
* refactor: use config.yaml for web backend, not env var
Match the TTS/browser pattern — web.backend is stored in config.yaml
(set by hermes tools), not as a WEB_SEARCH_BACKEND env var.
- _load_web_config() reads web: section from config.yaml
- _get_backend() reads web.backend from config, falls back to key detection
- _configure_provider() saves to config dict (saved to config.yaml)
- _is_provider_active() reads from config dict
- Removed WEB_SEARCH_BACKEND from .env.example, set_config_value, docs
- Updated all tests to mock _load_web_config instead of env vars
---------
Co-authored-by: s-jag <s-jag@users.noreply.github.com>
2026-03-17 04:02:02 -07:00
|
|
|
_print_success(f" Web backend set to: {provider['web_backend']}")
|
|
|
|
|
|
feat: ungate Tool Gateway — subscription-based access with per-tool opt-in
Replace the HERMES_ENABLE_NOUS_MANAGED_TOOLS env-var feature flag with
subscription-based detection. The Tool Gateway is now available to any
paid Nous subscriber without needing a hidden env var.
Core changes:
- managed_nous_tools_enabled() checks get_nous_auth_status() +
check_nous_free_tier() instead of an env var
- New use_gateway config flag per tool section (web, tts, browser,
image_gen) records explicit user opt-in and overrides direct API
keys at runtime
- New prefers_gateway(section) shared helper in tool_backend_helpers.py
used by all 4 tool runtimes (web, tts, image gen, browser)
UX flow:
- hermes model: after Nous login/model selection, shows a curses
prompt listing all gateway-eligible tools with current status.
User chooses to enable all, enable only unconfigured tools, or skip.
Defaults to Enable for new users, Skip when direct keys exist.
- hermes tools: provider selection now manages use_gateway flag —
selecting Nous Subscription sets it, selecting any other provider
clears it
- hermes status: renamed section to Nous Tool Gateway, added
free-tier upgrade nudge for logged-in free users
- curses_radiolist: new description parameter for multi-line context
that survives the screen clear
Runtime behavior:
- Each tool runtime (web_tools, tts_tool, image_generation_tool,
browser_use) checks prefers_gateway() before falling back to
direct env-var credentials
- get_nous_subscription_features() respects use_gateway flags,
suppressing direct credential detection when the user opted in
Removed:
- HERMES_ENABLE_NOUS_MANAGED_TOOLS env var and all references
- apply_nous_provider_defaults() silent TTS auto-set
- get_nous_subscription_explainer_lines() static text
- Override env var warnings (use_gateway handles this properly now)
2026-04-16 01:59:51 -04:00
|
|
|
# For tools without a specific config key (e.g. image_gen), still
|
|
|
|
|
# track use_gateway so the runtime knows the user's intent.
|
|
|
|
|
if managed_feature and managed_feature not in ("web", "tts", "browser"):
|
|
|
|
|
config.setdefault(managed_feature, {})["use_gateway"] = True
|
|
|
|
|
elif not managed_feature:
|
|
|
|
|
# User picked a non-gateway provider — find which category this
|
|
|
|
|
# belongs to and clear use_gateway if it was previously set.
|
|
|
|
|
for cat_key, cat in TOOL_CATEGORIES.items():
|
|
|
|
|
if provider in cat.get("providers", []):
|
|
|
|
|
section = config.get(cat_key)
|
|
|
|
|
if isinstance(section, dict) and section.get("use_gateway"):
|
|
|
|
|
section["use_gateway"] = False
|
|
|
|
|
break
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
if not env_vars:
|
2026-03-26 15:27:27 -07:00
|
|
|
if provider.get("post_setup"):
|
|
|
|
|
_run_post_setup(provider["post_setup"])
|
2026-03-06 18:11:35 -08:00
|
|
|
_print_success(f" {provider['name']} - no configuration needed!")
|
2026-03-26 15:27:27 -07:00
|
|
|
if managed_feature:
|
|
|
|
|
_print_info(" Requests for this tool will be billed to your Nous subscription.")
|
feat(plugins): pluggable image_gen backends + OpenAI provider (#13799)
* feat(plugins): pluggable image_gen backends + OpenAI provider
Adds a ImageGenProvider ABC so image generation backends register as
bundled plugins under `plugins/image_gen/<name>/`. The plugin scanner
gains three primitives to make this work generically:
- `kind:` manifest field (`standalone` | `backend` | `exclusive`).
Bundled `kind: backend` plugins auto-load — no `plugins.enabled`
incantation. User-installed backends stay opt-in.
- Path-derived keys: `plugins/image_gen/openai/` gets key
`image_gen/openai`, so a future `tts/openai` cannot collide.
- Depth-2 recursion into category namespaces (parent dirs without a
`plugin.yaml` of their own).
Includes `OpenAIImageGenProvider` as the first consumer (gpt-image-1.5
default, plus gpt-image-1, gpt-image-1-mini, DALL-E 3/2). Base64
responses save to `$HERMES_HOME/cache/images/`; URL responses pass
through.
FAL stays in-tree for this PR — a follow-up ports it into
`plugins/image_gen/fal/` so the in-tree `image_generation_tool.py`
slims down. The dispatch shim in `_handle_image_generate` only fires
when `image_gen.provider` is explicitly set to a non-FAL value, so
existing FAL setups are untouched.
- 41 unit tests (scanner recursion, kind parsing, gate logic,
registry, OpenAI payload shapes)
- E2E smoke verified: bundled plugin autoloads, registers, and
`_handle_image_generate` routes to OpenAI when configured
* fix(image_gen/openai): don't send response_format to gpt-image-*
The live API rejects it: 'Unknown parameter: response_format'
(verified 2026-04-21 with gpt-image-1.5). gpt-image-* models return
b64_json unconditionally, so the parameter was both unnecessary and
actively broken.
* feat(image_gen/openai): gpt-image-2 only, drop legacy catalog
gpt-image-2 is the latest/best OpenAI image model (released 2026-04-21)
and there's no reason to expose the older gpt-image-1.5 / gpt-image-1 /
dall-e-3 / dall-e-2 alongside it — slower, lower quality, or awkward
(dall-e-2 squares only). Trim the catalog down to a single model.
Live-verified end-to-end: landscape 1536x1024 render of a Moog-style
synth matches prompt exactly, 2.4MB PNG saved to cache.
* feat(image_gen/openai): expose gpt-image-2 as three quality tiers
Users pick speed/fidelity via the normal model picker instead of a
hidden quality knob. All three tier IDs resolve to the single underlying
gpt-image-2 API model with a different quality parameter:
gpt-image-2-low ~15s fast iteration
gpt-image-2-medium ~40s default
gpt-image-2-high ~2min highest fidelity
Live-measured on OpenAI's API today: 15.4s / 40.8s / 116.9s for the
same 1024x1024 prompt.
Config:
image_gen.openai.model: gpt-image-2-high
# or
image_gen.model: gpt-image-2-low
# or env var for scripts/tests
OPENAI_IMAGE_MODEL=gpt-image-2-medium
Live-verified end-to-end with the low tier: 18.8s landscape render of a
golden retriever in wildflowers, vision-confirmed exact match.
* feat(tools_config): plugin image_gen providers inject themselves into picker
'hermes tools' → Image Generation now shows plugin-registered backends
alongside Nous Subscription and FAL.ai without tools_config.py needing
to know about them. OpenAI appears as a third option today; future
backends appear automatically as they're added.
Mechanism:
- ImageGenProvider gains an optional get_setup_schema() hook
(name, badge, tag, env_vars). Default derived from display_name.
- tools_config._plugin_image_gen_providers() pulls the schemas from
every registered non-FAL plugin provider.
- _visible_providers() appends those rows when rendering the Image
Generation category.
- _configure_provider() handles the new image_gen_plugin_name marker:
writes image_gen.provider and routes to the plugin's list_models()
catalog for the model picker.
- _toolset_needs_configuration_prompt('image_gen') stops demanding a
FAL key when any plugin provider reports is_available().
FAL is skipped in the plugin path because it already has hardcoded
TOOL_CATEGORIES rows — when it gets ported to a plugin in a follow-up
PR the hardcoded rows go away and it surfaces through the same path
as OpenAI.
Verified live: picker shows Nous Subscription / FAL.ai / OpenAI.
Picking OpenAI prompts for OPENAI_API_KEY, then shows the
gpt-image-2-low/medium/high model picker sourced from the plugin.
397 tests pass across plugins/, tools_config, registry, and picker.
* fix(image_gen): close final gaps for plugin-backend parity with FAL
Two small places that still hardcoded FAL:
- hermes_cli/setup.py status line: an OpenAI-only setup showed
'Image Generation: missing FAL_KEY'. Now probes plugin providers
and reports '(OpenAI)' when one is_available() — or falls back to
'missing FAL_KEY or OPENAI_API_KEY' if nothing is configured.
- image_generate tool schema description: said 'using FAL.ai, default
FLUX 2 Klein 9B'. Rewrote provider-neutral — 'backend and model are
user-configured' — and notes the 'image' field can be a URL or an
absolute path, which the gateway delivers either way via
extract_local_files().
2026-04-21 21:30:10 -07:00
|
|
|
# Plugin-registered image_gen provider: write image_gen.provider
|
|
|
|
|
# and route model selection to the plugin's own catalog.
|
|
|
|
|
plugin_name = provider.get("image_gen_plugin_name")
|
|
|
|
|
if plugin_name:
|
2026-04-22 22:50:38 -06:00
|
|
|
_select_plugin_image_gen_provider(plugin_name, config)
|
feat(plugins): pluggable image_gen backends + OpenAI provider (#13799)
* feat(plugins): pluggable image_gen backends + OpenAI provider
Adds a ImageGenProvider ABC so image generation backends register as
bundled plugins under `plugins/image_gen/<name>/`. The plugin scanner
gains three primitives to make this work generically:
- `kind:` manifest field (`standalone` | `backend` | `exclusive`).
Bundled `kind: backend` plugins auto-load — no `plugins.enabled`
incantation. User-installed backends stay opt-in.
- Path-derived keys: `plugins/image_gen/openai/` gets key
`image_gen/openai`, so a future `tts/openai` cannot collide.
- Depth-2 recursion into category namespaces (parent dirs without a
`plugin.yaml` of their own).
Includes `OpenAIImageGenProvider` as the first consumer (gpt-image-1.5
default, plus gpt-image-1, gpt-image-1-mini, DALL-E 3/2). Base64
responses save to `$HERMES_HOME/cache/images/`; URL responses pass
through.
FAL stays in-tree for this PR — a follow-up ports it into
`plugins/image_gen/fal/` so the in-tree `image_generation_tool.py`
slims down. The dispatch shim in `_handle_image_generate` only fires
when `image_gen.provider` is explicitly set to a non-FAL value, so
existing FAL setups are untouched.
- 41 unit tests (scanner recursion, kind parsing, gate logic,
registry, OpenAI payload shapes)
- E2E smoke verified: bundled plugin autoloads, registers, and
`_handle_image_generate` routes to OpenAI when configured
* fix(image_gen/openai): don't send response_format to gpt-image-*
The live API rejects it: 'Unknown parameter: response_format'
(verified 2026-04-21 with gpt-image-1.5). gpt-image-* models return
b64_json unconditionally, so the parameter was both unnecessary and
actively broken.
* feat(image_gen/openai): gpt-image-2 only, drop legacy catalog
gpt-image-2 is the latest/best OpenAI image model (released 2026-04-21)
and there's no reason to expose the older gpt-image-1.5 / gpt-image-1 /
dall-e-3 / dall-e-2 alongside it — slower, lower quality, or awkward
(dall-e-2 squares only). Trim the catalog down to a single model.
Live-verified end-to-end: landscape 1536x1024 render of a Moog-style
synth matches prompt exactly, 2.4MB PNG saved to cache.
* feat(image_gen/openai): expose gpt-image-2 as three quality tiers
Users pick speed/fidelity via the normal model picker instead of a
hidden quality knob. All three tier IDs resolve to the single underlying
gpt-image-2 API model with a different quality parameter:
gpt-image-2-low ~15s fast iteration
gpt-image-2-medium ~40s default
gpt-image-2-high ~2min highest fidelity
Live-measured on OpenAI's API today: 15.4s / 40.8s / 116.9s for the
same 1024x1024 prompt.
Config:
image_gen.openai.model: gpt-image-2-high
# or
image_gen.model: gpt-image-2-low
# or env var for scripts/tests
OPENAI_IMAGE_MODEL=gpt-image-2-medium
Live-verified end-to-end with the low tier: 18.8s landscape render of a
golden retriever in wildflowers, vision-confirmed exact match.
* feat(tools_config): plugin image_gen providers inject themselves into picker
'hermes tools' → Image Generation now shows plugin-registered backends
alongside Nous Subscription and FAL.ai without tools_config.py needing
to know about them. OpenAI appears as a third option today; future
backends appear automatically as they're added.
Mechanism:
- ImageGenProvider gains an optional get_setup_schema() hook
(name, badge, tag, env_vars). Default derived from display_name.
- tools_config._plugin_image_gen_providers() pulls the schemas from
every registered non-FAL plugin provider.
- _visible_providers() appends those rows when rendering the Image
Generation category.
- _configure_provider() handles the new image_gen_plugin_name marker:
writes image_gen.provider and routes to the plugin's list_models()
catalog for the model picker.
- _toolset_needs_configuration_prompt('image_gen') stops demanding a
FAL key when any plugin provider reports is_available().
FAL is skipped in the plugin path because it already has hardcoded
TOOL_CATEGORIES rows — when it gets ported to a plugin in a follow-up
PR the hardcoded rows go away and it surfaces through the same path
as OpenAI.
Verified live: picker shows Nous Subscription / FAL.ai / OpenAI.
Picking OpenAI prompts for OPENAI_API_KEY, then shows the
gpt-image-2-low/medium/high model picker sourced from the plugin.
397 tests pass across plugins/, tools_config, registry, and picker.
* fix(image_gen): close final gaps for plugin-backend parity with FAL
Two small places that still hardcoded FAL:
- hermes_cli/setup.py status line: an OpenAI-only setup showed
'Image Generation: missing FAL_KEY'. Now probes plugin providers
and reports '(OpenAI)' when one is_available() — or falls back to
'missing FAL_KEY or OPENAI_API_KEY' if nothing is configured.
- image_generate tool schema description: said 'using FAL.ai, default
FLUX 2 Klein 9B'. Rewrote provider-neutral — 'backend and model are
user-configured' — and notes the 'image' field can be a URL or an
absolute path, which the gateway delivers either way via
extract_local_files().
2026-04-21 21:30:10 -07:00
|
|
|
return
|
feat(image_gen): multi-model FAL support with picker in hermes tools (#11265)
* feat(image_gen): multi-model FAL support with picker in hermes tools
Adds 8 FAL text-to-image models selectable via `hermes tools` →
Image Generation → (FAL.ai | Nous Subscription) → model picker.
Models supported:
- fal-ai/flux-2/klein/9b (new default, <1s, $0.006/MP)
- fal-ai/flux-2-pro (previous default, kept backward-compat upscaling)
- fal-ai/z-image/turbo (Tongyi-MAI, bilingual EN/CN)
- fal-ai/nano-banana (Gemini 2.5 Flash Image)
- fal-ai/gpt-image-1.5 (with quality tier: low/medium/high)
- fal-ai/ideogram/v3 (best typography)
- fal-ai/recraft-v3 (vector, brand styles)
- fal-ai/qwen-image (LLM-based)
Architecture:
- FAL_MODELS catalog declares per-model size family, defaults, supports
whitelist, and upscale flag. Three size families handled uniformly:
image_size_preset (flux family), aspect_ratio (nano-banana), and
gpt_literal (gpt-image-1.5).
- _build_fal_payload() translates unified inputs (prompt + aspect_ratio)
into model-specific payloads, merges defaults, applies caller overrides,
wires GPT quality_setting, then filters to the supports whitelist — so
models never receive rejected keys.
- IMAGEGEN_BACKENDS registry in tools_config prepares for future imagegen
providers (Replicate, Stability, etc.); each provider entry tags itself
with imagegen_backend: 'fal' to select the right catalog.
- Upscaler (Clarity) defaults off for new models (preserves <1s value
prop), on for flux-2-pro (backward-compat). Per-model via FAL_MODELS.
Config:
image_gen.model = fal-ai/flux-2/klein/9b (new)
image_gen.quality_setting = medium (new, GPT only)
image_gen.use_gateway = bool (existing)
Agent-facing schema unchanged (prompt + aspect_ratio only) — model
choice is a user-level config decision, not an agent-level arg.
Picker uses curses_radiolist (arrow keys, auto numbered-fallback on
non-TTY). Column-aligned: Model / Speed / Strengths / Price.
Docs: image-generation.md rewritten with the model table and picker
walkthrough. tools-reference, tool-gateway, overview updated to drop
the stale "FLUX 2 Pro" wording.
Tests: 42 new in tests/tools/test_image_generation.py covering catalog
integrity, all 3 size families, supports filter, default merging, GPT
quality wiring, model resolution fallback. 8 new in
tests/hermes_cli/test_tools_config.py for picker wiring (registry,
config writes, GPT quality follow-up prompt, corrupt-config repair).
* feat(image_gen): translate managed-gateway 4xx to actionable error
When the Nous Subscription managed FAL proxy rejects a model with 4xx
(likely portal-side allowlist miss or billing gate), surface a clear
message explaining:
1. The rejected model ID + HTTP status
2. Two remediation paths: set FAL_KEY for direct access, or
pick a different model via `hermes tools`
5xx, connection errors, and direct-FAL errors pass through unchanged
(those have different root causes and reasonable native messages).
Motivation: new FAL models added to this release (flux-2-klein-9b,
z-image-turbo, nano-banana, gpt-image-1.5, ideogram-v3, recraft-v3,
qwen-image) are untested against the Nous Portal proxy. If the portal
allowlists model IDs, users on Nous Subscription will hit cryptic
4xx errors without guidance on how to work around it.
Tests: 8 new cases covering status extraction across httpx/fal error
shapes and 4xx-vs-5xx-vs-ConnectionError translation policy.
Docs: brief note in image-generation.md for Nous subscribers.
Operator action (Nous Portal side): verify that fal-queue-gateway
passes through these 7 new FAL model IDs. If the proxy has an
allowlist, add them; otherwise Nous Subscription users will see the
new translated error and fall back to direct FAL.
* feat(image_gen): pin GPT-Image quality to medium (no user choice)
Previously the tools picker asked a follow-up question for GPT-Image
quality tier (low / medium / high) and persisted the answer to
`image_gen.quality_setting`. This created two problems:
1. Nous Portal billing complexity — the 22x cost spread between tiers
($0.009 low / $0.20 high) forces the gateway to meter per-tier per
user, which the portal team can't easily support at launch.
2. User footgun — anyone picking `high` by mistake burns through
credit ~6x faster than `medium`.
This commit pins quality at medium by baking it into FAL_MODELS
defaults for gpt-image-1.5 and removes all user-facing override paths:
- Removed `_resolve_gpt_quality()` runtime lookup
- Removed `honors_quality_setting` flag on the model entry
- Removed `_configure_gpt_quality_setting()` picker helper
- Removed `_GPT_QUALITY_CHOICES` constant
- Removed the follow-up prompt call in `_configure_imagegen_model()`
- Even if a user manually edits `image_gen.quality_setting` in
config.yaml, no code path reads it — always sends medium.
Tests:
- Replaced TestGptQualitySetting (6 tests) with TestGptQualityPinnedToMedium
(5 tests) — proves medium is baked in, config is ignored, flag is
removed, helper is removed, non-gpt models never get quality.
- Replaced test_picker_with_gpt_image_also_prompts_quality with
test_picker_with_gpt_image_does_not_prompt_quality — proves only 1
picker call fires when gpt-image is selected (no quality follow-up).
Docs updated: image-generation.md replaces the quality-tier table
with a short note explaining the pinning decision.
* docs(image_gen): drop stale 'wires GPT quality tier' line from internals section
Caught in a cleanup sweep after pinning quality to medium. The
"How It Works Internally" walkthrough still described the removed
quality-wiring step.
2026-04-16 20:19:53 -07:00
|
|
|
# Imagegen backends prompt for model selection after backend pick.
|
|
|
|
|
backend = provider.get("imagegen_backend")
|
|
|
|
|
if backend:
|
|
|
|
|
_configure_imagegen_model(backend, config)
|
feat(plugins): pluggable image_gen backends + OpenAI provider (#13799)
* feat(plugins): pluggable image_gen backends + OpenAI provider
Adds a ImageGenProvider ABC so image generation backends register as
bundled plugins under `plugins/image_gen/<name>/`. The plugin scanner
gains three primitives to make this work generically:
- `kind:` manifest field (`standalone` | `backend` | `exclusive`).
Bundled `kind: backend` plugins auto-load — no `plugins.enabled`
incantation. User-installed backends stay opt-in.
- Path-derived keys: `plugins/image_gen/openai/` gets key
`image_gen/openai`, so a future `tts/openai` cannot collide.
- Depth-2 recursion into category namespaces (parent dirs without a
`plugin.yaml` of their own).
Includes `OpenAIImageGenProvider` as the first consumer (gpt-image-1.5
default, plus gpt-image-1, gpt-image-1-mini, DALL-E 3/2). Base64
responses save to `$HERMES_HOME/cache/images/`; URL responses pass
through.
FAL stays in-tree for this PR — a follow-up ports it into
`plugins/image_gen/fal/` so the in-tree `image_generation_tool.py`
slims down. The dispatch shim in `_handle_image_generate` only fires
when `image_gen.provider` is explicitly set to a non-FAL value, so
existing FAL setups are untouched.
- 41 unit tests (scanner recursion, kind parsing, gate logic,
registry, OpenAI payload shapes)
- E2E smoke verified: bundled plugin autoloads, registers, and
`_handle_image_generate` routes to OpenAI when configured
* fix(image_gen/openai): don't send response_format to gpt-image-*
The live API rejects it: 'Unknown parameter: response_format'
(verified 2026-04-21 with gpt-image-1.5). gpt-image-* models return
b64_json unconditionally, so the parameter was both unnecessary and
actively broken.
* feat(image_gen/openai): gpt-image-2 only, drop legacy catalog
gpt-image-2 is the latest/best OpenAI image model (released 2026-04-21)
and there's no reason to expose the older gpt-image-1.5 / gpt-image-1 /
dall-e-3 / dall-e-2 alongside it — slower, lower quality, or awkward
(dall-e-2 squares only). Trim the catalog down to a single model.
Live-verified end-to-end: landscape 1536x1024 render of a Moog-style
synth matches prompt exactly, 2.4MB PNG saved to cache.
* feat(image_gen/openai): expose gpt-image-2 as three quality tiers
Users pick speed/fidelity via the normal model picker instead of a
hidden quality knob. All three tier IDs resolve to the single underlying
gpt-image-2 API model with a different quality parameter:
gpt-image-2-low ~15s fast iteration
gpt-image-2-medium ~40s default
gpt-image-2-high ~2min highest fidelity
Live-measured on OpenAI's API today: 15.4s / 40.8s / 116.9s for the
same 1024x1024 prompt.
Config:
image_gen.openai.model: gpt-image-2-high
# or
image_gen.model: gpt-image-2-low
# or env var for scripts/tests
OPENAI_IMAGE_MODEL=gpt-image-2-medium
Live-verified end-to-end with the low tier: 18.8s landscape render of a
golden retriever in wildflowers, vision-confirmed exact match.
* feat(tools_config): plugin image_gen providers inject themselves into picker
'hermes tools' → Image Generation now shows plugin-registered backends
alongside Nous Subscription and FAL.ai without tools_config.py needing
to know about them. OpenAI appears as a third option today; future
backends appear automatically as they're added.
Mechanism:
- ImageGenProvider gains an optional get_setup_schema() hook
(name, badge, tag, env_vars). Default derived from display_name.
- tools_config._plugin_image_gen_providers() pulls the schemas from
every registered non-FAL plugin provider.
- _visible_providers() appends those rows when rendering the Image
Generation category.
- _configure_provider() handles the new image_gen_plugin_name marker:
writes image_gen.provider and routes to the plugin's list_models()
catalog for the model picker.
- _toolset_needs_configuration_prompt('image_gen') stops demanding a
FAL key when any plugin provider reports is_available().
FAL is skipped in the plugin path because it already has hardcoded
TOOL_CATEGORIES rows — when it gets ported to a plugin in a follow-up
PR the hardcoded rows go away and it surfaces through the same path
as OpenAI.
Verified live: picker shows Nous Subscription / FAL.ai / OpenAI.
Picking OpenAI prompts for OPENAI_API_KEY, then shows the
gpt-image-2-low/medium/high model picker sourced from the plugin.
397 tests pass across plugins/, tools_config, registry, and picker.
* fix(image_gen): close final gaps for plugin-backend parity with FAL
Two small places that still hardcoded FAL:
- hermes_cli/setup.py status line: an OpenAI-only setup showed
'Image Generation: missing FAL_KEY'. Now probes plugin providers
and reports '(OpenAI)' when one is_available() — or falls back to
'missing FAL_KEY or OPENAI_API_KEY' if nothing is configured.
- image_generate tool schema description: said 'using FAL.ai, default
FLUX 2 Klein 9B'. Rewrote provider-neutral — 'backend and model are
user-configured' — and notes the 'image' field can be a URL or an
absolute path, which the gateway delivers either way via
extract_local_files().
2026-04-21 21:30:10 -07:00
|
|
|
# In-tree FAL is the only non-plugin backend today. Keep
|
|
|
|
|
# image_gen.provider clear so the dispatch shim falls through
|
|
|
|
|
# to the legacy FAL path.
|
|
|
|
|
img_cfg = config.setdefault("image_gen", {})
|
|
|
|
|
if isinstance(img_cfg, dict) and img_cfg.get("provider") not in (None, "", "fal"):
|
|
|
|
|
img_cfg["provider"] = "fal"
|
2026-03-06 18:11:35 -08:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# Prompt for each required env var
|
|
|
|
|
all_configured = True
|
|
|
|
|
for var in env_vars:
|
|
|
|
|
existing = get_env_value(var["key"])
|
|
|
|
|
if existing:
|
|
|
|
|
_print_success(f" {var['key']}: already configured")
|
|
|
|
|
# Don't ask to update - this is a new enable flow.
|
|
|
|
|
# Reconfigure is handled separately.
|
|
|
|
|
else:
|
|
|
|
|
url = var.get("url", "")
|
2026-02-24 00:01:39 +00:00
|
|
|
if url:
|
2026-03-06 18:11:35 -08:00
|
|
|
_print_info(f" Get yours at: {url}")
|
|
|
|
|
|
|
|
|
|
default_val = var.get("default", "")
|
|
|
|
|
if default_val:
|
|
|
|
|
value = _prompt(f" {var.get('prompt', var['key'])}", default_val)
|
|
|
|
|
else:
|
|
|
|
|
value = _prompt(f" {var.get('prompt', var['key'])}", password=True)
|
|
|
|
|
|
|
|
|
|
if value:
|
|
|
|
|
save_env_value(var["key"], value)
|
chore: fix 154 f-strings, simplify getattr/URL patterns, remove dead code (#3119)
Three categories of cleanup, all zero-behavioral-change:
1. F-strings without placeholders (154 fixes across 29 files)
- Converted f'...' to '...' where no {expression} was present
- Heaviest files: run_agent.py (24), cli.py (20), honcho_integration/cli.py (34)
2. Simplify defensive patterns in run_agent.py
- Added explicit self._is_anthropic_oauth = False in __init__ (before
the api_mode branch that conditionally sets it)
- Replaced 7x getattr(self, '_is_anthropic_oauth', False) with direct
self._is_anthropic_oauth (attribute always initialized now)
- Added _is_openrouter_url() and _is_anthropic_url() helper methods
- Replaced 3 inline 'openrouter' in self._base_url_lower checks
3. Remove dead code in small files
- hermes_cli/claw.py: removed unused 'total' computation
- tools/fuzzy_match.py: removed unused strip_indent() function and
pattern_stripped variable
Full test suite: 6184 passed, 0 failures
E2E PTY: banner clean, tool calls work, zero garbled ANSI
2026-03-25 19:47:58 -07:00
|
|
|
_print_success(" Saved")
|
2026-02-24 00:01:39 +00:00
|
|
|
else:
|
chore: fix 154 f-strings, simplify getattr/URL patterns, remove dead code (#3119)
Three categories of cleanup, all zero-behavioral-change:
1. F-strings without placeholders (154 fixes across 29 files)
- Converted f'...' to '...' where no {expression} was present
- Heaviest files: run_agent.py (24), cli.py (20), honcho_integration/cli.py (34)
2. Simplify defensive patterns in run_agent.py
- Added explicit self._is_anthropic_oauth = False in __init__ (before
the api_mode branch that conditionally sets it)
- Replaced 7x getattr(self, '_is_anthropic_oauth', False) with direct
self._is_anthropic_oauth (attribute always initialized now)
- Added _is_openrouter_url() and _is_anthropic_url() helper methods
- Replaced 3 inline 'openrouter' in self._base_url_lower checks
3. Remove dead code in small files
- hermes_cli/claw.py: removed unused 'total' computation
- tools/fuzzy_match.py: removed unused strip_indent() function and
pattern_stripped variable
Full test suite: 6184 passed, 0 failures
E2E PTY: banner clean, tool calls work, zero garbled ANSI
2026-03-25 19:47:58 -07:00
|
|
|
_print_warning(" Skipped")
|
2026-03-06 18:11:35 -08:00
|
|
|
all_configured = False
|
|
|
|
|
|
|
|
|
|
# Run post-setup hooks if needed
|
|
|
|
|
if provider.get("post_setup") and all_configured:
|
|
|
|
|
_run_post_setup(provider["post_setup"])
|
|
|
|
|
|
|
|
|
|
if all_configured:
|
|
|
|
|
_print_success(f" {provider['name']} configured!")
|
feat(plugins): pluggable image_gen backends + OpenAI provider (#13799)
* feat(plugins): pluggable image_gen backends + OpenAI provider
Adds a ImageGenProvider ABC so image generation backends register as
bundled plugins under `plugins/image_gen/<name>/`. The plugin scanner
gains three primitives to make this work generically:
- `kind:` manifest field (`standalone` | `backend` | `exclusive`).
Bundled `kind: backend` plugins auto-load — no `plugins.enabled`
incantation. User-installed backends stay opt-in.
- Path-derived keys: `plugins/image_gen/openai/` gets key
`image_gen/openai`, so a future `tts/openai` cannot collide.
- Depth-2 recursion into category namespaces (parent dirs without a
`plugin.yaml` of their own).
Includes `OpenAIImageGenProvider` as the first consumer (gpt-image-1.5
default, plus gpt-image-1, gpt-image-1-mini, DALL-E 3/2). Base64
responses save to `$HERMES_HOME/cache/images/`; URL responses pass
through.
FAL stays in-tree for this PR — a follow-up ports it into
`plugins/image_gen/fal/` so the in-tree `image_generation_tool.py`
slims down. The dispatch shim in `_handle_image_generate` only fires
when `image_gen.provider` is explicitly set to a non-FAL value, so
existing FAL setups are untouched.
- 41 unit tests (scanner recursion, kind parsing, gate logic,
registry, OpenAI payload shapes)
- E2E smoke verified: bundled plugin autoloads, registers, and
`_handle_image_generate` routes to OpenAI when configured
* fix(image_gen/openai): don't send response_format to gpt-image-*
The live API rejects it: 'Unknown parameter: response_format'
(verified 2026-04-21 with gpt-image-1.5). gpt-image-* models return
b64_json unconditionally, so the parameter was both unnecessary and
actively broken.
* feat(image_gen/openai): gpt-image-2 only, drop legacy catalog
gpt-image-2 is the latest/best OpenAI image model (released 2026-04-21)
and there's no reason to expose the older gpt-image-1.5 / gpt-image-1 /
dall-e-3 / dall-e-2 alongside it — slower, lower quality, or awkward
(dall-e-2 squares only). Trim the catalog down to a single model.
Live-verified end-to-end: landscape 1536x1024 render of a Moog-style
synth matches prompt exactly, 2.4MB PNG saved to cache.
* feat(image_gen/openai): expose gpt-image-2 as three quality tiers
Users pick speed/fidelity via the normal model picker instead of a
hidden quality knob. All three tier IDs resolve to the single underlying
gpt-image-2 API model with a different quality parameter:
gpt-image-2-low ~15s fast iteration
gpt-image-2-medium ~40s default
gpt-image-2-high ~2min highest fidelity
Live-measured on OpenAI's API today: 15.4s / 40.8s / 116.9s for the
same 1024x1024 prompt.
Config:
image_gen.openai.model: gpt-image-2-high
# or
image_gen.model: gpt-image-2-low
# or env var for scripts/tests
OPENAI_IMAGE_MODEL=gpt-image-2-medium
Live-verified end-to-end with the low tier: 18.8s landscape render of a
golden retriever in wildflowers, vision-confirmed exact match.
* feat(tools_config): plugin image_gen providers inject themselves into picker
'hermes tools' → Image Generation now shows plugin-registered backends
alongside Nous Subscription and FAL.ai without tools_config.py needing
to know about them. OpenAI appears as a third option today; future
backends appear automatically as they're added.
Mechanism:
- ImageGenProvider gains an optional get_setup_schema() hook
(name, badge, tag, env_vars). Default derived from display_name.
- tools_config._plugin_image_gen_providers() pulls the schemas from
every registered non-FAL plugin provider.
- _visible_providers() appends those rows when rendering the Image
Generation category.
- _configure_provider() handles the new image_gen_plugin_name marker:
writes image_gen.provider and routes to the plugin's list_models()
catalog for the model picker.
- _toolset_needs_configuration_prompt('image_gen') stops demanding a
FAL key when any plugin provider reports is_available().
FAL is skipped in the plugin path because it already has hardcoded
TOOL_CATEGORIES rows — when it gets ported to a plugin in a follow-up
PR the hardcoded rows go away and it surfaces through the same path
as OpenAI.
Verified live: picker shows Nous Subscription / FAL.ai / OpenAI.
Picking OpenAI prompts for OPENAI_API_KEY, then shows the
gpt-image-2-low/medium/high model picker sourced from the plugin.
397 tests pass across plugins/, tools_config, registry, and picker.
* fix(image_gen): close final gaps for plugin-backend parity with FAL
Two small places that still hardcoded FAL:
- hermes_cli/setup.py status line: an OpenAI-only setup showed
'Image Generation: missing FAL_KEY'. Now probes plugin providers
and reports '(OpenAI)' when one is_available() — or falls back to
'missing FAL_KEY or OPENAI_API_KEY' if nothing is configured.
- image_generate tool schema description: said 'using FAL.ai, default
FLUX 2 Klein 9B'. Rewrote provider-neutral — 'backend and model are
user-configured' — and notes the 'image' field can be a URL or an
absolute path, which the gateway delivers either way via
extract_local_files().
2026-04-21 21:30:10 -07:00
|
|
|
plugin_name = provider.get("image_gen_plugin_name")
|
|
|
|
|
if plugin_name:
|
2026-04-22 22:50:38 -06:00
|
|
|
_select_plugin_image_gen_provider(plugin_name, config)
|
feat(plugins): pluggable image_gen backends + OpenAI provider (#13799)
* feat(plugins): pluggable image_gen backends + OpenAI provider
Adds a ImageGenProvider ABC so image generation backends register as
bundled plugins under `plugins/image_gen/<name>/`. The plugin scanner
gains three primitives to make this work generically:
- `kind:` manifest field (`standalone` | `backend` | `exclusive`).
Bundled `kind: backend` plugins auto-load — no `plugins.enabled`
incantation. User-installed backends stay opt-in.
- Path-derived keys: `plugins/image_gen/openai/` gets key
`image_gen/openai`, so a future `tts/openai` cannot collide.
- Depth-2 recursion into category namespaces (parent dirs without a
`plugin.yaml` of their own).
Includes `OpenAIImageGenProvider` as the first consumer (gpt-image-1.5
default, plus gpt-image-1, gpt-image-1-mini, DALL-E 3/2). Base64
responses save to `$HERMES_HOME/cache/images/`; URL responses pass
through.
FAL stays in-tree for this PR — a follow-up ports it into
`plugins/image_gen/fal/` so the in-tree `image_generation_tool.py`
slims down. The dispatch shim in `_handle_image_generate` only fires
when `image_gen.provider` is explicitly set to a non-FAL value, so
existing FAL setups are untouched.
- 41 unit tests (scanner recursion, kind parsing, gate logic,
registry, OpenAI payload shapes)
- E2E smoke verified: bundled plugin autoloads, registers, and
`_handle_image_generate` routes to OpenAI when configured
* fix(image_gen/openai): don't send response_format to gpt-image-*
The live API rejects it: 'Unknown parameter: response_format'
(verified 2026-04-21 with gpt-image-1.5). gpt-image-* models return
b64_json unconditionally, so the parameter was both unnecessary and
actively broken.
* feat(image_gen/openai): gpt-image-2 only, drop legacy catalog
gpt-image-2 is the latest/best OpenAI image model (released 2026-04-21)
and there's no reason to expose the older gpt-image-1.5 / gpt-image-1 /
dall-e-3 / dall-e-2 alongside it — slower, lower quality, or awkward
(dall-e-2 squares only). Trim the catalog down to a single model.
Live-verified end-to-end: landscape 1536x1024 render of a Moog-style
synth matches prompt exactly, 2.4MB PNG saved to cache.
* feat(image_gen/openai): expose gpt-image-2 as three quality tiers
Users pick speed/fidelity via the normal model picker instead of a
hidden quality knob. All three tier IDs resolve to the single underlying
gpt-image-2 API model with a different quality parameter:
gpt-image-2-low ~15s fast iteration
gpt-image-2-medium ~40s default
gpt-image-2-high ~2min highest fidelity
Live-measured on OpenAI's API today: 15.4s / 40.8s / 116.9s for the
same 1024x1024 prompt.
Config:
image_gen.openai.model: gpt-image-2-high
# or
image_gen.model: gpt-image-2-low
# or env var for scripts/tests
OPENAI_IMAGE_MODEL=gpt-image-2-medium
Live-verified end-to-end with the low tier: 18.8s landscape render of a
golden retriever in wildflowers, vision-confirmed exact match.
* feat(tools_config): plugin image_gen providers inject themselves into picker
'hermes tools' → Image Generation now shows plugin-registered backends
alongside Nous Subscription and FAL.ai without tools_config.py needing
to know about them. OpenAI appears as a third option today; future
backends appear automatically as they're added.
Mechanism:
- ImageGenProvider gains an optional get_setup_schema() hook
(name, badge, tag, env_vars). Default derived from display_name.
- tools_config._plugin_image_gen_providers() pulls the schemas from
every registered non-FAL plugin provider.
- _visible_providers() appends those rows when rendering the Image
Generation category.
- _configure_provider() handles the new image_gen_plugin_name marker:
writes image_gen.provider and routes to the plugin's list_models()
catalog for the model picker.
- _toolset_needs_configuration_prompt('image_gen') stops demanding a
FAL key when any plugin provider reports is_available().
FAL is skipped in the plugin path because it already has hardcoded
TOOL_CATEGORIES rows — when it gets ported to a plugin in a follow-up
PR the hardcoded rows go away and it surfaces through the same path
as OpenAI.
Verified live: picker shows Nous Subscription / FAL.ai / OpenAI.
Picking OpenAI prompts for OPENAI_API_KEY, then shows the
gpt-image-2-low/medium/high model picker sourced from the plugin.
397 tests pass across plugins/, tools_config, registry, and picker.
* fix(image_gen): close final gaps for plugin-backend parity with FAL
Two small places that still hardcoded FAL:
- hermes_cli/setup.py status line: an OpenAI-only setup showed
'Image Generation: missing FAL_KEY'. Now probes plugin providers
and reports '(OpenAI)' when one is_available() — or falls back to
'missing FAL_KEY or OPENAI_API_KEY' if nothing is configured.
- image_generate tool schema description: said 'using FAL.ai, default
FLUX 2 Klein 9B'. Rewrote provider-neutral — 'backend and model are
user-configured' — and notes the 'image' field can be a URL or an
absolute path, which the gateway delivers either way via
extract_local_files().
2026-04-21 21:30:10 -07:00
|
|
|
return
|
feat(image_gen): multi-model FAL support with picker in hermes tools (#11265)
* feat(image_gen): multi-model FAL support with picker in hermes tools
Adds 8 FAL text-to-image models selectable via `hermes tools` →
Image Generation → (FAL.ai | Nous Subscription) → model picker.
Models supported:
- fal-ai/flux-2/klein/9b (new default, <1s, $0.006/MP)
- fal-ai/flux-2-pro (previous default, kept backward-compat upscaling)
- fal-ai/z-image/turbo (Tongyi-MAI, bilingual EN/CN)
- fal-ai/nano-banana (Gemini 2.5 Flash Image)
- fal-ai/gpt-image-1.5 (with quality tier: low/medium/high)
- fal-ai/ideogram/v3 (best typography)
- fal-ai/recraft-v3 (vector, brand styles)
- fal-ai/qwen-image (LLM-based)
Architecture:
- FAL_MODELS catalog declares per-model size family, defaults, supports
whitelist, and upscale flag. Three size families handled uniformly:
image_size_preset (flux family), aspect_ratio (nano-banana), and
gpt_literal (gpt-image-1.5).
- _build_fal_payload() translates unified inputs (prompt + aspect_ratio)
into model-specific payloads, merges defaults, applies caller overrides,
wires GPT quality_setting, then filters to the supports whitelist — so
models never receive rejected keys.
- IMAGEGEN_BACKENDS registry in tools_config prepares for future imagegen
providers (Replicate, Stability, etc.); each provider entry tags itself
with imagegen_backend: 'fal' to select the right catalog.
- Upscaler (Clarity) defaults off for new models (preserves <1s value
prop), on for flux-2-pro (backward-compat). Per-model via FAL_MODELS.
Config:
image_gen.model = fal-ai/flux-2/klein/9b (new)
image_gen.quality_setting = medium (new, GPT only)
image_gen.use_gateway = bool (existing)
Agent-facing schema unchanged (prompt + aspect_ratio only) — model
choice is a user-level config decision, not an agent-level arg.
Picker uses curses_radiolist (arrow keys, auto numbered-fallback on
non-TTY). Column-aligned: Model / Speed / Strengths / Price.
Docs: image-generation.md rewritten with the model table and picker
walkthrough. tools-reference, tool-gateway, overview updated to drop
the stale "FLUX 2 Pro" wording.
Tests: 42 new in tests/tools/test_image_generation.py covering catalog
integrity, all 3 size families, supports filter, default merging, GPT
quality wiring, model resolution fallback. 8 new in
tests/hermes_cli/test_tools_config.py for picker wiring (registry,
config writes, GPT quality follow-up prompt, corrupt-config repair).
* feat(image_gen): translate managed-gateway 4xx to actionable error
When the Nous Subscription managed FAL proxy rejects a model with 4xx
(likely portal-side allowlist miss or billing gate), surface a clear
message explaining:
1. The rejected model ID + HTTP status
2. Two remediation paths: set FAL_KEY for direct access, or
pick a different model via `hermes tools`
5xx, connection errors, and direct-FAL errors pass through unchanged
(those have different root causes and reasonable native messages).
Motivation: new FAL models added to this release (flux-2-klein-9b,
z-image-turbo, nano-banana, gpt-image-1.5, ideogram-v3, recraft-v3,
qwen-image) are untested against the Nous Portal proxy. If the portal
allowlists model IDs, users on Nous Subscription will hit cryptic
4xx errors without guidance on how to work around it.
Tests: 8 new cases covering status extraction across httpx/fal error
shapes and 4xx-vs-5xx-vs-ConnectionError translation policy.
Docs: brief note in image-generation.md for Nous subscribers.
Operator action (Nous Portal side): verify that fal-queue-gateway
passes through these 7 new FAL model IDs. If the proxy has an
allowlist, add them; otherwise Nous Subscription users will see the
new translated error and fall back to direct FAL.
* feat(image_gen): pin GPT-Image quality to medium (no user choice)
Previously the tools picker asked a follow-up question for GPT-Image
quality tier (low / medium / high) and persisted the answer to
`image_gen.quality_setting`. This created two problems:
1. Nous Portal billing complexity — the 22x cost spread between tiers
($0.009 low / $0.20 high) forces the gateway to meter per-tier per
user, which the portal team can't easily support at launch.
2. User footgun — anyone picking `high` by mistake burns through
credit ~6x faster than `medium`.
This commit pins quality at medium by baking it into FAL_MODELS
defaults for gpt-image-1.5 and removes all user-facing override paths:
- Removed `_resolve_gpt_quality()` runtime lookup
- Removed `honors_quality_setting` flag on the model entry
- Removed `_configure_gpt_quality_setting()` picker helper
- Removed `_GPT_QUALITY_CHOICES` constant
- Removed the follow-up prompt call in `_configure_imagegen_model()`
- Even if a user manually edits `image_gen.quality_setting` in
config.yaml, no code path reads it — always sends medium.
Tests:
- Replaced TestGptQualitySetting (6 tests) with TestGptQualityPinnedToMedium
(5 tests) — proves medium is baked in, config is ignored, flag is
removed, helper is removed, non-gpt models never get quality.
- Replaced test_picker_with_gpt_image_also_prompts_quality with
test_picker_with_gpt_image_does_not_prompt_quality — proves only 1
picker call fires when gpt-image is selected (no quality follow-up).
Docs updated: image-generation.md replaces the quality-tier table
with a short note explaining the pinning decision.
* docs(image_gen): drop stale 'wires GPT quality tier' line from internals section
Caught in a cleanup sweep after pinning quality to medium. The
"How It Works Internally" walkthrough still described the removed
quality-wiring step.
2026-04-16 20:19:53 -07:00
|
|
|
# Imagegen backends prompt for model selection after env vars are in.
|
|
|
|
|
backend = provider.get("imagegen_backend")
|
|
|
|
|
if backend:
|
|
|
|
|
_configure_imagegen_model(backend, config)
|
feat(plugins): pluggable image_gen backends + OpenAI provider (#13799)
* feat(plugins): pluggable image_gen backends + OpenAI provider
Adds a ImageGenProvider ABC so image generation backends register as
bundled plugins under `plugins/image_gen/<name>/`. The plugin scanner
gains three primitives to make this work generically:
- `kind:` manifest field (`standalone` | `backend` | `exclusive`).
Bundled `kind: backend` plugins auto-load — no `plugins.enabled`
incantation. User-installed backends stay opt-in.
- Path-derived keys: `plugins/image_gen/openai/` gets key
`image_gen/openai`, so a future `tts/openai` cannot collide.
- Depth-2 recursion into category namespaces (parent dirs without a
`plugin.yaml` of their own).
Includes `OpenAIImageGenProvider` as the first consumer (gpt-image-1.5
default, plus gpt-image-1, gpt-image-1-mini, DALL-E 3/2). Base64
responses save to `$HERMES_HOME/cache/images/`; URL responses pass
through.
FAL stays in-tree for this PR — a follow-up ports it into
`plugins/image_gen/fal/` so the in-tree `image_generation_tool.py`
slims down. The dispatch shim in `_handle_image_generate` only fires
when `image_gen.provider` is explicitly set to a non-FAL value, so
existing FAL setups are untouched.
- 41 unit tests (scanner recursion, kind parsing, gate logic,
registry, OpenAI payload shapes)
- E2E smoke verified: bundled plugin autoloads, registers, and
`_handle_image_generate` routes to OpenAI when configured
* fix(image_gen/openai): don't send response_format to gpt-image-*
The live API rejects it: 'Unknown parameter: response_format'
(verified 2026-04-21 with gpt-image-1.5). gpt-image-* models return
b64_json unconditionally, so the parameter was both unnecessary and
actively broken.
* feat(image_gen/openai): gpt-image-2 only, drop legacy catalog
gpt-image-2 is the latest/best OpenAI image model (released 2026-04-21)
and there's no reason to expose the older gpt-image-1.5 / gpt-image-1 /
dall-e-3 / dall-e-2 alongside it — slower, lower quality, or awkward
(dall-e-2 squares only). Trim the catalog down to a single model.
Live-verified end-to-end: landscape 1536x1024 render of a Moog-style
synth matches prompt exactly, 2.4MB PNG saved to cache.
* feat(image_gen/openai): expose gpt-image-2 as three quality tiers
Users pick speed/fidelity via the normal model picker instead of a
hidden quality knob. All three tier IDs resolve to the single underlying
gpt-image-2 API model with a different quality parameter:
gpt-image-2-low ~15s fast iteration
gpt-image-2-medium ~40s default
gpt-image-2-high ~2min highest fidelity
Live-measured on OpenAI's API today: 15.4s / 40.8s / 116.9s for the
same 1024x1024 prompt.
Config:
image_gen.openai.model: gpt-image-2-high
# or
image_gen.model: gpt-image-2-low
# or env var for scripts/tests
OPENAI_IMAGE_MODEL=gpt-image-2-medium
Live-verified end-to-end with the low tier: 18.8s landscape render of a
golden retriever in wildflowers, vision-confirmed exact match.
* feat(tools_config): plugin image_gen providers inject themselves into picker
'hermes tools' → Image Generation now shows plugin-registered backends
alongside Nous Subscription and FAL.ai without tools_config.py needing
to know about them. OpenAI appears as a third option today; future
backends appear automatically as they're added.
Mechanism:
- ImageGenProvider gains an optional get_setup_schema() hook
(name, badge, tag, env_vars). Default derived from display_name.
- tools_config._plugin_image_gen_providers() pulls the schemas from
every registered non-FAL plugin provider.
- _visible_providers() appends those rows when rendering the Image
Generation category.
- _configure_provider() handles the new image_gen_plugin_name marker:
writes image_gen.provider and routes to the plugin's list_models()
catalog for the model picker.
- _toolset_needs_configuration_prompt('image_gen') stops demanding a
FAL key when any plugin provider reports is_available().
FAL is skipped in the plugin path because it already has hardcoded
TOOL_CATEGORIES rows — when it gets ported to a plugin in a follow-up
PR the hardcoded rows go away and it surfaces through the same path
as OpenAI.
Verified live: picker shows Nous Subscription / FAL.ai / OpenAI.
Picking OpenAI prompts for OPENAI_API_KEY, then shows the
gpt-image-2-low/medium/high model picker sourced from the plugin.
397 tests pass across plugins/, tools_config, registry, and picker.
* fix(image_gen): close final gaps for plugin-backend parity with FAL
Two small places that still hardcoded FAL:
- hermes_cli/setup.py status line: an OpenAI-only setup showed
'Image Generation: missing FAL_KEY'. Now probes plugin providers
and reports '(OpenAI)' when one is_available() — or falls back to
'missing FAL_KEY or OPENAI_API_KEY' if nothing is configured.
- image_generate tool schema description: said 'using FAL.ai, default
FLUX 2 Klein 9B'. Rewrote provider-neutral — 'backend and model are
user-configured' — and notes the 'image' field can be a URL or an
absolute path, which the gateway delivers either way via
extract_local_files().
2026-04-21 21:30:10 -07:00
|
|
|
img_cfg = config.setdefault("image_gen", {})
|
|
|
|
|
if isinstance(img_cfg, dict) and img_cfg.get("provider") not in (None, "", "fal"):
|
|
|
|
|
img_cfg["provider"] = "fal"
|
2026-03-06 18:11:35 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def _configure_simple_requirements(ts_key: str):
|
|
|
|
|
"""Simple fallback for toolsets that just need env vars (no provider selection)."""
|
2026-03-14 20:22:13 -07:00
|
|
|
if ts_key == "vision":
|
|
|
|
|
if _toolset_has_keys("vision"):
|
|
|
|
|
return
|
|
|
|
|
print()
|
|
|
|
|
print(color(" Vision / Image Analysis requires a multimodal backend:", Colors.YELLOW))
|
|
|
|
|
choices = [
|
|
|
|
|
"OpenRouter — uses Gemini",
|
|
|
|
|
"OpenAI-compatible endpoint — base URL, API key, and vision model",
|
|
|
|
|
"Skip",
|
|
|
|
|
]
|
|
|
|
|
idx = _prompt_choice(" Configure vision backend", choices, 2)
|
|
|
|
|
if idx == 0:
|
|
|
|
|
_print_info(" Get key at: https://openrouter.ai/keys")
|
|
|
|
|
value = _prompt(" OPENROUTER_API_KEY", password=True)
|
|
|
|
|
if value and value.strip():
|
|
|
|
|
save_env_value("OPENROUTER_API_KEY", value.strip())
|
|
|
|
|
_print_success(" Saved")
|
|
|
|
|
else:
|
|
|
|
|
_print_warning(" Skipped")
|
|
|
|
|
elif idx == 1:
|
|
|
|
|
base_url = _prompt(" OPENAI_BASE_URL (blank for OpenAI)").strip() or "https://api.openai.com/v1"
|
fix: extend hostname-match provider detection across remaining call sites
Aslaaen's fix in the original PR covered _detect_api_mode_for_url and the
two openai/xai sites in run_agent.py. This finishes the sweep: the same
substring-match false-positive class (e.g. https://api.openai.com.evil/v1,
https://proxy/api.openai.com/v1, https://api.anthropic.com.example/v1)
existed in eight more call sites, and the hostname helper was duplicated
in two modules.
- utils: add shared base_url_hostname() (single source of truth).
- hermes_cli/runtime_provider, run_agent: drop local duplicates, import
from utils. Reuse the cached AIAgent._base_url_hostname attribute
everywhere it's already populated.
- agent/auxiliary_client: switch codex-wrap auto-detect, max_completion_tokens
gate (auxiliary_max_tokens_param), and custom-endpoint max_tokens kwarg
selection to hostname equality.
- run_agent: native-anthropic check in the Claude-style model branch
and in the AIAgent init provider-auto-detect branch.
- agent/model_metadata: Anthropic /v1/models context-length lookup.
- hermes_cli/providers.determine_api_mode: anthropic / openai URL
heuristics for custom/unknown providers (the /anthropic path-suffix
convention for third-party gateways is preserved).
- tools/delegate_tool: anthropic detection for delegated subagent
runtimes.
- hermes_cli/setup, hermes_cli/tools_config: setup-wizard vision-endpoint
native-OpenAI detection (paired with deduping the repeated check into
a single is_native_openai boolean per branch).
Tests:
- tests/test_base_url_hostname.py covers the helper directly
(path-containing-host, host-suffix, trailing dot, port, case).
- tests/hermes_cli/test_determine_api_mode_hostname.py adds the same
regression class for determine_api_mode, plus a test that the
/anthropic third-party gateway convention still wins.
Also: add asslaenn5@gmail.com → Aslaaen to scripts/release.py AUTHOR_MAP.
2026-04-20 20:58:01 -07:00
|
|
|
is_native_openai = base_url_hostname(base_url) == "api.openai.com"
|
|
|
|
|
key_label = " OPENAI_API_KEY" if is_native_openai else " API key"
|
2026-03-14 20:22:13 -07:00
|
|
|
api_key = _prompt(key_label, password=True)
|
|
|
|
|
if api_key and api_key.strip():
|
|
|
|
|
save_env_value("OPENAI_API_KEY", api_key.strip())
|
refactor: make config.yaml the single source of truth for endpoint URLs (#4165)
OPENAI_BASE_URL was written to .env AND config.yaml, creating a dual-source
confusion. Users (especially Docker) would see the URL in .env and assume
that's where all config lives, then wonder why LLM_MODEL in .env didn't work.
Changes:
- Remove all 27 save_env_value("OPENAI_BASE_URL", ...) calls across main.py,
setup.py, and tools_config.py
- Remove OPENAI_BASE_URL env var reading from runtime_provider.py, cli.py,
models.py, and gateway/run.py
- Remove LLM_MODEL/HERMES_MODEL env var reading from gateway/run.py and
auxiliary_client.py — config.yaml model.default is authoritative
- Vision base URL now saved to config.yaml auxiliary.vision.base_url
(both setup wizard and tools_config paths)
- Tests updated to set config values instead of env vars
Convention enforced: .env is for SECRETS only (API keys). All other
configuration (model names, base URLs, provider selection) lives
exclusively in config.yaml.
2026-03-30 22:02:53 -07:00
|
|
|
# Save vision base URL to config (not .env — only secrets go there)
|
|
|
|
|
_cfg = load_config()
|
|
|
|
|
_aux = _cfg.setdefault("auxiliary", {}).setdefault("vision", {})
|
|
|
|
|
_aux["base_url"] = base_url
|
|
|
|
|
save_config(_cfg)
|
fix: extend hostname-match provider detection across remaining call sites
Aslaaen's fix in the original PR covered _detect_api_mode_for_url and the
two openai/xai sites in run_agent.py. This finishes the sweep: the same
substring-match false-positive class (e.g. https://api.openai.com.evil/v1,
https://proxy/api.openai.com/v1, https://api.anthropic.com.example/v1)
existed in eight more call sites, and the hostname helper was duplicated
in two modules.
- utils: add shared base_url_hostname() (single source of truth).
- hermes_cli/runtime_provider, run_agent: drop local duplicates, import
from utils. Reuse the cached AIAgent._base_url_hostname attribute
everywhere it's already populated.
- agent/auxiliary_client: switch codex-wrap auto-detect, max_completion_tokens
gate (auxiliary_max_tokens_param), and custom-endpoint max_tokens kwarg
selection to hostname equality.
- run_agent: native-anthropic check in the Claude-style model branch
and in the AIAgent init provider-auto-detect branch.
- agent/model_metadata: Anthropic /v1/models context-length lookup.
- hermes_cli/providers.determine_api_mode: anthropic / openai URL
heuristics for custom/unknown providers (the /anthropic path-suffix
convention for third-party gateways is preserved).
- tools/delegate_tool: anthropic detection for delegated subagent
runtimes.
- hermes_cli/setup, hermes_cli/tools_config: setup-wizard vision-endpoint
native-OpenAI detection (paired with deduping the repeated check into
a single is_native_openai boolean per branch).
Tests:
- tests/test_base_url_hostname.py covers the helper directly
(path-containing-host, host-suffix, trailing dot, port, case).
- tests/hermes_cli/test_determine_api_mode_hostname.py adds the same
regression class for determine_api_mode, plus a test that the
/anthropic third-party gateway convention still wins.
Also: add asslaenn5@gmail.com → Aslaaen to scripts/release.py AUTHOR_MAP.
2026-04-20 20:58:01 -07:00
|
|
|
if is_native_openai:
|
2026-03-14 20:22:13 -07:00
|
|
|
save_env_value("AUXILIARY_VISION_MODEL", "gpt-4o-mini")
|
|
|
|
|
_print_success(" Saved")
|
|
|
|
|
else:
|
|
|
|
|
_print_warning(" Skipped")
|
|
|
|
|
return
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
requirements = TOOLSET_ENV_REQUIREMENTS.get(ts_key, [])
|
|
|
|
|
if not requirements:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
missing = [(var, url) for var, url in requirements if not get_env_value(var)]
|
|
|
|
|
if not missing:
|
|
|
|
|
return
|
|
|
|
|
|
2026-03-22 04:55:34 -07:00
|
|
|
ts_label = next((l for k, l, _ in _get_effective_configurable_toolsets() if k == ts_key), ts_key)
|
2026-03-06 18:11:35 -08:00
|
|
|
print()
|
|
|
|
|
print(color(f" {ts_label} requires configuration:", Colors.YELLOW))
|
|
|
|
|
|
|
|
|
|
for var, url in missing:
|
|
|
|
|
if url:
|
|
|
|
|
_print_info(f" Get key at: {url}")
|
|
|
|
|
value = _prompt(f" {var}", password=True)
|
|
|
|
|
if value and value.strip():
|
|
|
|
|
save_env_value(var, value.strip())
|
chore: fix 154 f-strings, simplify getattr/URL patterns, remove dead code (#3119)
Three categories of cleanup, all zero-behavioral-change:
1. F-strings without placeholders (154 fixes across 29 files)
- Converted f'...' to '...' where no {expression} was present
- Heaviest files: run_agent.py (24), cli.py (20), honcho_integration/cli.py (34)
2. Simplify defensive patterns in run_agent.py
- Added explicit self._is_anthropic_oauth = False in __init__ (before
the api_mode branch that conditionally sets it)
- Replaced 7x getattr(self, '_is_anthropic_oauth', False) with direct
self._is_anthropic_oauth (attribute always initialized now)
- Added _is_openrouter_url() and _is_anthropic_url() helper methods
- Replaced 3 inline 'openrouter' in self._base_url_lower checks
3. Remove dead code in small files
- hermes_cli/claw.py: removed unused 'total' computation
- tools/fuzzy_match.py: removed unused strip_indent() function and
pattern_stripped variable
Full test suite: 6184 passed, 0 failures
E2E PTY: banner clean, tool calls work, zero garbled ANSI
2026-03-25 19:47:58 -07:00
|
|
|
_print_success(" Saved")
|
2026-03-06 18:11:35 -08:00
|
|
|
else:
|
chore: fix 154 f-strings, simplify getattr/URL patterns, remove dead code (#3119)
Three categories of cleanup, all zero-behavioral-change:
1. F-strings without placeholders (154 fixes across 29 files)
- Converted f'...' to '...' where no {expression} was present
- Heaviest files: run_agent.py (24), cli.py (20), honcho_integration/cli.py (34)
2. Simplify defensive patterns in run_agent.py
- Added explicit self._is_anthropic_oauth = False in __init__ (before
the api_mode branch that conditionally sets it)
- Replaced 7x getattr(self, '_is_anthropic_oauth', False) with direct
self._is_anthropic_oauth (attribute always initialized now)
- Added _is_openrouter_url() and _is_anthropic_url() helper methods
- Replaced 3 inline 'openrouter' in self._base_url_lower checks
3. Remove dead code in small files
- hermes_cli/claw.py: removed unused 'total' computation
- tools/fuzzy_match.py: removed unused strip_indent() function and
pattern_stripped variable
Full test suite: 6184 passed, 0 failures
E2E PTY: banner clean, tool calls work, zero garbled ANSI
2026-03-25 19:47:58 -07:00
|
|
|
_print_warning(" Skipped")
|
2026-03-06 18:11:35 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def _reconfigure_tool(config: dict):
|
|
|
|
|
"""Let user reconfigure an existing tool's provider or API key."""
|
|
|
|
|
# Build list of configurable tools that are currently set up
|
|
|
|
|
configurable = []
|
2026-03-22 04:55:34 -07:00
|
|
|
for ts_key, ts_label, _ in _get_effective_configurable_toolsets():
|
2026-03-06 18:11:35 -08:00
|
|
|
cat = TOOL_CATEGORIES.get(ts_key)
|
|
|
|
|
reqs = TOOLSET_ENV_REQUIREMENTS.get(ts_key)
|
|
|
|
|
if cat or reqs:
|
2026-03-26 15:27:27 -07:00
|
|
|
if _toolset_has_keys(ts_key, config):
|
2026-03-06 18:11:35 -08:00
|
|
|
configurable.append((ts_key, ts_label))
|
|
|
|
|
|
|
|
|
|
if not configurable:
|
|
|
|
|
_print_info("No configured tools to reconfigure.")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
choices = [label for _, label in configurable]
|
|
|
|
|
choices.append("Cancel")
|
|
|
|
|
|
|
|
|
|
idx = _prompt_choice(" Which tool would you like to reconfigure?", choices, len(choices) - 1)
|
2026-02-24 00:01:39 +00:00
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
if idx >= len(configurable):
|
|
|
|
|
return # Cancel
|
|
|
|
|
|
|
|
|
|
ts_key, ts_label = configurable[idx]
|
|
|
|
|
cat = TOOL_CATEGORIES.get(ts_key)
|
|
|
|
|
|
|
|
|
|
if cat:
|
|
|
|
|
_configure_tool_category_for_reconfig(ts_key, cat, config)
|
|
|
|
|
else:
|
|
|
|
|
_reconfigure_simple_requirements(ts_key)
|
|
|
|
|
|
|
|
|
|
save_config(config)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _configure_tool_category_for_reconfig(ts_key: str, cat: dict, config: dict):
|
|
|
|
|
"""Reconfigure a tool category - provider selection + API key update."""
|
|
|
|
|
icon = cat.get("icon", "")
|
|
|
|
|
name = cat["name"]
|
2026-03-26 15:27:27 -07:00
|
|
|
providers = _visible_providers(cat, config)
|
2026-03-06 18:11:35 -08:00
|
|
|
|
|
|
|
|
if len(providers) == 1:
|
|
|
|
|
provider = providers[0]
|
|
|
|
|
print()
|
|
|
|
|
print(color(f" --- {icon} {name} ({provider['name']}) ---", Colors.CYAN))
|
|
|
|
|
_reconfigure_provider(provider, config)
|
|
|
|
|
else:
|
|
|
|
|
print()
|
|
|
|
|
print(color(f" --- {icon} {name} - Choose a provider ---", Colors.CYAN))
|
2026-02-24 00:01:39 +00:00
|
|
|
print()
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
provider_choices = []
|
|
|
|
|
for p in providers:
|
2026-04-14 16:58:10 -07:00
|
|
|
badge = f" [{p['badge']}]" if p.get("badge") else ""
|
|
|
|
|
tag = f" — {p['tag']}" if p.get("tag") else ""
|
2026-03-06 18:11:35 -08:00
|
|
|
configured = ""
|
|
|
|
|
env_vars = p.get("env_vars", [])
|
|
|
|
|
if not env_vars or all(get_env_value(v["key"]) for v in env_vars):
|
2026-03-17 00:16:34 -07:00
|
|
|
if _is_provider_active(p, config):
|
2026-03-06 18:11:35 -08:00
|
|
|
configured = " [active]"
|
|
|
|
|
elif not env_vars:
|
|
|
|
|
configured = ""
|
2026-02-24 00:01:39 +00:00
|
|
|
else:
|
2026-03-06 18:11:35 -08:00
|
|
|
configured = " [configured]"
|
2026-04-14 16:58:10 -07:00
|
|
|
provider_choices.append(f"{p['name']}{badge}{tag}{configured}")
|
2026-03-06 18:11:35 -08:00
|
|
|
|
2026-03-17 00:16:34 -07:00
|
|
|
default_idx = _detect_active_provider_index(providers, config)
|
2026-03-06 18:11:35 -08:00
|
|
|
|
|
|
|
|
provider_idx = _prompt_choice(" Select provider:", provider_choices, default_idx)
|
|
|
|
|
_reconfigure_provider(providers[provider_idx], config)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _reconfigure_provider(provider: dict, config: dict):
|
|
|
|
|
"""Reconfigure a provider - update API keys."""
|
|
|
|
|
env_vars = provider.get("env_vars", [])
|
2026-03-26 15:27:27 -07:00
|
|
|
managed_feature = provider.get("managed_nous_feature")
|
|
|
|
|
|
|
|
|
|
if provider.get("requires_nous_auth"):
|
|
|
|
|
features = get_nous_subscription_features(config)
|
|
|
|
|
if not features.nous_auth_present:
|
|
|
|
|
_print_warning(" Nous Subscription is only available after logging into Nous Portal.")
|
|
|
|
|
return
|
2026-03-06 18:11:35 -08:00
|
|
|
|
|
|
|
|
if provider.get("tts_provider"):
|
|
|
|
|
config.setdefault("tts", {})["provider"] = provider["tts_provider"]
|
|
|
|
|
_print_success(f" TTS provider set to: {provider['tts_provider']}")
|
|
|
|
|
|
2026-03-17 00:16:34 -07:00
|
|
|
if "browser_provider" in provider:
|
|
|
|
|
bp = provider["browser_provider"]
|
2026-03-26 15:27:27 -07:00
|
|
|
if bp == "local":
|
|
|
|
|
config.setdefault("browser", {})["cloud_provider"] = "local"
|
|
|
|
|
_print_success(" Browser set to local mode")
|
|
|
|
|
elif bp:
|
2026-03-17 00:16:34 -07:00
|
|
|
config.setdefault("browser", {})["cloud_provider"] = bp
|
|
|
|
|
_print_success(f" Browser cloud provider set to: {bp}")
|
|
|
|
|
|
2026-03-17 04:28:03 -07:00
|
|
|
# Set web search backend in config if applicable
|
|
|
|
|
if provider.get("web_backend"):
|
|
|
|
|
config.setdefault("web", {})["backend"] = provider["web_backend"]
|
|
|
|
|
_print_success(f" Web backend set to: {provider['web_backend']}")
|
|
|
|
|
|
2026-04-22 22:50:38 -06:00
|
|
|
if managed_feature and managed_feature not in ("web", "tts", "browser"):
|
|
|
|
|
section = config.setdefault(managed_feature, {})
|
|
|
|
|
if not isinstance(section, dict):
|
|
|
|
|
section = {}
|
|
|
|
|
config[managed_feature] = section
|
|
|
|
|
section["use_gateway"] = True
|
|
|
|
|
elif not managed_feature:
|
|
|
|
|
for cat_key, cat in TOOL_CATEGORIES.items():
|
|
|
|
|
if provider in cat.get("providers", []):
|
|
|
|
|
section = config.get(cat_key)
|
|
|
|
|
if isinstance(section, dict) and section.get("use_gateway"):
|
|
|
|
|
section["use_gateway"] = False
|
|
|
|
|
break
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
if not env_vars:
|
2026-03-26 15:27:27 -07:00
|
|
|
if provider.get("post_setup"):
|
|
|
|
|
_run_post_setup(provider["post_setup"])
|
2026-03-06 18:11:35 -08:00
|
|
|
_print_success(f" {provider['name']} - no configuration needed!")
|
2026-03-26 15:27:27 -07:00
|
|
|
if managed_feature:
|
|
|
|
|
_print_info(" Requests for this tool will be billed to your Nous subscription.")
|
2026-04-22 22:50:38 -06:00
|
|
|
plugin_name = provider.get("image_gen_plugin_name")
|
|
|
|
|
if plugin_name:
|
|
|
|
|
_select_plugin_image_gen_provider(plugin_name, config)
|
|
|
|
|
return
|
feat(image_gen): multi-model FAL support with picker in hermes tools (#11265)
* feat(image_gen): multi-model FAL support with picker in hermes tools
Adds 8 FAL text-to-image models selectable via `hermes tools` →
Image Generation → (FAL.ai | Nous Subscription) → model picker.
Models supported:
- fal-ai/flux-2/klein/9b (new default, <1s, $0.006/MP)
- fal-ai/flux-2-pro (previous default, kept backward-compat upscaling)
- fal-ai/z-image/turbo (Tongyi-MAI, bilingual EN/CN)
- fal-ai/nano-banana (Gemini 2.5 Flash Image)
- fal-ai/gpt-image-1.5 (with quality tier: low/medium/high)
- fal-ai/ideogram/v3 (best typography)
- fal-ai/recraft-v3 (vector, brand styles)
- fal-ai/qwen-image (LLM-based)
Architecture:
- FAL_MODELS catalog declares per-model size family, defaults, supports
whitelist, and upscale flag. Three size families handled uniformly:
image_size_preset (flux family), aspect_ratio (nano-banana), and
gpt_literal (gpt-image-1.5).
- _build_fal_payload() translates unified inputs (prompt + aspect_ratio)
into model-specific payloads, merges defaults, applies caller overrides,
wires GPT quality_setting, then filters to the supports whitelist — so
models never receive rejected keys.
- IMAGEGEN_BACKENDS registry in tools_config prepares for future imagegen
providers (Replicate, Stability, etc.); each provider entry tags itself
with imagegen_backend: 'fal' to select the right catalog.
- Upscaler (Clarity) defaults off for new models (preserves <1s value
prop), on for flux-2-pro (backward-compat). Per-model via FAL_MODELS.
Config:
image_gen.model = fal-ai/flux-2/klein/9b (new)
image_gen.quality_setting = medium (new, GPT only)
image_gen.use_gateway = bool (existing)
Agent-facing schema unchanged (prompt + aspect_ratio only) — model
choice is a user-level config decision, not an agent-level arg.
Picker uses curses_radiolist (arrow keys, auto numbered-fallback on
non-TTY). Column-aligned: Model / Speed / Strengths / Price.
Docs: image-generation.md rewritten with the model table and picker
walkthrough. tools-reference, tool-gateway, overview updated to drop
the stale "FLUX 2 Pro" wording.
Tests: 42 new in tests/tools/test_image_generation.py covering catalog
integrity, all 3 size families, supports filter, default merging, GPT
quality wiring, model resolution fallback. 8 new in
tests/hermes_cli/test_tools_config.py for picker wiring (registry,
config writes, GPT quality follow-up prompt, corrupt-config repair).
* feat(image_gen): translate managed-gateway 4xx to actionable error
When the Nous Subscription managed FAL proxy rejects a model with 4xx
(likely portal-side allowlist miss or billing gate), surface a clear
message explaining:
1. The rejected model ID + HTTP status
2. Two remediation paths: set FAL_KEY for direct access, or
pick a different model via `hermes tools`
5xx, connection errors, and direct-FAL errors pass through unchanged
(those have different root causes and reasonable native messages).
Motivation: new FAL models added to this release (flux-2-klein-9b,
z-image-turbo, nano-banana, gpt-image-1.5, ideogram-v3, recraft-v3,
qwen-image) are untested against the Nous Portal proxy. If the portal
allowlists model IDs, users on Nous Subscription will hit cryptic
4xx errors without guidance on how to work around it.
Tests: 8 new cases covering status extraction across httpx/fal error
shapes and 4xx-vs-5xx-vs-ConnectionError translation policy.
Docs: brief note in image-generation.md for Nous subscribers.
Operator action (Nous Portal side): verify that fal-queue-gateway
passes through these 7 new FAL model IDs. If the proxy has an
allowlist, add them; otherwise Nous Subscription users will see the
new translated error and fall back to direct FAL.
* feat(image_gen): pin GPT-Image quality to medium (no user choice)
Previously the tools picker asked a follow-up question for GPT-Image
quality tier (low / medium / high) and persisted the answer to
`image_gen.quality_setting`. This created two problems:
1. Nous Portal billing complexity — the 22x cost spread between tiers
($0.009 low / $0.20 high) forces the gateway to meter per-tier per
user, which the portal team can't easily support at launch.
2. User footgun — anyone picking `high` by mistake burns through
credit ~6x faster than `medium`.
This commit pins quality at medium by baking it into FAL_MODELS
defaults for gpt-image-1.5 and removes all user-facing override paths:
- Removed `_resolve_gpt_quality()` runtime lookup
- Removed `honors_quality_setting` flag on the model entry
- Removed `_configure_gpt_quality_setting()` picker helper
- Removed `_GPT_QUALITY_CHOICES` constant
- Removed the follow-up prompt call in `_configure_imagegen_model()`
- Even if a user manually edits `image_gen.quality_setting` in
config.yaml, no code path reads it — always sends medium.
Tests:
- Replaced TestGptQualitySetting (6 tests) with TestGptQualityPinnedToMedium
(5 tests) — proves medium is baked in, config is ignored, flag is
removed, helper is removed, non-gpt models never get quality.
- Replaced test_picker_with_gpt_image_also_prompts_quality with
test_picker_with_gpt_image_does_not_prompt_quality — proves only 1
picker call fires when gpt-image is selected (no quality follow-up).
Docs updated: image-generation.md replaces the quality-tier table
with a short note explaining the pinning decision.
* docs(image_gen): drop stale 'wires GPT quality tier' line from internals section
Caught in a cleanup sweep after pinning quality to medium. The
"How It Works Internally" walkthrough still described the removed
quality-wiring step.
2026-04-16 20:19:53 -07:00
|
|
|
# Imagegen backends prompt for model selection on reconfig too.
|
|
|
|
|
backend = provider.get("imagegen_backend")
|
|
|
|
|
if backend:
|
|
|
|
|
_configure_imagegen_model(backend, config)
|
2026-04-22 22:50:38 -06:00
|
|
|
if backend == "fal":
|
|
|
|
|
img_cfg = config.setdefault("image_gen", {})
|
|
|
|
|
if isinstance(img_cfg, dict):
|
|
|
|
|
img_cfg["provider"] = "fal"
|
|
|
|
|
img_cfg["use_gateway"] = False
|
2026-03-06 18:11:35 -08:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
for var in env_vars:
|
|
|
|
|
existing = get_env_value(var["key"])
|
|
|
|
|
if existing:
|
|
|
|
|
_print_info(f" {var['key']}: configured ({existing[:8]}...)")
|
|
|
|
|
url = var.get("url", "")
|
|
|
|
|
if url:
|
|
|
|
|
_print_info(f" Get yours at: {url}")
|
|
|
|
|
default_val = var.get("default", "")
|
|
|
|
|
value = _prompt(f" {var.get('prompt', var['key'])} (Enter to keep current)", password=not default_val)
|
|
|
|
|
if value and value.strip():
|
|
|
|
|
save_env_value(var["key"], value.strip())
|
chore: fix 154 f-strings, simplify getattr/URL patterns, remove dead code (#3119)
Three categories of cleanup, all zero-behavioral-change:
1. F-strings without placeholders (154 fixes across 29 files)
- Converted f'...' to '...' where no {expression} was present
- Heaviest files: run_agent.py (24), cli.py (20), honcho_integration/cli.py (34)
2. Simplify defensive patterns in run_agent.py
- Added explicit self._is_anthropic_oauth = False in __init__ (before
the api_mode branch that conditionally sets it)
- Replaced 7x getattr(self, '_is_anthropic_oauth', False) with direct
self._is_anthropic_oauth (attribute always initialized now)
- Added _is_openrouter_url() and _is_anthropic_url() helper methods
- Replaced 3 inline 'openrouter' in self._base_url_lower checks
3. Remove dead code in small files
- hermes_cli/claw.py: removed unused 'total' computation
- tools/fuzzy_match.py: removed unused strip_indent() function and
pattern_stripped variable
Full test suite: 6184 passed, 0 failures
E2E PTY: banner clean, tool calls work, zero garbled ANSI
2026-03-25 19:47:58 -07:00
|
|
|
_print_success(" Updated")
|
2026-02-24 00:01:39 +00:00
|
|
|
else:
|
chore: fix 154 f-strings, simplify getattr/URL patterns, remove dead code (#3119)
Three categories of cleanup, all zero-behavioral-change:
1. F-strings without placeholders (154 fixes across 29 files)
- Converted f'...' to '...' where no {expression} was present
- Heaviest files: run_agent.py (24), cli.py (20), honcho_integration/cli.py (34)
2. Simplify defensive patterns in run_agent.py
- Added explicit self._is_anthropic_oauth = False in __init__ (before
the api_mode branch that conditionally sets it)
- Replaced 7x getattr(self, '_is_anthropic_oauth', False) with direct
self._is_anthropic_oauth (attribute always initialized now)
- Added _is_openrouter_url() and _is_anthropic_url() helper methods
- Replaced 3 inline 'openrouter' in self._base_url_lower checks
3. Remove dead code in small files
- hermes_cli/claw.py: removed unused 'total' computation
- tools/fuzzy_match.py: removed unused strip_indent() function and
pattern_stripped variable
Full test suite: 6184 passed, 0 failures
E2E PTY: banner clean, tool calls work, zero garbled ANSI
2026-03-25 19:47:58 -07:00
|
|
|
_print_info(" Kept current")
|
2026-03-06 18:11:35 -08:00
|
|
|
|
feat(image_gen): multi-model FAL support with picker in hermes tools (#11265)
* feat(image_gen): multi-model FAL support with picker in hermes tools
Adds 8 FAL text-to-image models selectable via `hermes tools` →
Image Generation → (FAL.ai | Nous Subscription) → model picker.
Models supported:
- fal-ai/flux-2/klein/9b (new default, <1s, $0.006/MP)
- fal-ai/flux-2-pro (previous default, kept backward-compat upscaling)
- fal-ai/z-image/turbo (Tongyi-MAI, bilingual EN/CN)
- fal-ai/nano-banana (Gemini 2.5 Flash Image)
- fal-ai/gpt-image-1.5 (with quality tier: low/medium/high)
- fal-ai/ideogram/v3 (best typography)
- fal-ai/recraft-v3 (vector, brand styles)
- fal-ai/qwen-image (LLM-based)
Architecture:
- FAL_MODELS catalog declares per-model size family, defaults, supports
whitelist, and upscale flag. Three size families handled uniformly:
image_size_preset (flux family), aspect_ratio (nano-banana), and
gpt_literal (gpt-image-1.5).
- _build_fal_payload() translates unified inputs (prompt + aspect_ratio)
into model-specific payloads, merges defaults, applies caller overrides,
wires GPT quality_setting, then filters to the supports whitelist — so
models never receive rejected keys.
- IMAGEGEN_BACKENDS registry in tools_config prepares for future imagegen
providers (Replicate, Stability, etc.); each provider entry tags itself
with imagegen_backend: 'fal' to select the right catalog.
- Upscaler (Clarity) defaults off for new models (preserves <1s value
prop), on for flux-2-pro (backward-compat). Per-model via FAL_MODELS.
Config:
image_gen.model = fal-ai/flux-2/klein/9b (new)
image_gen.quality_setting = medium (new, GPT only)
image_gen.use_gateway = bool (existing)
Agent-facing schema unchanged (prompt + aspect_ratio only) — model
choice is a user-level config decision, not an agent-level arg.
Picker uses curses_radiolist (arrow keys, auto numbered-fallback on
non-TTY). Column-aligned: Model / Speed / Strengths / Price.
Docs: image-generation.md rewritten with the model table and picker
walkthrough. tools-reference, tool-gateway, overview updated to drop
the stale "FLUX 2 Pro" wording.
Tests: 42 new in tests/tools/test_image_generation.py covering catalog
integrity, all 3 size families, supports filter, default merging, GPT
quality wiring, model resolution fallback. 8 new in
tests/hermes_cli/test_tools_config.py for picker wiring (registry,
config writes, GPT quality follow-up prompt, corrupt-config repair).
* feat(image_gen): translate managed-gateway 4xx to actionable error
When the Nous Subscription managed FAL proxy rejects a model with 4xx
(likely portal-side allowlist miss or billing gate), surface a clear
message explaining:
1. The rejected model ID + HTTP status
2. Two remediation paths: set FAL_KEY for direct access, or
pick a different model via `hermes tools`
5xx, connection errors, and direct-FAL errors pass through unchanged
(those have different root causes and reasonable native messages).
Motivation: new FAL models added to this release (flux-2-klein-9b,
z-image-turbo, nano-banana, gpt-image-1.5, ideogram-v3, recraft-v3,
qwen-image) are untested against the Nous Portal proxy. If the portal
allowlists model IDs, users on Nous Subscription will hit cryptic
4xx errors without guidance on how to work around it.
Tests: 8 new cases covering status extraction across httpx/fal error
shapes and 4xx-vs-5xx-vs-ConnectionError translation policy.
Docs: brief note in image-generation.md for Nous subscribers.
Operator action (Nous Portal side): verify that fal-queue-gateway
passes through these 7 new FAL model IDs. If the proxy has an
allowlist, add them; otherwise Nous Subscription users will see the
new translated error and fall back to direct FAL.
* feat(image_gen): pin GPT-Image quality to medium (no user choice)
Previously the tools picker asked a follow-up question for GPT-Image
quality tier (low / medium / high) and persisted the answer to
`image_gen.quality_setting`. This created two problems:
1. Nous Portal billing complexity — the 22x cost spread between tiers
($0.009 low / $0.20 high) forces the gateway to meter per-tier per
user, which the portal team can't easily support at launch.
2. User footgun — anyone picking `high` by mistake burns through
credit ~6x faster than `medium`.
This commit pins quality at medium by baking it into FAL_MODELS
defaults for gpt-image-1.5 and removes all user-facing override paths:
- Removed `_resolve_gpt_quality()` runtime lookup
- Removed `honors_quality_setting` flag on the model entry
- Removed `_configure_gpt_quality_setting()` picker helper
- Removed `_GPT_QUALITY_CHOICES` constant
- Removed the follow-up prompt call in `_configure_imagegen_model()`
- Even if a user manually edits `image_gen.quality_setting` in
config.yaml, no code path reads it — always sends medium.
Tests:
- Replaced TestGptQualitySetting (6 tests) with TestGptQualityPinnedToMedium
(5 tests) — proves medium is baked in, config is ignored, flag is
removed, helper is removed, non-gpt models never get quality.
- Replaced test_picker_with_gpt_image_also_prompts_quality with
test_picker_with_gpt_image_does_not_prompt_quality — proves only 1
picker call fires when gpt-image is selected (no quality follow-up).
Docs updated: image-generation.md replaces the quality-tier table
with a short note explaining the pinning decision.
* docs(image_gen): drop stale 'wires GPT quality tier' line from internals section
Caught in a cleanup sweep after pinning quality to medium. The
"How It Works Internally" walkthrough still described the removed
quality-wiring step.
2026-04-16 20:19:53 -07:00
|
|
|
# Imagegen backends prompt for model selection on reconfig too.
|
2026-04-22 22:50:38 -06:00
|
|
|
plugin_name = provider.get("image_gen_plugin_name")
|
|
|
|
|
if plugin_name:
|
|
|
|
|
_select_plugin_image_gen_provider(plugin_name, config)
|
|
|
|
|
return
|
|
|
|
|
|
feat(image_gen): multi-model FAL support with picker in hermes tools (#11265)
* feat(image_gen): multi-model FAL support with picker in hermes tools
Adds 8 FAL text-to-image models selectable via `hermes tools` →
Image Generation → (FAL.ai | Nous Subscription) → model picker.
Models supported:
- fal-ai/flux-2/klein/9b (new default, <1s, $0.006/MP)
- fal-ai/flux-2-pro (previous default, kept backward-compat upscaling)
- fal-ai/z-image/turbo (Tongyi-MAI, bilingual EN/CN)
- fal-ai/nano-banana (Gemini 2.5 Flash Image)
- fal-ai/gpt-image-1.5 (with quality tier: low/medium/high)
- fal-ai/ideogram/v3 (best typography)
- fal-ai/recraft-v3 (vector, brand styles)
- fal-ai/qwen-image (LLM-based)
Architecture:
- FAL_MODELS catalog declares per-model size family, defaults, supports
whitelist, and upscale flag. Three size families handled uniformly:
image_size_preset (flux family), aspect_ratio (nano-banana), and
gpt_literal (gpt-image-1.5).
- _build_fal_payload() translates unified inputs (prompt + aspect_ratio)
into model-specific payloads, merges defaults, applies caller overrides,
wires GPT quality_setting, then filters to the supports whitelist — so
models never receive rejected keys.
- IMAGEGEN_BACKENDS registry in tools_config prepares for future imagegen
providers (Replicate, Stability, etc.); each provider entry tags itself
with imagegen_backend: 'fal' to select the right catalog.
- Upscaler (Clarity) defaults off for new models (preserves <1s value
prop), on for flux-2-pro (backward-compat). Per-model via FAL_MODELS.
Config:
image_gen.model = fal-ai/flux-2/klein/9b (new)
image_gen.quality_setting = medium (new, GPT only)
image_gen.use_gateway = bool (existing)
Agent-facing schema unchanged (prompt + aspect_ratio only) — model
choice is a user-level config decision, not an agent-level arg.
Picker uses curses_radiolist (arrow keys, auto numbered-fallback on
non-TTY). Column-aligned: Model / Speed / Strengths / Price.
Docs: image-generation.md rewritten with the model table and picker
walkthrough. tools-reference, tool-gateway, overview updated to drop
the stale "FLUX 2 Pro" wording.
Tests: 42 new in tests/tools/test_image_generation.py covering catalog
integrity, all 3 size families, supports filter, default merging, GPT
quality wiring, model resolution fallback. 8 new in
tests/hermes_cli/test_tools_config.py for picker wiring (registry,
config writes, GPT quality follow-up prompt, corrupt-config repair).
* feat(image_gen): translate managed-gateway 4xx to actionable error
When the Nous Subscription managed FAL proxy rejects a model with 4xx
(likely portal-side allowlist miss or billing gate), surface a clear
message explaining:
1. The rejected model ID + HTTP status
2. Two remediation paths: set FAL_KEY for direct access, or
pick a different model via `hermes tools`
5xx, connection errors, and direct-FAL errors pass through unchanged
(those have different root causes and reasonable native messages).
Motivation: new FAL models added to this release (flux-2-klein-9b,
z-image-turbo, nano-banana, gpt-image-1.5, ideogram-v3, recraft-v3,
qwen-image) are untested against the Nous Portal proxy. If the portal
allowlists model IDs, users on Nous Subscription will hit cryptic
4xx errors without guidance on how to work around it.
Tests: 8 new cases covering status extraction across httpx/fal error
shapes and 4xx-vs-5xx-vs-ConnectionError translation policy.
Docs: brief note in image-generation.md for Nous subscribers.
Operator action (Nous Portal side): verify that fal-queue-gateway
passes through these 7 new FAL model IDs. If the proxy has an
allowlist, add them; otherwise Nous Subscription users will see the
new translated error and fall back to direct FAL.
* feat(image_gen): pin GPT-Image quality to medium (no user choice)
Previously the tools picker asked a follow-up question for GPT-Image
quality tier (low / medium / high) and persisted the answer to
`image_gen.quality_setting`. This created two problems:
1. Nous Portal billing complexity — the 22x cost spread between tiers
($0.009 low / $0.20 high) forces the gateway to meter per-tier per
user, which the portal team can't easily support at launch.
2. User footgun — anyone picking `high` by mistake burns through
credit ~6x faster than `medium`.
This commit pins quality at medium by baking it into FAL_MODELS
defaults for gpt-image-1.5 and removes all user-facing override paths:
- Removed `_resolve_gpt_quality()` runtime lookup
- Removed `honors_quality_setting` flag on the model entry
- Removed `_configure_gpt_quality_setting()` picker helper
- Removed `_GPT_QUALITY_CHOICES` constant
- Removed the follow-up prompt call in `_configure_imagegen_model()`
- Even if a user manually edits `image_gen.quality_setting` in
config.yaml, no code path reads it — always sends medium.
Tests:
- Replaced TestGptQualitySetting (6 tests) with TestGptQualityPinnedToMedium
(5 tests) — proves medium is baked in, config is ignored, flag is
removed, helper is removed, non-gpt models never get quality.
- Replaced test_picker_with_gpt_image_also_prompts_quality with
test_picker_with_gpt_image_does_not_prompt_quality — proves only 1
picker call fires when gpt-image is selected (no quality follow-up).
Docs updated: image-generation.md replaces the quality-tier table
with a short note explaining the pinning decision.
* docs(image_gen): drop stale 'wires GPT quality tier' line from internals section
Caught in a cleanup sweep after pinning quality to medium. The
"How It Works Internally" walkthrough still described the removed
quality-wiring step.
2026-04-16 20:19:53 -07:00
|
|
|
backend = provider.get("imagegen_backend")
|
|
|
|
|
if backend:
|
|
|
|
|
_configure_imagegen_model(backend, config)
|
2026-04-22 22:50:38 -06:00
|
|
|
if backend == "fal":
|
|
|
|
|
img_cfg = config.setdefault("image_gen", {})
|
|
|
|
|
if isinstance(img_cfg, dict):
|
|
|
|
|
img_cfg["provider"] = "fal"
|
|
|
|
|
img_cfg["use_gateway"] = False
|
feat(image_gen): multi-model FAL support with picker in hermes tools (#11265)
* feat(image_gen): multi-model FAL support with picker in hermes tools
Adds 8 FAL text-to-image models selectable via `hermes tools` →
Image Generation → (FAL.ai | Nous Subscription) → model picker.
Models supported:
- fal-ai/flux-2/klein/9b (new default, <1s, $0.006/MP)
- fal-ai/flux-2-pro (previous default, kept backward-compat upscaling)
- fal-ai/z-image/turbo (Tongyi-MAI, bilingual EN/CN)
- fal-ai/nano-banana (Gemini 2.5 Flash Image)
- fal-ai/gpt-image-1.5 (with quality tier: low/medium/high)
- fal-ai/ideogram/v3 (best typography)
- fal-ai/recraft-v3 (vector, brand styles)
- fal-ai/qwen-image (LLM-based)
Architecture:
- FAL_MODELS catalog declares per-model size family, defaults, supports
whitelist, and upscale flag. Three size families handled uniformly:
image_size_preset (flux family), aspect_ratio (nano-banana), and
gpt_literal (gpt-image-1.5).
- _build_fal_payload() translates unified inputs (prompt + aspect_ratio)
into model-specific payloads, merges defaults, applies caller overrides,
wires GPT quality_setting, then filters to the supports whitelist — so
models never receive rejected keys.
- IMAGEGEN_BACKENDS registry in tools_config prepares for future imagegen
providers (Replicate, Stability, etc.); each provider entry tags itself
with imagegen_backend: 'fal' to select the right catalog.
- Upscaler (Clarity) defaults off for new models (preserves <1s value
prop), on for flux-2-pro (backward-compat). Per-model via FAL_MODELS.
Config:
image_gen.model = fal-ai/flux-2/klein/9b (new)
image_gen.quality_setting = medium (new, GPT only)
image_gen.use_gateway = bool (existing)
Agent-facing schema unchanged (prompt + aspect_ratio only) — model
choice is a user-level config decision, not an agent-level arg.
Picker uses curses_radiolist (arrow keys, auto numbered-fallback on
non-TTY). Column-aligned: Model / Speed / Strengths / Price.
Docs: image-generation.md rewritten with the model table and picker
walkthrough. tools-reference, tool-gateway, overview updated to drop
the stale "FLUX 2 Pro" wording.
Tests: 42 new in tests/tools/test_image_generation.py covering catalog
integrity, all 3 size families, supports filter, default merging, GPT
quality wiring, model resolution fallback. 8 new in
tests/hermes_cli/test_tools_config.py for picker wiring (registry,
config writes, GPT quality follow-up prompt, corrupt-config repair).
* feat(image_gen): translate managed-gateway 4xx to actionable error
When the Nous Subscription managed FAL proxy rejects a model with 4xx
(likely portal-side allowlist miss or billing gate), surface a clear
message explaining:
1. The rejected model ID + HTTP status
2. Two remediation paths: set FAL_KEY for direct access, or
pick a different model via `hermes tools`
5xx, connection errors, and direct-FAL errors pass through unchanged
(those have different root causes and reasonable native messages).
Motivation: new FAL models added to this release (flux-2-klein-9b,
z-image-turbo, nano-banana, gpt-image-1.5, ideogram-v3, recraft-v3,
qwen-image) are untested against the Nous Portal proxy. If the portal
allowlists model IDs, users on Nous Subscription will hit cryptic
4xx errors without guidance on how to work around it.
Tests: 8 new cases covering status extraction across httpx/fal error
shapes and 4xx-vs-5xx-vs-ConnectionError translation policy.
Docs: brief note in image-generation.md for Nous subscribers.
Operator action (Nous Portal side): verify that fal-queue-gateway
passes through these 7 new FAL model IDs. If the proxy has an
allowlist, add them; otherwise Nous Subscription users will see the
new translated error and fall back to direct FAL.
* feat(image_gen): pin GPT-Image quality to medium (no user choice)
Previously the tools picker asked a follow-up question for GPT-Image
quality tier (low / medium / high) and persisted the answer to
`image_gen.quality_setting`. This created two problems:
1. Nous Portal billing complexity — the 22x cost spread between tiers
($0.009 low / $0.20 high) forces the gateway to meter per-tier per
user, which the portal team can't easily support at launch.
2. User footgun — anyone picking `high` by mistake burns through
credit ~6x faster than `medium`.
This commit pins quality at medium by baking it into FAL_MODELS
defaults for gpt-image-1.5 and removes all user-facing override paths:
- Removed `_resolve_gpt_quality()` runtime lookup
- Removed `honors_quality_setting` flag on the model entry
- Removed `_configure_gpt_quality_setting()` picker helper
- Removed `_GPT_QUALITY_CHOICES` constant
- Removed the follow-up prompt call in `_configure_imagegen_model()`
- Even if a user manually edits `image_gen.quality_setting` in
config.yaml, no code path reads it — always sends medium.
Tests:
- Replaced TestGptQualitySetting (6 tests) with TestGptQualityPinnedToMedium
(5 tests) — proves medium is baked in, config is ignored, flag is
removed, helper is removed, non-gpt models never get quality.
- Replaced test_picker_with_gpt_image_also_prompts_quality with
test_picker_with_gpt_image_does_not_prompt_quality — proves only 1
picker call fires when gpt-image is selected (no quality follow-up).
Docs updated: image-generation.md replaces the quality-tier table
with a short note explaining the pinning decision.
* docs(image_gen): drop stale 'wires GPT quality tier' line from internals section
Caught in a cleanup sweep after pinning quality to medium. The
"How It Works Internally" walkthrough still described the removed
quality-wiring step.
2026-04-16 20:19:53 -07:00
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
|
|
|
|
|
def _reconfigure_simple_requirements(ts_key: str):
|
|
|
|
|
"""Reconfigure simple env var requirements."""
|
|
|
|
|
requirements = TOOLSET_ENV_REQUIREMENTS.get(ts_key, [])
|
|
|
|
|
if not requirements:
|
|
|
|
|
return
|
2026-02-24 00:01:39 +00:00
|
|
|
|
2026-03-22 04:55:34 -07:00
|
|
|
ts_label = next((l for k, l, _ in _get_effective_configurable_toolsets() if k == ts_key), ts_key)
|
2026-03-06 18:11:35 -08:00
|
|
|
print()
|
|
|
|
|
print(color(f" {ts_label}:", Colors.CYAN))
|
|
|
|
|
|
|
|
|
|
for var, url in requirements:
|
|
|
|
|
existing = get_env_value(var)
|
|
|
|
|
if existing:
|
|
|
|
|
_print_info(f" {var}: configured ({existing[:8]}...)")
|
|
|
|
|
if url:
|
|
|
|
|
_print_info(f" Get key at: {url}")
|
|
|
|
|
value = _prompt(f" {var} (Enter to keep current)", password=True)
|
|
|
|
|
if value and value.strip():
|
|
|
|
|
save_env_value(var, value.strip())
|
chore: fix 154 f-strings, simplify getattr/URL patterns, remove dead code (#3119)
Three categories of cleanup, all zero-behavioral-change:
1. F-strings without placeholders (154 fixes across 29 files)
- Converted f'...' to '...' where no {expression} was present
- Heaviest files: run_agent.py (24), cli.py (20), honcho_integration/cli.py (34)
2. Simplify defensive patterns in run_agent.py
- Added explicit self._is_anthropic_oauth = False in __init__ (before
the api_mode branch that conditionally sets it)
- Replaced 7x getattr(self, '_is_anthropic_oauth', False) with direct
self._is_anthropic_oauth (attribute always initialized now)
- Added _is_openrouter_url() and _is_anthropic_url() helper methods
- Replaced 3 inline 'openrouter' in self._base_url_lower checks
3. Remove dead code in small files
- hermes_cli/claw.py: removed unused 'total' computation
- tools/fuzzy_match.py: removed unused strip_indent() function and
pattern_stripped variable
Full test suite: 6184 passed, 0 failures
E2E PTY: banner clean, tool calls work, zero garbled ANSI
2026-03-25 19:47:58 -07:00
|
|
|
_print_success(" Updated")
|
2026-03-06 18:11:35 -08:00
|
|
|
else:
|
chore: fix 154 f-strings, simplify getattr/URL patterns, remove dead code (#3119)
Three categories of cleanup, all zero-behavioral-change:
1. F-strings without placeholders (154 fixes across 29 files)
- Converted f'...' to '...' where no {expression} was present
- Heaviest files: run_agent.py (24), cli.py (20), honcho_integration/cli.py (34)
2. Simplify defensive patterns in run_agent.py
- Added explicit self._is_anthropic_oauth = False in __init__ (before
the api_mode branch that conditionally sets it)
- Replaced 7x getattr(self, '_is_anthropic_oauth', False) with direct
self._is_anthropic_oauth (attribute always initialized now)
- Added _is_openrouter_url() and _is_anthropic_url() helper methods
- Replaced 3 inline 'openrouter' in self._base_url_lower checks
3. Remove dead code in small files
- hermes_cli/claw.py: removed unused 'total' computation
- tools/fuzzy_match.py: removed unused strip_indent() function and
pattern_stripped variable
Full test suite: 6184 passed, 0 failures
E2E PTY: banner clean, tool calls work, zero garbled ANSI
2026-03-25 19:47:58 -07:00
|
|
|
_print_info(" Kept current")
|
2026-02-24 00:01:39 +00:00
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
|
|
|
|
|
# ─── Main Entry Point ─────────────────────────────────────────────────────────
|
|
|
|
|
|
2026-03-08 23:39:00 -07:00
|
|
|
def tools_command(args=None, first_install: bool = False, config: dict = None):
|
2026-03-08 23:06:31 -07:00
|
|
|
"""Entry point for `hermes tools` and `hermes setup tools`.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
first_install: When True (set by the setup wizard on fresh installs),
|
|
|
|
|
skip the platform menu, go straight to the CLI checklist, and
|
|
|
|
|
prompt for API keys on all enabled tools that need them.
|
2026-03-08 23:39:00 -07:00
|
|
|
config: Optional config dict to use. When called from the setup
|
|
|
|
|
wizard, the wizard passes its own dict so that platform_toolsets
|
|
|
|
|
are written into it and survive the wizard's final save_config().
|
2026-03-08 23:06:31 -07:00
|
|
|
"""
|
2026-03-08 23:39:00 -07:00
|
|
|
if config is None:
|
|
|
|
|
config = load_config()
|
2026-02-23 23:52:07 +00:00
|
|
|
enabled_platforms = _get_enabled_platforms()
|
|
|
|
|
|
|
|
|
|
print()
|
2026-03-09 16:50:53 +03:00
|
|
|
|
|
|
|
|
# Non-interactive summary mode for CLI usage
|
|
|
|
|
if getattr(args, "summary", False):
|
2026-03-22 04:55:34 -07:00
|
|
|
total = len(_get_effective_configurable_toolsets())
|
2026-03-11 00:47:26 -07:00
|
|
|
print(color("⚕ Tool Summary", Colors.CYAN, Colors.BOLD))
|
|
|
|
|
print()
|
2026-03-09 16:50:53 +03:00
|
|
|
summary = _platform_toolset_summary(config, enabled_platforms)
|
|
|
|
|
for pkey in enabled_platforms:
|
|
|
|
|
pinfo = PLATFORMS[pkey]
|
|
|
|
|
enabled = summary.get(pkey, set())
|
2026-03-11 00:47:26 -07:00
|
|
|
count = len(enabled)
|
|
|
|
|
print(color(f" {pinfo['label']}", Colors.BOLD) + color(f" ({count}/{total})", Colors.DIM))
|
|
|
|
|
if enabled:
|
2026-03-09 16:50:53 +03:00
|
|
|
for ts_key in sorted(enabled):
|
2026-03-22 04:55:34 -07:00
|
|
|
label = next((l for k, l, _ in _get_effective_configurable_toolsets() if k == ts_key), ts_key)
|
2026-03-11 00:47:26 -07:00
|
|
|
print(color(f" ✓ {label}", Colors.GREEN))
|
|
|
|
|
else:
|
|
|
|
|
print(color(" (none enabled)", Colors.DIM))
|
2026-03-09 16:50:53 +03:00
|
|
|
print()
|
|
|
|
|
return
|
2026-02-23 23:52:07 +00:00
|
|
|
print(color("⚕ Hermes Tool Configuration", Colors.CYAN, Colors.BOLD))
|
|
|
|
|
print(color(" Enable or disable tools per platform.", Colors.DIM))
|
2026-03-06 18:11:35 -08:00
|
|
|
print(color(" Tools that need API keys will be configured when enabled.", Colors.DIM))
|
2026-04-05 11:46:13 -07:00
|
|
|
print(color(" Guide: https://hermes-agent.nousresearch.com/docs/user-guide/features/tools", Colors.DIM))
|
2026-02-23 23:52:07 +00:00
|
|
|
print()
|
|
|
|
|
|
2026-03-08 23:06:31 -07:00
|
|
|
# ── First-time install: linear flow, no platform menu ──
|
|
|
|
|
if first_install:
|
|
|
|
|
for pkey in enabled_platforms:
|
|
|
|
|
pinfo = PLATFORMS[pkey]
|
2026-03-26 13:39:41 -07:00
|
|
|
current_enabled = _get_platform_tools(config, pkey, include_default_mcp_servers=False)
|
2026-03-08 23:06:31 -07:00
|
|
|
|
|
|
|
|
# Uncheck toolsets that should be off by default
|
|
|
|
|
checklist_preselected = current_enabled - _DEFAULT_OFF_TOOLSETS
|
|
|
|
|
|
|
|
|
|
# Show checklist
|
|
|
|
|
new_enabled = _prompt_toolset_checklist(pinfo["label"], checklist_preselected)
|
|
|
|
|
|
|
|
|
|
added = new_enabled - current_enabled
|
|
|
|
|
removed = current_enabled - new_enabled
|
|
|
|
|
if added:
|
|
|
|
|
for ts in sorted(added):
|
2026-03-22 04:55:34 -07:00
|
|
|
label = next((l for k, l, _ in _get_effective_configurable_toolsets() if k == ts), ts)
|
2026-03-08 23:06:31 -07:00
|
|
|
print(color(f" + {label}", Colors.GREEN))
|
|
|
|
|
if removed:
|
|
|
|
|
for ts in sorted(removed):
|
2026-03-22 04:55:34 -07:00
|
|
|
label = next((l for k, l, _ in _get_effective_configurable_toolsets() if k == ts), ts)
|
2026-03-08 23:06:31 -07:00
|
|
|
print(color(f" - {label}", Colors.RED))
|
|
|
|
|
|
2026-03-26 15:27:27 -07:00
|
|
|
auto_configured = apply_nous_managed_defaults(
|
|
|
|
|
config,
|
|
|
|
|
enabled_toolsets=new_enabled,
|
|
|
|
|
)
|
2026-03-30 13:28:10 +09:00
|
|
|
if managed_nous_tools_enabled():
|
|
|
|
|
for ts_key in sorted(auto_configured):
|
|
|
|
|
label = next((l for k, l, _ in CONFIGURABLE_TOOLSETS if k == ts_key), ts_key)
|
|
|
|
|
print(color(f" ✓ {label}: using your Nous subscription defaults", Colors.GREEN))
|
2026-03-26 15:27:27 -07:00
|
|
|
|
2026-03-08 23:15:14 -07:00
|
|
|
# Walk through ALL selected tools that have provider options or
|
|
|
|
|
# need API keys. This ensures browser (Local vs Browserbase),
|
|
|
|
|
# TTS (Edge vs OpenAI vs ElevenLabs), etc. are shown even when
|
|
|
|
|
# a free provider exists.
|
|
|
|
|
to_configure = [
|
2026-03-08 23:06:31 -07:00
|
|
|
ts_key for ts_key in sorted(new_enabled)
|
2026-03-26 15:27:27 -07:00
|
|
|
if (TOOL_CATEGORIES.get(ts_key) or TOOLSET_ENV_REQUIREMENTS.get(ts_key))
|
|
|
|
|
and ts_key not in auto_configured
|
2026-03-08 23:06:31 -07:00
|
|
|
]
|
|
|
|
|
|
2026-03-08 23:15:14 -07:00
|
|
|
if to_configure:
|
2026-03-08 23:06:31 -07:00
|
|
|
print()
|
2026-03-08 23:15:14 -07:00
|
|
|
print(color(f" Configuring {len(to_configure)} tool(s):", Colors.YELLOW))
|
|
|
|
|
for ts_key in to_configure:
|
2026-03-22 04:55:34 -07:00
|
|
|
label = next((l for k, l, _ in _get_effective_configurable_toolsets() if k == ts_key), ts_key)
|
2026-03-08 23:06:31 -07:00
|
|
|
print(color(f" • {label}", Colors.DIM))
|
2026-03-08 23:15:14 -07:00
|
|
|
print(color(" You can skip any tool you don't need right now.", Colors.DIM))
|
2026-03-08 23:06:31 -07:00
|
|
|
print()
|
2026-03-08 23:15:14 -07:00
|
|
|
for ts_key in to_configure:
|
2026-03-08 23:06:31 -07:00
|
|
|
_configure_toolset(ts_key, config)
|
|
|
|
|
|
|
|
|
|
_save_platform_tools(config, pkey, new_enabled)
|
|
|
|
|
save_config(config)
|
|
|
|
|
print(color(f" ✓ Saved {pinfo['label']} tool configuration", Colors.GREEN))
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# ── Returning user: platform menu loop ──
|
2026-02-23 23:52:07 +00:00
|
|
|
# Build platform choices
|
|
|
|
|
platform_choices = []
|
|
|
|
|
platform_keys = []
|
|
|
|
|
for pkey in enabled_platforms:
|
|
|
|
|
pinfo = PLATFORMS[pkey]
|
2026-03-26 13:39:41 -07:00
|
|
|
current = _get_platform_tools(config, pkey, include_default_mcp_servers=False)
|
2026-02-23 23:52:07 +00:00
|
|
|
count = len(current)
|
2026-03-22 04:55:34 -07:00
|
|
|
total = len(_get_effective_configurable_toolsets())
|
2026-02-23 23:54:38 +00:00
|
|
|
platform_choices.append(f"Configure {pinfo['label']} ({count}/{total} enabled)")
|
2026-02-23 23:52:07 +00:00
|
|
|
platform_keys.append(pkey)
|
|
|
|
|
|
2026-03-10 23:49:03 -07:00
|
|
|
if len(platform_keys) > 1:
|
|
|
|
|
platform_choices.append("Configure all platforms (global)")
|
2026-03-06 18:11:35 -08:00
|
|
|
platform_choices.append("Reconfigure an existing tool's provider or API key")
|
2026-03-17 03:48:44 -07:00
|
|
|
|
|
|
|
|
# Show MCP option if any MCP servers are configured
|
|
|
|
|
_has_mcp = bool(config.get("mcp_servers"))
|
|
|
|
|
if _has_mcp:
|
|
|
|
|
platform_choices.append("Configure MCP server tools")
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
platform_choices.append("Done")
|
2026-02-23 23:52:07 +00:00
|
|
|
|
2026-03-10 23:49:03 -07:00
|
|
|
# Index offsets for the extra options after per-platform entries
|
|
|
|
|
_global_idx = len(platform_keys) if len(platform_keys) > 1 else -1
|
|
|
|
|
_reconfig_idx = len(platform_keys) + (1 if len(platform_keys) > 1 else 0)
|
2026-03-17 03:48:44 -07:00
|
|
|
_mcp_idx = (_reconfig_idx + 1) if _has_mcp else -1
|
|
|
|
|
_done_idx = _reconfig_idx + (2 if _has_mcp else 1)
|
2026-03-10 23:49:03 -07:00
|
|
|
|
2026-02-23 23:52:07 +00:00
|
|
|
while True:
|
2026-03-06 18:11:35 -08:00
|
|
|
idx = _prompt_choice("Select an option:", platform_choices, default=0)
|
2026-02-23 23:52:07 +00:00
|
|
|
|
|
|
|
|
# "Done" selected
|
2026-03-10 23:49:03 -07:00
|
|
|
if idx == _done_idx:
|
2026-02-23 23:52:07 +00:00
|
|
|
break
|
|
|
|
|
|
2026-03-06 18:11:35 -08:00
|
|
|
# "Reconfigure" selected
|
2026-03-10 23:49:03 -07:00
|
|
|
if idx == _reconfig_idx:
|
2026-03-06 18:11:35 -08:00
|
|
|
_reconfigure_tool(config)
|
|
|
|
|
print()
|
|
|
|
|
continue
|
|
|
|
|
|
2026-03-17 03:48:44 -07:00
|
|
|
# "Configure MCP tools" selected
|
|
|
|
|
if idx == _mcp_idx:
|
|
|
|
|
_configure_mcp_tools_interactive(config)
|
|
|
|
|
print()
|
|
|
|
|
continue
|
|
|
|
|
|
2026-03-10 23:49:03 -07:00
|
|
|
# "Configure all platforms (global)" selected
|
|
|
|
|
if idx == _global_idx:
|
|
|
|
|
# Use the union of all platforms' current tools as the starting state
|
|
|
|
|
all_current = set()
|
|
|
|
|
for pk in platform_keys:
|
2026-03-26 13:39:41 -07:00
|
|
|
all_current |= _get_platform_tools(config, pk, include_default_mcp_servers=False)
|
2026-03-10 23:49:03 -07:00
|
|
|
new_enabled = _prompt_toolset_checklist("All platforms", all_current)
|
|
|
|
|
if new_enabled != all_current:
|
|
|
|
|
for pk in platform_keys:
|
2026-03-26 13:39:41 -07:00
|
|
|
prev = _get_platform_tools(config, pk, include_default_mcp_servers=False)
|
2026-03-10 23:49:03 -07:00
|
|
|
added = new_enabled - prev
|
|
|
|
|
removed = prev - new_enabled
|
|
|
|
|
pinfo_inner = PLATFORMS[pk]
|
|
|
|
|
if added or removed:
|
|
|
|
|
print(color(f" {pinfo_inner['label']}:", Colors.DIM))
|
|
|
|
|
for ts in sorted(added):
|
2026-03-22 04:55:34 -07:00
|
|
|
label = next((l for k, l, _ in _get_effective_configurable_toolsets() if k == ts), ts)
|
2026-03-10 23:49:03 -07:00
|
|
|
print(color(f" + {label}", Colors.GREEN))
|
|
|
|
|
for ts in sorted(removed):
|
2026-03-22 04:55:34 -07:00
|
|
|
label = next((l for k, l, _ in _get_effective_configurable_toolsets() if k == ts), ts)
|
2026-03-10 23:49:03 -07:00
|
|
|
print(color(f" - {label}", Colors.RED))
|
|
|
|
|
# Configure API keys for newly enabled tools
|
|
|
|
|
for ts_key in sorted(added):
|
|
|
|
|
if (TOOL_CATEGORIES.get(ts_key) or TOOLSET_ENV_REQUIREMENTS.get(ts_key)):
|
2026-03-26 15:27:27 -07:00
|
|
|
if _toolset_needs_configuration_prompt(ts_key, config):
|
2026-03-10 23:49:03 -07:00
|
|
|
_configure_toolset(ts_key, config)
|
|
|
|
|
_save_platform_tools(config, pk, new_enabled)
|
|
|
|
|
save_config(config)
|
|
|
|
|
print(color(" ✓ Saved configuration for all platforms", Colors.GREEN))
|
|
|
|
|
# Update choice labels
|
|
|
|
|
for ci, pk in enumerate(platform_keys):
|
2026-03-26 13:39:41 -07:00
|
|
|
new_count = len(_get_platform_tools(config, pk, include_default_mcp_servers=False))
|
2026-03-22 04:55:34 -07:00
|
|
|
total = len(_get_effective_configurable_toolsets())
|
2026-03-10 23:49:03 -07:00
|
|
|
platform_choices[ci] = f"Configure {PLATFORMS[pk]['label']} ({new_count}/{total} enabled)"
|
|
|
|
|
else:
|
|
|
|
|
print(color(" No changes", Colors.DIM))
|
|
|
|
|
print()
|
|
|
|
|
continue
|
|
|
|
|
|
2026-02-23 23:52:07 +00:00
|
|
|
pkey = platform_keys[idx]
|
|
|
|
|
pinfo = PLATFORMS[pkey]
|
|
|
|
|
|
|
|
|
|
# Get current enabled toolsets for this platform
|
2026-03-26 13:39:41 -07:00
|
|
|
current_enabled = _get_platform_tools(config, pkey, include_default_mcp_servers=False)
|
2026-02-23 23:52:07 +00:00
|
|
|
|
2026-03-08 22:54:11 -07:00
|
|
|
# Show checklist
|
2026-03-08 23:06:31 -07:00
|
|
|
new_enabled = _prompt_toolset_checklist(pinfo["label"], current_enabled)
|
2026-03-08 22:54:11 -07:00
|
|
|
|
2026-03-08 23:06:31 -07:00
|
|
|
if new_enabled != current_enabled:
|
2026-02-23 23:52:07 +00:00
|
|
|
added = new_enabled - current_enabled
|
|
|
|
|
removed = current_enabled - new_enabled
|
|
|
|
|
|
|
|
|
|
if added:
|
|
|
|
|
for ts in sorted(added):
|
2026-03-22 04:55:34 -07:00
|
|
|
label = next((l for k, l, _ in _get_effective_configurable_toolsets() if k == ts), ts)
|
2026-02-23 23:52:07 +00:00
|
|
|
print(color(f" + {label}", Colors.GREEN))
|
|
|
|
|
if removed:
|
|
|
|
|
for ts in sorted(removed):
|
2026-03-22 04:55:34 -07:00
|
|
|
label = next((l for k, l, _ in _get_effective_configurable_toolsets() if k == ts), ts)
|
2026-02-23 23:52:07 +00:00
|
|
|
print(color(f" - {label}", Colors.RED))
|
|
|
|
|
|
2026-03-08 23:06:31 -07:00
|
|
|
# Configure newly enabled toolsets that need API keys
|
|
|
|
|
for ts_key in sorted(added):
|
|
|
|
|
if (TOOL_CATEGORIES.get(ts_key) or TOOLSET_ENV_REQUIREMENTS.get(ts_key)):
|
2026-03-26 15:27:27 -07:00
|
|
|
if _toolset_needs_configuration_prompt(ts_key, config):
|
2026-03-08 23:06:31 -07:00
|
|
|
_configure_toolset(ts_key, config)
|
2026-02-24 00:01:39 +00:00
|
|
|
|
|
|
|
|
_save_platform_tools(config, pkey, new_enabled)
|
2026-03-06 18:11:35 -08:00
|
|
|
save_config(config)
|
2026-02-23 23:52:07 +00:00
|
|
|
print(color(f" ✓ Saved {pinfo['label']} configuration", Colors.GREEN))
|
|
|
|
|
else:
|
|
|
|
|
print(color(f" No changes to {pinfo['label']}", Colors.DIM))
|
|
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
# Update the choice label with new count
|
2026-03-26 13:39:41 -07:00
|
|
|
new_count = len(_get_platform_tools(config, pkey, include_default_mcp_servers=False))
|
2026-03-22 04:55:34 -07:00
|
|
|
total = len(_get_effective_configurable_toolsets())
|
2026-02-23 23:54:38 +00:00
|
|
|
platform_choices[idx] = f"Configure {pinfo['label']} ({new_count}/{total} enabled)"
|
2026-02-23 23:52:07 +00:00
|
|
|
|
|
|
|
|
print()
|
2026-03-28 23:47:21 -07:00
|
|
|
from hermes_constants import display_hermes_home
|
|
|
|
|
print(color(f" Tool configuration saved to {display_hermes_home()}/config.yaml", Colors.DIM))
|
2026-02-23 23:52:07 +00:00
|
|
|
print(color(" Changes take effect on next 'hermes' or gateway restart.", Colors.DIM))
|
|
|
|
|
print()
|
2026-03-17 02:05:26 -07:00
|
|
|
|
|
|
|
|
|
2026-03-17 03:48:44 -07:00
|
|
|
# ─── MCP Tools Interactive Configuration ─────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _configure_mcp_tools_interactive(config: dict):
|
|
|
|
|
"""Probe MCP servers for available tools and let user toggle them on/off.
|
|
|
|
|
|
|
|
|
|
Connects to each configured MCP server, discovers tools, then shows
|
|
|
|
|
a per-server curses checklist. Writes changes back as ``tools.exclude``
|
|
|
|
|
entries in config.yaml.
|
|
|
|
|
"""
|
|
|
|
|
from hermes_cli.curses_ui import curses_checklist
|
|
|
|
|
|
|
|
|
|
mcp_servers = config.get("mcp_servers") or {}
|
|
|
|
|
if not mcp_servers:
|
|
|
|
|
_print_info("No MCP servers configured.")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# Count enabled servers
|
|
|
|
|
enabled_names = [
|
|
|
|
|
k for k, v in mcp_servers.items()
|
|
|
|
|
if v.get("enabled", True) not in (False, "false", "0", "no", "off")
|
|
|
|
|
]
|
|
|
|
|
if not enabled_names:
|
|
|
|
|
_print_info("All MCP servers are disabled.")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
print(color(" Discovering tools from MCP servers...", Colors.YELLOW))
|
|
|
|
|
print(color(f" Connecting to {len(enabled_names)} server(s): {', '.join(enabled_names)}", Colors.DIM))
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
from tools.mcp_tool import probe_mcp_server_tools
|
|
|
|
|
server_tools = probe_mcp_server_tools()
|
|
|
|
|
except Exception as exc:
|
|
|
|
|
_print_error(f"Failed to probe MCP servers: {exc}")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if not server_tools:
|
|
|
|
|
_print_warning("Could not discover tools from any MCP server.")
|
|
|
|
|
_print_info("Check that server commands/URLs are correct and dependencies are installed.")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# Report discovery results
|
|
|
|
|
failed = [n for n in enabled_names if n not in server_tools]
|
|
|
|
|
if failed:
|
|
|
|
|
for name in failed:
|
|
|
|
|
_print_warning(f" Could not connect to '{name}'")
|
|
|
|
|
|
|
|
|
|
total_tools = sum(len(tools) for tools in server_tools.values())
|
|
|
|
|
print(color(f" Found {total_tools} tool(s) across {len(server_tools)} server(s)", Colors.GREEN))
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
any_changes = False
|
|
|
|
|
|
|
|
|
|
for server_name, tools in server_tools.items():
|
|
|
|
|
if not tools:
|
|
|
|
|
_print_info(f" {server_name}: no tools found")
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
srv_cfg = mcp_servers.get(server_name, {})
|
|
|
|
|
tools_cfg = srv_cfg.get("tools") or {}
|
|
|
|
|
include_list = tools_cfg.get("include") or []
|
|
|
|
|
exclude_list = tools_cfg.get("exclude") or []
|
|
|
|
|
|
|
|
|
|
# Build checklist labels
|
|
|
|
|
labels = []
|
|
|
|
|
for tool_name, description in tools:
|
|
|
|
|
desc_short = description[:70] + "..." if len(description) > 70 else description
|
|
|
|
|
if desc_short:
|
|
|
|
|
labels.append(f"{tool_name} ({desc_short})")
|
|
|
|
|
else:
|
|
|
|
|
labels.append(tool_name)
|
|
|
|
|
|
|
|
|
|
# Determine which tools are currently enabled
|
|
|
|
|
pre_selected: Set[int] = set()
|
|
|
|
|
tool_names = [t[0] for t in tools]
|
|
|
|
|
for i, tool_name in enumerate(tool_names):
|
|
|
|
|
if include_list:
|
|
|
|
|
# Include mode: only included tools are selected
|
|
|
|
|
if tool_name in include_list:
|
|
|
|
|
pre_selected.add(i)
|
|
|
|
|
elif exclude_list:
|
|
|
|
|
# Exclude mode: everything except excluded
|
|
|
|
|
if tool_name not in exclude_list:
|
|
|
|
|
pre_selected.add(i)
|
|
|
|
|
else:
|
|
|
|
|
# No filter: all enabled
|
|
|
|
|
pre_selected.add(i)
|
|
|
|
|
|
|
|
|
|
chosen = curses_checklist(
|
|
|
|
|
f"MCP Server: {server_name} ({len(tools)} tools)",
|
|
|
|
|
labels,
|
|
|
|
|
pre_selected,
|
|
|
|
|
cancel_returns=pre_selected,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if chosen == pre_selected:
|
|
|
|
|
_print_info(f" {server_name}: no changes")
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
# Compute new exclude list based on unchecked tools
|
|
|
|
|
new_exclude = [tool_names[i] for i in range(len(tool_names)) if i not in chosen]
|
|
|
|
|
|
|
|
|
|
# Update config
|
|
|
|
|
srv_cfg = mcp_servers.setdefault(server_name, {})
|
|
|
|
|
tools_cfg = srv_cfg.setdefault("tools", {})
|
|
|
|
|
|
|
|
|
|
if new_exclude:
|
|
|
|
|
tools_cfg["exclude"] = new_exclude
|
|
|
|
|
# Remove include if present — we're switching to exclude mode
|
|
|
|
|
tools_cfg.pop("include", None)
|
|
|
|
|
else:
|
|
|
|
|
# All tools enabled — clear filters
|
|
|
|
|
tools_cfg.pop("exclude", None)
|
|
|
|
|
tools_cfg.pop("include", None)
|
|
|
|
|
|
|
|
|
|
enabled_count = len(chosen)
|
|
|
|
|
disabled_count = len(tools) - enabled_count
|
|
|
|
|
_print_success(
|
|
|
|
|
f" {server_name}: {enabled_count} enabled, {disabled_count} disabled"
|
|
|
|
|
)
|
|
|
|
|
any_changes = True
|
|
|
|
|
|
|
|
|
|
if any_changes:
|
|
|
|
|
save_config(config)
|
|
|
|
|
print()
|
|
|
|
|
print(color(" ✓ MCP tool configuration saved", Colors.GREEN))
|
|
|
|
|
else:
|
|
|
|
|
print(color(" No changes to MCP tools", Colors.DIM))
|
|
|
|
|
|
|
|
|
|
|
2026-03-17 02:05:26 -07:00
|
|
|
# ─── Non-interactive disable/enable ──────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _apply_toolset_change(config: dict, platform: str, toolset_names: List[str], action: str):
|
|
|
|
|
"""Add or remove built-in toolsets for a platform."""
|
2026-03-26 13:39:41 -07:00
|
|
|
enabled = _get_platform_tools(config, platform, include_default_mcp_servers=False)
|
2026-03-17 02:05:26 -07:00
|
|
|
if action == "disable":
|
|
|
|
|
updated = enabled - set(toolset_names)
|
|
|
|
|
else:
|
|
|
|
|
updated = enabled | set(toolset_names)
|
|
|
|
|
_save_platform_tools(config, platform, updated)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _apply_mcp_change(config: dict, targets: List[str], action: str) -> Set[str]:
|
|
|
|
|
"""Add or remove specific MCP tools from a server's exclude list.
|
|
|
|
|
|
|
|
|
|
Returns the set of server names that were not found in config.
|
|
|
|
|
"""
|
|
|
|
|
failed_servers: Set[str] = set()
|
|
|
|
|
mcp_servers = config.get("mcp_servers") or {}
|
|
|
|
|
|
|
|
|
|
for target in targets:
|
|
|
|
|
server_name, tool_name = target.split(":", 1)
|
|
|
|
|
if server_name not in mcp_servers:
|
|
|
|
|
failed_servers.add(server_name)
|
|
|
|
|
continue
|
|
|
|
|
tools_cfg = mcp_servers[server_name].setdefault("tools", {})
|
|
|
|
|
exclude = list(tools_cfg.get("exclude") or [])
|
|
|
|
|
if action == "disable":
|
|
|
|
|
if tool_name not in exclude:
|
|
|
|
|
exclude.append(tool_name)
|
|
|
|
|
else:
|
|
|
|
|
exclude = [t for t in exclude if t != tool_name]
|
|
|
|
|
tools_cfg["exclude"] = exclude
|
|
|
|
|
|
|
|
|
|
return failed_servers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _print_tools_list(enabled_toolsets: set, mcp_servers: dict, platform: str = "cli"):
|
|
|
|
|
"""Print a summary of enabled/disabled toolsets and MCP tool filters."""
|
2026-03-22 04:55:34 -07:00
|
|
|
effective = _get_effective_configurable_toolsets()
|
|
|
|
|
builtin_keys = {ts_key for ts_key, _, _ in CONFIGURABLE_TOOLSETS}
|
|
|
|
|
|
2026-03-17 02:05:26 -07:00
|
|
|
print(f"Built-in toolsets ({platform}):")
|
2026-03-22 04:55:34 -07:00
|
|
|
for ts_key, label, _ in effective:
|
|
|
|
|
if ts_key not in builtin_keys:
|
|
|
|
|
continue
|
2026-03-17 02:05:26 -07:00
|
|
|
status = (color("✓ enabled", Colors.GREEN) if ts_key in enabled_toolsets
|
|
|
|
|
else color("✗ disabled", Colors.RED))
|
|
|
|
|
print(f" {status} {ts_key} {color(label, Colors.DIM)}")
|
|
|
|
|
|
2026-03-22 04:55:34 -07:00
|
|
|
# Plugin toolsets
|
|
|
|
|
plugin_entries = [(k, l) for k, l, _ in effective if k not in builtin_keys]
|
|
|
|
|
if plugin_entries:
|
|
|
|
|
print()
|
|
|
|
|
print(f"Plugin toolsets ({platform}):")
|
|
|
|
|
for ts_key, label in plugin_entries:
|
|
|
|
|
status = (color("✓ enabled", Colors.GREEN) if ts_key in enabled_toolsets
|
|
|
|
|
else color("✗ disabled", Colors.RED))
|
|
|
|
|
print(f" {status} {ts_key} {color(label, Colors.DIM)}")
|
|
|
|
|
|
2026-03-17 02:05:26 -07:00
|
|
|
if mcp_servers:
|
|
|
|
|
print()
|
|
|
|
|
print("MCP servers:")
|
|
|
|
|
for srv_name, srv_cfg in mcp_servers.items():
|
|
|
|
|
tools_cfg = srv_cfg.get("tools") or {}
|
|
|
|
|
exclude = tools_cfg.get("exclude") or []
|
|
|
|
|
include = tools_cfg.get("include") or []
|
|
|
|
|
if include:
|
|
|
|
|
_print_info(f"{srv_name} [include only: {', '.join(include)}]")
|
|
|
|
|
elif exclude:
|
|
|
|
|
_print_info(f"{srv_name} [excluded: {color(', '.join(exclude), Colors.YELLOW)}]")
|
|
|
|
|
else:
|
|
|
|
|
_print_info(f"{srv_name} {color('all tools enabled', Colors.DIM)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tools_disable_enable_command(args):
|
|
|
|
|
"""Enable, disable, or list tools for a platform.
|
|
|
|
|
|
|
|
|
|
Built-in toolsets use plain names (e.g. ``web``, ``memory``).
|
|
|
|
|
MCP tools use ``server:tool`` notation (e.g. ``github:create_issue``).
|
|
|
|
|
"""
|
|
|
|
|
action = args.tools_action
|
|
|
|
|
platform = getattr(args, "platform", "cli")
|
|
|
|
|
config = load_config()
|
|
|
|
|
|
|
|
|
|
if platform not in PLATFORMS:
|
|
|
|
|
_print_error(f"Unknown platform '{platform}'. Valid: {', '.join(PLATFORMS)}")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if action == "list":
|
2026-03-26 13:39:41 -07:00
|
|
|
_print_tools_list(_get_platform_tools(config, platform, include_default_mcp_servers=False),
|
2026-03-17 02:05:26 -07:00
|
|
|
config.get("mcp_servers") or {}, platform)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
targets: List[str] = args.names
|
|
|
|
|
toolset_targets = [t for t in targets if ":" not in t]
|
|
|
|
|
mcp_targets = [t for t in targets if ":" in t]
|
|
|
|
|
|
2026-03-22 04:55:34 -07:00
|
|
|
valid_toolsets = {ts_key for ts_key, _, _ in CONFIGURABLE_TOOLSETS} | _get_plugin_toolset_keys()
|
2026-03-17 02:05:26 -07:00
|
|
|
unknown_toolsets = [t for t in toolset_targets if t not in valid_toolsets]
|
|
|
|
|
if unknown_toolsets:
|
|
|
|
|
for name in unknown_toolsets:
|
|
|
|
|
_print_error(f"Unknown toolset '{name}'")
|
|
|
|
|
toolset_targets = [t for t in toolset_targets if t in valid_toolsets]
|
|
|
|
|
|
|
|
|
|
if toolset_targets:
|
|
|
|
|
_apply_toolset_change(config, platform, toolset_targets, action)
|
|
|
|
|
|
|
|
|
|
failed_servers: Set[str] = set()
|
|
|
|
|
if mcp_targets:
|
|
|
|
|
failed_servers = _apply_mcp_change(config, mcp_targets, action)
|
|
|
|
|
for srv in failed_servers:
|
|
|
|
|
_print_error(f"MCP server '{srv}' not found in config")
|
|
|
|
|
|
|
|
|
|
save_config(config)
|
|
|
|
|
|
|
|
|
|
successful = [
|
|
|
|
|
t for t in targets
|
|
|
|
|
if t not in unknown_toolsets and (":" not in t or t.split(":")[0] not in failed_servers)
|
|
|
|
|
]
|
|
|
|
|
if successful:
|
|
|
|
|
verb = "Disabled" if action == "disable" else "Enabled"
|
|
|
|
|
_print_success(f"{verb}: {', '.join(successful)}")
|