Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 7 additions & 45 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,46 +35,25 @@ more deterministic account management.
### Docs
- **Multi-account guide**: clarified repair/quarantine behavior and legacy handling.

## [4.5.24] - 2026-01-31

**UI Polish release**: Final alignment tweaks for `codex-status`.

### Fixed
- **Dashboard Padding**: fine-tuned padding for Plan column and Usage bars to perfectly match the grid alignment.

## [4.5.23] - 2026-01-31

**UI Polish release**: New "Obsidian Dashboard" theme for `codex-status`.

### Changed
- **Visual Overhaul**: `codex-status` now features the "Obsidian Dashboard" theme:
- **High-Density Layout**: Clean, wall-less design with perfect grid alignment.
- **Status Pills**: Color-coded badges (ACTIVE/ENABLED/DISABLED) for instant status recognition.
- **Dynamic Usage Bars**: Quota bars shift color (Blue -> Yellow -> Red) based on consumption.
- **Precision Timers**: Reset timers now include dates for long-term limits (e.g., `resets 09:32 on 3 Feb`).

## [4.5.21] - 2026-01-31

**Parallel Rotation Resilience release**: atomic sync across multiple machine sessions.

### Fixed
- **Unauthorized Recovery**: main request loop now recovers from `401 Unauthorized` by re-syncing with disk and retrying, matching the official Codex CLI's robustness.
- **Ghost Rotations**: `codex-status` tool now persists rotated tokens to disk immediately, preventing drift that previously invalidated other active sessions.
- **Token Overwrite Race**: implemented **Timestamp Arbitration** in storage merges; the most recently active session (`lastUsed`) now always wins, preventing stale sessions from corrupting the authoritative machine state.

### Changed
- **Strict Identity Uniqueness**: all account matching now strictly uses the `accountId + email + plan` composite key to ensure global uniqueness across different workspaces and subscriptions.

## [4.5.20] - 2026-01-31

**Reliability & Identity Hardening release**: codex-status stability, memory safety, and identity-based tracking.
**Reliability & Identity Hardening release**: status tracking stability, memory safety, and identity-based tracking.

### Changed
- **codex-status Read-Only**: tool no longer forces token refresh; uses existing valid tokens and falls back to cached snapshots on failure.
- **Identity-Based Trackers**: `HealthScoreTracker` and `TokenBucketTracker` now key on `accountId|email|plan` instead of array index for stability across account changes.
- **Periodic Cleanup**: both trackers now auto-prune stale entries (24h for health, 1h for tokens) to prevent memory growth.
- **Console Logging**: migrated `console.error` calls to `logWarn` to respect debug settings and avoid TUI corruption.
- **Command Templates**: updated slash commands to output results exactly as returned by tools.

### Added
- **logCritical()**: new always-enabled logger for critical issues that bypass debug flags.
Expand All @@ -84,36 +63,19 @@ more deterministic account management.
### Fixed
- **Memory Leak**: `RateLimitTracker` now cleans up stale entries periodically (every 60s).

## [4.5.19] - 2026-01-31

**Slash Commands release**: register codex tools as TUI slash commands.

### Added
- **Slash Commands**: `/codex-status`, `/codex-switch-accounts`, `/codex-toggle-account` now available via config hook.

## [4.5.18] - 2026-01-31

**Tool Consolidation release**: finalized renaming of status and account management tools to match the `codex-*` namespace.

### Changed
- **Tool Consolidation**: renamed `openai-accounts` and `status-codex` to a single authoritative `codex-status` tool.
- **Account Management**: renamed `openai-accounts-switch` to `codex-switch-accounts` and `openai-accounts-toggle` to `codex-toggle-account`.
- **Lazy Refresh**: tool calls now only refresh tokens if they are within the `tokenRefreshSkewMs` window (default 60s), reducing unnecessary network roundtrips.
- **Code Hardening**: implemented SSE stream memory guards (1MB buffer limit) and removed redundant imports and logic in `index.ts`.

## [4.5.17] - 2026-01-31

**Authoritative Status release**: active fetching from official OpenAI `/wham/usage` endpoints and perfect protocol alignment.

