@@ -14,30 +14,81 @@ sessions, and OpenCode tools are intentionally absent.
1414
1515``` text
1616Codex subagent
17- -> POST /v1/responses
17+ -> POST /v1/responses (Responses API)
1818 -> this adapter
19- -> POST https://opencode.ai/zen/go/v1/chat/completions
20- -> Responses JSON or SSE
19+ -> POST /chat/completions (Chat Completions API)
20+ -> OpenCode Go (https://opencode.ai/zen/go/v1)
21+ -> Chat Completions response / SSE stream
22+ -> this adapter
23+ -> Responses API response / SSE stream
24+ -> Codex subagent
2125```
2226
2327Codex remains responsible for task roles, sandbox permissions, tool execution,
2428review, and deciding whether work is complete.
2529
26- ## Run
30+ ## Quick start (Rust)
31+
32+ ``` bash
33+ # Build
34+ cargo build --release
2735
28- ``` powershell
29- $env:OPENCODE_GO_API_KEY = "..."
30- $env:CODEX_OPENCODE_LOCAL_TOKEN = "use-a-different-local-token"
31- $env:CODEX_OPENCODE_PORT = "4010"
32- python -m codex_opencode_adapter
36+ # Run
37+ OPENCODE_GO_API_KEY=" your-key" \
38+ CODEX_OPENCODE_LOCAL_TOKEN=" your-local-token" \
39+ cargo run
3340```
3441
42+ The adapter listens on ` 127.0.0.1:4010 ` by default.
43+
44+ ## Environment variables
45+
46+ | Variable | Default | Description |
47+ | ---| ---| ---|
48+ | ` OPENCODE_GO_API_KEY ` | (required) | API key for OpenCode Go |
49+ | ` CODEX_OPENCODE_LOCAL_TOKEN ` | (none) | Bearer token the adapter requires from callers; if empty, auth is skipped |
50+ | ` CODEX_OPENCODE_HOST ` | ` 127.0.0.1 ` | Listen host |
51+ | ` CODEX_OPENCODE_PORT ` | ` 4010 ` | Listen port |
52+ | ` OPENCODE_GO_BASE_URL ` | ` https://opencode.ai/zen/go/v1 ` | Upstream base URL |
53+ | ` CODEX_OPENCODE_STATE_DB ` | ` .codex-opencode/state.sqlite ` | SQLite state database path |
54+ | ` CODEX_OPENCODE_STATE_TTL_SECONDS ` | ` 21600 ` | State TTL (6 hours) |
55+ | ` CODEX_OPENCODE_TIMEOUT_SECONDS ` | ` 300 ` | Upstream request timeout |
56+ | ` CODEX_OPENCODE_MAX_REQUEST_BYTES ` | ` 8388608 ` | Max request body size (8 MB) |
57+
3558The upstream API key and local client token must be different. The adapter
36- never logs either token. Copy the provider and agent examples from
37- ` config.toml.example ` and ` .codex/agents/ ` into the desired Codex configuration.
59+ never logs either token.
60+
61+ ## Run tests
3862
39- The provider block must be installed in the user-level Codex config. Codex
40- ignores ` model_providers ` declared in a project's ` .codex/config.toml ` .
63+ ### Rust tests (unit + integration)
64+
65+ ``` bash
66+ # All tests
67+ cargo test
68+
69+ # Unit tests only
70+ cargo test --lib
71+
72+ # L2 integration tests (mock upstream, no external dependency)
73+ cargo test --test test_e2e
74+
75+ # L2 real smoke test (requires OPENCODE_GO_API_KEY)
76+ OPENCODE_GO_API_KEY=" your-key" cargo test --test test_e2e test_e2e_real_smoke -- --ignored
77+ ```
78+
79+ ### Test structure
80+
81+ ``` text
82+ tests/
83+ ├── conversion_rs.rs # Rust unit tests for conversion modules
84+ └── test_e2e.rs # L2 integration tests (mock upstream + real smoke)
85+ ```
86+
87+ ## Endpoints
88+
89+ - ` POST /v1/responses ` — Responses API (streaming and non-streaming)
90+ - ` GET /v1/models ` — List available models (prefixed with ` opencode-go/ ` )
91+ - ` GET /health ` — Health check
4192
4293## Reasoning compatibility
4394
@@ -57,11 +108,19 @@ metadata and logs rather than silently pretending to work.
57108Reasoning content is retained only in stored chat history so tool continuations
58109remain valid. It is not exposed as user-visible chain of thought.
59110
60- ## Endpoints
111+ ## Supported models
112+
113+ All models available on OpenCode Go, prefixed with ` opencode-go/ ` when calling
114+ the adapter:
115+
116+ - deepseek-v4-flash, deepseek-v4-pro
117+ - glm-5.1, glm-5.2
118+ - kimi-k2.6, kimi-k2.7-code
119+ - mimo-v2.5, mimo-v2.5-pro
120+ - minimax-m2.7, minimax-m3
121+ - qwen3.6-plus, qwen3.7-max, qwen3.7-plus
61122
62- - ` POST /v1/responses `
63- - ` GET /v1/models `
64- - ` GET /health `
123+ ## State management
65124
66125State needed for ` previous_response_id ` and tool results is stored in a local
67126SQLite database and expires according to ` CODEX_OPENCODE_STATE_TTL_SECONDS ` .
0 commit comments