| 1 | # providers.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `providers.py` helper module. |
| 6 | - This module loads model provider configuration and provider metadata. |
| 7 | - Keep this file-level DOX profile synchronized with `providers.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `providers.py` owns the runtime implementation. |
| 12 | - `providers.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Classes: |
| 14 | - `FieldOption` (`TypedDict`) |
| 15 | - `ProviderManager` (no explicit base class) |
| 16 | - `get_instance(cls)` |
| 17 | - `reload(cls)` |
| 18 | - `get_providers(self, provider_type: ModelType) -> List[FieldOption]` |
| 19 | - `get_raw_providers(self, provider_type: ModelType) -> List[Dict[str, str]]` |
| 20 | - `get_provider_config(self, provider_type: ModelType, provider_id: str) -> Optional[Dict[str, str]]` |
| 21 | - Top-level functions: |
| 22 | - `get_providers(provider_type: ModelType) -> List[FieldOption]`: Convenience function to get providers of a specific type. |
| 23 | - `get_raw_providers(provider_type: ModelType) -> List[Dict[str, str]]`: Return full metadata for providers of a given type. |
| 24 | - `get_provider_config(provider_type: ModelType, provider_id: str) -> Optional[Dict[str, str]]`: Return metadata for a single provider (None if not found). |
| 25 | - `reload_providers()`: Re-merge base + plugin provider configs. Call after plugin changes. |
| 26 | - Notable constants/configuration names: `PROVIDER_MANAGER_CACHE_AREA`, `PROVIDER_MANAGER_CACHE_KEY`. |
| 27 | |
| 28 | ## Runtime Contracts |
| 29 | |
| 30 | - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together. |
| 31 | - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change. |
| 32 | - Observed side-effect areas: filesystem reads, filesystem deletion, plugin state, settings/state persistence. |
| 33 | - Imported dependency areas include: `helpers`, `typing`, `yaml`. |
| 34 | |
| 35 | ## Key Concepts |
| 36 | |
| 37 | - Important called helpers/classes observed in the source: `ProviderManager.get_instance.get_providers`, `ProviderManager.get_instance.get_raw_providers`, `ProviderManager.get_instance.get_provider_config`, `ProviderManager.reload`, `cache.remove`, `cls.get_instance`, `inst._load_providers`, `files.get_abs_path`, `self._normalise_yaml`, `get_enabled_plugin_paths`, `provider_id.lower`, `self.get_raw_providers`, `cls`, `cache.add`, `self._load_providers`, `self._load_yaml`, `items.sort`, `ProviderManager.get_instance`, `lower`, `yaml.safe_load`. |
| 38 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 39 | |
| 40 | ## Work Guidance |
| 41 | |
| 42 | - Preserve public helper APIs used by core code and plugins unless every caller is updated. |
| 43 | - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded. |
| 44 | - Prefer adding cohesive helper functions here only when behavior is reused across modules. |
| 45 | |
| 46 | ## Verification |
| 47 | |
| 48 | - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers. |
| 49 | - Related tests observed by source search: |
| 50 | - `tests/test_fastmcp_openapi_security.py` |
| 51 | - `tests/test_model_config_api_keys.py` |
| 52 | - `tests/test_oauth_codex.py` |
| 53 | - `tests/test_oauth_gemini_api.py` |
| 54 | - `tests/test_oauth_github_copilot.py` |
| 55 | - `tests/test_oauth_providers.py` |
| 56 | - `tests/test_oauth_xai_grok.py` |
| 57 | - `tests/test_onboarding_static.py` |
| 58 | |
| 59 | ## Child DOX Index |
| 60 | |
| 61 | No child DOX files. |