labs-claude 0.3.0 → 0.3.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/README.md +20 -4
- package/bin/labs.js +188 -40
- package/package.json +4 -3
- package/src/admin-cli.js +247 -0
- package/src/agy.js +1016 -0
- package/src/anthropic-protocol.js +84 -17
- package/src/chat/index.html +10 -1
- package/src/config.js +101 -71
- package/src/gateway-client.js +173 -124
- package/src/gemini.js +474 -0
- package/src/image-mcp.js +174 -0
- package/src/launch-args.js +15 -4
- package/src/proxy-manager.js +6 -4
- package/src/proxy.js +976 -801
- package/src/setup.js +43 -1
- package/src/ui.js +181 -0
- package/src/usage.js +42 -2
- package/src/web-mcp.js +253 -0
package/README.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# labs-claude
|
|
2
2
|
|
|
3
|
-
Run the **real Claude Code CLI** on **ElevenLabs models
|
|
3
|
+
Run the **real Claude Code CLI** on **Google Gemini 4 (`gemini-4-hydrogen`, `gemini-4-carbon`)**, **ElevenLabs models** (GPT-6 Astra, GPT-6.1 Sol, GPT-5.6 Terra, Claude Opus 5.5, GLM-52...), or **Amazon Bedrock** (GLM 5.3) — using your own API key or Google Cloud account. Claude Code stays original (tools, skills, subagents, `/model`, `/resume`, permissions) and only the model behind it changes.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install -g labs-claude
|
|
9
|
-
labs
|
|
10
|
-
labs
|
|
9
|
+
labs gemini # for Google Gemini 4 (Hydrogen / Carbon / Neon / Argon)
|
|
10
|
+
# or: labs setup (for ElevenLabs models)
|
|
11
|
+
# or: labs bedrock (for Amazon Bedrock GLM 5.3)
|
|
12
|
+
labs --model gemini
|
|
11
13
|
```
|
|
12
14
|
|
|
13
15
|
## Update
|
|
@@ -73,6 +75,20 @@ The box runs Qwen 3.8 27B (normal and uncensored, 262k context) on one RTX PRO 6
|
|
|
73
75
|
|
|
74
76
|
When the box is off, `labs` says so before Claude Code opens. Box tokens are free per token; each key can have a daily $ cap for paid models. The gateway (keys, metering, console) lives in `gateway/` and is not part of the npm package.
|
|
75
77
|
|
|
78
|
+
## Google Gemini 4 (`hydrogen` / `gemini` / `carbon` / `neon` / `argon`)
|
|
79
|
+
|
|
80
|
+
`labs --model gemini` and `labs --model hydrogen` run Google's **Gemini 4 Hydrogen** (`gemini-4-hydrogen`, 1M context, 64k replies, full tool calling + `thoughtSignature` preservation, `--effort` mapped to `thinkingLevel`). It calls Google directly over streaming SSE — no ElevenLabs account required and none of the ElevenLabs timeout/tool limits apply.
|
|
81
|
+
|
|
82
|
+
1. Run `labs gemini` and choose:
|
|
83
|
+
- **Option 1 (API key):** Paste a key from [Google AI Studio](https://aistudio.google.com/apikey) (or set `GEMINI_API_KEY` in your environment).
|
|
84
|
+
- **Option 2 (Google account via Vertex AI):** Enter your GCP Project ID and region (`global` by default), then sign in with `gcloud auth application-default login`.
|
|
85
|
+
2. Start coding:
|
|
86
|
+
- `labs --model gemini` or `labs --model hydrogen` (`gemini-4-hydrogen`)
|
|
87
|
+
- `labs --model carbon` (`gemini-4-carbon`, deep reasoning)
|
|
88
|
+
- `labs --model gemini --effort xhigh` (`LOW` / `MEDIUM` / `HIGH` / `XHIGH`)
|
|
89
|
+
|
|
90
|
+
Token usage is logged locally to `~/.labs/gemini-usage.jsonl` (view with `labs usage`).
|
|
91
|
+
|
|
76
92
|
## GLM 5.3 on Amazon Bedrock (your own AWS account)
|
|
77
93
|
|
|
78
94
|
`glm` runs Z.AI's full GLM 5.3 (744B, 1M context, 128k replies) through Amazon Bedrock instead of ElevenLabs. It is a direct API, so none of the ElevenLabs limits below apply (no 50-second cut, no tool cap, no 4k replies).
|
|
@@ -134,7 +150,7 @@ ElevenLabs caches only the system prompt, so every token of history is paid in f
|
|
|
134
150
|
|
|
135
151
|
## Files
|
|
136
152
|
|
|
137
|
-
`~/.labs/`: `config.json`, `proxy-key`, `proxy.log`, `llm-list.json`, `tool-registry-<agent>.json`, `conversations/`, `bedrock-key`, `bedrock-usage.jsonl`, `chat/`
|
|
153
|
+
`~/.labs/`: `config.json`, `proxy-key`, `proxy.log`, `llm-list.json`, `tool-registry-<agent>.json`, `conversations/`, `gemini-key`, `gemini-signatures.json`, `gemini-usage.jsonl`, `bedrock-key`, `bedrock-usage.jsonl`, `chat/`
|
|
138
154
|
|
|
139
155
|
## License
|
|
140
156
|
|
package/bin/labs.js
CHANGED
|
@@ -2,22 +2,28 @@
|
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const { spawn } = require('child_process');
|
|
4
4
|
const { randomUUID } = require('crypto');
|
|
5
|
-
const { CONFIG_PATH, LABS_DIR,
|
|
5
|
+
const { CONFIG_PATH, LABS_DIR, loadEffectiveConfig, loadLlmList } = require('../src/config');
|
|
6
6
|
const { loadProxyKey } = require('../src/local-auth');
|
|
7
7
|
const { ensureProxy, keepProxyAlive, stopProxy } = require('../src/proxy-manager');
|
|
8
8
|
const { parseLaunchArgs, withLabsHeaders, chromeCompatibilityWarning } = require('../src/launch-args');
|
|
9
|
-
const { runSetup, setupBedrock, ask, askHidden } = require('../src/setup');
|
|
10
|
-
const { gatewayModelFrom, prepareGatewayLaunch, saveGatewayKey, makeAdminToken, openConsole, storedConfig } = require('../src/gateway-client');
|
|
9
|
+
const { runSetup, setupBedrock, setupGemini, ask, askHidden } = require('../src/setup');
|
|
10
|
+
const { boxOnlyArgs, gatewayModelFrom, prepareGatewayLaunch, saveGatewayKey, makeAdminToken, openConsole, storedConfig } = require('../src/gateway-client');
|
|
11
11
|
const { bedrockModelId, readBedrockKey } = require('../src/bedrock');
|
|
12
|
+
const { geminiModelId, resolveGeminiAuth } = require('../src/gemini');
|
|
13
|
+
const { agyModelId, agyModelInfo, hasAgyCli, isAgyFallbackModel } = require('../src/agy');
|
|
12
14
|
const { printUsage } = require('../src/usage');
|
|
13
15
|
const { setAutostart } = require('../src/autostart');
|
|
14
16
|
const { planSubscriptionLeg, planLabsLegArgs, createWatcher } = require('../src/auto-fallback');
|
|
15
17
|
const { version } = require('../package.json');
|
|
18
|
+
const { c, playMascotIntro, checkUpdateNotice, runSelfUpdate } = require('../src/ui');
|
|
16
19
|
|
|
17
|
-
const HELP = `labs ${version} — Claude Code
|
|
20
|
+
const HELP = `labs ${version} — Run Claude Code on Antigravity (agy), Google Gemini 4, ElevenLabs, Bedrock, or Qwen
|
|
18
21
|
|
|
19
|
-
labs open Claude Code on the default model
|
|
20
|
-
labs --model
|
|
22
|
+
labs open Claude Code on the default model
|
|
23
|
+
labs --model gem Gemini 4 Hydrogen (1M context, reasoning) via your signed-in agy CLI
|
|
24
|
+
labs --model gemini Gemini 4 Hydrogen (1M context, reasoning) via agy or your ElevenLabs bridge
|
|
25
|
+
labs --model hydrogen same as --model gemini (also: agy-flash, agy-opus, agy-sonnet, agy-oss)
|
|
26
|
+
labs --model opus pick a model by name, number (labs --model 5) or raw LLM id
|
|
21
27
|
labs -p "question" any Claude Code flag works, e.g. -p, --resume, --permission-mode
|
|
22
28
|
labs auto [claude args] real Claude Code on your subscription; on a limit or expired login, same session continues on labs Opus 5.5
|
|
23
29
|
labs models [--all] list models
|
|
@@ -25,15 +31,20 @@ const HELP = `labs ${version} — Claude Code running on ElevenLabs models
|
|
|
25
31
|
labs setup set your ElevenLabs key, the bridge agent and real-Chrome control
|
|
26
32
|
labs bedrock save your Amazon Bedrock key, then: labs --model glm (GLM 5.3)
|
|
27
33
|
labs --model qwen Claude Code on our GPU box (qwen | qwen-uncensored), through the labs gateway
|
|
28
|
-
labs key save
|
|
29
|
-
labs
|
|
34
|
+
labs key save your labs key (lk_...) with interactive model + effort setup
|
|
35
|
+
labs admin [subcommand] terminal-native Admin Control Room (stats | create | pause | resume | revoke | usage)
|
|
36
|
+
labs update update labs-claude to the latest npm version in one command
|
|
37
|
+
labs console open the web admin console (optional; labs admin does everything in terminal)
|
|
38
|
+
labs paint "a red kite" paint on the box (--size wide|portrait|square… --count 1-4 --seed N); prints the file paths
|
|
39
|
+
labs image-mcp picture tool for any Claude Code chat: claude mcp add -s user labs-image -- labs image-mcp
|
|
40
|
+
labs web-mcp web search + page reading on this computer (added to every box session by itself)
|
|
30
41
|
labs admin-token <ssh> make a new console admin token on the gateway server
|
|
31
42
|
labs chat open the private chat page (http://127.0.0.1:8081/chat)
|
|
32
43
|
labs serve start the background proxy if it is not running, then exit
|
|
33
44
|
labs autostart on|off keep the proxy (and the chat page) running from login (Windows)
|
|
34
45
|
labs stop stop the background proxy
|
|
35
46
|
|
|
36
|
-
Inside Claude Code: /model <name> switches model, e.g. /model
|
|
47
|
+
Inside Claude Code: /model <name> switches model, e.g. /model gemini-4-neon
|
|
37
48
|
Browser: "open gmail.com and read my top email" uses your real Chrome (set up with labs setup)
|
|
38
49
|
Update: npm install -g labs-claude@latest --prefer-online, then close and reopen every labs window`;
|
|
39
50
|
|
|
@@ -41,14 +52,28 @@ function printModels(config, showAll) {
|
|
|
41
52
|
const llms = loadLlmList();
|
|
42
53
|
const byId = Object.fromEntries(llms.map(item => [item.llm, item]));
|
|
43
54
|
const size = (n) => n >= 1000000 ? `${Math.round(n / 100000) / 10}M` : `${Math.round(n / 1000)}k`;
|
|
55
|
+
const geminiAuth = resolveGeminiAuth(LABS_DIR, config);
|
|
56
|
+
const agyReady = hasAgyCli();
|
|
57
|
+
const hasEl = Boolean(config?.apiKey && config?.bridgeAgent);
|
|
44
58
|
console.log('\n🚀 Labs models (labs --model <name or number>)\n');
|
|
45
59
|
Object.entries(config.models).forEach(([name, llm], index) => {
|
|
46
60
|
const info = byId[llm];
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
const gemId = geminiModelId(llm);
|
|
62
|
+
const explicitAgy = agyModelId(llm);
|
|
63
|
+
const fallbackAgy = !explicitAgy && !gemId && !hasEl && !geminiAuth && agyReady && isAgyFallbackModel(llm) ? llm : null;
|
|
64
|
+
const agyId = explicitAgy || fallbackAgy;
|
|
65
|
+
const isGw4 = GATEWAY_GEMINI4.has(llm);
|
|
66
|
+
const detail = agyId
|
|
67
|
+
? `Antigravity (agy), ${size(agyModelInfo(agyId).contextLimit).padStart(4)} context ${size(agyModelInfo(agyId).maxReply).padStart(4)} reply`
|
|
68
|
+
: gemId
|
|
69
|
+
? `${geminiAuth?.mode === 'vertex' ? 'Vertex AI' : 'Google Gemini'}, ${size(config.geminiContextLimit || 1000000).padStart(4)} context ${/carbon|argon/.test(gemId) ? '32k' : '64k'} reply`
|
|
70
|
+
: isGw4
|
|
71
|
+
? `Google Gemini, ${size(info?.max_context_limit || 1048576).padStart(4)} context ${size(info?.max_tokens_limit || 65536).padStart(5)} reply`
|
|
72
|
+
: bedrockModelId(llm)
|
|
73
|
+
? `Amazon Bedrock, ${size(config.bedrockContextLimit).padStart(5)} context 128k reply`
|
|
74
|
+
: info ? `${size(info.max_context_limit).padStart(5)} context ${size(info.max_tokens_limit).padStart(5)} reply` : 'not offered on your account';
|
|
50
75
|
const marker = name === config.defaultModel ? ' ← default' : '';
|
|
51
|
-
console.log(`${String(index + 1).padStart(3)}. ${name.padEnd(11)} ${llm.padEnd(
|
|
76
|
+
console.log(`${String(index + 1).padStart(3)}. ${name.padEnd(11)} ${llm.padEnd(28)} ${detail}${marker}`);
|
|
52
77
|
});
|
|
53
78
|
const current = llms.filter(item => !item.deprecation_info && !item.is_checkpoint);
|
|
54
79
|
if (showAll) {
|
|
@@ -104,52 +129,148 @@ function launchClaude(claudeArgs, env, onExit = code => process.exit(code ?? 0))
|
|
|
104
129
|
return handle;
|
|
105
130
|
}
|
|
106
131
|
|
|
132
|
+
function readEffortFlag(args, fallback) {
|
|
133
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
134
|
+
if (args[i] === '--effort' && args[i + 1]) return args[i + 1];
|
|
135
|
+
if (args[i].startsWith('--effort=')) return args[i].slice('--effort='.length);
|
|
136
|
+
}
|
|
137
|
+
return fallback;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Gemini-4 model IDs that the ElevenLabs gateway serves natively (no Google API key needed).
|
|
141
|
+
const GATEWAY_GEMINI4 = new Set(['gemini-4-hydrogen', 'gemini-4-neon', 'gemini-4-argon', 'gemini-4-carbon', 'gemini-4-nano']);
|
|
142
|
+
|
|
107
143
|
// Everything needed to start Claude Code against the labs proxy; shared by `labs` and the labs leg of `labs auto`.
|
|
108
144
|
async function prepareLabsLaunch(config, args) {
|
|
109
145
|
const { modelName, claudeArgs } = parseLaunchArgs(args, {
|
|
110
146
|
aliases: config.models,
|
|
111
|
-
llmIds: new Set(loadLlmList().map(item => item.llm)),
|
|
147
|
+
llmIds: new Set([...loadLlmList().map(item => item.llm), ...GATEWAY_GEMINI4]),
|
|
112
148
|
defaultModel: config.defaultModel
|
|
113
149
|
});
|
|
114
150
|
|
|
115
151
|
const chromeWarning = chromeCompatibilityWarning(claudeArgs);
|
|
116
152
|
if (chromeWarning) console.error(`⚠️ ${chromeWarning}`);
|
|
117
153
|
|
|
118
|
-
if (!(await ensureProxy(config.port))) {
|
|
119
|
-
console.error('❌ The labs proxy did not start. See ~/.labs/proxy.log');
|
|
120
|
-
process.exit(1);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
154
|
const llm = config.models[modelName] || modelName;
|
|
155
|
+
// gemini: prefix = direct Google API path; agy: prefix = Antigravity CLI ACP bridge; plain gemini-4-* = ElevenLabs or agy fallback.
|
|
156
|
+
const explicitAgyId = agyModelId(llm);
|
|
157
|
+
const directGemId = geminiModelId(llm); // "gemini-4-hydrogen" when prefix is "gemini:"
|
|
158
|
+
const geminiAuth = directGemId ? resolveGeminiAuth(LABS_DIR, config) : null;
|
|
159
|
+
const hasEl = Boolean(config?.apiKey && config.bridgeAgent);
|
|
160
|
+
const fallbackAgyId = !explicitAgyId && !directGemId && !hasEl && isAgyFallbackModel(llm) && hasAgyCli() ? llm : null;
|
|
161
|
+
const agyId = explicitAgyId || fallbackAgyId;
|
|
162
|
+
const onAgy = Boolean(agyId);
|
|
163
|
+
const gatewayGem4 = !onAgy && GATEWAY_GEMINI4.has(llm); // true when alias resolves to "gemini-4-hydrogen" etc.
|
|
164
|
+
const onGemini = Boolean(directGemId); // only direct-API path needs Google auth
|
|
165
|
+
const onGatewayGemini4 = gatewayGem4; // ElevenLabs-routed Gemini 4
|
|
124
166
|
const onBedrock = Boolean(bedrockModelId(llm));
|
|
167
|
+
|
|
168
|
+
if (onAgy && !hasAgyCli()) {
|
|
169
|
+
console.error(`❌ ${modelName} requires Antigravity CLI (agy) in your PATH.`);
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
// Direct Google API path requires a key; skip this check for agy or gateway-routed gemini-4 models.
|
|
173
|
+
if (onGemini && !geminiAuth) {
|
|
174
|
+
console.error(`❌ ${modelName} runs on Google Gemini and no key or Vertex project is configured. Run: labs gemini (or set GEMINI_API_KEY)`);
|
|
175
|
+
process.exit(1);
|
|
176
|
+
}
|
|
125
177
|
// Without a key every call gets 401, and Claude Code retries those silently: the window would look frozen.
|
|
126
178
|
if (onBedrock && !readBedrockKey(LABS_DIR)) {
|
|
127
179
|
console.error(`❌ ${modelName} runs on Amazon Bedrock and no Bedrock key is saved. Run: labs bedrock`);
|
|
128
180
|
process.exit(1);
|
|
129
181
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
182
|
+
if (!onAgy && !onGemini && !onGatewayGemini4 && !onBedrock && !hasEl) {
|
|
183
|
+
console.log(`No ElevenLabs setup found at ${CONFIG_PATH}, running setup first.\n`);
|
|
184
|
+
await runSetup();
|
|
185
|
+
config = loadEffectiveConfig();
|
|
186
|
+
}
|
|
187
|
+
// Gateway Gemini-4 models (hydrogen, neon, argon) route through the ElevenLabs bridge agent when agy is not handling them.
|
|
188
|
+
if (onGatewayGemini4 && (!config?.apiKey || !config.bridgeAgent)) {
|
|
189
|
+
console.error(`\n❌ ${modelName} (${llm}) requires a labs ElevenLabs account (or use labs --model gem for agy).\n`);
|
|
190
|
+
console.error(` Run: labs setup to enter your ElevenLabs key and bridge agent.\n`);
|
|
191
|
+
console.error(` No account? Sign up at https://elevenlabs.io (free tier works)\n`);
|
|
192
|
+
process.exit(1);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (!(await ensureProxy(config.port))) {
|
|
196
|
+
console.error('❌ The labs proxy did not start. See ~/.labs/proxy.log');
|
|
197
|
+
process.exit(1);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const llmInfo = onAgy
|
|
201
|
+
? { max_context_limit: agyModelInfo(agyId).contextLimit }
|
|
202
|
+
: onGemini
|
|
203
|
+
? { max_context_limit: config.geminiContextLimit || 1000000 }
|
|
204
|
+
: onGatewayGemini4
|
|
205
|
+
// Gateway gemini-4 models have 1M context; use the LLM list value if present, else 1M.
|
|
206
|
+
? (loadLlmList().find(item => item.llm === llm) || { max_context_limit: 1048576 })
|
|
207
|
+
: onBedrock
|
|
208
|
+
? { max_context_limit: config.bedrockContextLimit }
|
|
209
|
+
: loadLlmList().find(item => item.llm === llm);
|
|
133
210
|
if (!claudeArgs.some(arg => arg === '--effort' || arg.startsWith('--effort='))) {
|
|
134
211
|
claudeArgs.push('--effort', config.defaultEffort || 'high');
|
|
135
212
|
}
|
|
213
|
+
const effort = readEffortFlag(claudeArgs, config.defaultEffort || 'high');
|
|
136
214
|
|
|
215
|
+
const CAPS = 'effort,xhigh_effort,max_effort,thinking,interleaved_thinking';
|
|
216
|
+
// For Google Gemini / Gateway Gemini-4, present claude-opus-4-6; for Antigravity (agy), present the real agy model id
|
|
217
|
+
// (like gemini-4-hydrogen) so Claude Code displays and routes the actual model name rather than Opus/Sonnet/Haiku.
|
|
218
|
+
const isOpusUx = onGemini || onGatewayGemini4;
|
|
219
|
+
const launchArgs = [];
|
|
220
|
+
for (let i = 0; i < claudeArgs.length; i += 1) {
|
|
221
|
+
if (onAgy && claudeArgs[i] === '--model') { launchArgs.push('--model', agyId); i += 1; continue; }
|
|
222
|
+
if (onAgy && claudeArgs[i].startsWith('--model=')) { launchArgs.push(`--model=${agyId}`); continue; }
|
|
223
|
+
if (isOpusUx && claudeArgs[i] === '--model') { launchArgs.push('--model', 'claude-opus-4-6'); i += 1; continue; }
|
|
224
|
+
if (isOpusUx && claudeArgs[i].startsWith('--model=')) { launchArgs.push('--model=claude-opus-4-6'); continue; }
|
|
225
|
+
launchArgs.push(claudeArgs[i]);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const agyDisplayName = modelName === 'gem' ? 'Gemini 4 Hydrogen (agy)' : `${agyId} (agy)`;
|
|
137
229
|
const env = {
|
|
138
230
|
...process.env,
|
|
139
231
|
// Claude Code only knows Anthropic windows; without this it assumes 200k and compacts at the wrong point.
|
|
140
|
-
...(llmInfo ? { CLAUDE_CODE_MAX_CONTEXT_TOKENS: String(Math.min(llmInfo.max_context_limit, config.contextLimit)) } : {}),
|
|
232
|
+
...(llmInfo ? { CLAUDE_CODE_MAX_CONTEXT_TOKENS: String((onAgy || isOpusUx) ? llmInfo.max_context_limit : Math.min(llmInfo.max_context_limit, config.contextLimit)) } : {}),
|
|
141
233
|
ANTHROPIC_BASE_URL: `http://127.0.0.1:${config.port}`,
|
|
142
234
|
ANTHROPIC_AUTH_TOKEN: loadProxyKey(LABS_DIR),
|
|
143
|
-
ANTHROPIC_CUSTOM_HEADERS: withLabsHeaders(process.env.ANTHROPIC_CUSTOM_HEADERS, randomUUID(), modelName),
|
|
235
|
+
ANTHROPIC_CUSTOM_HEADERS: withLabsHeaders(process.env.ANTHROPIC_CUSTOM_HEADERS, randomUUID(), modelName, effort, process.cwd()),
|
|
236
|
+
...(onAgy ? {
|
|
237
|
+
ANTHROPIC_MODEL: agyId,
|
|
238
|
+
ANTHROPIC_CUSTOM_MODEL_OPTION: agyId,
|
|
239
|
+
ANTHROPIC_CUSTOM_MODEL_OPTION_NAME: agyDisplayName,
|
|
240
|
+
ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION: `Antigravity (agy) · ${Math.round(llmInfo.max_context_limit / 1000)}k context`,
|
|
241
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL: agyId,
|
|
242
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL: agyId,
|
|
243
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL: 'gemini-3.8-flash',
|
|
244
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES: CAPS,
|
|
245
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES: CAPS,
|
|
246
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES: CAPS
|
|
247
|
+
} : isOpusUx ? {
|
|
248
|
+
// Present a native Claude Opus id so Claude Code enables full thinking/effort/1M UX with zero
|
|
249
|
+
// unrecognized_model warnings; X-Labs-Model in the custom header routes every call to the target model.
|
|
250
|
+
ANTHROPIC_MODEL: 'claude-opus-4-6',
|
|
251
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL: 'claude-opus-4-6',
|
|
252
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL: 'claude-sonnet-4-6',
|
|
253
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL: 'claude-haiku-4-5',
|
|
254
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES: CAPS,
|
|
255
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES: CAPS,
|
|
256
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES: CAPS
|
|
257
|
+
} : {}),
|
|
144
258
|
// Subagents run on the chosen model too; the proxy answers overload with 529 so Claude Code retries, never switches.
|
|
145
|
-
CLAUDE_CODE_SUBAGENT_MODEL: modelName
|
|
259
|
+
CLAUDE_CODE_SUBAGENT_MODEL: onAgy ? agyId : isOpusUx ? 'claude-opus-4-6' : modelName
|
|
146
260
|
};
|
|
147
261
|
// A leftover key (e.g. from an Ollama setup) would take precedence over the proxy's auth token.
|
|
148
262
|
delete env.ANTHROPIC_API_KEY;
|
|
149
263
|
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
|
|
264
|
+
const contextK = llmInfo ? `, ${Math.round(llmInfo.max_context_limit / 1000)}k context` : '';
|
|
265
|
+
const providerLabel = onAgy
|
|
266
|
+
? 'Antigravity (agy)'
|
|
267
|
+
: onGatewayGemini4
|
|
268
|
+
? 'Google Gemini'
|
|
269
|
+
: onGemini
|
|
270
|
+
? (geminiAuth?.mode === 'vertex' ? 'Vertex AI' : 'Google Gemini')
|
|
271
|
+
: onBedrock ? 'Amazon Bedrock' : 'ElevenLabs';
|
|
272
|
+
const banner = `🚀 Claude Code on ${providerLabel} ${modelName} (${agyId || llm}${contextK})`;
|
|
273
|
+
return { modelName, claudeArgs: launchArgs, env, banner };
|
|
153
274
|
}
|
|
154
275
|
|
|
155
276
|
// `labs auto`: real Claude Code on the subscription first; when the subscription fails for good in this session
|
|
@@ -190,13 +311,33 @@ async function runAuto(args) {
|
|
|
190
311
|
});
|
|
191
312
|
}
|
|
192
313
|
|
|
314
|
+
async function runInteractiveSetup() {
|
|
315
|
+
await playMascotIntro(version, 'Choose your backend to set up');
|
|
316
|
+
console.log(` ${c.bold('Select setup mode:')}`);
|
|
317
|
+
console.log(` ${c.cyan('1.')} ${c.bold('Labs Key (Qwen4 1M)')} ${c.dim('Paste lk_... key from admin — Vision, Web, 200–400 tok/s [Recommended]')}`);
|
|
318
|
+
console.log(` ${c.cyan('2.')} ${c.bold('ElevenLabs')} ${c.dim('ElevenLabs API key + bridge agent + Chrome control')}`);
|
|
319
|
+
console.log(` ${c.cyan('3.')} ${c.bold('Google Gemini 4')} ${c.dim('AI Studio key or Vertex AI')}`);
|
|
320
|
+
console.log(` ${c.cyan('4.')} ${c.bold('Amazon Bedrock')} ${c.dim('Bedrock API key (GLM 5.3)')}\n`);
|
|
321
|
+
const choice = (await ask(' Choose [1]: ')) || '1';
|
|
322
|
+
if (choice === '1') return saveGatewayKey(askHidden, ask);
|
|
323
|
+
if (choice === '2') return runSetup();
|
|
324
|
+
if (choice === '3') return setupGemini();
|
|
325
|
+
if (choice === '4') return setupBedrock();
|
|
326
|
+
console.log(` ${c.rose('✖')} Unknown choice "${choice}".`);
|
|
327
|
+
}
|
|
328
|
+
|
|
193
329
|
async function main() {
|
|
194
330
|
const args = process.argv.slice(2);
|
|
195
|
-
if (args[0] === '
|
|
331
|
+
if (args[0] === 'image-mcp') return require('../src/image-mcp').serveFromConfig(version);
|
|
332
|
+
if (args[0] === 'web-mcp') return require('../src/web-mcp').serve({ version });
|
|
333
|
+
if (args[0] === '--version') return console.log(version);
|
|
334
|
+
if (args[0] === 'update') return runSelfUpdate(version);
|
|
335
|
+
checkUpdateNotice(version, LABS_DIR);
|
|
336
|
+
if (args[0] === 'setup') return runInteractiveSetup();
|
|
196
337
|
if (args[0] === 'bedrock') return setupBedrock();
|
|
338
|
+
if (args[0] === 'gemini') return setupGemini();
|
|
197
339
|
if (args[0] === 'auto') return runAuto(args.slice(1));
|
|
198
340
|
if (args[0] === '--help' || args[0] === 'help') return console.log(HELP);
|
|
199
|
-
if (args[0] === '--version') return console.log(version);
|
|
200
341
|
if (args[0] === 'autostart') {
|
|
201
342
|
if (!['on', 'off'].includes(args[1])) return console.log('Use: labs autostart on | labs autostart off');
|
|
202
343
|
const { ok, message } = setAutostart(args[1] === 'on');
|
|
@@ -205,27 +346,34 @@ async function main() {
|
|
|
205
346
|
}
|
|
206
347
|
// The autostart task runs this with no window, so it must never fall into the interactive setup.
|
|
207
348
|
if (args[0] === 'serve') {
|
|
208
|
-
const
|
|
209
|
-
|
|
349
|
+
const cfg = loadEffectiveConfig();
|
|
350
|
+
const ready = (cfg.apiKey || resolveGeminiAuth(LABS_DIR, cfg) || readBedrockKey(LABS_DIR) || hasAgyCli()) && await ensureProxy(cfg.port);
|
|
351
|
+
console.log(ready ? '✅ labs proxy running' : '❌ labs proxy not started (run labs gemini or labs setup, see ~/.labs/proxy.log)');
|
|
210
352
|
return process.exit(ready ? 0 : 1);
|
|
211
353
|
}
|
|
212
354
|
|
|
213
355
|
// Box users (friends) may have no ElevenLabs account at all, so these never fall into the ElevenLabs setup.
|
|
214
|
-
if (args[0] === 'key') return saveGatewayKey(askHidden, ask);
|
|
356
|
+
if (args[0] === 'key') return saveGatewayKey(askHidden, ask, args[1]);
|
|
357
|
+
if (args[0] === 'paint') return require('../src/image-mcp').paintFromCli(args.slice(1));
|
|
215
358
|
if (args[0] === 'admin-token') return makeAdminToken(args[1]);
|
|
216
359
|
if (args[0] === 'console') return openConsole(storedConfig());
|
|
217
|
-
const
|
|
360
|
+
const stored = storedConfig();
|
|
361
|
+
if (!args.length && !stored.gatewayKey && !stored.apiKey && !process.env.ELEVENLABS_API_KEY && !readBedrockKey(LABS_DIR)) {
|
|
362
|
+
return runInteractiveSetup();
|
|
363
|
+
}
|
|
364
|
+
const boxArgs = boxOnlyArgs(args, stored) || args;
|
|
365
|
+
const boxModel = gatewayModelFrom(boxArgs);
|
|
218
366
|
if (boxModel) {
|
|
219
|
-
const launch = await prepareGatewayLaunch(
|
|
367
|
+
const launch = await prepareGatewayLaunch(stored, boxArgs, boxModel);
|
|
220
368
|
console.log(launch.banner);
|
|
221
369
|
return launchClaude(launch.claudeArgs, launch.env);
|
|
222
370
|
}
|
|
223
371
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
config =
|
|
372
|
+
const config = loadEffectiveConfig();
|
|
373
|
+
// If no ElevenLabs account, pick the best available backend as default.
|
|
374
|
+
if (!config.apiKey || !config.bridgeAgent) {
|
|
375
|
+
if (readBedrockKey(LABS_DIR)) config.defaultModel = 'glm';
|
|
376
|
+
else config.defaultModel = 'hydrogen'; // gemini-4-hydrogen works via ElevenLabs gateway; setup will prompt if needed
|
|
229
377
|
}
|
|
230
378
|
|
|
231
379
|
if (args[0] === 'models') return printModels(config, args.includes('--all'));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "labs-claude",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "Run the real Claude Code CLI on
|
|
3
|
+
"version": "0.3.4",
|
|
4
|
+
"description": "Run the real Claude Code CLI on Qwen4 1M (Vision + Web), Gemini 4, Bedrock, or ElevenLabs — with colorful setup and admin token tracking.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"labs": "bin/labs.js"
|
|
7
7
|
},
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"README.md"
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
|
-
"test": "node --test"
|
|
14
|
+
"test": "node --test",
|
|
15
|
+
"release": "node scripts/release.js"
|
|
15
16
|
},
|
|
16
17
|
"engines": {
|
|
17
18
|
"node": ">=18"
|