Skip to content

Commit b633737

Browse files
committed
docs: refresh guides and localized site
1 parent 5ccc671 commit b633737

50 files changed

Lines changed: 3228 additions & 1206 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ Provider picker as a local config with Cursor's static public model catalog. Liv
212212
HTTP/2 transport is enabled when a Cursor access token is configured. Cursor server-driven native
213213
read/write/delete/ls/grep/shell/fetch execution is disabled by default because it bypasses Codex's
214214
approval and sandbox path; set `unsafeAllowNativeLocalExec: true` only for trusted local
215-
experiments. The older `allowNativeLocalExec` spelling is accepted as a deprecated transition
216-
alias.
215+
experiments.
217216
MCP, screen recording, and computer-use are exposed through executor hooks; when no local executor
218217
is configured, opencodex returns typed no-executor results instead of policy-blocking the request.
219218
Cursor OAuth and live model discovery are enabled for the experimental Cursor adapter.
2.08 MB
Loading
2.24 MB
Loading

docs-site/src/components/Landing.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import {
1515
import demo from '../assets/demo.gif';
1616
import dashboard from '../assets/dashboard.png';
1717
import picker from '../assets/codex-app-picker.png';
18-
import heroFieldLight from '../assets/hero-field-light.png';
19-
import heroFieldDark from '../assets/hero-field-dark.png';
18+
import heroFieldLight from '../assets/hero-route-light.png';
19+
import heroFieldDark from '../assets/hero-route-dark.png';
2020
2121
interface Props {
2222
locale?: 'ko' | 'zh-cn';

docs-site/src/content/docs/contributing.md

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,32 @@ cd opencodex
1111
bun install
1212
bun run dev:proxy # proxy API in dev mode
1313
bun run dev:gui # dashboard dev server (another terminal)
14-
bun x tsc --noEmit # typecheck (must be clean)
14+
bun run typecheck # bun x tsc --noEmit
15+
bun run test # bun test ./tests/
1516
```
1617

1718
`bun run dev` remains an alias for `bun run dev:proxy`. The dashboard dev server is `bun run dev:gui`;
1819
the packaged dashboard at `GET /` is produced by `bun run build:gui` (`gui/dist`).
1920

21+
## Build and test commands
22+
23+
The root package is Bun-native TypeScript; there is no separate server compile step. Use the checked-in
24+
scripts so local commands match CI:
25+
26+
```bash
27+
bun run typecheck # strict TypeScript check
28+
bun run test # complete tests/ suite
29+
bun test tests/router.test.ts # focused test file
30+
bun run build:gui # Vite GUI build + package preparation
31+
bun run privacy:scan # credential/privacy scan used by CI
32+
bun run prepare:package # refresh package launchers/assets
33+
```
34+
35+
Most tests are flat `tests/*.test.ts` Bun tests. `tests/helpers/` contains shared fixtures and
36+
`tests/e2e-style/` contains broader native-parity scenarios. Keep a focused regression near the
37+
existing tests for the subsystem you change; run the full suite for shared routing, adapters, config,
38+
or server behavior.
39+
2040
The docs site you're reading lives in `docs-site/` (Astro + Starlight):
2141

2242
```bash
@@ -41,8 +61,10 @@ bun run build
4161
GitHub Actions intentionally stay small:
4262

4363
- **Cross-platform CI** (`.github/workflows/ci.yml`) runs on pull requests and `main` pushes that
44-
touch runtime, tests, package, script, TypeScript, or workflow files. It verifies Linux and Windows
45-
with install, typecheck, tests, a release-helper build smoke, and `ocx help`.
64+
touch runtime, tests, package, script, TypeScript, or workflow files. Its Bun matrix covers Linux,
65+
Windows, and macOS with install, typecheck, tests, privacy scan, a release-helper build smoke, GUI
66+
build, and `ocx help`. A second three-OS lane proves npm global install works without a separately
67+
installed Bun by using the package's bundled runtime.
4668
- **Release** (`.github/workflows/release.yml`) is manual. It does not act as a second full CI
4769
pipeline; before dry-run or publish it requires the exact release commit (`GITHUB_SHA`) to already
4870
have a successful Cross-platform CI run.
@@ -68,31 +90,38 @@ bun run release:watch # watch the newest Release workflow run
6890

6991
## Adding a provider to the catalog
7092

71-
Most providers are just an entry in the API-key catalog (`src/oauth/key-providers.ts`):
93+
All provider pickers and seeds derive from the canonical registry (`src/providers/registry.ts`):
7294

7395
```ts
74-
"my-provider": {
96+
{
97+
id: "my-provider",
7598
label: "My Provider",
7699
baseUrl: "https://api.example.com/v1",
77100
adapter: "openai-chat",
101+
authKind: "key",
78102
dashboardUrl: "https://example.com/keys",
79103
models: ["model-a", "model-b"],
80104
defaultModel: "model-a",
81105
noVisionModels: ["model-a"], // text-only models → vision sidecar describes images
82-
}
106+
},
83107
```
84108

85-
`enrichProviderFromCatalog()` copies `models` / `noVisionModels` / `noReasoningModels` onto the
86-
created provider config, so classifications take effect automatically. For OAuth providers, add to
87-
`OAUTH_PROVIDERS` in `src/oauth/index.ts` instead.
109+
`src/providers/derive.ts` feeds that entry into `ocx init`, `ocx provider`, dashboard presets,
110+
API-key login, and OAuth config seeds. `enrichProviderFromCatalog()` copies model metadata and
111+
capability classifications onto the saved provider config. OAuth protocol implementations still
112+
live in `src/oauth/`; registry metadata alone is not an OAuth flow.
88113

89114
## Adding an adapter
90115

91116
Implement `ProviderAdapter` (see [Adapters](/opencodex/reference/adapters/)) in `src/adapters/`,
92-
register it in the adapter resolver, and bridge its output to internal `AdapterEvent`s. Reuse
93-
`image.ts` for image handling and follow `openai-chat.ts` as the reference for streaming + tool calls.
117+
register its name in `src/server/adapter-resolve.ts`, and bridge its output to internal
118+
`AdapterEvent`s. Reuse `image.ts` for image handling and follow `openai-chat.ts` for ordinary
119+
streaming/tool calls; use `fetchResponse` only when the adapter owns transport retries, or `runTurn`
120+
for a genuinely bidirectional transport such as Cursor. Add focused tests under `tests/` and export
121+
the factory from `src/index.ts` when it belongs to the public package API.
94122

95123
## Verify before you claim done
96124

97-
Run the narrowest command that proves your change — `bun x tsc --noEmit` for types, a focused runtime
98-
probe for behavior. opencodex favors small, verifiable commits over large batches.
125+
Run the narrowest command that proves your change — `bun run typecheck` for types, a focused
126+
`bun test tests/<name>.test.ts` or runtime probe for behavior, then the broader gates appropriate to
127+
the affected surface. opencodex favors small, verifiable commits over large batches.

docs-site/src/content/docs/getting-started/how-it-works.mdx

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ description: The full opencodex request lifecycle — parse, route, adapt, bridg
55

66
import { Steps } from '@astrojs/starlight/components';
77

8-
Codex speaks exactly one protocol: the OpenAI **Responses API** (`POST /v1/responses`, Server-Sent
9-
Events). opencodex accepts that request, translates it to your provider's wire format, and translates
10-
the streamed answer back into Responses events — so Codex never knows it isn't talking to OpenAI.
8+
Codex speaks the OpenAI **Responses API**. opencodex accepts `POST /v1/responses` over HTTP with
9+
Server-Sent Events, plus an opt-in WebSocket upgrade on the same path. It translates the request to
10+
your provider's wire format and the answer back into Responses events — so Codex never knows it
11+
isn't talking to OpenAI.
1112

1213
```
1314
┌──────────────────────────── opencodex ────────────────────────────┐
1415
│ │
1516
Codex ──▶ │ parser ──▶ router ──▶ [vision] ──▶ adapter ──▶ provider │ ──▶ Codex
16-
(/v1/ │ │ │ │ │ │ │ (SSE)
17+
(/v1/ │ │ │ │ │ │ │ (SSE / WS)
1718
responses)│ OcxParsed provider describe buildRequest parseStream │
1819
│ Request +adapter images + fetch AdapterEvent[] │
1920
│ │ │ │
@@ -38,6 +39,14 @@ account before the request is forwarded upstream. The rule is intentionally spli
3839
`GET /api/codex-auth/accounts?refresh=1`; successful upstream responses capture quota headers,
3940
429 puts an account in cooldown, and 401/403 marks it for reauthentication.
4041

42+
## Sub-agent model selection
43+
44+
On a fresh install, `subagentModels` features `gpt-5.5`, the GPT-5.6 Sol/Terra/Luna trio, and
45+
`gpt-5.4-mini` in Codex's sub-agent picker. The dashboard can reorder or replace up to five entries
46+
with native or routed models. For v1 collaboration requests, optional `injectionModel` and
47+
`injectionEffort` settings add developer guidance that tells `spawn_agent` which model and reasoning
48+
effort to use; v2 requests keep Codex's native multi-agent guidance.
49+
4150
## The lifecycle
4251

4352
<Steps>
@@ -50,8 +59,8 @@ account before the request is forwarded upstream. The rule is intentionally spli
5059
base64 text.
5160

5261
2. **Route**`router.ts` maps the requested model id to a configured provider using a fixed
53-
precedence: explicit `provider/model` → a provider's `defaultModel`a provider's `models[]`
54-
built-in prefix patterns (`claude-`, `gpt-`, `o1-`/`o3-`/`o4-`, `llama-`/`mixtral-`/`gemma-`) →
62+
precedence: explicit `provider/model` → a provider's `defaultModel`built-in prefix patterns
63+
(`claude-`, `gpt-`, `o1-`/`o3-`/`o4-`, `llama-`/`mixtral-`/`gemma-`) → a provider's `models[]`
5564
the `defaultProvider` fallback. See [Model Routing](/opencodex/guides/model-routing/).
5665

5766
3. **Authenticate** — for an `oauth` provider, opencodex swaps in a fresh, auto-refreshed access
@@ -60,26 +69,31 @@ account before the request is forwarded upstream. The rule is intentionally spli
6069
to continue if the required pool credential is unavailable.
6170

6271
4. **Vision sidecar (optional)** — if the routed model is listed in `provider.noVisionModels` and the
63-
request carries an image, opencodex describes each image with a `gpt-5.4-mini` vision model over
64-
your ChatGPT login and replaces it with text, so a text-only model can still reason about it.
72+
request carries an image, opencodex describes each image with the configured ChatGPT vision
73+
sidecar and replaces it with text, so a text-only model can still reason about it.
6574
See [Sidecars](/opencodex/guides/sidecars/).
6675

67-
5. **Passthrough fast path** — if the adapter is a passthrough (`openai-responses` in `forward` mode,
68-
or `azure-openai`), the raw request body is piped straight to the provider and the response streamed back
69-
untouched. No translation happens.
76+
5. **Passthrough fast path** — if the adapter is a Responses passthrough (`openai-responses` or
77+
`azure-openai`), opencodex keeps the Responses body, applies targeted routing and compatibility
78+
rewrites, then relays the provider's response without converting it through `AdapterEvent`s.
7079

7180
6. **Web-search sidecar (optional)** — if Codex enabled hosted `web_search` but the routed model is
7281
non-OpenAI, opencodex exposes a synthetic `web_search` function tool and runs the model in a small
73-
agentic loop, executing real searches through `gpt-5.4-mini` over your ChatGPT login and injecting
74-
the results back as tool results.
82+
agentic loop, executing real searches through `gpt-5.6-luna` by default over your ChatGPT login
83+
and injecting the results back as tool results.
84+
85+
7. **Compact (when requested)** — Codex v1 calls `POST /v1/responses/compact`; v2 adds a
86+
`compaction_trigger` to a Responses turn. Native passthrough routes compaction upstream, while a
87+
routed model runs as a tool-free summarizer and returns the replacement history shape Codex expects.
7588

76-
7. **Adapt** — otherwise the chosen adapter's `buildRequest()` produces the upstream HTTP request
89+
8. **Adapt** — otherwise the chosen adapter's `buildRequest()` produces the upstream HTTP request
7790
(URL, headers, body) in the provider's native format, and opencodex `fetch`es it.
7891

79-
8. **Bridge** — the adapter's `parseStream()` (or `parseResponse()`) yields internal `AdapterEvent`s
92+
9. **Bridge** — the adapter's `parseStream()` (or `parseResponse()`) yields internal `AdapterEvent`s
8093
(text, reasoning, tool-call start/delta/end, done, error). `bridge.ts` converts that stream back
8194
into Responses SSE events — `response.output_text.delta`, `response.reasoning_summary_text.delta`,
82-
`response.function_call_arguments.delta`, `response.completed`, and so on — which Codex consumes.
95+
`response.function_call_arguments.delta`, `response.completed`, and so on. The optional WebSocket
96+
transport sends the same event payloads as text frames.
8397

8498
</Steps>
8599

docs-site/src/content/docs/getting-started/installation.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ title: Installation
33
description: Install the opencodex (ocx) proxy, its prerequisites, and verify it runs.
44
---
55

6-
opencodex ships as a single CLI, `ocx`. It runs as a small local HTTP server (built on Bun) and never
7-
sends your traffic anywhere except the provider you configure.
6+
opencodex installs two equivalent command names, `ocx` and `opencodex`. Both launch the same small
7+
local HTTP server (built on Bun). Model requests go to the provider selected by routing; optional
8+
vision and web-search sidecars can also use your ChatGPT login when a routed model needs them.
89

910
## Prerequisites
1011

@@ -20,25 +21,25 @@ sends your traffic anywhere except the provider you configure.
2021
npm install -g @bitkyc08/opencodex
2122
```
2223

23-
Verify the binary is on your `PATH`:
24+
Verify both command aliases are on your `PATH`:
2425

2526
```bash
26-
ocx --help
27+
ocx --version
28+
opencodex --version
2729
```
2830

29-
### Preview channel
31+
### Release channels
3032

31-
GPT-5.6 Sol/Terra/Luna support is preview-gated until the rollout graduates. Install the preview tag
32-
for a fresh setup, or keep an existing preview install on the preview channel:
33+
The stable `latest` channel already includes GPT-5.6 Sol/Terra/Luna catalog support for ChatGPT,
34+
OpenAI API-key, OpenRouter, and experimental Cursor routes. Upstream access is still account-gated;
35+
the catalog entries do not grant access by themselves. Use the preview channel only to test
36+
unreleased opencodex builds:
3337

3438
```bash
3539
npm install -g @bitkyc08/opencodex@preview
3640
ocx update --tag preview
3741
```
3842

39-
Preview builds seed the GPT-5.6 model ids and Codex catalog metadata; they do not grant upstream
40-
model access by themselves.
41-
4243
## Run from source
4344

4445
To hack on opencodex itself:
@@ -58,13 +59,19 @@ has produced `gui/dist`. While hacking on the dashboard, run the frontend separa
5859

5960
## What gets created
6061

62+
opencodex state lives under `$OPENCODEX_HOME` (default `~/.opencodex`). Codex integration files live
63+
under `$CODEX_HOME` (default `~/.codex`).
64+
6165
| Path | Purpose |
6266
| --- | --- |
63-
| `~/.opencodex/config.json` | Your providers, default provider, port, and options. |
64-
| `~/.opencodex/ocx.pid` | PID of the running proxy (single-instance guard). |
65-
| `~/.opencodex/auth.json` | Stored OAuth credentials (when you `ocx login`). |
66-
| `~/.opencodex/catalog-backup.json` | Pristine Codex model catalog, backed up before any edit. |
67-
| `$CODEX_HOME/config.toml` | opencodex appends a `[model_providers.opencodex]` table here on `ocx init` (defaults to `~/.codex/config.toml`). |
67+
| `$OPENCODEX_HOME/config.json` | Your providers, default provider, port, and options. |
68+
| `$OPENCODEX_HOME/ocx.pid` | PID of the running proxy (single-instance guard). |
69+
| `$OPENCODEX_HOME/runtime-port.json` | The live PID, hostname, and port, including an automatically selected fallback port. |
70+
| `$OPENCODEX_HOME/auth.json` | Stored OAuth credentials (when you `ocx login`). |
71+
| `$OPENCODEX_HOME/catalog-backup*.json` | Codex model catalog backups made before opencodex edits it. |
72+
| `$CODEX_HOME/config.toml` | On loopback, opencodex adds a marker-owned root `openai_base_url`; non-loopback binds use `model_provider = "opencodex"` plus `[model_providers.opencodex]` so Codex can send the API-auth header. |
73+
| `$CODEX_HOME/opencodex.config.toml` | Fallback/reference profile written alongside the main Codex config. |
74+
| `$CODEX_HOME/opencodex-catalog.json` | Synced native and routed model catalog used by Codex. |
6875

6976
:::note
7077
opencodex never deletes your Codex config. Every injection is reversible — `ocx stop`, `ocx restore`,

docs-site/src/content/docs/getting-started/quickstart.md

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@ ocx init
1313

1414
`ocx init` walks you through:
1515

16-
1. **Pick a provider** — choose a preset (opencode zen, Anthropic, OpenAI, OpenRouter, Groq, Google,
17-
Azure) or `custom` to type a base URL and adapter.
16+
1. **Pick a provider** — choose one of the 50 built-in registry presets or `custom` to type a base
17+
URL and adapter.
1818
2. **API key** — paste a key, or reference an environment variable like `${ANTHROPIC_API_KEY}`.
19-
3. **Default model**the model used when a request doesn't match another provider.
19+
3. **Default model**for key, local, and custom providers, accept the preset or enter a model id.
2020
4. **Proxy port** — defaults to `10100`.
21-
5. **Inject into Codex?** — when you accept, opencodex writes the `[model_providers.opencodex]` table
22-
into `$CODEX_HOME/config.toml` (default `~/.codex/config.toml`) and sets
23-
`model_provider = "opencodex"` so Codex routes through the proxy.
24-
25-
The result is saved to `~/.opencodex/config.json`.
26-
27-
:::note[GPT-5.6 preview]
28-
On the preview channel, the wizard/catalog presets know about GPT-5.6 Sol/Terra/Luna. Use ChatGPT
29-
passthrough, OpenAI (API key), or OpenRouter only when that upstream account already has access; the
30-
synced Codex entries include `max` reasoning and 372,000 usable-token context metadata.
21+
5. **Inject into Codex?** — on a normal loopback setup, opencodex adds a root `openai_base_url` to
22+
`$CODEX_HOME/config.toml` (default `~/.codex/config.toml`) so Codex's built-in `openai` provider
23+
targets the proxy. Remote/LAN binds use a dedicated provider entry with an API-auth header instead.
24+
6. **Install the autostart shim?** — when enabled, launching `codex` runs `ocx ensure` first.
25+
26+
The result is saved to `$OPENCODEX_HOME/config.json` (default `~/.opencodex/config.json`).
27+
28+
:::note[GPT-5.6 rollout entries]
29+
Stable v2.7.1 seeds GPT-5.6 Sol/Terra/Luna for ChatGPT passthrough, OpenAI API-key, OpenRouter, and
30+
the experimental Cursor adapter. They work only when that upstream account has access. The OpenAI
31+
API-key and OpenRouter presets advertise a 372,000-token usable context window; Cursor keeps its own
32+
adapter metadata.
3133
:::
3234

3335
## 2. Start the proxy
@@ -40,13 +42,18 @@ ocx start --port 8080
4042
On start, opencodex:
4143

4244
- writes its PID to `~/.opencodex/ocx.pid` (and refuses to start twice),
43-
- fetches each provider's live model list and **syncs them into Codex's model catalog**, and
45+
- discovers live models where the provider supports it and **syncs native and routed entries into
46+
Codex's model catalog**,
4447
- listens on `http://localhost:<port>/v1`.
4548

49+
If the requested port is busy, `ocx start` selects a free port, records it in `runtime-port.json`,
50+
and updates Codex to use the live listener.
51+
4652
Check it:
4753

4854
```bash
4955
ocx status
56+
ocx gui # open the dashboard on the live port
5057
```
5158

5259
## 3. Use Codex
@@ -64,12 +71,19 @@ codex -m "anthropic/claude-opus-4-8" "Explain this stack trace"
6471
codex -m "ollama-cloud/glm-5.2" "Write a SQL migration"
6572
```
6673

74+
## Choose sub-agent models (optional)
75+
76+
A fresh config features five native models in Codex's sub-agent picker: `gpt-5.5`,
77+
`gpt-5.6-sol`, `gpt-5.6-terra`, `gpt-5.6-luna`, and `gpt-5.4-mini`. Open `ocx gui` to replace or
78+
reorder up to five native or routed models. The dashboard can also set one preferred sub-agent model
79+
and reasoning effort; opencodex adds that guidance to v1 collaboration requests.
80+
6781
## Logging in instead of pasting a key
6882

6983
Some providers support real account login (OAuth, auto-refreshed):
7084

7185
```bash
72-
ocx login xai # or: anthropic, kimi
86+
ocx login xai # or: anthropic, kimi, kiro, google-antigravity, cursor
7387
ocx logout xai
7488
```
7589

@@ -79,8 +93,9 @@ credentials straight through (see [Providers](/opencodex/guides/providers/)).
7993
## Stopping & restoring
8094

8195
```bash
82-
ocx stop # stop the proxy and restore native Codex
83-
ocx restore # restore native Codex without stopping (alias: ocx eject)
96+
ocx stop # stop the proxy and restore native Codex
97+
ocx restore # restore native Codex without stopping (alias: ocx eject)
98+
ocx restore back # route Codex through the still-running proxy again
8499
```
85100

86101
## Next

0 commit comments

Comments
 (0)