oc-chatgpt-multi-auth 5.3.2 → 5.3.4

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 (40) hide show
  1. package/README.md +198 -85
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1623 -50
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/accounts.d.ts +16 -0
  6. package/dist/lib/accounts.d.ts.map +1 -1
  7. package/dist/lib/accounts.js +60 -0
  8. package/dist/lib/accounts.js.map +1 -1
  9. package/dist/lib/config.d.ts +4 -0
  10. package/dist/lib/config.d.ts.map +1 -1
  11. package/dist/lib/config.js +36 -0
  12. package/dist/lib/config.js.map +1 -1
  13. package/dist/lib/refresh-queue.d.ts +16 -0
  14. package/dist/lib/refresh-queue.d.ts.map +1 -1
  15. package/dist/lib/refresh-queue.js +46 -0
  16. package/dist/lib/refresh-queue.js.map +1 -1
  17. package/dist/lib/request/retry-budget.d.ts +19 -0
  18. package/dist/lib/request/retry-budget.d.ts.map +1 -0
  19. package/dist/lib/request/retry-budget.js +99 -0
  20. package/dist/lib/request/retry-budget.js.map +1 -0
  21. package/dist/lib/schemas.d.ts +26 -0
  22. package/dist/lib/schemas.d.ts.map +1 -1
  23. package/dist/lib/schemas.js +28 -0
  24. package/dist/lib/schemas.js.map +1 -1
  25. package/dist/lib/storage/migrations.d.ts +4 -0
  26. package/dist/lib/storage/migrations.d.ts.map +1 -1
  27. package/dist/lib/storage/migrations.js +2 -0
  28. package/dist/lib/storage/migrations.js.map +1 -1
  29. package/dist/lib/storage.d.ts +31 -5
  30. package/dist/lib/storage.d.ts.map +1 -1
  31. package/dist/lib/storage.js +354 -71
  32. package/dist/lib/storage.js.map +1 -1
  33. package/dist/lib/ui/auth-menu.d.ts.map +1 -1
  34. package/dist/lib/ui/auth-menu.js +23 -5
  35. package/dist/lib/ui/auth-menu.js.map +1 -1
  36. package/dist/lib/ui/beginner.d.ts +57 -0
  37. package/dist/lib/ui/beginner.d.ts.map +1 -0
  38. package/dist/lib/ui/beginner.js +230 -0
  39. package/dist/lib/ui/beginner.js.map +1 -0
  40. package/package.json +1 -1
package/README.md CHANGED
@@ -15,6 +15,10 @@ OAuth plugin for OpenCode that lets you use ChatGPT Plus/Pro rate limits with mo
15
15
  - **Per-project accounts** — Each project gets its own account storage (new in v4.10.0)
16
16
  - **Workspace-aware identity persistence** — Keeps workspace/org identity stable across token refresh and verify-flagged restore flows
17
17
  - **Click-to-switch** — Switch accounts directly from the OpenCode TUI
18
+ - **Beginner command toolkit** — Guided onboarding with `codex-help`, `codex-setup`, `codex-doctor`, and `codex-next`
19
+ - **Account metadata controls** — Per-account labels, tags, and notes with quick filtering
20
+ - **Safer backup/import flow** — Timestamped exports, import dry-run preview, and conditional pre-import backups when existing accounts are present
21
+ - **Startup preflight summary** — One-line health/readiness summary at plugin startup with suggested next step
18
22
  - **Strict tool validation** — Automatically cleans schemas for compatibility with strict models
19
23
  - **Auto-update notifications** — Get notified when a new version is available
20
24
  - **21 template model presets** — Full variant system with reasoning levels (none/low/medium/high/xhigh)
@@ -278,177 +282,253 @@ The plugin provides built-in tools for managing your OpenAI accounts. These are
278
282
 
279
283
  ### codex-list
280
284
 
281
- List all configured accounts with their status.
285
+ List all configured accounts with status badges.
282
286
 
283
- ```
287
+ ```text
284
288
  codex-list
