ccproxy.core.plugins.declaration¶
ccproxy.core.plugins.declaration
¶
Plugin declaration system for static plugin specification.
This module provides the declaration layer of the plugin system, allowing plugins to specify their requirements and capabilities at declaration time (app creation) rather than runtime (lifespan).
FormatAdapterSpec
dataclass
¶
Specification for format adapter registration.
MiddlewareSpec
dataclass
¶
MiddlewareSpec(
middleware_class, priority=APPLICATION, kwargs=dict()
)
Specification for plugin middleware.
RouterSpec
dataclass
¶
Specification for individual routers in a plugin.
RouteSpec
dataclass
¶
Specification for plugin routes.
TaskSpec
dataclass
¶
TaskSpec(
task_name,
task_type,
task_class,
interval_seconds,
enabled=True,
kwargs=dict(),
)
Specification for scheduled tasks.
AuthCommandSpec
dataclass
¶
AuthCommandSpec(
command_name, description, handler, options=dict()
)
Specification for auth commands.
CliCommandSpec
dataclass
¶
Specification for plugin CLI commands.
CliArgumentSpec
dataclass
¶
CliArgumentSpec(
target_command,
argument_name,
argument_type=str,
help_text="",
default=None,
required=False,
typer_kwargs=dict(),
)
Specification for adding arguments to existing commands.
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
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.