claudmax 2.0.1 → 2.0.4

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/index.js CHANGED
@@ -76,7 +76,7 @@ function verifyConnection(apiKey) {
76
76
  const options = {
77
77
  hostname: API_BASE.replace('https://', ''),
78
78
  port: 443,
79
- path: '/api/v1/key-status',
79
+ path: '/api/v1/key-check',
80
80
  method: 'POST',
81
81
  headers: {
82
82
  'Content-Type': 'application/json',
@@ -90,7 +90,7 @@ function verifyConnection(apiKey) {
90
90
  res.on('data', (chunk) => { body += chunk; });
91
91
  res.on('end', () => {
92
92
  try {
93
- // key-status uses POST with { apiKey } field
93
+ // key-check uses POST with { apiKey } field
94
94
  const data = JSON.parse(body);
95
95
  resolve({ status: res.statusCode, data, ok: true });
96
96
  } catch {
@@ -102,7 +102,7 @@ function verifyConnection(apiKey) {
102
102
  req.on('error', (err) => resolve({ status: 0, error: err.message, ok: false }));
103
103
  req.on('timeout', () => { req.destroy(); resolve({ status: 0, error: 'timeout', ok: false }); });
104
104
 
105
- // key-status endpoint expects { apiKey } in body
105
+ // key-check endpoint expects { apiKey } in body
106
106
  req.write(JSON.stringify({ apiKey }));
107
107
  req.end();
108
108
  });
@@ -123,11 +123,11 @@ function configureClaudeCLI(apiKey) {
123
123
  env: {
124
124
  ANTHROPIC_AUTH_TOKEN: apiKey,
125
125
  ANTHROPIC_BASE_URL: API_BASE + '/v1',
126
- ANTHROPIC_MODEL: 'Opus 4.6',
127
- ANTHROPIC_SMALL_FAST_MODEL: 'Haiku 4.5',
128
- ANTHROPIC_DEFAULT_SONNET_MODEL: 'Sonnet 4.5',
129
- ANTHROPIC_DEFAULT_OPUS_MODEL: 'Opus 4.6',
130
- ANTHROPIC_DEFAULT_HAIKU_MODEL: 'Haiku 4.5',
126
+ ANTHROPIC_MODEL: 'claude-opus-4-6',
127
+ ANTHROPIC_SMALL_FAST_MODEL: 'claude-haiku-4-5',
128
+ ANTHROPIC_DEFAULT_SONNET_MODEL: 'claude-sonnet-4-6',
129
+ ANTHROPIC_DEFAULT_OPUS_MODEL: 'claude-opus-4-6',
130
+ ANTHROPIC_DEFAULT_HAIKU_MODEL: 'claude-haiku-4-5',
131
131
  CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1',
132
132
  },
133
133
  hasCompletedOnboarding: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudmax",
3
- "version": "2.0.1",
3
+ "version": "2.0.4",
4
4
  "description": "ClaudMax CLI — Configure Claude Code, Cursor, Windsurf, Cline, and Roo Code to use ClaudMax API gateway with one command",
5
5
  "main": "index.js",
6
6
  "bin": {
package/bin/claudmax.js DELETED
@@ -1,293 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * ClaudMax CLI
5
- * One command: npx claudmax
6
- * Setup in seconds, start building immediately.
7
- */
8
-
9
- const fs = require('fs');
10
- const path = require('path');
11
- const { execSync } = require('child_process');
12
-
13
- // ─── Constants ────────────────────────────────────────────────
14
- const BOLD = '\x1b[1m';
15
- const ORANGE = '\x1b[33m';
16
- const GREEN = '\x1b[32m';
17
- const RED = '\x1b[31m';
18
- const DIM = '\x1b[2m';
19
- const RESET = '\x1b[0m';
20
- const CYAN = '\x1b[36m';
21
-
22
- const CONFIG_DIR = path.join(process.env.HOME, '.claudmax');
23
- const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
24
- const API_BASE = process.env.CLAUDEMAX_API_BASE || 'https://api.claudmax.pro';
25
- const API_KEY_REGEX = /^sk-cmx_[a-zA-Z0-9]{32}$/;
26
-
27
- // ─── Helpers ──────────────────────────────────────────────────
28
- function printBanner() {
29
- console.log('');
30
- console.log(`${ORANGE}╔══════════════════════════════════════════════════════════╗${RESET}`);
31
- console.log(`${ORANGE}║${RESET} ${ORANGE}║${RESET}`);
32
- console.log(`${ORANGE}║${RESET} ${BOLD}⚡ ClaudMax${RESET} ${ORANGE}║${RESET}`);
33
- console.log(`${ORANGE}║${RESET} ${ORANGE}║${RESET}`);
34
- console.log(`${ORANGE}╚══════════════════════════════════════════════════════════╝${RESET}`);
35
- console.log('');
36
- }
37
-
38
- function printSuccess(msg) {
39
- console.log(`${GREEN}✓${RESET} ${msg}`);
40
- }
41
-
42
- function printError(msg) {
43
- console.log(`${RED}✗${RESET} ${msg}`);
44
- }
45
-
46
- function printInfo(msg) {
47
- console.log(`${DIM}${msg}${RESET}`);
48
- }
49
-
50
- function getConfig() {
51
- if (!fs.existsSync(CONFIG_FILE)) return null;
52
- try {
53
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
54
- } catch {
55
- return null;
56
- }
57
- }
58
-
59
- function saveConfig(config) {
60
- fs.mkdirSync(CONFIG_DIR, { recursive: true });
61
- fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
62
- }
63
-
64
- // ─── API Calls ────────────────────────────────────────────────
65
- async function apiStatus(apiKey) {
66
- try {
67
- const res = await fetch(`${API_BASE}/api/v1/key-status`, {
68
- method: 'POST',
69
- headers: { 'Content-Type': 'application/json' },
70
- body: JSON.stringify({ apiKey }),
71
- });
72
- return await res.json();
73
- } catch (err) {
74
- return { error: `Network error: ${err.message}` };
75
- }
76
- }
77
-
78
- async function apiCreateKey(name, tier) {
79
- try {
80
- const res = await fetch(`${API_BASE}/api/admin/keys`, {
81
- method: 'POST',
82
- headers: { 'Content-Type': 'application/json' },
83
- body: JSON.stringify({ name, tier }),
84
- });
85
- return await res.json();
86
- } catch (err) {
87
- return { error: `Network error: ${err.message}` };
88
- }
89
- }
90
-
91
- // ─── Commands ─────────────────────────────────────────────────
92
-
93
- async function cmdConfigure() {
94
- printBanner();
95
- console.log(`${BOLD}Configure your ClaudMax API key${RESET}`);
96
- console.log('');
97
- console.log(`${CYAN}Get Your API Key: https://www.claudmax.pro/support${RESET}`);
98
- console.log('');
99
-
100
- const config = getConfig();
101
- if (config?.apiKey) {
102
- console.log(`${DIM}Current key: ${config.apiKey.slice(0, 12)}...${RESET}`);
103
- console.log('');
104
- }
105
-
106
- // Prompt for key
107
- process.stdout.write(`${BOLD}Enter your ClaudMax API key:${RESET}\n`);
108
- process.stdout.write(`${DIM}API Key (sk-cmx_...): ${RESET}`);
109
-
110
- const readline = require('readline');
111
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
112
- const apiKey = await new Promise(resolve => rl.question('', resolve));
113
- rl.close();
114
- console.log('');
115
-
116
- const trimmedKey = apiKey.trim();
117
-
118
- if (!trimmedKey) {
119
- printError('API key cannot be empty');
120
- process.exit(1);
121
- }
122
-
123
- if (!API_KEY_REGEX.test(trimmedKey)) {
124
- printError('Invalid API key format. Keys start with sk-cmx_ followed by 32 characters.');
125
- process.exit(1);
126
- }
127
-
128
- // Validate key
129
- process.stdout.write(`${DIM}Validating API key... ${RESET}`);
130
- const status = await apiStatus(trimmedKey);
131
-
132
- if (status.error) {
133
- console.log('');
134
- printError(`Invalid API key: ${status.error}`);
135
- process.exit(1);
136
- }
137
-
138
- // Save config
139
- saveConfig({ apiKey: trimmedKey, baseUrl: API_BASE });
140
-
141
- console.log('');
142
- printSuccess(`Connected! Configuration saved.`);
143
- console.log('');
144
- console.log(`${BOLD}Your key details:${RESET}`);
145
- console.log(` Name: ${status.name || 'ClaudeMax Key'}`);
146
- console.log(` Tier: ${(status.tier || 'free').toUpperCase()}`);
147
- console.log(` Status: ${status.isActive ? `${GREEN}Active${RESET}` : `${RED}Revoked${RESET}`}`);
148
- console.log('');
149
- console.log(`${BOLD}Next steps:${RESET}`);
150
- console.log(` Add these to your shell profile (~/.bashrc or ~/.zshrc):\n`);
151
- console.log(` ${ORANGE}export ANTHROPIC_BASE_URL=${API_BASE}${RESET}`);
152
- console.log(` ${ORANGE}export ANTHROPIC_API_KEY=${trimmedKey}${RESET}`);
153
- console.log('');
154
- console.log(` Then reload: ${DIM}source ~/.bashrc${RESET}`);
155
- console.log('');
156
- }
157
-
158
- async function cmdStatus() {
159
- printBanner();
160
-
161
- const config = getConfig();
162
- if (!config?.apiKey) {
163
- printError('No API key configured. Run: claudmax configure');
164
- process.exit(1);
165
- }
166
-
167
- process.stdout.write(`${DIM}Checking status... ${RESET}`);
168
- const status = await apiStatus(config.apiKey);
169
-
170
- if (status.error) {
171
- console.log('');
172
- printError(`Failed: ${status.error}`);
173
- process.exit(1);
174
- }
175
-
176
- console.log('');
177
- console.log(`${BOLD}API Key Status${RESET}`);
178
- console.log(` Name: ${status.name || 'ClaudeMax Key'}`);
179
- console.log(` Tier: ${(status.tier || 'free').toUpperCase()}`);
180
- console.log(` Status: ${status.isActive ? `${GREEN}Active${RESET}` : `${RED}Revoked${RESET}`}`);
181
- console.log(` Requests: ${status.requestsUsed?.toLocaleString() || 0} / ${status.requestsLimit?.toLocaleString() || '∞'}`);
182
- console.log(` Tokens: ${((status.tokensUsed||0)/1000).toFixed(1)}K / ${((status.tokensLimit||0)/1000).toFixed(1)}K`);
183
- console.log(` Window: ${status.windowResetAt ? new Date(status.windowResetAt).toLocaleString() : 'N/A'}`);
184
- console.log(` Created: ${status.createdAt ? new Date(status.createdAt).toLocaleDateString() : 'N/A'}`);
185
- console.log(` Last Used: ${status.lastUsedAt ? new Date(status.lastUsedAt).toLocaleString() : 'Never'}`);
186
- console.log('');
187
-
188
- // Usage bars
189
- if (status.requestsLimit) {
190
- const reqPct = Math.min(100, (status.requestsUsed / status.requestsLimit) * 100);
191
- const bar = '█'.repeat(Math.floor(reqPct / 5)) + '░'.repeat(20 - Math.floor(reqPct / 5));
192
- const barColor = reqPct > 80 ? RED : reqPct > 60 ? '\x1b[33m' : GREEN;
193
- console.log(` Requests: [${barColor}${bar}${RESET}] ${reqPct.toFixed(0)}%`);
194
- }
195
- console.log('');
196
- }
197
-
198
- async function cmdCreate() {
199
- printBanner();
200
- console.log(`${BOLD}Create a new API key${RESET}`);
201
- console.log('');
202
-
203
- const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
204
-
205
- const ask = (q) => new Promise(res => {
206
- process.stdout.write(`${q}: `);
207
- rl.question('', res);
208
- });
209
-
210
- const name = await ask('Key name (e.g. My App)');
211
- console.log('');
212
- console.log('Available tiers:');
213
- console.log(' 1. Free (100 req/5h, 100K tokens/month)');
214
- console.log(' 2. 5x Max (500 req/5h, 500K tokens/month)');
215
- console.log(' 3. 20x Max (2000 req/5h, 2M tokens/month)');
216
- const tierChoice = await ask('Choose tier (1-3)');
217
- rl.close();
218
-
219
- const tiers = { '1': 'free', '2': '5x', '3': '20x' };
220
- const tier = tiers[tierChoice.trim()] || 'free';
221
-
222
- process.stdout.write(`${DIM}Creating API key... ${RESET}`);
223
- const result = await apiCreateKey(name || 'ClaudeMax Key', tier);
224
-
225
- if (result.error || !result.key) {
226
- console.log('');
227
- printError(`Failed: ${result.error || 'Unknown error'}`);
228
- console.log(`${DIM}Tip: You need an active ClaudeMax Pro subscription to create keys.${RESET}`);
229
- process.exit(1);
230
- }
231
-
232
- console.log('');
233
- console.log(`${GREEN}✓ API key created!${RESET}`);
234
- console.log('');
235
- console.log(` ${BOLD}${result.key}${RESET}`);
236
- console.log('');
237
- console.log(`${RED}⚠ Save this key now — you won't see it again!${RESET}`);
238
- console.log('');
239
-
240
- // Auto-configure
241
- saveConfig({ apiKey: result.key, baseUrl: API_BASE });
242
- printSuccess('Key saved to ~/.claudmax/config.json');
243
- console.log('');
244
- }
245
-
246
- function cmdHelp() {
247
- printBanner();
248
- console.log(`${BOLD}ClaudMax CLI${RESET} — Claude API gateway setup in seconds\n`);
249
- console.log(`${BOLD}Usage:${RESET}`);
250
- console.log(' npx claudmax Open setup wizard');
251
- console.log(' claudmax configure Configure API key');
252
- console.log(' claudmax status Check usage & limits');
253
- console.log(' claudmax create Create new API key');
254
- console.log(' claudmax help Show this help');
255
- console.log(`${BOLD}Quick Start:${RESET}`);
256
- console.log(` ${ORANGE}curl -fsSL https://claudmax.pro/setup.sh | bash${RESET}`);
257
- console.log(` ${ORANGE}npx claudmax${RESET}\n`);
258
- }
259
-
260
- // ─── Main ─────────────────────────────────────────────────────
261
- async function main() {
262
- const cmd = process.argv[2] || 'configure';
263
-
264
- switch (cmd) {
265
- case 'configure':
266
- case 'setup':
267
- case 'init':
268
- await cmdConfigure();
269
- break;
270
- case 'status':
271
- case 'check':
272
- await cmdStatus();
273
- break;
274
- case 'create':
275
- case 'new':
276
- await cmdCreate();
277
- break;
278
- case 'help':
279
- case '--help':
280
- case '-h':
281
- cmdHelp();
282
- break;
283
- default:
284
- printError(`Unknown command: ${cmd}`);
285
- console.log(`Run ${ORANGE}claudmax help${RESET} for usage.`);
286
- process.exit(1);
287
- }
288
- }
289
-
290
- main().catch(err => {
291
- console.error(`${RED}Error:${RESET}`, err.message);
292
- process.exit(1);
293
- });
Binary file
Binary file