ccproxy-api 0.1.0__tar.gz

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.
Files changed (269) hide show
  1. ccproxy_api-0.1.0/.env.example +31 -0
  2. ccproxy_api-0.1.0/.github/workflows/backend.yml +117 -0
  3. ccproxy_api-0.1.0/.github/workflows/build.yml +72 -0
  4. ccproxy_api-0.1.0/.github/workflows/ci.yml +44 -0
  5. ccproxy_api-0.1.0/.github/workflows/docs.yml +115 -0
  6. ccproxy_api-0.1.0/.github/workflows/frontend.yml.disabled +122 -0
  7. ccproxy_api-0.1.0/.github/workflows/release.yml +148 -0
  8. ccproxy_api-0.1.0/.gitignore +165 -0
  9. ccproxy_api-0.1.0/.pre-commit-config.yaml +125 -0
  10. ccproxy_api-0.1.0/.python-version +1 -0
  11. ccproxy_api-0.1.0/CHANGELOG.md +47 -0
  12. ccproxy_api-0.1.0/CONTRIBUTING.md +402 -0
  13. ccproxy_api-0.1.0/CONVENTIONS.md +259 -0
  14. ccproxy_api-0.1.0/Dockerfile +99 -0
  15. ccproxy_api-0.1.0/LICENSE +21 -0
  16. ccproxy_api-0.1.0/Makefile +237 -0
  17. ccproxy_api-0.1.0/PKG-INFO +253 -0
  18. ccproxy_api-0.1.0/README.md +224 -0
  19. ccproxy_api-0.1.0/TESTING.md +514 -0
  20. ccproxy_api-0.1.0/ccproxy/__init__.py +4 -0
  21. ccproxy_api-0.1.0/ccproxy/__main__.py +7 -0
  22. ccproxy_api-0.1.0/ccproxy/_version.py +21 -0
  23. ccproxy_api-0.1.0/ccproxy/adapters/__init__.py +11 -0
  24. ccproxy_api-0.1.0/ccproxy/adapters/base.py +80 -0
  25. ccproxy_api-0.1.0/ccproxy/adapters/openai/__init__.py +43 -0
  26. ccproxy_api-0.1.0/ccproxy/adapters/openai/adapter.py +915 -0
  27. ccproxy_api-0.1.0/ccproxy/adapters/openai/models.py +412 -0
  28. ccproxy_api-0.1.0/ccproxy/adapters/openai/streaming.py +449 -0
  29. ccproxy_api-0.1.0/ccproxy/api/__init__.py +28 -0
  30. ccproxy_api-0.1.0/ccproxy/api/app.py +225 -0
  31. ccproxy_api-0.1.0/ccproxy/api/dependencies.py +140 -0
  32. ccproxy_api-0.1.0/ccproxy/api/middleware/__init__.py +11 -0
  33. ccproxy_api-0.1.0/ccproxy/api/middleware/auth.py +0 -0
  34. ccproxy_api-0.1.0/ccproxy/api/middleware/cors.py +55 -0
  35. ccproxy_api-0.1.0/ccproxy/api/middleware/errors.py +703 -0
  36. ccproxy_api-0.1.0/ccproxy/api/middleware/headers.py +51 -0
  37. ccproxy_api-0.1.0/ccproxy/api/middleware/logging.py +175 -0
  38. ccproxy_api-0.1.0/ccproxy/api/middleware/request_id.py +69 -0
  39. ccproxy_api-0.1.0/ccproxy/api/middleware/server_header.py +62 -0
  40. ccproxy_api-0.1.0/ccproxy/api/responses.py +84 -0
  41. ccproxy_api-0.1.0/ccproxy/api/routes/__init__.py +16 -0
  42. ccproxy_api-0.1.0/ccproxy/api/routes/claude.py +181 -0
  43. ccproxy_api-0.1.0/ccproxy/api/routes/health.py +489 -0
  44. ccproxy_api-0.1.0/ccproxy/api/routes/metrics.py +1033 -0
  45. ccproxy_api-0.1.0/ccproxy/api/routes/proxy.py +238 -0
  46. ccproxy_api-0.1.0/ccproxy/auth/__init__.py +75 -0
  47. ccproxy_api-0.1.0/ccproxy/auth/bearer.py +68 -0
  48. ccproxy_api-0.1.0/ccproxy/auth/credentials_adapter.py +93 -0
  49. ccproxy_api-0.1.0/ccproxy/auth/dependencies.py +229 -0
  50. ccproxy_api-0.1.0/ccproxy/auth/exceptions.py +79 -0
  51. ccproxy_api-0.1.0/ccproxy/auth/manager.py +102 -0
  52. ccproxy_api-0.1.0/ccproxy/auth/models.py +118 -0
  53. ccproxy_api-0.1.0/ccproxy/auth/oauth/__init__.py +26 -0
  54. ccproxy_api-0.1.0/ccproxy/auth/oauth/models.py +49 -0
  55. ccproxy_api-0.1.0/ccproxy/auth/oauth/routes.py +396 -0
  56. ccproxy_api-0.1.0/ccproxy/auth/oauth/storage.py +0 -0
  57. ccproxy_api-0.1.0/ccproxy/auth/storage/__init__.py +12 -0
  58. ccproxy_api-0.1.0/ccproxy/auth/storage/base.py +57 -0
  59. ccproxy_api-0.1.0/ccproxy/auth/storage/json_file.py +159 -0
  60. ccproxy_api-0.1.0/ccproxy/auth/storage/keyring.py +192 -0
  61. ccproxy_api-0.1.0/ccproxy/claude_sdk/__init__.py +20 -0
  62. ccproxy_api-0.1.0/ccproxy/claude_sdk/client.py +169 -0
  63. ccproxy_api-0.1.0/ccproxy/claude_sdk/converter.py +331 -0
  64. ccproxy_api-0.1.0/ccproxy/claude_sdk/options.py +120 -0
  65. ccproxy_api-0.1.0/ccproxy/cli/__init__.py +14 -0
  66. ccproxy_api-0.1.0/ccproxy/cli/commands/__init__.py +8 -0
  67. ccproxy_api-0.1.0/ccproxy/cli/commands/auth.py +553 -0
  68. ccproxy_api-0.1.0/ccproxy/cli/commands/config/__init__.py +14 -0
  69. ccproxy_api-0.1.0/ccproxy/cli/commands/config/commands.py +766 -0
  70. ccproxy_api-0.1.0/ccproxy/cli/commands/config/schema_commands.py +119 -0
  71. ccproxy_api-0.1.0/ccproxy/cli/commands/serve.py +630 -0
  72. ccproxy_api-0.1.0/ccproxy/cli/docker/__init__.py +34 -0
  73. ccproxy_api-0.1.0/ccproxy/cli/docker/adapter_factory.py +157 -0
  74. ccproxy_api-0.1.0/ccproxy/cli/docker/params.py +278 -0
  75. ccproxy_api-0.1.0/ccproxy/cli/helpers.py +144 -0
  76. ccproxy_api-0.1.0/ccproxy/cli/main.py +193 -0
  77. ccproxy_api-0.1.0/ccproxy/cli/options/__init__.py +14 -0
  78. ccproxy_api-0.1.0/ccproxy/cli/options/claude_options.py +216 -0
  79. ccproxy_api-0.1.0/ccproxy/cli/options/core_options.py +40 -0
  80. ccproxy_api-0.1.0/ccproxy/cli/options/security_options.py +48 -0
  81. ccproxy_api-0.1.0/ccproxy/cli/options/server_options.py +117 -0
  82. ccproxy_api-0.1.0/ccproxy/config/__init__.py +40 -0
  83. ccproxy_api-0.1.0/ccproxy/config/auth.py +154 -0
  84. ccproxy_api-0.1.0/ccproxy/config/claude.py +124 -0
  85. ccproxy_api-0.1.0/ccproxy/config/cors.py +79 -0
  86. ccproxy_api-0.1.0/ccproxy/config/discovery.py +87 -0
  87. ccproxy_api-0.1.0/ccproxy/config/docker_settings.py +265 -0
  88. ccproxy_api-0.1.0/ccproxy/config/loader.py +108 -0
  89. ccproxy_api-0.1.0/ccproxy/config/observability.py +158 -0
  90. ccproxy_api-0.1.0/ccproxy/config/pricing.py +88 -0
  91. ccproxy_api-0.1.0/ccproxy/config/reverse_proxy.py +31 -0
  92. ccproxy_api-0.1.0/ccproxy/config/scheduler.py +89 -0
  93. ccproxy_api-0.1.0/ccproxy/config/security.py +14 -0
  94. ccproxy_api-0.1.0/ccproxy/config/server.py +81 -0
  95. ccproxy_api-0.1.0/ccproxy/config/settings.py +534 -0
  96. ccproxy_api-0.1.0/ccproxy/config/validators.py +231 -0
  97. ccproxy_api-0.1.0/ccproxy/core/__init__.py +274 -0
  98. ccproxy_api-0.1.0/ccproxy/core/async_utils.py +675 -0
  99. ccproxy_api-0.1.0/ccproxy/core/constants.py +97 -0
  100. ccproxy_api-0.1.0/ccproxy/core/errors.py +256 -0
  101. ccproxy_api-0.1.0/ccproxy/core/http.py +328 -0
  102. ccproxy_api-0.1.0/ccproxy/core/http_transformers.py +428 -0
  103. ccproxy_api-0.1.0/ccproxy/core/interfaces.py +247 -0
  104. ccproxy_api-0.1.0/ccproxy/core/logging.py +189 -0
  105. ccproxy_api-0.1.0/ccproxy/core/middleware.py +114 -0
  106. ccproxy_api-0.1.0/ccproxy/core/proxy.py +143 -0
  107. ccproxy_api-0.1.0/ccproxy/core/system.py +38 -0
  108. ccproxy_api-0.1.0/ccproxy/core/transformers.py +259 -0
  109. ccproxy_api-0.1.0/ccproxy/core/types.py +129 -0
  110. ccproxy_api-0.1.0/ccproxy/core/validators.py +288 -0
  111. ccproxy_api-0.1.0/ccproxy/docker/__init__.py +67 -0
  112. ccproxy_api-0.1.0/ccproxy/docker/adapter.py +588 -0
  113. ccproxy_api-0.1.0/ccproxy/docker/docker_path.py +207 -0
  114. ccproxy_api-0.1.0/ccproxy/docker/middleware.py +103 -0
  115. ccproxy_api-0.1.0/ccproxy/docker/models.py +228 -0
  116. ccproxy_api-0.1.0/ccproxy/docker/protocol.py +192 -0
  117. ccproxy_api-0.1.0/ccproxy/docker/stream_process.py +264 -0
  118. ccproxy_api-0.1.0/ccproxy/docker/validators.py +173 -0
  119. ccproxy_api-0.1.0/ccproxy/models/__init__.py +123 -0
  120. ccproxy_api-0.1.0/ccproxy/models/errors.py +42 -0
  121. ccproxy_api-0.1.0/ccproxy/models/messages.py +243 -0
  122. ccproxy_api-0.1.0/ccproxy/models/requests.py +85 -0
  123. ccproxy_api-0.1.0/ccproxy/models/responses.py +227 -0
  124. ccproxy_api-0.1.0/ccproxy/models/types.py +102 -0
  125. ccproxy_api-0.1.0/ccproxy/observability/__init__.py +51 -0
  126. ccproxy_api-0.1.0/ccproxy/observability/access_logger.py +400 -0
  127. ccproxy_api-0.1.0/ccproxy/observability/context.py +447 -0
  128. ccproxy_api-0.1.0/ccproxy/observability/metrics.py +539 -0
  129. ccproxy_api-0.1.0/ccproxy/observability/pushgateway.py +366 -0
  130. ccproxy_api-0.1.0/ccproxy/observability/sse_events.py +303 -0
  131. ccproxy_api-0.1.0/ccproxy/observability/stats_printer.py +755 -0
  132. ccproxy_api-0.1.0/ccproxy/observability/storage/__init__.py +1 -0
  133. ccproxy_api-0.1.0/ccproxy/observability/storage/duckdb_simple.py +665 -0
  134. ccproxy_api-0.1.0/ccproxy/observability/storage/models.py +55 -0
  135. ccproxy_api-0.1.0/ccproxy/pricing/__init__.py +19 -0
  136. ccproxy_api-0.1.0/ccproxy/pricing/cache.py +212 -0
  137. ccproxy_api-0.1.0/ccproxy/pricing/loader.py +267 -0
  138. ccproxy_api-0.1.0/ccproxy/pricing/models.py +106 -0
  139. ccproxy_api-0.1.0/ccproxy/pricing/updater.py +309 -0
  140. ccproxy_api-0.1.0/ccproxy/scheduler/__init__.py +39 -0
  141. ccproxy_api-0.1.0/ccproxy/scheduler/core.py +335 -0
  142. ccproxy_api-0.1.0/ccproxy/scheduler/exceptions.py +34 -0
  143. ccproxy_api-0.1.0/ccproxy/scheduler/manager.py +186 -0
  144. ccproxy_api-0.1.0/ccproxy/scheduler/registry.py +150 -0
  145. ccproxy_api-0.1.0/ccproxy/scheduler/tasks.py +484 -0
  146. ccproxy_api-0.1.0/ccproxy/services/__init__.py +10 -0
  147. ccproxy_api-0.1.0/ccproxy/services/claude_sdk_service.py +614 -0
  148. ccproxy_api-0.1.0/ccproxy/services/credentials/__init__.py +55 -0
  149. ccproxy_api-0.1.0/ccproxy/services/credentials/config.py +105 -0
  150. ccproxy_api-0.1.0/ccproxy/services/credentials/manager.py +562 -0
  151. ccproxy_api-0.1.0/ccproxy/services/credentials/oauth_client.py +482 -0
  152. ccproxy_api-0.1.0/ccproxy/services/proxy_service.py +1536 -0
  153. ccproxy_api-0.1.0/ccproxy/static/.keep +0 -0
  154. ccproxy_api-0.1.0/ccproxy/testing/__init__.py +34 -0
  155. ccproxy_api-0.1.0/ccproxy/testing/config.py +148 -0
  156. ccproxy_api-0.1.0/ccproxy/testing/content_generation.py +197 -0
  157. ccproxy_api-0.1.0/ccproxy/testing/mock_responses.py +262 -0
  158. ccproxy_api-0.1.0/ccproxy/testing/response_handlers.py +161 -0
  159. ccproxy_api-0.1.0/ccproxy/testing/scenarios.py +241 -0
  160. ccproxy_api-0.1.0/ccproxy/utils/__init__.py +6 -0
  161. ccproxy_api-0.1.0/ccproxy/utils/cost_calculator.py +210 -0
  162. ccproxy_api-0.1.0/ccproxy/utils/streaming_metrics.py +199 -0
  163. ccproxy_api-0.1.0/data/metrics.db +0 -0
  164. ccproxy_api-0.1.0/devenv.lock +103 -0
  165. ccproxy_api-0.1.0/devenv.nix +119 -0
  166. ccproxy_api-0.1.0/docker-compose.monitoring.yml +56 -0
  167. ccproxy_api-0.1.0/docker-compose.yml +22 -0
  168. ccproxy_api-0.1.0/docs/README.md +221 -0
  169. ccproxy_api-0.1.0/docs/api-reference.md +98 -0
  170. ccproxy_api-0.1.0/docs/assets/extra.css +0 -0
  171. ccproxy_api-0.1.0/docs/assets/extra.js +15 -0
  172. ccproxy_api-0.1.0/docs/contributing.md +1 -0
  173. ccproxy_api-0.1.0/docs/development/debugging-with-proxy.md +198 -0
  174. ccproxy_api-0.1.0/docs/examples.md +114 -0
  175. ccproxy_api-0.1.0/docs/gen_ref_pages.py +41 -0
  176. ccproxy_api-0.1.0/docs/getting-started/configuration.md +704 -0
  177. ccproxy_api-0.1.0/docs/getting-started/installation.md +169 -0
  178. ccproxy_api-0.1.0/docs/getting-started/quickstart.md +630 -0
  179. ccproxy_api-0.1.0/docs/index.md +175 -0
  180. ccproxy_api-0.1.0/docs/metrics-api.md +529 -0
  181. ccproxy_api-0.1.0/docs/observability.md +82 -0
  182. ccproxy_api-0.1.0/docs/systemd-setup.md +252 -0
  183. ccproxy_api-0.1.0/docs/user-guide/api-usage.md +103 -0
  184. ccproxy_api-0.1.0/docs/user-guide/authentication.md +198 -0
  185. ccproxy_api-0.1.0/docs/user-guide/claude-code-options.md +214 -0
  186. ccproxy_api-0.1.0/docs/user-guide/claude-sdk-compatibility.md +229 -0
  187. ccproxy_api-0.1.0/docs/user-guide/mcp-integration.md +146 -0
  188. ccproxy_api-0.1.0/docs/user-guide/pool-configuration.md +162 -0
  189. ccproxy_api-0.1.0/docs/user-guide/understanding-pool-logs.md +166 -0
  190. ccproxy_api-0.1.0/examples/README.md +127 -0
  191. ccproxy_api-0.1.0/examples/README_chat_agent.md +79 -0
  192. ccproxy_api-0.1.0/examples/ai_code_discussion_demo.py +1458 -0
  193. ccproxy_api-0.1.0/examples/anthropic_streaming_demo.py +263 -0
  194. ccproxy_api-0.1.0/examples/anthropic_tools_demo.py +188 -0
  195. ccproxy_api-0.1.0/examples/client.py +313 -0
  196. ccproxy_api-0.1.0/examples/common_utils.py +266 -0
  197. ccproxy_api-0.1.0/examples/console_utils.py +360 -0
  198. ccproxy_api-0.1.0/examples/openai_anthropic_conversation_demo.py +709 -0
  199. ccproxy_api-0.1.0/examples/openai_claude_code_options_example.sh +50 -0
  200. ccproxy_api-0.1.0/examples/openai_json_object_example.sh +46 -0
  201. ccproxy_api-0.1.0/examples/openai_json_schema_example.sh +61 -0
  202. ccproxy_api-0.1.0/examples/openai_streaming_demo.py +126 -0
  203. ccproxy_api-0.1.0/examples/openai_structured_response_demo.py +238 -0
  204. ccproxy_api-0.1.0/examples/openai_thinking_demo.py +226 -0
  205. ccproxy_api-0.1.0/examples/openai_tools_demo.py +211 -0
  206. ccproxy_api-0.1.0/examples/project_code_access_demo.py +593 -0
  207. ccproxy_api-0.1.0/examples/simple_thinking_demo.py +118 -0
  208. ccproxy_api-0.1.0/examples/textual_chat_agent.py +443 -0
  209. ccproxy_api-0.1.0/mkdocs.yml +217 -0
  210. ccproxy_api-0.1.0/monitoring/grafana/dashboards/ccproxy-dashboard.json +1720 -0
  211. ccproxy_api-0.1.0/monitoring/grafana/provisioning/dashboards/dashboard.yml +12 -0
  212. ccproxy_api-0.1.0/monitoring/grafana/provisioning/datasources/victoria-metrics.yml +18 -0
  213. ccproxy_api-0.1.0/pyproject.toml +338 -0
  214. ccproxy_api-0.1.0/scripts/act-run.sh +7 -0
  215. ccproxy_api-0.1.0/scripts/benchmark_startup_node.py +394 -0
  216. ccproxy_api-0.1.0/scripts/build-docs.sh +24 -0
  217. ccproxy_api-0.1.0/scripts/entrypoint.sh +183 -0
  218. ccproxy_api-0.1.0/scripts/format_version.py +50 -0
  219. ccproxy_api-0.1.0/scripts/serve-docs.sh +18 -0
  220. ccproxy_api-0.1.0/scripts/setup-systemd.sh +210 -0
  221. ccproxy_api-0.1.0/scripts/setup.sh +45 -0
  222. ccproxy_api-0.1.0/scripts/traffic_generator.py +674 -0
  223. ccproxy_api-0.1.0/systemd/ccproxy.service.template +20 -0
  224. ccproxy_api-0.1.0/test_config/test-config.toml +5 -0
  225. ccproxy_api-0.1.0/tests/__init__.py +0 -0
  226. ccproxy_api-0.1.0/tests/conftest.py +1096 -0
  227. ccproxy_api-0.1.0/tests/factories/MIGRATION_GUIDE.md +252 -0
  228. ccproxy_api-0.1.0/tests/factories/README.md +160 -0
  229. ccproxy_api-0.1.0/tests/factories/__init__.py +24 -0
  230. ccproxy_api-0.1.0/tests/factories/fastapi_factory.py +376 -0
  231. ccproxy_api-0.1.0/tests/fixtures/MIGRATION_GUIDE.md +206 -0
  232. ccproxy_api-0.1.0/tests/fixtures/README.md +160 -0
  233. ccproxy_api-0.1.0/tests/fixtures/auth/MIGRATION_GUIDE.md +216 -0
  234. ccproxy_api-0.1.0/tests/fixtures/auth/__init__.py +51 -0
  235. ccproxy_api-0.1.0/tests/fixtures/auth/example_usage.py +287 -0
  236. ccproxy_api-0.1.0/tests/fixtures/claude_sdk/__init__.py +5 -0
  237. ccproxy_api-0.1.0/tests/fixtures/claude_sdk/internal_mocks.py +224 -0
  238. ccproxy_api-0.1.0/tests/fixtures/claude_sdk/responses.py +95 -0
  239. ccproxy_api-0.1.0/tests/fixtures/credentials.json +9 -0
  240. ccproxy_api-0.1.0/tests/fixtures/external_apis/__init__.py +5 -0
  241. ccproxy_api-0.1.0/tests/fixtures/external_apis/anthropic_api.py +177 -0
  242. ccproxy_api-0.1.0/tests/fixtures/proxy_service/__init__.py +5 -0
  243. ccproxy_api-0.1.0/tests/fixtures/proxy_service/oauth_mocks.py +91 -0
  244. ccproxy_api-0.1.0/tests/fixtures/responses.json +177 -0
  245. ccproxy_api-0.1.0/tests/test_access_logger_integration.py +461 -0
  246. ccproxy_api-0.1.0/tests/test_adapters.py +1137 -0
  247. ccproxy_api-0.1.0/tests/test_api.py +658 -0
  248. ccproxy_api-0.1.0/tests/test_auth.py +799 -0
  249. ccproxy_api-0.1.0/tests/test_cli_auth_commands.py +574 -0
  250. ccproxy_api-0.1.0/tests/test_cli_config.py +389 -0
  251. ccproxy_api-0.1.0/tests/test_cli_serve.py +482 -0
  252. ccproxy_api-0.1.0/tests/test_docker.py +522 -0
  253. ccproxy_api-0.1.0/tests/test_duckdb_lifecycle.py +267 -0
  254. ccproxy_api-0.1.0/tests/test_duckdb_settings_integration.py +149 -0
  255. ccproxy_api-0.1.0/tests/test_fastapi_factory.py +184 -0
  256. ccproxy_api-0.1.0/tests/test_http_transformers.py +1187 -0
  257. ccproxy_api-0.1.0/tests/test_metrics_api.py +502 -0
  258. ccproxy_api-0.1.0/tests/test_observability.py +1206 -0
  259. ccproxy_api-0.1.0/tests/test_pricing.py +878 -0
  260. ccproxy_api-0.1.0/tests/test_pushgateway_error_handling.py +326 -0
  261. ccproxy_api-0.1.0/tests/test_queue_duckdb_storage.py +452 -0
  262. ccproxy_api-0.1.0/tests/test_reset_endpoint.py +283 -0
  263. ccproxy_api-0.1.0/tests/test_scheduler.py +686 -0
  264. ccproxy_api-0.1.0/tests/test_scheduler_tasks.py +552 -0
  265. ccproxy_api-0.1.0/tests/test_sse_events.py +477 -0
  266. ccproxy_api-0.1.0/tests/test_sse_stream_filtering.py +529 -0
  267. ccproxy_api-0.1.0/tests/test_stats_printer.py +883 -0
  268. ccproxy_api-0.1.0/tests/test_streaming.py +547 -0
  269. ccproxy_api-0.1.0/uv.lock +3297 -0
