opencode-openai-codex-auth-multi 4.3.0-multiaccount.1

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 (90) hide show
  1. package/LICENSE +37 -0
  2. package/README.md +107 -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 +44 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +666 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/lib/accounts.d.ts +48 -0
  14. package/dist/lib/accounts.d.ts.map +1 -0
  15. package/dist/lib/accounts.js +282 -0
  16. package/dist/lib/accounts.js.map +1 -0
  17. package/dist/lib/auth/auth.d.ts +43 -0
  18. package/dist/lib/auth/auth.d.ts.map +1 -0
  19. package/dist/lib/auth/auth.js +163 -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 +76 -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 +78 -0
  28. package/dist/lib/auth/server.js.map +1 -0
  29. package/dist/lib/cli.d.ts +8 -0
  30. package/dist/lib/cli.d.ts.map +1 -0
  31. package/dist/lib/cli.js +44 -0
  32. package/dist/lib/cli.js.map +1 -0
  33. package/dist/lib/config.d.ts +17 -0
  34. package/dist/lib/config.d.ts.map +1 -0
  35. package/dist/lib/config.js +51 -0
  36. package/dist/lib/config.js.map +1 -0
  37. package/dist/lib/constants.d.ts +67 -0
  38. package/dist/lib/constants.d.ts.map +1 -0
  39. package/dist/lib/constants.js +67 -0
  40. package/dist/lib/constants.js.map +1 -0
  41. package/dist/lib/logger.d.ts +26 -0
  42. package/dist/lib/logger.d.ts.map +1 -0
  43. package/dist/lib/logger.js +110 -0
  44. package/dist/lib/logger.js.map +1 -0
  45. package/dist/lib/oauth-success.html +712 -0
  46. package/dist/lib/prompts/codex-opencode-bridge.d.ts +19 -0
  47. package/dist/lib/prompts/codex-opencode-bridge.d.ts.map +1 -0
  48. package/dist/lib/prompts/codex-opencode-bridge.js +152 -0
  49. package/dist/lib/prompts/codex-opencode-bridge.js.map +1 -0
  50. package/dist/lib/prompts/codex.d.ts +27 -0
  51. package/dist/lib/prompts/codex.d.ts.map +1 -0
  52. package/dist/lib/prompts/codex.js +241 -0
  53. package/dist/lib/prompts/codex.js.map +1 -0
  54. package/dist/lib/prompts/opencode-codex.d.ts +21 -0
  55. package/dist/lib/prompts/opencode-codex.d.ts.map +1 -0
  56. package/dist/lib/prompts/opencode-codex.js +91 -0
  57. package/dist/lib/prompts/opencode-codex.js.map +1 -0
  58. package/dist/lib/request/fetch-helpers.d.ts +81 -0
  59. package/dist/lib/request/fetch-helpers.d.ts.map +1 -0
  60. package/dist/lib/request/fetch-helpers.js +321 -0
  61. package/dist/lib/request/fetch-helpers.js.map +1 -0
  62. package/dist/lib/request/helpers/input-utils.d.ts +6 -0
  63. package/dist/lib/request/helpers/input-utils.d.ts.map +1 -0
  64. package/dist/lib/request/helpers/input-utils.js +174 -0
  65. package/dist/lib/request/helpers/input-utils.js.map +1 -0
  66. package/dist/lib/request/helpers/model-map.d.ts +28 -0
  67. package/dist/lib/request/helpers/model-map.d.ts.map +1 -0
  68. package/dist/lib/request/helpers/model-map.js +109 -0
  69. package/dist/lib/request/helpers/model-map.js.map +1 -0
  70. package/dist/lib/request/request-transformer.d.ts +93 -0
  71. package/dist/lib/request/request-transformer.d.ts.map +1 -0
  72. package/dist/lib/request/request-transformer.js +403 -0
  73. package/dist/lib/request/request-transformer.js.map +1 -0
  74. package/dist/lib/request/response-handler.d.ts +14 -0
  75. package/dist/lib/request/response-handler.d.ts.map +1 -0
  76. package/dist/lib/request/response-handler.js +90 -0
  77. package/dist/lib/request/response-handler.js.map +1 -0
  78. package/dist/lib/storage.d.ts +23 -0
  79. package/dist/lib/storage.d.ts.map +1 -0
  80. package/dist/lib/storage.js +153 -0
  81. package/dist/lib/storage.js.map +1 -0
  82. package/dist/lib/types.d.ts +170 -0
  83. package/dist/lib/types.d.ts.map +1 -0
  84. package/dist/lib/types.js +2 -0
  85. package/dist/lib/types.js.map +1 -0
  86. package/package.json +71 -0
  87. package/scripts/copy-oauth-success.js +37 -0
  88. package/scripts/install-opencode-codex-auth.js +193 -0
  89. package/scripts/test-all-models.sh +260 -0
  90. 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,107 @@
