From 32f4e601455d0214eebbed160a0a5a768223f175 Mon Sep 17 00:00:00 2001 From: Xubin Ren Date: Fri, 20 Mar 2026 19:19:02 +0000 Subject: [PATCH] refactor(providers): hide oauth-only providers from config setup Exclude openai_codex alongside github_copilot from generated config, filter OAuth-only providers out of the onboarding wizard, and clarify in README that OAuth login stores session state outside config. Also unify the GitHub Copilot login command spelling and add regression tests. Made-with: Cursor --- README.md | 8 +++++--- nanobot/cli/onboard_wizard.py | 1 + nanobot/config/schema.py | 2 +- tests/test_commands.py | 9 +++++++++ tests/test_onboard_logic.py | 2 ++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a62da82..64ae157 100644 --- a/README.md +++ b/README.md @@ -811,6 +811,7 @@ Config file: `~/.nanobot/config.json` OpenAI Codex (OAuth) Codex uses OAuth instead of API keys. Requires a ChatGPT Plus or Pro account. +No `providers.openaiCodex` block is needed in `config.json`; `nanobot provider login` stores the OAuth session outside config. **1. Login:** ```bash @@ -845,13 +846,14 @@ nanobot agent -c ~/.nanobot-telegram/config.json -w /tmp/nanobot-telegram-test -
-Github Copilot (OAuth) +GitHub Copilot (OAuth) -Github Copilot uses OAuth instead of API keys. Requires a [Github account with a plan](https://github.com/features/copilot/plans) configured. +GitHub Copilot uses OAuth instead of API keys. Requires a [GitHub account with a plan](https://github.com/features/copilot/plans) configured. +No `providers.githubCopilot` block is needed in `config.json`; `nanobot provider login` stores the OAuth session outside config. **1. Login:** ```bash -nanobot provider login github_copilot +nanobot provider login github-copilot ``` **2. Set model** (merge into `~/.nanobot/config.json`): diff --git a/nanobot/cli/onboard_wizard.py b/nanobot/cli/onboard_wizard.py index 2537dcc..eca86bf 100644 --- a/nanobot/cli/onboard_wizard.py +++ b/nanobot/cli/onboard_wizard.py @@ -664,6 +664,7 @@ def _get_provider_info() -> dict[str, tuple[str, bool, bool, str]]: spec.default_api_base, ) for spec in PROVIDERS + if not spec.is_oauth } diff --git a/nanobot/config/schema.py b/nanobot/config/schema.py index 607bd7a..c884433 100644 --- a/nanobot/config/schema.py +++ b/nanobot/config/schema.py @@ -78,7 +78,7 @@ class ProvidersConfig(Base): volcengine_coding_plan: ProviderConfig = Field(default_factory=ProviderConfig) # VolcEngine Coding Plan byteplus: ProviderConfig = Field(default_factory=ProviderConfig) # BytePlus (VolcEngine international) byteplus_coding_plan: ProviderConfig = Field(default_factory=ProviderConfig) # BytePlus Coding Plan - openai_codex: ProviderConfig = Field(default_factory=ProviderConfig) # OpenAI Codex (OAuth) + openai_codex: ProviderConfig = Field(default_factory=ProviderConfig, exclude=True) # OpenAI Codex (OAuth) github_copilot: ProviderConfig = Field(default_factory=ProviderConfig, exclude=True) # Github Copilot (OAuth) diff --git a/tests/test_commands.py b/tests/test_commands.py index 6020856..124802e 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -213,6 +213,15 @@ def test_config_matches_openai_codex_with_hyphen_prefix(): assert config.get_provider_name() == "openai_codex" +def test_config_dump_excludes_oauth_provider_blocks(): + config = Config() + + providers = config.model_dump(by_alias=True)["providers"] + + assert "openaiCodex" not in providers + assert "githubCopilot" not in providers + + def test_config_matches_explicit_ollama_prefix_without_api_key(): config = Config() config.agents.defaults.model = "ollama/llama3.2" diff --git a/tests/test_onboard_logic.py b/tests/test_onboard_logic.py index fbcb4fb..9e0f6f7 100644 --- a/tests/test_onboard_logic.py +++ b/tests/test_onboard_logic.py @@ -359,6 +359,8 @@ class TestProviderChannelInfo: assert len(names) > 0 # Should include common providers assert "openai" in names or "anthropic" in names + assert "openai_codex" not in names + assert "github_copilot" not in names def test_get_channel_names_returns_dict(self): from nanobot.cli.onboard_wizard import _get_channel_names