@kamel-ahmed/proxy-claude 1.0.2 → 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 +96 -9
- package/package.json +1 -1
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
|
|
25
|
+
proxy-claude [command] [options]
|
|
26
26
|
|
|
27
27
|
COMMANDS:
|
|
28
|
-
|
|
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
|
|
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
|
|
47
|
-
|
|
48
|
-
proxy-claude
|
|
49
|
-
proxy-claude
|
|
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
|
-
|
|
85
|
-
|
|
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