codex-as-api 0.10.1__tar.gz → 0.10.2__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 (60) hide show
  1. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/PKG-INFO +17 -182
  2. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/README.md +13 -178
  3. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/RELEASES.md +22 -0
  4. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/pyproject.toml +4 -4
  5. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/scripts/check_package_versions.py +48 -2
  6. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/scripts/check_release_artifacts.py +1 -1
  7. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/__init__.py +1 -1
  8. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/server.py +5 -3
  9. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_package_versions.py +63 -0
  10. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_provider.py +40 -3
  11. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_registry_release.py +16 -16
  12. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_release_artifacts.py +3 -3
  13. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_server.py +57 -1
  14. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_standalone_login_api.py +4 -1
  15. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/.gitignore +0 -0
  16. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/LICENSE +0 -0
  17. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/THIRD_PARTY_NOTICES.md +0 -0
  18. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/config/codex-upstream-contract.json +0 -0
  19. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/config/o200k_base.tiktoken +0 -0
  20. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/config/verified-hidden-models.json +0 -0
  21. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/requirements.txt +0 -0
  22. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/rust/THIRD_PARTY_NOTICES.md +0 -0
  23. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/scripts/check_no_static_model_catalog.py +0 -0
  24. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/scripts/check_registry_release.py +0 -0
  25. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/scripts/generate_rust_third_party_notices.py +0 -0
  26. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/scripts/package_rust_release.py +0 -0
  27. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/anthropic_adapter.py +0 -0
  28. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/auth.py +0 -0
  29. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/browser_login.py +0 -0
  30. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/codex_config.py +0 -0
  31. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/codex_version.py +0 -0
  32. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/device_login.py +0 -0
  33. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/messages.py +0 -0
  34. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/model_capabilities.py +0 -0
  35. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/o200k_tokenizer.py +0 -0
  36. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/protocol.py +0 -0
  37. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/provider.py +0 -0
  38. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/reasoning_signature.py +0 -0
  39. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/src/codex_as_api/strict_json.py +0 -0
  40. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/__init__.py +0 -0
  41. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/conftest.py +0 -0
  42. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/fixtures/o200k_base_encode_ordinary.json +0 -0
  43. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_anthropic_adapter.py +0 -0
  44. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_auth.py +0 -0
  45. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_browser_login.py +0 -0
  46. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_codex_config.py +0 -0
  47. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_codex_version.py +0 -0
  48. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_device_login.py +0 -0
  49. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_login_commit_races.py +0 -0
  50. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_login_generation.py +0 -0
  51. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_login_http_real_store.py +0 -0
  52. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_management_body.py +0 -0
  53. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_messages.py +0 -0
  54. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_model_capabilities.py +0 -0
  55. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_no_static_model_catalog.py +0 -0
  56. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_o200k_tokenizer.py +0 -0
  57. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_protocol.py +0 -0
  58. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_rust_third_party_notices.py +0 -0
  59. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_strict_json.py +0 -0
  60. {codex_as_api-0.10.1 → codex_as_api-0.10.2}/tests/test_ultrafast.py +0 -0
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: codex-as-api
3
- Version: 0.10.1
3
+ Version: 0.10.2
4
4
  Summary: Use ChatGPT/Codex OAuth as a local OpenAI-compatible API server.
5
- Project-URL: Homepage, https://github.com/Eunho-J/codex-as-api
6
- Project-URL: Repository, https://github.com/Eunho-J/codex-as-api
7
- Author: Eunho-J
5
+ Project-URL: Homepage, https://github.com/CHOAM-CO/codex-as-api
6
+ Project-URL: Repository, https://github.com/CHOAM-CO/codex-as-api
7
+ Author: CHOAM
8
8
  License: Apache-2.0
9
9
  License-File: LICENSE
10
10
  Keywords: api,chatgpt,codex,llm,oauth,openai
@@ -35,10 +35,10 @@ Description-Content-Type: text/markdown
35
35
 
36
36
  # codex-as-api
37
37
 
