fix(hermes_cli): keep TTS/setup xAI OAuth from switching active chat provider

Save side-tool OAuth tokens without promoting xai-oauth via active_provider
or model.provider so hermes setup tts login no longer hijacks inference routing.
This commit is contained in:
Fangliquan 2026-07-25 20:41:57 +08:00 committed by Teknium
parent a54067a6fd
commit fce06e909d
5 changed files with 134 additions and 6 deletions

View file

@ -896,15 +896,17 @@ def _xai_oauth_logged_in_for_setup() -> bool:
def _run_xai_oauth_login_from_setup() -> bool:
"""Run the xAI Grok OAuth device-code login from inside the setup wizard.
Saves OAuth tokens only. Does **not** switch the active inference
provider or rewrite ``model.provider`` callers (TTS setup, tools
config) only need credentials for side tools.
Returns True on success, False on any failure (the caller falls back
to whatever the user picked next, e.g. Edge TTS).
"""
try:
from hermes_cli.auth import (
DEFAULT_XAI_OAUTH_BASE_URL,
_is_remote_session,
_save_xai_oauth_tokens,
_update_config_for_provider,
_xai_oauth_device_code_login,
)
except Exception as exc:
@ -922,9 +924,7 @@ def _run_xai_oauth_login_from_setup() -> bool:
redirect_uri=creds.get("redirect_uri", ""),
last_refresh=creds.get("last_refresh"),
auth_mode="oauth_device_code",
)
_update_config_for_provider(
"xai-oauth", creds.get("base_url", DEFAULT_XAI_OAUTH_BASE_URL)
set_active=False,
)
return True
except Exception as exc: