ccproxy-api 0.1.4__tar.gz → 0.1.6__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 (359) hide show
  1. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/.pre-commit-config.yaml +4 -3
  2. ccproxy_api-0.1.6/CHANGELOG.md +403 -0
  3. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/Makefile +8 -0
  4. ccproxy_api-0.1.6/PKG-INFO +615 -0
  5. ccproxy_api-0.1.6/README.md +582 -0
  6. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/TESTING.md +93 -29
  7. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/_version.py +2 -2
  8. ccproxy_api-0.1.6/ccproxy/adapters/codex/__init__.py +11 -0
  9. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/adapters/openai/adapter.py +1 -1
  10. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/adapters/openai/models.py +1 -1
  11. ccproxy_api-0.1.6/ccproxy/adapters/openai/response_adapter.py +355 -0
  12. ccproxy_api-0.1.6/ccproxy/adapters/openai/response_models.py +178 -0
  13. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/adapters/openai/streaming.py +1 -0
  14. ccproxy_api-0.1.6/ccproxy/api/app.py +354 -0
  15. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/dependencies.py +22 -2
  16. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/middleware/errors.py +27 -3
  17. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/middleware/logging.py +4 -0
  18. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/responses.py +6 -1
  19. ccproxy_api-0.1.6/ccproxy/api/routes/claude.py +371 -0
  20. ccproxy_api-0.1.6/ccproxy/api/routes/codex.py +1231 -0
  21. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/routes/health.py +228 -3
  22. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/routes/proxy.py +25 -6
  23. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/services/permission_service.py +2 -2
  24. ccproxy_api-0.1.6/ccproxy/auth/openai/__init__.py +13 -0
  25. ccproxy_api-0.1.6/ccproxy/auth/openai/credentials.py +166 -0
  26. ccproxy_api-0.1.6/ccproxy/auth/openai/oauth_client.py +334 -0
  27. ccproxy_api-0.1.6/ccproxy/auth/openai/storage.py +184 -0
  28. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/claude_sdk/__init__.py +4 -8
  29. ccproxy_api-0.1.6/ccproxy/claude_sdk/client.py +782 -0
  30. ccproxy_api-0.1.6/ccproxy/claude_sdk/exceptions.py +16 -0
  31. ccproxy_api-0.1.6/ccproxy/claude_sdk/manager.py +219 -0
  32. ccproxy_api-0.1.6/ccproxy/claude_sdk/message_queue.py +342 -0
  33. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/claude_sdk/options.py +6 -1
  34. ccproxy_api-0.1.6/ccproxy/claude_sdk/session_client.py +546 -0
  35. ccproxy_api-0.1.6/ccproxy/claude_sdk/session_pool.py +550 -0
  36. ccproxy_api-0.1.6/ccproxy/claude_sdk/stream_handle.py +538 -0
  37. ccproxy_api-0.1.6/ccproxy/claude_sdk/stream_worker.py +392 -0
  38. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/claude_sdk/streaming.py +53 -11
  39. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/commands/auth.py +398 -1
  40. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/commands/serve.py +99 -1
  41. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/options/claude_options.py +47 -0
  42. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/config/__init__.py +0 -3
  43. ccproxy_api-0.1.6/ccproxy/config/claude.py +348 -0
  44. ccproxy_api-0.1.6/ccproxy/config/codex.py +100 -0
  45. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/config/discovery.py +10 -1
  46. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/config/scheduler.py +2 -2
  47. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/config/settings.py +38 -1
  48. ccproxy_api-0.1.6/ccproxy/core/codex_transformers.py +389 -0
  49. ccproxy_api-0.1.6/ccproxy/core/http_transformers.py +812 -0
  50. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/core/logging.py +108 -12
  51. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/core/transformers.py +5 -0
  52. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/models/claude_sdk.py +57 -0
  53. ccproxy_api-0.1.6/ccproxy/models/detection.py +208 -0
  54. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/models/requests.py +22 -0
  55. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/models/responses.py +16 -0
  56. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/observability/access_logger.py +72 -14
  57. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/observability/metrics.py +151 -0
  58. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/observability/storage/duckdb_simple.py +12 -0
  59. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/observability/storage/models.py +16 -0
  60. ccproxy_api-0.1.6/ccproxy/observability/streaming_response.py +107 -0
  61. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/scheduler/manager.py +31 -6
  62. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/scheduler/tasks.py +122 -0
  63. ccproxy_api-0.1.6/ccproxy/services/claude_detection_service.py +269 -0
  64. ccproxy_api-0.1.6/ccproxy/services/claude_sdk_service.py +713 -0
  65. ccproxy_api-0.1.6/ccproxy/services/codex_detection_service.py +263 -0
  66. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/services/proxy_service.py +618 -197
  67. ccproxy_api-0.1.6/ccproxy/utils/__init__.py +14 -0
  68. ccproxy_api-0.1.6/ccproxy/utils/disconnection_monitor.py +83 -0
  69. ccproxy_api-0.1.6/ccproxy/utils/id_generator.py +12 -0
  70. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/utils/model_mapping.py +7 -5
  71. ccproxy_api-0.1.6/ccproxy/utils/startup_helpers.py +470 -0
  72. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/devenv.lock +4 -4
  73. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/api-reference.md +45 -1
  74. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/getting-started/configuration.md +44 -1
  75. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/systemd-setup.md +9 -0
  76. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/user-guide/authentication.md +108 -11
  77. ccproxy_api-0.1.6/docs/user-guide/codex-api.md +549 -0
  78. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/pyproject.toml +5 -3
  79. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/scripts/act-run.sh +2 -2
  80. ccproxy_api-0.1.6/tests/.gitignore +7 -0
  81. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/conftest.py +199 -335
  82. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/factories/README.md +12 -45
  83. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/factories/fastapi_factory.py +51 -19
  84. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/fixtures/README.md +3 -33
  85. ccproxy_api-0.1.6/tests/fixtures/claude_sdk/client_mocks.py +146 -0
  86. ccproxy_api-0.1.6/tests/fixtures/external_apis/openai_codex_api.py +153 -0
  87. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/helpers/assertions.py +27 -0
  88. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/helpers/test_data.py +84 -0
  89. ccproxy_api-0.1.6/tests/integration/__init__.py +0 -0
  90. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/integration}/test_duckdb_settings_integration.py +1 -1
  91. ccproxy_api-0.1.6/tests/integration/test_streaming_access_logging.py +488 -0
  92. ccproxy_api-0.1.6/tests/test_cache_control_limiter.py +321 -0
  93. ccproxy_api-0.1.6/tests/unit/__init__.py +0 -0
  94. ccproxy_api-0.1.6/tests/unit/api/__init__.py +0 -0
  95. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/api}/test_api.py +99 -7
  96. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/api}/test_confirmation_routes.py +36 -21
  97. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/api}/test_mcp_route.py +1 -2
  98. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/api}/test_reset_endpoint.py +47 -31
  99. ccproxy_api-0.1.6/tests/unit/auth/__init__.py +0 -0
  100. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/auth}/test_auth.py +204 -11
  101. ccproxy_api-0.1.6/tests/unit/cli/__init__.py +0 -0
  102. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/cli}/test_cli_confirmation_handler.py +29 -19
  103. ccproxy_api-0.1.6/tests/unit/config/__init__.py +0 -0
  104. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/config}/test_claude_sdk_options.py +18 -13
  105. ccproxy_api-0.1.6/tests/unit/observability/test_streaming_response.py +274 -0
  106. ccproxy_api-0.1.6/tests/unit/services/__init__.py +0 -0
  107. ccproxy_api-0.1.6/tests/unit/services/test_claude_sdk_client.py +491 -0
  108. ccproxy_api-0.1.6/tests/unit/services/test_codex_proxy.py +379 -0
  109. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_fastapi_factory.py +13 -26
  110. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_http_transformers.py +210 -13
  111. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_observability.py +7 -1
  112. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_scheduler.py +8 -4
  113. ccproxy_api-0.1.6/tests/unit/services/test_session_pool_race_condition.py +208 -0
  114. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_streaming.py +22 -9
  115. ccproxy_api-0.1.6/tests/unit/utils/__init__.py +0 -0
  116. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/utils}/test_duckdb_lifecycle.py +1 -1
  117. ccproxy_api-0.1.6/tests/unit/utils/test_startup_helpers.py +917 -0
  118. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/uv.lock +1647 -1614
  119. ccproxy_api-0.1.4/CHANGELOG.md +0 -136
  120. ccproxy_api-0.1.4/PKG-INFO +0 -369
  121. ccproxy_api-0.1.4/README.md +0 -337
  122. ccproxy_api-0.1.4/ccproxy/api/app.py +0 -428
  123. ccproxy_api-0.1.4/ccproxy/api/routes/claude.py +0 -166
  124. ccproxy_api-0.1.4/ccproxy/claude_sdk/client.py +0 -252
  125. ccproxy_api-0.1.4/ccproxy/config/claude.py +0 -200
  126. ccproxy_api-0.1.4/ccproxy/config/loader.py +0 -105
  127. ccproxy_api-0.1.4/ccproxy/core/http_transformers.py +0 -429
  128. ccproxy_api-0.1.4/ccproxy/services/claude_sdk_service.py +0 -510
  129. ccproxy_api-0.1.4/ccproxy/utils/__init__.py +0 -6
  130. ccproxy_api-0.1.4/cleanup.sh +0 -13
  131. ccproxy_api-0.1.4/debug_stream.sh +0 -18
  132. ccproxy_api-0.1.4/debug_stream_openai.sh +0 -17
  133. ccproxy_api-0.1.4/reddit.md +0 -471
  134. ccproxy_api-0.1.4/reddit_soft.md +0 -101
  135. ccproxy_api-0.1.4/scripts/benchmark_startup_node.py +0 -392
  136. ccproxy_api-0.1.4/test_config/test-config.toml +0 -5
  137. ccproxy_api-0.1.4/test_logging.py +0 -132
  138. ccproxy_api-0.1.4/tests/factories/MIGRATION_GUIDE.md +0 -252
  139. ccproxy_api-0.1.4/tests/fixtures/MIGRATION_GUIDE.md +0 -206
  140. ccproxy_api-0.1.4/tests/fixtures/auth/MIGRATION_GUIDE.md +0 -216
  141. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/.env.example +0 -0
  142. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/.github/workflows/backend.yml +0 -0
  143. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/.github/workflows/build.yml +0 -0
  144. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/.github/workflows/ci.yml +0 -0
  145. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/.github/workflows/docs.yml +0 -0
  146. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/.github/workflows/frontend.yml.disabled +0 -0
  147. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/.github/workflows/release.yml +0 -0
  148. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/.gitignore +0 -0
  149. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/.python-version +0 -0
  150. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/CONTRIBUTING.md +0 -0
  151. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/CONVENTIONS.md +0 -0
  152. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/Dockerfile +0 -0
  153. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/LICENSE +0 -0
  154. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/__init__.py +0 -0
  155. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/__main__.py +0 -0
  156. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/adapters/__init__.py +0 -0
  157. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/adapters/base.py +0 -0
  158. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/adapters/openai/__init__.py +0 -0
  159. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/__init__.py +0 -0
  160. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/middleware/__init__.py +0 -0
  161. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/middleware/auth.py +0 -0
  162. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/middleware/cors.py +0 -0
  163. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/middleware/headers.py +0 -0
  164. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/middleware/request_content_logging.py +0 -0
  165. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/middleware/request_id.py +0 -0
  166. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/middleware/server_header.py +0 -0
  167. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/routes/__init__.py +0 -0
  168. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/routes/mcp.py +0 -0
  169. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/routes/metrics.py +0 -0
  170. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/routes/permissions.py +0 -0
  171. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/services/__init__.py +0 -0
  172. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/ui/__init__.py +0 -0
  173. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/ui/permission_handler_protocol.py +0 -0
  174. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/api/ui/terminal_permission_handler.py +0 -0
  175. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/__init__.py +0 -0
  176. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/bearer.py +0 -0
  177. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/conditional.py +0 -0
  178. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/credentials_adapter.py +0 -0
  179. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/dependencies.py +0 -0
  180. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/exceptions.py +0 -0
  181. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/manager.py +0 -0
  182. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/models.py +0 -0
  183. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/oauth/__init__.py +0 -0
  184. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/oauth/models.py +0 -0
  185. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/oauth/routes.py +0 -0
  186. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/oauth/storage.py +0 -0
  187. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/storage/__init__.py +0 -0
  188. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/storage/base.py +0 -0
  189. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/storage/json_file.py +0 -0
  190. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/auth/storage/keyring.py +0 -0
  191. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/claude_sdk/converter.py +0 -0
  192. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/claude_sdk/parser.py +0 -0
  193. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/__init__.py +0 -0
  194. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/commands/__init__.py +0 -0
  195. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/commands/config/__init__.py +0 -0
  196. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/commands/config/commands.py +0 -0
  197. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/commands/config/schema_commands.py +0 -0
  198. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/commands/permission_handler.py +0 -0
  199. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/docker/__init__.py +0 -0
  200. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/docker/adapter_factory.py +0 -0
  201. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/docker/params.py +0 -0
  202. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/helpers.py +0 -0
  203. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/main.py +0 -0
  204. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/options/__init__.py +0 -0
  205. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/options/core_options.py +0 -0
  206. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/options/security_options.py +0 -0
  207. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/cli/options/server_options.py +0 -0
  208. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/config/auth.py +0 -0
  209. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/config/cors.py +0 -0
  210. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/config/docker_settings.py +0 -0
  211. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/config/observability.py +0 -0
  212. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/config/pricing.py +0 -0
  213. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/config/reverse_proxy.py +0 -0
  214. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/config/security.py +0 -0
  215. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/config/server.py +0 -0
  216. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/config/validators.py +0 -0
  217. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/core/__init__.py +0 -0
  218. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/core/async_utils.py +0 -0
  219. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/core/constants.py +0 -0
  220. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/core/errors.py +0 -0
  221. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/core/http.py +0 -0
  222. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/core/interfaces.py +0 -0
  223. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/core/middleware.py +0 -0
  224. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/core/proxy.py +0 -0
  225. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/core/system.py +0 -0
  226. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/core/types.py +0 -0
  227. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/core/validators.py +0 -0
  228. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/docker/__init__.py +0 -0
  229. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/docker/adapter.py +0 -0
  230. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/docker/docker_path.py +0 -0
  231. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/docker/middleware.py +0 -0
  232. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/docker/models.py +0 -0
  233. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/docker/protocol.py +0 -0
  234. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/docker/stream_process.py +0 -0
  235. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/docker/validators.py +0 -0
  236. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/models/__init__.py +0 -0
  237. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/models/errors.py +0 -0
  238. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/models/messages.py +0 -0
  239. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/models/permissions.py +0 -0
  240. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/models/types.py +0 -0
  241. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/observability/__init__.py +0 -0
  242. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/observability/context.py +0 -0
  243. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/observability/pushgateway.py +0 -0
  244. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/observability/sse_events.py +0 -0
  245. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/observability/stats_printer.py +0 -0
  246. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/observability/storage/__init__.py +0 -0
  247. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/pricing/__init__.py +0 -0
  248. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/pricing/cache.py +0 -0
  249. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/pricing/loader.py +0 -0
  250. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/pricing/models.py +0 -0
  251. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/pricing/updater.py +0 -0
  252. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/scheduler/__init__.py +0 -0
  253. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/scheduler/core.py +0 -0
  254. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/scheduler/errors.py +0 -0
  255. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/scheduler/registry.py +0 -0
  256. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/services/__init__.py +0 -0
  257. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/services/credentials/__init__.py +0 -0
  258. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/services/credentials/config.py +0 -0
  259. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/services/credentials/manager.py +0 -0
  260. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/services/credentials/oauth_client.py +0 -0
  261. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/static/.keep +0 -0
  262. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/testing/__init__.py +0 -0
  263. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/testing/config.py +0 -0
  264. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/testing/content_generation.py +0 -0
  265. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/testing/mock_responses.py +0 -0
  266. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/testing/response_handlers.py +0 -0
  267. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/testing/scenarios.py +0 -0
  268. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/utils/cost_calculator.py +0 -0
  269. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/utils/models_provider.py +0 -0
  270. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/utils/simple_request_logger.py +0 -0
  271. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/utils/streaming_metrics.py +0 -0
  272. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/ccproxy/utils/version_checker.py +0 -0
  273. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/data/metrics.db +0 -0
  274. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/devenv.nix +0 -0
  275. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docker-compose.monitoring.yml +0 -0
  276. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docker-compose.yml +0 -0
  277. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/README.md +0 -0
  278. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/assets/extra.css +0 -0
  279. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/assets/extra.js +0 -0
  280. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/contributing.md +0 -0
  281. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/development/debugging-with-proxy.md +0 -0
  282. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/examples.md +0 -0
  283. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/gen_ref_pages.py +0 -0
  284. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/getting-started/installation.md +0 -0
  285. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/getting-started/quickstart.md +0 -0
  286. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/index.md +0 -0
  287. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/metrics-api.md +0 -0
  288. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/observability.md +0 -0
  289. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/user-guide/api-usage.md +0 -0
  290. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/user-guide/claude-code-options.md +0 -0
  291. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/user-guide/claude-sdk-compatibility.md +0 -0
  292. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/user-guide/mcp-integration.md +0 -0
  293. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/user-guide/pool-configuration.md +0 -0
  294. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/docs/user-guide/understanding-pool-logs.md +0 -0
  295. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/README.md +0 -0
  296. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/README_chat_agent.md +0 -0
  297. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/ai_code_discussion_demo.py +0 -0
  298. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/anthropic_streaming_demo.py +0 -0
  299. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/anthropic_tools_demo.py +0 -0
  300. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/client.py +0 -0
  301. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/common_utils.py +0 -0
  302. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/console_utils.py +0 -0
  303. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/debug_anthropic_streaming.py +0 -0
  304. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/openai_anthropic_conversation_demo.py +0 -0
  305. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/openai_claude_code_options_example.sh +0 -0
  306. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/openai_json_object_example.sh +0 -0
  307. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/openai_json_schema_example.sh +0 -0
  308. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/openai_streaming_demo.py +0 -0
  309. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/openai_structured_response_demo.py +0 -0
  310. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/openai_thinking_demo.py +0 -0
  311. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/openai_tools_demo.py +0 -0
  312. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/project_code_access_demo.py +0 -0
  313. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/simple_thinking_demo.py +0 -0
  314. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/examples/textual_chat_agent.py +0 -0
  315. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/mkdocs.yml +0 -0
  316. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/monitoring/grafana/dashboards/ccproxy-dashboard.json +0 -0
  317. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/monitoring/grafana/provisioning/dashboards/dashboard.yml +0 -0
  318. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/monitoring/grafana/provisioning/datasources/victoria-metrics.yml +0 -0
  319. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/scripts/build-docs.sh +0 -0
  320. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/scripts/entrypoint.sh +0 -0
  321. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/scripts/format_version.py +0 -0
  322. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/scripts/serve-docs.sh +0 -0
  323. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/scripts/setup-systemd.sh +0 -0
  324. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/scripts/setup.sh +0 -0
  325. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/scripts/traffic_generator.py +0 -0
  326. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/systemd/ccproxy.service.template +0 -0
  327. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/__init__.py +0 -0
  328. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/factories/__init__.py +0 -0
  329. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/fixtures/auth/__init__.py +0 -0
  330. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/fixtures/auth/example_usage.py +0 -0
  331. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/fixtures/claude_sdk/__init__.py +0 -0
  332. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/fixtures/claude_sdk/internal_mocks.py +0 -0
  333. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/fixtures/claude_sdk/responses.py +0 -0
  334. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/fixtures/credentials.json +0 -0
  335. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/fixtures/external_apis/__init__.py +0 -0
  336. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/fixtures/external_apis/anthropic_api.py +0 -0
  337. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/fixtures/proxy_service/__init__.py +0 -0
  338. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/fixtures/proxy_service/oauth_mocks.py +0 -0
  339. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/fixtures/responses.json +0 -0
  340. {ccproxy_api-0.1.4 → ccproxy_api-0.1.6}/tests/helpers/__init__.py +0 -0
  341. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/integration}/test_access_logger_integration.py +0 -0
  342. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/integration}/test_confirmation_integration.py +0 -0
  343. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/api}/test_metrics_api.py +0 -0
  344. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/cli}/test_cli_auth_commands.py +0 -0
  345. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/cli}/test_cli_config.py +0 -0
  346. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/cli}/test_cli_serve.py +0 -0
  347. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/config}/test_claude_sdk_parser.py +0 -0
  348. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/config}/test_terminal_handler.py +0 -0
  349. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_adapters.py +0 -0
  350. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_confirmation_service.py +0 -0
  351. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_docker.py +0 -0
  352. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_pricing.py +0 -0
  353. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_pushgateway_error_handling.py +0 -0
  354. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_queue_duckdb_storage.py +0 -0
  355. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_scheduler_tasks.py +0 -0
  356. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_sse_events.py +0 -0
  357. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_sse_stream_filtering.py +0 -0
  358. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/services}/test_stats_printer.py +0 -0
  359. {ccproxy_api-0.1.4/tests → ccproxy_api-0.1.6/tests/unit/utils}/test_version_checker.py +0 -0
