@kamel-ahmed/proxy-claude 1.0.1 → 1.0.3

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/bin/cli.js CHANGED
@@ -22,10 +22,13 @@ proxy-claude v${packageJson.version}
22
22
  Proxy server for using Antigravity's Claude models with Claude Code CLI.
23
23
 
24
24
  USAGE:
25
- proxy-claude <command> [options]
25
+ proxy-claude [command] [options]
26
26
 
27
27
  COMMANDS:
28
- start Start the proxy server (default port: 8080)
28
+ (default) Start proxy + launch Claude Code (interactive)
29
+ run Same as default - start proxy + Claude Code
30
+ start Start the proxy server only (foreground)
31
+ web Same as start - server with web dashboard
29
32
  accounts Manage Google accounts (interactive)
30
33
  accounts add Add a new Google account via OAuth
31
34
  accounts list List all configured accounts
@@ -33,7 +36,7 @@ COMMANDS:
33
36
  accounts verify Verify account tokens are valid
34
37
  accounts clear Remove all accounts
35
38
  refresh Check and refresh account tokens
36
- setup Install Claude Code CLI and create global 'proxy-claude' command
39
+ setup Install Claude Code CLI (if needed)
37
40
 
38
41
  OPTIONS:
39
42
  --help, -h Show this help message
@@ -43,10 +46,11 @@ ENVIRONMENT:
43
46
  PORT Server port (default: 8080)
44
47
 
45
48
  EXAMPLES:
46
- proxy-claude start
47
- PORT=3000 proxy-claude start
48
- proxy-claude accounts add
49
- proxy-claude accounts list
49
+ proxy-claude # Start proxy + Claude Code
50
+ proxy-claude run # Same as above
51
+ proxy-claude start # Start proxy server only
52
+ PORT=3000 proxy-claude # Use custom port
53
+ proxy-claude accounts add # Add Google account
50
54
 
51
55
  CONFIGURATION:
52
56
  Claude Code CLI (~/.claude/settings.json):
@@ -81,11 +85,94 @@ async function main() {
81
85
  break;
82
86
 
83
87
  case 'start':
84
- case undefined:
85
- // Default to starting the server
88
+ // Start the server only
89
+ await import('../src/index.js');
90
+ break;
91
+
92
+ case 'web':
93
+ // Alias for start (server with web dashboard)
86
94
  await import('../src/index.js');
87
95
  break;
88
96
 
97
+ case undefined:
98
+ case 'run': {
99
+ // Default: Start proxy in background + launch Claude Code
100
+ const { spawn, execSync } = await import('child_process');
101
+ const port = process.env.PORT || 8080;
102
+
103
+ console.log(`\x1b[34mStarting Antigravity Claude Proxy on port ${port}...\x1b[0m`);
104
+
105
+ // Start proxy in background
106
+ const proxyProcess = spawn('node', [join(__dirname, '..', 'src', 'index.js')], {
107
+ detached: true,
108
+ stdio: 'ignore',
109
+ env: { ...process.env, PORT: port }
110
+ });
111
+ proxyProcess.unref();
112
+
113
+ // Wait for proxy to be ready
114
+ console.log('Waiting for proxy to be ready...');
115
+ let ready = false;
116
+ for (let i = 0; i < 60; i++) {
117
+ try {
118
+ execSync(`curl -s http://localhost:${port}/health`, { stdio: 'ignore' });
119
+ ready = true;
120
+ break;
121
+ } catch {
122
+ await new Promise(r => setTimeout(r, 500));
123
+ }
124
+ }
125
+
126
+ if (!ready) {
127
+ console.error('\x1b[31mError: Proxy failed to start within 30 seconds.\x1b[0m');
128
+ process.exit(1);
129
+ }
130
+
131
+ console.log(`\x1b[32m✓ Proxy is ready on port ${port}!\x1b[0m\n`);
132
+
133
+ // Check if claude is installed
134
+ try {
135
+ execSync('which claude', { stdio: 'ignore' });
136
+ } catch {
137
+ console.error('\x1b[31mError: Claude Code CLI not found.\x1b[0m');
138
+ console.error('Install it with: npm install -g @anthropic-ai/claude-code');
139
+ process.exit(1);
140
+ }
141
+
142
+ // Launch Claude with proxy config
143
+ const claudeArgs = args.slice(command === 'run' ? 1 : 0);
144
+ const claudeProcess = spawn('claude', claudeArgs, {
145
+ stdio: 'inherit',
146
+ env: {
147
+ ...process.env,
148
+ ANTHROPIC_BASE_URL: `http://localhost:${port}`,
149
+ ANTHROPIC_API_KEY: 'dummy'
150
+ }
151
+ });
152
+
153
+ // Cleanup on exit
154
+ const cleanup = () => {
155
+ console.log('\n\x1b[33mStopping Antigravity Claude Proxy...\x1b[0m');
156
+ try {
157
+ execSync(`lsof -ti tcp:${port} | xargs kill 2>/dev/null`, { stdio: 'ignore' });
158
+ } catch {}
159
+ console.log('\x1b[32m✓ Proxy stopped\x1b[0m');
160
+ };
161
+
162
+ claudeProcess.on('close', (code) => {
163
+ cleanup();
164
+ process.exit(code || 0);
165
+ });
166
+
167
+ process.on('SIGINT', () => {
168
+ claudeProcess.kill('SIGINT');
169
+ });
170
+ process.on('SIGTERM', () => {
171
+ claudeProcess.kill('SIGTERM');
172
+ });
173
+ break;
174
+ }
175
+
89
176
  case 'accounts': {
90
177
  // Pass remaining args to accounts CLI
91
178
  const subCommand = args[1] || 'add';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamel-ahmed/proxy-claude",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Proxy server to use Antigravity's Claude models with Claude Code CLI - run 'proxy-claude' to start",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/cli/setup.js CHANGED
@@ -65,7 +65,7 @@ async function createProxyLauncher() {
65
65
  # proxy-claude - Full CLI for Antigravity Claude Proxy
66
66
  # This script provides complete control over the proxy and Claude Code.
67
67
 
68
- VERSION="1.0.1"
68
+ VERSION="1.0.2"
69
69
  PORT=\${PORT:-${DEFAULT_PORT || 8080}}
70
70
  PROXY_PID=""
71
71
 
package/src/server.js CHANGED
@@ -638,7 +638,7 @@ app.post('/refresh-token', async (req, res) => {
638
638
  app.get('/v1/models', async (req, res) => {
639
639
  try {
640
640
  await ensureInitialized();
641
- const account = accountManager.pickNext();
641
+ const { account } = accountManager.selectAccount();
642
642
  if (!account) {
643
643
  return res.status(503).json({
644
644
  type: 'error',