Skip to content

Commit 2a8ab3a

Browse files
committed
Add online quota mode and release v0.1.1
1 parent 1c4d54e commit 2a8ab3a

12 files changed

Lines changed: 1411 additions & 156 deletions

File tree

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ jobs:
3737
with:
3838
name: CodexAuth Switch ${{ github.ref_name }}
3939
body: |
40-
Initial open-source release.
40+
CodexAuth Switch release.
4141
4242
- Windows local Codex App account switcher
4343
- DPAPI-encrypted local account snapshots
44-
- No OpenAI official API calls
44+
- Local quota estimation by default
45+
- Optional online precise quota mode for current-account limits
46+
- Reviews, model-level quota cards, and quota pace hints
4547
- No Codex conversation history upload
4648
- The installer is not commercially code-signed, so Windows may show a security warning.
4749
files: |

README.en.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ English README | [中文说明](README.md)
66

77
CodexAuth Switch is a local Windows desktop utility for quickly switching between multiple Codex App login accounts.
88

9-
It is designed for people who use more than one OpenAI / Codex App account. You can save each account's local login state, then switch the active Codex login through this tool. The project only operates on local files. It does not call OpenAI official APIs, does not access `chatgpt.com`, and does not upload Codex conversation history.
9+
It is designed for people who use more than one OpenAI / Codex App account. You can save each account's local login state, then switch the active Codex login through this tool. By default the app only operates on local files. If you manually enable online precise quota mode, it uses the current Codex access token to query the `chatgpt.com` quota endpoint. It does not upload Codex conversation history.
1010

1111
One-line positioning: **CodexAuth Switch is a local-first Codex App multi-account switcher with `auth.json` snapshot management, Windows DPAPI encryption, quota display, and token usage statistics.**
1212

@@ -17,12 +17,12 @@ One-line positioning: **CodexAuth Switch is a local-first Codex App multi-accoun
1717
- Users who manage multiple Codex App login accounts on Windows.
1818
- Users who want to switch the active OpenAI Codex / Codex App account quickly.
1919
- Users who want to safely save and restore local `%USERPROFILE%\.codex\auth.json` login snapshots.
20-
- Users who want to view local Codex quota, 5-hour quota, weekly quota, token usage, and recent sessions.
21-
- Users who want a local-only tool that does not call OpenAI official APIs or upload Codex conversation history.
20+
- Users who want to view local Codex quota, 5-hour quota, weekly quota, Reviews, model-level limits, token usage, and recent sessions.
21+
- Users who want local log estimation by default, with an optional online precise quota mode.
2222

2323
## Search Keywords
2424

25-
Codex account switcher, Codex multi account, Codex App account manager, OpenAI Codex account switcher, Codex auth.json switcher, Codex local login manager, Codex quota viewer, Codex token usage dashboard, Codex Windows desktop app, Codex DPAPI encryption, Codex no official API calls, Codex local history read-only.
25+
Codex account switcher, Codex multi account, Codex App account manager, OpenAI Codex account switcher, Codex auth.json switcher, Codex local login manager, Codex quota viewer, Codex token usage dashboard, Codex Windows desktop app, Codex DPAPI encryption, Codex local quota estimate, Codex online precise quota, Codex local history read-only.
2626

2727
## Features
2828

@@ -32,8 +32,10 @@ Codex account switcher, Codex multi account, Codex App account manager, OpenAI C
3232
- Encrypt saved account credentials with Windows DPAPI, readable only by the current Windows user.
3333
- Automatically back up the original `auth.json` before switching, reauth, or deleting the active account.
3434
- Provide a main window, system tray menu, and floating quick-view widget.
35-
- Read quota and token usage from local Codex logs.
36-
- Disable network requests inside the app to keep it local-only.
35+
- Read quota and token usage from local Codex logs by default.
36+
- Optionally use the current login token to read precise quota from the ChatGPT backend, falling back to local estimation on failure.
37+
- Show quota pace hints, Reviews, and model-level limit cards.
38+
- Disable network requests in renderer pages; only the main process performs an online quota request after the user enables precise mode.
3739

