claude-codex-proxy 1.0.5-beta.13 → 1.0.5-beta.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.
Files changed (41) hide show
  1. package/README.md +272 -0
  2. package/bin/cli.js +2 -37
  3. package/package.json +1 -1
  4. package/public/css/style.css +9 -210
  5. package/public/index.html +926 -32
  6. package/public/js/app.js +744 -115
  7. package/src/account-manager.js +3 -34
  8. package/src/account-rotation/rate-limits.js +26 -4
  9. package/src/account-rotation/strategies/base-strategy.js +0 -4
  10. package/src/account-rotation/strategies/sticky-strategy.js +0 -7
  11. package/src/claude-config.js +18 -0
  12. package/src/deployment.js +49 -49
  13. package/src/direct-api.js +13 -12
  14. package/src/index.js +4 -13
  15. package/src/middleware/auth.js +11 -46
  16. package/src/middleware/credentials.js +3 -13
  17. package/src/model-api.js +0 -60
  18. package/src/response-streamer.js +5 -5
  19. package/src/routes/accounts-route.js +2 -106
  20. package/src/routes/api-routes.js +35 -61
  21. package/src/routes/chat-route.js +4 -25
  22. package/src/routes/claude-config-route.js +15 -22
  23. package/src/routes/logs-route.js +2 -21
  24. package/src/routes/messages-route.js +13 -39
  25. package/src/routes/settings-route.js +5 -36
  26. package/src/server-settings.js +2 -18
  27. package/src/utils/logger.js +0 -18
  28. package/public/login.html +0 -32
  29. package/public/views/accounts-modals.html +0 -215
  30. package/public/views/accounts.html +0 -202
  31. package/public/views/client-api-keys-modals.html +0 -55
  32. package/public/views/client-api-keys.html +0 -69
  33. package/public/views/dashboard.html +0 -90
  34. package/public/views/empty.html +0 -0
  35. package/public/views/logs.html +0 -99
  36. package/public/views/settings.html +0 -123
  37. package/src/admin-path.js +0 -33
  38. package/src/client-key-usage.js +0 -125
  39. package/src/model-pricing.js +0 -96
  40. package/src/routes/client-quota-route.js +0 -25
  41. package/src/utils/proxy-logging.js +0 -5
@@ -1,96 +0,0 @@
1
- /**
2
- * Upstream Codex model pricing in USD per one million tokens.
3
- * Long-context pricing applies when input tokens exceed 272,000.
4
- */
5
-
6
- export const PRICE_UNIT_TOKENS = 1_000_000;
7
- export const LONG_CONTEXT_THRESHOLD_TOKENS = 272_000;
8
-
9
- const STANDARD_PRICING = {
10
- 'gpt-5.6-sol': {
11
- input: 5,
12
- cachedInput: 0.5,
13
- cacheWrite: 6.25,
14
- output: 30
15
- },
16
- 'gpt-5.6-terra': {
17
- input: 2.5,
18
- cachedInput: 0.25,
19
- cacheWrite: 3.125,
20
- output: 15
21
- },
22
- 'gpt-5.4-mini': {
23
- input: 0.75,
24
- cachedInput: 0.075,
25
- cacheWrite: 0,
26
- output: 4.5
27
- }
28
- };
29
-
30
- const LONG_CONTEXT_PRICING = {
31
- 'gpt-5.6-sol': {
32
- input: 10,
33
- cachedInput: 1,
34
- cacheWrite: 12.5,
35
- output: 45
36
- },
37
- 'gpt-5.6-terra': {
38
- input: 5,
39
- cachedInput: 0.5,
40
- cacheWrite: 6.25,
41
- output: 22.5
42
- }
43
- };
44
-
45
- /**
46
- * Returns the applicable USD-per-million-token price record for an upstream
47
- * model. Models without a configured price return null.
48
- */
49
- export function getModelPricing(model, inputTokens = 0) {
50
- const normalizedModel = String(model || '').toLowerCase();
51
- const standard = STANDARD_PRICING[normalizedModel];
52
- if (!standard) return null;
53
-
54
- const usesLongContext = Number(inputTokens) > LONG_CONTEXT_THRESHOLD_TOKENS;
55
- const longContext = usesLongContext ? LONG_CONTEXT_PRICING[normalizedModel] : null;
56
-
57
- return {
58
- ...standard,
59
- ...(longContext || {}),
60
- model: normalizedModel,
61
- priceUnitTokens: PRICE_UNIT_TOKENS,
62
- longContext: Boolean(longContext)
63
- };
64
- }
65
-
66
- /**
67
- * Calculates a request charge from Responses API usage and returns it in
68
- * integer microdollars. Cached input and cache-write tokens are included in
69
- * input_tokens, so both are removed from standard input before applying their
70
- * respective prices.
71
- */
72
- export function calculateUsageCostMicrousd(model, usage = {}) {
73
- const inputTokens = Math.max(0, Number(usage.input_tokens) || 0);
74
- const outputTokens = Math.max(0, Number(usage.output_tokens) || 0);
75
- const cachedInputTokens = Math.min(
76
- inputTokens,
77
- Math.max(0, Number(usage.cache_read_input_tokens ?? usage.input_tokens_details?.cached_tokens) || 0)
78
- );
79
- const cacheWriteTokens = Math.max(0, Number(usage.input_tokens_details?.cache_write_tokens) || 0);
80
- const pricing = getModelPricing(model, inputTokens);
81
- if (!pricing) return null;
82
-
83
- const uncachedInputTokens = Math.max(0, inputTokens - cachedInputTokens - cacheWriteTokens);
84
- const usd = (
85
- (uncachedInputTokens * pricing.input)
86
- + (cachedInputTokens * pricing.cachedInput)
87
- + (cacheWriteTokens * pricing.cacheWrite)
88
- + (outputTokens * pricing.output)
89
- ) / PRICE_UNIT_TOKENS;
90
-
91
- return Math.round(usd * 1_000_000);
92
- }
93
-
94
- export { STANDARD_PRICING, LONG_CONTEXT_PRICING };
95
-
96
- export default { getModelPricing, calculateUsageCostMicrousd };
@@ -1,25 +0,0 @@
1
- import { DEFAULT_CLIENT_KEY_WEEKLY_LIMIT_USD } from '../server-settings.js';
2
-
3
- /**
4
- * Returns the authenticated client key's weekly quota using Claude Code's
5
- * utilization response shape, so the terminal can consume it directly.
6
- */
7
- export function handleGetClientQuota(req, res) {
8
- const quota = req.clientApiKeyQuota;
9
- const weeklyLimitUsd = quota?.weeklyLimitUsd ?? DEFAULT_CLIENT_KEY_WEEKLY_LIMIT_USD;
10
- const utilization = quota && weeklyLimitUsd > 0
11
- ? Math.min(100, Math.max(0, (quota.consumedUsd / weeklyLimitUsd) * 100))
12
- : null;
13
-
14
- return res.json({
15
- five_hour: null,
16
- seven_day: quota ? {
17
- utilization,
18
- resets_at: quota.nextPeriodStart
19
- } : null,
20
- seven_day_oauth_apps: null,
21
- seven_day_opus: null,
22
- seven_day_sonnet: null,
23
- extra_usage: null
24
- });
25
- }
@@ -1,5 +0,0 @@
1
- import { getServerSettings } from '../server-settings.js';
2
-
3
- export function shouldLogRawProxyPayloads() {
4
- return getServerSettings().logRawProxyPayloads === true;
5
- }