oc-codex-multi-account 1.0.0 → 1.0.11

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 (2) hide show
  1. package/README.md +45 -265
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,319 +2,99 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/oc-codex-multi-account)](https://www.npmjs.com/package/oc-codex-multi-account)
4
4
 
5
- Multi-account OAuth rotation for OpenAI Codex with sticky threshold switching.
6
-
7
- > **Based on [opencode-openai-codex-auth](https://github.com/numman-ali/opencode-openai-codex-auth) by [@nummanali](https://x.com/nummanali)**. Forked and modified to add multi-account rotation support.
8
-
9
- ## Patched Build (Codex Backend Compatible)
10
-
11
- This fork patches the plugin to talk to **ChatGPT Codex backend** (`chatgpt.com/backend-api`) with the same headers and request shape as the official Codex OAuth plugin.
12
-
13
- **Install from npm (recommended):**
14
-
15
- ```bash
16
- bun add oc-codex-multi-account --cwd ~/.config/opencode
17
- ```
18
-
19
- Then set the plugin entry in `~/.config/opencode/opencode.json`:
20
-
21
- ```json
22
- {
23
- "plugin": ["oc-codex-multi-account@latest"]
24
- }
25
- ```
26
-
27
- If you already installed an older build, re-run the GitHub install command above to override it.
5
+ OpenCode plugin for Codex multi-account routing with sticky primary selection and threshold-based fallback.
28
6
 
29
7
  ## Installation
30
8
 
31
- ### Via npm (Recommended)
9
+ ### 1) Add plugin to OpenCode config
32
10
 
33
- Add to your `~/.config/opencode/opencode.json`:
11
+ Add this to your `~/.config/opencode/opencode.json` (or project-level `opencode.json`):
34
12
 
35
13
  ```json
36
14
  {
37
- "plugin": ["oc-codex-multi-account@latest"]
15
+ "plugin": [
16
+ "oc-codex-multi-account@latest"
17
+ ]
38
18
  }
39
19
  ```
40
20
 
41
- OpenCode will auto-install on first run.
21
+ OpenCode installs the package automatically on startup.
42
22
 
43
- ### Manual Install
23
+ ### 2) (Optional) Install locally for CLI usage
44
24
 
45
- If auto-install fails, install manually:
25
+ If you want to manage accounts via terminal commands:
46
26
 
47
27
  ```bash
48
28
  bun add oc-codex-multi-account --cwd ~/.config/opencode
49
29
  ```
50
30
 
51
- ### From Source
52
-
53
- ```bash
54
- git clone https://github.com/gaboe/oc-codex-multi-account.git
55
- cd oc-codex-multi-account
56
- bun install
57
- bun run build
58
- bun link
59
- ```
60
-
61
- ## Add Your Accounts
62
-
63
- ```bash
64
- # Add each account (opens browser for OAuth)
65
- opencode-multi-auth add personal
66
- opencode-multi-auth add work
67
- opencode-multi-auth add backup
68
-
69
- # Each command opens your browser - log in with a different ChatGPT account each time
70
- ```
71
-
72
- ## Verify Setup
31
+ Then use:
73
32
 
74
33
  ```bash
75
- opencode-multi-auth status
76
- ```
77
-
78
- Output:
79
- ```
80
- [multi-auth] Account Status
81
-
82
- Strategy: round-robin
83
- Accounts: 3
84
- Active: personal
85
-
86
- personal (active)
87
- Email: you@personal.com
88
- Uses: 12
89
- Token expires: 12/25/2025, 3:00:00 PM
90
-
91
- work
92
- Email: you@work.com
93
- Uses: 10
94
- Token expires: 12/25/2025, 3:00:00 PM
95
-
96
- backup
97
- Email: you@backup.com
98
- Uses: 8
99
- Token expires: 12/25/2025, 3:00:00 PM
34
+ ~/.config/opencode/node_modules/.bin/oc-codex-multi-account --help
100
35
  ```
101
36
 
102
- ## Web Dashboard (Local Only)
103
-
104
- Launch the local dashboard:
37
+ If global bin is available in your PATH, you can use:
105
38
 
106
39
  ```bash
107
- opencode-multi-auth web --port 3434 --host 127.0.0.1
40
+ oc-codex-multi-account --help
108
41
  ```
109
42
 
110
- Or from the repo:
43
+ ## Add Accounts
111
44
 
112
45
  ```bash
113
- npm run web
46
+ oc-codex-multi-account add primary
47
+ oc-codex-multi-account add fallback1
48
+ oc-codex-multi-account add fallback2
114
49
  ```
115
50
 
116
- Open `http://127.0.0.1:3434` to manage Codex CLI tokens from `~/.codex/auth.json`:
117
- - Sync current auth.json token into your local list
118
- - See which token is active on the device
119
- - Switch auth.json to a stored token
120
- - Refresh OAuth tokens (per-token or all)
121
- - Refresh 5-hour and weekly limits manually (probe-run per alias)
122
- - Search/filter by alias/email/tags/notes
123
- - Sort by remaining limits, expiry, or alias; recommended token badge
124
- - Tag and annotate tokens (notes)
125
- - Queue-based refresh with progress + stop
126
- - Limit history sparklines and trend rate
127
- - Built-in log view
51
+ The first account is treated as primary. Additional accounts are fallbacks.
128
52
 
129
- The dashboard watches `~/.codex/auth.json` and will add new tokens as you log in via Codex CLI.
53
+ ## How Switching Works
130
54
 
131
- Limit refresh runs `codex exec` in a per-alias sandbox (`~/.codex-multi/<alias>`) so you can
132
- update limits for any stored token without switching the active device token.
55
+ - Primary-first (sticky): requests stay on primary while under thresholds.
56
+ - Fallback on pressure: switches when primary exceeds configured utilization.
57
+ - Recovery checks: while on fallback, periodically checks if primary recovered and switches back.
58
+ - Safety skips: temporarily skips accounts that are rate-limited or have auth/model/workspace issues.
133
59
 
134
- ### Optional Store Encryption
60
+ ## Storage
135
61
 
136
- Set `CODEX_SOFT_STORE_PASSPHRASE` to encrypt `~/.config/opencode-multi-auth/accounts.json` at rest:
62
+ Credentials and runtime state are stored in:
137
63
 
138
- ```bash
139
- export CODEX_SOFT_STORE_PASSPHRASE="your-passphrase"
140
- ```
64
+ - `~/.config/oc-codex-multi-account/accounts.json`
141
65
 
142
- If the store is encrypted and the passphrase is missing, the UI will show a locked status and refuse to overwrite.
66
+ Migration is automatic from legacy path:
143
67
 
144
- ### Systemd Autostart (user service)
68
+ - `~/.config/opencode-multi-auth/accounts.json`
145
69
 
146
- Install and enable the user service:
147
-
148
- ```bash
149
- opencode-multi-auth service install --port 3434 --host 127.0.0.1
150
- ```
151
-
152
- Check status or disable:
70
+ ## CLI Commands
153
71
 
154
72
  ```bash
155
- opencode-multi-auth service status
156
- opencode-multi-auth service disable
157
- ```
158
-
159
- ### Logs
160
-
161
- The dashboard writes logs to `~/.config/opencode-multi-auth/logs/codex-soft.log` by default.
162
- Override with `CODEX_SOFT_LOG_PATH` if you want a custom path.
163
-
164
- ## Configure OpenCode
165
-
166
- Add to your `~/.config/opencode/opencode.json`:
167
-
168
- ```json
169
- {
170
- "plugin": ["oc-codex-multi-account@latest"]
171
- }
172
- ```
173
-
174
- Or with other plugins:
175
-
176
- ```json
177
- {
178
- "plugin": [
179
- "oh-my-opencode",
180
- "oc-codex-multi-account@latest"
181
- ]
182
- }
183
- ```
184
-
185
-
186
- ## Background Notifications (macOS)
187
-
188
-
189
- ### iPhone notifications via ntfy (click to open session)
190
-
191
- If you want push notifications on iOS (with a clickable link to the OpenCode web session), use `ntfy`.
192
-
193
- 1) Install the **ntfy** app on iPhone and subscribe to a topic.
194
-
195
- 2) Set these env vars on the Mac where OpenCode runs:
196
-
197
- - `OPENCODE_MULTI_AUTH_NOTIFY_NTFY_URL`
198
- Example: `https://ntfy.sh/<your-topic>` (or your self-hosted ntfy URL)
199
- - `OPENCODE_MULTI_AUTH_NOTIFY_UI_BASE_URL`
200
- Base URL of your OpenCode web UI reachable from iPhone.
201
- Example (Tailscale): `http://100.x.y.z:4096`
202
- - Optional: `OPENCODE_MULTI_AUTH_NOTIFY_NTFY_TOKEN` (Bearer token)
203
-
204
- The plugin sends notifications for:
205
-
206
- - `session.idle` (finished): priority `3`
207
- - `session.status` with `retry`: priority `4`
208
- - `session.error`: priority `5`
209
-
210
- When possible, the notification body includes `Project` + session `Title`, plus the `sessionID`.
211
- It also attaches a `Click:` URL like `<base>/session/<sessionID>` so tapping the push opens the session.
212
-
213
- This plugin can send a **macOS notification + sound** when a session finishes work.
214
- It listens for OpenCode events (`session.status` and `session.idle`).
215
-
216
- Defaults:
217
- - Enabled by default
218
- - Sound: `/System/Library/Sounds/Glass.aiff`
219
-
220
- Environment variables:
221
- - `OPENCODE_MULTI_AUTH_NOTIFY=0` disables notifications
222
- - `OPENCODE_MULTI_AUTH_NOTIFY_SOUND=/path/to/sound.aiff` overrides the sound
223
- - `OPENCODE_MULTI_AUTH_NOTIFY_MAC_OPEN=0` disables click-to-open on macOS (when available)
224
-
225
- Clickable macOS notifications require `terminal-notifier` (optional). If installed, clicking the banner opens the session URL.
226
-
227
- If OpenCode seems to only make progress when the window is focused, macOS may be throttling it.
228
- Try disabling App Nap for OpenCode.app (Finder -> Get Info -> Prevent App Nap),
229
- or run the server from a terminal under `caffeinate`.
230
-
231
- ## Codex Latest Model Mapping
232
-
233
- OpenCode may not list the newest Codex model yet (it keeps an internal allowlist).
234
- This plugin can still use the newest model by **mapping** the selected Codex model
235
- to the latest backend model on ChatGPT.
236
-
237
- Default behavior:
238
- - If you select `openai/gpt-5.2-codex` (or `openai/gpt-5-codex`), the plugin will send requests as `gpt-5.3-codex`.
239
-
240
- Environment variables:
241
- - `OPENCODE_MULTI_AUTH_PREFER_CODEX_LATEST=0` disables the mapping (use exact model).
242
- - `OPENCODE_MULTI_AUTH_CODEX_LATEST_MODEL=gpt-5.3-codex` overrides the target model.
243
- - `OPENCODE_MULTI_AUTH_DEBUG=1` prints mapping logs like: `model map: gpt-5.2-codex -> gpt-5.3-codex`.
244
-
245
- ## Troubleshooting
246
-
247
- ### BunInstallFailedError (DependencyLoop)
248
-
249
- If OpenCode fails to boot with:
250
-
251
- ```
252
- BunInstallFailedError
253
- { "pkg": "oc-codex-multi-account", "version": "latest" }
73
+ oc-codex-multi-account add <alias> # OAuth login flow
74
+ oc-codex-multi-account remove <alias> # remove account
75
+ oc-codex-multi-account list # list accounts
76
+ oc-codex-multi-account status # detailed status
77
+ oc-codex-multi-account path # print store file path
78
+ oc-codex-multi-account web --port 3434 --host 127.0.0.1
79
+ oc-codex-multi-account service install --port 3434 --host 127.0.0.1
254
80
  ```
