ccproxy.plugins.claude_sdk.adapter¶
ccproxy.plugins.claude_sdk.adapter
¶
Claude SDK adapter implementation using delegation pattern.
ClaudeSDKAdapter
¶
Bases: BaseHTTPAdapter
Claude SDK adapter implementation using delegation pattern.
This adapter integrates with the application request lifecycle, following the same pattern as claude_api and codex plugins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ClaudeSDKSettings
|
SDK configuration settings |
required |
session_manager
|
SessionManager | None
|
Optional session manager for session handling |
None
|
metrics
|
IMetricsCollector | None
|
Optional metrics collector |
None
|
hook_manager
|
Any | None
|
Optional hook manager for emitting events |
None
|
Source code in ccproxy/plugins/claude_sdk/adapter.py
initialize
async
¶
Initialize the adapter and start session manager if needed.
Source code in ccproxy/plugins/claude_sdk/adapter.py
set_detection_service
¶
Set the detection service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detection_service
|
Any
|
Claude CLI detection service |
required |
handle_streaming
async
¶
Handle a streaming request through Claude SDK.
This is a convenience method that ensures stream=true and delegates to handle_request which handles both streaming and non-streaming.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
FastAPI request object |
required |
endpoint
|
str
|
Target endpoint path |
required |
**kwargs
|
Any
|
Additional arguments |
{}
|
Returns:
| Type | Description |
|---|---|
StreamingResponse
|
Streaming response from Claude SDK |
Source code in ccproxy/plugins/claude_sdk/adapter.py
cleanup
async
¶
Cleanup resources when shutting down.
Source code in ccproxy/plugins/claude_sdk/adapter.py
close
async
¶
prepare_provider_request
async
¶
Prepare request for ClaudeSDK (minimal implementation).
ClaudeSDK uses the local Claude SDK rather than making HTTP requests, so this just passes through the body and headers.
Source code in ccproxy/plugins/claude_sdk/adapter.py
process_provider_response
async
¶
Process response from ClaudeSDK (minimal implementation).
ClaudeSDK handles response processing in handle_request method, so this should not be called in normal operation.
Source code in ccproxy/plugins/claude_sdk/adapter.py
get_target_url
async
¶
Get target URL for ClaudeSDK (minimal implementation).
ClaudeSDK uses local SDK rather than HTTP URLs, so this returns a placeholder URL.