Multi-Workspace Support, Auto-Switching, and Usage API Integration#6
Merged
Multi-Workspace Support, Auto-Switching, and Usage API Integration#6
Conversation
@loongphy/codex-auth-darwin-arm64
@loongphy/codex-auth-darwin-x64
@loongphy/codex-auth-linux-x64
@loongphy/codex-auth-win32-x64
@loongphy/codex-auth
commit: |
Tests:\n- zig test src/main.zig -lc\n- zig build run -- list\n- zig build -Dtarget=x86_64-windows-gnu -Doptimize=ReleaseSafe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces significant architectural improvements to codex-auth, moving from email-keyed storage to account_id identity. It also adds a background auto-switch daemon and an API-based usage refresh mode to address reliability issues with local session files.
🚀 Key Features
Added support for fetching ChatGPT usage directly via the /backend-api/wham/usage endpoint.
(rate_limits is always null in rollout session files openai/codex#14880)
A background daemon that monitors usage and automatically switches to the best available account when thresholds are met.
If the embedded codex login process fails to start, the tool now provides clear, actionable instructions for manual recovery.
🛠 New & Updated Commands
📦 Registry Migration (Technical Note)
📦 PR Preview Packages
.github/workflows/preview-release.ymlso each pull request publishes installable preview packages throughpkg.pr.new.--version, for example:codex-auth 0.1.5 (preview pr-6 b6bfcf5).npx https://pkg.pr.new/@loongphy/codex-auth@6 --version.🔗 Related Issues
✅ Verification & Testing
Functional Test: zig build run -- list (Verified registry migration and grouped display).
Unit/BDD Tests: zig test src/main.zig -lc (Covered 5h/weekly scoring, migration logic, and API parsing).
Cross-Platform: Verified service installation on Linux (systemd) and Windows (task scheduler).
PR Preview Publish: Verified the
Preview Releaseworkflow can publishpkg.pr.newpackages for PR Multi-Workspace Support, Auto-Switching, and Usage API Integration #6 and that preview installs expose the preview identifier incodex-auth --version.Note
Add multi-workspace support, auto-switching daemon, and usage API integration to codex-auth
account_key(derived fromchatgpt_user_id::chatgpt_account_id) as the primary account identity across the registry, CLI, and file paths, replacing email-based keying throughout.src/auto.zig) with cross-platform file locking, configurable usage thresholds, andstatus/config auto/config apiCLI commands.src/usage_api.zig) that fetches liveRateLimitSnapshotdata from the ChatGPT usage endpoint for the active ChatGPT account.account_key-keyed) with automatic on-load migration, atomic writes, and a newimport --purgemode that rebuilds the registry from existing snapshots.codex-auth-auto.exehelper binary (src/windows_auto_main.zig) built and packaged alongside the main binary.src/display_rows.zig, with non-selectable header rows and stable numbered selection.import --purgeto recover.Macroscope summarized b0c95f3.