Agent Zero AI framework
Keep OAuth metadata provider-owned
Alessandroef3b4dda71cd
diff --git a/plugins/_model_config/provider_metadata.yaml b/plugins/_model_config/provider_metadata.yamlindex d336ce572..1fcd1d6f4 100644--- a/plugins/_model_config/provider_metadata.yaml+++ b/plugins/_model_config/provider_metadata.yaml@@ -1,18 +1,10 @@chat:- codex_oauth:- api_key_mode: oauth- github_copilot_oauth:- api_key_mode: oauth- gemini_api_oauth:- api_key_mode: oauthlm_studio:api_key_mode: noneollama:api_key_mode: noneother:api_key_mode: optional- xai_grok_oauth:- api_key_mode: oauthembedding:huggingface:diff --git a/plugins/_oauth/conf/model_providers.yaml b/plugins/_oauth/conf/model_providers.yamlindex a860c2fb5..8af6bf491 100644--- a/plugins/_oauth/conf/model_providers.yaml+++ b/plugins/_oauth/conf/model_providers.yaml@@ -2,6 +2,7 @@ chat:codex_oauth:name: Codex/ChatGPT Accountlitellm_provider: openai+ api_key_mode: oauthmodels_list:endpoint_url: "/models"kwargs:@@ -10,6 +11,7 @@ chat:github_copilot_oauth:name: GitHub Copilot Accountlitellm_provider: openai+ api_key_mode: oauthmodels_list:endpoint_url: "/models"kwargs:@@ -18,6 +20,7 @@ chat:gemini_api_oauth:name: Google Gemini API Accountlitellm_provider: openai+ api_key_mode: oauthmodels_list:endpoint_url: "/models"kwargs:@@ -26,6 +29,7 @@ chat:xai_grok_oauth:name: xAI Grok Accountlitellm_provider: openai+ api_key_mode: oauthmodels_list:endpoint_url: "/models"kwargs:diff --git a/plugins/_oauth/extensions/python/_functions/models/get_api_key/end/_20_codex_account_dummy_key.py b/plugins/_oauth/extensions/python/_functions/models/get_api_key/end/_20_oauth_account_dummy_key.pysimilarity index 95%rename from plugins/_oauth/extensions/python/_functions/models/get_api_key/end/_20_codex_account_dummy_key.pyrename to plugins/_oauth/extensions/python/_functions/models/get_api_key/end/_20_oauth_account_dummy_key.pyindex 48d5c974b..f90703faa 100644--- a/plugins/_oauth/extensions/python/_functions/models/get_api_key/end/_20_codex_account_dummy_key.py+++ b/plugins/_oauth/extensions/python/_functions/models/get_api_key/end/_20_oauth_account_dummy_key.py@@ -4,7 +4,7 @@ from helpers.extension import Extensionfrom plugins._oauth.helpers.providers import DUMMY_API_KEY, oauth_provider_ids-class CodexAccountDummyKey(Extension):+class OAuthAccountDummyKey(Extension):def execute(self, data: dict | None = None, **kwargs):del kwargsif not isinstance(data, dict):diff --git a/plugins/_oauth/webui/oauth-config-store.js b/plugins/_oauth/webui/oauth-config-store.jsindex c00adef10..7a48c0181 100644--- a/plugins/_oauth/webui/oauth-config-store.js+++ b/plugins/_oauth/webui/oauth-config-store.js@@ -284,14 +284,6 @@ export const store = createStore("oauthConfig", {return path ? `${window.location.origin}${path}` : "";},- connected() {- return this.providerConnected(CODEX_PROVIDER);- },-- statusLabel() {- return this.providerStatusLabel(CODEX_PROVIDER);- },-usage(providerId = CODEX_PROVIDER) {return this.providerStatus(providerId)?.usage || null;},@@ -364,14 +356,6 @@ export const store = createStore("oauthConfig", {return `${Math.round(hours / 24)}d`;},- endpointUrl() {- return this.providerEndpointUrl(CODEX_PROVIDER);- },-- callbackUrl() {- return this.providerCallbackUrl(CODEX_PROVIDER);- },-installSettingsHooks(context) {if (!context || context.__oauthConfigHooksInstalled) return;@@ -429,10 +413,6 @@ export const store = createStore("oauthConfig", {return this.modelSlot(key).provider === providerId;},- slotUsesCodex(key) {- return this.slotUsesProvider(key, CODEX_PROVIDER);- },-providerName(provider) {if (!provider) return "Not configured";const found = (modelConfigStore.chatProviders || []).find((item) => item.value === provider);@@ -470,10 +450,6 @@ export const store = createStore("oauthConfig", {}},- useCodexForSlot(key) {- this.useProviderForSlot(key, CODEX_PROVIDER);- },-copyMainToUtility() {if (!this.modelConfig) return;const main = this.modelSlot("chat_model");@@ -636,10 +612,6 @@ export const store = createStore("oauthConfig", {}},- connectCodex() {- return this.connectProvider(CODEX_PROVIDER);- },-startPolling(providerId = CODEX_PROVIDER) {this.stopPolling(providerId);this.pollStartedAt = { ...this.pollStartedAt, [providerId]: Date.now() };@@ -859,10 +831,6 @@ export const store = createStore("oauthConfig", {}},- disconnectCodex() {- return this.disconnectProvider(CODEX_PROVIDER);- },-cancelConnect(providerId = "") {if (providerId) {this.stopPolling(providerId);diff --git a/tests/test_oauth_codex.py b/tests/test_oauth_codex.pyindex af84f8b44..9391ec16d 100644--- a/tests/test_oauth_codex.py+++ b/tests/test_oauth_codex.py@@ -15,8 +15,8 @@ import yamlsys.path.insert(0, str(Path(__file__).resolve().parents[1]))from plugins._oauth.helpers import codexfrom plugins._oauth.helpers import routes-from plugins._oauth.extensions.python._functions.models.get_api_key.end._20_codex_account_dummy_key import (- CodexAccountDummyKey,+from plugins._oauth.extensions.python._functions.models.get_api_key.end._20_oauth_account_dummy_key import (+ OAuthAccountDummyKey,)@@ -689,7 +689,7 @@ def test_provider_config_uses_container_local_agent_zero_origin():def test_codex_provider_reports_dummy_api_key_when_missing():data = {"args": ("codex_oauth",), "kwargs": {}, "result": "None"}- CodexAccountDummyKey(agent=None).execute(data=data)+ OAuthAccountDummyKey(agent=None).execute(data=data)assert data["result"] == "oauth"@@ -697,6 +697,6 @@ def test_codex_provider_reports_dummy_api_key_when_missing():def test_codex_provider_preserves_configured_api_key():data = {"args": ("codex_oauth",), "kwargs": {}, "result": "configured"}- CodexAccountDummyKey(agent=None).execute(data=data)+ OAuthAccountDummyKey(agent=None).execute(data=data)assert data["result"] == "configured"diff --git a/tests/test_oauth_providers.py b/tests/test_oauth_providers.pyindex 27559bdb0..0f9c6b8f0 100644--- a/tests/test_oauth_providers.py+++ b/tests/test_oauth_providers.py@@ -55,8 +55,8 @@ from plugins._oauth.api import poll_device_login as poll_device_login_apifrom plugins._oauth.api import start_device_login as start_device_login_apifrom plugins._oauth.api import start_login as start_login_apifrom plugins._oauth.api.models import Models-from plugins._oauth.extensions.python._functions.models.get_api_key.end._20_codex_account_dummy_key import (- CodexAccountDummyKey,+from plugins._oauth.extensions.python._functions.models.get_api_key.end._20_oauth_account_dummy_key import (+ OAuthAccountDummyKey,)from plugins._oauth.helpers import statefrom plugins._oauth.helpers.providers import base as provider_base@@ -635,7 +635,7 @@ def test_poll_device_login_unknown_provider_returns_structured_error():def test_oauth_providers_report_dummy_api_key_when_missing(provider_id, initial):data = {"args": (provider_id,), "kwargs": {}, "result": initial}- CodexAccountDummyKey(agent=None).execute(data=data)+ OAuthAccountDummyKey(agent=None).execute(data=data)assert data["result"] == DUMMY_API_KEY@@ -647,7 +647,7 @@ def test_oauth_providers_report_dummy_api_key_when_missing(provider_id, initial)def test_oauth_providers_report_dummy_api_key_when_result_missing(provider_id):data = {"args": (provider_id,), "kwargs": {}}- CodexAccountDummyKey(agent=None).execute(data=data)+ OAuthAccountDummyKey(agent=None).execute(data=data)assert data["result"] == DUMMY_API_KEY@@ -659,7 +659,7 @@ def test_oauth_providers_report_dummy_api_key_when_result_missing(provider_id):def test_oauth_providers_preserve_configured_api_key(provider_id):data = {"args": (provider_id,), "kwargs": {}, "result": "configured"}- CodexAccountDummyKey(agent=None).execute(data=data)+ OAuthAccountDummyKey(agent=None).execute(data=data)assert data["result"] == "configured"@@ -689,13 +689,25 @@ def test_model_provider_config_contains_all_oauth_providers():assert "50001" not in json.dumps(provider_config)-def test_provider_metadata_marks_new_oauth_providers_as_oauth_api_key_mode():+def test_oauth_provider_config_marks_oauth_providers_as_oauth_api_key_mode():+ provider_path = Path(__file__).resolve().parents[1] / "plugins/_oauth/conf/model_providers.yaml"+ provider_config = yaml.safe_load(provider_path.read_text(encoding="utf-8"))+ chat = provider_config["chat"]++ assert chat[CODEX_PROVIDER_ID]["api_key_mode"] == "oauth"+ assert chat[GITHUB_COPILOT_PROVIDER_ID]["api_key_mode"] == "oauth"+ assert chat[GEMINI_API_PROVIDER_ID]["api_key_mode"] == "oauth"+ assert chat[XAI_GROK_PROVIDER_ID]["api_key_mode"] == "oauth"+++def test_model_config_provider_metadata_stays_oauth_provider_agnostic():metadata_path = Path(__file__).resolve().parents[1] / "plugins/_model_config/provider_metadata.yaml"metadata = yaml.safe_load(metadata_path.read_text(encoding="utf-8"))- assert metadata["chat"][GITHUB_COPILOT_PROVIDER_ID]["api_key_mode"] == "oauth"- assert metadata["chat"][GEMINI_API_PROVIDER_ID]["api_key_mode"] == "oauth"- assert metadata["chat"][XAI_GROK_PROVIDER_ID]["api_key_mode"] == "oauth"+ assert CODEX_PROVIDER_ID not in metadata["chat"]+ assert GITHUB_COPILOT_PROVIDER_ID not in metadata["chat"]+ assert GEMINI_API_PROVIDER_ID not in metadata["chat"]+ assert XAI_GROK_PROVIDER_ID not in metadata["chat"]def test_usage_plan_catalog_covers_connectable_subscription_providers_only():