285
289
  ```
286
290
 
287
- **Output:**
288
- ```
289
- OpenAI Accounts (3 total):
290
-
291
- [1] user@gmail.com (active)
292
- [2] work@company.com
293
- [3] backup@email.com
291
+ Filter by tag:
294
292
 
295
- Use codex-switch to change active account.
293
+ ```text
294
+ codex-list tag="work"
296
295
  ```
297
296
 
297
+ Shows account labels, IDs, tags, active state, and rate-limit/cooldown markers.
298
+
298
299
  ---
299
300
 
300
301
  ### codex-switch
301
302
 
302
- Switch to a different account by index (1-based).
303
+ Switch to a different account. If `index` is omitted and your terminal supports menus, an interactive picker opens.
303
304
 
304
- ```
305
+ ```text
305
306
  codex-switch index=2
306
307
  ```
307
308
 
308
- **Output:**
309
- ```
310
- Switched to account [2] work@company.com
309
+ or:
310
+
311
+ ```text
312
+ codex-switch
311
313
  ```
312
314
 
313
315
  ---
314
316
 
315
- ### codex-status
317
+ ### codex-label
316
318
 
317
- Show detailed status including rate limits and health scores.
319
+ Set or clear a display label for an account. Useful for workspace naming.
318
320
 
321
+ ```text
322
+ codex-label index=2 label="Work"
319
323
  ```
320
- codex-status
324
+
325
+ Clear:
326
+
327
+ ```text
328
+ codex-label index=2 label=""
321
329
  ```
322
330
 
323
- **Output:**
331
+ If `index` is omitted in interactive terminals, a picker opens.
332
+
333
+ ---
334
+
335
+ ### codex-tag
336
+
337
+ Set or clear comma-separated tags for filtering and grouping.
338
+
339
+ ```text
340
+ codex-tag index=2 tags="work,team-a"
324
341
  ```
325
- OpenAI Account Status:
326
342
 
327
- [1] user@gmail.com (active)
328
- Health: 100/100
329
- Rate Limit: 45/50 requests remaining
330
- Resets: 2m 30s
331
- Last Used: 5 minutes ago
343
+ Clear:
332
344
 
333
- [2] work@company.com
334
- Health: 85/100
335
- Rate Limit: 12/50 requests remaining
336
- Resets: 8m 15s
337
- Last Used: 1 hour ago
345
+ ```text
346
+ codex-tag index=2 tags=""
338
347
  ```
339
348
 
349
+ Use tags with `codex-list tag="work"`.
350
+
340
351
  ---
341
352
 
342
- ### codex-metrics
353
+ ### codex-note
343
354
 
344
- Show live runtime metrics (request counts, latency, errors, rotations) for the current plugin process.
355
+ Set or clear a short per-account note for reminders.
345
356
 