38
- [![GitHub Release](https://img.shields.io/github/v/release/Eunho-J/codex-as-api)](https://github.com/Eunho-J/codex-as-api/releases)
38
+ [![GitHub Release](https://img.shields.io/github/v/release/CHOAM-CO/codex-as-api)](https://github.com/CHOAM-CO/codex-as-api/releases)
39
39
  [![PyPI](https://img.shields.io/pypi/v/codex-as-api)](https://pypi.org/project/codex-as-api/)
40
40
  [![npm](https://img.shields.io/npm/v/codex-as-api)](https://www.npmjs.com/package/codex-as-api)
41
- [![License](https://img.shields.io/github/license/Eunho-J/codex-as-api)](LICENSE)
41
+ [![License](https://img.shields.io/github/license/CHOAM-CO/codex-as-api)](LICENSE)
42
42
 
43
43
  Use ChatGPT / Codex OAuth as a local OpenAI-compatible API server.
44
44
 
@@ -100,7 +100,7 @@ codex-as-api
100
100
  Or from source:
101
101
 
102
102
  ```bash
103
- git clone https://github.com/Eunho-J/codex-as-api.git
103
+ git clone https://github.com/CHOAM-CO/codex-as-api.git
104
104
  cd codex-as-api
105
105
  pip install -e .
106
106
  codex-as-api
@@ -298,7 +298,7 @@ These three upstream-hidden models returned real responses on October 24, 2026,
298
298
 
299
299
  A small authenticated smoke test also verified function-tool calling plus tool-result continuation for all three models, and executed a simple generated JavaScript function against four inputs per model. This is a basic functionality check, not a coding-quality benchmark.
300
300
 
301
- **These are hidden models. Upstream support can stop at any time, and availability may differ by account. If a model stops responding, [open an issue](https://github.com/Eunho-J/codex-as-api/issues) with its model ID and a sanitized error; we will remove the discontinued model from this catalog.** Do not include access tokens or other credentials in the issue.
301
+ **These are hidden models. Upstream support can stop at any time, and availability may differ by account. If a model stops responding, [open an issue](https://github.com/CHOAM-CO/codex-as-api/issues) with its model ID and a sanitized error; we will remove the discontinued model from this catalog.** Do not include access tokens or other credentials in the issue.
302
302
 
303
303
  The proxy exposes these verified exceptions as selectable models and prefers their current live capability metadata. Bundled capability records keep only these three IDs available when a successful live catalog omits them; they do not bypass OAuth, upstream rejection, or a failed/malformed catalog fetch. A successful empty upstream catalog can therefore list these experimental entries, while health/default selection still fails until an ordinary upstream default is available. The proxy never selects a hidden experimental model as its automatic default.
304
304
 
@@ -981,10 +981,12 @@ The provider handles:
981
981
  ## Release & package publishing
982
982
 
983
983
  The `Release` GitHub Actions workflow runs on a pushed `v*` tag. It rejects a
984
- tag that does not exactly match every Python, npm, and Rust version surface,
984
+ tag that does not exactly match every Python, npm, and Rust version surface or
985
+ lacks a matching `## v<version>` section in [RELEASES.md](RELEASES.md),
985
986
  runs the complete cross-runtime gate, and then publishes PyPI, npmjs, the
986
987
  scoped GitHub npm package, deterministic platform Rust ZIP archives, and one
987
- GitHub Release. Each Rust archive contains the platform binary, `LICENSE`, and
988
+ GitHub Release whose body is populated from that `RELEASES.md` section. Each
989
+ Rust archive contains the platform binary, `LICENSE`, and
988
990
  the generated `THIRD_PARTY_NOTICES.md` covering both bundled tokenizer data and
989
991
  the locked normal dependency graph across supported release targets.
990
992
 
@@ -994,10 +996,10 @@ registry setup is still required:
994
996
 
995
997
  - Create GitHub environments named `pypi` and `npm`; add deployment protection
996
998
  rules if desired.
997
- - On PyPI, add a trusted publisher for project `codex-as-api`, owner `Eunho-J`,
999
+ - On PyPI, add a trusted publisher for project `codex-as-api`, owner `CHOAM-CO`,
998
1000
  repository `codex-as-api`, workflow `release.yml`, environment `pypi`.
999
1001
  - On npmjs, add a GitHub Actions trusted publisher for package `codex-as-api`,
1000
- owner `Eunho-J`, repository `codex-as-api`, workflow `release.yml`,
1002
+ owner `CHOAM-CO`, repository `codex-as-api`, workflow `release.yml`,
1001
1003
  environment `npm`, with `npm publish` allowed.
1002
1004
  - GitHub Packages and GitHub Releases use the job-scoped automatic
1003
1005
  `GITHUB_TOKEN`; repository policy must allow the workflow's declared
@@ -1006,9 +1008,9 @@ registry setup is still required:
1006
1008
  After bumping every version and passing the local gate, push the matching tag:
1007
1009
 
1008
1010
  ```bash
1009
- python scripts/check_package_versions.py --tag v0.10.1
1010
- git tag v0.10.1
1011
- git push origin v0.10.1
1011
+ python scripts/check_package_versions.py --tag v0.10.2
1012
+ git tag v0.10.2
1013
+ git push origin v0.10.2
1012
1014
  ```
1013
1015
 
1014
1016
  ## Tests
@@ -1036,173 +1038,6 @@ npm install
1036
1038
  npm test
1037
1039
  ```
1038
1040
 
1039
-
1040
- ## Release Notes
1041
-
1042
- ### v0.10.1
1043
-
1044
- - Preserve mid-history `system` messages added after conversation history starts as in-place `developer` input items across Python, TypeScript, and Rust chat requests, keeping the earlier conversation history prefix stable for prompt caching while leaving remote compaction (`compact_messages`) unchanged.
1045
- - Document current preview limitations of OpenAI's public "Sign in with ChatGPT" (`chatgpt.tokens.use.direct`) route and why the Codex OAuth transport remains the default.
1046
-
1047
- ### v0.10.0
1048
-
1049
- - Sign in directly with ordinary browser OAuth; no Codex installation or existing
1050
- Codex credentials are required. Device-code login is an explicit remote option.
1051
- - Add independent admin-key-protected login start/status/cancel endpoints and a
1052
- private application-owned credential store across Python, TypeScript and Rust.
1053
- - Upgrading requires a new codex-as-api login; existing Codex credentials remain
1054
- untouched. See [Standalone login](#standalone-login) and [full release notes](RELEASES.md).
1055
-
1056
- ### v0.8.0
1057
-
1058
- - Add ChatGPT Live realtime voice to the TypeScript runtime: `POST
1059
- /v1/realtime/calls` creates an OAuth-authorized call from a client-owned WebRTC
1060
- SDP offer and returns the SDP answer, and `WS /v1/realtime/sideband/{call_id}`
1061
- relays the OpenAI realtime event sideband for headless clients. Audio stays on
1062
- the client's media plane.
1063
- - Mirror the pinned Codex call contract exactly: one identity in
1064
- `x-session-id`/`session-id`/`thread-id`, the `openai-alpha: quicksilver=v2`
1065
- handshake, `intent=quicksilver&architecture=avas`, and a session payload that
1066
- never chooses its own voice-session id.
1067
- - Document realtime as a TypeScript-only capability; Python and Rust remain
1068
- HTTP-only in this release instead of claiming cross-runtime parity.
1069
-
1070
- ### v0.7.0
1071
-
1072
- - Replace bundled model capability tables with a fresh authenticated Codex
1073
- catalog and add `GET /v1/models` across all three runtimes.
1074
- - Remove stale/unknown-model fallbacks, fabricated Anthropic signatures, silent
1075
- request downgrades, and malformed upstream recovery; return typed failures.
1076
- - Reject hosted Anthropic WebSearch instead of translating incomplete OpenAI
1077
- search lifecycle data, and require authoritative completion and final usage.
1078
- - Keep immediate Claude Code `message_start` delivery without inventing token
1079
- counts; final Anthropic fields are emitted only from authoritative provider data.
1080
- - Scope continuation history and catalog state to the authenticated account,
1081
- validate before streaming, and make `/health` report actual readiness.
1082
- - Require the official nested `tokens` auth layout, remove root-level and
1083
- noncanonical auth aliases, and reject external-host `chatgptAuthTokens`.
1084
- - Pin the validated private contract to Codex `0.153.3` and publish the exact
1085
- tested artifacts to PyPI, npmjs, GitHub Packages, and GitHub Releases.
1086
- - Install Python server dependencies with the base package so the default
1087
- `pip install codex-as-api` command produces a runnable server.
1088
-
1089
- ### v0.6.5
1090
-
1091
- - Align GPT-5.6 alias, Sol, Terra, and Luna context limits with Codex `0.147.0`
1092
- at 272,000 tokens and derive the 244,800-token automatic compact threshold.
1093
- - Pin the verified upstream request, Responses Lite, header, and model contract
1094
- to `openai/codex` commit
1095
- `be6e8eac029b183056b7e4402879f15d2c85f61b`; track its new fractional SSE
1096
- rollout-budget field without claiming an unapproved facade mapping.
1097
- - Refresh OAuth credentials five minutes before expiry, coalesce concurrent
1098
- refreshes, reload changed credentials after 401, and preserve upstream HTTP
1099
- status codes across all three servers.
1100
- - Replace startup npm version discovery with deterministic compatibility and
1101
- package-version identity in the Codex-style `User-Agent`.
1102
- - Add full cross-runtime CI plus tag-gated OIDC publishing to PyPI and npmjs,
1103
- `GITHUB_TOKEN` publishing to GitHub Packages, and GitHub Release assets.
1104
-
1105
- ### v0.6.4
1106
-
1107
- - Remove process-global generated Codex session/thread identities and require
1108
- explicit session identity when Codex metadata mode is enabled.
1109
- - Resolve Chat cache affinity as explicit `prompt_cache_key`, then
1110
- `client_metadata.session_id`, then omission.
1111
- - Derive Claude Code cache affinity from `x-claude-code-session-id` without
1112
- fabricating Codex metadata; keep normal Anthropic Messages stateless.
1113
- - Validate and strip Anthropic `cache_control` compatibility hints without
1114
- claiming unavailable breakpoint or TTL semantics.
1115
- - Update current compatibility evidence to Codex `0.145.0`, Codex `main` at
1116
- `bd2de422aa287b97b06ca6425a10935bcf1b3731`, and Claude Code `2.1.220`.
1117
-
1118
- ### v0.6.3
1119
-
1120
- - Accept Claude Code auxiliary requests that combine ambient `output_config.effort` with call-level `thinking.disabled`.
1121
- - Give explicit disabled thinking precedence and send Codex reasoning effort `none` instead of returning HTTP 400.
1122
- - Document and test `CODEX_AS_API_RESPONSES_LITE=off` for Claude Code hosted WebSearch on GPT-5.6; WebFetch needs no Responses Lite override.
1123
- - Preserve fail-loudly validation for invalid effort values and unsupported `output_config` fields.
1124
- - Add Python, TypeScript, and Rust adapter regressions, streamed `/v1/messages` coverage, and a `/count_tokens` regression for the WebSearch/WebFetch request shape.
1125
-
1126
- ### v0.6.2
1127
-
1128
- - Fix `/v1/messages/count_tokens` overcounting that could trigger Claude Code autocompaction on every turn.
1129
- - Count normalized model-visible messages, tool calls, reasoning, tool-result metadata, and tool schemas once; remove the second full raw-request-body addition.
1130
- - Port official `tiktoken` `o200k_base` ordinary encoding into Python, TypeScript, and Rust without adding a `tiktoken` package dependency or runtime rank download.
1131
- - Match the upstream Unicode text split and BPE merge ranks last checked on 2026-07-14 against `tiktoken` 0.13.0 at `08a5f3b`.
1132
- - Keep image input cost separate and count inline base64 images once rather than adding both a fixed image estimate and the base64 request bytes.
1133
- - Add matching Python, TypeScript, and Rust endpoint regressions: a 4,000-byte ASCII message now returns `1,012` instead of roughly `8,000`, and non-model control fields do not change the count.
1134
- - Validate the release with Claude Code `2.1.209` and real Codex OAuth chat.
1135
-
1136
- ### v0.6.1
1137
-
1138
- - Re-audit official Codex `0.144.4` and `main` at `393f64565ab46f09d99ca4d9bd973537e72a114b`, plus Claude Code `2.1.208`, before publishing.
1139
- - Validate Claude Code `2.1.208` with real Codex OAuth chat and tool loops, and document the official custom GPT picker entry alongside Fable, Opus, Sonnet, and Haiku.
1140
- - Route bundled GPT model IDs from Anthropic requests to the selected Codex backend model while retaining configured fallback behavior for built-in Claude model names.
1141
- - Map `output_config.effort` and Fast Mode to Codex effort and priority service tier, preserve URL images and tool-error state, and handle current context/tool beta fields without silent loss.
1142
- - Keep Messages, token counting, and remote compaction aligned on effective model limits and fail-loudly validation for output formats and image sources.
1143
- - Keep Python streaming work off the ASGI event loop and make Rust Anthropic SSE truly incremental so concurrent Claude Code requests are not stalled or buffered.
1144
- - Preserve Rust streaming authentication, rate-limit, and overload errors after OAuth refresh instead of collapsing them to generic HTTP 500 failures.
1145
- - Restrict the Python source distribution to release inputs so local agent state and unrelated runtime sources cannot enter PyPI artifacts.
1146
-
1147
- ### v0.6.0
1148
-
1149
- - Add GPT-5.6 public alias plus Sol, Terra, and Luna capability metadata, model defaults, and Codex context-window behavior.
1150
- - Refresh bundled context and default-effort metadata for current GPT-5.5, GPT-5.4, GPT-5.4 Mini, and GPT-5.2 catalog entries.
1151
- - Update Responses Lite request bodies and headers across chat, compact, and inspection paths; Lite image generation is rejected explicitly because this proxy has no standalone image-tool executor.
1152
- - Add `max`, Codex-compatible `ultra` to `max` wire conversion, future model-defined efforts, and `model_reasoning_effort` config support.
1153
- - Add GPT-5.6 reasoning effort/context, `standard` mode compatibility, capability-gated image `original` detail, standard verbosity, cache accounting, and real backend `response_id` support across Python, TypeScript, and Rust.
1154
- - Translate known `previous_response_id` values into bounded local full-history replay; reject Pro and non-null public cache policy/breakpoints or `safety_identifier` because the private Codex request contract has no equivalent field.
1155
- - Reject hosted Multi-agent and Programmatic Tool Calling on the Chat facade until their native agent/program item lifecycle can be preserved.
1156
-
1157
- ### v0.5.2
1158
-
1159
- - Support latest Codex root-level OAuth token files while keeping PAT-only, agent-identity-only, and Bedrock-only auth files explicitly unsupported.
1160
- - Add shared model capability gating for Responses Lite, parallel tool calls, verbosity, and service-tier behavior across Python, TypeScript, and Rust.
1161
- - Preserve encrypted reasoning state via top-level `reasoning.encrypted_content` include and add Codex metadata forwarding controls.
1162
-
1163
- ### v0.5.1
1164
-
1165
- - Add official Codex CLI `originator` and versioned `User-Agent` headers for ChatGPT/Codex OAuth requests.
1166
- - Resolve the latest `@openai/codex` version from npm at server startup, with `CODEX_AS_API_CODEX_CLI_VERSION` as an explicit override.
1167
-
1168
- ### v0.5.0
1169
-
1170
- - Preserve Claude Code server-tool history (`server_tool_use`, `web_search_tool_result`, MCP/advisor-like result blocks) as backend context instead of dropping it on the next turn.
1171
- - Support Anthropic `output_format` structured outputs by mapping JSON schema/object formats to OpenAI Responses `text.format`.
1172
- - Preserve `document` and `search_result` content blocks inside tool results, keep Python streaming defaults aligned, and accept unsuffixed `web_search` server-tool types across Python, TypeScript, and Rust.
1173
-
1174
- ### v0.4.0
1175
-
1176
- - Add Claude Code-compatible Anthropic hosted web search support by mapping `web_search_*` server tools to OpenAI Responses `web_search`.
1177
- - Return `server_tool_use` and `web_search_tool_result` blocks so Claude Code can parse web search results reliably.
1178
- - Prepare TypeScript package publishing to npmjs and GitHub Packages via GitHub Actions.
1179
-
1180
- ### v0.3.3
1181
-
1182
- - Stop forwarding client `max_tokens` as Codex `max_output_tokens`, restoring Claude Code compatibility with the Codex OAuth backend.
1183
- - Add Python, TypeScript, and Rust regression tests for the provider payload.
1184
-
1185
- ### v0.3.2
1186
-
1187
- - Restore immediate Anthropic streaming so Claude Code receives events without waiting for the backend response to finish.
1188
- - Use conservative local token estimates for `/v1/messages/count_tokens`; Codex OAuth has no count-only backend endpoint.
1189
- - Keep real final streaming usage metadata in `message_delta`.
1190
-
1191
- ### v0.3.1
1192
-
1193
- - Attempted real backend token counting for `/v1/messages/count_tokens` with `max_output_tokens: 0`; this is superseded by v0.3.2 because Codex OAuth rejects count-only requests.
1194
- - Forward converted Anthropic tools, tool choice, stop sequences, and thinking/reasoning settings during token-count requests.
1195
- - Propagate cumulative Anthropic streaming usage, including cache accounting, server tool use, and service tier metadata when available.
1196
- - Pass `max_output_tokens` through provider requests across Python, TypeScript, and Rust.
1197
-
1198
- ### v0.3.0
1199
-
1200
- - Read Codex CLI config from `CODEX_HOME` / `~/.codex/config.toml` across Python, TypeScript, and Rust.
1201
- - Use the configured Codex backend model while preserving Anthropic client model names in `/v1/messages` responses.
1202
- - Expose `context_window` and `auto_compact_token_limit` through `/health` and `/v1/messages/count_tokens`.
1203
- - Add Anthropic-compatible `/v1/messages/count_tokens` and `/v1/messages/compact`.
1204
- - Map context-window failures to Anthropic-style `400 invalid_request_error` responses and stream error events.
1205
-
1206
1041
  ## License
1207
1042
 
1208
1043
  Apache License 2.0 — derived from [OpenAI Codex CLI](https://github.com/openai/codex) (Apache-2.0, Copyright 2025 OpenAI).
@@ -1,9 +1,9 @@
1
1
  # codex-as-api
2
2
 
3
- [![GitHub Release](https://img.shields.io/github/v/release/Eunho-J/codex-as-api)](https://github.com/Eunho-J/codex-as-api/releases)
3
+ [![GitHub Release](https://img.shields.io/github/v/release/CHOAM-CO/codex-as-api)](https://github.com/CHOAM-CO/codex-as-api/releases)
4
4
  [![PyPI](https://img.shields.io/pypi/v/codex-as-api)](https://pypi.org/project/codex-as-api/)
5
5
  [![npm](https://img.shields.io/npm/v/codex-as-api)](https://www.npmjs.com/package/codex-as-api)
6
- [![License](https://img.shields.io/github/license/Eunho-J/codex-as-api)](LICENSE)
6
+ [![License](https://img.shields.io/github/license/CHOAM-CO/codex-as-api)](LICENSE)
7
7
 
8
8
  Use ChatGPT / Codex OAuth as a local OpenAI-compatible API server.
9
9
 
@@ -65,7 +65,7 @@ codex-as-api
65
65
  Or from source:
66
66
 
67
67
  ```bash
68
- git clone https://github.com/Eunho-J/codex-as-api.git
68
+ git clone https://github.com/CHOAM-CO/codex-as-api.git
69
69
  cd codex-as-api
70
70
  pip install -e .
71
71
  codex-as-api
@@ -263,7 +263,7 @@ These three upstream-hidden models returned real responses on October 24, 2026,
263
263
 
264
264
  A small authenticated smoke test also verified function-tool calling plus tool-result continuation for all three models, and executed a simple generated JavaScript function against four inputs per model. This is a basic functionality check, not a coding-quality benchmark.
265
265
 
266
- **These are hidden models. Upstream support can stop at any time, and availability may differ by account. If a model stops responding, [open an issue](https://github.com/Eunho-J/codex-as-api/issues) with its model ID and a sanitized error; we will remove the discontinued model from this catalog.** Do not include access tokens or other credentials in the issue.
266
+ **These are hidden models. Upstream support can stop at any time, and availability may differ by account. If a model stops responding, [open an issue](https://github.com/CHOAM-CO/codex-as-api/issues) with its model ID and a sanitized error; we will remove the discontinued model from this catalog.** Do not include access tokens or other credentials in the issue.
267
267
 
268
268
  The proxy exposes these verified exceptions as selectable models and prefers their current live capability metadata. Bundled capability records keep only these three IDs available when a successful live catalog omits them; they do not bypass OAuth, upstream rejection, or a failed/malformed catalog fetch. A successful empty upstream catalog can therefore list these experimental entries, while health/default selection still fails until an ordinary upstream default is available. The proxy never selects a hidden experimental model as its automatic default.
269
269
 
@@ -946,10 +946,12 @@ The provider handles:
946
946
  ## Release & package publishing
947
947
 
948
948
  The `Release` GitHub Actions workflow runs on a pushed `v*` tag. It rejects a
949
- tag that does not exactly match every Python, npm, and Rust version surface,
949
+ tag that does not exactly match every Python, npm, and Rust version surface or
950
+ lacks a matching `## v<version>` section in [RELEASES.md](RELEASES.md),
950
951
  runs the complete cross-runtime gate, and then publishes PyPI, npmjs, the
951
952
  scoped GitHub npm package, deterministic platform Rust ZIP archives, and one
952
- GitHub Release. Each Rust archive contains the platform binary, `LICENSE`, and
953
+ GitHub Release whose body is populated from that `RELEASES.md` section. Each
954
+ Rust archive contains the platform binary, `LICENSE`, and
953
955
  the generated `THIRD_PARTY_NOTICES.md` covering both bundled tokenizer data and
954
956
  the locked normal dependency graph across supported release targets.
955
957
 
@@ -959,10 +961,10 @@ registry setup is still required:
959
961
 
960
962
  - Create GitHub environments named `pypi` and `npm`; add deployment protection
961
963
  rules if desired.
962
- - On PyPI, add a trusted publisher for project `codex-as-api`, owner `Eunho-J`,
964
+ - On PyPI, add a trusted publisher for project `codex-as-api`, owner `CHOAM-CO`,
963
965
  repository `codex-as-api`, workflow `release.yml`, environment `pypi`.
964
966
  - On npmjs, add a GitHub Actions trusted publisher for package `codex-as-api`,
965
- owner `Eunho-J`, repository `codex-as-api`, workflow `release.yml`,
967
+ owner `CHOAM-CO`, repository `codex-as-api`, workflow `release.yml`,
966
968
  environment `npm`, with `npm publish` allowed.
967
969
  - GitHub Packages and GitHub Releases use the job-scoped automatic
968
970
  `GITHUB_TOKEN`; repository policy must allow the workflow's declared
@@ -971,9 +973,9 @@ registry setup is still required:
971
973
  After bumping every version and passing the local gate, push the matching tag:
972
974
 
973
975
  ```bash
974
- python scripts/check_package_versions.py --tag v0.10.1
975
- git tag v0.10.1
976
- git push origin v0.10.1
976
+ python scripts/check_package_versions.py --tag v0.10.2
977
+ git tag v0.10.2
978
+ git push origin v0.10.2
977
979
  ```
978
980
 
979
981
  ## Tests
@@ -1001,173 +1003,6 @@ npm install
1001
1003
  npm test
1002
1004
  ```
1003
1005
 
1004
-
1005
- ## Release Notes
1006
-
1007
- ### v0.10.1
1008
-
1009
- - Preserve mid-history `system` messages added after conversation history starts as in-place `developer` input items across Python, TypeScript, and Rust chat requests, keeping the earlier conversation history prefix stable for prompt caching while leaving remote compaction (`compact_messages`) unchanged.
1010
- - Document current preview limitations of OpenAI's public "Sign in with ChatGPT" (`chatgpt.tokens.use.direct`) route and why the Codex OAuth transport remains the default.
1011
-
1012
- ### v0.10.0
1013
-
1014
- - Sign in directly with ordinary browser OAuth; no Codex installation or existing
1015
- Codex credentials are required. Device-code login is an explicit remote option.
1016
- - Add independent admin-key-protected login start/status/cancel endpoints and a
1017
- private application-owned credential store across Python, TypeScript and Rust.
1018
- - Upgrading requires a new codex-as-api login; existing Codex credentials remain
1019
- untouched. See [Standalone login](#standalone-login) and [full release notes](RELEASES.md).
1020
-
1021
- ### v0.8.0
1022
-
1023
- - Add ChatGPT Live realtime voice to the TypeScript runtime: `POST
1024
- /v1/realtime/calls` creates an OAuth-authorized call from a client-owned WebRTC
1025
- SDP offer and returns the SDP answer, and `WS /v1/realtime/sideband/{call_id}`
1026
- relays the OpenAI realtime event sideband for headless clients. Audio stays on
1027
- the client's media plane.
1028
- - Mirror the pinned Codex call contract exactly: one identity in
1029
- `x-session-id`/`session-id`/`thread-id`, the `openai-alpha: quicksilver=v2`
1030
- handshake, `intent=quicksilver&architecture=avas`, and a session payload that
1031
- never chooses its own voice-session id.
1032
- - Document realtime as a TypeScript-only capability; Python and Rust remain
1033
- HTTP-only in this release instead of claiming cross-runtime parity.
1034
-
1035
- ### v0.7.0
1036
-
1037
- - Replace bundled model capability tables with a fresh authenticated Codex
1038
- catalog and add `GET /v1/models` across all three runtimes.
1039
- - Remove stale/unknown-model fallbacks, fabricated Anthropic signatures, silent
1040
- request downgrades, and malformed upstream recovery; return typed failures.
1041
- - Reject hosted Anthropic WebSearch instead of translating incomplete OpenAI
1042
- search lifecycle data, and require authoritative completion and final usage.
1043
- - Keep immediate Claude Code `message_start` delivery without inventing token
1044
- counts; final Anthropic fields are emitted only from authoritative provider data.
1045
- - Scope continuation history and catalog state to the authenticated account,
1046
- validate before streaming, and make `/health` report actual readiness.
1047
- - Require the official nested `tokens` auth layout, remove root-level and
1048
- noncanonical auth aliases, and reject external-host `chatgptAuthTokens`.
1049
- - Pin the validated private contract to Codex `0.153.3` and publish the exact
1050
- tested artifacts to PyPI, npmjs, GitHub Packages, and GitHub Releases.
1051
- - Install Python server dependencies with the base package so the default
1052
- `pip install codex-as-api` command produces a runnable server.
1053
-
1054
- ### v0.6.5
1055
-
1056
- - Align GPT-5.6 alias, Sol, Terra, and Luna context limits with Codex `0.147.0`
1057
- at 272,000 tokens and derive the 244,800-token automatic compact threshold.
1058
- - Pin the verified upstream request, Responses Lite, header, and model contract
1059
- to `openai/codex` commit
1060
- `be6e8eac029b183056b7e4402879f15d2c85f61b`; track its new fractional SSE
1061
- rollout-budget field without claiming an unapproved facade mapping.
1062
- - Refresh OAuth credentials five minutes before expiry, coalesce concurrent
1063
- refreshes, reload changed credentials after 401, and preserve upstream HTTP
1064
- status codes across all three servers.
1065
- - Replace startup npm version discovery with deterministic compatibility and
1066
- package-version identity in the Codex-style `User-Agent`.
1067
- - Add full cross-runtime CI plus tag-gated OIDC publishing to PyPI and npmjs,
1068
- `GITHUB_TOKEN` publishing to GitHub Packages, and GitHub Release assets.
1069
-
1070
- ### v0.6.4
1071
-
1072
- - Remove process-global generated Codex session/thread identities and require
1073
- explicit session identity when Codex metadata mode is enabled.
1074
- - Resolve Chat cache affinity as explicit `prompt_cache_key`, then
1075
- `client_metadata.session_id`, then omission.
1076
- - Derive Claude Code cache affinity from `x-claude-code-session-id` without
1077
- fabricating Codex metadata; keep normal Anthropic Messages stateless.
1078
- - Validate and strip Anthropic `cache_control` compatibility hints without
1079
- claiming unavailable breakpoint or TTL semantics.
1080
- - Update current compatibility evidence to Codex `0.145.0`, Codex `main` at
1081
- `bd2de422aa287b97b06ca6425a10935bcf1b3731`, and Claude Code `2.1.220`.
1082
-
1083
- ### v0.6.3
1084
-
1085
- - Accept Claude Code auxiliary requests that combine ambient `output_config.effort` with call-level `thinking.disabled`.
1086
- - Give explicit disabled thinking precedence and send Codex reasoning effort `none` instead of returning HTTP 400.
1087
- - Document and test `CODEX_AS_API_RESPONSES_LITE=off` for Claude Code hosted WebSearch on GPT-5.6; WebFetch needs no Responses Lite override.
1088
- - Preserve fail-loudly validation for invalid effort values and unsupported `output_config` fields.
1089
- - Add Python, TypeScript, and Rust adapter regressions, streamed `/v1/messages` coverage, and a `/count_tokens` regression for the WebSearch/WebFetch request shape.
1090
-
1091
- ### v0.6.2
1092
-
1093
- - Fix `/v1/messages/count_tokens` overcounting that could trigger Claude Code autocompaction on every turn.
1094
- - Count normalized model-visible messages, tool calls, reasoning, tool-result metadata, and tool schemas once; remove the second full raw-request-body addition.
1095
- - Port official `tiktoken` `o200k_base` ordinary encoding into Python, TypeScript, and Rust without adding a `tiktoken` package dependency or runtime rank download.
1096
- - Match the upstream Unicode text split and BPE merge ranks last checked on 2026-07-14 against `tiktoken` 0.13.0 at `08a5f3b`.
1097
- - Keep image input cost separate and count inline base64 images once rather than adding both a fixed image estimate and the base64 request bytes.
1098
- - Add matching Python, TypeScript, and Rust endpoint regressions: a 4,000-byte ASCII message now returns `1,012` instead of roughly `8,000`, and non-model control fields do not change the count.
1099
- - Validate the release with Claude Code `2.1.209` and real Codex OAuth chat.
1100
-
1101
- ### v0.6.1
1102
-
1103
- - Re-audit official Codex `0.144.4` and `main` at `393f64565ab46f09d99ca4d9bd973537e72a114b`, plus Claude Code `2.1.208`, before publishing.
1104
- - Validate Claude Code `2.1.208` with real Codex OAuth chat and tool loops, and document the official custom GPT picker entry alongside Fable, Opus, Sonnet, and Haiku.
1105
- - Route bundled GPT model IDs from Anthropic requests to the selected Codex backend model while retaining configured fallback behavior for built-in Claude model names.
1106
- - Map `output_config.effort` and Fast Mode to Codex effort and priority service tier, preserve URL images and tool-error state, and handle current context/tool beta fields without silent loss.
1107
- - Keep Messages, token counting, and remote compaction aligned on effective model limits and fail-loudly validation for output formats and image sources.
1108
- - Keep Python streaming work off the ASGI event loop and make Rust Anthropic SSE truly incremental so concurrent Claude Code requests are not stalled or buffered.
1109
- - Preserve Rust streaming authentication, rate-limit, and overload errors after OAuth refresh instead of collapsing them to generic HTTP 500 failures.
1110
- - Restrict the Python source distribution to release inputs so local agent state and unrelated runtime sources cannot enter PyPI artifacts.
1111
-
1112
- ### v0.6.0
1113
-
1114
- - Add GPT-5.6 public alias plus Sol, Terra, and Luna capability metadata, model defaults, and Codex context-window behavior.
1115
- - Refresh bundled context and default-effort metadata for current GPT-5.5, GPT-5.4, GPT-5.4 Mini, and GPT-5.2 catalog entries.
1116
- - Update Responses Lite request bodies and headers across chat, compact, and inspection paths; Lite image generation is rejected explicitly because this proxy has no standalone image-tool executor.
1117
- - Add `max`, Codex-compatible `ultra` to `max` wire conversion, future model-defined efforts, and `model_reasoning_effort` config support.
1118
- - Add GPT-5.6 reasoning effort/context, `standard` mode compatibility, capability-gated image `original` detail, standard verbosity, cache accounting, and real backend `response_id` support across Python, TypeScript, and Rust.
1119
- - Translate known `previous_response_id` values into bounded local full-history replay; reject Pro and non-null public cache policy/breakpoints or `safety_identifier` because the private Codex request contract has no equivalent field.
1120
- - Reject hosted Multi-agent and Programmatic Tool Calling on the Chat facade until their native agent/program item lifecycle can be preserved.
1121
-
1122
- ### v0.5.2
1123
-
1124
- - Support latest Codex root-level OAuth token files while keeping PAT-only, agent-identity-only, and Bedrock-only auth files explicitly unsupported.
1125
- - Add shared model capability gating for Responses Lite, parallel tool calls, verbosity, and service-tier behavior across Python, TypeScript, and Rust.
1126
- - Preserve encrypted reasoning state via top-level `reasoning.encrypted_content` include and add Codex metadata forwarding controls.
1127
-
1128
- ### v0.5.1
1129
-
1130
- - Add official Codex CLI `originator` and versioned `User-Agent` headers for ChatGPT/Codex OAuth requests.
1131
- - Resolve the latest `@openai/codex` version from npm at server startup, with `CODEX_AS_API_CODEX_CLI_VERSION` as an explicit override.
1132
-
1133
- ### v0.5.0
1134
-
1135
- - Preserve Claude Code server-tool history (`server_tool_use`, `web_search_tool_result`, MCP/advisor-like result blocks) as backend context instead of dropping it on the next turn.
1136
- - Support Anthropic `output_format` structured outputs by mapping JSON schema/object formats to OpenAI Responses `text.format`.
1137
- - Preserve `document` and `search_result` content blocks inside tool results, keep Python streaming defaults aligned, and accept unsuffixed `web_search` server-tool types across Python, TypeScript, and Rust.
1138
-
1139
- ### v0.4.0
1140
-
1141
- - Add Claude Code-compatible Anthropic hosted web search support by mapping `web_search_*` server tools to OpenAI Responses `web_search`.
1142
- - Return `server_tool_use` and `web_search_tool_result` blocks so Claude Code can parse web search results reliably.
1143
- - Prepare TypeScript package publishing to npmjs and GitHub Packages via GitHub Actions.
1144
-
1145
- ### v0.3.3
1146
-
1147
- - Stop forwarding client `max_tokens` as Codex `max_output_tokens`, restoring Claude Code compatibility with the Codex OAuth backend.
1148
- - Add Python, TypeScript, and Rust regression tests for the provider payload.
1149
-
1150
- ### v0.3.2
1151
-
1152
- - Restore immediate Anthropic streaming so Claude Code receives events without waiting for the backend response to finish.
1153
- - Use conservative local token estimates for `/v1/messages/count_tokens`; Codex OAuth has no count-only backend endpoint.
1154
- - Keep real final streaming usage metadata in `message_delta`.
1155
-
1156
- ### v0.3.1
1157
-
1158
- - Attempted real backend token counting for `/v1/messages/count_tokens` with `max_output_tokens: 0`; this is superseded by v0.3.2 because Codex OAuth rejects count-only requests.
1159
- - Forward converted Anthropic tools, tool choice, stop sequences, and thinking/reasoning settings during token-count requests.
1160
- - Propagate cumulative Anthropic streaming usage, including cache accounting, server tool use, and service tier metadata when available.
1161
- - Pass `max_output_tokens` through provider requests across Python, TypeScript, and Rust.
1162
-
1163
- ### v0.3.0
1164
-
1165
- - Read Codex CLI config from `CODEX_HOME` / `~/.codex/config.toml` across Python, TypeScript, and Rust.
1166
- - Use the configured Codex backend model while preserving Anthropic client model names in `/v1/messages` responses.
1167
- - Expose `context_window` and `auto_compact_token_limit` through `/health` and `/v1/messages/count_tokens`.
1168
- - Add Anthropic-compatible `/v1/messages/count_tokens` and `/v1/messages/compact`.
1169
- - Map context-window failures to Anthropic-style `400 invalid_request_error` responses and stream error events.
1170
-
1171
1006
  ## License
1172
1007
 
1173
1008
  Apache License 2.0 — derived from [OpenAI Codex CLI](https://github.com/openai/codex) (Apache-2.0, Copyright 2025 OpenAI).
@@ -1,5 +1,27 @@
1
1
  # Release Notes
2
2
 
3
+ ## v0.10.2
4
+
5
+ ### Realtime call & sideband deadlines and cross-runtime parity fixes
6
+
7
+ - Bound `createRealtimeCall` (`POST /v1/realtime/calls`) with a wall-clock deadline
8
+ (`REALTIME_CALL_TIMEOUT_MS = 15_000`, configurable via `timeoutMs` and `signal`)
9
+ covering the request and SDP answer read so silent or trickling upstream responses
10
+ abort with `504` instead of waiting indefinitely.
11
+ - Bound each WebSocket sideband join handshake in `relayRealtimeSideband` /
12
+ `attachRealtimeSideband` with a wall-clock deadline (`SIDEBAND_HANDSHAKE_TIMEOUT_MS = 10_000`,
13
+ configurable via `handshakeTimeoutMs`; cleared immediately on `open`), close the
14
+ client with `4504` (`realtime sideband unavailable (timeout)`) on timeout, and
15
+ reject the returned Promise on join or validation failure so callers never mark a
16
+ call live when the sideband WebSocket fails to attach. Forward the HTTP upgrade
17
+ `voice-session-id` header in `attachRealtimeSideband`.
18
+ - Reject whitespace-only `CODEX_AS_API_ADMIN_KEY` values with `503` (`management_disabled`)
19
+ in TypeScript and Rust, matching Python.
20
+ - Align Rust `POST /auth/login` request body limit to `4,096` bytes and return `400`
21
+ (`invalid_request`) when exceeded, matching Python and TypeScript.
22
+ - Derive session-scoped `prompt_cache_key` from `x-claude-code-session-id` on
23
+ `POST /v1/messages/compact` in Python and TypeScript, matching Rust.
24
+
3
25
  ## v0.10.1
4
26
 
5
27
  ### Preserve late system notes across Python, TypeScript and Rust chat histories
@@ -4,13 +4,13 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "codex-as-api"
7
- version = "0.10.1"
7
+ version = "0.10.2"
8
8
  description = "Use ChatGPT/Codex OAuth as a local OpenAI-compatible API server."
9
9
  readme = "README.md"
10
10
  license = { text = "Apache-2.0" }
11
11
  requires-python = ">=3.10"
12
12
  authors = [
13
- { name = "Eunho-J", email = "" },
13
+ { name = "CHOAM", email = "" },
14
14
  ]
15
15
  keywords = ["openai", "codex", "chatgpt", "oauth", "api", "llm"]
16
16
  classifiers = [
@@ -40,8 +40,8 @@ dev = ["pytest", "ruff", "mypy", "httpx", "types-regex", "tomli>=2.0.1"]
40
40
  codex-as-api = "codex_as_api.server:main"
41
41
 
42
42
  [project.urls]
43
- Homepage = "https://github.com/Eunho-J/codex-as-api"
44
- Repository = "https://github.com/Eunho-J/codex-as-api"
43
+ Homepage = "https://github.com/CHOAM-CO/codex-as-api"
44
+ Repository = "https://github.com/CHOAM-CO/codex-as-api"
45
45
 
46
46
  [tool.hatch.build.targets.wheel]
47
47
  packages = ["src/codex_as_api"]
@@ -212,17 +212,63 @@ def validate_versions(versions: Mapping[str, str], tag: str | None = None) -> st
212
212
  return version
213
213
 
214
214
 
215
- def main() -> int:
215
+ def extract_release_notes(path: Path, version: str) -> str:
216
+ try:
217
+ text = path.read_text(encoding="utf-8")
218
+ except OSError as error:
219
+ raise VersionCheckError(f"{path}: could not read release notes ({type(error).__name__})") from None
220
+
221
+ target_heading = f"## v{version}"
222
+ sections: list[list[str]] = []
223
+ current_lines: list[str] | None = None
224
+
225
+ for line in text.splitlines():
226
+ stripped = line.strip()
227
+ if line.startswith("## "):
228
+ if stripped == target_heading:
229
+ current_lines = []
230
+ sections.append(current_lines)
231
+ else:
232
+ current_lines = None
233
+ continue
234
+ if current_lines is not None:
235
+ current_lines.append(line)
236
+
237
+ if not sections:
238
+ raise VersionCheckError(f"{path}: missing release notes section {target_heading!r}")
239
+ if len(sections) > 1:
240
+ raise VersionCheckError(f"{path}: duplicate release notes section {target_heading!r}")
241
+
242
+ body = "\n".join(sections[0]).strip()
243
+ if not body:
244
+ raise VersionCheckError(f"{path}: release notes section {target_heading!r} must not be empty")
245
+ return body
246
+
247
+
248
+ def main(argv: list[str] | None = None) -> int:
216
249
  parser = argparse.ArgumentParser(description=__doc__)
217
250
  parser.add_argument(
218
251
  "--tag",
219
252
  help="Release tag to validate. It must be v followed by the shared package version.",
220
253
  )
221
- args = parser.parse_args()
254
+ parser.add_argument(
255
+ "--notes-output",
256
+ type=Path,
257
+ help="Optional file path to write the extracted RELEASES.md section for this version.",
258
+ )
259
+ args = parser.parse_args(argv)
222
260
 
223
261
  try:
224
262
  validate_package_names(collect_package_names(ROOT))
225
263
  version = validate_versions(collect_versions(ROOT), args.tag)
264
+ notes = extract_release_notes(ROOT / "RELEASES.md", version)
265
+ if args.notes_output is not None:
266
+ try:
267
+ args.notes_output.write_text(f"{notes}\n", encoding="utf-8")
268
+ except OSError as error:
269
+ raise VersionCheckError(
270
+ f"{args.notes_output}: could not write extracted release notes ({type(error).__name__})"
271
+ ) from None
226
272
  except VersionCheckError as error:
227
273
  print(error, file=sys.stderr)
228
274
  return 1
@@ -17,7 +17,7 @@ from typing import TypeVar
17
17
 
18
18
  PYTHON_PACKAGE_NAME = "codex-as-api"
19
19
  NPM_PACKAGE_NAME = "codex-as-api"
20
- GITHUB_NPM_PACKAGE_NAME = "@eunho-j/codex-as-api"
20
+ GITHUB_NPM_PACKAGE_NAME = "@choam-co/codex-as-api"
21
21
  REPOSITORY_ROOT = Path(__file__).resolve().parents[1]
22
22
  NPM_REQUIRED_TEXT_FILES = ("LICENSE", "THIRD_PARTY_NOTICES.md")
23
23
  SDIST_REQUIRED_SCRIPT_FILES = (
@@ -1,3 +1,3 @@
1
1
  """codex-as-api: Use ChatGPT/Codex OAuth as a local OpenAI-compatible API server."""
2
2
 
3
- __version__ = "0.10.1"
3
+ __version__ = "0.10.2"
@@ -471,7 +471,7 @@ def _health_error_message(exc: BaseException) -> str:
471
471
  app = FastAPI(
472
472
  title="codex-as-api",
473
473
  description="Local OpenAI-compatible API server backed by ChatGPT/Codex OAuth.",
474
- version="0.10.1",
474
+ version="0.10.2",
475
475
  )
476
476
 
477
477
 
@@ -2707,8 +2707,7 @@ async def compact(request: Request) -> JSONResponse:
2707
2707
  body = await _request_json_object(request)
2708
2708
  _reject_explicit_null_responses_lite(body)
2709
2709
  is_anthropic_compact = request.url.path == "/v1/messages/compact"
2710
- if is_anthropic_compact:
2711
- _claude_code_session_id(request.headers)
2710
+ claude_session_id = _claude_code_session_id(request.headers) if is_anthropic_compact else None
2712
2711
  _reject_unknown_fields(
2713
2712
  body,
2714
2713
  _ANTHROPIC_COMPACT_FIELDS if is_anthropic_compact else _OPENAI_COMPACT_FIELDS,
@@ -2789,6 +2788,9 @@ async def compact(request: Request) -> JSONResponse:
2789
2788
  "_resolved_model": resolved_model,
2790
2789
  }
2791
2790
  if is_anthropic_compact:
2791
+ prompt_cache_key = _anthropic_prompt_cache_key(body, claude_session_id)
2792
+ if prompt_cache_key is not None:
2793
+ compact_options["prompt_cache_key"] = prompt_cache_key
2792
2794
  service_tier = _anthropic_service_tier(body)
2793
2795
  if service_tier is not None:
2794
2796
  compact_options["service_tier"] = service_tier
@@ -50,6 +50,10 @@ def write_release_metadata(root: Path, version: str = "1.2.3") -> None:
50
50
  f'version = 4\n\n[[package]]\nname = "codex-as-api"\nversion = "{version}"\n',
51
51
  encoding="utf-8",
52
52
  )
53
+ (root / "RELEASES.md").write_text(
54
+ f"# Release Notes\n\n## v{version}\n\n- Validated release {version}.\n",
55
+ encoding="utf-8",
56
+ )
53
57
 
54
58
 
55
59
  def test_collect_versions_reads_every_release_version_surface(tmp_path: Path) -> None:
@@ -157,3 +161,62 @@ def test_collect_versions_rejects_missing_lockfile_root_version(tmp_path: Path)
157
161
  with pytest.raises(check_package_versions.VersionCheckError) as caught:
158
162
  check_package_versions.collect_versions(tmp_path)
159
163
  assert "packages..version" in str(caught.value)
164
+
165
+
166
+ def test_extract_release_notes_returns_exact_version_section(tmp_path: Path) -> None:
167
+ releases = tmp_path / "RELEASES.md"
168
+ releases.write_text(
169
+ "# Release Notes\n\n"
170
+ "## v1.2.4\n\n"
171
+ "- Newer item.\n\n"
172
+ "## v1.2.3\n\n"
173
+ "### Summary\n\n"
174
+ "- First change.\n"
175
+ "- Second change.\n\n"
176
+ "## v1.2.2\n\n"
177
+ "- Older item.\n",
178
+ encoding="utf-8",
179
+ )
180
+
181
+ notes = check_package_versions.extract_release_notes(releases, "1.2.3")
182
+
183
+ assert notes == "### Summary\n\n- First change.\n- Second change."
184
+
185
+
186
+ @pytest.mark.parametrize(
187
+ ("content", "expected_message"),
188
+ [
189
+ ("# Release Notes\n\n## v1.2.2\n\n- Older item.\n", "missing release notes section '## v1.2.3'"),
190
+ (
191
+ "# Release Notes\n\n## v1.2.3\n\n- First.\n\n## v1.2.3\n\n- Duplicate.\n",
192
+ "duplicate release notes section '## v1.2.3'",
193
+ ),
194
+ ("# Release Notes\n\n## v1.2.3\n\n \n## v1.2.2\n\n- Older.\n", "must not be empty"),
195
+ ],
196
+ )
197
+ def test_extract_release_notes_rejects_missing_duplicate_or_empty_section(
198
+ tmp_path: Path, content: str, expected_message: str
199
+ ) -> None:
200
+ releases = tmp_path / "RELEASES.md"
201
+ releases.write_text(content, encoding="utf-8")
202
+
203
+ with pytest.raises(check_package_versions.VersionCheckError) as caught:
204
+ check_package_versions.extract_release_notes(releases, "1.2.3")
205
+ assert expected_message in str(caught.value)
206
+
207
+
208
+ def test_extract_release_notes_rejects_missing_file(tmp_path: Path) -> None:
209
+ with pytest.raises(check_package_versions.VersionCheckError) as caught:
210
+ check_package_versions.extract_release_notes(tmp_path / "RELEASES.md", "1.2.3")
211
+ assert "could not read release notes" in str(caught.value)
212
+
213
+
214
+ def test_main_writes_notes_output_file(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
215
+ write_release_metadata(tmp_path, "1.2.3")
216
+ monkeypatch.setattr(check_package_versions, "ROOT", tmp_path)
217
+ output_file = tmp_path / "release-notes.md"
218
+
219
+ exit_code = check_package_versions.main(["--tag", "v1.2.3", "--notes-output", str(output_file)])
220
+
221
+ assert exit_code == 0
222
+ assert output_file.read_text(encoding="utf-8") == "- Validated release 1.2.3.\n"
@@ -2196,7 +2196,7 @@ def test_codex_cli_headers_include_official_originator_and_versioned_user_agent(
2196
2196
 
2197
2197
  assert headers["originator"] == "codex_cli_rs"
2198
2198
  assert headers["User-Agent"].startswith("codex_cli_rs/0.164.0 (")
2199
- assert headers["User-Agent"].endswith(") codex-as-api/0.10.1")
2199
+ assert headers["User-Agent"].endswith(") codex-as-api/0.10.2")
2200
2200
 
2201
2201
 
2202
2202
  def test_codex_cli_headers_reject_unpinned_version():
@@ -2936,7 +2936,7 @@ def test_provider_headers_include_codex_cli_headers(auth_json_factory):
2936
2936
 
2937
2937
  assert headers["originator"] == "codex_cli_rs"
2938
2938
  assert headers["User-Agent"].startswith("codex_cli_rs/0.164.0 (")
2939
- assert headers["User-Agent"].endswith(") codex-as-api/0.10.1")
2939
+ assert headers["User-Agent"].endswith(") codex-as-api/0.10.2")
2940
2940
  assert headers["Authorization"].startswith("Bearer ")
2941
2941
 
2942
2942
 
@@ -3549,6 +3549,43 @@ def test_split_instructions_multiple_system_joined():
3549
3549
  assert instructions == "Part one.\n\nPart two."
3550
3550
 
3551
3551
 
3552
+ def test_split_instructions_keeps_only_leading_system_prefix_unless_combining_all():
3553
+ messages = [
3554
+ Message(role=MessageRole.SYSTEM, content="S0"),
3555
+ Message(role=MessageRole.SYSTEM, content="S1"),
3556
+ Message(role=MessageRole.USER, content="U0"),
3557
+ Message(role=MessageRole.ASSISTANT, content="A0"),
3558
+ Message(role=MessageRole.SYSTEM, content="S2"),
3559
+ Message(role=MessageRole.SYSTEM, content="S3"),
3560
+ Message(role=MessageRole.USER, content="U1"),
3561
+ ]
3562
+ chat_instructions, chat_items = _split_instructions_and_input(
3563
+ messages,
3564
+ preserve_system_positions=True,
3565
+ )
3566
+ compact_instructions, compact_items = _split_instructions_and_input(messages)
3567
+ assert chat_instructions == "S0\n\nS1"
3568
+ assert [
3569
+ (item["role"], item["content"][0]["text"])
3570
+ for item in chat_items
3571
+ ] == [
3572
+ ("user", "U0"),
3573
+ ("assistant", "A0"),
3574
+ ("developer", "S2"),
3575
+ ("developer", "S3"),
3576
+ ("user", "U1"),
3577
+ ]
3578
+ assert compact_instructions == "S0\n\nS1\n\nS2\n\nS3"
3579
+ assert [
3580
+ (item["role"], item["content"][0]["text"])
3581
+ for item in compact_items
3582
+ ] == [
3583
+ ("user", "U0"),
3584
+ ("assistant", "A0"),
3585
+ ("user", "U1"),
3586
+ ]
3587
+
3588
+
3552
3589
  @pytest.mark.parametrize("with_reasoning", [False, True])
3553
3590
  def test_responses_payload_keeps_late_system_notes_after_tool_results(with_reasoning):
3554
3591
  provider = ChatGPTOAuthProvider()
@@ -4572,7 +4609,7 @@ def test_provider_injects_dynamic_npm_version_across_catalog_responses_and_401_r
4572
4609
  for full_url, headers in observed_requests:
4573
4610
  assert full_url == "https://example.test/codex/models?client_version=0.175.2"
4574
4611
  assert headers["user-agent"].startswith("codex_cli_rs/0.175.2 (")
4575
- assert headers["user-agent"].endswith(") codex-as-api/0.10.1")
4612
+ assert headers["user-agent"].endswith(") codex-as-api/0.10.2")
4576
4613
 
4577
4614
 
4578
4615
  def test_provider_cold_version_resolver_failure_raises_typed_503(auth_json_factory, monkeypatch):
@@ -179,9 +179,9 @@ def test_npm_rejects_mismatched_or_malformed_registry_state(tmp_path: Path, muta
179
179
 
180
180
 
181
181
  def test_github_packages_packument_supports_new_and_identical_versions(tmp_path: Path) -> None:
182
- artifact = tmp_path / "eunho-j-codex-as-api-0.7.0.tgz"
182
+ artifact = tmp_path / "choam-co-codex-as-api-0.7.0.tgz"
183
183
  artifact.write_bytes(b"github package")
184
- package = "@eunho-j/codex-as-api"
184
+ package = "@choam-co/codex-as-api"
185
185
  unpublished = {"name": package, "versions": {"0.6.5": {}}}
186
186
  published = {
187
187
  "name": package,
@@ -215,9 +215,9 @@ def test_github_packages_packument_supports_new_and_identical_versions(tmp_path:
215
215
 
216
216
 
217
217
  def test_github_packages_rejects_a_malformed_target_version(tmp_path: Path) -> None:
218
- artifact = tmp_path / "eunho-j-codex-as-api-0.7.0.tgz"
218
+ artifact = tmp_path / "choam-co-codex-as-api-0.7.0.tgz"
219
219
  artifact.write_bytes(b"github package")
220
- package = "@eunho-j/codex-as-api"
220
+ package = "@choam-co/codex-as-api"
221
221
 
222
222
  with pytest.raises(check_registry_release.RegistryPreflightError):
223
223
  check_registry_release.check_npm_release(
@@ -232,19 +232,19 @@ def test_github_packages_rejects_a_malformed_target_version(tmp_path: Path) -> N
232
232
 
233
233
 
234
234
  def test_github_packages_uses_bearer_without_exposing_it(tmp_path: Path) -> None:
235
- artifact = tmp_path / "eunho-j-codex-as-api-0.7.0.tgz"
235
+ artifact = tmp_path / "choam-co-codex-as-api-0.7.0.tgz"
236
236
  artifact.write_bytes(b"github package")
237
237
  token = "never-print-this-token"
238
238
 
239
239
  def fetch(url: str, headers: Mapping[str, str]) -> object | None:
240
- assert url == "https://npm.pkg.github.com/@eunho-j%2Fcodex-as-api"
240
+ assert url == "https://npm.pkg.github.com/@choam-co%2Fcodex-as-api"
241
241
  assert headers["Authorization"] == f"Bearer {token}"
242
242
  raise check_registry_release.RegistryPreflightError("registry request returned HTTP 401")
243
243
 
244
244
  with pytest.raises(check_registry_release.RegistryPreflightError) as captured:
245
245
  check_registry_release.check_npm_release(
246
246
  "https://npm.pkg.github.com",
247
- "@eunho-j/codex-as-api",
247
+ "@choam-co/codex-as-api",
248
248
  "0.7.0",
249
249
  artifact,
250
250
  token=token,
@@ -336,7 +336,7 @@ def test_http_layer_rejects_malformed_json_and_sanitizes_network_errors() -> Non
336
336
  def test_github_release_only_accepts_404_or_the_exact_tag() -> None:
337
337
  assert (
338
338
  check_registry_release.check_github_release(
339
- "Eunho-J/codex-as-api",
339
+ "CHOAM-CO/codex-as-api",
340
340
  "v0.7.0",
341
341
  "secret",
342
342
  fetch_json=static_fetcher(None),
@@ -345,7 +345,7 @@ def test_github_release_only_accepts_404_or_the_exact_tag() -> None:
345
345
  )
346
346
  assert (
347
347
  check_registry_release.check_github_release(
348
- "Eunho-J/codex-as-api",
348
+ "CHOAM-CO/codex-as-api",
349
349
  "v0.7.0",
350
350
  "secret",
351
351
  fetch_json=static_fetcher({"tag_name": "v0.7.0"}),
@@ -354,7 +354,7 @@ def test_github_release_only_accepts_404_or_the_exact_tag() -> None:
354
354
  )
355
355
  with pytest.raises(check_registry_release.RegistryPreflightError):
356
356
  check_registry_release.check_github_release(
357
- "Eunho-J/codex-as-api",
357
+ "CHOAM-CO/codex-as-api",
358
358
  "v0.7.0",
359
359
  "secret",
360
360
  fetch_json=static_fetcher({"tag_name": "v0.7.1"}),
@@ -378,7 +378,7 @@ def test_github_release_asset_prune_only_deletes_unexpected_assets(tmp_path: Pat
378
378
  deleted.append(url)
379
379
 
380
380
  check_registry_release.prune_github_release_assets(
381
- "Eunho-J/codex-as-api",
381
+ "CHOAM-CO/codex-as-api",
382
382
  "v0.7.0",
383
383
  "secret",
384
384
  [expected],
@@ -386,7 +386,7 @@ def test_github_release_asset_prune_only_deletes_unexpected_assets(tmp_path: Pat
386
386
  delete_asset=delete_asset,
387
387
  )
388
388
 
389
- assert deleted == ["https://api.github.com/repos/Eunho-J/codex-as-api/releases/assets/11"]
389
+ assert deleted == ["https://api.github.com/repos/CHOAM-CO/codex-as-api/releases/assets/11"]
390
390
 
391
391
 
392
392
  def test_github_release_asset_prune_validates_all_ids_before_deleting(tmp_path: Path) -> None:
@@ -396,7 +396,7 @@ def test_github_release_asset_prune_validates_all_ids_before_deleting(tmp_path:
396
396
 
397
397
  with pytest.raises(check_registry_release.RegistryPreflightError):
398
398
  check_registry_release.prune_github_release_assets(
399
- "Eunho-J/codex-as-api",
399
+ "CHOAM-CO/codex-as-api",
400
400
  "v0.7.0",
401
401
  "secret",
402
402
  [expected],
@@ -433,7 +433,7 @@ def test_github_release_asset_verification_requires_exact_names_and_sha256(
433
433
  }
434
434
 
435
435
  check_registry_release.verify_github_release_assets(
436
- "Eunho-J/codex-as-api",
436
+ "CHOAM-CO/codex-as-api",
437
437
  "v0.7.0",
438
438
  "secret",
439
439
  [expected],
@@ -468,7 +468,7 @@ def test_github_release_asset_verification_rejects_non_exact_remote_state(
468
468
 
469
469
  with pytest.raises(check_registry_release.RegistryPreflightError):
470
470
  check_registry_release.verify_github_release_assets(
471
- "Eunho-J/codex-as-api",
471
+ "CHOAM-CO/codex-as-api",
472
472
  "v0.7.0",
473
473
  "secret",
474
474
  [expected],
@@ -484,7 +484,7 @@ def test_http_delete_requires_github_no_content_without_exposing_token() -> None
484
484
 
485
485
  with pytest.raises(check_registry_release.RegistryPreflightError) as captured:
486
486
  check_registry_release._http_delete( # noqa: SLF001
487
- "https://api.github.com/repos/Eunho-J/codex-as-api/releases/assets/11",
487
+ "https://api.github.com/repos/CHOAM-CO/codex-as-api/releases/assets/11",
488
488
  {"Authorization": "Bearer never-print-this-token"},
489
489
  opener=forbidden,
490
490
  )
@@ -113,17 +113,17 @@ def test_accepts_exact_python_and_npm_release_identities(tmp_path: Path) -> None
113
113
  wheel = tmp_path / "codex_as_api-0.7.0-py3-none-any.whl"
114
114
  sdist = tmp_path / "codex_as_api-0.7.0.tar.gz"
115
115
  npm = tmp_path / "codex-as-api-0.7.0.tgz"
116
- github_npm = tmp_path / "eunho-j-codex-as-api-0.7.0.tgz"
116
+ github_npm = tmp_path / "choam-co-codex-as-api-0.7.0.tgz"
117
117
  make_wheel(wheel)
118
118
  make_sdist(sdist)
119
119
  make_npm_tarball(npm, "codex-as-api")
120
- make_npm_tarball(github_npm, "@eunho-j/codex-as-api")
120
+ make_npm_tarball(github_npm, "@choam-co/codex-as-api")
121
121
 
122
122
  check_release_artifacts.validate_python_distributions([wheel, sdist], "0.7.0")
123
123
  check_release_artifacts.validate_npm_tarball(npm, "codex-as-api", "0.7.0")
124
124
  check_release_artifacts.validate_npm_tarball(
125
125
  github_npm,
126
- "@eunho-j/codex-as-api",
126
+ "@choam-co/codex-as-api",
127
127
  "0.7.0",
128
128
  )
129
129
 
@@ -4887,6 +4887,62 @@ def test_messages_compact_routes_known_gpt_model_to_backend(
4887
4887
  assert recorded["body"]["model"] == "gpt-5.6-sol"
4888
4888
 
4889
4889
 
4890
+ def test_messages_compact_derives_claude_session_cache_key_and_respects_explicit_key(
4891
+ client,
4892
+ recording_backend: RecordingBackend,
4893
+ ):
4894
+ derived_response = client.post(
4895
+ "/v1/messages/compact",
4896
+ headers={"x-claude-code-session-id": "session-compact-1"},
4897
+ json={
4898
+ "model": "gpt-5.6-sol",
4899
+ "max_tokens": 1024,
4900
+ "system": "system",
4901
+ "messages": [{"role": "user", "content": "hello"}],
4902
+ },
4903
+ )
4904
+ assert derived_response.status_code == 200, derived_response.text
4905
+ derived_recorded = recording_backend.requests.get(timeout=1)
4906
+ expected_key = hashlib.sha256(
4907
+ b"codex-as-api:claude-code-session:session-compact-1"
4908
+ ).hexdigest()
4909
+ assert derived_recorded["path"] == "/responses/compact"
4910
+ assert derived_recorded["body"]["prompt_cache_key"] == expected_key
4911
+ assert derived_recorded["headers"]["session-id"] == expected_key
4912
+ assert derived_recorded["headers"]["thread-id"] == expected_key
4913
+ assert derived_recorded["headers"]["x-client-request-id"] == expected_key
4914
+
4915
+ explicit_response = client.post(
4916
+ "/v1/messages/compact",
4917
+ headers={"x-claude-code-session-id": "session-compact-1"},
4918
+ json={
4919
+ "model": "gpt-5.6-sol",
4920
+ "max_tokens": 1024,
4921
+ "system": "system",
4922
+ "prompt_cache_key": "explicit-compact-key",
4923
+ "messages": [{"role": "user", "content": "hello"}],
4924
+ },
4925
+ )
4926
+ assert explicit_response.status_code == 200, explicit_response.text
4927
+ explicit_recorded = recording_backend.requests.get(timeout=1)
4928
+ assert explicit_recorded["body"]["prompt_cache_key"] == "explicit-compact-key"
4929
+ assert explicit_recorded["headers"]["session-id"] == "explicit-compact-key"
4930
+ assert explicit_recorded["headers"]["thread-id"] == "explicit-compact-key"
4931
+ assert explicit_recorded["headers"]["x-client-request-id"] == "explicit-compact-key"
4932
+
4933
+ blank_session = client.post(
4934
+ "/v1/messages/compact",
4935
+ headers={"x-claude-code-session-id": " "},
4936
+ json={
4937
+ "model": "gpt-5.6-sol",
4938
+ "max_tokens": 1024,
4939
+ "messages": [{"role": "user", "content": "hello"}],
4940
+ },
4941
+ )
4942
+ assert blank_session.status_code == 400
4943
+ assert recording_backend.requests.empty()
4944
+
4945
+
4890
4946
  def test_messages_compact_maps_fast_mode_and_rejects_invalid_speed(
4891
4947
  client,
4892
4948
  recording_backend: RecordingBackend,
@@ -6652,7 +6708,7 @@ def test_dynamic_npm_version_resolver_updates_models_query_user_agent_and_cold_f
6652
6708
  responses_req_1 = recording_backend.requests.get(timeout=1)
6653
6709
  assert catalog_req_1["path"] == "/models?client_version=0.175.2"
6654
6710
  assert catalog_req_1["headers"]["user-agent"].startswith("codex_cli_rs/0.175.2 (")
6655
- assert catalog_req_1["headers"]["user-agent"].endswith(") codex-as-api/0.10.1")
6711
+ assert catalog_req_1["headers"]["user-agent"].endswith(") codex-as-api/0.10.2")
6656
6712
  assert responses_req_1["headers"]["user-agent"].startswith("codex_cli_rs/0.175.2 (")
6657
6713
 
6658
6714
  active_version = "0.176.0"
@@ -45,7 +45,10 @@ ROUTES = [
45
45
 
46
46
 
47
47
  @pytest.mark.parametrize(("method", "path"), ROUTES)
48
- def test_management_disabled_without_admin_key(management_client, method, path):
48
+ @pytest.mark.parametrize("admin_key", [None, "", " "])
49
+ def test_management_disabled_without_admin_key(monkeypatch, management_client, method, path, admin_key):
50
+ if admin_key is not None:
51
+ monkeypatch.setenv("CODEX_AS_API_ADMIN_KEY", admin_key)
49
52
  response = management_client.request(method, path, headers={"Authorization": "Bearer anything"})
50
53
  assert_error(response, 503, "management_disabled")
51
54
 
File without changes
File without changes