@legioncodeinc/rflectr 0.1.0 → 0.1.2

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 (69) hide show
  1. package/README.md +1 -5
  2. package/dist/cli.js +4 -1
  3. package/dist/cli.js.map +1 -0
  4. package/package.json +4 -1
  5. package/.markdown-link-check.json +0 -7
  6. package/AGENTS.md +0 -169
  7. package/assets/733630021_1421561133353555_3999689754075308337_n.jpg +0 -0
  8. package/assets/github-home-image.png +0 -0
  9. package/assets/og-image.jpg +0 -0
  10. package/assets/og-image.png +0 -0
  11. package/assets/og-image.psd +0 -0
  12. package/assets/rflectr-no-bg.png +0 -0
  13. package/assets/vertex-models.example.json +0 -14
  14. package/library/README.md +0 -39
  15. package/library/issues/README.md +0 -46
  16. package/library/issues/backlog/README.md +0 -26
  17. package/library/issues/completed/README.md +0 -13
  18. package/library/issues/in-work/README.md +0 -13
  19. package/library/knowledge/README.md +0 -34
  20. package/library/knowledge/private/README.md +0 -40
  21. package/library/knowledge/private/ai/README.md +0 -8
  22. package/library/knowledge/private/ai/model-discovery-classification.md +0 -81
  23. package/library/knowledge/private/ai/translation-layer.md +0 -88
  24. package/library/knowledge/private/architecture/README.md +0 -10
  25. package/library/knowledge/private/architecture/launch-flow-claude.md +0 -93
  26. package/library/knowledge/private/architecture/system-overview.md +0 -108
  27. package/library/knowledge/private/auth/README.md +0 -9
  28. package/library/knowledge/private/auth/oauth-device-flows.md +0 -95
  29. package/library/knowledge/private/data/README.md +0 -8
  30. package/library/knowledge/private/data/preferences-config.md +0 -87
  31. package/library/knowledge/private/data/provider-registry.md +0 -126
  32. package/library/knowledge/private/infrastructure/README.md +0 -7
  33. package/library/knowledge/private/infrastructure/server-gateway.md +0 -87
  34. package/library/knowledge/private/integrations/README.md +0 -8
  35. package/library/knowledge/private/integrations/harnesses.md +0 -87
  36. package/library/knowledge/private/integrations/local-proxy.md +0 -82
  37. package/library/knowledge/private/security/README.md +0 -9
  38. package/library/knowledge/private/security/credential-storage.md +0 -129
  39. package/library/knowledge/private/standards/documentation-framework.md +0 -154
  40. package/library/knowledge/public/README.md +0 -49
  41. package/library/knowledge/public/faqs/README.md +0 -7
  42. package/library/knowledge/public/faqs/troubleshooting.md +0 -92
  43. package/library/knowledge/public/guides/README.md +0 -13
  44. package/library/knowledge/public/guides/ai-agents.md +0 -273
  45. package/library/knowledge/public/guides/api-server.md +0 -108
  46. package/library/knowledge/public/guides/claude-desktop.md +0 -382
  47. package/library/knowledge/public/guides/codex.md +0 -296
  48. package/library/knowledge/public/guides/gemini-cli.md +0 -105
  49. package/library/knowledge/public/guides/model-compatibility.md +0 -80
  50. package/library/knowledge/public/guides/providers.md +0 -90
  51. package/library/knowledge/public/overview/README.md +0 -7
  52. package/library/knowledge/public/overview/what-is-rflectr.md +0 -71
  53. package/library/notes/README.md +0 -21
  54. package/library/requirements/README.md +0 -51
  55. package/library/requirements/backlog/README.md +0 -30
  56. package/library/requirements/completed/README.md +0 -14
  57. package/library/requirements/completed/prd-001-cli-core-launch-orchestration/prd-001-cli-core-launch-orchestration-index.md +0 -205
  58. package/library/requirements/completed/prd-001-cli-core-launch-orchestration/qa/.gitkeep +0 -0
  59. package/library/requirements/completed/prd-002-provider-registry/qa/.gitkeep +0 -0
  60. package/library/requirements/completed/prd-003-model-discovery-classification/qa/.gitkeep +0 -0
  61. package/library/requirements/completed/prd-004-translation-layer/qa/.gitkeep +0 -0
  62. package/library/requirements/completed/prd-005-local-proxy-catalog-routing/qa/.gitkeep +0 -0
  63. package/library/requirements/completed/prd-007-oauth-device-flows/qa/.gitkeep +0 -0
  64. package/library/requirements/completed/prd-011-claude-desktop-integration/qa/.gitkeep +0 -0
  65. package/library/requirements/in-work/README.md +0 -19
  66. package/library/requirements/reports/README.md +0 -31
  67. package/scripts/refresh-models-dev-cache.mjs +0 -34
  68. package/test-proxy.ts +0 -19
  69. package/test-split.js +0 -1