346
- ```
347
- codex-metrics
357
+ ```text
358
+ codex-note index=2 note="primary for weekday daytime usage"
348
359
  ```
349
360
 
350
- **Output:**
361
+ Clear:
362
+
363
+ ```text
364
+ codex-note index=2 note=""
351
365
  ```
352
- Codex Plugin Metrics:
353
366
 
354
- Uptime: 12m
355
- Total upstream requests: 84
356
- Successful responses: 77
357
- Failed responses: 7
358
- Average successful latency: 842ms
367
+ ---
368
+
369
+ ### codex-help
370
+
371
+ Show beginner-friendly command guidance. Optional topic filter:
372
+
373
+ ```text
374
+ codex-help
375
+ codex-help topic="backup"
359
376
  ```
360
377
 
378
+ Available topics: `setup`, `switch`, `health`, `backup`, `dashboard`, `metrics`.
379
+
361
380
  ---
362
381
 
363
- ### codex-health
382
+ ### codex-setup
364
383
 
365
- Check if all account tokens are still valid (read-only check).
384
+ Show readiness checklist for first-run onboarding and account health.
366
385
 
386
+ ```text
387
+ codex-setup
367
388
  ```
368
- codex-health
389
+
390
+ Open guided wizard (menu-driven when terminal supports it, checklist fallback otherwise):
391
+
392
+ ```text
393
+ codex-setup wizard=true
369
394
  ```
370
395
 
371
- **Output:**
396
+ ---
397
+
398
+ ### codex-doctor
399
+
400
+ Run diagnostics with actionable findings.
401
+
402
+ ```text
403
+ codex-doctor
404
+ codex-doctor deep=true
372
405
  ```
373
- Checking 3 account(s):
374
406
 
375
- [1] user@gmail.com: Healthy
376
- [2] work@company.com: Healthy
377
- [3] old@expired.com: Token expired
407
+ Apply safe auto-fixes (`--fix` equivalent):
408
+ - Refreshes tokens where possible
409
+ - Persists refreshed credentials
410
+ - Switches active account to the healthiest eligible account
378
411
 
379
- Summary: 2 healthy, 1 unhealthy
412
+ ```text
413
+ codex-doctor fix=true
380
414
  ```
381
415
 
382
416
  ---
383
417
 
384
- ### codex-refresh
418
+ ### codex-next
385
419
 
386
- Refresh all OAuth tokens and save them to disk. Use this after long idle periods.
420
+ Show the single most recommended next action based on current account/runtime state.
387
421
 
422
+ ```text
423
+ codex-next
388
424
  ```
389
- codex-refresh
425
+
426
+ ---
427
+
428
+ ### codex-status
429
+
430
+ Show detailed status including rate limits and health scores.
431
+
432
+ ```text
433
+ codex-status
390
434
  ```
391
435
 
392
- **Output:**
436
+ ---
437
+
438
+ ### codex-metrics
439
+
440
+ Show live runtime metrics (request counts, latency, errors, retries, and safe mode).
441
+
442
+ ```text
443
+ codex-metrics
444
+ ```
445
+
446
+ ---
447
+
448
+ ### codex-health
449
+
450
+ Check if all account tokens are still valid (read-only check).
451
+
452
+ ```text
453
+ codex-health
393
454
  ```
394
- Refreshing 3 account(s):
395
455
 
396
- ✓ [1] user@gmail.com: Refreshed
397
- ✓ [2] work@company.com: Refreshed
398
- [3] old@expired.com: Failed - Token expired
456
+ ---
457
+
458
+ ### codex-refresh
459
+
460
+ Refresh all OAuth tokens and save them to disk. Use this after long idle periods.
399
461
 
400
- Summary: 2 refreshed, 1 failed
462
+ ```text
463
+ codex-refresh
401
464
  ```
402
465
 
403
- **Difference from health check:** `codex-health` only validates tokens. `codex-refresh` actually refreshes them and saves new tokens to disk.
466
+ `codex-health` validates. `codex-refresh` validates + refreshes + persists.
404
467
 
405
468
  ---
406
469
 
407
470
  ### codex-remove
408
471
 
409
- Remove an account by index. Useful for cleaning up expired accounts.
472
+ Remove an account entry. If `index` is omitted and your terminal supports menus, an interactive picker opens.
410
473
 
411
- ```
474
+ ```text
412
475
  codex-remove index=3
413
476
  ```
414
477
 
415
- **Output:**
416
- ```
417
- Removed: [3] old@expired.com
478
+ or:
418
479
 
419
- Remaining accounts: 2
480
+ ```text
481
+ codex-remove
420
482
  ```
421
483
 
422
484
  ---
423
485
 
424
486
  ### codex-export
425
487
 
426
- Export all accounts to a portable JSON file. Useful for backup or migration.
488
+ Export accounts to JSON for backup/migration.
427
489
 
428
- ```
490
+ Explicit path:
491
+
492
+ ```text
429
493
  codex-export path="~/backup/accounts.json"
430
494
  ```
431
495
 
