claude-codex-proxy 1.0.5-beta.0 → 1.0.5-beta.10
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/README.md +16 -0
- package/bin/cli.js +30 -2
- package/package.json +1 -1
- package/public/css/style.css +210 -9
- package/public/index.html +32 -926
- package/public/js/app.js +98 -744
- package/public/login.html +32 -0
- package/public/views/accounts-modals.html +159 -0
- package/public/views/accounts.html +183 -0
- package/public/views/client-api-keys-modals.html +55 -0
- package/public/views/client-api-keys.html +69 -0
- package/public/views/dashboard.html +90 -0
- package/public/views/empty.html +0 -0
- package/public/views/logs.html +99 -0
- package/public/views/settings.html +123 -0
- package/src/account-rotation/rate-limits.js +0 -26
- package/src/claude-config.js +0 -18
- package/src/client-key-usage.js +125 -0
- package/src/deployment.js +49 -0
- package/src/direct-api.js +12 -13
- package/src/index.js +20 -8
- package/src/middleware/auth.js +49 -15
- package/src/model-pricing.js +96 -0
- package/src/response-streamer.js +5 -5
- package/src/routes/api-routes.js +13 -2
- package/src/routes/chat-route.js +25 -4
- package/src/routes/claude-config-route.js +53 -26
- package/src/routes/client-quota-route.js +25 -0
- package/src/routes/logs-route.js +21 -2
- package/src/routes/messages-route.js +30 -6
- package/src/routes/settings-route.js +36 -5
- package/src/server-settings.js +18 -2
- package/src/server.js +3 -2
- package/src/utils/logger.js +18 -0
- package/src/utils/proxy-logging.js +5 -0
package/README.md
CHANGED
|
@@ -95,6 +95,22 @@ The startup prompt asks you to choose **local deployment** or **public deploymen
|
|
|
95
95
|
- Local deployment: no access key is required.
|
|
96
96
|
- Public deployment: enter the UI/admin access key to unlock the Web Dashboard and management APIs. After startup, create and manage Claude Code client API keys from **Settings → Claude Code Client API Keys**.
|
|
97
97
|
|
|
98
|
+
For non-interactive deployments, pass the mode and admin key directly. The command-line options take precedence over environment variables:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
claude-codex-proxy start --mode public --admin-key "your-admin-key"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
PROXY_DEPLOYMENT_MODE=public PROXY_ADMIN_KEY="your-admin-key" claude-codex-proxy start
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
PowerShell:
|
|
109
|
+
|
|
110
|
+
```powershell
|
|
111
|
+
$env:PROXY_DEPLOYMENT_MODE="public"; $env:PROXY_ADMIN_KEY="your-admin-key"; npm start
|
|
112
|
+
```
|
|
113
|
+
|
|
98
114
|
The server will start at `http://localhost:8081` by default. To use another port:
|
|
99
115
|
|
|
100
116
|
```bash
|
package/bin/cli.js
CHANGED
|
@@ -38,13 +38,19 @@ COMMANDS:
|
|
|
38
38
|
OPTIONS:
|
|
39
39
|
--help, -h Show this help message
|
|
40
40
|
--version, -v Show version number
|
|
41
|
+
--mode <local|public> Deployment mode for the start command
|
|
42
|
+
--admin-key <key> UI/admin access key for public deployment
|
|
41
43
|
|
|
42
44
|
ENVIRONMENT:
|
|
43
45
|
PORT Server port (default: 8081)
|
|
46
|
+
PROXY_DEPLOYMENT_MODE Deployment mode (local or public)
|
|
47
|
+
PROXY_ADMIN_KEY UI/admin access key for public deployment
|
|
44
48
|
|
|
45
49
|
EXAMPLES:
|
|
46
50
|
claude-codex-proxy start
|
|
47
51
|
PORT=3000 claude-codex-proxy start
|
|
52
|
+
claude-codex-proxy start --mode public --admin-key "your-admin-key"
|
|
53
|
+
PROXY_DEPLOYMENT_MODE=public PROXY_ADMIN_KEY="your-admin-key" claude-codex-proxy start
|
|
48
54
|
claude-codex-proxy accounts add
|
|
49
55
|
claude-codex-proxy accounts add --no-browser
|
|
50
56
|
claude-codex-proxy accounts list
|
|
@@ -101,12 +107,34 @@ async function askRequiredKey(label) {
|
|
|
101
107
|
}
|
|
102
108
|
}
|
|
103
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Reads an option value from either `--option value` or `--option=value`.
|
|
112
|
+
* @param {string} option
|
|
113
|
+
* @returns {string|undefined}
|
|
114
|
+
*/
|
|
115
|
+
function getOptionValue(option) {
|
|
116
|
+
const optionIndex = args.indexOf(option);
|
|
117
|
+
if (optionIndex !== -1) {
|
|
118
|
+
return args[optionIndex + 1];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const prefixedOption = `${option}=`;
|
|
122
|
+
const matchedOption = args.find((arg) => arg.startsWith(prefixedOption));
|
|
123
|
+
return matchedOption?.slice(prefixedOption.length);
|
|
124
|
+
}
|
|
125
|
+
|
|
104
126
|
async function configureStartMode() {
|
|
105
|
-
const
|
|
127
|
+
const requestedMode = getOptionValue('--mode') || process.env.PROXY_DEPLOYMENT_MODE;
|
|
128
|
+
if (requestedMode && !['local', 'public'].includes(requestedMode)) {
|
|
129
|
+
throw new Error('Deployment mode must be "local" or "public".');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const mode = requestedMode || await askDeploymentMode();
|
|
106
133
|
process.env.PROXY_DEPLOYMENT_MODE = mode;
|
|
107
134
|
|
|
108
135
|
if (mode === 'public') {
|
|
109
|
-
|
|
136
|
+
const adminKey = getOptionValue('--admin-key') || process.env.PROXY_ADMIN_KEY;
|
|
137
|
+
process.env.PROXY_ADMIN_KEY = adminKey || await askRequiredKey('Enter UI/admin access key');
|
|
110
138
|
}
|
|
111
139
|
}
|
|
112
140
|
|
package/package.json
CHANGED
package/public/css/style.css
CHANGED
|
@@ -67,23 +67,97 @@ body::before {
|
|
|
67
67
|
|
|
68
68
|
.shadow-neon-purple { --tw-shadow-color: rgba(168, 85, 247, 0.4); box-shadow: 0 0 15px var(--tw-shadow-color); }
|
|
69
69
|
|
|
70
|
-
.
|
|
71
|
-
|
|
72
|
-
color: #9ca3af;
|
|
73
|
-
border-right: 2px solid transparent;
|
|
70
|
+
.sidebar-content {
|
|
71
|
+
padding: 1.25rem 0.75rem;
|
|
74
72
|
}
|
|
75
73
|
|
|
76
|
-
.
|
|
77
|
-
|
|
74
|
+
.sidebar-brand {
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
gap: 0.75rem;
|
|
78
|
+
margin: 0 0.5rem 1.75rem;
|
|
79
|
+
padding: 0.5rem;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.sidebar-brand-mark {
|
|
83
|
+
display: grid;
|
|
84
|
+
width: 2.25rem;
|
|
85
|
+
height: 2.25rem;
|
|
86
|
+
place-items: center;
|
|
87
|
+
border: 1px solid rgba(192, 132, 252, 0.4);
|
|
88
|
+
border-radius: 0.65rem;
|
|
89
|
+
background: linear-gradient(135deg, rgba(168, 85, 247, 0.95), rgba(37, 99, 235, 0.9));
|
|
90
|
+
box-shadow: 0 0 18px rgba(168, 85, 247, 0.28);
|
|
78
91
|
color: white;
|
|
79
|
-
|
|
92
|
+
font-size: 0.7rem;
|
|
93
|
+
font-weight: 700;
|
|
94
|
+
letter-spacing: 0.08em;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.sidebar-brand-title { color: #f5f3ff; font-size: 0.875rem; font-weight: 600; }
|
|
98
|
+
.sidebar-brand-subtitle { margin-top: 0.125rem; color: #6b7280; font-family: 'JetBrains Mono', monospace; font-size: 0.625rem; }
|
|
99
|
+
|
|
100
|
+
.sidebar-section-title {
|
|
101
|
+
margin: 1.25rem 0.75rem 0.5rem;
|
|
102
|
+
color: #64748b;
|
|
103
|
+
font-family: 'JetBrains Mono', monospace;
|
|
104
|
+
font-size: 0.625rem;
|
|
105
|
+
font-weight: 600;
|
|
106
|
+
letter-spacing: 0.12em;
|
|
107
|
+
text-transform: uppercase;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.sidebar-section-title:first-of-type { margin-top: 0; }
|
|
111
|
+
.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; }
|
|
112
|
+
|
|
113
|
+
.nav-item {
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
gap: 0.75rem;
|
|
117
|
+
min-height: 2.75rem;
|
|
118
|
+
padding: 0.625rem 0.75rem;
|
|
119
|
+
border: 1px solid transparent;
|
|
120
|
+
border-radius: 0.5rem;
|
|
121
|
+
color: #94a3b8;
|
|
122
|
+
font-size: 0.8125rem;
|
|
123
|
+
font-weight: 500;
|
|
124
|
+
text-decoration: none;
|
|
125
|
+
transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
|
|
80
126
|
}
|
|
81
127
|
|
|
128
|
+
.nav-item svg { width: 1.125rem; height: 1.125rem; flex: 0 0 auto; color: #64748b; }
|
|
129
|
+
|
|
82
130
|
.nav-item:hover {
|
|
83
|
-
background: rgba(255, 255, 255, 0.
|
|
84
|
-
color:
|
|
131
|
+
background: rgba(255, 255, 255, 0.045);
|
|
132
|
+
color: #f8fafc;
|
|
133
|
+
transform: translateX(2px);
|
|
85
134
|
}
|
|
86
135
|
|
|
136
|
+
.nav-item:hover svg { color: #c4b5fd; }
|
|
137
|
+
|
|
138
|
+
.nav-item.active {
|
|
139
|
+
border-color: rgba(168, 85, 247, 0.2);
|
|
140
|
+
background: linear-gradient(90deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.055));
|
|
141
|
+
box-shadow: inset 3px 0 0 var(--color-neon-purple);
|
|
142
|
+
color: #fff;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.nav-item.active svg { color: #c084fc; }
|
|
146
|
+
|
|
147
|
+
.sidebar-footer {
|
|
148
|
+
display: flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
gap: 0.5rem;
|
|
151
|
+
margin: auto 0.75rem 0.25rem;
|
|
152
|
+
padding-top: 1rem;
|
|
153
|
+
border-top: 1px solid rgba(42, 42, 62, 0.72);
|
|
154
|
+
color: #64748b;
|
|
155
|
+
font-family: 'JetBrains Mono', monospace;
|
|
156
|
+
font-size: 0.625rem;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.sidebar-status-dot { width: 0.375rem; height: 0.375rem; border-radius: 9999px; background: var(--color-neon-green); box-shadow: 0 0 8px rgba(34, 197, 94, 0.65); }
|
|
160
|
+
|
|
87
161
|
.view-container {
|
|
88
162
|
padding: 1.5rem;
|
|
89
163
|
max-width: 1400px;
|
|
@@ -322,6 +396,133 @@ table .btn-outline:hover {
|
|
|
322
396
|
color: white;
|
|
323
397
|
}
|
|
324
398
|
|
|
399
|
+
.client-keys-panel {
|
|
400
|
+
overflow: hidden;
|
|
401
|
+
border: 1px solid rgba(42, 42, 62, 0.72);
|
|
402
|
+
border-radius: 0.875rem;
|
|
403
|
+
background: rgba(12, 12, 20, 0.72);
|
|
404
|
+
box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.client-keys-toolbar {
|
|
408
|
+
display: flex;
|
|
409
|
+
align-items: center;
|
|
410
|
+
justify-content: space-between;
|
|
411
|
+
gap: 1.5rem;
|
|
412
|
+
padding: 1.25rem 1.5rem;
|
|
413
|
+
border-bottom: 1px solid rgba(42, 42, 62, 0.55);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.client-keys-toolbar h2 { color: #f8fafc; font-size: 0.9375rem; font-weight: 600; }
|
|
417
|
+
.client-keys-toolbar p { margin-top: 0.25rem; color: #64748b; font-size: 0.75rem; }
|
|
418
|
+
.client-keys-toolbar-actions { display: flex; align-items: center; gap: 1rem; }
|
|
419
|
+
|
|
420
|
+
.client-keys-reset { display: flex; align-items: center; gap: 0.625rem; color: #64748b; }
|
|
421
|
+
.client-keys-reset svg { width: 1rem; height: 1rem; color: #8b5cf6; }
|
|
422
|
+
.client-keys-reset div { display: flex; flex-direction: column; gap: 0.125rem; }
|
|
423
|
+
.client-keys-reset span { font-size: 0.625rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
|
|
424
|
+
.client-keys-reset strong { color: #a1a1aa; font-family: 'JetBrains Mono', monospace; font-size: 0.6875rem; font-weight: 500; }
|
|
425
|
+
|
|
426
|
+
.client-keys-new {
|
|
427
|
+
display: inline-flex;
|
|
428
|
+
align-items: center;
|
|
429
|
+
gap: 0.5rem;
|
|
430
|
+
padding: 0.55rem 0.9rem;
|
|
431
|
+
border: 1px solid rgba(168, 85, 247, 0.65);
|
|
432
|
+
border-radius: 0.5rem;
|
|
433
|
+
background: linear-gradient(135deg, #9333ea, #7c3aed);
|
|
434
|
+
box-shadow: 0 8px 20px rgba(126, 34, 206, 0.22);
|
|
435
|
+
color: #fff;
|
|
436
|
+
font-size: 0.75rem;
|
|
437
|
+
font-weight: 600;
|
|
438
|
+
cursor: pointer;
|
|
439
|
+
}
|
|
440
|
+
.client-keys-new:hover { background: linear-gradient(135deg, #a855f7, #8b5cf6); }
|
|
441
|
+
.client-keys-new span { font-size: 1rem; font-weight: 400; line-height: 1; }
|
|
442
|
+
|
|
443
|
+
.client-keys-list { padding: 0.75rem; }
|
|
444
|
+
.client-key-card {
|
|
445
|
+
display: grid;
|
|
446
|
+
grid-template-columns: minmax(270px, 1.45fr) minmax(230px, 1.15fr) 130px 110px auto;
|
|
447
|
+
align-items: center;
|
|
448
|
+
gap: 1.5rem;
|
|
449
|
+
padding: 1.1rem 1rem;
|
|
450
|
+
border: 1px solid transparent;
|
|
451
|
+
border-radius: 0.7rem;
|
|
452
|
+
transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
|
|
453
|
+
}
|
|
454
|
+
.client-key-card + .client-key-card { margin-top: 0.375rem; }
|
|
455
|
+
.client-key-card:hover {
|
|
456
|
+
border-color: rgba(42, 42, 62, 0.72);
|
|
457
|
+
background: rgba(26, 26, 40, 0.48);
|
|
458
|
+
box-shadow: inset 3px 0 0 rgba(168, 85, 247, 0.72);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
.client-key-identity { display: flex; align-items: center; gap: 0.875rem; min-width: 0; }
|
|
462
|
+
.client-key-icon { display: grid; width: 2.4rem; height: 2.4rem; flex: 0 0 auto; place-items: center; border: 1px solid rgba(168, 85, 247, 0.2); border-radius: 0.65rem; background: rgba(168, 85, 247, 0.08); color: #c084fc; }
|
|
463
|
+
.client-key-icon svg { width: 1.15rem; height: 1.15rem; }
|
|
464
|
+
.client-key-fields { display: grid; grid-template-columns: minmax(110px, 1fr) minmax(100px, 0.85fr); gap: 0.625rem; min-width: 0; }
|
|
465
|
+
.client-key-fields label, .client-key-limit { display: block; min-width: 0; }
|
|
466
|
+
.client-key-fields label > span, .client-key-limit > span, .client-key-meta > span, .client-key-quota-heading > span { display: block; margin-bottom: 0.35rem; color: #64748b; font-size: 0.6rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; }
|
|
467
|
+
.client-key-fields input, .client-key-limit input {
|
|
468
|
+
width: 100%;
|
|
469
|
+
height: 2.15rem;
|
|
470
|
+
border: 1px solid rgba(42, 42, 62, 0.75);
|
|
471
|
+
border-radius: 0.45rem;
|
|
472
|
+
outline: none;
|
|
473
|
+
background: rgba(15, 15, 26, 0.62);
|
|
474
|
+
color: #e5e7eb;
|
|
475
|
+
font-size: 0.75rem;
|
|
476
|
+
transition: border-color 150ms ease, background-color 150ms ease;
|
|
477
|
+
}
|
|
478
|
+
.client-key-fields input { padding: 0 0.7rem; }
|
|
479
|
+
.client-key-fields input:focus, .client-key-limit input:focus { border-color: rgba(168, 85, 247, 0.72); background: rgba(26, 26, 40, 0.9); }
|
|
480
|
+
|
|
481
|
+
.client-key-quota-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
|
|
482
|
+
.client-key-quota-heading strong { color: #f8fafc; font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
|
|
483
|
+
.client-key-quota-heading small { color: #64748b; font-size: 0.6875rem; font-weight: 400; }
|
|
484
|
+
.client-key-progress { overflow: hidden; height: 0.35rem; border-radius: 999px; background: rgba(42, 42, 62, 0.72); }
|
|
485
|
+
.client-key-progress i { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: linear-gradient(90deg, #8b5cf6, #22d3ee); box-shadow: 0 0 10px rgba(34, 211, 238, 0.25); }
|
|
486
|
+
.client-key-quota-foot { display: flex; justify-content: space-between; margin-top: 0.4rem; color: #64748b; font-family: 'JetBrains Mono', monospace; font-size: 0.6rem; }
|
|
487
|
+
|
|
488
|
+
.client-key-limit > div { display: flex; height: 2.15rem; border: 1px solid rgba(42, 42, 62, 0.75); border-radius: 0.45rem; background: rgba(15, 15, 26, 0.62); }
|
|
489
|
+
.client-key-limit b { display: grid; width: 1.9rem; place-items: center; border-right: 1px solid rgba(42, 42, 62, 0.75); color: #64748b; font-size: 0.75rem; font-weight: 500; }
|
|
490
|
+
.client-key-limit input { height: auto; padding: 0 0.55rem; border: 0; background: transparent; font-family: 'JetBrains Mono', monospace; }
|
|
491
|
+
|
|
492
|
+
.client-key-meta strong, .client-key-meta small { display: block; font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
|
|
493
|
+
.client-key-meta strong { color: #a1a1aa; font-size: 0.6875rem; font-weight: 500; }
|
|
494
|
+
.client-key-meta small { margin-top: 0.2rem; color: #52525b; font-size: 0.625rem; }
|
|
495
|
+
.client-key-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.45rem; }
|
|
496
|
+
.client-key-save, .client-key-delete { height: 2.15rem; border-radius: 0.45rem; cursor: pointer; transition: all 150ms ease; }
|
|
497
|
+
.client-key-save { padding: 0 0.75rem; border: 1px solid rgba(168, 85, 247, 0.35); background: rgba(168, 85, 247, 0.1); color: #d8b4fe; font-size: 0.6875rem; font-weight: 600; white-space: nowrap; }
|
|
498
|
+
.client-key-save:hover { border-color: rgba(168, 85, 247, 0.65); background: rgba(168, 85, 247, 0.2); color: #fff; }
|
|
499
|
+
.client-key-delete { display: grid; width: 2.15rem; place-items: center; border: 1px solid transparent; background: transparent; color: #52525b; }
|
|
500
|
+
.client-key-delete svg { width: 1rem; height: 1rem; }
|
|
501
|
+
.client-key-delete:hover { border-color: rgba(239, 68, 68, 0.2); background: rgba(239, 68, 68, 0.08); color: #f87171; }
|
|
502
|
+
.client-key-save:disabled, .client-key-delete:disabled { opacity: 0.45; cursor: not-allowed; }
|
|
503
|
+
.client-keys-empty { padding: 4rem 1.5rem; color: #64748b; font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; text-align: center; }
|
|
504
|
+
|
|
505
|
+
@media (max-width: 1100px) {
|
|
506
|
+
.client-key-card { grid-template-columns: minmax(260px, 1.3fr) minmax(220px, 1fr) 120px auto; }
|
|
507
|
+
.client-key-meta { display: none; }
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
@media (max-width: 800px) {
|
|
511
|
+
.client-keys-toolbar { align-items: flex-start; }
|
|
512
|
+
.client-keys-toolbar-actions { align-items: flex-end; flex-direction: column-reverse; }
|
|
513
|
+
.client-key-card { grid-template-columns: 1fr; gap: 1rem; }
|
|
514
|
+
.client-key-fields { width: 100%; }
|
|
515
|
+
.client-key-actions { justify-content: flex-start; }
|
|
516
|
+
.client-key-save { flex: 1; }
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
@media (max-width: 560px) {
|
|
520
|
+
.client-keys-toolbar { flex-direction: column; }
|
|
521
|
+
.client-keys-toolbar-actions { width: 100%; align-items: stretch; }
|
|
522
|
+
.client-keys-new { justify-content: center; }
|
|
523
|
+
.client-key-fields { grid-template-columns: 1fr; }
|
|
524
|
+
}
|
|
525
|
+
|
|
325
526
|
.animate-spin {
|
|
326
527
|
animation: spin 1s linear infinite;
|
|
327
528
|
}
|