1
+ ![Image 1: opencode-openai-codex-auth-multi](assets/readme-hero.svg)
2
+
3
+
4
+ **Forked from [numman-ali/opencode-openai-codex-auth](https://github.com/numman-ali/opencode-openai-codex-auth) (by [Numman Ali](https://x.com/nummanali))**
5
+ **Maintained by [ndycode](https://github.com/ndycode)**
6
+
7
+ [![Twitter Follow](https://img.shields.io/twitter/follow/nummanali?style=social)](https://x.com/nummanali)
8
+ [![npm version](https://img.shields.io/npm/v/opencode-openai-codex-auth-multi.svg)](https://www.npmjs.com/package/opencode-openai-codex-auth-multi)
9
+ [![Tests](https://github.com/ndycode/opencode-openai-codex-auth-multi/actions/workflows/ci.yml/badge.svg)](https://github.com/ndycode/opencode-openai-codex-auth-multi/actions)
10
+ [![npm downloads](https://img.shields.io/npm/dm/opencode-openai-codex-auth-multi.svg)](https://www.npmjs.com/package/opencode-openai-codex-auth-multi)
11
+ **One install. Every Codex model.**
12
+ [Install](#-quick-start) · [Models](#-models) · [Configuration](#-configuration) · [Docs](#-docs)
13
+
14
+ ---
15
+ ## 💡 Philosophy
16
+ > **"One config. Every model."**
17
+ OpenCode should feel effortless. This plugin keeps the setup minimal while giving you full GPT‑5.x + Codex access via ChatGPT OAuth.
18
+ ```
19
+ ┌─────────────────────────────────────────────────────────┐
20
+ │ │
21
+ │ ChatGPT OAuth → Codex backend → OpenCode │
22
+ │ One command install, full model presets, done. │
23
+ │ │
24
+ └─────────────────────────────────────────────────────────┘
25
+ ```
26
+ ---
27
+ ## 🚀 Quick Start
28
+
29
+ ### Install from npm (recommended)
30
+
31
+ ```bash
32
+ npx -y opencode-openai-codex-auth-multi@latest
33
+ ```
34
+
35
+ Legacy OpenCode (v1.0.209 and below):
36
+
37
+ ```bash
38
+ npx -y opencode-openai-codex-auth-multi@latest --legacy
39
+ ```
40
+
41
+ Then:
42
+
43
+ ```bash
44
+ # Modern OpenCode (v1.0.210+)
45
+ opencode auth login
46
+ opencode run "write hello world to test.txt" --model=openai/gpt-5.2 --variant=medium
47
+
48
+ # Legacy OpenCode (v1.0.209 and below)
49
+ opencode run "write hello world to test.txt" --model=openai/gpt-5.2-medium
50
+ ```
51
+
52
+ ### Install from source (optional)
53
+
54
+ ```bash
55
+ git clone https://github.com/ndycode/opencode-openai-codex-auth-multi.git
56
+ cd opencode-openai-codex-auth-multi
57
+ npm ci
58
+ npm run build
59
+ ```
60
+
61
+ Point OpenCode at the local build output (replace with your absolute path):
62
+
63
+ ```json
64
+ {
65
+ "plugin": ["file:///absolute/path/to/opencode-openai-codex-auth-multi/dist"]
66
+ }
67
+ ```
68
+
69
+ ---
70
+ ## 📦 Models
71
+ - **gpt-5.2** (none/low/medium/high/xhigh)
72
+ - **gpt-5.2-codex** (low/medium/high/xhigh)
73
+ - **gpt-5.1-codex-max** (low/medium/high/xhigh)
74
+ - **gpt-5.1-codex** (low/medium/high)
75
+ - **gpt-5.1-codex-mini** (medium/high)
76
+ - **gpt-5.1** (none/low/medium/high)
77
+ ---
78
+ ## 🧩 Configuration
79
+ - Modern (OpenCode v1.0.210+): `config/opencode-modern.json`
80
+ - Legacy (OpenCode v1.0.209 and below): `config/opencode-legacy.json`
81
+
82
+ Minimal configs are not recommended for GPT–5.x/Codex; use the full configs above. For advanced/debug use only, see `config/minimal-opencode.json`.
83
+ ---
84
+ ## Multi-account
85
+ - Add multiple accounts by running `opencode auth login` and choosing add more accounts.
86
+ - Auto-rotation kicks in on rate limits.
87
+ - Manage accounts with `openai-accounts`, `openai-accounts-switch`, and `openai-accounts-status`.
88
+ - Storage: `~/.opencode/openai-codex-accounts.json`
89
+ ---
90
+ ## ✅ Features
91
+ - ChatGPT Plus/Pro OAuth authentication (official flow)
92
+ - 22 model presets across GPT–5.2 / GPT–5.2 Codex / GPT–5.1 families
93
+ - Variant system support (v1.0.210+) + legacy presets
94
+ - Multimodal input enabled for all models
95
+ - Usage–aware errors + automatic token refresh
96
+ ---
97
+ ## 📚 Docs
98
+ - Getting Started: `docs/getting-started.md`
99
+ - Configuration: `docs/configuration.md`
100
+ - Troubleshooting: `docs/troubleshooting.md`
101
+ - Architecture: `docs/development/ARCHITECTURE.md`
102
+ ---
103
+ ## ⚠️ Usage Notice
104
+ This plugin is for **personal development use** with your own ChatGPT Plus/Pro subscription.
105
+ For production or multi‑user applications, use the OpenAI Platform API.
106
+
107
+ **Built for developers who value simplicity.**
@@ -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>
@@ -0,0 +1,110 @@
1
+ # Configuration
2
+
3
+ This directory contains the official opencode configuration files for the OpenAI Codex OAuth plugin.
4
+
5
+ ## ⚠️ REQUIRED: Choose the Right Configuration
6
+
7
+ **Two configuration files are available based on your OpenCode version:**
8
+
9
+ | File | OpenCode Version | Description |
10
+ |------|------------------|-------------|
11
+ | [`opencode-modern.json`](./opencode-modern.json) | **v1.0.210+ (Jan 2026+)** | Compact config using variants system - 6 models with built-in reasoning level variants |
12
+ | [`opencode-legacy.json`](./opencode-legacy.json) | **v1.0.209 and below** | Extended config with separate model entries for each reasoning level - 20+ individual model definitions |
13
+
14
+ ### Which one should I use?
15
+
16
+ **If you have OpenCode v1.0.210 or newer** (check with `opencode --version`):
17
+ ```bash
18
+ cp config/opencode-modern.json ~/.config/opencode/opencode.json
19
+ ```
20
+
21
+ **If you have OpenCode v1.0.209 or older**:
22
+ ```bash
23
+ cp config/opencode-legacy.json ~/.config/opencode/opencode.json
24
+ ```
25
+
26
+ ### Why two configs?
27
+
28
+ OpenCode v1.0.210+ introduced a **variants system** that allows defining reasoning effort levels as variants under a single model. This reduces config size from 572 lines to ~150 lines while maintaining the same functionality.
29
+
30
+ **What you get:**
31
+
32
+ | Config File | Model Families | Reasoning Variants | Total Models |
33
+ |------------|----------------|-------------------|--------------|
34
+ | `opencode-modern.json` | 6 | Built-in variants (low/medium/high/xhigh) | 6 base models with 19 total variants |
35
+ | `opencode-legacy.json` | 6 | Separate model entries | 20 individual model definitions |
36
+
37
+ Both configs provide:
38
+ - ✅ All supported GPT 5.2/5.1 variants: gpt-5.2, gpt-5.2-codex, gpt-5.1, gpt-5.1-codex, gpt-5.1-codex-max, gpt-5.1-codex-mini
39
+ - ✅ Proper reasoning effort settings for each variant (including `xhigh` for Codex Max/5.2)
40
+ - ✅ Context limits (272k context / 128k output for all Codex families)
41
+ - ✅ Required options: `store: false`, `include: ["reasoning.encrypted_content"]`
42
+ - ✅ Image input support for all models
43
+ - ✅ All required metadata for OpenCode features
44
+
45
+ ### Modern Config Benefits (v1.0.210+)
46
+
47
+ - **74% smaller**: 150 lines vs 572 lines
48
+ - **DRY**: Common options defined once at provider level
49
+ - **Variant cycling**: Built-in support for `Ctrl+T` to switch reasoning levels
50
+ - **Easier maintenance**: Add new variants without copying model definitions
51
+
52
+ ## Usage
53
+
54
+ 1. **Check your OpenCode version**:
55
+ ```bash
56
+ opencode --version
57
+ ```
58
+
59
+ 2. **Copy the appropriate config** based on your version:
60
+ ```bash
61
+ # For v1.0.210+ (recommended):
62
+ cp config/opencode-modern.json ~/.config/opencode/opencode.json
63
+
64
+ # For older versions:
65
+ cp config/opencode-legacy.json ~/.config/opencode/opencode.json
66
+ ```
67
+
68
+ 3. **Run opencode**:
69
+ ```bash
70
+ # Modern config (v1.0.210+):
71
+ opencode run "task" --model=openai/gpt-5.2 --variant=medium
72
+ opencode run "task" --model=openai/gpt-5.2 --variant=high
73
+
74
+ # Legacy config:
75
+ opencode run "task" --model=openai/gpt-5.2-medium
76
+ opencode run "task" --model=openai/gpt-5.2-high
77
+ ```
78
+
79
+ > **⚠️ Important**: Use the config file appropriate for your OpenCode version. Using the modern config with an older OpenCode version (v1.0.209 or below) will not work correctly.
80
+
81
+ > **Note**: The config templates use an **unversioned** plugin entry (`opencode-openai-codex-auth-multi`) so the installer can always pull the latest release. If you need reproducibility, pin a specific version manually.
82
+
83
+ ### Minimal config (advanced)
84
+
85
+ A barebones example is available at [`minimal-opencode.json`](./minimal-opencode.json). It’s intended for debugging and does not include the full GPT‑5.x/Codex preset/variant definitions.
86
+
87
+ For normal usage, prefer `opencode-modern.json` (v1.0.210+) or `opencode-legacy.json` (v1.0.209 and below).
88
+
89
+ ## Available Models
90
+
91
+
92
+ Both configs provide access to the same model families:
93
+
94
+ - **gpt-5.2** (none/low/medium/high/xhigh) - Latest GPT 5.2 model with full reasoning support
95
+ - **gpt-5.2-codex** (low/medium/high/xhigh) - GPT 5.2 Codex presets
96
+ - **gpt-5.1-codex-max** (low/medium/high/xhigh) - Codex Max presets
97
+ - **gpt-5.1-codex** (low/medium/high) - Codex model presets
98
+ - **gpt-5.1-codex-mini** (medium/high) - Codex mini tier presets
99
+ - **gpt-5.1** (none/low/medium/high) - General-purpose reasoning presets
100
+
101
+ All appear in the opencode model selector as "GPT 5.1 Codex Low (OAuth)", "GPT 5.1 High (OAuth)", etc.
102
+
103
+ ## Configuration Options
104
+
105
+ See the main [README.md](../README.md#configuration) for detailed documentation of all configuration options.
106
+
107
+ ## Version History
108
+
109
+ - **January 2026 (v1.0.210+)**: Introduced variant system support. Use `opencode-modern.json`
110
+ - **December 2025 and earlier**: Use `opencode-legacy.json`
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "https://opencode.ai/config.json",
3
+ "plugin": ["opencode-openai-codex-auth-multi"],
4
+
5
+ "provider": {
6
+ "openai": {
7
+ "options": {
8
+ "store": false
9
+ }
10
+ }
11
+ },
12
+ "model": "openai/gpt-5-codex"
13
+ }