@@ -1,7 +1,7 @@
1
1
  repos:
2
2
  # Ruff linting and formatting
3
3
  - repo: https://github.com/astral-sh/ruff-pre-commit
4
- rev: v0.12.2
4
+ rev: v0.12.8
5
5
  hooks:
6
6
  # Ruff linting (matches: make lint -> uv run ruff check .)
7
7
  - id: ruff
@@ -16,7 +16,7 @@ repos:
16
16
 
17
17
  # MyPy type checking (matches: make typecheck -> uv run mypy .)
18
18
  - repo: https://github.com/pre-commit/mirrors-mypy
19
- rev: v1.16.1
19
+ rev: v1.17.1
20
20
  hooks:
21
21
  - id: mypy
22
22
  name: mypy type check
@@ -58,6 +58,7 @@ repos:
58
58
  - textual>=3.7.1
59
59
  - aiofiles>=24.1.0
60
60
  - types-aiofiles>=24.0.0
61
+ - pyjwt>=2.10.0
61
62
  args: [--config-file=pyproject.toml]
62
63
  exclude: ^(docs/|examples/)
63
64
 
@@ -81,7 +82,7 @@ repos:
81
82
 
82
83
  # General file checks
83
84
  - repo: https://github.com/pre-commit/pre-commit-hooks
