labs-claude 0.3.6 → 0.4.0
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/labs.js +20 -29
- package/package.json +1 -1
- package/src/gateway-client.js +36 -23
- package/src/ui.js +125 -44
package/bin/labs.js
CHANGED
|
@@ -17,36 +17,18 @@ const { planSubscriptionLeg, planLabsLegArgs, createWatcher } = require('../src/
|
|
|
17
17
|
const { version } = require('../package.json');
|
|
18
18
|
const { c, playMascotIntro, checkUpdateNotice, runSelfUpdate } = require('../src/ui');
|
|
19
19
|
|
|
20
|
-
const HELP = `labs ${version} — Run Claude Code on
|
|
20
|
+
const HELP = `labs ${version} — Run Claude Code on Qwen4-35B-A3B (1M context · Native Vision · Web Search)
|
|
21
21
|
|
|
22
|
-
labs open Claude Code on
|
|
23
|
-
labs --model
|
|
24
|
-
labs
|
|
25
|
-
labs
|
|
26
|
-
labs
|
|
27
|
-
labs
|
|
28
|
-
labs
|
|
29
|
-
labs
|
|
30
|
-
labs usage credits left and what recent sessions cost per model
|
|
31
|
-
labs setup set your ElevenLabs key, the bridge agent and real-Chrome control
|
|
32
|
-
labs bedrock save your Amazon Bedrock key, then: labs --model glm (GLM 5.3)
|
|
33
|
-
labs --model qwen Claude Code on our GPU box (qwen | qwen-uncensored), through the labs gateway
|
|
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)
|
|
41
|
-
labs admin-token <ssh> make a new console admin token on the gateway server
|
|
42
|
-
labs chat open the private chat page (http://127.0.0.1:8081/chat)
|
|
43
|
-
labs serve start the background proxy if it is not running, then exit
|
|
44
|
-
labs autostart on|off keep the proxy (and the chat page) running from login (Windows)
|
|
45
|
-
labs stop stop the background proxy
|
|
22
|
+
labs open Claude Code directly on Qwen4-35B-A3B (1M ctx, high effort)
|
|
23
|
+
labs --model qwen explicitly launch Qwen4-35B-A3B (also: --model qwen-uncensored)
|
|
24
|
+
labs -p "question" any Claude Code flag works (-p, --resume, --effort max, etc.)
|
|
25
|
+
labs setup interactive mascot setup (paste lk_... key, choose effort)
|
|
26
|
+
labs key [lk_...] save or rotate your labs API key
|
|
27
|
+
labs models list available engines (Qwen4-35B-A3B live + upcoming)
|
|
28
|
+
labs update update labs-claude to the latest npm version in 1 command
|
|
29
|
+
labs admin [subcommand] admin terminal control room (stats | create | pause | resume | revoke | usage)
|
|
46
30
|
|
|
47
|
-
Inside Claude Code: /
|
|
48
|
-
Browser: "open gmail.com and read my top email" uses your real Chrome (set up with labs setup)
|
|
49
|
-
Update: npm install -g labs-claude@latest --prefer-online, then close and reopen every labs window`;
|
|
31
|
+
Inside Claude Code: /effort low | high | max adjusts reasoning depth live.`;
|
|
50
32
|
|
|
51
33
|
function printModels(config, showAll) {
|
|
52
34
|
const llms = loadLlmList();
|
|
@@ -376,7 +358,16 @@ async function main() {
|
|
|
376
358
|
else config.defaultModel = 'hydrogen'; // gemini-4-hydrogen works via ElevenLabs gateway; setup will prompt if needed
|
|
377
359
|
}
|
|
378
360
|
|
|
379
|
-
if (args[0] === 'models')
|
|
361
|
+
if (args[0] === 'models') {
|
|
362
|
+
console.log(`\n ${c.bold(c.white('labs engines'))}\n`);
|
|
363
|
+
console.log(` ${c.cyan('1.')} ${c.bold('qwen')} ${c.mint('● live')} ${c.dim('Qwen4-35B-A3B · 1m context · vision · web · 200-400 tok/s ← default')}`);
|
|
364
|
+
console.log(` ${c.cyan('2.')} ${c.bold('qwen-uncensored')} ${c.mint('● live')} ${c.dim('same qwen4 engine, uncensored alias 💀')}`);
|
|
365
|
+
console.log(` ${c.dim('3. opus ○ coming soon')}`);
|
|
366
|
+
console.log(` ${c.dim('4. gemini ○ coming soon')}`);
|
|
367
|
+
console.log(` ${c.dim('5. glm ○ coming soon')}\n`);
|
|
368
|
+
console.log(` ${c.dim('start:')} ${c.cyan('labs')} ${c.dim('effort inside chat:')} ${c.cyan('/effort low | high | max')}\n`);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
380
371
|
if (args[0] === 'usage') return printUsage(config);
|
|
381
372
|
if (args[0] === 'chat') return openChat(config);
|
|
382
373
|
if (args[0] === 'stop') return console.log(await stopProxy(config.port) ? '🛑 Proxy stopped' : 'Proxy was not running');
|
package/package.json
CHANGED
package/src/gateway-client.js
CHANGED
|
@@ -7,21 +7,27 @@ const path = require('path');
|
|
|
7
7
|
const { execFileSync, spawn } = require('child_process');
|
|
8
8
|
const { CONFIG_PATH, LABS_DIR, saveConfig } = require('./config');
|
|
9
9
|
const { withBypassDefault } = require('./launch-args');
|
|
10
|
-
const { c, randomQuip, playMascotIntro, withSpinner, printCard } = require('./ui');
|
|
10
|
+
const { c, randomQuip, playMascotIntro, askMasked, withSpinner, printCard } = require('./ui');
|
|
11
11
|
const { version } = require('../package.json');
|
|
12
12
|
|
|
13
|
-
const GATEWAY_MODELS = {
|
|
13
|
+
const GATEWAY_MODELS = {
|
|
14
|
+
qwen: 'qwen-normal',
|
|
15
|
+
qwen4: 'qwen-normal',
|
|
16
|
+
'qwen4-35b': 'qwen-normal',
|
|
17
|
+
'qwen-normal': 'qwen-normal',
|
|
18
|
+
'qwen-uncensored': 'qwen-uncensored'
|
|
19
|
+
};
|
|
14
20
|
const DEFAULT_GATEWAY_URL = 'https://labs.instant.uz';
|
|
15
21
|
const ADMIN_TOKEN_FILE = path.join(LABS_DIR, 'gateway-admin');
|
|
16
|
-
// Same capability list the box's own claude-local uses, so /effort and thinking work on
|
|
22
|
+
// Same capability list the box's own claude-local uses, so /effort, xhigh, max, and thinking work on Qwen4.
|
|
17
23
|
const CAPS = 'effort,xhigh_effort,max_effort,thinking,interleaved_thinking';
|
|
18
24
|
|
|
19
|
-
//
|
|
20
|
-
function boxOnlyArgs(args, stored
|
|
25
|
+
// Whenever a labs key is configured, bare `labs` ALWAYS launches Qwen4 (never falls back into ElevenLabs).
|
|
26
|
+
function boxOnlyArgs(args, stored) {
|
|
21
27
|
const named = args.some(a => a === '--model' || a.startsWith('--model='));
|
|
22
|
-
const command = ['models', 'usage', 'chat', 'stop', 'setup', 'update'].includes(args[0]);
|
|
28
|
+
const command = ['models', 'usage', 'chat', 'stop', 'setup', 'update', 'admin', 'key', 'console', 'paint'].includes(args[0]);
|
|
23
29
|
const defaultModel = stored.defaultBoxModel || 'qwen';
|
|
24
|
-
return !named && !command && stored.gatewayKey
|
|
30
|
+
return !named && !command && stored.gatewayKey ? ['--model', defaultModel, ...args] : null;
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
function gatewayModelFrom(args) {
|
|
@@ -44,22 +50,24 @@ async function boxModels(url, key) {
|
|
|
44
50
|
// `labs key lk_...` takes the key from the command line: on Windows PowerShell a Ctrl+V into the hidden prompt can
|
|
45
51
|
// arrive empty (a friend saw "does not look like a labs key" with a correct lk_ key, 22 Nov).
|
|
46
52
|
async function saveGatewayKey(askHidden, ask, givenKey, skipIntro = false) {
|
|
47
|
-
if (!skipIntro) await playMascotIntro(version, 'Qwen4 1M ·
|
|
53
|
+
if (!skipIntro) await playMascotIntro(version, 'Qwen4-35B-A3B · 1M Context · Vision · Web');
|
|
48
54
|
const stored = storedConfig();
|
|
49
55
|
const url = (stored.gatewayUrl || DEFAULT_GATEWAY_URL).replace(/\/+$/, '');
|
|
50
|
-
const key = givenKey
|
|
56
|
+
const key = givenKey
|
|
57
|
+
? String(givenKey).trim()
|
|
58
|
+
: await askMasked(` ${c.cyan('[1/3]')} ${c.amber('🔑')} Paste your API key ${c.dim('(lk_...)')}: `);
|
|
51
59
|
if (!/^lk_[A-Za-z0-9_-]{20,}$/.test(key)) {
|
|
52
60
|
console.log(key
|
|
53
61
|
? ` ${c.rose('✖')} That does not look like a valid labs key (it starts with ${c.bold('lk_')}). Nothing saved.`
|
|
54
|
-
: ` ${c.rose('✖')} Nothing arrived
|
|
62
|
+
: ` ${c.rose('✖')} Nothing arrived. Run with the key directly:\n ${c.cyan('labs key lk_your_key_here')}`);
|
|
55
63
|
return process.exit(1);
|
|
56
64
|
}
|
|
57
65
|
let models = [];
|
|
58
66
|
try {
|
|
59
67
|
models = await withSpinner(randomQuip(), () => boxModels(url, key));
|
|
60
68
|
console.log(models.length
|
|
61
|
-
? ` ${c.mint('✔')}
|
|
62
|
-
: ` ${c.mint('✔')}
|
|
69
|
+
? ` ${c.mint('✔')} Key verified · ${c.bold('Qwen4-35B-A3B')} online ${c.dim('(1M ctx · Vision · Web)')}`
|
|
70
|
+
: ` ${c.mint('✔')} Key verified · ${c.amber('GPU box is sleeping right now (ready as soon as it wakes).')}`);
|
|
63
71
|
} catch (error) {
|
|
64
72
|
const status = error.response?.status;
|
|
65
73
|
console.log(status === 401
|
|
@@ -68,21 +76,20 @@ async function saveGatewayKey(askHidden, ask, givenKey, skipIntro = false) {
|
|
|
68
76
|
return process.exit(1);
|
|
69
77
|
}
|
|
70
78
|
|
|
71
|
-
let defaultBoxModel =
|
|
79
|
+
let defaultBoxModel = 'qwen';
|
|
72
80
|
let defaultEffort = stored.defaultEffort || 'high';
|
|
73
81
|
if (process.stdin.isTTY) {
|
|
74
|
-
console.log(`\n ${c.bold('
|
|
75
|
-
console.log(` ${c.cyan('1.')} ${c.bold('Qwen4
|
|
82
|
+
console.log(`\n ${c.cyan('[2/3]')} ${c.bold('Choose default engine:')}`);
|
|
83
|
+
console.log(` ${c.cyan('1.')} ${c.bold('Qwen4-35B-A3B')} ${c.mint('● LIVE')} ${c.dim('1M ctx · Native Vision · Web · 200–400 tok/s [Default]')}`);
|
|
76
84
|
console.log(` ${c.dim('2. Opus 5.5 ○ In progress (coming soon)')}`);
|
|
77
85
|
console.log(` ${c.dim('3. Gemini 4 ○ In progress (coming soon)')}`);
|
|
78
86
|
console.log(` ${c.dim('4. GLM 5.3 ○ In progress (coming soon)')}`);
|
|
79
87
|
const mChoice = await ask(' Choose [1]: ');
|
|
80
88
|
if (mChoice && mChoice !== '1') {
|
|
81
|
-
console.log(` ${c.amber('⚡')} Still cooking that one in the lab — locking in ${c.cyan('Qwen4
|
|
89
|
+
console.log(` ${c.amber('⚡')} Still cooking that one in the lab — locking in ${c.cyan('Qwen4-35B-A3B')} for now!`);
|
|
82
90
|
}
|
|
83
|
-
defaultBoxModel = 'qwen';
|
|
84
91
|
|
|
85
|
-
console.log(`\n ${c.bold('
|
|
92
|
+
console.log(`\n ${c.cyan('[3/3]')} ${c.bold('Choose default thinking effort:')}`);
|
|
86
93
|
console.log(` ${c.cyan('1.')} ${c.bold('high')} ${c.dim('Best everyday balance (auto-skips thinking on easy prompts) [Default]')}`);
|
|
87
94
|
console.log(` ${c.cyan('2.')} ${c.bold('xhigh')} ${c.dim('Deepest reasoning for tough bugs & architecture (max)')}`);
|
|
88
95
|
console.log(` ${c.cyan('3.')} ${c.bold('low')} ${c.dim('Minimal thinking, fastest multi-agent speed')}`);
|
|
@@ -92,9 +99,11 @@ async function saveGatewayKey(askHidden, ask, givenKey, skipIntro = false) {
|
|
|
92
99
|
else defaultEffort = 'high';
|
|
93
100
|
}
|
|
94
101
|
|
|
95
|
-
|
|
102
|
+
// Strip any stale ElevenLabs keys so bare `labs` never falls back into ElevenLabs.
|
|
103
|
+
const { apiKey: _oldEl, bridgeAgent: _oldBridge, ...cleanStored } = stored;
|
|
104
|
+
saveConfig({ ...cleanStored, gatewayUrl: url, gatewayKey: key, defaultBoxModel, defaultEffort });
|
|
96
105
|
printCard('READY TO SHIP · HOW LABS WORKS', [
|
|
97
|
-
`${c.mint('Start coding:')} ${c.cyan('labs')} ${c.dim('(opens Claude Code on Qwen4 1M
|
|
106
|
+
`${c.mint('Start coding:')} ${c.cyan('labs')} ${c.dim('(opens Claude Code on Qwen4-35B-A3B · 1M · Vision)')}`,
|
|
98
107
|
`${c.mint('Change IQ:')} ${c.cyan('/effort low')} ${c.dim('|')} ${c.cyan('/effort high')} ${c.dim('|')} ${c.cyan('/effort max')} ${c.dim('inside chat')}`,
|
|
99
108
|
`${c.mint('Re-configure:')} ${c.cyan('labs setup')} ${c.dim('(change key or effort anytime)')}`,
|
|
100
109
|
`${c.mint('Auto-update:')} ${c.cyan('labs update')} ${c.dim('(1-command latest version)')}`,
|
|
@@ -126,12 +135,17 @@ async function prepareGatewayLaunch(config, args, picked) {
|
|
|
126
135
|
|
|
127
136
|
const claudeArgs = args.filter((_, i) => i !== picked.index && (picked.inline || i !== picked.index + 1));
|
|
128
137
|
if (!claudeArgs.some(a => a === '--effort' || a.startsWith('--effort='))) claudeArgs.push('--effort', config.defaultEffort || 'high');
|
|
138
|
+
const ctxLabel = (model.max_model_len || 131072) >= 1000000 ? '1m context' : `${Math.round((model.max_model_len || 131072) / 1000)}k context`;
|
|
139
|
+
const displayName = picked.id === 'qwen-uncensored' ? 'Qwen4-35B-A3B (uncensored)' : 'Qwen4-35B-A3B';
|
|
129
140
|
const env = {
|
|
130
141
|
...process.env,
|
|
131
142
|
ANTHROPIC_BASE_URL: url,
|
|
132
143
|
ANTHROPIC_AUTH_TOKEN: config.gatewayKey,
|
|
133
144
|
ANTHROPIC_MODEL: picked.id,
|
|
134
|
-
|
|
145
|
+
ANTHROPIC_CUSTOM_MODEL_OPTION: picked.id,
|
|
146
|
+
ANTHROPIC_CUSTOM_MODEL_OPTION_NAME: displayName,
|
|
147
|
+
ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION: `${displayName} · ${ctxLabel} · vision · web · 200-400 tok/s`,
|
|
148
|
+
// Every row Claude Code can fall back to points at the same box model, so side calls and subagents stay on Qwen4.
|
|
135
149
|
ANTHROPIC_DEFAULT_OPUS_MODEL: picked.id,
|
|
136
150
|
ANTHROPIC_DEFAULT_SONNET_MODEL: picked.id,
|
|
137
151
|
ANTHROPIC_DEFAULT_HAIKU_MODEL: picked.id,
|
|
@@ -142,8 +156,7 @@ async function prepareGatewayLaunch(config, args, picked) {
|
|
|
142
156
|
CLAUDE_CODE_MAX_CONTEXT_TOKENS: String(model.max_model_len || 131072)
|
|
143
157
|
};
|
|
144
158
|
for (const name of ['ANTHROPIC_API_KEY', 'ANTHROPIC_CUSTOM_HEADERS']) delete env[name];
|
|
145
|
-
const
|
|
146
|
-
const banner = `${c.mint('🚀')} ${c.bold('Claude Code')} on ${c.cyan(picked.id)} ${c.dim(`(${ctxLabel} · Vision · Web)`)} via ${c.dim(url)}\n ${c.violet('✦')} ${c.dim(randomQuip())}`;
|
|
159
|
+
const banner = `${c.mint('🚀')} ${c.bold('claude code')} on ${c.cyan(displayName)} ${c.dim(`(${ctxLabel} · vision · web)`)}\n ${c.violet('✦')} ${c.dim(randomQuip(picked.id))}`;
|
|
147
160
|
// Qwen cannot use Claude Code's WebSearch (an Anthropic server tool); give it a search tool that runs here instead.
|
|
148
161
|
if (!claudeArgs.some(a => a === '--strict-mcp-config')) claudeArgs.push(...require('./web-mcp').webMcpArgs());
|
|
149
162
|
return { claudeArgs: withBypassDefault(claudeArgs), env, banner };
|
package/src/ui.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
1
|
+
// Top-tier terminal UI: 24-bit RGB gradients, animated LABS mascot, live *-masked input,
|
|
2
|
+
// Karpathy-mode humor quips, boxed cards, and non-blocking npm auto-update check.
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const readline = require('readline');
|
|
5
6
|
const { spawnSync } = require('child_process');
|
|
6
7
|
|
|
7
8
|
const USE_COLOR = Boolean(process.stdout.isTTY && !process.env.NO_COLOR);
|
|
@@ -18,9 +19,23 @@ const c = {
|
|
|
18
19
|
white: s => ansi('38;2;248;250;252', s),
|
|
19
20
|
};
|
|
20
21
|
|
|
22
|
+
function gradient(text, from = [56, 189, 248], to = [167, 139, 250]) {
|
|
23
|
+
if (!USE_COLOR) return String(text);
|
|
24
|
+
const chars = [...String(text)];
|
|
25
|
+
const len = Math.max(1, chars.length - 1);
|
|
26
|
+
return chars.map((ch, i) => {
|
|
27
|
+
if (ch === ' ') return ' ';
|
|
28
|
+
const t = i / len;
|
|
29
|
+
const r = Math.round(from[0] + (to[0] - from[0]) * t);
|
|
30
|
+
const g = Math.round(from[1] + (to[1] - from[1]) * t);
|
|
31
|
+
const b = Math.round(from[2] + (to[2] - from[2]) * t);
|
|
32
|
+
return `\x1b[38;2;${r};${g};${b}m${ch}`;
|
|
33
|
+
}).join('') + '\x1b[0m';
|
|
34
|
+
}
|
|
35
|
+
|
|
21
36
|
const MASCOT_FRAMES = [
|
|
22
37
|
[
|
|
23
|
-
' ╭───╮
|
|
38
|
+
' ╭───╮ · ',
|
|
24
39
|
' ╭──┴───┴──╮ ',
|
|
25
40
|
' │ ◉ ◉ │ ',
|
|
26
41
|
' │ ◡ │ ',
|
|
@@ -29,7 +44,7 @@ const MASCOT_FRAMES = [
|
|
|
29
44
|
' ╰─────────╯ ',
|
|
30
45
|
],
|
|
31
46
|
[
|
|
32
|
-
'
|
|
47
|
+
' · ╭───╮ ✦ ',
|
|
33
48
|
' ╭──┴───┴──╮ ',
|
|
34
49
|
' │ ◉ ◉ │ ',
|
|
35
50
|
' │ ◡ │ ',
|
|
@@ -38,7 +53,7 @@ const MASCOT_FRAMES = [
|
|
|
38
53
|
' ╰─────────╯ ',
|
|
39
54
|
],
|
|
40
55
|
[
|
|
41
|
-
' ✦ ╭───╮
|
|
56
|
+
' ✦ ╭───╮ ✧ ',
|
|
42
57
|
' ╭──┴───┴──╮ ',
|
|
43
58
|
' │ ◠ ◠ │ ',
|
|
44
59
|
' │ ◡ │ ',
|
|
@@ -46,55 +61,121 @@ const MASCOT_FRAMES = [
|
|
|
46
61
|
' ╱ ▓▓▓▓▓ ╲ ',
|
|
47
62
|
' ╰─────────╯ ',
|
|
48
63
|
],
|
|
64
|
+
[
|
|
65
|
+
' ✧ ╭───╮ ✦ ',
|
|
66
|
+
' ╭──┴───┴──╮ ',
|
|
67
|
+
' │ ◉ ◉ │ ',
|
|
68
|
+
' │ ◡ │ ',
|
|
69
|
+
' ╰─┬─────┬─╯ ',
|
|
70
|
+
' ╱ █████ ╲ ',
|
|
71
|
+
' ╰─────────╯ ',
|
|
72
|
+
],
|
|
49
73
|
];
|
|
50
74
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
'
|
|
55
|
-
'
|
|
56
|
-
'
|
|
57
|
-
'
|
|
58
|
-
'
|
|
59
|
-
'
|
|
60
|
-
'Calibrating xhigh reasoning... please hold while the model overthinks...',
|
|
61
|
-
'Zero corporate rate limits detected. Full local throttle engaged.',
|
|
75
|
+
const CHILL_QUIPS = [
|
|
76
|
+
'hehe, spinning up qwen4... try not to hack into nasa 💀',
|
|
77
|
+
'bro really opened another terminal tab 😭 loading 1m context...',
|
|
78
|
+
'warming up 256 experts (8 are working, 248 are chilling) 💀',
|
|
79
|
+
'no rate limits, no drama, just pure speed ⚡',
|
|
80
|
+
'loading 1m context... still smaller than your open chrome tabs 😭',
|
|
81
|
+
'convincing the gpu to go brrr at 400 tok/s...',
|
|
82
|
+
'if this takes more than 2 seconds blame wifi not me 💀',
|
|
83
|
+
'unlocking vision + web search... lock in bro ⚡',
|
|
62
84
|
];
|
|
63
85
|
|
|
64
|
-
function randomQuip() {
|
|
65
|
-
|
|
86
|
+
function randomQuip(modelId = '') {
|
|
87
|
+
if (String(modelId).includes('uncensored')) {
|
|
88
|
+
return 'hehe, going uncensored mode 💀 which one are you hacking into, nasa? 😭';
|
|
89
|
+
}
|
|
90
|
+
return CHILL_QUIPS[Math.floor(Math.random() * CHILL_QUIPS.length)];
|
|
66
91
|
}
|
|
67
92
|
|
|
68
|
-
|
|
93
|
+
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
94
|
+
|
|
95
|
+
async function playMascotIntro(version, subtitle = 'Qwen4-35B-A3B · 1M Context · Vision · Web') {
|
|
69
96
|
const quip = randomQuip();
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
]
|
|
82
|
-
|
|
83
|
-
|
|
97
|
+
const wordmark = gradient('█░░ ▄▀█ █▄▄ █▀', [56, 189, 248], [52, 211, 153]);
|
|
98
|
+
const wordmark2 = gradient('█▄▄ █▀█ █▄█ ▄█', [167, 139, 250], [56, 189, 248]);
|
|
99
|
+
|
|
100
|
+
const paintFrame = (frame, fromRgb, toRgb) => [
|
|
101
|
+
'',
|
|
102
|
+
` ${gradient(frame[0], fromRgb, toRgb)} ${wordmark} ${c.violet(`v${version}`)}`,
|
|
103
|
+
` ${gradient(frame[1], fromRgb, toRgb)} ${wordmark2}`,
|
|
104
|
+
` ${c.cyan(frame[2])} ${c.white(subtitle)}`,
|
|
105
|
+
` ${c.cyan(frame[3])} ${c.mint('✦')} ${c.dim(quip)}`,
|
|
106
|
+
` ${gradient(frame[4], fromRgb, toRgb)}`,
|
|
107
|
+
` ${gradient(frame[5], [52, 211, 153], [56, 189, 248])}`,
|
|
108
|
+
` ${c.mint(frame[6])}`,
|
|
109
|
+
'',
|
|
110
|
+
].join('\n');
|
|
84
111
|
|
|
85
112
|
if (!USE_COLOR) {
|
|
86
|
-
console.log(paintFrame(MASCOT_FRAMES[
|
|
113
|
+
console.log(paintFrame(MASCOT_FRAMES[3], [56, 189, 248], [52, 211, 153]));
|
|
87
114
|
return;
|
|
88
115
|
}
|
|
89
116
|
|
|
90
|
-
const
|
|
117
|
+
const palettes = [
|
|
118
|
+
[[167, 139, 250], [56, 189, 248]],
|
|
119
|
+
[[56, 189, 248], [52, 211, 153]],
|
|
120
|
+
[[52, 211, 153], [167, 139, 250]],
|
|
121
|
+
[[56, 189, 248], [52, 211, 153]],
|
|
122
|
+
];
|
|
91
123
|
for (let i = 0; i < MASCOT_FRAMES.length; i += 1) {
|
|
92
124
|
if (i > 0) process.stdout.write('\x1b[9A\x1b[0J');
|
|
93
|
-
process.stdout.write(paintFrame(MASCOT_FRAMES[i],
|
|
94
|
-
if (i < MASCOT_FRAMES.length - 1) await sleep(
|
|
125
|
+
process.stdout.write(paintFrame(MASCOT_FRAMES[i], palettes[i][0], palettes[i][1]) + '\n');
|
|
126
|
+
if (i < MASCOT_FRAMES.length - 1) await sleep(110);
|
|
95
127
|
}
|
|
96
128
|
}
|
|
97
129
|
|
|
130
|
+
// Live *-masked input so pasting or typing an API key feels responsive instead of frozen.
|
|
131
|
+
function askMasked(promptText) {
|
|
132
|
+
return new Promise(resolve => {
|
|
133
|
+
if (!process.stdin.isTTY) {
|
|
134
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
135
|
+
rl.question(promptText, ans => { rl.close(); resolve(ans.trim()); });
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
process.stdout.write(promptText);
|
|
139
|
+
const stdin = process.stdin;
|
|
140
|
+
const wasRaw = stdin.isRaw;
|
|
141
|
+
stdin.setRawMode(true);
|
|
142
|
+
stdin.resume();
|
|
143
|
+
stdin.setEncoding('utf8');
|
|
144
|
+
let value = '';
|
|
145
|
+
const cleanup = () => {
|
|
146
|
+
stdin.removeListener('data', onData);
|
|
147
|
+
stdin.setRawMode(Boolean(wasRaw));
|
|
148
|
+
stdin.pause();
|
|
149
|
+
};
|
|
150
|
+
const onData = chunk => {
|
|
151
|
+
for (const ch of chunk) {
|
|
152
|
+
if (ch === '\r' || ch === '\n') {
|
|
153
|
+
cleanup();
|
|
154
|
+
process.stdout.write('\n');
|
|
155
|
+
return resolve(value.trim());
|
|
156
|
+
}
|
|
157
|
+
if (ch === '\u0003') {
|
|
158
|
+
cleanup();
|
|
159
|
+
process.stdout.write('\n');
|
|
160
|
+
process.exit(130);
|
|
161
|
+
}
|
|
162
|
+
if (ch === '\u007f' || ch === '\b') {
|
|
163
|
+
if (value.length > 0) {
|
|
164
|
+
value = value.slice(0, -1);
|
|
165
|
+
process.stdout.write('\b \b');
|
|
166
|
+
}
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (ch >= ' ') {
|
|
170
|
+
value += ch;
|
|
171
|
+
process.stdout.write(c.mint('*'));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
stdin.on('data', onData);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
98
179
|
async function withSpinner(label, fn) {
|
|
99
180
|
if (!USE_COLOR) {
|
|
100
181
|
process.stdout.write(` ... ${label}\n`);
|
|
@@ -104,22 +185,22 @@ async function withSpinner(label, fn) {
|
|
|
104
185
|
let idx = 0;
|
|
105
186
|
const timer = setInterval(() => {
|
|
106
187
|
process.stdout.write(`\r ${c.cyan(frames[idx++ % frames.length])} ${c.dim(label)}`);
|
|
107
|
-
},
|
|
188
|
+
}, 70);
|
|
108
189
|
try {
|
|
109
190
|
const result = await fn();
|
|
110
191
|
clearInterval(timer);
|
|
111
|
-
process.stdout.write(`\r ${c.mint('✔')} ${label}${' '.repeat(
|
|
192
|
+
process.stdout.write(`\r ${c.mint('✔')} ${label}${' '.repeat(14)}\n`);
|
|
112
193
|
return result;
|
|
113
194
|
} catch (error) {
|
|
114
195
|
clearInterval(timer);
|
|
115
|
-
process.stdout.write(`\r ${c.rose('✖')} ${label}${' '.repeat(
|
|
196
|
+
process.stdout.write(`\r ${c.rose('✖')} ${label}${' '.repeat(14)}\n`);
|
|
116
197
|
throw error;
|
|
117
198
|
}
|
|
118
199
|
}
|
|
119
200
|
|
|
120
201
|
function printCard(title, rows) {
|
|
121
202
|
const strip = s => String(s).replace(/\x1b\[[0-9;]*m/g, '');
|
|
122
|
-
const width = Math.max(
|
|
203
|
+
const width = Math.max(46, strip(title).length + 4, ...rows.map(r => strip(r).length + 4));
|
|
123
204
|
const top = ` ${c.violet('╭─')} ${c.bold(c.white(title))} ${c.violet('─'.repeat(Math.max(1, width - strip(title).length - 3)) + '╮')}`;
|
|
124
205
|
const bot = ` ${c.violet('╰' + '─'.repeat(width + 1) + '╯')}`;
|
|
125
206
|
console.log('');
|
|
@@ -151,10 +232,10 @@ function checkUpdateNotice(currentVersion, labsDir) {
|
|
|
151
232
|
} catch { /* ignore corrupt cache */ }
|
|
152
233
|
|
|
153
234
|
if (cached && cached.latest && isNewerVersion(cached.latest, currentVersion)) {
|
|
154
|
-
console.log(` ${c.amber('⬆')} ${c.bold(
|
|
235
|
+
console.log(` ${c.amber('⬆')} ${c.bold('Update available:')} ${c.dim(currentVersion)} → ${c.mint(cached.latest)} ${c.dim('Run:')} ${c.cyan('labs update')}`);
|
|
155
236
|
}
|
|
156
237
|
|
|
157
|
-
const stale = !cached || (Date.now() - (cached.checkedAt || 0)) >
|
|
238
|
+
const stale = !cached || (Date.now() - (cached.checkedAt || 0)) > 6 * 3600e3;
|
|
158
239
|
if (stale && typeof fetch === 'function') {
|
|
159
240
|
fetch('https://registry.npmjs.org/labs-claude/latest', { signal: AbortSignal.timeout(2500) })
|
|
160
241
|
.then(r => (r.ok ? r.json() : null))
|
|
@@ -185,4 +266,4 @@ function runSelfUpdate(currentVersion) {
|
|
|
185
266
|
console.log(`\n ${c.mint('✔')} Updated to latest! Close and reopen any open labs terminals.\n`);
|
|
186
267
|
}
|
|
187
268
|
|
|
188
|
-
module.exports = { c,
|
|
269
|
+
module.exports = { c, gradient, CHILL_QUIPS, randomQuip, playMascotIntro, askMasked, withSpinner, printCard, isNewerVersion, checkUpdateNotice, runSelfUpdate };
|