3840
## Screenshots
3941

@@ -73,9 +75,10 @@ CodexAuth Switch is intentionally scoped to the local Codex login file and the a
7375
- It does not modify Codex conversation history.
7476
- It does not delete `%USERPROFILE%\.codex\sessions`.
7577
- It does not write to `logs_2.sqlite`.
76-
- It does not upload tokens, account data, session logs, or usage records.
78+
- By default, it does not upload tokens, account data, session logs, or usage records.
79+
- Online precise quota mode uses the current access token only as authentication for the `chatgpt.com` quota endpoint and does not upload local conversation history.
7780
- It does not refresh OpenAI tokens by itself.
78-
- It does not call OpenAI official APIs.
81+
- It does not call remote quota endpoints unless the user explicitly enables online precise quota mode.
7982

8083
The only features that intentionally affect Codex App runtime state are account switching, reauth, deleting the active account, and restarting Codex App. These actions may replace or remove the current `auth.json` and restart Codex App so the new local login state takes effect.
8184

@@ -135,9 +138,18 @@ If a saved account's refresh token becomes invalid, the app can start a reauth f
135138

136139
This does not bypass or replace official login. The real login still happens inside Codex App.
137140

141+
### Quota Modes
142+
143+
The quota panel supports two modes:
144+
145+
- Local estimate: default mode; reads only logs already written by Codex App.
146+
- Online precise: manually enabled; uses the access token in the current `auth.json` to request `https://chatgpt.com/backend-api/wham/usage` and read 5-hour, weekly, Reviews, model-level limits, and credits. If the request fails, the app falls back to local estimation.
147+
148+
Online precise mode does not refresh OpenAI tokens and does not write back to `auth.json`.
149+
138150
### Local Quota And Usage
139151

140-
The quota and usage panels only read logs already written by Codex App:
152+
Local estimate mode reads:
141153

142154
- `codex.rate_limits` records in session JSONL files.
143155
- `codex.rate_limits` and usage-limit records in `logs_2.sqlite`.
@@ -147,6 +159,10 @@ The app watches local log file changes with a short debounce and uses a low-freq
147159

148160
Quota snapshots are saved only into this app's own account metadata. They are not written back to Codex log files.
149161

162+
### Quota Pace Hints
163+
164+
The app uses the current used percentage, quota window length, and reset time to estimate consumption pace. It can show whether usage is light, on track, or likely to run out early. This is a trend hint, not a promise of how much quota the next request will consume.
165+
150166
### Network Isolation
151167