### Added
- **Active Usage Fetching**: tools now actively fetch real-time rate limit data from `https://chatgpt.com/backend-api/wham/usage` (ChatGPT plans) and `https://api.openai.com/api/codex/usage` (API plans).
- **Active Usage Fetching**: status tracking now actively fetches real-time rate limit data from `https://chatgpt.com/backend-api/wham/usage` (ChatGPT plans) and `https://api.openai.com/api/codex/usage` (API plans).
- **Protocol Alignment**: refactored `CodexStatusManager` to match the official `codex-rs v0.92.0` data structures and TUI formatting.
- **Detailed Reset Dates**: long-term resets (>24h) now display the full date and time (e.g., `resets 18:10 on 5 Feb`).

### Changed
- **Inverted Usage Display**: status bars now show **"% left"** instead of "% used", correctly representing remaining quota.
- **Standardized Labels**: updated window labels to "5 hour limit:" and "Weekly limit:".
- **Proactive Tool Hydration**: tool calls now force a token refresh and identity repair to ensure the authoritative `/usage` endpoint receives a valid Bearer token.
- **Proactive Hydration**: status fetches now force a token refresh and identity repair to ensure the authoritative `/usage` endpoint receives a valid Bearer token.
- **Enhanced UI Alignment**: applied strict padding and "Always Render Both" logic to ensure vertical and horizontal table stability even with missing or "unknown" data.

### Fixed
Expand All @@ -137,8 +99,8 @@ more deterministic account management.
**Global Cache path release**: ensure cross-process visibility.

### Fixed
- **Global Snapshot Path**: corrected `getCachePath` to always use the system configuration directory (`~/.config/opencode/cache`), ensuring that rate limit data captured by the proxy is visible to CLI tools regardless of project scope.
- **Table Alignment**: refactored `openai-accounts` and `status-codex` into a strict ASCII table format to prevent horizontal shifting.
- **Global Snapshot Path**: corrected `getCachePath` to always use the system configuration directory (`~/.config/opencode/cache`), ensuring that rate limit data captured by the proxy is visible across project scopes.
- **Table Alignment**: refactored account/status table output into a strict ASCII format to prevent horizontal shifting.

## [4.5.13] - 2026-01-30

Expand All @@ -157,7 +119,7 @@ more deterministic account management.
### Changed
- **Async Status Hardening**: refactored `CodexStatusManager` to use non-blocking async I/O (`fs.promises`) and promise-based initialization gates to prevent concurrency races.
- **Cross-Process Hydration**: ensured status snapshots are stored globally even when using per-project account storage, allowing all projects to share real-time rate limit visibility.
- **Tool UI Refinement**: refactored `openai-accounts` and `status-codex` output into a strictly aligned ASCII table format for better readability.
- **Status UI Refinement**: refactored account/status output into a strictly aligned ASCII table format for better readability.
- **Lost Updates Prevention**: implemented timestamp-based (`updatedAt`) merge arbitration under lock (`proper-lockfile`) to ensure newest state wins across concurrent processes.
- **Security Hardening**: primary accounts and snapshots cache files now use restrictive `0600` permissions.

Expand All @@ -175,7 +137,7 @@ more deterministic account management.
- **Persistent Snapshots**: rate limit data is now persisted to `~/.config/opencode/cache/codex-snapshots.json` for cross-process visibility between the proxy and CLI tools.

### Tests
- **Status Fixtures**: added `codex-status-snapshots.json` and `codex-headers.json` for deterministic testing of rate limit parsing and rendering.
- **Status Fixtures**: added snapshot and header fixtures for deterministic testing of rate limit parsing and rendering.

## [4.5.10] - 2026-01-30

Expand Down
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,6 @@ Personality descriptions come from:
The filename (case-insensitive) defines the key (e.g., `Idiot.md`), and the file contents are used verbatim.

Built-ins: `none`, `default` (uses model runtime defaults), `friendly`, `pragmatic` (fallback if unset). Any other key requires a matching personality file.
---
## ⌨️ Slash Commands (TUI)
In the OpenCode TUI, you can use these commands to manage your accounts and monitor usage:

| Command | Description |
|---------|-------------|
| `/codex-status` | Shows current rate limits (5h/Weekly), credits, and account status (percent left). |
| `/codex-switch-accounts <index>` | Switch the active account by its 1-based index from the status list. |
| `/codex-toggle-account <index>` | Enable or disable an account by its 1-based index (prevents auto-selection). |
| `/codex-remove-account <index>` | Remove an account by its 1-based index. |

