ccproxy.core.plugins.runtime¶
ccproxy.core.plugins.runtime
¶
Plugin runtime system for managing plugin instances.
This module defines runtime classes that manage plugin instances and lifecycle. Factory/loader utilities remain in their respective modules to avoid import cycles during consolidation. Import runtime classes from here, and import factories/loaders from their modules for now.
PluginContext
¶
Context provided to plugin runtime during initialization.
Source code in ccproxy/core/plugins/declaration.py
get_service
¶
Get a service instance by type with proper type safety.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service_type
|
type[T]
|
The type of service to retrieve |
required |
Returns:
| Type | Description |
|---|---|
T
|
The service instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the service is not available |
Source code in ccproxy/core/plugins/declaration.py
get
¶
Get service by type (new) or by string key (backward compatibility).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_or_type
|
type[T] | str
|
Service type for type-safe access or string key for compatibility |
required |
default
|
Any
|
Default value for string-based access (ignored for type-safe access) |
None
|
Returns:
| Type | Description |
|---|---|
T | Any
|
Service instance for type-safe access, or attribute value for string access |
Source code in ccproxy/core/plugins/declaration.py
get_attr
¶
Get attribute by string name - for backward compatibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
String attribute name |
required |
default
|
Any
|
Default value if attribute not found |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Attribute value or default |
Source code in ccproxy/core/plugins/declaration.py
keys
¶
Backward compatibility: Return list of available service keys.
Source code in ccproxy/core/plugins/declaration.py
PluginManifest
dataclass
¶
PluginManifest(
name,
version,
description="",
dependencies=list(),
is_provider=False,
provides=list(),
requires=list(),
optional_requires=list(),
middleware=list(),
routes=list(),
tasks=list(),
hooks=list(),
auth_commands=list(),
config_class=None,
tool_accumulator_class=None,
oauth_client_factory=None,
oauth_provider_factory=None,
token_manager_factory=None,
oauth_config_class=None,
oauth_routes=list(),
format_adapters=list(),
requires_format_adapters=list(),
cli_commands=list(),
cli_arguments=list(),
)
Complete static declaration of a plugin's capabilities.
This manifest is created at module import time and contains all static information needed to integrate the plugin into the application.
validate_dependencies
¶
validate_service_dependencies
¶
Validate that required services are available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
available_services
|
set[str]
|
Set of available service names |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of missing required services |
Source code in ccproxy/core/plugins/declaration.py
get_sorted_middleware
¶
validate_format_adapter_requirements
¶
Validate that required format adapters are available.
Source code in ccproxy/core/plugins/declaration.py
PluginRuntimeProtocol
¶
BasePluginRuntime
¶
Bases: PluginRuntimeProtocol
Base implementation of plugin runtime.
This class provides common functionality for all plugin runtimes. Specific plugin types (system, provider) can extend this base class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest
|
PluginManifest
|
Plugin manifest with static declarations |
required |
Source code in ccproxy/core/plugins/runtime.py
initialize
async
¶
Initialize the plugin with runtime context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
PluginContext
|
Runtime context with services and configuration |
required |
Source code in ccproxy/core/plugins/runtime.py
shutdown
async
¶
Cleanup on shutdown.
Source code in ccproxy/core/plugins/runtime.py
validate
async
¶
Validate plugin is ready.
Returns:
| Type | Description |
|---|---|
bool
|
True if plugin is ready, False otherwise |
Source code in ccproxy/core/plugins/runtime.py
health_check
async
¶
Perform health check.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Health check result following IETF format |
Source code in ccproxy/core/plugins/runtime.py
SystemPluginRuntime
¶
Bases: BasePluginRuntime
Runtime for system plugins (non-provider plugins).
System plugins provide functionality like logging, monitoring, permissions, etc., but don't proxy to external providers.
Source code in ccproxy/core/plugins/runtime.py
AuthProviderPluginRuntime
¶
Bases: BasePluginRuntime
Runtime for authentication provider plugins.
Auth provider plugins provide OAuth authentication flows and token management for various API providers without directly proxying requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest
|
PluginManifest
|
Plugin manifest with static declarations |
required |
Source code in ccproxy/core/plugins/runtime.py
ProviderPluginRuntime
¶
Bases: BasePluginRuntime
Runtime for provider plugins.
Provider plugins proxy requests to external API providers and require additional components like adapters and detection services.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest
|
PluginManifest
|
Plugin manifest with static declarations |
required |