oc-chatgpt-multi-auth 4.9.0

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 (134) hide show
  1. package/LICENSE +37 -0
  2. package/README.md +507 -0
  3. package/assets/opencode-logo-ornate-dark.svg +18 -0
  4. package/assets/readme-hero.svg +31 -0
  5. package/config/README.md +110 -0
  6. package/config/minimal-opencode.json +13 -0
  7. package/config/opencode-legacy.json +572 -0
  8. package/config/opencode-modern.json +240 -0
  9. package/dist/index.d.ts +45 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +971 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/lib/accounts.d.ts +120 -0
  14. package/dist/lib/accounts.d.ts.map +1 -0
  15. package/dist/lib/accounts.js +579 -0
  16. package/dist/lib/accounts.js.map +1 -0
  17. package/dist/lib/auth/auth.d.ts +51 -0
  18. package/dist/lib/auth/auth.d.ts.map +1 -0
  19. package/dist/lib/auth/auth.js +180 -0
  20. package/dist/lib/auth/auth.js.map +1 -0
  21. package/dist/lib/auth/browser.d.ts +17 -0
  22. package/dist/lib/auth/browser.d.ts.map +1 -0
  23. package/dist/lib/auth/browser.js +83 -0
  24. package/dist/lib/auth/browser.js.map +1 -0
  25. package/dist/lib/auth/server.d.ts +10 -0
  26. package/dist/lib/auth/server.d.ts.map +1 -0
  27. package/dist/lib/auth/server.js +85 -0
  28. package/dist/lib/auth/server.js.map +1 -0
  29. package/dist/lib/auto-update-checker.d.ts +10 -0
  30. package/dist/lib/auto-update-checker.d.ts.map +1 -0
  31. package/dist/lib/auto-update-checker.js +129 -0
  32. package/dist/lib/auto-update-checker.js.map +1 -0
  33. package/dist/lib/cli.d.ts +9 -0
  34. package/dist/lib/cli.d.ts.map +1 -0
  35. package/dist/lib/cli.js +50 -0
  36. package/dist/lib/cli.js.map +1 -0
  37. package/dist/lib/config.d.ts +17 -0
  38. package/dist/lib/config.d.ts.map +1 -0
  39. package/dist/lib/config.js +102 -0
  40. package/dist/lib/config.js.map +1 -0
  41. package/dist/lib/constants.d.ts +74 -0
  42. package/dist/lib/constants.d.ts.map +1 -0
  43. package/dist/lib/constants.js +74 -0
  44. package/dist/lib/constants.js.map +1 -0
  45. package/dist/lib/context-overflow.d.ts +27 -0
  46. package/dist/lib/context-overflow.d.ts.map +1 -0
  47. package/dist/lib/context-overflow.js +124 -0
  48. package/dist/lib/context-overflow.js.map +1 -0
  49. package/dist/lib/index.d.ts +13 -0
  50. package/dist/lib/index.d.ts.map +1 -0
  51. package/dist/lib/index.js +13 -0
  52. package/dist/lib/index.js.map +1 -0
  53. package/dist/lib/logger.d.ts +22 -0
  54. package/dist/lib/logger.d.ts.map +1 -0
  55. package/dist/lib/logger.js +175 -0
  56. package/dist/lib/logger.js.map +1 -0
  57. package/dist/lib/oauth-success.html +712 -0
  58. package/dist/lib/prompts/codex-opencode-bridge.d.ts +19 -0
  59. package/dist/lib/prompts/codex-opencode-bridge.d.ts.map +1 -0
  60. package/dist/lib/prompts/codex-opencode-bridge.js +152 -0
  61. package/dist/lib/prompts/codex-opencode-bridge.js.map +1 -0
  62. package/dist/lib/prompts/codex.d.ts +32 -0
  63. package/dist/lib/prompts/codex.d.ts.map +1 -0
  64. package/dist/lib/prompts/codex.js +262 -0
  65. package/dist/lib/prompts/codex.js.map +1 -0
  66. package/dist/lib/prompts/opencode-codex.d.ts +21 -0
  67. package/dist/lib/prompts/opencode-codex.d.ts.map +1 -0
  68. package/dist/lib/prompts/opencode-codex.js +91 -0
  69. package/dist/lib/prompts/opencode-codex.js.map +1 -0
  70. package/dist/lib/recovery/constants.d.ts +12 -0
  71. package/dist/lib/recovery/constants.d.ts.map +1 -0
  72. package/dist/lib/recovery/constants.js +25 -0
  73. package/dist/lib/recovery/constants.js.map +1 -0
  74. package/dist/lib/recovery/index.d.ts +12 -0
  75. package/dist/lib/recovery/index.d.ts.map +1 -0
  76. package/dist/lib/recovery/index.js +12 -0
  77. package/dist/lib/recovery/index.js.map +1 -0
  78. package/dist/lib/recovery/storage.d.ts +24 -0
  79. package/dist/lib/recovery/storage.d.ts.map +1 -0
  80. package/dist/lib/recovery/storage.js +354 -0
  81. package/dist/lib/recovery/storage.js.map +1 -0
  82. package/dist/lib/recovery/types.d.ts +116 -0
  83. package/dist/lib/recovery/types.d.ts.map +1 -0
  84. package/dist/lib/recovery/types.js +7 -0
  85. package/dist/lib/recovery/types.js.map +1 -0
  86. package/dist/lib/recovery.d.ts +31 -0
  87. package/dist/lib/recovery.d.ts.map +1 -0
  88. package/dist/lib/recovery.js +308 -0
  89. package/dist/lib/recovery.js.map +1 -0
  90. package/dist/lib/refresh-queue.d.ts +100 -0
  91. package/dist/lib/refresh-queue.d.ts.map +1 -0
  92. package/dist/lib/refresh-queue.js +196 -0
  93. package/dist/lib/refresh-queue.js.map +1 -0
  94. package/dist/lib/request/fetch-helpers.d.ts +81 -0
  95. package/dist/lib/request/fetch-helpers.d.ts.map +1 -0
  96. package/dist/lib/request/fetch-helpers.js +325 -0
  97. package/dist/lib/request/fetch-helpers.js.map +1 -0
  98. package/dist/lib/request/helpers/input-utils.d.ts +7 -0
  99. package/dist/lib/request/helpers/input-utils.d.ts.map +1 -0
  100. package/dist/lib/request/helpers/input-utils.js +213 -0
  101. package/dist/lib/request/helpers/input-utils.js.map +1 -0
  102. package/dist/lib/request/helpers/model-map.d.ts +28 -0
  103. package/dist/lib/request/helpers/model-map.d.ts.map +1 -0
  104. package/dist/lib/request/helpers/model-map.js +109 -0
  105. package/dist/lib/request/helpers/model-map.js.map +1 -0
  106. package/dist/lib/request/rate-limit-backoff.d.ts +17 -0
  107. package/dist/lib/request/rate-limit-backoff.d.ts.map +1 -0
  108. package/dist/lib/request/rate-limit-backoff.js +74 -0
  109. package/dist/lib/request/rate-limit-backoff.js.map +1 -0
  110. package/dist/lib/request/request-transformer.d.ts +93 -0
  111. package/dist/lib/request/request-transformer.d.ts.map +1 -0
  112. package/dist/lib/request/request-transformer.js +405 -0
  113. package/dist/lib/request/request-transformer.js.map +1 -0
  114. package/dist/lib/request/response-handler.d.ts +14 -0
  115. package/dist/lib/request/response-handler.d.ts.map +1 -0
  116. package/dist/lib/request/response-handler.js +90 -0
  117. package/dist/lib/request/response-handler.js.map +1 -0
  118. package/dist/lib/rotation.d.ts +121 -0
  119. package/dist/lib/rotation.d.ts.map +1 -0
  120. package/dist/lib/rotation.js +248 -0
  121. package/dist/lib/rotation.js.map +1 -0
  122. package/dist/lib/storage.d.ts +91 -0
  123. package/dist/lib/storage.d.ts.map +1 -0
  124. package/dist/lib/storage.js +323 -0
  125. package/dist/lib/storage.js.map +1 -0
  126. package/dist/lib/types.d.ts +185 -0
  127. package/dist/lib/types.d.ts.map +1 -0
  128. package/dist/lib/types.js +2 -0
  129. package/dist/lib/types.js.map +1 -0
  130. package/package.json +86 -0
  131. package/scripts/copy-oauth-success.js +37 -0
  132. package/scripts/install-opencode-codex-auth.js +193 -0
  133. package/scripts/test-all-models.sh +260 -0
  134. package/scripts/validate-model-map.sh +97 -0