255
81
 
256
- It usually means an older `@a3fckx/opencode-multi-auth` dependency is still present.
82
+ ## Release Flow
257
83
 
258
- Fix:
84
+ This repository is configured for tag-based publishing via GitHub Actions.
259
85
 
260
- 1) Remove the old dependency from `~/.config/opencode/package.json`:
261
-
262
- ```json
263
- {
264
- "dependencies": {
265
- "@a3fckx/opencode-multi-auth": "^1.0.4"
266
- }
267
- }
268
- ```
269
-
270
- 2) Reinstall:
86
+ - Create and push a tag like `v1.0.1`
87
+ - Workflow publishes to npm and creates GitHub Release
271
88
 
272
89
  ```bash
273
- bun add oc-codex-multi-account --cwd ~/.config/opencode
274
- ```
275
-
276
- Optional fallback: use a file path plugin entry if installs are blocked:
277
-
278
- ```json
279
- {
280
- "plugin": [
281
- "file:///Users/<you>/.config/opencode/node_modules/oc-codex-multi-account/dist/index.js"
282
- ]
283
- }
90
+ git tag v1.0.1
91
+ git push origin v1.0.1
284
92
  ```
285
93
 
286
- ## How It Works
287
-
288
- | Feature | Behavior |
289
- |---------|----------|
290
- | **Rotation** | Round-robin across all accounts per API call |
291
- | **Rate Limits** | Auto-skips rate-limited account for 5 min, uses next |
292
- | **Token Refresh** | Auto-refreshes tokens before expiry |
293
- | **Models** | Auto-discovers GPT-5.x models from OpenAI API |
294
- | **Storage** | `~/.config/opencode-multi-auth/accounts.json` |
295
-
296
- ## CLI Commands
297
-
298
- | Command | Description |
299
- |---------|-------------|
300
- | `add <alias>` | Add new account via OAuth (opens browser) |
301
- | `remove <alias>` | Remove an account |
302
- | `list` | List all configured accounts |
303
- | `status` | Detailed status with usage counts |
304
- | `path` | Show config file location |
305
- | `web` | Launch local Codex auth.json dashboard |
306
- | `service` | Install/disable systemd user service |
307
- | `help` | Show help message |
308
-
309
- ## Requirements
310
-
311
- - ChatGPT Plus/Pro subscription(s)
312
- - OpenCode CLI
313
-
314
- ## Credits
94
+ ## Repository
315
95
 
316
- - Original OAuth implementation: [numman-ali/opencode-openai-codex-auth](https://github.com/numman-ali/opencode-openai-codex-auth)
317
- - Multi-account rotation: [@a3fckx](https://github.com/a3fckx)
96
+ - GitHub: `https://github.com/gaboe/oc-codex-multi-account`
97
+ - npm: `https://www.npmjs.com/package/oc-codex-multi-account`
318
98
 
319
99
  ## License
320
100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-codex-multi-account",
3
- "version": "1.0.0",
3
+ "version": "1.0.11",
4
4
  "description": "Codex multi-account plugin with sticky threshold switching",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",