432
- **Output:**
433
- ```
434
- Exported 3 account(s) to ~/backup/accounts.json
496
+ Auto timestamped backup path (default behavior when `path` is omitted):
497
+
498
+ ```text
499
+ codex-export
435
500
  ```
436
501
 
502
+ Generated paths are stored in a `backups/` subdirectory near the active account storage file.
503
+
437
504
  ---
438
505
 
439
506
  ### codex-import
440
507
 
441
- Import accounts from a JSON file (exported via `codex-export`). Merges with existing accounts.
508
+ Import accounts from a JSON file (dedupe-aware merge).
509
+
510
+ Dry-run preview (no writes):
442
511
 
512
+ ```text
513
+ codex-import path="~/backup/accounts.json" dryRun=true
443
514
  ```
515
+
516
+ Apply import:
517
+
518
+ ```text
444
519
  codex-import path="~/backup/accounts.json"
445
520
  ```
446
521
 
447
- **Output:**
448
- ```
449
- Imported 2 new account(s) (1 duplicate skipped)
522
+ Before apply, the plugin creates an automatic timestamped pre-import backup when existing accounts are present. If backup creation fails, import apply is aborted.
523
+
524
+ ---
450
525
 
451
- Total accounts: 4
526
+ ### codex-dashboard
527
+
528
+ Show live account eligibility, retry budget usage, refresh queue metrics, and the recommended next step.
529
+
530
+ ```text
531
+ codex-dashboard
452
532
  ```
453
533
 
454
534
  ---
@@ -457,18 +537,38 @@ Total accounts: 4
457
537
 
458
538
  | Tool | What It Does | Example |
459
539
  |------|--------------|---------|
460
- | `codex-list` | List all accounts | "list my accounts" |
461
- | `codex-switch` | Switch active account | "switch to account 2" |
462
- | `codex-status` | Show rate limits & health | "show account status" |
463
- | `codex-metrics` | Show runtime metrics | "show plugin metrics" |
464
- | `codex-health` | Validate tokens (read-only) | "check account health" |
465
- | `codex-refresh` | Refresh & save tokens | "refresh my tokens" |
466
- | `codex-remove` | Remove an account | "remove account 3" |
467
- | `codex-export` | Export accounts to file | "export my accounts" |
468
- | `codex-import` | Import accounts from file | "import accounts from backup" |
540
+ | `codex-help` | Command guide by topic | `codex-help topic="setup"` |
541
+ | `codex-setup` | Readiness checklist/wizard | `codex-setup wizard=true` |
542
+ | `codex-next` | Best next action | `codex-next` |
543
+ | `codex-doctor` | Diagnostics and optional safe fixes | `codex-doctor fix=true` |
544
+ | `codex-list` | List/filter accounts | `codex-list tag="work"` |
545
+ | `codex-switch` | Switch active account | `codex-switch index=2` |
546
+ | `codex-label` | Set/clear display label | `codex-label index=2 label="Work"` |
547
+ | `codex-tag` | Set/clear tag list | `codex-tag index=2 tags="work,team-a"` |
548
+ | `codex-note` | Set/clear account note | `codex-note index=2 note="night backup"` |
549
+ | `codex-status` | Per-account health/rate limit detail | `codex-status` |
550
+ | `codex-dashboard` | Live selection and retry view | `codex-dashboard` |
551
+ | `codex-metrics` | Runtime metrics summary | `codex-metrics` |
552
+ | `codex-health` | Validate token health (read-only) | `codex-health` |
553
+ | `codex-refresh` | Refresh and persist tokens | `codex-refresh` |
554
+ | `codex-remove` | Remove account entry | `codex-remove index=3` |
555
+ | `codex-export` | Export account backups | `codex-export` |
556
+ | `codex-import` | Dry-run or apply imports | `codex-import path="~/backup/accounts.json" dryRun=true` |
469
557
 
470
558
  ---
471
559
 
560
+ ### Sample Output (codex-list)
561
+
562
+ ```text
563
+ Codex Accounts (3):
564
+
565
+ [1] Account 1 (user@gmail.com, workspace:Work, tags:work,team-a) active
566
+ [2] Account 2 (backup@email.com, tags:backup) ok
567
+ [3] Account 3 (personal@email.com) rate-limited
568
+
569
+ Storage: ~/.opencode/openai-codex-accounts.json
570
+ ```
571
+
472
572
  ## Rotation Behavior