@@ -1,382 +0,0 @@
1
- # Claude Desktop Setup
2
-
3
- > Category: Guide | Version: 1.0 | Date: June 2026 | Status: Active
4
-
5
- Point **Claude Desktop** at an **rflectr** gateway on your machine. You get OpenCode Zen, Go, and your configured providers (Groq, Mistral, OpenAI, Gemini, Ollama, …) in Desktop's model picker, with a catalog size you control.
6
-
7
- **What's available:** with third-party inference, Desktop gives you **Cowork** and **Code** only. The regular **Chat** tab (claude.ai-style chat) is not available in this mode. Anthropic calls this **third-party inference** in the Developer menu.
8
-
9
- For Anthropic's upstream docs, see [Installation and setup](https://claude.com/docs/cowork/3p/installation) and [Configuration reference](https://claude.com/docs/cowork/3p/configuration).
10
-
11
- ---
12
-
13
- ## Contents
14
-
15
- - [What you get](#what-you-get)
16
- - [Known limitations](#known-limitations)
17
- - [Prerequisites](#prerequisites)
18
- - [Quick start: automated setup](#quick-start-automated-setup)
19
- - [Manual setup (network / advanced)](#manual-setup-network--advanced)
20
- - [Gateway values cheat sheet](#gateway-values-cheat-sheet)
21
- - [Restore Claude Desktop to Anthropic's servers](#restore-claude-desktop-to-anthropics-servers)
22
- - [Disable Developer Mode](#disable-developer-mode)
23
- - [Troubleshooting](#troubleshooting)
24
- - [Official references](#official-references)
25
-
26
- ---
27
-
28
- ## What you get
29
-
30
- | Piece | Role |
31
- |---|---|
32
- | `rflectr server` | Local gateway on port **17645** — Zen, Go, and registry providers. |
33
- | Claude Desktop gateway config | Desktop sends inference to your machine instead of only claude.ai. |
34
- | Server wizard filters | Exposed providers, optional favorites-only catalog, discovery-id masking. |
35
- | **Cowork** tab | Agentic sessions (files, research, multi-step) against your gateway models. |
36
- | **Code** tab | Claude Code inside Desktop, against your gateway models. |
37
-
38
- **Not included:** Chat (the standard claude.ai chat UI). For that, sign in to Claude Desktop normally without a custom gateway, or use claude.ai in the browser. Billing runs through your OpenCode / provider keys. Keep the server terminal open while you use Desktop.
39
-
40
- ---
41
-
42
- ## Known limitations
43
-
44
- These are Anthropic product constraints, not rflectr bugs.
45
-
46
- | Feature | With rflectr gateway (3P) | With Anthropic 1P (normal sign-in) |
47
- |---|---|---|
48
- | **Chat tab** | Not available | Available |
49
- | **Cowork / Code** | Available | Available (with subscription) |
50
- | **Claude in Chrome** (browser extension) | **Not available** | Requires Pro, Max, Team, or Enterprise |
51
-
52
- ### Claude in Chrome does not work with the gateway
53
-
54
- **Claude in Chrome** (Anthropic's browser-automation extension) is **not compatible** with third-party inference — including a rflectr gateway on `127.0.0.1`. Per Anthropic's [Claude Code + Chrome docs](https://code.claude.com/docs/en/chrome):
55
-
56
- - It requires a direct Anthropic plan (Pro, Max, Team, or Enterprise).
57
- - It is **not available** through third-party providers (Bedrock, Vertex, Foundry, or a custom gateway).
58
- - Using Claude exclusively through a gateway means you'd need a **separate claude.ai paid account** for Claude in Chrome — and that extension routes through **Anthropic's servers**, not your gateway.
59
-
60
- API/console credits do not unlock it. **What gateway users can do instead:** use Cowork and Code in Desktop (this guide), use `rflectr claude` in the terminal, or use a dedicated browser-automation tool (e.g. Playwright, a browser MCP). To use Claude in Chrome, [restore 1P mode](#restore-claude-desktop-to-anthropics-servers) and sign in with a paid claude.ai plan.
61
-
62
- ---
63
-
64
- ## Prerequisites
65
-
66
- 1. **rflectr** installed: `npm install -g @legioncodeinc/rflectr`.
67
- 2. **OpenCode API key** configured at least once (for `rflectr server`):
68
- ```bash
69
- rflectr providers add # if starting fresh
70
- rflectr claude # stores the key in Keychain / credential store
71
- ```
72
- 3. **Latest Claude Desktop** from [claude.com/download](https://claude.com/download). Older builds may not show the third-party inference UI.
73
- 4. *(Optional)* providers configured in rflectr — whatever you've set up appears in the server catalog automatically.
74
- 5. *(Optional)* **Favorites** via `rflectr models` to cap the catalog at up to 20 models.
75
- 6. *(Optional)* **Google Vertex** — configure in Desktop (**Developer → third-party inference → Vertex**).
76
-
77
- ---
78
-
79
- ## Quick start: automated setup
80
-
81
- On macOS or Windows, the easiest path is the **automated** command:
82
-
83
- ```bash
84
- rflectr claude-app
85
- ```
86
-
87
- 1. Run it.
88
- 2. Select a provider and a model.
89
- 3. rflectr **enables Developer Mode**, configures the gateway to point at itself, and launches Claude Desktop.
90
- 4. **Keep the terminal running** — it's the live proxy for Desktop.
91
- 5. When done, press `Ctrl+C` to stop the proxy and restore your original Desktop configuration.
92
-
93
- If the terminal crashes or you need to recover manually:
94
-
95
- ```bash
96
- rflectr claude-app --restore
97
- ```
98
-
99
- ---
100
-
101
- ## Manual setup (network / advanced)
102
-
103
- Use this if the gateway runs on a different machine (remote desktop, container, home server) or you want a permanent background gateway.
104
-
105
- ### Step 1: Start the rflectr server
106
-
107
- ```bash
108
- rflectr server
109
- ```
110
-
111
- Leave it running. First-time wizard recommendations:
112
-
113
- | Prompt | Recommendation |
114
- |---|---|
115
- | **Configure & start** vs **Start with saved settings** | *Configure & start* the first time. |
116
- | **Exposed providers** | Add only what you want in Desktop (Zen, Go, OpenAI, …). |
117
- | **Mask gateway model ids for discovery?** | **Yes** — Desktop filters competitor names in gateway ids; masking keeps discovery working while display names stay readable. |
118
- | **Expose only favorite models?** | Optional. |
119
- | **Listen mode** | **Local only** (`127.0.0.1`) when Desktop runs on the same machine. |
120
-
121
- When it's up:
122
-
123
- ```text
124
- Rflectr server running
125
- Anthropic: http://127.0.0.1:17645/anthropic
126
- OpenAI: http://127.0.0.1:17645/openai
127
- API key: any non-empty value
128
- ```
129
-
130
- Optional health check:
131
-
132
- ```bash
133
- curl -s http://127.0.0.1:17645/health
134
- curl -s http://127.0.0.1:17645/anthropic/v1/models | head
135
- ```
136
-
137
- ### Step 2: Enable Developer Mode
138
-
139
- Third-party inference lives behind **Developer Mode**.
140
-
141
- - **macOS** — menu bar: **Help → Troubleshooting → Enable Developer Mode**.
142
- - **Windows** — application menu (☰): **Help → Troubleshooting → Enable Developer Mode**.
143
-
144
- The app may relaunch (normal). A **Developer** menu then appears. If you already use Claude Desktop, just enable it from the menu and move on.
145
-
146
- ### Step 3: Configure third-party inference
147
-
148
- 1. **Developer → Configure third-party inference**.
149
- 2. Open the **Connection** section.
150
- 3. Set:
151
-
152
- | Field | Value |
153
- |---|---|
154
- | **Inference provider** | **Gateway** (Anthropic-compatible) |
155
- | **Gateway base URL** | `http://127.0.0.1:17645/anthropic` |
156
- | **Gateway API key** | Any non-empty string (e.g. `rflectr`) |
157
- | **Gateway auth scheme** | `bearer` |
158
-
159
- > ⚠️ **Do not append `/v1` to the base URL.** Claude Desktop adds API paths itself (`/v1/models`, `/v1/messages`). A `.../anthropic/v1` URL breaks discovery and inference.
160
-
161
- 4. Leave **model discovery** enabled.
162
- 5. Hit **Test connection** and **Test model discovery** if present.
163
- 6. Click **Apply locally** — the app saves config and relaunches.
164
-
165
- Config lands here:
166
-
167
- | Platform | Path |
168
- |---|---|
169
- | macOS | `~/Library/Application Support/Claude-3p/configLibrary/` |
170
- | Windows | `%LOCALAPPDATA%\Claude-3p\configLibrary\` |
171
-
172
- `Claude-3p` is Anthropic's on-disk layout for third-party inference; ignore it day to day.
173
-
174
- ### Step 4: Use Claude Desktop
175
-
176
- 1. Make sure `rflectr server` is still running.
177
- 2. Open the **Cowork** or **Code** tab (Chat won't be there).
178
- 3. Open the model picker — you should see your gateway models.
179
- 4. Pick a model and start a session.
180
-
181
- If discovery worked in Step 3, you're done — no extra launch step.
182
-
183
- ---
184
-
185
- ## Gateway values cheat sheet
186
-
187
- | Setting | Local rflectr server |
188
- |---|---|
189
- | Provider | Gateway (Anthropic-compatible) |
190
- | Base URL | `http://127.0.0.1:17645/anthropic` |
191
- | API key | Any non-empty value (local mode has no server password) |
192
- | Auth scheme | `bearer` |
193
- | Discovery (internal) | `GET http://127.0.0.1:17645/anthropic/v1/models` |
194
- | Messages (internal) | `POST http://127.0.0.1:17645/anthropic/v1/messages` |
195
-
196
- ### Network mode (another device on your LAN)
197
-
198
- | Setting | Value |
199
- |---|---|
200
- | Base URL | `http://<server-ip>:17645/anthropic` |
201
- | API key | The **server password** printed when the server started |
202
-
203
- ---
204
-
205
- ## Restore Claude Desktop to Anthropic's servers
206
-
207
- To stop routing through rflectr and return to normal Claude Desktop (Anthropic sign-in, Chat tab, claude.ai inference):
208
-
209
- ### Verified revert (macOS, Claude Desktop 1.11847.5)
210
-
211
- Three on-disk changes plus a relaunch:
212
-
213
- | What | Why |
214
- |---|---|
215
- | Remove `Claude-3p/configLibrary/` | Drops the gateway config that keeps Desktop in 3P mode. |
216
- | Set `"allowDevTools": false` | Hides the **Developer** menu — current builds have *Enable* but no *Disable* toggle. |
217
- | Set `"deploymentMode": "1p"` | Pins first-party mode in the standard `Claude/` data folder. |
218
-
219
- **Before you start:** fully quit Claude Desktop (`Cmd+Q` on macOS — not just the window). Back up the folders below if you want an undo path.
220
-
221
- **Step 1 — Remove the gateway config**
222
-
223
- ```bash
224
- # macOS
225
- rm -rf ~/Library/Application\ Support/Claude-3p/configLibrary/
226
- ```
227
- ```powershell
228
- # Windows (PowerShell)
229
- Remove-Item -Recurse -Force "$env:LOCALAPPDATA\Claude-3p\configLibrary"
230
- ```
231
-
232
- This deletes the applied third-party inference profile. It does **not** delete Cowork session history under `Claude-3p/` or `~/Claude/`.
233
-
234
- **Step 2 — Disable Developer Mode** — edit `developer_settings.json` in the **standard** (1P) data folder:
235
-
236
- - macOS: `~/Library/Application Support/Claude/developer_settings.json`
237
- - Windows: `%APPDATA%\Claude\developer_settings.json`
238
-
239
- ```json
240
- { "allowDevTools": false }
241
- ```
242
-
243
- Create the file if it doesn't exist.
244
-
245
- **Step 3 — Pin first-party mode** — add to the standard config file:
246
-
247
- - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
248
- - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
249
-
250
- ```json
251
- {
252
- "preferences": { },
253
- "deploymentMode": "1p"
254
- }
255
- ```
256
-
257
- Merge with existing keys — don't delete your `preferences` block.
258
-
259
- **Step 4 — Relaunch**
260
-
261
- ```bash
262
- open -a Claude
263
- ```
264
-
265
- Optional one-shot override if Desktop still picks up stale 3P state:
266
-
267
- ```bash
268
- /Applications/Claude.app/Contents/MacOS/Claude --boot-1p-once
269
- ```
270
-
271
- Stop the rflectr server (`Ctrl+C`) if you no longer need the gateway.
272
-
273
- **How to confirm it worked:** the Chat tab and Anthropic sign-in are back, no **Cowork 3P | Gateway** label appears bottom-left, the **Developer** menu is gone, and logs write to `~/Library/Logs/Claude/main.log` showing `claude.ai account active and logged in`.
274
-
275
- ### Option A — In-app (if the Developer menu is still available)
276
-
277
- Open **Developer → Configure third-party inference**, clear or replace the gateway settings, and apply. You may still need [Step 2](#restore-claude-desktop-to-anthropics-servers) afterward — clearing the gateway doesn't hide the Developer menu.
278
-
279
- ### Option B — Log out → Anthropic sign-in
280
-
281
- In 3P mode, **Log out** (bottom-left) can surface the sign-in screen with an option to use Anthropic directly. It's easy to miss; the verified revert above is more reliable.
282
-
283
- ### Full reset (deletes local Desktop history)
284
-
285
- Only if the above isn't enough:
286
-
287
- | Platform | Delete |
288
- |---|---|
289
- | macOS | `~/Library/Application Support/Claude-3p/` and optionally `~/Claude/` |
290
- | Windows | `%LOCALAPPDATA%\Claude-3p\` and optionally `%USERPROFILE%\Claude\` |
291
-
292
- > ⚠️ Conversation history in that folder is not recoverable after deletion.
293
-
294
- **Managed / enterprise profiles:** if IT pushed a managed profile (Jamf, Intune, Group Policy), local `configLibrary/` edits may be ignored or restored on launch. Talk to IT.
295
-
296
- ---
297
-
298
- ## Disable Developer Mode
299
-
300
- There is **no "Disable Developer Mode" menu item** in Claude Desktop v1.11847.5. To turn it off after reverting:
301
-
302
- 1. Fully quit Claude Desktop.
303
- 2. Edit `developer_settings.json` in the **standard** `Claude/` folder (paths above).
304
- 3. Set `"allowDevTools": false`.
305
- 4. Relaunch.
306
-
307
- To re-enable later: set `"allowDevTools": true` and relaunch, or use **Help → Troubleshooting → Enable Developer Mode** again.
308
-
309
- ---
310
-
311
- ## Troubleshooting
312
-
313
- ### Gateway config doesn't seem to apply
314
-
315
- - Confirm **Connection** uses **Gateway** with a valid base URL and API key.
316
- - Config is read at launch — fully quit and reopen Desktop after **Apply locally**.
317
- - **Help → Troubleshooting → Copy Managed Configuration Report** shows what the app loaded (secrets redacted).
318
- - Logs: macOS `~/Library/Logs/Claude-3p/main.log`, Windows `%LOCALAPPDATA%\Claude-3p\Logs\main.log`.
319
-
320
- ### Test connection / model discovery fails
321
-
322
- | Check | Action |
323
- |---|---|
324
- | Server not running | Start `rflectr server` and keep the terminal open. |
325
- | Wrong base URL | `http://127.0.0.1:17645/anthropic`, no `/v1` suffix. |
326
- | Empty API key | Any non-empty string for local mode. |
327
- | Network mode | Base URL uses the server's LAN IP; API key matches the server password. |
328
- | Firewall | Allow local connections to port `17645`. |
329
-
330
- ```bash
331
- curl -s http://127.0.0.1:17645/health
332
- curl -s -H "Authorization: Bearer test" http://127.0.0.1:17645/anthropic/v1/models
333
- ```
334
-
335
- ### Model picker shows 0 models or fewer than expected
336
-
337
- - **Discovery id masking:** answer **Yes** in the server wizard — Desktop hides models whose gateway ids contain competitor vendor strings.
338
- - **Provider filter:** re-run the wizard and add the providers you need.
339
- - **Favorites-only:** add models with `rflectr models`, or turn favorites-only off.
340
- - **Providers:** `rflectr providers list` — ensure the providers you want are configured.
341
-
342
- ### Models show in `curl` but not in Desktop
343
-
344
- Enable **Mask gateway model ids for discovery**, restart the server, relaunch Desktop.
345
-
346
- ### `Missing OPENCODE_API_KEY` when starting the server
347
-
348
- Run `rflectr claude` once to store your key, or export `OPENCODE_API_KEY` before `rflectr server`.
349
-
350
- ### `No providers configured`
351
-
352
- ```bash
353
- rflectr providers add # or: rflectr providers import
354
- ```
355
-
356
- ### Authentication errors from the gateway (401)
357
-
358
- - **Local mode:** any non-empty bearer token works.
359
- - **Network mode:** the gateway API key in Desktop must match the server password exactly.
360
-
361
- ### Generate a diagnostic report
362
-
363
- **Help → Troubleshooting → Generate Diagnostic Report**, then share the saved folder. No conversation content is included.
364
-
365
- ---
366
-
367
- ## Official references
368
-
369
- | Topic | Link |
370
- |---|---|
371
- | Third-party inference overview | [claude.com/docs/cowork/3p/overview](https://claude.com/docs/cowork/3p/overview) |
372
- | Installation and setup | [claude.com/docs/cowork/3p/installation](https://claude.com/docs/cowork/3p/installation) |
373
- | Configuration reference | [claude.com/docs/cowork/3p/configuration](https://claude.com/docs/cowork/3p/configuration) |
374
- | User identity and local data | [claude.com/docs/cowork/3p/data-storage](https://claude.com/docs/cowork/3p/data-storage) |
375
- | Claude Desktop download | [claude.com/download](https://claude.com/download) |
376
- | rflectr API server | [API Server guide](api-server.md) |
377
-
378
- ---
379
-
380
- ## Related guides
381
-
382
- - [API Server](api-server.md) · [Providers](providers.md) · [Troubleshooting](../faqs/troubleshooting.md)
@@ -1,296 +0,0 @@
1
- # Codex
2
-
3
- > Category: Guide | Version: 1.0 | Date: June 2026 | Status: Active
4
-
5
- Use **OpenAI Codex** — the terminal CLI or the desktop app — with any model from your rflectr registry: Anthropic, xAI, Google Gemini, Nvidia, DeepSeek, OpenAI, and more.
6
-
7
- | Command | Launches | Config target |
8
- |---|---|---|
9
- | `rflectr codex` | Codex **terminal** (TUI) | A temporary sidecar profile — never touches your main Codex config. |
10
- | `rflectr codex-app` | Codex **desktop app** (macOS / Windows) | Patches `~/.codex/config.toml` with a backup; restored on `Ctrl+C`. |
11
-
12
- Both use the same registry (`~/.rflectr/providers.json`) and provider picker. The CLI uses OpenAI directly when possible; the desktop app always uses the local Responses proxy so it can keep Codex's built-in provider identity and preserve history visibility.
13
-
14
- > 📖 Full flags: `rflectr codex --help` and `rflectr codex-app --help`.
15
- > 🤖 Automating it? See [AI Agents & automation](ai-agents.md) or run `rflectr --ai`.
16
-
17
- ---
18
-
19
- ## Prerequisites
20
-
21
- 1. **rflectr** on your PATH (`npm install -g @legioncodeinc/rflectr`, or `npm run build && npm link` locally).
22
- 2. **At least one provider:** `rflectr providers add` (or `rflectr providers import`).
23
- 3. **Codex installed:**
24
- - CLI: `npm install -g @openai/codex` (for `rflectr codex`)
25
- - Desktop: [Codex for macOS or Windows](https://developers.openai.com/codex/cli) (for `rflectr codex-app`)
26
-
27
- Registry providers plus OpenCode Zen/Go cloud backends all route through rflectr's local Responses proxy.
28
-
29
- ---
30
-
31
- ## How it works
32
-
33
- Codex speaks the **OpenAI Responses API** (`POST /v1/responses`). Most registry providers don't, so rflectr bridges the gap with a two-tier routing model:
34
-
35
- ```mermaid
36
- flowchart LR
37
- codex["Codex"]
38
- codex -->|"Tier 1: OpenAI only"| openai["OpenAI directly"]
39
- codex -->|"Tier 2: everyone else"| proxy["rflectr Responses proxy<br/>(127.0.0.1)"]
40
- proxy --> sdk["Vercel AI SDK"]
41
- sdk --> upstream["Anthropic / xAI / Gemini / DeepSeek / …"]
42
- ```
43
-
44
- | Tier | Providers | What rflectr does |
45
- |---|---|---|
46
- | **Tier 1 — Direct** | OpenAI (API key or ChatGPT OAuth) | Points Codex at OpenAI; no local proxy. |
47
- | **Tier 2 — Proxy** | Anthropic, xAI, Gemini, Nvidia, DeepSeek, most others | Local server translates Responses ↔ upstream SDK. |
48
-
49
- Your real API keys stay in rflectr (keychain / registry). The proxy holds them in memory for the session only.
50
-
51
- ---
52
-
53
- ## Codex CLI (`rflectr codex`)
54
-
55
- ### Quick start
56
-
57
- ```bash
58
- rflectr codex
59
- ```
60
-
61
- Pick provider → pick model → the Codex TUI opens. Under the hood rflectr runs `codex --profile rflectr-launch -m <model-id>`.
62
-
63
- ### Flags
64
-
65
- | Flag | Purpose |
66
- |---|---|
67
- | *(none)* | Interactive launch. |
68
- | `--restore` | Remove leftover CLI files after a crash. |
69
- | `--config` | Write profile + catalog to disk, print paths, exit (no launch). |
70
- | `--help` | Help text. |
71
-
72
- rflectr manages `--profile` and `-m` / `--model`; pass any other Codex flag directly (no `--` needed):
73
-
74
- ```bash
75
- rflectr codex -s workspace-write
76
- ```
77
-
78
- ### Files rflectr owns (CLI)
79
-
80
- | File | Purpose |
81
- |---|---|
82
- | `~/.codex/rflectr-launch.config.toml` | Temporary profile for this session. |
83
- | `~/.rflectr/codex/models-<provider>.json` | Model catalog. |
84
- | `~/.rflectr/codex/session.json` | Session lock (one CLI session at a time). |
85
-
86
- rflectr **never edits** `~/.codex/config.toml` for CLI launches — your personal Codex settings still apply.
87
-
88
- ### Cleanup (CLI)
89
-
90
- | Situation | What happens |
91
- |---|---|
92
- | Normal exit (including `Ctrl+C` in Codex) | Overlay files removed automatically. |
93
- | Crash / force-quit | Files may remain; next launch auto-recovers when possible. |
94
- | Manual | `rflectr codex --restore`. |
95
-
96
- ### What rflectr injects (CLI)
97
-
98
- | Variable | When | Why |
99
- |---|---|---|
100
- | `RFLECTR_CODEX_KEY=proxy-local` | Tier 2 only | Placeholder so Codex hits the local proxy; the real key stays in the proxy. |
101
- | `OPENAI_API_KEY` (etc.) | Tier 1 OpenAI | Codex calls OpenAI natively. |
102
-
103
- rflectr **strips CI env vars** (`CI`, `CODEX_CI`, `GITHUB_ACTIONS`, …) before spawning Codex so IDE terminals don't accidentally force read-only CI mode. `RFLECTR_CODEX_KEY` does **not** control sandbox policy.
104
-
105
- ### Sandbox and network (CLI)
106
-
107
- Two layers people confuse:
108
-
109
- 1. **Codex's sandbox** — shell commands inside Codex (files, network, approvals). Lives in `~/.codex/config.toml` and Codex CLI flags.
110
- 2. **rflectr's proxy** — model API traffic only.
111
-
112
- `rflectr codex` **defaults to `danger-full-access`** (set in both the launch profile and the spawn args) so shell tools (`curl`, `nlm`, npm, MCP CLIs) reach the network without passing `-s` each time. Override per session:
113
-
114
- ```bash
115
- rflectr codex -s workspace-write
116
- ```
117
-
118
- To change the sandbox for bare `codex` (without rflectr), edit `~/.codex/config.toml` yourself:
119
-
120
- ```toml
121
- sandbox = "danger-full-access"
122
- ask_for_approval = "never"
123
-
124
- [shell_environment_policy]
125
- inherit = "all"
126
- ```
127
-
128
- On macOS, profile TOML alone may not be enough; rflectr also passes `-s danger-full-access` on spawn ([Codex #10390](https://github.com/openai/codex/issues/10390)).
129
-
130
- ---
131
-
132
- ## Codex desktop app (`rflectr codex-app`)
133
-
134
- ### Quick start
135
-
136
- ```bash
137
- rflectr codex-app
138
- ```
139
-
140
- Pick provider → pick model → the Codex **app** opens. **Keep the rflectr terminal open** until you're done — the app always uses the foreground proxy. Press **`Ctrl+C`** to stop the proxy and restore your previous Codex config.
141
-
142
- **Platforms:** macOS and Windows (no Codex desktop app on Linux).
143
-
144
- ### Flags
145
-
146
- | Flag | Purpose |
147
- |---|---|
148
- | *(none)* | Interactive launch + open app. |
149
- | `--restore` | Restore `config.toml` and remove rflectr app files. |
150
- | `--config` | **Preview only** — print the TOML that would be written; no disk writes, no app, no proxy. |
151
- | `--help` | Help text. |
152
-
153
- `--config` skips the picker and uses your last Codex provider/model (or the first compatible provider). The shown port `54321` is a placeholder; a real launch uses a random port.
154
-
155
- ### Files rflectr owns (App)
156
-
157
- | File | Purpose |
158
- |---|---|
159
- | `~/.codex/config.toml` | **Patched while active** — restored on `Ctrl+C` or `--restore`. |
160
- | `~/.rflectr/codex/app-models-<provider>.json` | Model catalog. |
161
- | `~/.rflectr/codex/session-app.json` | App session lock. |
162
- | `~/.rflectr/codex/app-restore-state.json` | Snapshot of your pre-session root keys (for surgical restore). |
163
- | `~/.rflectr/codex/backups/config.toml.*.bak` | Rotating backups before each patch. |
164
-
165
- CLI and App files are separate — running one after the other won't break the other.
166
-
167
- ### What gets written to `config.toml`
168
-
169
- ```toml
170
- model = "claude-sonnet-4-6"
171
- model_provider = "openai"
172
- openai_base_url = "http://127.0.0.1:<random-port>/v1"
173
- model_catalog_json = "/Users/you/.rflectr/codex/app-models-anthropic.json"
174
- model_context_window = 1000000
175
- model_auto_compact_token_limit = 700000
176
- ```
177
-
178
- The app deliberately keeps `model_provider = "openai"` and redirects the built-in provider with `openai_base_url`. Codex records the provider on every local thread and filters history by provider; a separate custom provider would hide your existing OpenAI/ChatGPT threads while a rflectr session is active. No conversations are deleted. (See [Context management](#context-management) for the two context fields.)
179
-
180
- ### Cleanup (App)
181
-
182
- | Situation | What to do |
183
- |---|---|
184
- | Normal end of session | `Ctrl+C` in the rflectr terminal → config restored, proxy stopped. |
185
- | Codex already running | rflectr offers to **restart Codex** so new settings apply; decline and reopen manually if you prefer. |
186
- | Crash / killed terminal | Next launch auto-recovers, or `rflectr codex-app --restore`. |
187
- | Live session still running | `--restore` refuses until you `Ctrl+C` the other terminal. |
188
-
189
- ### App vs CLI — config safety
190
-
191
- | | CLI | App |
192
- |---|---|---|
193
- | Touches `~/.codex/config.toml`? | **Never** | Yes, with backup + restore |
194
- | Proxy lifetime | Until Codex CLI exits | Until **`Ctrl+C`** in the rflectr terminal |
195
- | Picker every launch? | Yes (prefs pre-highlight last choice) | Yes |
196
-
197
- ---
198
-
199
- ## Favorites catalog mode
200
-
201
- When you've saved favorites via `rflectr models`, both commands show your starting model + favorites in the mid-session picker. Zen/Go favorites are included when an OpenCode API key is available.
202
-
203
- - **Slugs** — CLI uses `${providerId}__${modelId}` so models from different providers never collide. The App uses bare ids for single-provider catalogs and the same collision-safe slug for favorites.
204
- - **Auth** — CLI favorites give the Codex child `OPENAI_API_KEY=proxy-local`; the app keeps its normal OpenAI login while `openai_base_url` points at the proxy. Either way the proxy holds the real credentials.
205
- - **Warm-up** — with ~20 favorites across many providers, the first request may be slow as the proxy initializes one `LanguageModel` per favorite. Subsequent requests are fast.
206
-
207
- ---
208
-
209
- ## Reasoning effort
210
-
211
- Codex shows a **reasoning-effort** picker when rflectr's catalog includes supported levels. rflectr fills `supported_reasoning_levels`, `default_reasoning_level`, and `supports_reasoning_summaries` from its reasoning resolver — provider metadata first, provider-specific rules second. You control effort in **Codex's native UI**; rflectr adds no menu of its own. For `codex-app`, an existing `model_reasoning_effort` in your config is **preserved**.
212
-
213
- | Provider npm | Example models | Picker levels | Wire mapping |
214
- |---|---|---|---|
215
- | `@ai-sdk/anthropic` | claude-sonnet-4-6, claude-opus-4-6 | low, medium, high | SDK `thinking: adaptive` + `effort` |
216
- | `@ai-sdk/openai` | gpt-5.5, gpt-5.4-codex | low, medium, high, xhigh | `reasoningEffort` on Responses API |
217
- | `@ai-sdk/google` | gemini-2.5-pro, gemini-3-flash | low, medium, high | Gemini 2.5 → token budget; Gemini 3 → `thinkingLevel` |
218
- | `@ai-sdk/mistral` | mistral-large, magistral-* | **high, off only** | `reasoningEffort: high \| none` |
219
- | `@ai-sdk/xai` | grok-* | none, low, medium, high | `reasoningEffort` |
220
- | `@openrouter/ai-sdk-provider` | z-ai/glm-5.2, models with `reasoning` support | none, minimal, low, medium, high, xhigh | `providerOptions.openrouter.reasoning.effort` |
221
- | `@ai-sdk/openai-compatible` | unknown backends | *(picker hidden)* | no effort sent |
222
-
223
- Unrecognized local models (e.g. Ollama `llama3:8b`) get an empty picker — best-effort, no guarantee.
224
-
225
- ---
226
-
227
- ## Provider routing
228
-
229
- | Provider | CLI route | App route | Notes |
230
- |---|---|---|---|
231
- | **OpenAI** | Tier 1 direct | Local proxy | `rflectr providers auth openai` for ChatGPT OAuth. |
232
- | **Anthropic, xAI, Gemini, Nvidia, DeepSeek, …** | Tier 2 proxy | Local proxy | SDK translation path. |
233
- | **OpenCode Zen / Go** | Tier 2 proxy | Local proxy | Requires an OpenCode API key. |
234
-
235
- ---
236
-
237
- ## OAuth
238
-
239
- Tokens (e.g. xAI, OpenAI OAuth) refresh **at launch only**. Long sessions may return 401 when a token expires — restart `rflectr codex` or `rflectr codex-app`.
240
-
241
- ---
242
-
243
- ## Context management
244
-
245
- **Codex App is a stateless client:** it sends the full accumulated conversation history with every request (the Responses API `previous_response_id` field is not implemented in the app binary). Each turn therefore grows larger, and a long GPT-5.5 session (which OpenAI manages server-side) can't be transparently resumed on a different model — the full local history is sent inline, and a 1 M-token model rejects a 2 M-token payload.
246
-
247
- rflectr protects against overflow in two layers:
248
-
249
- 1. **Early auto-compaction via `config.toml`.** rflectr writes `model_context_window` and `model_auto_compact_token_limit` (70% of the limit). Codex compacts before hitting the threshold, leaving headroom for the compaction request itself.
250
- 2. **Proxy-level truncation as a last resort.** If an over-threshold conversation reaches the proxy (e.g. after switching off a GPT-5.5 session), rflectr drops the oldest messages to bring the estimate under ~85% of the window — degraded but functional rather than crashing.
251
-
252
- **"Custom" label:** Codex App labels any catalog-loaded model as **"Custom"** (e.g. "Custom · Medium"). That's expected — the model rflectr selected is in use; the label is cosmetic.
253
-
254
- **Background requests:** Codex App's internal agent periodically sends background requests with hardcoded OpenAI model ids (`gpt-5.4`, `gpt-5.4-mini`, `gpt-5.5`). rflectr's proxy silently routes these to the session's starting model. Harmless — it handles UI state, not your conversation.
255
-
256
- ---
257
-
258
- ## Troubleshooting
259
-
260
- ### CLI (`rflectr codex`)
261
-
262
- | Symptom | Fix |
263
- |---|---|
264
- | Provider missing in picker | `rflectr providers add` |
265
- | Leftover files after crash | Next launch auto-cleans, or `rflectr codex --restore` |
266
- | "Another session running" | Wait, or `--restore` |
267
- | Shell tools have no network | Confirm `rflectr codex --config` shows `sandbox = "danger-full-access"`, or pass `-s danger-full-access` |
268
- | Read-only / CI behavior | rflectr strips CI vars; try Terminal.app outside your IDE |
269
- | `codex` not found | `npm install -g @openai/codex` |
270
-
271
- ### App (`rflectr codex-app`)
272
-
273
- | Symptom | Fix |
274
- |---|---|
275
- | Conversations disappear during a session | Update rflectr — older releases used a custom `model_provider`; current releases keep `openai` and preserve history. |
276
- | App didn't open | Open Codex once manually, then re-run `rflectr codex-app` |
277
- | Model errors / disconnected | Keep the rflectr terminal open (the proxy must run) |
278
- | Stuck on rflectr settings | `rflectr codex-app --restore` |
279
- | `--restore` blocked | `Ctrl+C` the other `codex-app` terminal first |
280
- | Wrong config after a test | `--restore`; backups live in `~/.rflectr/codex/backups/` |
281
- | "prompt too long" after many turns | History outgrew the context limit — start a fresh conversation. See [Context management](#context-management). |
282
- | Model shows as "Custom" | Expected — the correct model is in use. |
283
-
284
- ### Shared
285
-
286
- | Symptom | Fix |
287
- |---|---|
288
- | Anthropic key rejected on `providers add` | Update rflectr (Bearer vs `x-api-key` fix). |
289
- | "rflectr forced sandbox" | It didn't — check Codex sandbox flags, not `RFLECTR_CODEX_KEY`. |
290
-
291
- ---
292
-
293
- ## Related guides
294
-
295
- - [AI Agents & automation](ai-agents.md) · [Providers](providers.md) · [Troubleshooting](../faqs/troubleshooting.md)
296
- - [Codex advanced config](https://developers.openai.com/codex/config-advanced) · [Codex approvals & security](https://developers.openai.com/codex/agent-approvals-security)