152168
Electron windows use these security settings:
@@ -173,7 +189,7 @@ ws://
173189
wss://
174190
```
175191

176-
These restrictions keep the app local-only and help prevent account data or local history from being uploaded.
192+
These restrictions keep renderer pages local-only and help prevent account data or local history from being uploaded. Online precise quota requests are made by the main process only after the user enables that mode.
177193

178194
## Usage
179195

@@ -268,19 +284,14 @@ QUOTA-LOGIC.md Quota-estimation notes
268284
- Windows only for now.
269285
- Credential encryption depends on Windows DPAPI.
270286
- This targets Codex App local login switching, not Codex CLI-only workflows.
271-
- Quota and usage display are best-effort interpretations of local logs.
287+
- Local estimate mode is a best-effort interpretation of local logs.
288+
- Online precise mode depends on the `chatgpt.com` quota endpoint, whose response shape may change with Codex backend updates.
272289
- Quota snapshots may stay stale until Codex writes new local rate-limit records.
273290
- Do not share saved credential snapshots across machines or Windows users.
274291

275-
## Release Notes
276-
277-
For a first GitHub release, upload the generated Windows installer from:
278-
279-
```text
280-
release\CodexAuthSwitch-Setup-0.1.0.exe
281-
```
292+
## Release
282293

283-
The installer is not commercially code-signed, so Windows may show a security warning.
294+
Windows installers are uploaded through GitHub Releases. The installer is not commercially code-signed, so Windows may show a security warning.
284295

285296
## License
286297

README.md

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
CodexAuth Switch 是一个 Windows 本地桌面工具,用来在多个 Codex App 登录账号之间快速切换。
88

9-
它适合同时使用多个 OpenAI / Codex App 账号的人:先把每个账号的本地登录状态保存下来,之后通过这个工具切换当前生效的 Codex 登录。项目只操作本机文件,不调用 OpenAI 官方接口,不访问 `chatgpt.com`,也不会上传 Codex 会话历史。
9+
它适合同时使用多个 OpenAI / Codex App 账号的人:先把每个账号的本地登录状态保存下来,之后通过这个工具切换当前生效的 Codex 登录。默认模式只操作本机文件;如果手动开启“联网精准”额度模式,应用会用当前 Codex 登录 token 请求 `chatgpt.com` 的额度接口。应用不会上传 Codex 会话历史。
1010

1111
一句话定位:**CodexAuth Switch 是一个本地优先的 Codex App 多账号切换工具,支持 `auth.json` 快照管理、Windows DPAPI 加密、额度查看和 token 用量统计。**
1212

@@ -17,12 +17,12 @@ CodexAuth Switch 是一个 Windows 本地桌面工具,用来在多个 Codex Ap
1717
- 想在 Windows 上管理多个 Codex App 登录账号。
1818
- 想快速切换 OpenAI Codex / Codex App 当前账号。
1919
- 想安全保存和恢复本地 `%USERPROFILE%\.codex\auth.json` 登录快照。
20-
- 想查看 Codex 本地额度、5 小时额度、周额度、token 用量和最近会话。
21-
- 想确认工具不会调用 OpenAI 官方 API、不会上传本地 Codex 会话历史
20+
- 想查看 Codex 本地额度、5 小时额度、周额度、Reviews、模型级额度、token 用量和最近会话。
21+
- 想默认使用本地日志估算,也希望可选启用联网精准额度读取
2222

2323
## 常见搜索词
2424

25-
Codex 账号切换、Codex 多账号、Codex App 账号管理、OpenAI Codex 账号切换工具、Codex auth.json 切换、Codex 本地登录管理、Codex 额度查看、Codex token 用量统计、Codex Windows 桌面工具、Codex DPAPI 加密、Codex 不调用官方 API、Codex 本地历史只读。
25+
Codex 账号切换、Codex 多账号、Codex App 账号管理、OpenAI Codex 账号切换工具、Codex auth.json 切换、Codex 本地登录管理、Codex 额度查看、Codex token 用量统计、Codex Windows 桌面工具、Codex DPAPI 加密、Codex 本地预估、Codex 联网精准额度、Codex 本地历史只读。
2626

2727
## 功能
2828

@@ -32,8 +32,10 @@ Codex 账号切换、Codex 多账号、Codex App 账号管理、OpenAI Codex 账
3232
- 使用 Windows DPAPI 加密保存账号凭据,仅当前 Windows 用户可解密。
3333
- 切换、重新登录、删除当前账号前自动备份原始 `auth.json`
3434
- 提供主窗口、系统托盘菜单和悬浮快捷窗。
35-
- 从本地 Codex 日志读取额度和 token 使用情况。
36-
- 在应用内禁用网络请求,保持本地运行。
35+
- 默认从本地 Codex 日志读取额度和 token 使用情况。
36+
- 可选使用当前登录 token 联网读取 ChatGPT 后端额度,失败时回退本地估算。
37+
- 显示额度消耗 pace 提示、Reviews 和模型级额度。
38+
- 渲染页面禁用网络请求;只有用户开启联网精准模式时,主进程才会发起额度读取请求。
3739

3840
## 界面截图
3941

@@ -73,9 +75,10 @@ CodexAuth Switch 的设计目标是把影响范围限制在本机登录文件和
7375
- 不修改 Codex 会话历史。
7476
- 不删除 `%USERPROFILE%\.codex\sessions`
7577
- 不写入 `logs_2.sqlite`
76-
- 不上传 token、账号信息、会话日志或用量记录。
78+
- 默认不上传 token、账号信息、会话日志或用量记录。
79+
- 联网精准额度模式只会把当前 access token 用作 `chatgpt.com` 额度接口认证,不上传本地会话历史。
7780
- 不自行刷新 OpenAI token。
78-
- 不调用 OpenAI 官方 API
81+
- 默认不调用远程额度接口;联网精准模式需要用户手动开启
7982

8083
会影响 Codex App 当前运行状态的功能只有:切换账号、重新登录、删除当前账号、重启 Codex App。这些操作可能会替换或移除当前 `auth.json`,并重启 Codex App,让新的本地登录状态生效。
8184

@@ -135,9 +138,18 @@ DataProtectionScope.CurrentUser
135138

136139
这个过程不绕过官方登录,也不代替官方登录。真正的登录仍然发生在 Codex App 内。
137140

141+
### 额度读取模式
142+
143+
额度面板支持两种模式:
144+
145+
- 本地预估:默认模式,只读取 Codex App 已经写到本机的日志。
146+
- 联网精准:手动开启后,使用当前 `auth.json` 里的 access token 请求 `https://chatgpt.com/backend-api/wham/usage`,读取官方返回的 5 小时、周额度、Reviews、模型级额度和 credits;读取失败会回退本地估算。
147+
148+
联网精准模式不会自动刷新 OpenAI token,也不会写回 `auth.json`
149+
138150
### 本地额度和用量统计
139151