84
- rev: v5.0.0
85
+ rev: v6.0.0
85
86
  hooks:
86
87
  # Basic file checks
87
88
  - id: trailing-whitespace
@@ -0,0 +1,403 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.6] - 2025-08-04
9
+
10
+ ## Added OpenAI Codex Provider with Full Proxy Support
11
+
12
+ ### Overview
13
+
14
+ Implemented comprehensive support for OpenAI Codex CLI integration, enabling users to proxy requests through their OpenAI subscription via the ChatGPT backend API. This feature provides an alternative to the Claude provider while maintaining full compatibility with the existing proxy architecture. The implementation uses the OpenAI Responses API endpoint as documented at https://platform.openai.com/docs/api-reference/responses/get.
15
+
16
+ ### Key Features
17
+
18
+ **Complete Codex API Proxy**
19
+
20
+ - Full reverse proxy to `https://chatgpt.com/backend-api/codex`
21
+ - Support for both `/codex/responses` and `/codex/{session_id}/responses` endpoints
22
+ - Compatible with Codex CLI 0.21.0 and authentication flow
23
+ - Implements OpenAI Responses API protocol
24
+
25
+ **OAuth PKCE Authentication Flow**
26
+
27
+ - Implements complete OpenAI OAuth 2.0 PKCE flow matching official Codex CLI
28
+ - Local callback server on port 1455 for authorization code exchange
29
+ - Token refresh and credential management with persistent storage
30
+ - Support for `~/.codex/auth.json` configuration file format
31
+
32
+ **Intelligent Request/Response Handling**
33
+
34
+ - Automatic detection and injection of Codex CLI instructions field
35
+ - Smart streaming behavior based on user's explicit `stream` parameter
36
+ - Session management with flexible session ID handling (auto-generated, persistent, header-forwarded)
37
+ - Request transformation preserving Codex CLI identity headers
38
+
39
+ **Advanced Configuration**
40
+
41
+ - Environment variable support: `CODEX__BASE_URL`
42
+ - Configurable via TOML: `[codex]` section in configuration files
43
+ - Debug logging with request/response capture capabilities
44
+ - Comprehensive error handling with proper HTTP status codes
45
+ - Enabled by default
46
+
47
+ ### Technical Implementation
48
+
49
+ **New Components Added:**
50
+
51
+ - `ccproxy/auth/openai.py` - OAuth token management and credential storage
52
+ - `ccproxy/core/codex_transformers.py` - Request/response transformation for Codex format
53
+ - `ccproxy/api/routes/codex.py` - FastAPI routes for Codex endpoints
54
+ - `ccproxy/models/detection.py` - Codex CLI detection and header management
55
+ - `ccproxy/services/codex_detection_service.py` - Runtime detection of Codex CLI requests
56
+
57
+ **Enhanced Proxy Service:**
58
+
59
+ - Extended `ProxyService.handle_codex_request()` with full Codex support
60
+ - Intelligent streaming response conversion when user doesn't explicitly request streaming
61
+ - Comprehensive request/response logging for debugging
62
+ - Error handling with proper OpenAI-compatible error responses
63
+
64
+ ### Streaming Behavior Fix
65
+
66
+ **Problem Resolved:** Fixed issue where requests without explicit `stream` field were incorrectly returning streaming responses.
67
+
68
+ **Solution Implemented:**
69
+
70
+ - When `"stream"` field is missing: Inject `"stream": true` for upstream (Codex requirement) but return JSON response to client
71
+ - When `"stream": true` explicitly set: Return streaming response to client
72
+ - When `"stream": false` explicitly set: Return JSON response to client
73
+ - Smart response conversion: collects streaming data and converts to single JSON response when user didn't request streaming
74
+
75
+ ### Usage Examples
76
+
77
+ **Basic Request (JSON Response):**
78
+
79
+ ```bash
80
+ curl -X POST "http://127.0.0.1:8000/codex/responses" \
81
+ -H "Content-Type: application/json" \
82
+ -d '{
83
+ "input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Hello!"}]}],
84
+ "model": "gpt-5",
85
+ "store": false
86
+ }'
87
+ ```
88
+
89
+ **Streaming Request:**
90
+
91
+ ```bash
92
+ curl -X POST "http://127.0.0.1:8000/codex/responses" \
93
+ -H "Content-Type: application/json" \
94
+ -d '{
95
+ "input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Hello!"}]}],
96
+ "model": "gpt-5",
97
+ "stream": true,
98
+ "store": false
99
+ }'
100
+ ```
101
+
102
+ ### Authentication Setup
103
+
104
+ **Environment Variables:**
105
+
106
+ ```bash
107
+ export CODEX__BASE_URL="https://chatgpt.com/backend-api/codex"
108
+ ```
109
+
110
+ **Configuration File (`~/.ccproxy.toml`):**
111
+
112
+ ```toml
113
+ [codex]
114
+ base_url = "https://chatgpt.com/backend-api/codex"
115
+ ```
116
+
117
+ ### Compatibility
118
+
119
+ - Codex CLI: Full compatibility with `codex-cli 0.21.0`
120
+ - OpenAI OAuth: Complete PKCE flow implementation
121
+ - Session Management: Supports persistent and auto-generated sessions
122
+ - Model Support: All Codex-supported models (`gpt-5`, `gpt-4`, etc.)
123
+ - Streaming: Both streaming and non-streaming responses
124
+ - Error Handling: Proper HTTP status codes and OpenAI-compatible errors
125
+ - API Compliance: Follows OpenAI Responses API specification
126
+
127
+ ### Files Modified/Added
128
+
129
+ **New Files:**
130
+
131
+ - `ccproxy/auth/openai.py` - OpenAI authentication management
132
+ - `ccproxy/core/codex_transformers.py` - Codex request/response transformation
133
+ - `ccproxy/api/routes/codex.py` - Codex API endpoints
134
+ - `ccproxy/models/detection.py` - Codex detection models
135
+ - `ccproxy/services/codex_detection_service.py` - Codex CLI detection service
136
+
137
+ **Modified Files:**
138
+
139
+ - `ccproxy/services/proxy_service.py` - Added `handle_codex_request()` method
140
+ - `ccproxy/config/settings.py` - Added Codex configuration section
141
+ - `ccproxy/api/app.py` - Integrated Codex routes
142
+ - `ccproxy/api/routes/health.py` - Added Codex health checks
143
+
144
+ ### Breaking Changes
145
+
146
+ None. This is a purely additive feature that doesn't affect existing Claude provider functionality.
147
+
148
+ ### Migration Notes
149
+
150
+ For users wanting to use Codex provider:
151
+
152
+ 1. Authenticate: Use existing OpenAI credentials or run Codex CLI login
153
+ 2. Update endpoints: Change from `/v1/messages` to `/codex/responses`
154
+
155
+ This implementation provides a complete, production-ready OpenAI Codex proxy solution that maintains the same standards as the existing Claude provider while offering users choice in their AI provider preferences.
156
+
157
+ ## [0.1.5] - 2025-08-03
158
+
159
+ ### Added
160
+
161
+ - **Advanced Session and Pool Management**:
162
+ - Implemented a robust session-aware pool for persistent Claude SDK connections, significantly improving performance and maintaining conversation continuity.
163
+ - Introduced a hybrid pooling system that automatically transfers clients from a general pool to the session pool upon receiving a session ID.
164
+ - Developed a queue-based streaming architecture to efficiently handle and broadcast messages to multiple listeners, improving session management and disconnection handling.
165
+ - **Enhanced Observability and Logging**:
166
+ - Upgraded logging capabilities to include detailed session metadata, providing deeper insights into session lifecycle and reuse.
167
+ - Implemented a pool monitoring system to track the health and performance of both general and session-based connection pools.
168
+ - Reduced logging noise by adjusting log levels for operational SDK messages, focusing on essential access logs, warnings, and errors.
169
+ - **Improved Configuration and Control**:
170
+ - Introduced a `builtin_permissions` flag to provide granular control over the built-in permission handling infrastructure (MCP and SSE).
171
+ - Implemented configurable system prompt injection modes (`minimal` and `full`) to customize how the Claude Code identity is presented in requests.
172
+ - **Robust Streaming and Header Management**:
173
+ - Implemented `StreamingResponseWithLogging` for unified and consistent access logging across all streaming endpoints.
174
+ - Ensured critical upstream headers (e.g., `cf-ray`, `anthropic-ratelimit-*`) are correctly forwarded in SSE streaming responses.
175
+
176
+ ### Changed
177
+
178
+ - **Default Behavior**:
179
+ - The Claude SDK connection pool is now disabled by default, requiring an explicit opt-in for safer and more predictable behavior.
180
+ - **Architectural Improvements**:
181
+ - Refactored the application's startup and shutdown logic into a modular, component-based architecture for better maintainability and testability.
182
+ - Renamed `SessionContext` to `SessionClient` for improved clarity and consistency in the session pooling implementation.
183
+ - **Testing Infrastructure**:
184
+ - Reorganized the entire test suite into a hierarchical structure (`unit` and `integration`) to improve navigation and maintainability.
185
+ - Migrated from legacy test fixtures to a more flexible and maintainable factory pattern for creating test clients and application instances.
186
+
187
+ ### Fixed
188
+
189
+ - **Session and Streaming Stability**:
190
+ - Eliminated critical race conditions and `AttributeError` exceptions in the session pool and stream handling logic.
191
+ - Replaced fragile `asyncio.sleep` calls with a robust, event-based synchronization mechanism to prevent timing-related failures.
192
+ - Implemented a more accurate message-based stale detection mechanism to prevent the incorrect termination of active sessions.
193
+ - **Resource Management**:
194
+ - Corrected several resource leak issues by improving stream interruption handling, ensuring that hanging sessions are properly cleaned up.
195
+ - **Header and Content Formatting**:
196
+ - Resolved an issue that prevented the forwarding of upstream headers in SSE streaming responses.
197
+ - Fixed a formatting bug in the OpenAI adapter that caused message content to be improperly concatenated.
198
+
199
+ ### Added
200
+
201
+ - **Configurable Permission Infrastructure**: Added `builtin_permissions` configuration flag to control built-in permission handling infrastructure:
202
+ - New `builtin_permissions` flag (default: true) in ClaudeSettings for granular control
203
+ - CLI support with `--builtin-permissions/--no-builtin-permissions` options
204
+ - When disabled: No MCP server setup, no SSE permission endpoints, no permission service initialization
205
+ - When enabled: Full built-in permission infrastructure with smart MCP server merging
206
+ - Users can configure custom MCP servers independently when built-in infrastructure is disabled
207
+ - Maintains full backward compatibility with existing configurations
208
+ - **Claude SDK Pool Mode**: Implemented connection pooling for Claude Code SDK clients to improve request performance:
209
+ - Maintains a pool of pre-initialized Claude Code instances to eliminate startup overhead
210
+ - Reduces request latency by reusing established connections
211
+ - Pool mode is disabled by default and can be enabled via configuration
212
+ - **Limitations**: Pool mode does not support dynamic Claude options (max_tokens, model changes, etc.)
213
+ - Pool instances are shared across requests with identical configurations
214
+ - **Session-Aware Connection Pooling**: Added advanced session-based pooling for persistent conversation context:
215
+ - Session pools maintain dedicated Claude SDK clients per session ID for conversation continuity
216
+ - Configurable session TTL (time-to-live) with automatic cleanup of idle sessions
217
+ - Session pool settings include max sessions, idle threshold, and cleanup intervals
218
+ - Automatic connection recovery for unhealthy sessions when enabled
219
+ - Session interruption support for graceful handling of canceled requests
220
+ - Separate from the general connection pool - can be used independently or together
221
+ - Configuration via `claude.session_pool` settings with sensible defaults
222
+ - **Claude Detection Service**: Implemented automatic Claude CLI header and system prompt detection at startup:
223
+ - Automatically detects current Claude CLI version and extracts real headers/system prompt
224
+ - Caches detection results per version to avoid repeated startup delays
225
+ - Falls back to hardcoded values when detection fails
226
+ - **Detection Models**: Added Pydantic models for Claude detection data:
227
+ - `ClaudeCodeHeaders` - Structured header extraction with field aliases
228
+ - `SystemPromptData` - System prompt content with cache control
229
+ - `ClaudeCacheData` - Complete cached detection data with version tracking
230
+
231
+ ### Changed
232
+
233
+ - **Configuration Updates**: Enhanced Claude settings with new pool configuration options:
234
+ - Added `use_client_pool` boolean flag to enable general connection pooling
235
+ - Added `pool_settings` for configuring general pool behavior (size, timeouts, health checks)
236
+ - Added `session_pool` settings for session-aware pooling configuration
237
+ - Session pool enabled by default with 1-hour TTL and automatic cleanup
238
+ - **HTTP Request Transformation**: Enhanced request transformers to use detected Claude CLI headers and system prompt:
239
+ - Dynamically uses detected headers when available, falls back to hardcoded when not
240
+ - System prompt injection now uses detected Claude Code system prompt
241
+ - Added app_state parameter propagation for detection data access
242
+ - **Request Transformer Architecture**: Refactored transformers to support dynamic header and prompt injection:
243
+ - Added proxy_mode parameter to RequestTransformer base class
244
+ - Enhanced transform methods to accept app_state for detection data access
245
+ - Improved header creation logic to distinguish between detected and fallback headers
246
+ - **Test Organization Cleanup**: Finalized test suite migration and removed obsolete migration documentation:
247
+ - Removed obsolete `MIGRATION_GUIDE.md` files from factories, fixtures, and auth directories
248
+ - Cleaned up `conftest.py` by removing backward compatibility aliases for fixture names
249
+ - Updated fixture references to use direct imports from fixture modules
250
+ - Simplified FastAPI factory test organization by removing legacy compatibility layer
251
+ - Modernized fixture naming convention throughout test files (internal_claude_sdk_service vs claude_service)
252
+ - Removed unused factory fixtures and consolidated client creation patterns
253
+ - **Test Organization**: Migrated test suite from flat structure to organized hierarchy:
254
+ - Tests now organized under `tests/unit/` and `tests/integration/` directories
255
+ - Unit tests categorized by component: `api/`, `services/`, `auth/`, `config/`, `utils/`, `cli/`
256
+ - Integration tests moved to dedicated `tests/integration/` directory
257
+ - Enhanced factory pattern with `FastAPIAppFactory` for flexible test app creation
258
+ - Improved fixture organization with dedicated `tests/fixtures/` structure
259
+ - **Configuration Cleanup**: Removed unused `ConfigLoader` class and simplified configuration management
260
+ - **Logging Optimization**: Reduced permission service log verbosity from INFO to DEBUG level for cleaner production logs
261
+
262
+ ### Infrastructure
263
+
264
+ - **Test Structure**: Added `.gitignore` for test artifacts and coverage reports
265
+ - **Documentation**: Updated `TESTING.md` with new test organization and examples
266
+ - **Cache Directory**: Added automatic creation of `~/.cache/ccproxy/` for detection data persistence
267
+ - **Session Pool Components**: Added new modules for session management:
268
+ - `ccproxy/claude_sdk/session_pool.py` - Core session pool implementation
269
+ - `ccproxy/claude_sdk/session_client.py` - Session-aware client wrapper
270
+ - `ccproxy/claude_sdk/manager.py` - Unified pool management with metrics integration
271
+ - **Test Coverage**: Added comprehensive tests for session pool functionality:
272
+ - Unit tests for session lifecycle, cleanup, and recovery
273
+ - Integration tests for end-to-end session pooling behavior
274
+
275
+ ## [0.1.4] - 2025-05-28
276
+
277
+ ### Fixed
278
+
279
+ - **Pydantic Compatibility**: Fixed TypeError in model_dump_json() call by removing invalid separators parameter (issue #5)
280
+
281
+ ## [0.1.3] - 2025-07-25
282
+
283
+ ### Added
284
+
285
+ - **Version Update Checking**: Automatic version checking against GitHub releases with configurable intervals (default 12 hours) and startup checks
286
+ - **MCP Server Integration**: Added Model Context Protocol (MCP) server functionality with permission checking tools for Claude Code integration
287
+ - **Permission System**: Implemented comprehensive permission management with REST API endpoints and Server-Sent Events (SSE) streaming for real-time permission requests
288
+ - **Request/Response Logging**: Added comprehensive logging middleware with configurable verbosity levels (`CCPROXY_VERBOSE_API`, `CCPROXY_REQUEST_LOG_DIR`)
289
+ - **Claude SDK Custom Content Blocks**: Added support for `system_message`, `tool_use_sdk`, and `tool_result_sdk` content blocks with full metadata preservation
290
+ - **Model Mapping Utilities**: Centralized model provider abstraction with unified mapping logic in `ccproxy/utils/models_provider.py`
291
+ - **Terminal Permission Handler**: Interactive permission workflow handler for CLI-based permission management
292
+ - **Claude SDK Field Rendering**: Added flexible content handling with `forward`, `formatted`, and `ignore` rendering options for Claude SDK fields
293
+
294
+ ### Changed
295
+
296
+ - **Claude SDK Integration**: Refactored to use native ThinkingBlock models from Claude Code SDK
297
+ - **Models Endpoint**: Centralized `/v1/models` endpoint implementation to eliminate code duplication across routes
298
+ - **OpenAI Adapter**: Enhanced with improved modularization and streaming architecture
299
+ - **Logging System**: Migrated to canonical structlog pattern for structured, consistent logging
300
+ - **SSE Streaming**: Improved Server-Sent Events format with comprehensive examples and better error handling
301
+
302
+ ### Fixed
303
+
304
+ - **SDK Double Content**: Resolved duplicate content issue in Claude SDK message processing
305
+ - **Error Handling**: Enhanced error handling throughout Claude SDK message processing pipeline
306
+ - **Type Safety**: Improved type checking across permission system components
307
+ - **Permission Handler**: Fixed lazy initialization issues in terminal permission handler
308
+
309
+ ## [0.1.2] - 2025-07-22
310
+
311
+ ### Added
312
+
313
+ - **Permission Mode Support**: Restored `--permission-mode` option supporting default, acceptEdits, and bypassPermissions modes
314
+ - **Custom Permission Tool**: Restored `--permission-prompt-tool-name` option to specify custom permission tool names
315
+ - **Permission Response Models**: Added `PermissionToolAllowResponse` and `PermissionToolDenyResponse` models with proper JSON serialization
316
+
317
+ ### Changed
318
+
319
+ - **Message Formatting**: Modified `MessageConverter.combine_text_parts()` to join text parts with newlines instead of spaces, preserving formatting in multi-line content
320
+ - **Settings Integration**: Enhanced OptionsHandler to apply default Claude options from settings before API parameters
321
+ - **Configuration**: Extended settings to persist permission_mode and permission_prompt_tool_name
322
+
323
+ ### Fixed
324
+
325
+ - **Claude SDK Options**: Integrated Settings dependency into ClaudeSDKService to support configuration-based options
326
+
327
+ ## [0.1.1] - 2025-07-22
328
+
329
+ ### Added
330
+
331
+ - **Conditional Authentication**: API endpoints now support optional authentication - when `SECURITY__AUTH_TOKEN` is configured, authentication is enforced; when not configured, the proxy runs in open mode.
332
+ - **Startup Validation**: Added comprehensive validation checks during application startup:
333
+ - Validates OAuth credentials and warns about expired tokens
334
+ - Checks for Claude CLI binary availability with installation instructions
335
+ - Logs token expiration time and subscription type when valid
336
+ - **Default Command**: The `serve` command is now the default - running `ccproxy` without subcommands automatically starts the server.
337
+ - **Alternative Entry Point**: Added `ccproxy-api` as an alternative command-line entry point.
338
+
339
+ ### Changed
340
+
341
+ - **Authentication Variable**: Renamed environment variable from `AUTH_TOKEN` to `SECURITY__AUTH_TOKEN` for better namespace organization and clarity.
342
+ - **Credential Priority**: Reordered credential search paths to prioritize ccproxy-specific credentials before Claude CLI paths.
343
+ - **CLI Syntax**: Migrated all CLI parameters to modern Annotated syntax for better type safety and IDE support.
344
+ - **Pydantic v2**: Updated all models to use Pydantic v2 configuration syntax (`model_config` instead of `Config` class).
345
+ - **Documentation**: Improved Aider integration docs with correct API endpoint URLs and added installation options (uv, pipx).
346
+
347
+ ### Fixed
348
+
349
+ - **Authentication Separation**: Fixed critical issue where auth token was incorrectly used for both client and upstream authentication - now client auth token is separate from OAuth credentials.
350
+ - **URL Paths**: Fixed documentation to use `/api` endpoints for Aider compatibility instead of SDK mode paths.
351
+ - **Default Values**: Fixed default values for list parameters in CLI (docker_env, docker_volume, docker_arg).
352
+
353
+ ### Removed
354
+
355
+ - **Status Endpoints**: Removed redundant `/status` endpoints from both Claude SDK and proxy routes.
356
+ - **Permission Tool**: Removed Claude permission tool functionality and related CLI options (`--permission-mode`, `--permission-prompt-tool-name`) that are no longer needed.
357
+ - **Deprecated Options**: Removed references to deprecated permission_mode and permission_prompt_tool_name from documentation.
358
+
359
+ ## [0.1.0] - 2025-07-21
360
+
361
+ This is the initial public release of the CCProxy API.
362
+
363
+ ### Added
364
+
365
+ #### Core Functionality
366
+
367
+ - **Personal Claude Access**: Enables using a personal Claude Pro, Team, or Enterprise subscription as an API endpoint, without needing separate API keys.
368
+ - **OAuth2 Authentication**: Implements the official Claude OAuth2 flow for secure, local authentication.
369
+ - **Local Proxy Server**: Runs a lightweight FastAPI server on your local machine.
370
+ - **HTTP/HTTPS Proxy Support**: Full support for routing requests through an upstream HTTP or HTTPS proxy.
371
+
372
+ #### API & Compatibility
373
+
374
+ - **Dual API Support**: Provides full compatibility with both Anthropic and OpenAI API specifications.
375
+ - **Anthropic Messages API**: Native support for the Anthropic Messages API at `/v1/chat/completions`.
376
+ - **OpenAI Chat Completions API**: Compatibility layer for the OpenAI Chat Completions API at `/openai/v1/chat/completions`.
377
+ - **Request/Response Translation**: Seamlessly translates requests and responses between OpenAI and Anthropic formats.
378
+ - **Streaming Support**: Real-time streaming for both Anthropic and OpenAI-compatible endpoints.
379
+ - **Model Endpoints**: Lists available models via `/v1/models` and `/openai/v1/models`.
380
+ - **Health Check**: A `/health` endpoint for monitoring the proxy's status.
381
+
382
+ #### Configuration & CLI
383
+
384
+ - **Unified `ccproxy` CLI**: A single, user-friendly command-line interface for managing the proxy.
385
+ - **TOML Configuration**: Configure the server using a `config.toml` file with JSON Schema validation.
386
+ - **Keyring Integration**: Securely stores and manages OAuth credentials in the system's native keyring.
387
+ - **`generate-token` Command**: A CLI command to manually generate and manage API tokens.
388
+ - **Systemd Integration**: Includes a setup script and service template for running the proxy as a systemd service in production environments.
389
+ - **Docker Support**: A `Dockerfile` and `docker-compose.yml` for running the proxy in an isolated containerized environment.
390
+
391
+ #### Security
392
+
393
+ - **Local-First Design**: All processing and authentication happens locally; no conversation data is stored or transmitted to third parties.
394
+ - **Credential Security**: OAuth tokens are stored securely in the system keyring, not in plaintext files.
395
+ - **Header Stripping**: Automatically removes client-side `Authorization` headers to prevent accidental key leakage.
396
+
397
+ #### Developer Experience
398
+
399
+ - **Comprehensive Documentation**: Includes a quick start guide, API reference, and setup instructions.
400
+ - **Pre-commit Hooks**: Configured for automated code formatting and linting to ensure code quality.
401
+ - **Modern Tooling**: Uses `uv` for package management and `devenv` for a reproducible development environment.
402
+ - **Extensive Test Suite**: Includes unit, integration, and benchmark tests to ensure reliability.
403
+ - **Rich Logging**: Structured and colorized logging for improved readability during development and debugging.
@@ -81,6 +81,14 @@ clean:
81
81
  # - 'unit': Fast unit tests (< 1s each, no external dependencies)
82
82
  # - Tests without 'real_api' marker are considered unit tests by default
83
83
 
84
+ # Fix code with unsafe fixes
85
+ fix-hard:
86
+ uv run ruff check . --fix --unsafe-fixes
87
+ uv run uv run ruff check . --select F401 --fix --unsafe-fixes # Used variable import
88
+ uv run uv run ruff check . --select I --fix --unsafe-fixes # Import order
89
+ uv run ruff format .
90
+
91
+
84
92
  fix: format lint-fix
85
93
  ruff check . --fix --unsafe-fixes
86
94