-
Notifications
You must be signed in to change notification settings - Fork 263
Add OAuth Gateway microservice for Claude and Gemini authentication #633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
benzntech
wants to merge
5
commits into
katanemo:main
Choose a base branch
from
benzntech:oauth-gateway-feature
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Implement PKCE OAuth2 flow (RFC 7636 compliant) - Support 4 OAuth providers: Claude, Gemini, ChatGPT, Anthropic Console - Persistent token storage at ~/.archgw/oauth_tokens.json - Multi-provider token management with refresh support - REST API endpoints for OAuth operations - Environment variables for all OAuth credentials - Fix Gemini redirect_uri from /auth/gemini/callback to /auth/callback - Docker integration via supervisord - Comprehensive unit tests (211 tests passing)
Implement dynamic model availability tracking and management across 15+ providers.
Introduces three new HTTP endpoints and a thread-safe registry for managing model
metadata, fallback routing, and provider distribution tracking.
New Features:
- New crate: model_registry with ModelRegistry singleton for concurrent access
- ModelInfo struct with rich metadata (pricing, thinking support, capabilities)
- Three fallback strategies: SameProviderFallback, CapabilityMatchFallback, CostOptimizedFallback
- Model mapping/aliasing support for request transformation
- 15+ pre-configured models (Claude, Gemini, OpenAI, Groq, Mistral)
API Endpoints:
- GET /v1/models - List all available models with rich metadata
- GET /v1/models/{model_id} - Get individual model details
- GET /v1/models/available - List only active/beta models
Integration:
- brightstaff initialized with default models on startup
- Enhanced models handler to use registry instead of config-based list
- OpenAI-compatible response format for all endpoints
Testing:
- 8 new unit tests for registry core functionality
- All 215 existing tests still passing
- Clean compilation with no errors
Implement dynamic model discovery from LLM providers with async/await patterns. Adds OpenAI, Anthropic, Gemini, Groq, and Mistral discovery implementations. Supports caching with configurable TTL and graceful error handling with timeouts. New Features: - ModelDiscovery async trait for provider-agnostic discovery - OpenAI implementation: Calls /v1/models API endpoint - Gemini implementation: Calls Google Generative API with model discovery - Anthropic/Groq/Mistral: Static implementations with known models - CachedDiscovery wrapper: 5-minute TTL cache for provider API calls - DiscoveryManager: Coordinates discovery across all providers API Integrations: - OpenAI: Fetches real-time model list (requires OPENAI_API_KEY) - Gemini: Fetches real-time model list (requires GEMINI_API_KEY) - Anthropic/Groq/Mistral: Pre-configured known models (no API key needed) New Handler: - discover_and_register_models(): Called on startup to auto-populate registry - Gracefully handles missing API keys and provider timeouts - Logs discovery results and failures with tracing Testing: - 4 new discovery tests (cached, anthropic, groq, discovery manager) - 12 total model_registry tests (was 8) - 220 total workspace tests (was 215) - All tests passing with no regressions Error Handling: - DiscoveryTimeout error now includes provider name - 10-second timeout per provider API call - Graceful fallback to static definitions on discovery failure
Implement model availability checking and fallback routing in the request path. Adds routing helpers for checking model availability and selecting fallbacks when primary models are unavailable. Integrates with ModelRegistry for real-time availability tracking. New Components: - Model routing helpers module: model_routing.rs - Model availability checking functions - Fallback model resolution with logging - Recommended fallback models lookup - Routing decision logging with fallback tracking Integration Points: - Common routing module: Enhanced get_llm_provider() with model availability checking - Brightstaff handlers: New model_routing module with public API - Model registry integration: Uses registry for availability checks - Tracing/logging: Logs all routing decisions and fallbacks Key Functions: - is_model_available(): Check if model is in registry and available - get_available_models(): Get list of all available models - resolve_model_with_fallback(): Get available model or fallback alternative - get_fallback_models(): Get top 5 recommended fallback models - log_routing_decision(): Log routing decisions to traces Features: - Automatic fallback selection when primary model unavailable - Same provider preference for fallbacks (default strategy) - Graceful error handling with logging - Request ID correlation in all logs - Non-blocking: Falls back to random selection if registry unavailable Testing: - 4 new model_routing tests - 2 new hermesllm tests - 6 total new tests - 226 total workspace tests (was 220) - All tests passing with no regressions Ready for: - Streaming requests with model availability checks - Real-time failover when models become unavailable - Provider health monitoring (Phase 3+) - Configuration-based policies (Phase 3+)
- Integrate resolve_model_with_fallback() into router_chat_get_upstream_model() - Check availability of both routed and default models - Apply fallback routing if primary model unavailable - Log routing decisions with request ID correlation - Gracefully handle cases where no fallback is available
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR contains Phase 1 + Phase 2 + Phase 3 of the ArchGW enhancement:
Phase 1: OAuth Gateway (COMPLETED) ✅
Implement OAuth Gateway as a new microservice supporting Claude Pro/Max, Gemini CLI, ChatGPT Plus/Pro, and Anthropic Console authentication flows.
Key Features:
Phase 2: Model Registry Enhancement (COMPLETED) ✅
Component 1: Registry & API Endpoints
Component 2: Real Provider Discovery
Component 3: Fallback Routing
Component 4: Pre-configured Models (15+)
Phase 3: Model Routing Integration (COMPLETED) ✅
Component 1: Routing System Integration
Key Functions:
Routing Logic:
Testing
✅ 226 total tests passing (+6 new tests in Phase 3)
Breakdown:
Files Changed
Phase 3 (Routing Integration)
New:
crates/brightstaff/src/handlers/model_routing.rs(130 lines)Modified:
crates/common/src/routing.rs(+50 lines)crates/brightstaff/src/handlers/mod.rs(+1 line)Commits
a28f35ac- Add OAuth Gateway microservice83cec34f- Add Phase 2: Model Registry Enhancement with API endpointsf1fb4299- Add real provider discovery APIscb17632a- Add Phase 3: Model availability integration into routing systemStatus
✅ All 226 tests passing
✅ Clean compilation
✅ Request ID tracing integrated
✅ Fallback routing implemented
✅ Model availability checking ready
✅ Foundation for health monitoring established
Next Steps (Phase 4+)