140-
额度和用量面板只读取 Codex App 已经写到本机的日志
152+
本地预估模式读取以下数据
141153

142154
- session JSONL 文件里的 `codex.rate_limits`
143155
- `logs_2.sqlite` 里的 `codex.rate_limits` 和 usage-limit 记录。
@@ -147,6 +159,10 @@ DataProtectionScope.CurrentUser
147159

148160
额度快照只保存到本应用自己的账号元数据中,不会写回 Codex 的日志文件。
149161

162+
### 额度 pace 提示
163+
164+
应用会根据当前已用百分比、额度窗口长度和重置时间估算当前消耗速度,显示“消耗速度宽松 / 消耗速度正常 / 按当前速度会提前用完”。这只是趋势提示,不代表下一次对话会准确消耗多少额度。
165+
150166
### 网络隔离
151167

152168
Electron 窗口启用了以下安全配置:
@@ -173,7 +189,7 @@ ws://
173189
wss://
174190
```
175191

176-
这些限制用于确保应用保持本地工具属性,避免账号信息或本地历史被上传。
192+
这些限制用于确保渲染页面保持本地工具属性,避免账号信息或本地历史被上传。联网精准额度模式的请求由主进程在用户手动开启后发起
177193

178194
## 使用方法
179195

@@ -268,16 +284,14 @@ QUOTA-LOGIC.md 额度估算逻辑说明
268284
- 目前只支持 Windows。
269285
- 凭据加密依赖 Windows DPAPI。
270286
- 目标是 Codex App 本地登录切换,不是 Codex CLI-only 工作流。
271-
- 额度和用量展示来自本地日志解析,属于本地近似展示。
287+
- 本地预估模式来自本地日志解析,属于本地近似展示。
288+
- 联网精准模式依赖 `chatgpt.com` 额度接口,接口字段可能随 Codex 后端变化。
272289
- Codex 没有写入新的本地 rate-limit 记录时,额度快照可能暂时不更新。
273290
- 不要跨机器或跨 Windows 用户共享已保存的凭据快照。
274291

275-
## 开源前建议
276-
277-
正式公开仓库前,建议补充:
292+
## Release
278293

279-
- Release 说明:解释安装包来源、版本号和校验方式。
280-
- 截图:展示主窗口、悬浮窗和托盘菜单。
294+
Windows 安装包会随 GitHub Release 上传。安装器未做商业代码签名,Windows 可能会显示安全提醒。
281295

282296
## License
283297

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codexauth-switch",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"private": true,
55
"description": "Local Windows desktop account switcher for Codex App.",
66
"author": "GboyCode",

0 commit comments

Comments
 (0)