ccproxy-api 0.1.3__py3-none-any.whl → 0.1.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccproxy/_version.py +2 -2
- ccproxy/adapters/openai/adapter.py +1 -1
- ccproxy/adapters/openai/streaming.py +1 -0
- ccproxy/api/app.py +134 -224
- ccproxy/api/dependencies.py +22 -2
- ccproxy/api/middleware/errors.py +27 -3
- ccproxy/api/middleware/logging.py +4 -0
- ccproxy/api/responses.py +6 -1
- ccproxy/api/routes/claude.py +222 -17
- ccproxy/api/routes/proxy.py +25 -6
- ccproxy/api/services/permission_service.py +2 -2
- ccproxy/claude_sdk/__init__.py +4 -8
- ccproxy/claude_sdk/client.py +661 -131
- ccproxy/claude_sdk/exceptions.py +16 -0
- ccproxy/claude_sdk/manager.py +219 -0
- ccproxy/claude_sdk/message_queue.py +342 -0
- ccproxy/claude_sdk/options.py +5 -0
- ccproxy/claude_sdk/session_client.py +546 -0
- ccproxy/claude_sdk/session_pool.py +550 -0
- ccproxy/claude_sdk/stream_handle.py +538 -0
- ccproxy/claude_sdk/stream_worker.py +392 -0
- ccproxy/claude_sdk/streaming.py +53 -11
- ccproxy/cli/commands/serve.py +96 -0
- ccproxy/cli/options/claude_options.py +47 -0
- ccproxy/config/__init__.py +0 -3
- ccproxy/config/claude.py +171 -23
- ccproxy/config/discovery.py +10 -1
- ccproxy/config/scheduler.py +4 -4
- ccproxy/config/settings.py +19 -1
- ccproxy/core/http_transformers.py +305 -73
- ccproxy/core/logging.py +108 -12
- ccproxy/core/transformers.py +5 -0
- ccproxy/models/claude_sdk.py +57 -0
- ccproxy/models/detection.py +126 -0
- ccproxy/observability/access_logger.py +72 -14
- ccproxy/observability/metrics.py +151 -0
- ccproxy/observability/storage/duckdb_simple.py +12 -0
- ccproxy/observability/storage/models.py +16 -0
- ccproxy/observability/streaming_response.py +107 -0
- ccproxy/scheduler/manager.py +31 -6
- ccproxy/scheduler/tasks.py +122 -0
- ccproxy/services/claude_detection_service.py +269 -0
- ccproxy/services/claude_sdk_service.py +334 -131
- ccproxy/services/proxy_service.py +91 -200
- ccproxy/utils/__init__.py +9 -1
- ccproxy/utils/disconnection_monitor.py +83 -0
- ccproxy/utils/id_generator.py +12 -0
- ccproxy/utils/startup_helpers.py +408 -0
- {ccproxy_api-0.1.3.dist-info → ccproxy_api-0.1.5.dist-info}/METADATA +29 -2
- {ccproxy_api-0.1.3.dist-info → ccproxy_api-0.1.5.dist-info}/RECORD +53 -41
- ccproxy/config/loader.py +0 -105
- {ccproxy_api-0.1.3.dist-info → ccproxy_api-0.1.5.dist-info}/WHEEL +0 -0
- {ccproxy_api-0.1.3.dist-info → ccproxy_api-0.1.5.dist-info}/entry_points.txt +0 -0
- {ccproxy_api-0.1.3.dist-info → ccproxy_api-0.1.5.dist-info}/licenses/LICENSE +0 -0
ccproxy/config/loader.py
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"""Configuration file loader for ccproxy."""
|
|
2
|
-
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from typing import Any
|
|
5
|
-
|
|
6
|
-
from ccproxy.config.discovery import find_toml_config_file
|
|
7
|
-
from ccproxy.config.settings import Settings
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class ConfigurationError(Exception):
|
|
11
|
-
"""Configuration loading error."""
|
|
12
|
-
|
|
13
|
-
pass
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class ConfigLoader:
|
|
17
|
-
"""Load configuration from multiple sources."""
|
|
18
|
-
|
|
19
|
-
def __init__(self) -> None:
|
|
20
|
-
self._cached_config: dict[str, Any] | None = None
|
|
21
|
-
|
|
22
|
-
def load(self, config_file: Path | None = None) -> Settings:
|
|
23
|
-
"""Load configuration from multiple sources.
|
|
24
|
-
|
|
25
|
-
Priority: ENV > config file > defaults
|
|
26
|
-
|
|
27
|
-
Args:
|
|
28
|
-
config_file: Optional path to config file
|
|
29
|
-
|
|
30
|
-
Returns:
|
|
31
|
-
Settings instance with loaded configuration
|
|
32
|
-
|
|
33
|
-
Raises:
|
|
34
|
-
ConfigurationError: If config file is invalid or cannot be loaded
|
|
35
|
-
"""
|
|
36
|
-
config_data = self._load_config_file(config_file)
|
|
37
|
-
|
|
38
|
-
# Environment variables take precedence over config file
|
|
39
|
-
return Settings(**config_data) if config_data else Settings()
|
|
40
|
-
|
|
41
|
-
def _load_config_file(self, config_file: Path | None = None) -> dict[str, Any]:
|
|
42
|
-
"""Load configuration from file.
|
|
43
|
-
|
|
44
|
-
Args:
|
|
45
|
-
config_file: Optional path to config file
|
|
46
|
-
|
|
47
|
-
Returns:
|
|
48
|
-
Configuration dictionary
|
|
49
|
-
|
|
50
|
-
Raises:
|
|
51
|
-
ConfigurationError: If config file is invalid
|
|
52
|
-
"""
|
|
53
|
-
if config_file is None:
|
|
54
|
-
config_file = find_toml_config_file()
|
|
55
|
-
|
|
56
|
-
if config_file is None or not config_file.exists():
|
|
57
|
-
return {}
|
|
58
|
-
|
|
59
|
-
try:
|
|
60
|
-
if config_file.suffix.lower() in [".toml", ".tml"]:
|
|
61
|
-
return self._load_toml_config(config_file)
|
|
62
|
-
else:
|
|
63
|
-
raise ConfigurationError(
|
|
64
|
-
f"Unsupported config file format: {config_file.suffix}. Only TOML (.toml) files are supported."
|
|
65
|
-
)
|
|
66
|
-
except Exception as e:
|
|
67
|
-
raise ConfigurationError(
|
|
68
|
-
f"Failed to load config file {config_file}: {e}"
|
|
69
|
-
) from e
|
|
70
|
-
|
|
71
|
-
def _load_toml_config(self, config_file: Path) -> dict[str, Any]:
|
|
72
|
-
"""Load TOML configuration file."""
|
|
73
|
-
try:
|
|
74
|
-
import tomllib
|
|
75
|
-
except ImportError:
|
|
76
|
-
try:
|
|
77
|
-
import tomli as tomllib # type: ignore
|
|
78
|
-
except ImportError:
|
|
79
|
-
raise ConfigurationError(
|
|
80
|
-
"TOML support not available. Install 'tomli' for Python < 3.11"
|
|
81
|
-
) from None
|
|
82
|
-
|
|
83
|
-
with config_file.open("rb") as f:
|
|
84
|
-
data = tomllib.load(f)
|
|
85
|
-
return data if isinstance(data, dict) else {}
|
|
86
|
-
|
|
87
|
-
def clear_cache(self) -> None:
|
|
88
|
-
"""Clear cached configuration."""
|
|
89
|
-
self._cached_config = None
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
# Global config loader instance
|
|
93
|
-
config_loader = ConfigLoader()
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
def load_config(config_file: Path | None = None) -> Settings:
|
|
97
|
-
"""Load configuration using the global loader.
|
|
98
|
-
|
|
99
|
-
Args:
|
|
100
|
-
config_file: Optional path to config file
|
|
101
|
-
|
|
102
|
-
Returns:
|
|
103
|
-
Settings instance with loaded configuration
|
|
104
|
-
"""
|
|
105
|
-
return config_loader.load(config_file)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|