---
## ✅ Features
- ChatGPT Plus/Pro OAuth authentication (official flow)
- Model presets across GPT‑5.3 Codex / GPT‑5.2 / GPT‑5.2 Codex / GPT‑5.1 families
Expand All @@ -124,8 +112,8 @@ In the OpenCode TUI, you can use these commands to manage your accounts and moni
- Strict account identity matching (`accountId` + `email` + `plan`)
- Hybrid account selection strategy (health score + token bucket + LRU bias)
- Optional round-robin account rotation (maximum throughput)
- OpenCode TUI toasts + `codex-status` / `codex-switch-accounts` tools
- **Authoritative Codex Status**: Real-time rate limit monitoring (5h/Weekly) with ASCII status bars
- OpenCode TUI toasts for account switching and rate-limit events
- **Authoritative Status Tracking**: Real-time rate limit monitoring (5h/Weekly) with cached snapshots
---
## 🛡️ Safety & Reliability
- Hard-stop safety gate for all-accounts rate-limit/auth-failure loops
Expand Down
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ Bugfix release: toast debounce configuration and legacy account removal.
**Reliability & Data Safety**

- **Toast Spam Fix**: Notifications for rate-limit account switching now respect the 60s debounce timer (`rateLimitToastDebounceMs`) instead of the 2s dedupe window, preventing UI spam during heavy load.
- **Account Removal Safety**: `codex-remove-account` now safely removes accounts even if their tokens were rotated in memory during the same session, preventing "zombie" accounts from persisting in storage.
- **Account Removal Safety**: account removal now safely handles in-memory token rotations during the same session, preventing "zombie" accounts from persisting in storage.

**Full Changelog**: https://github.com/iam-brain/opencode-openai-codex-multi-auth/compare/v4.5.24...v4.5.25
22 changes: 14 additions & 8 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ This directory contains the official opencode configuration files for the OpenAI

**Two configuration files are available based on your OpenCode version:**

| File | OpenCode Version | Description |
|------|------------------|-------------|
| [`opencode-modern.json`](./opencode-modern.json) | **v1.0.210+ (Jan 2026+)** | Compact config using variants system - 6 models with built-in reasoning level variants |
| [`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 |
| File | OpenCode Version | Description |
| ------------------------------------------------ | ------------------------- | ------------------------------------------------------------------------------------------------------- |
| [`opencode-modern.json`](./opencode-modern.json) | **v1.0.210+ (Jan 2026+)** | Compact config using variants system - 6 models with built-in reasoning level variants |
| [`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 |

### Which one should I use?

**If you have OpenCode v1.0.210 or newer** (check with `opencode --version`):

```bash
cp config/opencode-modern.json ~/.config/opencode/opencode.jsonc
```

**If you have OpenCode v1.0.209 or older**:

```bash
cp config/opencode-legacy.json ~/.config/opencode/opencode.jsonc
```
Expand All @@ -29,12 +31,13 @@ OpenCode v1.0.210+ introduced a **variants system** that allows defining reasoni

**What you get:**

| Config File | Model Families | Reasoning Variants | Total Models |
|------------|----------------|-------------------|--------------|
| `opencode-modern.json` | 6 | Built-in variants (low/medium/high/xhigh) | 6 base models with 19 total variants |
| `opencode-legacy.json` | 6 | Separate model entries | 20 individual model definitions |
| Config File | Model Families | Reasoning Variants | Total Models |
| ---------------------- | -------------- | ----------------------------------------- | ------------------------------------ |
| `opencode-modern.json` | 6 | Built-in variants (low/medium/high/xhigh) | 6 base models with 19 total variants |
| `opencode-legacy.json` | 6 | Separate model entries | 20 individual model definitions |

Both configs provide:

- ✅ All supported GPT 5.x variants: gpt-5.3-codex, gpt-5.2, gpt-5.2-codex, gpt-5.1, gpt-5.1-codex, gpt-5.1-codex-max, gpt-5.1-codex-mini
- ✅ Proper reasoning effort settings for each variant (including `xhigh` for Codex Max/5.2)
- ✅ Context limits (272k context / 128k output for all Codex families)
Expand All @@ -52,11 +55,13 @@ Both configs provide:
## Usage

1. **Check your OpenCode version**:

```bash
opencode --version
```

2. **Copy the appropriate config** based on your version:

```bash
# For v1.0.210+ (recommended):
cp config/opencode-modern.json ~/.config/opencode/opencode.jsonc
Expand All @@ -66,6 +71,7 @@ Both configs provide:
```

3. **Run opencode**:

```bash
# Modern config (v1.0.210+):
opencode run "task" --model=openai/gpt-5.3-codex --variant=medium
Expand Down
Loading