package/LICENSE ADDED
@@ -0,0 +1,37 @@
1
+ MIT License with Usage Disclaimer
2
+
3
+ Copyright (c) 2024-2025 numman-ali
4
+
5
+ USAGE NOTICE AND DISCLAIMER:
6
+ This software is provided for personal development use only. Users must comply
7
+ with OpenAI's Terms of Service (https://openai.com/policies/terms-of-use/) and
8
+ Usage Policies (https://openai.com/policies/usage-policies/) when using this
9
+ software to access OpenAI services.
10
+
11
+ The authors and contributors are not responsible for any violations of
12
+ third-party terms of service. For commercial use or production applications,
13
+ obtain proper API access from OpenAI directly through the OpenAI Platform
14
+ (https://platform.openai.com/).
15
+
16
+ This software uses OpenAI's official OAuth authentication system and is not
17
+ affiliated with, endorsed by, or sponsored by OpenAI.
18
+
19
+ ---
20
+
21
+ Permission is hereby granted, free of charge, to any person obtaining a copy
22
+ of this software and associated documentation files (the "Software"), to deal
23
+ in the Software without restriction, including without limitation the rights
24
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
+ copies of the Software, and to permit persons to whom the Software is
26
+ furnished to do so, subject to the following conditions:
27
+
28
+ The above copyright notice, usage notice, and this permission notice shall be
29
+ included in all copies or substantial portions of the Software.
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,507 @@
1
+ # OpenAI Codex Auth Plugin for OpenCode
2
+
3
+ [![npm version](https://img.shields.io/npm/v/oc-chatgpt-multi-auth.svg)](https://www.npmjs.com/package/oc-chatgpt-multi-auth)
4
+ [![npm downloads](https://img.shields.io/npm/dw/oc-chatgpt-multi-auth.svg)](https://www.npmjs.com/package/oc-chatgpt-multi-auth)
5
+ [![Tests](https://github.com/ndycode/oc-chatgpt-multi-auth/actions/workflows/ci.yml/badge.svg)](https://github.com/ndycode/oc-chatgpt-multi-auth/actions)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
+
8
+ Enable OpenCode to authenticate against **OpenAI's Codex backend** via OAuth so you can use ChatGPT Plus/Pro rate limits and access models like `gpt-5.2`, `gpt-5.2-codex`, and `gpt-5.1-codex-max` with your ChatGPT credentials.
9
+
10
+ > [!NOTE]
11
+ > **Renamed from `opencode-openai-codex-auth-multi`** — If you were using the old package, update your config to use `oc-chatgpt-multi-auth` instead. The rename was necessary because OpenCode blocks plugins containing `opencode-openai-codex-auth` in the name.
12
+
13
+ ## What You Get
14
+
15
+ - **GPT-5.2, GPT-5.2 Codex, GPT-5.1 Codex Max** and all GPT-5.x variants via ChatGPT OAuth
16
+ - **Multi-account support** — add multiple ChatGPT accounts, health-aware rotation with automatic failover
17
+ - **Auto-update notifications** — get notified when a new version is available
18
+ - **22 model presets** — full variant system with reasoning levels (none/low/medium/high/xhigh)
19
+ - **Prompt caching** — session-based caching for faster multi-turn conversations
20
+ - **Usage-aware errors** — friendly messages with rate limit reset timing
21
+ - **Plugin compatible** — works alongside other OpenCode plugins (oh-my-opencode, dcp, etc.)
22
+
23
+ ---
24
+
25
+ <details open>
26
+ <summary><b>Terms of Service Warning — Read Before Installing</b></summary>
27
+
28
+ > [!CAUTION]
29
+ > This plugin uses OpenAI's official OAuth authentication (the same method as OpenAI's official Codex CLI) for personal development use with your ChatGPT Plus/Pro subscription.
30
+ >
31
+ > **This plugin is for personal development only:**
32
+ > - Not for commercial services, API resale, or multi-user applications
33
+ > - For production use, see [OpenAI Platform API](https://platform.openai.com/)
34
+ >
35
+ > **By using this plugin, you acknowledge:**
36
+ > - This is an unofficial tool not endorsed by OpenAI
37
+ > - Users are responsible for compliance with [OpenAI's Terms of Use](https://openai.com/policies/terms-of-use/)
38
+ > - You assume all risks associated with using this plugin
39
+
40
+ </details>
41
+
42
+ ---
43
+
44
+ ## Installation
45
+
46
+ <details open>
47
+ <summary><b>For Humans</b></summary>
48
+
49
+ **Option A: Let an LLM do it**
50
+
51
+ Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):
52
+
53
+ ```
54
+ Install the oc-chatgpt-multi-auth plugin and add the OpenAI model definitions to ~/.config/opencode/opencode.json by following: https://raw.githubusercontent.com/ndycode/oc-chatgpt-multi-auth/main/README.md
55
+ ```
56
+
57
+ **Option B: One-command install**
58
+
59
+ ```bash
60
+ npx -y oc-chatgpt-multi-auth@latest
61
+ ```
62
+
63
+ This writes the config to `~/.config/opencode/opencode.json`, backs up existing config, and clears the plugin cache.
64
+
65
+ > Want legacy config (OpenCode v1.0.209 and below)? Add `--legacy` flag.
66
+
67
+ **Option C: Manual setup**
68
+
69
+ 1. **Add the plugin** to `~/.config/opencode/opencode.json`:
70
+
71
+ ```json
72
+ {
73
+ "plugin": ["oc-chatgpt-multi-auth@latest"]
74
+ }
75
+ ```
76
+
77
+ 2. **Login** with your ChatGPT account:
78
+
79
+ ```bash
80
+ opencode auth login
81
+ ```
82
+
83
+ 3. **Add models** — copy the [full configuration](#models) below
84
+
85
+ 4. **Use it:**
86
+
87
+ ```bash
88
+ opencode run "Hello" --model=openai/gpt-5.2 --variant=medium
89
+ ```
90
+
91
+ </details>
92
+
93
+ <details>
94
+ <summary><b>For LLM Agents</b></summary>
95
+
96
+ ### Step-by-Step Instructions
97
+
98
+ 1. Edit the OpenCode configuration file at `~/.config/opencode/opencode.json`
99
+
100
+ > **Note**: This path works on all platforms. On Windows, `~` resolves to your user home directory (e.g., `C:\Users\YourName`).
101
+
102
+ 2. Add the plugin to the `plugin` array:
103
+ ```json
104
+ {
105
+ "plugin": ["oc-chatgpt-multi-auth@latest"]
106
+ }
107
+ ```
108
+
109
+ 3. Add the model definitions from the [Full models configuration](#full-models-configuration-copy-paste-ready) section
110
+
111
+ 4. Set `provider` to `"openai"` and choose a model
112
+
113
+ ### Verification
114
+
115
+ ```bash
116
+ opencode run "Hello" --model=openai/gpt-5.2 --variant=medium
117
+ ```
118
+
119
+ </details>
120
+
121
+ ---
122
+
123
+ ## Models
124
+
125
+ ### Model Reference
126
+
127
+ | Model | Variants | Notes |
128
+ |-------|----------|-------|
129
+ | `gpt-5.2` | none, low, medium, high, xhigh | Latest GPT-5.2 with reasoning levels |
130
+ | `gpt-5.2-codex` | low, medium, high, xhigh | GPT-5.2 Codex for code generation |
131
+ | `gpt-5.1-codex-max` | low, medium, high, xhigh | Maximum context Codex |
132
+ | `gpt-5.1-codex` | low, medium, high | Standard Codex |
133
+ | `gpt-5.1-codex-mini` | medium, high | Lightweight Codex |
134
+ | `gpt-5.1` | none, low, medium, high | GPT-5.1 base model |
135
+
136
+ **Using variants:**
137
+ ```bash
138
+ # Modern OpenCode (v1.0.210+)
139
+ opencode run "Hello" --model=openai/gpt-5.2 --variant=high
140
+
141
+ # Legacy OpenCode (v1.0.209 and below)
142
+ opencode run "Hello" --model=openai/gpt-5.2-high
143
+ ```
144
+
145
+ <details>
146
+ <summary><b>Full models configuration (copy-paste ready)</b></summary>
147
+
148
+ Add this to your `~/.config/opencode/opencode.json`:
149
+
150
+ ```json
151
+ {
152
+ "$schema": "https://opencode.ai/config.json",
153
+ "plugin": ["oc-chatgpt-multi-auth@latest"],
154
+ "provider": {
155
+ "openai": {
156
+ "options": {
157
+ "reasoningEffort": "medium",
158
+ "reasoningSummary": "auto",
159
+ "textVerbosity": "medium",
160
+ "include": ["reasoning.encrypted_content"],
161
+ "store": false
162
+ },
163
+ "models": {
164
+ "gpt-5.2": {
165
+ "name": "GPT 5.2 (OAuth)",
166
+ "limit": { "context": 272000, "output": 128000 },
167
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
168
+ "variants": {
169
+ "none": { "reasoningEffort": "none" },
170
+ "low": { "reasoningEffort": "low" },
171
+ "medium": { "reasoningEffort": "medium" },
172
+ "high": { "reasoningEffort": "high" },
173
+ "xhigh": { "reasoningEffort": "xhigh" }
174
+ }
175
+ },
176
+ "gpt-5.2-codex": {
177
+ "name": "GPT 5.2 Codex (OAuth)",
178
+ "limit": { "context": 272000, "output": 128000 },
179
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
180
+ "variants": {
181
+ "low": { "reasoningEffort": "low" },
182
+ "medium": { "reasoningEffort": "medium" },
183
+ "high": { "reasoningEffort": "high" },
184
+ "xhigh": { "reasoningEffort": "xhigh" }
185
+ }
186
+ },
187
+ "gpt-5.1-codex-max": {
188
+ "name": "GPT 5.1 Codex Max (OAuth)",
189
+ "limit": { "context": 272000, "output": 128000 },
190
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
191
+ "variants": {
192
+ "low": { "reasoningEffort": "low" },
193
+ "medium": { "reasoningEffort": "medium" },
194
+ "high": { "reasoningEffort": "high" },
195
+ "xhigh": { "reasoningEffort": "xhigh" }
196
+ }
197
+ },
198
+ "gpt-5.1-codex": {
199
+ "name": "GPT 5.1 Codex (OAuth)",
200
+ "limit": { "context": 272000, "output": 128000 },
201
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
202
+ "variants": {
203
+ "low": { "reasoningEffort": "low" },
204
+ "medium": { "reasoningEffort": "medium" },
205
+ "high": { "reasoningEffort": "high" }
206
+ }
207
+ },
208
+ "gpt-5.1-codex-mini": {
209
+ "name": "GPT 5.1 Codex Mini (OAuth)",
210
+ "limit": { "context": 272000, "output": 128000 },
211
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
212
+ "variants": {
213
+ "medium": { "reasoningEffort": "medium" },
214
+ "high": { "reasoningEffort": "high" }
215
+ }
216
+ },
217
+ "gpt-5.1": {
218
+ "name": "GPT 5.1 (OAuth)",
219
+ "limit": { "context": 272000, "output": 128000 },
220
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
221
+ "variants": {
222
+ "none": { "reasoningEffort": "none" },
223
+ "low": { "reasoningEffort": "low" },
224
+ "medium": { "reasoningEffort": "medium" },
225
+ "high": { "reasoningEffort": "high" }
226
+ }
227
+ }
228
+ }
229
+ }
230
+ }
231
+ }
232
+ ```
233
+
234
+ For legacy OpenCode (v1.0.209 and below), use `config/opencode-legacy.json` which has individual model entries like `gpt-5.2-low`, `gpt-5.2-medium`, etc.
235
+
236
+ </details>
237
+
238
+ ---
239
+
240
+ ## Multi-Account Setup
241
+
242
+ Add multiple ChatGPT accounts for higher combined quotas. The plugin uses **health-aware rotation** with automatic failover.
243
+
244
+ ```bash
245
+ opencode auth login # Run again to add more accounts
246
+ ```
247
+
248
+ **Manage accounts:**
249
+ - `openai-accounts` — List all accounts
250
+ - `openai-accounts-switch` — Switch active account
251
+ - `openai-accounts-status` — Show rate limit status
252
+
253
+ **How rotation works (v4.4.0+):**
254
+ - Health scoring tracks success/failure per account
255
+ - Token bucket prevents hitting rate limits
256
+ - Hybrid selection prefers healthy accounts with available tokens
257
+ - Always retries when all accounts are rate-limited (waits for reset)
258
+
259
+ **Storage:** `~/.opencode/openai-codex-accounts.json`
260
+
261
+ ---
262
+
263
+ ## Troubleshoot
264
+
265
+ > **Quick Reset**: Most issues can be resolved by deleting `~/.opencode/auth/openai.json` and running `opencode auth login` again.
266
+
267
+ ### Configuration Path (All Platforms)
268
+
269
+ OpenCode uses `~/.config/opencode/` on **all platforms** including Windows.
270
+
271
+ | File | Path |
272
+ |------|------|
273
+ | Main config | `~/.config/opencode/opencode.json` |
274
+ | Auth tokens | `~/.opencode/auth/openai.json` |
275
+ | Multi-account | `~/.opencode/openai-codex-accounts.json` |
276
+ | Plugin config | `~/.opencode/openai-codex-auth-config.json` |
277
+ | Debug logs | `~/.opencode/logs/codex-plugin/` |
278
+
279
+ > **Windows users**: `~` resolves to your user home directory (e.g., `C:\Users\YourName`).
280
+
281
+ ---
282
+
283
+ <details>
284
+ <summary><b>401 Unauthorized Error</b></summary>
285
+
286
+ **Cause:** Token expired or not authenticated.
287
+
288
+ **Solutions:**
289
+ 1. Re-authenticate:
290
+ ```bash
291
+ opencode auth login
292
+ ```
293
+ 2. Check auth file exists:
294
+ ```bash
295
+ cat ~/.opencode/auth/openai.json
296
+ ```
297
+
298
+ </details>
299
+
300
+ <details>
301
+ <summary><b>Browser Doesn't Open for OAuth</b></summary>
302
+
303
+ **Cause:** Port 1455 conflict or SSH/WSL environment.
304
+
305
+ **Solutions:**
306
+ 1. **Manual URL paste:**
307
+ - Re-run `opencode auth login`
308
+ - Select **"ChatGPT Plus/Pro (Manual URL Paste)"**
309
+ - Paste the full redirect URL after login
310
+
311
+ 2. **Check port availability:**
312
+ ```bash
313
+ # macOS/Linux
314
+ lsof -i :1455
315
+
316
+ # Windows
317
+ netstat -ano | findstr :1455
318
+ ```
319
+
320
+ 3. **Stop Codex CLI if running** — both use port 1455
321
+
322
+ </details>
323
+
324
+ <details>
325
+ <summary><b>Model Not Found</b></summary>
326
+
327
+ **Cause:** Missing provider prefix or config mismatch.
328
+
329
+ **Solutions:**
330
+ 1. Use `openai/` prefix:
331
+ ```bash
332
+ # Correct
333
+ --model=openai/gpt-5.2
334
+
335
+ # Wrong
336
+ --model=gpt-5.2
337
+ ```
338
+
339
+ 2. Verify model is in your config:
340
+ ```json
341
+ { "models": { "gpt-5.2": { ... } } }
342
+ ```
343
+
344
+ </details>
345
+
346
+ <details>
347
+ <summary><b>Rate Limit Exceeded</b></summary>
348
+
349
+ **Cause:** ChatGPT subscription usage limit reached.
350
+
351
+ **Solutions:**
352
+ 1. Wait for reset (plugin shows timing in error message)
353
+ 2. Add more accounts: `opencode auth login`
354
+ 3. Switch to a different model family
355
+
356
+ </details>
357
+
358
+ <details>
359
+ <summary><b>Multi-Turn Context Lost</b></summary>
360
+
361
+ **Cause:** Old plugin version or missing config.
362
+
363
+ **Solutions:**
364
+ 1. Update plugin:
365
+ ```bash
366
+ npx -y oc-chatgpt-multi-auth@latest
367
+ ```
368
+ 2. Ensure config has:
369
+ ```json
370
+ {
371
+ "include": ["reasoning.encrypted_content"],
372
+ "store": false
373
+ }
374
+ ```
375
+
376
+ </details>
377
+
378
+ <details>
379
+ <summary><b>OAuth Callback Issues (Safari/WSL/Docker)</b></summary>
380
+
381
+ **Safari HTTPS-Only Mode:**
382
+ - Use Chrome or Firefox instead, or
383
+ - Temporarily disable Safari > Settings > Privacy > "Enable HTTPS-Only Mode"
384
+
385
+ **WSL2:**
386
+ - Use VS Code's port forwarding, or
387
+ - Configure Windows → WSL port forwarding
388
+
389
+ **SSH / Remote:**
390
+ ```bash
391
+ ssh -L 1455:localhost:1455 user@remote
392
+ ```
393
+
394
+ **Docker / Containers:**
395
+ - OAuth with localhost redirect doesn't work in containers
396
+ - Use SSH port forwarding or manual URL flow
397
+
398
+ </details>
399
+
400
+ ---
401
+
402
+ ## Plugin Compatibility
403
+
404
+ ### oh-my-opencode
405
+
406
+ Works alongside oh-my-opencode. No special configuration needed.
407
+
408
+ ```json
409
+ {
410
+ "plugin": [
411
+ "oc-chatgpt-multi-auth@latest",
412
+ "oh-my-opencode@latest"
413
+ ]
414
+ }
415
+ ```
416
+
417
+ ### @tarquinen/opencode-dcp
418
+
419
+ List this plugin BEFORE DCP:
420
+
421
+ ```json
422
+ {
423
+ "plugin": [
424
+ "oc-chatgpt-multi-auth@latest",
425
+ "@tarquinen/opencode-dcp@latest"
426
+ ]
427
+ }
428
+ ```
429
+
430
+ ### Plugins you don't need
431
+
432
+ - **openai-codex-auth** — Not needed. This plugin replaces the original.
433
+
434
+ ---
435
+
436
+ ## Configuration
437
+
438
+ Create `~/.opencode/openai-codex-auth-config.json` for optional settings:
439
+
440
+ ### Model Behavior
441
+
442
+ | Option | Default | What it does |
443
+ |--------|---------|--------------|
444
+ | `codexMode` | `true` | Uses Codex-OpenCode bridge prompt (synced with latest Codex CLI) |
445
+
446
+ ### Retry Behavior (v4.4.0+)
447
+
448
+ | Option | Default | What it does |
449
+ |--------|---------|--------------|
450
+ | `retryAllAccountsRateLimited` | `true` | Wait and retry when all accounts are rate-limited |
451
+ | `retryAllAccountsMaxWaitMs` | `0` | Max wait time (0 = unlimited) |
452
+ | `retryAllAccountsMaxRetries` | `Infinity` | Max retry attempts |
453
+
454
+ ### Environment Variables
455
+
456
+ ```bash
457
+ DEBUG_CODEX_PLUGIN=1 opencode # Enable debug logging
458
+ ENABLE_PLUGIN_REQUEST_LOGGING=1 opencode # Log all API requests
459
+ CODEX_PLUGIN_LOG_LEVEL=debug opencode # Set log level (debug|info|warn|error)
460
+ CODEX_MODE=0 opencode # Temporarily disable bridge prompt
461
+ ```
462
+
463
+ For all options, see [docs/configuration.md](docs/configuration.md).
464
+
465
+ ---
466
+
467
+ ## Documentation
468
+
469
+ - [Getting Started](docs/getting-started.md) — Complete installation guide
470
+ - [Configuration](docs/configuration.md) — All configuration options
471
+ - [Troubleshooting](docs/troubleshooting.md) — Common issues and fixes
472
+ - [Architecture](docs/development/ARCHITECTURE.md) — How the plugin works
473
+
474
+ ---
475
+
476
+ ## Credits
477
+
478
+ - [numman-ali/opencode-openai-codex-auth](https://github.com/numman-ali/opencode-openai-codex-auth) by [numman-ali](https://github.com/numman-ali) — Original plugin
479
+ - [ndycode](https://github.com/ndycode) — Multi-account support and maintenance
480
+
481
+ ## License
482
+
483
+ MIT License. See [LICENSE](LICENSE) for details.
484
+
485
+ <details>
486
+ <summary><b>Legal</b></summary>
487
+
488
+ ### Intended Use
489
+
490
+ - Personal / internal development only
491
+ - Respect subscription quotas and data handling policies
492
+ - Not for production services or bypassing intended limits
493
+
494
+ ### Warning
495
+
496
+ By using this plugin, you acknowledge:
497
+
498
+ - **Terms of Service risk** — This approach may violate ToS of AI model providers
499
+ - **No guarantees** — APIs may change without notice
500
+ - **Assumption of risk** — You assume all legal, financial, and technical risks
501
+
502
+ ### Disclaimer
503
+
504
+ - Not affiliated with OpenAI. This is an independent open-source project.
505
+ - "ChatGPT", "GPT-5", "Codex", and "OpenAI" are trademarks of OpenAI, L.L.C.
506
+
507
+ </details>
@@ -0,0 +1,18 @@
1
+ <svg width="234" height="42" viewBox="0 0 234 42" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M18 30H6V18H18V30Z" fill="#4B4646"/>
3
+ <path d="M18 12H6V30H18V12ZM24 36H0V6H24V36Z" fill="#B7B1B1"/>
4
+ <path d="M48 30H36V18H48V30Z" fill="#4B4646"/>
5
+ <path d="M36 30H48V12H36V30ZM54 36H36V42H30V6H54V36Z" fill="#B7B1B1"/>
6
+ <path d="M84 24V30H66V24H84Z" fill="#4B4646"/>
7
+ <path d="M84 24H66V30H84V36H60V6H84V24ZM66 18H78V12H66V18Z" fill="#B7B1B1"/>
8
+ <path d="M108 36H96V18H108V36Z" fill="#4B4646"/>
9
+ <path d="M108 12H96V36H90V6H108V12ZM114 36H108V12H114V36Z" fill="#B7B1B1"/>
10
+ <path d="M144 30H126V18H144V30Z" fill="#4B4646"/>
11
+ <path d="M144 12H126V30H144V36H120V6H144V12Z" fill="#F1ECEC"/>
12
+ <path d="M168 30H156V18H168V30Z" fill="#4B4646"/>
13
+ <path d="M168 12H156V30H168V12ZM174 36H150V6H174V36Z" fill="#F1ECEC"/>
14
+ <path d="M198 30H186V18H198V30Z" fill="#4B4646"/>
15
+ <path d="M198 12H186V30H198V12ZM204 36H180V6H198V0H204V36Z" fill="#F1ECEC"/>
16
+ <path d="M234 24V30H216V24H234Z" fill="#4B4646"/>
17
+ <path d="M216 12V18H228V12H216ZM234 24H216V30H234V36H210V6H234V24Z" fill="#F1ECEC"/>
18
+ </svg>
@@ -0,0 +1,31 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1200" height="300" viewBox="0 0 1200 300" role="img" aria-label="OpenCode Codex OAuth">
2
+ <defs>
3
+ <linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
4
+ <stop offset="0%" stop-color="#0f172a" />
5
+ <stop offset="100%" stop-color="#1f2937" />
6
+ </linearGradient>
7
+ <linearGradient id="accent" x1="0" y1="0" x2="1" y2="0">
8
+ <stop offset="0%" stop-color="#38bdf8" />
9
+ <stop offset="100%" stop-color="#22d3ee" />
10
+ </linearGradient>
11
+ </defs>
12
+ <rect width="1200" height="300" rx="28" fill="url(#bg)" />
13
+ <g opacity="0.12">
14
+ <circle cx="1020" cy="70" r="120" fill="#38bdf8" />
15
+ <circle cx="150" cy="260" r="140" fill="#22d3ee" />
16
+ </g>
17
+ <g fill="none" stroke="url(#accent)" stroke-width="8" stroke-linecap="round" stroke-linejoin="round">
18
+ <path d="M160 95 L100 150 L160 205" />
19
+ <path d="M280 95 L340 150 L280 205" />
20
+ <path d="M205 80 L235 220" />
21
+ </g>
22
+ <text x="420" y="120" fill="#e2e8f0" font-size="42" font-family="'IBM Plex Sans','Segoe UI',Arial,sans-serif" font-weight="600">
23
+ OpenCode Codex OAuth
24
+ </text>
25
+ <text x="420" y="170" fill="#cbd5f5" font-size="24" font-family="'IBM Plex Sans','Segoe UI',Arial,sans-serif">
26
+ ChatGPT Plus/Pro auth for GPT-5.2 and Codex models
27
+ </text>
28
+ <text x="420" y="220" fill="#7dd3fc" font-size="18" font-family="'IBM Plex Sans','Segoe UI',Arial,sans-serif">
29
+ One-command install, modern variants, full tool support
30
+ </text>
31
+ </svg>