labs-claude 0.3.0 → 0.3.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/README.md +20 -4
- package/bin/labs.js +187 -40
- package/package.json +4 -3
- 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,19 @@ 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 update update labs-claude to the latest npm version in one command
|
|
36
|
+
labs console open the gateway admin dashboard (keys & per-friend token stats)
|
|
37
|
+
labs paint "a red kite" paint on the box (--size wide|portrait|square… --count 1-4 --seed N); prints the file paths
|
|
38
|
+
labs image-mcp picture tool for any Claude Code chat: claude mcp add -s user labs-image -- labs image-mcp
|
|
39
|
+
labs web-mcp web search + page reading on this computer (added to every box session by itself)
|
|
30
40
|
labs admin-token <ssh> make a new console admin token on the gateway server
|
|
31
41
|
labs chat open the private chat page (http://127.0.0.1:8081/chat)
|
|
32
42
|
labs serve start the background proxy if it is not running, then exit
|
|
33
43
|
labs autostart on|off keep the proxy (and the chat page) running from login (Windows)
|
|
34
44
|
labs stop stop the background proxy
|
|
35
45
|
|
|
36
|
-
Inside Claude Code: /model <name> switches model, e.g. /model
|
|
46
|
+
Inside Claude Code: /model <name> switches model, e.g. /model gemini-4-neon
|
|
37
47
|
Browser: "open gmail.com and read my top email" uses your real Chrome (set up with labs setup)
|
|
38
48
|
Update: npm install -g labs-claude@latest --prefer-online, then close and reopen every labs window`;
|
|
39
49
|
|
|
@@ -41,14 +51,28 @@ function printModels(config, showAll) {
|
|
|
41
51
|
const llms = loadLlmList();
|
|
42
52
|
const byId = Object.fromEntries(llms.map(item => [item.llm, item]));
|
|
43
53
|
const size = (n) => n >= 1000000 ? `${Math.round(n / 100000) / 10}M` : `${Math.round(n / 1000)}k`;
|
|
54
|
+
const geminiAuth = resolveGeminiAuth(LABS_DIR, config);
|
|
55
|
+
const agyReady = hasAgyCli();
|
|
56
|
+
const hasEl = Boolean(config?.apiKey && config?.bridgeAgent);
|
|
44
57
|
console.log('\n🚀 Labs models (labs --model <name or number>)\n');
|
|
45
58
|
Object.entries(config.models).forEach(([name, llm], index) => {
|
|
46
59
|
const info = byId[llm];
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
const gemId = geminiModelId(llm);
|
|
61
|
+
const explicitAgy = agyModelId(llm);
|
|
62
|
+
const fallbackAgy = !explicitAgy && !gemId && !hasEl && !geminiAuth && agyReady && isAgyFallbackModel(llm) ? llm : null;
|
|
63
|
+
const agyId = explicitAgy || fallbackAgy;
|
|
64
|
+
const isGw4 = GATEWAY_GEMINI4.has(llm);
|
|
65
|
+
const detail = agyId
|
|
66
|
+
? `Antigravity (agy), ${size(agyModelInfo(agyId).contextLimit).padStart(4)} context ${size(agyModelInfo(agyId).maxReply).padStart(4)} reply`
|
|
67
|
+
: gemId
|
|
68
|
+
? `${geminiAuth?.mode === 'vertex' ? 'Vertex AI' : 'Google Gemini'}, ${size(config.geminiContextLimit || 1000000).padStart(4)} context ${/carbon|argon/.test(gemId) ? '32k' : '64k'} reply`
|
|
69
|
+
: isGw4
|
|
70
|
+
? `Google Gemini, ${size(info?.max_context_limit || 1048576).padStart(4)} context ${size(info?.max_tokens_limit || 65536).padStart(5)} reply`
|
|
71
|
+
: bedrockModelId(llm)
|
|
72
|
+
? `Amazon Bedrock, ${size(config.bedrockContextLimit).padStart(5)} context 128k reply`
|
|
73
|
+
: info ? `${size(info.max_context_limit).padStart(5)} context ${size(info.max_tokens_limit).padStart(5)} reply` : 'not offered on your account';
|
|
50
74
|
const marker = name === config.defaultModel ? ' ← default' : '';
|
|
51
|
-
console.log(`${String(index + 1).padStart(3)}. ${name.padEnd(11)} ${llm.padEnd(
|
|
75
|
+
console.log(`${String(index + 1).padStart(3)}. ${name.padEnd(11)} ${llm.padEnd(28)} ${detail}${marker}`);
|
|
52
76
|
});
|
|
53
77
|
const current = llms.filter(item => !item.deprecation_info && !item.is_checkpoint);
|
|
54
78
|
if (showAll) {
|
|
@@ -104,52 +128,148 @@ function launchClaude(claudeArgs, env, onExit = code => process.exit(code ?? 0))
|
|
|
104
128
|
return handle;
|
|
105
129
|
}
|
|
106
130
|
|
|
131
|
+
function readEffortFlag(args, fallback) {
|
|
132
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
133
|
+
if (args[i] === '--effort' && args[i + 1]) return args[i + 1];
|
|
134
|
+
if (args[i].startsWith('--effort=')) return args[i].slice('--effort='.length);
|
|
135
|
+
}
|
|
136
|
+
return fallback;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Gemini-4 model IDs that the ElevenLabs gateway serves natively (no Google API key needed).
|
|
140
|
+
const GATEWAY_GEMINI4 = new Set(['gemini-4-hydrogen', 'gemini-4-neon', 'gemini-4-argon', 'gemini-4-carbon', 'gemini-4-nano']);
|
|
141
|
+
|
|
107
142
|
// Everything needed to start Claude Code against the labs proxy; shared by `labs` and the labs leg of `labs auto`.
|
|
108
143
|
async function prepareLabsLaunch(config, args) {
|
|
109
144
|
const { modelName, claudeArgs } = parseLaunchArgs(args, {
|
|
110
145
|
aliases: config.models,
|
|
111
|
-
llmIds: new Set(loadLlmList().map(item => item.llm)),
|
|
146
|
+
llmIds: new Set([...loadLlmList().map(item => item.llm), ...GATEWAY_GEMINI4]),
|
|
112
147
|
defaultModel: config.defaultModel
|
|
113
148
|
});
|
|
114
149
|
|
|
115
150
|
const chromeWarning = chromeCompatibilityWarning(claudeArgs);
|
|
116
151
|
if (chromeWarning) console.error(`⚠️ ${chromeWarning}`);
|
|
117
152
|
|
|
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
153
|
const llm = config.models[modelName] || modelName;
|
|
154
|
+
// gemini: prefix = direct Google API path; agy: prefix = Antigravity CLI ACP bridge; plain gemini-4-* = ElevenLabs or agy fallback.
|
|
155
|
+
const explicitAgyId = agyModelId(llm);
|
|
156
|
+
const directGemId = geminiModelId(llm); // "gemini-4-hydrogen" when prefix is "gemini:"
|
|
157
|
+
const geminiAuth = directGemId ? resolveGeminiAuth(LABS_DIR, config) : null;
|
|
158
|
+
const hasEl = Boolean(config?.apiKey && config.bridgeAgent);
|
|
159
|
+
const fallbackAgyId = !explicitAgyId && !directGemId && !hasEl && isAgyFallbackModel(llm) && hasAgyCli() ? llm : null;
|
|
160
|
+
const agyId = explicitAgyId || fallbackAgyId;
|
|
161
|
+
const onAgy = Boolean(agyId);
|
|
162
|
+
const gatewayGem4 = !onAgy && GATEWAY_GEMINI4.has(llm); // true when alias resolves to "gemini-4-hydrogen" etc.
|
|
163
|
+
const onGemini = Boolean(directGemId); // only direct-API path needs Google auth
|
|
164
|
+
const onGatewayGemini4 = gatewayGem4; // ElevenLabs-routed Gemini 4
|
|
124
165
|
const onBedrock = Boolean(bedrockModelId(llm));
|
|
166
|
+
|
|
167
|
+
if (onAgy && !hasAgyCli()) {
|
|
168
|
+
console.error(`❌ ${modelName} requires Antigravity CLI (agy) in your PATH.`);
|
|
169
|
+
process.exit(1);
|
|
170
|
+
}
|
|
171
|
+
// Direct Google API path requires a key; skip this check for agy or gateway-routed gemini-4 models.
|
|
172
|
+
if (onGemini && !geminiAuth) {
|
|
173
|
+
console.error(`❌ ${modelName} runs on Google Gemini and no key or Vertex project is configured. Run: labs gemini (or set GEMINI_API_KEY)`);
|
|
174
|
+
process.exit(1);
|
|
175
|
+
}
|
|
125
176
|
// Without a key every call gets 401, and Claude Code retries those silently: the window would look frozen.
|
|
126
177
|
if (onBedrock && !readBedrockKey(LABS_DIR)) {
|
|
127
178
|
console.error(`❌ ${modelName} runs on Amazon Bedrock and no Bedrock key is saved. Run: labs bedrock`);
|
|
128
179
|
process.exit(1);
|
|
129
180
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
181
|
+
if (!onAgy && !onGemini && !onGatewayGemini4 && !onBedrock && !hasEl) {
|
|
182
|
+
console.log(`No ElevenLabs setup found at ${CONFIG_PATH}, running setup first.\n`);
|
|
183
|
+
await runSetup();
|
|
184
|
+
config = loadEffectiveConfig();
|
|
185
|
+
}
|
|
186
|
+
// Gateway Gemini-4 models (hydrogen, neon, argon) route through the ElevenLabs bridge agent when agy is not handling them.
|
|
187
|
+
if (onGatewayGemini4 && (!config?.apiKey || !config.bridgeAgent)) {
|
|
188
|
+
console.error(`\n❌ ${modelName} (${llm}) requires a labs ElevenLabs account (or use labs --model gem for agy).\n`);
|
|
189
|
+
console.error(` Run: labs setup to enter your ElevenLabs key and bridge agent.\n`);
|
|
190
|
+
console.error(` No account? Sign up at https://elevenlabs.io (free tier works)\n`);
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (!(await ensureProxy(config.port))) {
|
|
195
|
+
console.error('❌ The labs proxy did not start. See ~/.labs/proxy.log');
|
|
196
|
+
process.exit(1);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const llmInfo = onAgy
|
|
200
|
+
? { max_context_limit: agyModelInfo(agyId).contextLimit }
|
|
201
|
+
: onGemini
|
|
202
|
+
? { max_context_limit: config.geminiContextLimit || 1000000 }
|
|
203
|
+
: onGatewayGemini4
|
|
204
|
+
// Gateway gemini-4 models have 1M context; use the LLM list value if present, else 1M.
|
|
205
|
+
? (loadLlmList().find(item => item.llm === llm) || { max_context_limit: 1048576 })
|
|
206
|
+
: onBedrock
|
|
207
|
+
? { max_context_limit: config.bedrockContextLimit }
|
|
208
|
+
: loadLlmList().find(item => item.llm === llm);
|
|
133
209
|
if (!claudeArgs.some(arg => arg === '--effort' || arg.startsWith('--effort='))) {
|
|
134
210
|
claudeArgs.push('--effort', config.defaultEffort || 'high');
|
|
135
211
|
}
|
|
212
|
+
const effort = readEffortFlag(claudeArgs, config.defaultEffort || 'high');
|
|
136
213
|
|
|
214
|
+
const CAPS = 'effort,xhigh_effort,max_effort,thinking,interleaved_thinking';
|
|
215
|
+
// For Google Gemini / Gateway Gemini-4, present claude-opus-4-6; for Antigravity (agy), present the real agy model id
|
|
216
|
+
// (like gemini-4-hydrogen) so Claude Code displays and routes the actual model name rather than Opus/Sonnet/Haiku.
|
|
217
|
+
const isOpusUx = onGemini || onGatewayGemini4;
|
|
218
|
+
const launchArgs = [];
|
|
219
|
+
for (let i = 0; i < claudeArgs.length; i += 1) {
|
|
220
|
+
if (onAgy && claudeArgs[i] === '--model') { launchArgs.push('--model', agyId); i += 1; continue; }
|
|
221
|
+
if (onAgy && claudeArgs[i].startsWith('--model=')) { launchArgs.push(`--model=${agyId}`); continue; }
|
|
222
|
+
if (isOpusUx && claudeArgs[i] === '--model') { launchArgs.push('--model', 'claude-opus-4-6'); i += 1; continue; }
|
|
223
|
+
if (isOpusUx && claudeArgs[i].startsWith('--model=')) { launchArgs.push('--model=claude-opus-4-6'); continue; }
|
|
224
|
+
launchArgs.push(claudeArgs[i]);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const agyDisplayName = modelName === 'gem' ? 'Gemini 4 Hydrogen (agy)' : `${agyId} (agy)`;
|
|
137
228
|
const env = {
|
|
138
229
|
...process.env,
|
|
139
230
|
// 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)) } : {}),
|
|
231
|
+
...(llmInfo ? { CLAUDE_CODE_MAX_CONTEXT_TOKENS: String((onAgy || isOpusUx) ? llmInfo.max_context_limit : Math.min(llmInfo.max_context_limit, config.contextLimit)) } : {}),
|
|
141
232
|
ANTHROPIC_BASE_URL: `http://127.0.0.1:${config.port}`,
|
|
142
233
|
ANTHROPIC_AUTH_TOKEN: loadProxyKey(LABS_DIR),
|
|
143
|
-
ANTHROPIC_CUSTOM_HEADERS: withLabsHeaders(process.env.ANTHROPIC_CUSTOM_HEADERS, randomUUID(), modelName),
|
|
234
|
+
ANTHROPIC_CUSTOM_HEADERS: withLabsHeaders(process.env.ANTHROPIC_CUSTOM_HEADERS, randomUUID(), modelName, effort, process.cwd()),
|
|
235
|
+
...(onAgy ? {
|
|
236
|
+
ANTHROPIC_MODEL: agyId,
|
|
237
|
+
ANTHROPIC_CUSTOM_MODEL_OPTION: agyId,
|
|
238
|
+
ANTHROPIC_CUSTOM_MODEL_OPTION_NAME: agyDisplayName,
|
|
239
|
+
ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION: `Antigravity (agy) · ${Math.round(llmInfo.max_context_limit / 1000)}k context`,
|
|
240
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL: agyId,
|
|
241
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL: agyId,
|
|
242
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL: 'gemini-3.8-flash',
|
|
243
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES: CAPS,
|
|
244
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES: CAPS,
|
|
245
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES: CAPS
|
|
246
|
+
} : isOpusUx ? {
|
|
247
|
+
// Present a native Claude Opus id so Claude Code enables full thinking/effort/1M UX with zero
|
|
248
|
+
// unrecognized_model warnings; X-Labs-Model in the custom header routes every call to the target model.
|
|
249
|
+
ANTHROPIC_MODEL: 'claude-opus-4-6',
|
|
250
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL: 'claude-opus-4-6',
|
|
251
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL: 'claude-sonnet-4-6',
|
|
252
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL: 'claude-haiku-4-5',
|
|
253
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES: CAPS,
|
|
254
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES: CAPS,
|
|
255
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES: CAPS
|
|
256
|
+
} : {}),
|
|
144
257
|
// 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
|
|
258
|
+
CLAUDE_CODE_SUBAGENT_MODEL: onAgy ? agyId : isOpusUx ? 'claude-opus-4-6' : modelName
|
|
146
259
|
};
|
|
147
260
|
// A leftover key (e.g. from an Ollama setup) would take precedence over the proxy's auth token.
|
|
148
261
|
delete env.ANTHROPIC_API_KEY;
|
|
149
262
|
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
|
|
263
|
+
const contextK = llmInfo ? `, ${Math.round(llmInfo.max_context_limit / 1000)}k context` : '';
|
|
264
|
+
const providerLabel = onAgy
|
|
265
|
+
? 'Antigravity (agy)'
|
|
266
|
+
: onGatewayGemini4
|
|
267
|
+
? 'Google Gemini'
|
|
268
|
+
: onGemini
|
|
269
|
+
? (geminiAuth?.mode === 'vertex' ? 'Vertex AI' : 'Google Gemini')
|
|
270
|
+
: onBedrock ? 'Amazon Bedrock' : 'ElevenLabs';
|
|
271
|
+
const banner = `🚀 Claude Code on ${providerLabel} ${modelName} (${agyId || llm}${contextK})`;
|
|
272
|
+
return { modelName, claudeArgs: launchArgs, env, banner };
|
|
153
273
|
}
|
|
154
274
|
|
|
155
275
|
// `labs auto`: real Claude Code on the subscription first; when the subscription fails for good in this session
|
|
@@ -190,13 +310,33 @@ async function runAuto(args) {
|
|
|
190
310
|
});
|
|
191
311
|
}
|
|
192
312
|
|
|
313
|
+
async function runInteractiveSetup() {
|
|
314
|
+
await playMascotIntro(version, 'Choose your backend to set up');
|
|
315
|
+
console.log(` ${c.bold('Select setup mode:')}`);
|
|
316
|
+
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]')}`);
|
|
317
|
+
console.log(` ${c.cyan('2.')} ${c.bold('ElevenLabs')} ${c.dim('ElevenLabs API key + bridge agent + Chrome control')}`);
|
|
318
|
+
console.log(` ${c.cyan('3.')} ${c.bold('Google Gemini 4')} ${c.dim('AI Studio key or Vertex AI')}`);
|
|
319
|
+
console.log(` ${c.cyan('4.')} ${c.bold('Amazon Bedrock')} ${c.dim('Bedrock API key (GLM 5.3)')}\n`);
|
|
320
|
+
const choice = (await ask(' Choose [1]: ')) || '1';
|
|
321
|
+
if (choice === '1') return saveGatewayKey(askHidden, ask);
|
|
322
|
+
if (choice === '2') return runSetup();
|
|
323
|
+
if (choice === '3') return setupGemini();
|
|
324
|
+
if (choice === '4') return setupBedrock();
|
|
325
|
+
console.log(` ${c.rose('✖')} Unknown choice "${choice}".`);
|
|
326
|
+
}
|
|
327
|
+
|
|
193
328
|
async function main() {
|
|
194
329
|
const args = process.argv.slice(2);
|
|
195
|
-
if (args[0] === '
|
|
330
|
+
if (args[0] === 'image-mcp') return require('../src/image-mcp').serveFromConfig(version);
|
|
331
|
+
if (args[0] === 'web-mcp') return require('../src/web-mcp').serve({ version });
|
|
332
|
+
if (args[0] === '--version') return console.log(version);
|
|
333
|
+
if (args[0] === 'update') return runSelfUpdate(version);
|
|
334
|
+
checkUpdateNotice(version, LABS_DIR);
|
|
335
|
+
if (args[0] === 'setup') return runInteractiveSetup();
|
|
196
336
|
if (args[0] === 'bedrock') return setupBedrock();
|
|
337
|
+
if (args[0] === 'gemini') return setupGemini();
|
|
197
338
|
if (args[0] === 'auto') return runAuto(args.slice(1));
|
|
198
339
|
if (args[0] === '--help' || args[0] === 'help') return console.log(HELP);
|
|
199
|
-
if (args[0] === '--version') return console.log(version);
|
|
200
340
|
if (args[0] === 'autostart') {
|
|
201
341
|
if (!['on', 'off'].includes(args[1])) return console.log('Use: labs autostart on | labs autostart off');
|
|
202
342
|
const { ok, message } = setAutostart(args[1] === 'on');
|
|
@@ -205,27 +345,34 @@ async function main() {
|
|
|
205
345
|
}
|
|
206
346
|
// The autostart task runs this with no window, so it must never fall into the interactive setup.
|
|
207
347
|
if (args[0] === 'serve') {
|
|
208
|
-
const
|
|
209
|
-
|
|
348
|
+
const cfg = loadEffectiveConfig();
|
|
349
|
+
const ready = (cfg.apiKey || resolveGeminiAuth(LABS_DIR, cfg) || readBedrockKey(LABS_DIR) || hasAgyCli()) && await ensureProxy(cfg.port);
|
|
350
|
+
console.log(ready ? '✅ labs proxy running' : '❌ labs proxy not started (run labs gemini or labs setup, see ~/.labs/proxy.log)');
|
|
210
351
|
return process.exit(ready ? 0 : 1);
|
|
211
352
|
}
|
|
212
353
|
|
|
213
354
|
// 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);
|
|
355
|
+
if (args[0] === 'key') return saveGatewayKey(askHidden, ask, args[1]);
|
|
356
|
+
if (args[0] === 'paint') return require('../src/image-mcp').paintFromCli(args.slice(1));
|
|
215
357
|
if (args[0] === 'admin-token') return makeAdminToken(args[1]);
|
|
216
358
|
if (args[0] === 'console') return openConsole(storedConfig());
|
|
217
|
-
const
|
|
359
|
+
const stored = storedConfig();
|
|
360
|
+
if (!args.length && !stored.gatewayKey && !stored.apiKey && !process.env.ELEVENLABS_API_KEY && !readBedrockKey(LABS_DIR)) {
|
|
361
|
+
return runInteractiveSetup();
|
|
362
|
+
}
|
|
363
|
+
const boxArgs = boxOnlyArgs(args, stored) || args;
|
|
364
|
+
const boxModel = gatewayModelFrom(boxArgs);
|
|
218
365
|
if (boxModel) {
|
|
219
|
-
const launch = await prepareGatewayLaunch(
|
|
366
|
+
const launch = await prepareGatewayLaunch(stored, boxArgs, boxModel);
|
|
220
367
|
console.log(launch.banner);
|
|
221
368
|
return launchClaude(launch.claudeArgs, launch.env);
|
|
222
369
|
}
|
|
223
370
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
config =
|
|
371
|
+
const config = loadEffectiveConfig();
|
|
372
|
+
// If no ElevenLabs account, pick the best available backend as default.
|
|
373
|
+
if (!config.apiKey || !config.bridgeAgent) {
|
|
374
|
+
if (readBedrockKey(LABS_DIR)) config.defaultModel = 'glm';
|
|
375
|
+
else config.defaultModel = 'hydrogen'; // gemini-4-hydrogen works via ElevenLabs gateway; setup will prompt if needed
|
|
229
376
|
}
|
|
230
377
|
|
|
231
378
|
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.3",
|
|
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"
|