@pikoloo/codex-proxy 1.1.0 → 1.2.2
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.
- package/CHANGELOG.md +76 -0
- package/README.md +28 -11
- package/bin/cli.js +15 -15
- package/docs/ACCOUNT.md +104 -0
- package/docs/API.md +26 -19
- package/docs/ARCHITECTURE.md +9 -9
- package/docs/CLAUDE_INTEGRATION.md +3 -3
- package/docs/OAUTH.md +13 -13
- package/docs/OPENCLAW.md +1 -1
- package/docs/legal.md +6 -0
- package/package.json +10 -8
- package/public/css/style.css +4 -34
- package/public/index.html +105 -166
- package/public/js/app.js +23 -58
- package/src/account-manager.js +210 -292
- package/src/cli/account.js +236 -0
- package/src/direct-api.js +7 -9
- package/src/index.js +7 -7
- package/src/middleware/credentials.js +6 -47
- package/src/oauth.js +2 -1
- package/src/routes/{accounts-route.js → account-route.js} +25 -109
- package/src/routes/api-routes.js +18 -26
- package/src/routes/chat-route.js +2 -2
- package/src/routes/messages-route.js +29 -189
- package/src/routes/models-route.js +11 -21
- package/src/security.js +1 -1
- package/src/server-settings.js +1 -8
- package/docs/ACCOUNTS.md +0 -202
- package/src/account-rotation/index.js +0 -130
- package/src/account-rotation/rate-limits.js +0 -293
- package/src/cli/accounts.js +0 -557
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this package are documented in this file.
|
|
4
|
+
|
|
5
|
+
This project uses release entries grouped by package version, with the newest release first.
|
|
6
|
+
|
|
7
|
+
## [1.2.2] - 2026-05-24
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Made release verification run against an isolated temporary proxy config instead of the user's real local account and settings.
|
|
12
|
+
- Made `test:all` run unit tests and server-backed tests sequentially so mutable settings tests cannot race each other.
|
|
13
|
+
- Made `make update` restore its own version bump if verification fails before the release commit is created.
|
|
14
|
+
|
|
15
|
+
## [1.2.1] - 2026-05-24
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Made release metadata tests compare against the active package version so `make update` can bump patch, minor, major, or explicit versions without breaking on stale literals.
|
|
20
|
+
- Updated the release script to refresh the dashboard version along with package metadata, lockfile metadata, and the server banner.
|
|
21
|
+
|
|
22
|
+
## [1.2.0] - 2026-05-24
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- Single-account local mode for the ChatGPT account manager, API surface, CLI, and dashboard.
|
|
27
|
+
- `codex-proxy account` CLI commands for configuring, showing, verifying, and removing the one local account.
|
|
28
|
+
- Singular account API routes under `/account`, including status, add, import, refresh, delete, quota, models, usage, and OAuth cleanup endpoints.
|
|
29
|
+
- Responsible use documentation for local single-user intent, credential boundaries, no resale, and no rate-limit bypass behavior.
|
|
30
|
+
- Regression tests for single-account storage, route registration, CLI command shape, release metadata, changelog packaging, and static removal audits.
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- Adding or importing an account now replaces the existing configured account instead of appending another account.
|
|
35
|
+
- `/v1/messages` now uses only the configured account credentials for OpenAI requests.
|
|
36
|
+
- The dashboard Account tab now shows one account card and one empty state instead of multi-account tables or switching controls.
|
|
37
|
+
- Package metadata, lockfile metadata, server banner, and dashboard version now report `1.2.0`.
|
|
38
|
+
|
|
39
|
+
### Removed
|
|
40
|
+
|
|
41
|
+
- Removed plural first-party account-management routes and per-email account operations.
|
|
42
|
+
- Removed legacy plural account CLI command handling, account listing, switching, refresh-all, and quota-all semantics.
|
|
43
|
+
- Removed legacy account fallback code, tests, settings, and related docs.
|
|
44
|
+
|
|
45
|
+
## [1.1.0] - 2026-05-24
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- Hardened release/update flow so update verification does not depend on stale local proxy instances.
|
|
50
|
+
- Restored npm package metadata to the `1.1.0` release line after local version experiments.
|
|
51
|
+
|
|
52
|
+
## [1.0.8] - 2026-05-23
|
|
53
|
+
|
|
54
|
+
### Added
|
|
55
|
+
|
|
56
|
+
- Added explicit update bump commands for release maintenance.
|
|
57
|
+
- Added compact dashboard account controls for narrow screens.
|
|
58
|
+
|
|
59
|
+
### Changed
|
|
60
|
+
|
|
61
|
+
- Refreshed README screenshots and dashboard presentation.
|
|
62
|
+
- Tightened small-screen action bars and bottom navigation styling.
|
|
63
|
+
- Removed legacy local artifacts from the tracked package surface.
|
|
64
|
+
|
|
65
|
+
## [1.0.7] - 2026-05-23
|
|
66
|
+
|
|
67
|
+
### Added
|
|
68
|
+
|
|
69
|
+
- Added token usage metrics and recent request dashboard panels.
|
|
70
|
+
- Added Claude model mapping and reasoning mapping controls.
|
|
71
|
+
- Added Claude Code configuration helpers in the dashboard.
|
|
72
|
+
|
|
73
|
+
### Changed
|
|
74
|
+
|
|
75
|
+
- Simplified dashboard header layout and local development entrypoints.
|
|
76
|
+
- Removed account strategy selection from settings.
|
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ _Current README cover: a short, thumbgen-style composite generated from fresh lo
|
|
|
17
17
|
| GitHub | [surajmandalcell](https://github.com/surajmandalcell) |
|
|
18
18
|
| Contact | [surajmandalcell@gmail.com](mailto:surajmandalcell@gmail.com) |
|
|
19
19
|
| Package | [@pikoloo/codex-proxy](https://www.npmjs.com/package/@pikoloo/codex-proxy) |
|
|
20
|
+
| Changelog | [Changelog](CHANGELOG.md) |
|
|
20
21
|
|
|
21
22
|
---
|
|
22
23
|
|
|
@@ -24,8 +25,8 @@ _Current README cover: a short, thumbgen-style composite generated from fresh lo
|
|
|
24
25
|
|
|
25
26
|
- **Seamless Translation**: Translates Anthropic Messages API calls to ChatGPT Codex format.
|
|
26
27
|
- **Model Mapping**: maps Claude model aliases to current OpenAI models, with direct GPT model IDs passed through.
|
|
27
|
-
- **Personal Account Mode**:
|
|
28
|
-
- **Web Dashboard**: Built-in macOS-style UI (`http://localhost:8081`) for managing
|
|
28
|
+
- **Personal Account Mode**: Stores and uses one configured ChatGPT account for local-only personal use, with token auto-refresh.
|
|
29
|
+
- **Web Dashboard**: Built-in macOS-style UI (`http://localhost:8081`) for managing the local account, configuring Claude Code, viewing logs, adjusting settings, and testing prompts.
|
|
29
30
|
- **Streaming Support**: Full Server-Sent Events (SSE) support for real-time responses.
|
|
30
31
|
- **Native Tool Calling**: Supports Claude's tool use capabilities by translating them to Codex function calls.
|
|
31
32
|
|
|
@@ -37,13 +38,29 @@ _Current README cover: a short, thumbgen-style composite generated from fresh lo
|
|
|
37
38
|
|
|
38
39
|
- **Local Execution**: This server binds to `127.0.0.1` by default.
|
|
39
40
|
- **Direct Communication by Default**: Claude and GPT model requests connect directly to OpenAI/ChatGPT endpoints.
|
|
40
|
-
- **
|
|
41
|
+
- **Single Account Only**: Requests use one configured ChatGPT account. Adding or importing an account replaces the existing local account.
|
|
41
42
|
- **Third-Party Opt-In**: The explicit `kilo` model route uses Kilo/OpenRouter-backed free models only when `CODEX_CLAUDE_PROXY_ENABLE_KILO=true` is set. Default routing is OpenAI-only.
|
|
42
43
|
- **Open Source**: The full source code is available here for you to audit.
|
|
43
44
|
- **No Data Collection**: We do not track your prompts, keys, or personal data.
|
|
44
45
|
|
|
45
46
|
---
|
|
46
47
|
|
|
48
|
+
## Responsible Use And Account Boundaries
|
|
49
|
+
|
|
50
|
+
| Boundary | Commitment |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| Single user | This tool is intended for local, single-user use with your own ChatGPT/Codex account. |
|
|
53
|
+
| Single account | The proxy stores and uses one configured ChatGPT account at a time. Adding or importing an account replaces the existing local account. |
|
|
54
|
+
| No sharing | Do not expose the proxy to other users or make your ChatGPT credentials, session, or local proxy available to anyone else. |
|
|
55
|
+
| No resale | This package distributes client software only. It does not sell, rent, sublicense, bundle, or provide OpenAI service access. |
|
|
56
|
+
| No rate-limit bypass | The project does not pool accounts, rotate accounts, retry on another account, or attempt to avoid usage limits. |
|
|
57
|
+
| Unofficial tool | This project is independent and is not affiliated with, endorsed by, or sponsored by OpenAI, Anthropic, or Kilo. |
|
|
58
|
+
| Terms reminder | Users remain responsible for their own compliance with the [OpenAI Terms](https://openai.com/policies/terms-of-use/) and [Anthropic Terms](https://www.anthropic.com/legal/consumer-terms). |
|
|
59
|
+
|
|
60
|
+
This project uses unofficial ChatGPT/Codex backend behavior and does not claim official approval or guaranteed Terms compliance.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
47
64
|
## ⚙️ How it works
|
|
48
65
|
|
|
49
66
|
This tool acts as a "translation layer" between the Claude CLI and ChatGPT's Codex backend.
|
|
@@ -97,17 +114,17 @@ The server will start at `http://localhost:8081`.
|
|
|
97
114
|
#### **Option A: Web Dashboard (Local Desktop)**
|
|
98
115
|
|
|
99
116
|
1. Open the dashboard at **[http://localhost:8081](http://localhost:8081)**
|
|
100
|
-
2. Go to the **
|
|
117
|
+
2. Go to the **Account** tab
|
|
101
118
|
3. Click **Add Account** and login with your ChatGPT account
|
|
102
119
|
|
|
103
120
|
#### **Option B: CLI (Desktop or Headless/VM)**
|
|
104
121
|
|
|
105
122
|
```bash
|
|
106
123
|
# Desktop (opens browser)
|
|
107
|
-
codex-proxy
|
|
124
|
+
codex-proxy account add
|
|
108
125
|
|
|
109
126
|
# Headless/VM server (manual code input)
|
|
110
|
-
codex-proxy
|
|
127
|
+
codex-proxy account add --no-browser
|
|
111
128
|
```
|
|
112
129
|
|
|
113
130
|
For **headless/VM servers** without a browser:
|
|
@@ -156,22 +173,22 @@ The proxy automatically maps Claude model names to current OpenAI backend models
|
|
|
156
173
|
|
|
157
174
|
### Web Dashboard
|
|
158
175
|
|
|
159
|
-
The dashboard uses a clean desktop split-view layout with a compact toolbar, native-feeling glass surfaces, account management, live logs, settings, Claude Code configuration, and prompt test panels. The screenshots below are captured from the actual local app.
|
|
176
|
+
The dashboard uses a clean desktop split-view layout with a compact toolbar, native-feeling glass surfaces, single-account management, live logs, settings, Claude Code configuration, and prompt test panels. The screenshots below are captured from the actual local app.
|
|
160
177
|
|
|
161
178
|
| Dashboard | Settings |
|
|
162
179
|
| --- | --- |
|
|
163
180
|
|  |  |
|
|
164
181
|
|
|
165
182
|
Visit `http://localhost:8081` to:
|
|
166
|
-
- **Manage
|
|
167
|
-
- **Personal Mode**: Requests use the
|
|
183
|
+
- **Manage Account**: Add, import, refresh, replace, or remove the one local ChatGPT account.
|
|
184
|
+
- **Personal Mode**: Requests use the configured account only.
|
|
168
185
|
- **Configure Claude Code**: Use the dashboard button to set `ANTHROPIC_BASE_URL`, `ANTHROPIC_API_KEY`, and Claude model defaults, or enable the startup toggle to do it automatically.
|
|
169
186
|
- **View Logs**: See real-time request/response logs for debugging.
|
|
170
187
|
- **Test Models**: Run quick tests against the configured models.
|
|
171
188
|
|
|
172
189
|
### API Endpoints
|
|
173
190
|
- `GET /health`: Check server status.
|
|
174
|
-
- `GET /
|
|
191
|
+
- `GET /account`: View the configured account.
|
|
175
192
|
- `POST /v1/messages`: Anthropic-compatible chat completion endpoint.
|
|
176
193
|
|
|
177
194
|
See [API Documentation](./docs/API.md) for full details.
|
|
@@ -194,7 +211,7 @@ Contributions are welcome! Please feel free to submit a Pull Request.
|
|
|
194
211
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
195
212
|
|
|
196
213
|
## ⚠️ Disclaimer
|
|
197
|
-
This project is an independent open-source tool and is not affiliated with, endorsed by, or sponsored by Anthropic or
|
|
214
|
+
This project is an independent open-source tool and is not affiliated with, endorsed by, or sponsored by Anthropic, OpenAI, or Kilo. "Claude" is a trademark of Anthropic PBC. "ChatGPT" and "Codex" are trademarks of OpenAI. Use responsibly and in accordance with applicable Terms of Service.
|
|
198
215
|
|
|
199
216
|
---
|
|
200
217
|
|
package/bin/cli.js
CHANGED
|
@@ -27,13 +27,13 @@ USAGE:
|
|
|
27
27
|
|
|
28
28
|
COMMANDS:
|
|
29
29
|
start Start the proxy server (default port: 8081)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
account Manage the configured ChatGPT account
|
|
31
|
+
account add Configure an account via OAuth
|
|
32
|
+
account add --no-browser Configure account manually (headless/VM)
|
|
33
|
+
account show Show the configured account
|
|
34
|
+
account remove Remove the configured account
|
|
35
|
+
account verify Verify account tokens are valid
|
|
36
|
+
account clear Remove the configured account
|
|
37
37
|
|
|
38
38
|
OPTIONS:
|
|
39
39
|
--help, -h Show this help message
|
|
@@ -45,16 +45,16 @@ ENVIRONMENT:
|
|
|
45
45
|
EXAMPLES:
|
|
46
46
|
${CLI_NAME} start
|
|
47
47
|
PORT=3000 ${CLI_NAME} start
|
|
48
|
-
${CLI_NAME}
|
|
49
|
-
${CLI_NAME}
|
|
50
|
-
${CLI_NAME}
|
|
51
|
-
${CLI_NAME}
|
|
48
|
+
${CLI_NAME} account add
|
|
49
|
+
${CLI_NAME} account add --no-browser
|
|
50
|
+
${CLI_NAME} account show
|
|
51
|
+
${CLI_NAME} account verify
|
|
52
52
|
|
|
53
53
|
ALIASES:
|
|
54
54
|
${LEGACY_CLI_NAME} Legacy command name, still supported
|
|
55
55
|
|
|
56
56
|
HEADLESS/VM USAGE:
|
|
57
|
-
1. Run: ${CLI_NAME}
|
|
57
|
+
1. Run: ${CLI_NAME} account add --no-browser
|
|
58
58
|
2. Copy the URL shown and open in browser on another device
|
|
59
59
|
3. After login, paste the callback URL back in terminal
|
|
60
60
|
|
|
@@ -90,10 +90,10 @@ async function main() {
|
|
|
90
90
|
await import('../src/index.js');
|
|
91
91
|
break;
|
|
92
92
|
|
|
93
|
-
case '
|
|
93
|
+
case 'account': {
|
|
94
94
|
const subCommand = args[1] || 'add';
|
|
95
|
-
process.argv = ['node', '
|
|
96
|
-
await import('../src/cli/
|
|
95
|
+
process.argv = ['node', 'account-cli.js', subCommand, ...args.slice(2)];
|
|
96
|
+
await import('../src/cli/account.js');
|
|
97
97
|
break;
|
|
98
98
|
}
|
|
99
99
|
|
package/docs/ACCOUNT.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Account Management
|
|
2
|
+
|
|
3
|
+
## Storage Structure
|
|
4
|
+
|
|
5
|
+
The proxy stores one configured ChatGPT account at a time.
|
|
6
|
+
|
|
7
|
+
| File | Purpose |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| `~/.codex-claude-proxy/account.json` | Local account registry and quota snapshot |
|
|
10
|
+
| `~/.codex-claude-proxy/auth.json` | Token file compatible with the Codex app auth shape |
|
|
11
|
+
| Legacy `accounts.json` in the config directory | Legacy file read once for migration only |
|
|
12
|
+
|
|
13
|
+
### Main Registry
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"account": {
|
|
18
|
+
"email": "user@gmail.com",
|
|
19
|
+
"accountId": "d41e9636-16d8-42be-91da-7ea8773bfb7e",
|
|
20
|
+
"planType": "plus",
|
|
21
|
+
"accessToken": "eyJhbGciOiJSUzI1NiIs...",
|
|
22
|
+
"refreshToken": "rt_WpTMn1...",
|
|
23
|
+
"idToken": "eyJhbGciOiJSUzI1NiIs...",
|
|
24
|
+
"expiresAt": 1770886178000,
|
|
25
|
+
"addedAt": "2026-02-13T04:00:00.000Z",
|
|
26
|
+
"lastUsed": "2026-02-13T04:30:00.000Z",
|
|
27
|
+
"quota": {
|
|
28
|
+
"usage": {},
|
|
29
|
+
"account": {},
|
|
30
|
+
"lastChecked": "2026-02-14T10:00:00.000Z"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"activeAccount": "user@gmail.com",
|
|
34
|
+
"version": 2
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Operations
|
|
39
|
+
|
|
40
|
+
| Operation | Endpoint |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| View configured account | `GET /account` |
|
|
43
|
+
| Start browser OAuth | `POST /account/add` |
|
|
44
|
+
| Complete headless OAuth | `POST /account/add/manual` |
|
|
45
|
+
| Import from Codex app | `POST /account/import` |
|
|
46
|
+
| Refresh token | `POST /account/refresh` |
|
|
47
|
+
| Fetch quota | `GET /account/quota` |
|
|
48
|
+
| Remove account | `DELETE /account` |
|
|
49
|
+
|
|
50
|
+
Adding, importing, or manually completing OAuth replaces the existing local account.
|
|
51
|
+
|
|
52
|
+
### Add Account
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
curl -X POST http://localhost:8081/account/add
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Import from Codex App
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
curl -X POST http://localhost:8081/account/import
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### View Account
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
curl http://localhost:8081/account
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Remove Account
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
curl -X DELETE http://localhost:8081/account
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Token Lifecycle
|
|
77
|
+
|
|
78
|
+
| Step | Behavior |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| Expiration | Access tokens expire in about 1 hour. |
|
|
81
|
+
| Auto-refresh | Background refresh runs every 55 minutes. |
|
|
82
|
+
| Startup | The server schedules a refresh shortly after startup. |
|
|
83
|
+
| Request path | Each OpenAI-bound request uses the one configured account after refreshing if needed. |
|
|
84
|
+
|
|
85
|
+
## Quota Tracking
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
curl http://localhost:8081/account/quota
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The Account tab renders remaining quota from the normalized usage percentage. If quota data is unavailable, the UI shows `Unavailable` instead of rendering a broken bar. If the upstream marks the limit as reached, the UI shows the quota as used.
|
|
92
|
+
|
|
93
|
+
## Legacy Migration
|
|
94
|
+
|
|
95
|
+
On first startup after upgrading, the proxy checks for the old `accounts.json` file only if `account.json` does not already exist. It imports the previously selected account, or the first account in the legacy file when no selection is recorded. Legacy files are left in place unless the user clears the configured account.
|
|
96
|
+
|
|
97
|
+
## Security
|
|
98
|
+
|
|
99
|
+
| Boundary | Detail |
|
|
100
|
+
| --- | --- |
|
|
101
|
+
| Local storage | Tokens stay under `~/.codex-claude-proxy/`. |
|
|
102
|
+
| File permissions | Account files are written with user-only permissions where supported. |
|
|
103
|
+
| API responses | Access, refresh, and ID tokens are never returned in account API responses. |
|
|
104
|
+
| Account boundary | The proxy does not share, pool, rotate, or retry across other accounts. |
|
package/docs/API.md
CHANGED
|
@@ -87,21 +87,22 @@ Common endpoints:
|
|
|
87
87
|
|
|
88
88
|
| Endpoint | Method | Description |
|
|
89
89
|
|----------|--------|-------------|
|
|
90
|
-
| `/
|
|
91
|
-
| `/
|
|
92
|
-
| `/
|
|
93
|
-
| `/
|
|
94
|
-
| `/
|
|
95
|
-
| `/
|
|
96
|
-
| `/
|
|
97
|
-
| `/
|
|
98
|
-
|
|
99
|
-
|
|
90
|
+
| `/account` | GET | View the configured account |
|
|
91
|
+
| `/account/status` | GET | Get account status summary |
|
|
92
|
+
| `/account/add` | POST | Start OAuth flow that replaces the local account |
|
|
93
|
+
| `/account/add/manual` | POST | Complete headless OAuth manually |
|
|
94
|
+
| `/account/import` | POST | Import the local Codex app account, replacing the existing local account |
|
|
95
|
+
| `/account/refresh` | POST | Refresh the configured account token |
|
|
96
|
+
| `/account/quota` | GET | Get quota info |
|
|
97
|
+
| `/account/models` | GET | Get models for the configured account |
|
|
98
|
+
| `/account/usage` | GET | Get usage stats for the configured account |
|
|
99
|
+
| `/account/oauth/cleanup` | POST | Stop any pending OAuth callback server |
|
|
100
|
+
| `/account` | DELETE | Remove the configured account |
|
|
100
101
|
|
|
101
102
|
### Add Account
|
|
102
103
|
|
|
103
104
|
```bash
|
|
104
|
-
POST /
|
|
105
|
+
POST /account/add
|
|
105
106
|
Content-Type: application/json
|
|
106
107
|
|
|
107
108
|
# Optional: specify callback port
|
|
@@ -115,16 +116,22 @@ Content-Type: application/json
|
|
|
115
116
|
}
|
|
116
117
|
```
|
|
117
118
|
|
|
118
|
-
###
|
|
119
|
+
### Import Account
|
|
119
120
|
|
|
120
121
|
```bash
|
|
121
|
-
POST /
|
|
122
|
-
Content-Type: application/json
|
|
122
|
+
POST /account/import
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
# Response
|
|
125
|
+
{"success": true, "message": "Imported account from Codex"}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Refresh Account
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
POST /account/refresh
|
|
125
132
|
|
|
126
133
|
# Response
|
|
127
|
-
{"success": true, "message": "
|
|
134
|
+
{"success": true, "message": "Token refreshed"}
|
|
128
135
|
```
|
|
129
136
|
|
|
130
137
|
### OAuth Callback
|
|
@@ -162,9 +169,9 @@ GET /health
|
|
|
162
169
|
# Response
|
|
163
170
|
{
|
|
164
171
|
"status": "ok",
|
|
165
|
-
"total":
|
|
172
|
+
"total": 1,
|
|
166
173
|
"active": "active@example.com",
|
|
167
|
-
"
|
|
174
|
+
"account": {...}
|
|
168
175
|
}
|
|
169
176
|
```
|
|
170
177
|
|
|
@@ -177,7 +184,7 @@ GET /health
|
|
|
177
184
|
"type": "error",
|
|
178
185
|
"error": {
|
|
179
186
|
"type": "authentication_error",
|
|
180
|
-
"message": "No
|
|
187
|
+
"message": "No account configured"
|
|
181
188
|
}
|
|
182
189
|
}
|
|
183
190
|
```
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -31,7 +31,7 @@ codex-proxy/
|
|
|
31
31
|
│ ├── ARCHITECTURE.md
|
|
32
32
|
│ ├── API.md
|
|
33
33
|
│ ├── OAUTH.md
|
|
34
|
-
│ ├──
|
|
34
|
+
│ ├── ACCOUNT.md
|
|
35
35
|
│ └── CLAUDE_INTEGRATION.md
|
|
36
36
|
├── public/
|
|
37
37
|
│ ├── index.html
|
|
@@ -41,7 +41,7 @@ codex-proxy/
|
|
|
41
41
|
├── index.js # App entrypoint
|
|
42
42
|
├── server.js # Express server setup
|
|
43
43
|
├── routes/api-routes.js # API route registrations
|
|
44
|
-
└── ... # OAuth,
|
|
44
|
+
└── ... # OAuth, account storage, converters, upstream clients
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
(See the `src/` directory for the full implementation; this doc focuses on the high-level shape.)
|
|
@@ -54,7 +54,7 @@ codex-proxy/
|
|
|
54
54
|
| `server.js` | Express server, routes, request handling (CORS restricted) |
|
|
55
55
|
| `routes/api-routes.js` | API route registrations (mounted by server) |
|
|
56
56
|
| `oauth.js` | OAuth 2.0 PKCE flow, token exchange |
|
|
57
|
-
| `account-manager.js` |
|
|
57
|
+
| `account-manager.js` | Single-account persistence, one-time migration, token refresh |
|
|
58
58
|
| `format-converter.js` | Convert between Anthropic and OpenAI Responses API formats |
|
|
59
59
|
| `response-streamer.js` | Parse SSE events, convert to Anthropic streaming format |
|
|
60
60
|
| `direct-api.js` | HTTP client for ChatGPT backend |
|
|
@@ -77,11 +77,11 @@ codex-proxy/
|
|
|
77
77
|
|
|
78
78
|
### Web UI Account/Quota Flow
|
|
79
79
|
|
|
80
|
-
1. Web UI loads account
|
|
81
|
-
2. Web UI fetches quota
|
|
82
|
-
3. Quota values are merged into account
|
|
80
|
+
1. Web UI loads the configured account from `/account`
|
|
81
|
+
2. Web UI fetches the quota snapshot from `/account/quota`
|
|
82
|
+
3. Quota values are merged into the account card and modal views
|
|
83
83
|
4. Remaining quota is rendered from normalized usage percentages
|
|
84
|
-
5. On mobile/tablet, sidebar navigation auto-closes after tab change and account
|
|
84
|
+
5. On mobile/tablet, sidebar navigation auto-closes after tab change and account controls stay compact
|
|
85
85
|
|
|
86
86
|
### Format Conversion
|
|
87
87
|
|
|
@@ -122,8 +122,8 @@ Kilo routing is explicit and disabled unless `CODEX_CLAUDE_PROXY_ENABLE_KILO=tru
|
|
|
122
122
|
|
|
123
123
|
## Account Selection
|
|
124
124
|
|
|
125
|
-
The default execution mode is personal local use: `/v1/messages` uses the
|
|
125
|
+
The default execution mode is personal local use: `/v1/messages` uses the single configured account. Adding, importing, or completing OAuth for another account replaces the prior local account. The request path does not pool accounts, retry on another account, or attempt to avoid usage limits.
|
|
126
126
|
|
|
127
127
|
## Data Storage
|
|
128
128
|
|
|
129
|
-
Account and configuration files are stored under your home directory (platform-specific). See `docs/
|
|
129
|
+
Account and configuration files are stored under your home directory (platform-specific). See `docs/ACCOUNT.md` and `docs/CLAUDE_INTEGRATION.md` for details.
|
|
@@ -144,12 +144,12 @@ curl -X POST http://localhost:8081/claude/config/direct \
|
|
|
144
144
|
2. Verify config: `cat ~/.claude/settings.json`
|
|
145
145
|
3. Re-configure: `curl -X POST http://localhost:8081/claude/config/proxy`
|
|
146
146
|
|
|
147
|
-
### "No
|
|
147
|
+
### "No configured account" error
|
|
148
148
|
|
|
149
149
|
Add an account first:
|
|
150
150
|
|
|
151
151
|
```bash
|
|
152
|
-
curl -X POST http://localhost:8081/
|
|
152
|
+
curl -X POST http://localhost:8081/account/import
|
|
153
153
|
# or use WebUI
|
|
154
154
|
```
|
|
155
155
|
|
|
@@ -159,5 +159,5 @@ Ensure you're using the direct API mode (not CLI subprocess). Check:
|
|
|
159
159
|
|
|
160
160
|
```bash
|
|
161
161
|
curl http://localhost:8081/health
|
|
162
|
-
# Should show
|
|
162
|
+
# Should show an account with a valid token
|
|
163
163
|
```
|
package/docs/OAUTH.md
CHANGED
|
@@ -6,12 +6,12 @@ This proxy uses **OAuth 2.0 with PKCE** for secure authentication with ChatGPT.
|
|
|
6
6
|
|
|
7
7
|
### Desktop (Browser)
|
|
8
8
|
```bash
|
|
9
|
-
codex-proxy
|
|
9
|
+
codex-proxy account add
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
### Headless/VM (No Browser)
|
|
13
13
|
```bash
|
|
14
|
-
codex-proxy
|
|
14
|
+
codex-proxy account add --no-browser
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
The legacy `codex-claude-proxy` command remains supported as an alias.
|
|
@@ -22,7 +22,7 @@ When running on a server without a browser (VM, Docker, SSH):
|
|
|
22
22
|
|
|
23
23
|
1. Run the command with `--no-browser`:
|
|
24
24
|
```bash
|
|
25
|
-
codex-proxy
|
|
25
|
+
codex-proxy account add --no-browser
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
2. It prints a URL like:
|
|
@@ -41,7 +41,7 @@ When running on a server without a browser (VM, Docker, SSH):
|
|
|
41
41
|
|
|
42
42
|
6. Copy that entire URL (or just the `code` parameter) and paste it back in the terminal
|
|
43
43
|
|
|
44
|
-
7. The proxy exchanges the code for tokens and saves your account
|
|
44
|
+
7. The proxy exchanges the code for tokens and saves your account, replacing any existing local account
|
|
45
45
|
|
|
46
46
|
## OAuth Config
|
|
47
47
|
|
|
@@ -54,29 +54,29 @@ When running on a server without a browser (VM, Docker, SSH):
|
|
|
54
54
|
|
|
55
55
|
- **PKCE**: Secure code exchange with SHA256 challenge
|
|
56
56
|
- **Auto-Refresh**: Tokens refresh automatically before expiry
|
|
57
|
-
- **Account Selection**: Uses `prompt=login` so you can choose the account
|
|
57
|
+
- **Account Selection**: Uses `prompt=login` so you can choose the personal account that replaces the local account
|
|
58
58
|
- **Headless Support**: Works on servers without browsers
|
|
59
59
|
|
|
60
|
-
## Managing
|
|
60
|
+
## Managing Account
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
|
-
#
|
|
64
|
-
codex-proxy
|
|
63
|
+
# Show account
|
|
64
|
+
codex-proxy account show
|
|
65
65
|
|
|
66
66
|
# Add account (browser)
|
|
67
|
-
codex-proxy
|
|
67
|
+
codex-proxy account add
|
|
68
68
|
|
|
69
69
|
# Add account (headless)
|
|
70
|
-
codex-proxy
|
|
70
|
+
codex-proxy account add --no-browser
|
|
71
71
|
|
|
72
|
-
# Clear
|
|
73
|
-
codex-proxy
|
|
72
|
+
# Clear account
|
|
73
|
+
codex-proxy account clear
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
## Troubleshooting
|
|
77
77
|
|
|
78
78
|
### "Port already in use"
|
|
79
|
-
The `--no-browser` mode works independently of the server
|
|
79
|
+
The `--no-browser` mode works independently of the server, so you can replace the local account even while the proxy is running.
|
|
80
80
|
|
|
81
81
|
### "Invalid state" error
|
|
82
82
|
This happens if you use a code from an old session. Generate a fresh URL and try again.
|
package/docs/OPENCLAW.md
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## Key Benefits
|
|
28
|
-
- **Personal Account Mode**: Proxy uses the
|
|
28
|
+
- **Personal Account Mode**: Proxy uses the single configured local ChatGPT account.
|
|
29
29
|
- **SSE Streaming**: Full real-time response support.
|
|
30
30
|
- **Tool Calling**: Native support for agentic workflows.
|
|
31
31
|
|
package/docs/legal.md
CHANGED
|
@@ -9,3 +9,9 @@
|
|
|
9
9
|
- "Kilo" and "Kilo Search" are trademarks of their respective owners.
|
|
10
10
|
|
|
11
11
|
- Software is provided "as is", without warranty. You are responsible for complying with all applicable Terms of Service and Acceptable Use Policies.
|
|
12
|
+
|
|
13
|
+
- This package distributes client software only. It does not sell, rent, sublicense, bundle, or provide OpenAI service access.
|
|
14
|
+
|
|
15
|
+
- This project is intended for local, single-user use with one configured ChatGPT/Codex account. Do not expose the proxy to other users or make your credentials, session, or local proxy available to anyone else.
|
|
16
|
+
|
|
17
|
+
- The project does not pool accounts, retry on another account, or attempt to avoid usage limits. Review the [OpenAI Terms](https://openai.com/policies/terms-of-use/) and [Anthropic Terms](https://www.anthropic.com/legal/consumer-terms) for the obligations that apply to your own usage.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikoloo/codex-proxy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Local personal proxy for OpenAI Codex models with Claude API compatibility",
|
|
5
5
|
"author": "Suraj Mandal <surajmandalcell@gmail.com>",
|
|
6
6
|
"type": "module",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"public",
|
|
16
16
|
"docs",
|
|
17
17
|
"images",
|
|
18
|
+
"CHANGELOG.md",
|
|
18
19
|
"README.md",
|
|
19
20
|
"LICENSE",
|
|
20
21
|
"package.json"
|
|
@@ -32,16 +33,17 @@
|
|
|
32
33
|
"homepage": "https://github.com/surajmandalcell/codex-proxy#readme",
|
|
33
34
|
"scripts": {
|
|
34
35
|
"start": "node src/index.js",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
36
|
+
"account": "node src/cli/account.js",
|
|
37
|
+
"account:add": "node src/cli/account.js add",
|
|
38
|
+
"account:add:headless": "node src/cli/account.js add --no-browser",
|
|
39
|
+
"account:show": "node src/cli/account.js show",
|
|
40
|
+
"account:remove": "node src/cli/account.js remove",
|
|
41
|
+
"account:verify": "node src/cli/account.js verify",
|
|
42
|
+
"account:clear": "node src/cli/account.js clear",
|
|
41
43
|
"build": "find src bin scripts \\( -name '*.js' -o -name '*.mjs' \\) -print0 | xargs -0 -n1 node --check",
|
|
42
44
|
"test": "node --test tests/*.test.js",
|
|
43
45
|
"test:unit": "node --test tests/unit/*.test.js",
|
|
44
|
-
"test:all": "
|
|
46
|
+
"test:all": "npm run test:unit && npm test",
|
|
45
47
|
"test:api": "node --test tests/api.test.js",
|
|
46
48
|
"test:routing": "node --test tests/routing.test.js",
|
|
47
49
|
"test:cors": "node --test tests/cors_security.test.js",
|