@@ -0,0 +1,31 @@
1
+ # Claude Proxy Configuration
2
+
3
+ # Required: Anthropic API Key
4
+ ANTHROPIC_API_KEY=your_anthropic_api_key_here
5
+
6
+ # Optional: Server Configuration
7
+ HOST=0.0.0.0
8
+ PORT=8000
9
+ LOG_LEVEL=INFO
10
+
11
+ # Optional: Security Configuration
12
+ CLAUDE_USER=claude
13
+ CLAUDE_GROUP=claude
14
+ CLAUDE_WORKING_DIRECTORY=/tmp/claude-workspace
15
+
16
+ # Optional: User/Group ID mapping for Docker
17
+ # Set these to match your host user ID to avoid permission issues
18
+ # Find your user ID with: id -u
19
+ # Find your group ID with: id -g
20
+ PUID=1000
21
+ PGID=1000
22
+
23
+ # Optional: Rate Limiting
24
+ RATE_LIMIT_REQUESTS=100
25
+ RATE_LIMIT_WINDOW=60
26
+
27
+ # Optional: Request Timeout
28
+ REQUEST_TIMEOUT=300
29
+
30
+ # Optional: CORS Origins (comma-separated)
31
+ CORS_ORIGINS=*
@@ -0,0 +1,117 @@
1
+ name: Backend CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, dev]
6
+ paths:
7
+ - "ccproxy/**"
8
+ - "tests/**"
9
+ - "pyproject.toml"
10
+ - "uv.lock"
11
+ - "Makefile"
12
+ - ".github/workflows/backend.yml"
13
+ pull_request:
14
+ branches: [main, dev]
15
+ paths:
16
+ - "ccproxy/**"
17
+ - "tests/**"
18
+ - "pyproject.toml"
19
+ - "uv.lock"
20
+ - "Makefile"
21
+ - ".github/workflows/backend.yml"
22
+ workflow_dispatch:
23
+
24
+ jobs:
25
+ quality-checks:
26
+ runs-on: ubuntu-latest
27
+ name: Quality Checks (ruff + mypy)
28
+
29
+ steps:
30
+ - name: Checkout code
31
+ uses: actions/checkout@v4
32
+
33
+ - name: Install uv
34
+ uses: astral-sh/setup-uv@v4
35
+ with:
36
+ enable-cache: true
37
+
38
+ - name: Set up Python
39
+ run: uv python install
40
+
41
+ - name: Install dependencies
42
+ run: make dev-install
43
+
44
+ - name: Cache mypy
45
+ uses: actions/cache@v4
46
+ with:
47
+ path: .mypy_cache
48
+ key: mypy-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'uv.lock') }}
49
+ restore-keys: |
50
+ mypy-${{ runner.os }}-
51
+
52
+ - name: Run quality checks
53
+ run: make check
54
+
55
+ tests:
56
+ runs-on: ubuntu-latest
57
+ name: Tests
58
+ needs: quality-checks
59
+
60
+ strategy:
61
+ matrix:
62
+ python-version: ["3.11", "3.12"]
63
+
64
+ steps:
65
+ - name: Checkout code
66
+ uses: actions/checkout@v4
67
+
68
+ - name: Install uv
69
+ uses: astral-sh/setup-uv@v4
70
+ with:
71
+ enable-cache: true
72
+
73
+ - name: Set up Python ${{ matrix.python-version }}
74
+ run: uv python install ${{ matrix.python-version }}
75
+
76
+ - name: Install dependencies
77
+ run: make dev-install
78
+
79
+ - name: Run unit tests
80
+ run: make test-unit
81
+
82
+ - name: Upload coverage reports
83
+ if: matrix.python-version == '3.11'
84
+ uses: codecov/codecov-action@v4
85
+ with:
86
+ files: ./coverage.xml
87
+ fail_ci_if_error: false
88
+ env:
89
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
90
+
91
+ build-verification:
92
+ runs-on: ubuntu-latest
93
+ name: Build Verification
94
+ needs: quality-checks
95
+
96
+ steps:
97
+ - name: Checkout code
98
+ uses: actions/checkout@v4
99
+
100
+ - name: Install uv
101
+ uses: astral-sh/setup-uv@v4
102
+ with:
103
+ enable-cache: true
104
+
105
+ - name: Set up Python
106
+ run: uv python install
107
+
108
+ - name: Install dependencies
109
+ run: make dev-install
110
+
111
+ - name: Test package build
112
+ run: make build-backend
113
+
114
+ - name: Verify CLI installation
115
+ run: |
116
+ uv run ccproxy --version
117
+ uv run ccproxy --help
@@ -0,0 +1,72 @@
1
+ name: Build Docker Images
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_run:
7
+ workflows: ["CI"]
8
+ types: [completed]
9
+ branches: [main]
10
+ workflow_dispatch:
11
+
12
+ env:
13
+ REGISTRY: ghcr.io
14
+ IMAGE_NAME: ${{ github.repository }}
15
+
16
+ jobs:
17
+ build-docker:
18
+ runs-on: ubuntu-latest
19
+ if: github.event_name == 'push' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
20
+
21
+ # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
22
+ permissions:
23
+ contents: read
24
+ packages: write
25
+ attestations: write
26
+ id-token: write
27
+
28
+ steps:
29
+ - name: Checkout repository
30
+ uses: actions/checkout@v4
31
+ # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
32
+ - name: Log in to the Container registry
33
+ uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
34
+ with:
35
+ registry: ${{ env.REGISTRY }}
36
+ username: ${{ github.actor }}
37
+ password: ${{ secrets.GITHUB_TOKEN }}
38
+ # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
39
+ - name: Extract metadata (tags, labels) for Docker
40
+ id: meta
41
+ uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
42
+ with:
43
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44
+ # generate Docker tags based on the following events/attributes
45
+ tags: |
46
+ type=schedule
47
+ type=ref,event=branch
48
+ type=ref,event=pr
49
+ type=semver,pattern={{version}}
50
+ type=semver,pattern={{major}}.{{minor}}
51
+ type=semver,pattern={{major}}
52
+ type=semver,pattern={{version}}-{{branch}}
53
+ type=sha
54
+ # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
55
+ # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
56
+ # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
57
+ - name: Build and push Docker image
58
+ id: push
59
+ uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
60
+ with:
61
+ context: .
62
+ push: true
63
+ tags: ${{ steps.meta.outputs.tags }}
64
+ labels: ${{ steps.meta.outputs.labels }}
65
+
66
+ # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
67
+ - name: Generate artifact attestation
68
+ uses: actions/attest-build-provenance@v2
69
+ with:
70
+ subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
71
+ subject-digest: ${{ steps.push.outputs.digest }}
72
+ push-to-registry: true
@@ -0,0 +1,44 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, develop]
6
+ pull_request:
7
+ branches: [main, develop]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.11", "3.12", "3.13"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - uses: oven-sh/setup-bun@v2
20
+
21
+ - name: Install uv
22
+ uses: astral-sh/setup-uv@v3
23
+ with:
24
+ enable-cache: true
25
+
26
+ - name: Set up Python ${{ matrix.python-version }}
27
+ run: uv python install ${{ matrix.python-version }}
28
+
29
+ - name: Install dependencies
30
+ run: make dev-install
31
+
32
+ - name: Run CI pipeline
33
+ run: make ci
34
+
35
+ - name: Build documentation
36
+ run: make docs-build
37
+
38
+ - name: Upload coverage reports
39
+ uses: codecov/codecov-action@v4
40
+ with:
41
+ file: ./coverage.xml
42
+ flags: unittests
43
+ name: codecov-umbrella
44
+ fail_ci_if_error: false
@@ -0,0 +1,115 @@
1
+ name: Documentation
2
+
3
+ on:
4
+ push:
5
+ branches: [main, dev]
6
+ paths:
7
+ - "docs/**"
8
+ - "ccproxy/**"
9
+ - "mkdocs.yml"
10
+ - "pyproject.toml"
11
+ - ".github/workflows/docs.yml"
12
+ pull_request:
13
+ branches: [main]
14
+ paths:
15
+ - "docs/**"
16
+ - "ccproxy/**"
17
+ - "mkdocs.yml"
18
+ - "pyproject.toml"
19
+ - ".github/workflows/docs.yml"
20
+ workflow_dispatch:
21
+
22
+ permissions:
23
+ contents: read
24
+ pages: write
25
+ id-token: write
26
+
27
+ concurrency:
28
+ group: "pages"
29
+ cancel-in-progress: false
30
+
31
+ jobs:
32
+ build:
33
+ runs-on: ubuntu-latest
34
+ steps:
35
+ - name: Checkout
36
+ uses: actions/checkout@v4
37
+ with:
38
+ fetch-depth: 0
39
+
40
+ - name: Setup Python
41
+ uses: actions/setup-python@v4
42
+ with:
43
+ python-version: "3.13"
44
+
45
+ - name: Install uv
46
+ uses: astral-sh/setup-uv@v3
47
+ with:
48
+ enable-cache: true
49
+
50
+ - name: Install dependencies
51
+ run: uv sync --group docs
52
+
53
+ - name: Setup Pages
54
+ uses: actions/configure-pages@v4
55
+
56
+ - name: Build documentation
57
+ run: |
58
+ uv run mkdocs build --clean --verbose
59
+ env:
60
+ ENABLE_MKDOCSTRINGS: true
61
+
62
+ - name: Upload artifact
63
+ uses: actions/upload-pages-artifact@v3
64
+ with:
65
+ path: ./site
66
+
67
+ deploy:
68
+ if: github.ref == 'refs/heads/main' && github.event_name == 'push'
69
+ environment:
70
+ name: github-pages
71
+ url: ${{ steps.deployment.outputs.page_url }}
72
+ runs-on: ubuntu-latest
73
+ needs: build
74
+ steps:
75
+ - name: Deploy to GitHub Pages
76
+ id: deployment
77
+ uses: actions/deploy-pages@v4
78
+
79
+ check:
80
+ runs-on: ubuntu-latest
81
+ steps:
82
+ - name: Checkout
83
+ uses: actions/checkout@v4
84
+
85
+ - name: Setup Python
86
+ uses: actions/setup-python@v4
87
+ with:
88
+ python-version: "3.12"
89
+
90
+ - name: Install uv
91
+ uses: astral-sh/setup-uv@v3
92
+ with:
93
+ enable-cache: true
94
+
95
+ - name: Install dependencies
96
+ run: uv sync --group docs
97
+
98
+ - name: Check documentation links
99
+ run: |
100
+ uv run mkdocs build --clean --verbose
101
+ env:
102
+ ENABLE_MKDOCSTRINGS: true
103
+
104
+ - name: Check for broken links
105
+ run: |
106
+ # Install linkchecker if needed
107
+ pip install linkchecker
108
+ # Start a local server
109
+ uv run mkdocs serve --dev-addr 127.0.0.1:8000 &
110
+ SERVER_PID=$!
111
+ sleep 5
112
+ # Check for broken links
113
+ linkchecker http://127.0.0.1:8000 --check-extern --ignore-url=".*localhost.*" --ignore-url=".*127\.0\.0\.1.*" || true
114
+ # Kill the server
115
+ kill $SERVER_PID
@@ -0,0 +1,122 @@
1
+ name: Frontend CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main, dev ]
6
+ paths:
7
+ - 'dashboard/**'
8
+ - '.github/workflows/frontend.yml'
9
+ pull_request:
10
+ branches: [ main, dev ]
11
+ paths:
12
+ - 'dashboard/**'
13
+ - '.github/workflows/frontend.yml'
14
+ workflow_dispatch:
15
+
16
+ jobs:
17
+ quality-checks:
18
+ runs-on: ubuntu-latest
19
+ name: Quality Checks (Biome + TypeScript)
20
+ defaults:
21
+ run:
22
+ working-directory: ./dashboard
23
+
24
+ steps:
25
+ - name: Checkout code
26
+ uses: actions/checkout@v4
27
+
28
+ - name: Setup Bun
29
+ uses: oven-sh/setup-bun@v2
30
+ with:
31
+ bun-version: latest
32
+
33
+ - name: Cache Bun dependencies
34
+ uses: actions/cache@v4
35
+ with:
36
+ path: |
37
+ dashboard/node_modules
38
+ ~/.bun/install/cache
39
+ key: bun-${{ runner.os }}-${{ hashFiles('dashboard/bun.lock', 'dashboard/package.json') }}
40
+ restore-keys: |
41
+ bun-${{ runner.os }}-
42
+
43
+ - name: Install dependencies
44
+ run: make install
45
+
46
+ - name: Run quality checks
47
+ run: make check
48
+
49
+ build-and-test:
50
+ runs-on: ubuntu-latest
51
+ name: Build & Test
52
+ needs: quality-checks
53
+ defaults:
54
+ run:
55
+ working-directory: ./dashboard
56
+
57
+ steps:
58
+ - name: Checkout code
59
+ uses: actions/checkout@v4
60
+
61
+ - name: Setup Bun
62
+ uses: oven-sh/setup-bun@v2
63
+ with:
64
+ bun-version: latest
65
+
66
+ - name: Cache Bun dependencies
67
+ uses: actions/cache@v4
68
+ with:
69
+ path: |
70
+ dashboard/node_modules
71
+ ~/.bun/install/cache
72
+ key: bun-${{ runner.os }}-${{ hashFiles('dashboard/bun.lock', 'dashboard/package.json') }}
73
+ restore-keys: |
74
+ bun-${{ runner.os }}-
75
+
76
+ - name: Install dependencies
77
+ run: make install
78
+
79
+ - name: Build dashboard
80
+ run: make build
81
+
82
+ - name: Verify build output
83
+ run: |
84
+ if [ ! -f "build/index.html" ]; then
85
+ echo "❌ Build failed: index.html not found"
86
+ exit 1
87
+ fi
88
+
89
+ # Check build size (warn if > 500KB)
90
+ size=$(du -k build/index.html | cut -f1)
91
+ if [ $size -gt 500 ]; then
92
+ echo "⚠️ Warning: Dashboard bundle size is ${size}KB (> 500KB)"
93
+ else
94
+ echo "✅ Dashboard bundle size: ${size}KB"
95
+ fi
96
+
97
+ # Verify key dependencies are included
98
+ if ! grep -q "svelte" build/index.html; then
99
+ echo "❌ Svelte runtime not found in build"
100
+ exit 1
101
+ fi
102
+
103
+ echo "✅ Build verification passed"
104
+
105
+ - name: Upload build artifacts
106
+ uses: actions/upload-artifact@v4
107
+ with:
108
+ name: dashboard-build
109
+ path: dashboard/build/
110
+ retention-days: 7
111
+
112
+ - name: Test production build
113
+ run: make build
114
+
115
+ - name: Verify ccproxy static copy
116
+ run: |
117
+ if [ -d "../ccproxy/static/dashboard" ] && [ -f "../ccproxy/static/dashboard/index.html" ]; then
118
+ echo "✅ Dashboard successfully copied to ccproxy static directory"
119
+ else
120
+ echo "❌ Dashboard not found in ccproxy static directory"
121
+ exit 1
122
+ fi
@@ -0,0 +1,148 @@
1
+ name: Release
2
+
3
+ on:
4
+ release:
5
+ types: [created]
6
+ workflow_dispatch:
7
+ inputs:
8
+ force_release:
9
+ description: "Force release even if tests fail"
10
+ required: false
11
+ default: false
12
+ type: boolean
13
+
14
+ env:
15
+ REGISTRY: ghcr.io
16
+ IMAGE_NAME: ${{ github.repository }}
17
+
18
+ jobs:
19
+ test:
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+
24
+ - name: Install uv
25
+ uses: astral-sh/setup-uv@v3
26
+ with:
27
+ enable-cache: true
28
+
29
+ - name: Set up Python
30
+ run: uv python install 3.12
31
+
32
+ - name: Install dependencies
33
+ run: make dev-install
34
+
35
+ - name: Run tests
36
+ run: make ci
37
+ continue-on-error: ${{ github.event.inputs.force_release == 'true' }}
38
+
39
+ build-package:
40
+ needs: test
41
+ runs-on: ubuntu-latest
42
+ environment: publish
43
+ permissions:
44
+ id-token: write
45
+
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+
49
+ - name: Install uv
50
+ uses: astral-sh/setup-uv@v3
51
+ with:
52
+ enable-cache: true
53
+
54
+ - name: Set up Python
55
+ run: uv python install 3.12
56
+
57
+ - name: Install dependencies
58
+ run: make install
59
+
60
+ - name: Build package
61
+ run: make build
62
+
63
+ - name: Upload package artifacts
64
+ uses: actions/upload-artifact@v4
65
+ with:
66
+ name: python-package
67
+ path: dist/
68
+
69
+ - name: Publish to PyPI
70
+ if: startsWith(github.ref, 'refs/tags/')
71
+ uses: pypa/gh-action-pypi-publish@release/v1
72
+
73
+ build-release-docker:
74
+ runs-on: ubuntu-latest
75
+
76
+ # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
77
+ permissions:
78
+ contents: read
79
+ packages: write
80
+ attestations: write
81
+ id-token: write
82
+
83
+ steps:
84
+ - name: Checkout repository
85
+ uses: actions/checkout@v4
86
+ # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
87
+ - name: Log in to the Container registry
88
+ uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
89
+ with:
90
+ registry: ${{ env.REGISTRY }}
91
+ username: ${{ github.actor }}
92
+ password: ${{ secrets.GITHUB_TOKEN }}
93
+ # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
94
+ - name: Extract metadata (tags, labels) for Docker
95
+ id: meta
96
+ uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
97
+ with:
98
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
99
+ # generate Docker tags based on the following events/attributes
100
+ tags: |
101
+ type=schedule
102
+ type=ref,event=branch
103
+ type=ref,event=pr
104
+ type=semver,pattern={{version}}
105
+ type=semver,pattern={{major}}.{{minor}}
106
+ type=semver,pattern={{major}}
107
+ type=semver,pattern={{version}}-{{branch}}
108
+ type=sha
109
+ # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
110
+ # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
111
+ # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
112
+ - name: Build and push Docker image
113
+ id: push
114
+ uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
115
+ with:
116
+ context: .
117
+ push: true
118
+ tags: ${{ steps.meta.outputs.tags }}
119
+ labels: ${{ steps.meta.outputs.labels }}
120
+
121
+ # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
122
+ - name: Generate artifact attestation
123
+ uses: actions/attest-build-provenance@v2
124
+ with:
125
+ subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
126
+ subject-digest: ${{ steps.push.outputs.digest }}
127
+ push-to-registry: true
128
+
129
+ create-release:
130
+ needs: [build-package, build-release-docker]
131
+ runs-on: ubuntu-latest
132
+
133
+ steps:
134
+ - uses: actions/checkout@v4
135
+
136
+ - name: Download package artifacts
137
+ uses: actions/download-artifact@v4
138
+ with:
139
+ name: python-package
140
+ path: dist/
141
+
142
+ - name: Upload release assets
143
+ uses: softprops/action-gh-release@v2
144
+ with:
145
+ files: dist/*
146
+ generate_release_notes: true
147
+ env:
148
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}