Skip to content

ccproxy.core.plugins.protocol

ccproxy.core.plugins.protocol

Plugin protocol for provider plugins.

OAuthClientProtocol

Bases: Protocol

Protocol for OAuth client implementations.

authenticate async

authenticate(open_browser=True)

Perform OAuth authentication flow.

Parameters:

Name Type Description Default
open_browser bool

Whether to automatically open browser

True

Returns:

Type Description
Any

Provider-specific credentials object

Source code in ccproxy/core/plugins/protocol.py
async def authenticate(self, open_browser: bool = True) -> Any:
    """Perform OAuth authentication flow.

    Args:
        open_browser: Whether to automatically open browser

    Returns:
        Provider-specific credentials object
    """
    ...

refresh_access_token async

refresh_access_token(refresh_token)

Refresh access token using refresh token.

Parameters:

Name Type Description Default
refresh_token str

Refresh token

required

Returns:

Type Description
Any

New token response

Source code in ccproxy/core/plugins/protocol.py
async def refresh_access_token(self, refresh_token: str) -> Any:
    """Refresh access token using refresh token.

    Args:
        refresh_token: Refresh token

    Returns:
        New token response
    """
    ...

AuthCommandDefinition

Bases: TypedDict

Definition for provider-specific auth command extensions.

HealthCheckResult

Bases: BaseModel

Standardized health check result following IETF format.

ScheduledTaskDefinition

Bases: TypedDict

Definition for a scheduled task from a plugin.

BasePlugin

Bases: Protocol

Base protocol for all plugins.

name property

name

Plugin name.

version property

version

Plugin version.

dependencies property

dependencies

List of plugin names this plugin depends on.

router_prefix property

router_prefix

Unique route prefix for this plugin.

initialize async

initialize(services)

Initialize plugin with shared services. Called once on startup.

Source code in ccproxy/core/plugins/protocol.py
async def initialize(self, services: "ServiceContainer") -> None:
    """Initialize plugin with shared services. Called once on startup."""
    ...

shutdown async

shutdown()

Perform graceful shutdown. Called once on app shutdown.

Source code in ccproxy/core/plugins/protocol.py
async def shutdown(self) -> None:
    """Perform graceful shutdown. Called once on app shutdown."""
    ...

validate async

validate()

Validate plugin is ready.

Source code in ccproxy/core/plugins/protocol.py
async def validate(self) -> bool:
    """Validate plugin is ready."""
    ...

get_routes

get_routes()

Get plugin-specific routes (optional).

Source code in ccproxy/core/plugins/protocol.py
def get_routes(self) -> APIRouter | dict[str, APIRouter] | None:
    """Get plugin-specific routes (optional)."""
    ...

health_check async

health_check()

Perform health check following IETF format.

Source code in ccproxy/core/plugins/protocol.py
async def health_check(self) -> HealthCheckResult:
    """Perform health check following IETF format."""
    ...

get_scheduled_tasks

get_scheduled_tasks()

Get scheduled task definitions for this plugin (optional).

Returns:

Type Description
list[ScheduledTaskDefinition] | None

List of task definitions or None if no scheduled tasks needed

Source code in ccproxy/core/plugins/protocol.py
def get_scheduled_tasks(self) -> list[ScheduledTaskDefinition] | None:
    """Get scheduled task definitions for this plugin (optional).

    Returns:
        List of task definitions or None if no scheduled tasks needed
    """
    ...

get_config_class

get_config_class()

Get the Pydantic configuration model for this plugin.

Returns:

Type Description
type[BaseModel] | None

Pydantic BaseModel class for plugin configuration or None if no configuration needed

Source code in ccproxy/core/plugins/protocol.py
def get_config_class(self) -> type[BaseModel] | None:
    """Get the Pydantic configuration model for this plugin.

    Returns:
        Pydantic BaseModel class for plugin configuration or None if no configuration needed
    """
    ...

get_hooks

get_hooks()

Get hooks provided by this plugin (optional).

Returns:

Type Description
list[Hook] | None

List of hook instances or None if no hooks

Source code in ccproxy/core/plugins/protocol.py
def get_hooks(self) -> list[Hook] | None:
    """Get hooks provided by this plugin (optional).

    Returns:
        List of hook instances or None if no hooks
    """
    ...

SystemPlugin

Bases: BasePlugin, Protocol

Protocol for system plugins (non-provider plugins).

System plugins inherit all methods from BasePlugin and don't add any additional requirements. They don't proxy to external providers and therefore don't need adapters or provider configurations.

ProviderPlugin

Bases: BasePlugin, Protocol

Enhanced protocol for provider plugins.

Provider plugins proxy requests to external API providers and therefore need additional methods for creating adapters and configurations.

create_adapter

create_adapter()

Create adapter instance for handling provider requests.

Source code in ccproxy/core/plugins/protocol.py
def create_adapter(self) -> BaseAdapter:
    """Create adapter instance for handling provider requests."""
    ...

create_config

create_config()

Create provider configuration from settings.

Source code in ccproxy/core/plugins/protocol.py
def create_config(self) -> ProviderConfig:
    """Create provider configuration from settings."""
    ...

get_oauth_client async

get_oauth_client()

Get OAuth client for this plugin if it supports OAuth authentication.

Returns:

Type Description
OAuthClientProtocol | None

OAuth client instance or None if plugin doesn't support OAuth

Source code in ccproxy/core/plugins/protocol.py
async def get_oauth_client(self) -> OAuthClientProtocol | None:
    """Get OAuth client for this plugin if it supports OAuth authentication.

    Returns:
        OAuth client instance or None if plugin doesn't support OAuth
    """