agent-zero/plugins/_oauth/helpers/route_bootstrap.py
Alessandro f67564a8ae Add Codex/ChatGPT account OAuth provider
Create a generic OAuth Connections plugin with Codex/ChatGPT Account as the first provider, using OpenAI's device-code flow to persist Codex-compatible account tokens.

Expose a loopback OpenAI-compatible wrapper for models, responses, and chat completions, and point LiteLLM at the container-local Agent Zero origin.

Add a dummy API-key extension and focused tests so the account-backed provider appears configured without requiring a user-entered key.

docs: add Codex plan OAuth callout

Highlight that Agent Zero can use an existing OpenAI Codex plan through the new OAuth flow.

Add the account-backed LLM plans image and surface the section from the README navigation, while pointing toward future Gemini CLI and Claude Code integrations.

Handle Codex account SSE chat chunks

Teach the Codex/ChatGPT account bridge to extract text from OpenAI-style SSE chat completion deltas and fall back to a normal output_text response when upstream only streams chunks.

Strip user-supplied stream kwargs before LiteLLM calls so Agent Zero owns streaming mode and custom parameters cannot pass stream twice.

Add targeted tests for streamed delta extraction and reconstructed responses.

update README.md with LLM plans mention
2026-04-28 16:14:53 +02:00

26 lines
804 B
Python

from __future__ import annotations
def install_route_hooks() -> None:
from helpers.ui_server import UiServerRuntime
if getattr(UiServerRuntime, "_a0_oauth_route_hooks_installed", False):
return
original_register_http_routes = UiServerRuntime.register_http_routes
def register_http_routes(self):
result = original_register_http_routes(self)
from plugins._oauth.helpers.routes import register_oauth_routes
register_oauth_routes(self.webapp)
return result
UiServerRuntime.register_http_routes = register_http_routes
UiServerRuntime._a0_oauth_route_hooks_installed = True
def is_installed() -> bool:
from helpers.ui_server import UiServerRuntime
return bool(getattr(UiServerRuntime, "_a0_oauth_route_hooks_installed", False))