473
573
 
474
574
  **How rotation works:**
@@ -724,11 +824,14 @@ Create `~/.opencode/openai-codex-auth-config.json` for optional settings:
724
824
  |--------|---------|--------------|
725
825
  | `perProjectAccounts` | `true` | Each project gets its own account storage namespace under `~/.opencode/projects/` |
726
826
  | `toastDurationMs` | `5000` | How long toast notifications stay visible (ms) |
827
+ | `beginnerSafeMode` | `false` | Beginner-safe retry profile: conservative retry budget, disables all-accounts wait/retry, and caps all-accounts retries |
727
828
 
728
829
  ### Retry Behavior
729
830
 
730
831
  | Option | Default | What It Does |
731
832
  |--------|---------|--------------|
833
+ | `retryProfile` | `balanced` | Global retry budget profile (`conservative`, `balanced`, `aggressive`) |
834
+ | `retryBudgetOverrides` | `{}` | Per-class retry budget overrides (`authRefresh`, `network`, `server`, `rateLimitShort`, `rateLimitGlobal`, `emptyResponse`) |
732
835
  | `retryAllAccountsRateLimited` | `true` | Wait and retry when all accounts are rate-limited |
733
836
  | `retryAllAccountsMaxWaitMs` | `0` | Max wait time (0 = unlimited) |
734
837
  | `retryAllAccountsMaxRetries` | `Infinity` | Max retry attempts |
@@ -745,6 +848,11 @@ Default unsupported-model fallback chain (used when `unsupportedCodexPolicy` is
745
848
  - `gpt-5.2-codex -> gpt-5-codex`
746
849
  - `gpt-5.1-codex -> gpt-5-codex`
747
850
 
851
+ When `beginnerSafeMode` is enabled, runtime behavior is intentionally conservative:
852
+ - Retry profile is forced to `conservative`
853
+ - `retryAllAccountsRateLimited` is forced `false`
854
+ - `retryAllAccountsMaxRetries` is capped to `1`
855
+
748
856
  ### Environment Variables
749
857
 
750
858
  ```bash
@@ -761,6 +869,11 @@ CODEX_AUTH_PREWARM=0 opencode # Disable startup prewarm (prom
761
869
  CODEX_AUTH_FAST_SESSION=1 opencode # Enable faster response defaults
762
870
  CODEX_AUTH_FAST_SESSION_STRATEGY=always opencode # Force fast mode for all prompts
763
871
  CODEX_AUTH_FAST_SESSION_MAX_INPUT_ITEMS=24 opencode # Tune fast-mode history window
872
+ CODEX_AUTH_BEGINNER_SAFE_MODE=1 opencode # Enable beginner-safe runtime profile
873
+ CODEX_AUTH_RETRY_PROFILE=aggressive opencode # Override retry profile (ignored when beginner safe mode is on)
874
+ CODEX_AUTH_RETRY_ALL_RATE_LIMITED=0 opencode # Disable all-accounts wait-and-retry
875
+ CODEX_AUTH_RETRY_ALL_MAX_WAIT_MS=30000 opencode # Cap all-accounts wait duration
876
+ CODEX_AUTH_RETRY_ALL_MAX_RETRIES=1 opencode # Cap all-accounts retry attempts
764
877
  CODEX_AUTH_UNSUPPORTED_MODEL_POLICY=fallback opencode # Enable generic unsupported-model fallback
765
878
  CODEX_AUTH_FALLBACK_UNSUPPORTED_MODEL=1 opencode # Legacy fallback toggle (prefer policy var above)
766
879
  CODEX_AUTH_FALLBACK_GPT53_TO_GPT52=0 opencode # Disable only the legacy gpt-5.3 -> gpt-5.2 edge
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AA0I/D;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,iBAAiB,EAAE,MAosG/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAoB,CAAC;AAElD,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AA+J/D;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,iBAAiB,EAAE,MA8kK/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAoB,CAAC;AAElD,eAAe,iBAAiB,CAAC"}