labs-claude 0.4.1 → 0.5.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 CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  const axios = require('axios');
3
3
  const { spawn } = require('child_process');
4
4
  const { randomUUID } = require('crypto');
@@ -336,6 +336,10 @@ async function main() {
336
336
  // Box users (friends) may have no ElevenLabs account at all, so these never fall into the ElevenLabs setup.
337
337
  if (args[0] === 'key') return saveGatewayKey(askHidden, ask, args[1]);
338
338
  if (args[0] === 'admin') return require('../src/admin-cli').runAdminCli(args.slice(1), ask);
339
+ if (args[0] === 'statusline') {
340
+ const { scriptPath } = require('../src/statusline').installStatusline();
341
+ return console.log(` ${c.mint('✔')} Cute Claude Code statusline installed (${c.dim(scriptPath)}). Reopen labs to see it!`);
342
+ }
339
343
  if (args[0] === 'paint') return require('../src/image-mcp').paintFromCli(args.slice(1));
340
344
  if (args[0] === 'admin-token') return makeAdminToken(args[1]);
341
345
  if (args[0] === 'console') return openConsole(storedConfig());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "labs-claude",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
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"
package/src/admin-cli.js CHANGED
@@ -6,7 +6,7 @@ const path = require('path');
6
6
  const { spawn } = require('child_process');
7
7
  const { LABS_DIR } = require('./config');
8
8
  const { storedConfig } = require('./gateway-client');
9
- const { c, randomQuip, playMascotIntro, withSpinner, printCard } = require('./ui');
9
+ const { c, sparkline, randomQuip, playMascotIntro, withSpinner, printCard } = require('./ui');
10
10
  const { version } = require('../package.json');
11
11
 
12
12
  const DEFAULT_GATEWAY_URL = 'https://labs.instant.uz';
@@ -72,24 +72,39 @@ function resolveKeyTarget(keys, target) {
72
72
  function renderDashboard(keys, usageRows, box) {
73
73
  const todayStr = new Date(Date.now() + 5 * 3600e3).toISOString().slice(0, 10);
74
74
  const todayRows = usageRows.filter(r => r.day === todayStr);
75
- const todayTotal = todayRows.reduce((s, r) => s + r.input + r.cache_read + r.cache_write + r.output, 0);
75
+ const todayIn = todayRows.reduce((s, r) => s + r.input, 0);
76
+ const todayCache = todayRows.reduce((s, r) => s + r.cache_read, 0);
76
77
  const todayOut = todayRows.reduce((s, r) => s + r.output, 0);
78
+ const todayTotal = todayRows.reduce((s, r) => s + r.input + r.cache_read + r.cache_write + r.output, 0);
77
79
  const todayCalls = todayRows.reduce((s, r) => s + r.calls, 0);
80
+ const cachePct = (todayIn + todayCache) > 0 ? Math.round((todayCache / (todayIn + todayCache)) * 100) : 0;
78
81
  const activeCount = keys.filter(k => k.status === 'active').length;
79
82
 
83
+ // 7-day daily token trend sparkline
84
+ const byDay = {};
85
+ for (const r of usageRows) {
86
+ byDay[r.day] = (byDay[r.day] || 0) + r.input + r.cache_read + r.cache_write + r.output;
87
+ }
88
+ const last7 = [];
89
+ for (let i = 6; i >= 0; i -= 1) {
90
+ const d = new Date(Date.now() + 5 * 3600e3 - i * 86400e3).toISOString().slice(0, 10);
91
+ last7.push(byDay[d] || 0);
92
+ }
93
+
80
94
  const boxPill = box.up
81
- ? `${c.mint('● ONLINE')} ${c.dim(`(${box.models.join(', ')})`)}`
82
- : `${c.rose('● SLEEPING')}`;
95
+ ? `${c.mint('ONLINE')} ${c.dim(`(${box.models.join(', ')})`)}`
96
+ : `${c.rose('SLEEPING')}`;
83
97
 
84
98
  printCard('LABS ADMIN CONTROL ROOM', [
85
- `${c.dim('GPU Box:')} ${boxPill}`,
86
- `${c.dim('Tokens Today:')} ${c.bold(c.mint(compactTokens(todayTotal)))} ${c.dim('Output:')} ${c.cyan(compactTokens(todayOut))} ${c.dim('Calls:')} ${c.violet(String(todayCalls))} ${c.dim('Active Keys:')} ${c.bold(String(activeCount))}`,
99
+ `${c.dim('gpu box:')} ${boxPill} ${c.dim('7d trend:')} ${sparkline(last7)}`,
100
+ `${c.dim('today:')} ${c.bold(c.mint(compactTokens(todayTotal)))} tok ${c.dim('out:')} ${c.cyan(compactTokens(todayOut))} ${c.dim('cache hit:')} ${c.violet(`${cachePct}%`)}`,
101
+ `${c.dim('calls today:')} ${c.bold(String(todayCalls))} ${c.dim('active keys:')} ${c.mint(String(activeCount))} ${c.dim('time:')} ${c.dim(new Date().toLocaleTimeString())}`,
87
102
  ]);
88
103
 
89
104
  const maxAll = Math.max(1, ...keys.map(k => Number(k.total_tokens || 0)));
90
105
  console.log(` ${c.bold(c.white('FRIEND KEYS & TOKEN LEADERBOARD'))}`);
91
- console.log(` ${c.dim('ID NAME STATUS TODAY ALL-TIME SHARE CALLS LAST ACTIVE')}`);
92
- console.log(` ${c.dim('─'.repeat(88))}`);
106
+ console.log(` ${c.dim('ID NAME STATUS TODAY ALL-TIME SHARE CALLS LAST ACTIVE')}`);
107
+ console.log(` ${c.dim('─'.repeat(90))}`);
93
108
  if (!keys.length) {
94
109
  console.log(` ${c.dim('No keys yet. Run: labs admin create <name>')}\n`);
95
110
  return;
@@ -97,7 +112,10 @@ function renderDashboard(keys, usageRows, box) {
97
112
  for (const k of keys) {
98
113
  const id = String(k.id).padEnd(4);
99
114
  const name = k.name.slice(0, 14).padEnd(15);
100
- const status = k.status === 'active' ? c.mint('active ') : c.amber('paused ');
115
+ const isCooking = k.last_seen && (Date.now() - new Date(k.last_seen).getTime()) < 90000;
116
+ const status = k.status !== 'active'
117
+ ? c.amber('paused ')
118
+ : isCooking ? c.mint('cooking🔥') : c.mint('active ');
101
119
  const today = compactTokens(k.today_tokens).padStart(9);
102
120
  const all = compactTokens(k.total_tokens).padStart(9);
103
121
  const bar = barChart(Number(k.total_tokens || 0), maxAll, 14);
@@ -203,16 +221,36 @@ async function runAdminCli(args, ask) {
203
221
  return;
204
222
  }
205
223
 
224
+ if (sub === 'watch' || sub === 'live') {
225
+ const fetchState = async () => {
226
+ const [k, u, b] = await Promise.all([api.get('/keys'), api.get('/usage?days=14'), api.get('/box')]);
227
+ return { keys: k.keys || [], rows: u.rows || [], box: b || { up: false, models: [] } };
228
+ };
229
+ const renderLive = async () => {
230
+ const st = await fetchState();
231
+ process.stdout.write('\x1b[2J\x1b[H');
232
+ renderDashboard(st.keys, st.rows, st.box);
233
+ console.log(` ${c.dim('live watch mode (refreshing every 3s) · press Ctrl+C to exit')}\n`);
234
+ };
235
+ await renderLive();
236
+ const timer = setInterval(() => { renderLive().catch(() => {}); }, 3000);
237
+ await new Promise(resolve => process.once('SIGINT', () => { clearInterval(timer); resolve(); }));
238
+ return;
239
+ }
240
+
206
241
  // Interactive menu loop
207
242
  let state = await loadAll(14);
208
243
  while (true) {
209
244
  renderDashboard(state.keys, state.rows, state.box);
210
- console.log(` ${c.bold('Actions:')}`);
211
- console.log(` ${c.cyan('1.')} Mint new friend API key ${c.cyan('4.')} Revoke (delete) a key`);
212
- console.log(` ${c.cyan('2.')} Pause a key ${c.cyan('5.')} Daily token table (14d)`);
213
- console.log(` ${c.cyan('3.')} Resume a key ${c.cyan('6.')} Refresh stats ${c.dim('q. Quit')}\n`);
245
+ console.log(` ${c.bold('actions:')}`);
246
+ console.log(` ${c.cyan('1.')} mint new friend api key ${c.cyan('4.')} revoke (delete) a key`);
247
+ console.log(` ${c.cyan('2.')} pause a key ${c.cyan('5.')} daily token table (14d)`);
248
+ console.log(` ${c.cyan('3.')} resume a key ${c.cyan('6.')} refresh stats ${c.cyan('w.')} live watch (3s) ${c.dim('q. quit')}\n`);
214
249
  const choice = (await ask(` ${c.violet('admin>')} `)).trim().toLowerCase();
215
250
  if (!choice || choice === 'q' || choice === 'quit' || choice === 'exit') break;
251
+ if (choice === 'w') {
252
+ return runAdminCli(['watch'], ask);
253
+ }
216
254
  if (choice === '1') {
217
255
  const name = (await ask(` ${c.cyan('?')} Friend name: `)).trim();
218
256
  if (name) {
@@ -101,12 +101,52 @@ async function saveGatewayKey(askHidden, ask, givenKey, skipIntro = false) {
101
101
 
102
102
  // Strip any stale ElevenLabs keys so bare `labs` never falls back into ElevenLabs.
103
103
  const { apiKey: _oldEl, bridgeAgent: _oldBridge, ...cleanStored } = stored;
104
- saveConfig({ ...cleanStored, gatewayUrl: url, gatewayKey: key, defaultBoxModel, defaultEffort });
104
+ let braveKey = cleanStored.braveKey || '';
105
+
106
+ if (!givenKey && process.stdin.isTTY) {
107
+ console.log(`\n ${c.violet('✨ optional power-ups (press enter to skip):')}`);
108
+
109
+ const addBrowser = await ask(` ${c.cyan('🌐')} connect your real chrome (playwright mcp)? ${c.dim('[y/N]:')} `);
110
+ if (/^y/i.test(addBrowser)) {
111
+ const { EXTENSION_URL, installBrowserServer } = require('./browser-setup');
112
+ console.log(` ${c.dim('1. install extension:')} ${c.cyan(EXTENSION_URL)}`);
113
+ console.log(` ${c.dim('2. click icon -> copy PLAYWRIGHT_MCP_EXTENSION_TOKEN (optional)')}`);
114
+ const tok = (await askMasked(` ${c.amber('🔑')} token ${c.dim('(or enter to skip):')} `)).replace(/^PLAYWRIGHT_MCP_EXTENSION_TOKEN=/, '');
115
+ try {
116
+ installBrowserServer(tok);
117
+ console.log(` ${c.mint('✔')} real chrome tools added (labs-browser)!`);
118
+ } catch (err) {
119
+ console.log(` ${c.rose('✖')} could not add chrome tools: ${err.message}`);
120
+ }
121
+ }
122
+
123
+ const addBrave = await ask(` ${c.cyan('🔎')} add your own free brave search api key? ${c.dim('[y/N]:')} `);
124
+ if (/^y/i.test(addBrave)) {
125
+ console.log(` ${c.dim('free key (2,000 searches/mo):')} ${c.cyan('https://api.search.brave.com/')}`);
126
+ const bk = await askMasked(` ${c.amber('🔑')} brave api key: `);
127
+ if (bk) {
128
+ braveKey = bk;
129
+ console.log(` ${c.mint('✔')} brave search key saved!`);
130
+ }
131
+ }
132
+
133
+ const addStatus = await ask(` ${c.cyan('🎨')} install cute claude code statusline ${c.dim('(model · folder · git · ctx%) [Y/n]:')} `);
134
+ if (!/^n/i.test(addStatus)) {
135
+ try {
136
+ require('./statusline').installStatusline();
137
+ console.log(` ${c.mint('✔')} cute statusline installed into ~/.claude/settings.json!`);
138
+ } catch (err) {
139
+ console.log(` ${c.rose('✖')} statusline skipped: ${err.message}`);
140
+ }
141
+ }
142
+ }
143
+
144
+ saveConfig({ ...cleanStored, ...(braveKey ? { braveKey } : {}), gatewayUrl: url, gatewayKey: key, defaultBoxModel, defaultEffort });
105
145
  printCard('READY TO SHIP · HOW LABS WORKS', [
106
- `${c.mint('Start coding:')} ${c.cyan('labs')} ${c.dim('(opens Claude Code on Qwen4-35B-A3B · 1M · Vision)')}`,
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')}`,
108
- `${c.mint('Re-configure:')} ${c.cyan('labs setup')} ${c.dim('(change key or effort anytime)')}`,
109
- `${c.mint('Auto-update:')} ${c.cyan('labs update')} ${c.dim('(1-command latest version)')}`,
146
+ `${c.mint('start coding:')} ${c.cyan('labs')} ${c.dim('(opens claude code on Qwen4-35B-A3B · 1m · vision)')}`,
147
+ `${c.mint('change iq:')} ${c.cyan('/effort low')} ${c.dim('|')} ${c.cyan('/effort high')} ${c.dim('|')} ${c.cyan('/effort max')} ${c.dim('inside chat')}`,
148
+ `${c.mint('re-configure:')} ${c.cyan('labs setup')} ${c.dim('(key, chrome mcp, brave, statusline)')}`,
149
+ `${c.mint('auto-update:')} ${c.dim('updates silently in background · manual:')} ${c.cyan('labs update')}`,
110
150
  ]);
111
151
  }
112
152
 
@@ -0,0 +1,60 @@
1
+ // Installs a clean, cute, zero-lag Claude Code statusline (`~/.labs/statusline.js`) into `~/.claude/settings.json`.
2
+ const fs = require('fs');
3
+ const os = require('os');
4
+ const path = require('path');
5
+ const { LABS_DIR } = require('./config');
6
+
7
+ const STATUSLINE_SCRIPT = `#!/usr/bin/env node
8
+ // Cute cracked-engineer Claude Code statusline (installed by labs setup)
9
+ const { execSync } = require('child_process');
10
+ const path = require('path');
11
+
12
+ let raw = '';
13
+ process.stdin.setEncoding('utf8');
14
+ process.stdin.on('data', d => { raw += d; });
15
+ process.stdin.on('end', () => {
16
+ let data = {};
17
+ try { data = JSON.parse(raw || '{}'); } catch {}
18
+ const model = data.model?.display_name || data.model?.id || 'Qwen4-35B-A3B';
19
+ const cwd = data.workspace?.current_dir || process.cwd();
20
+ const folder = path.basename(cwd);
21
+ const pct = data.context_window?.used_percentage;
22
+ let branch = '';
23
+ try {
24
+ branch = execSync('git rev-parse --abbrev-ref HEAD', { cwd, stdio: ['ignore', 'pipe', 'ignore'], timeout: 400 }).toString().trim();
25
+ } catch {}
26
+ const c = (rgb, s) => \`\\x1b[38;2;\${rgb}m\${s}\\x1b[0m\`;
27
+ const parts = [
28
+ c('52;211;153', '✦ ' + model),
29
+ c('56;189;248', '📁 ' + folder),
30
+ ];
31
+ if (branch) parts.push(c('167;139;250', '🌿 ' + branch));
32
+ if (pct != null) {
33
+ const color = pct > 75 ? '251;113;133' : pct > 45 ? '251;191;36' : '52;211;153';
34
+ parts.push(c(color, '🧠 ' + Math.round(pct) + '%'));
35
+ }
36
+ process.stdout.write(parts.join(c('100;116;139', ' · ')) + '\\n');
37
+ });
38
+ `;
39
+
40
+ function installStatusline() {
41
+ fs.mkdirSync(LABS_DIR, { recursive: true });
42
+ const scriptPath = path.join(LABS_DIR, 'statusline.js');
43
+ fs.writeFileSync(scriptPath, STATUSLINE_SCRIPT, { mode: 0o755 });
44
+
45
+ const claudeDir = path.join(os.homedir(), '.claude');
46
+ const settingsPath = path.join(claudeDir, 'settings.json');
47
+ fs.mkdirSync(claudeDir, { recursive: true });
48
+ let settings = {};
49
+ if (fs.existsSync(settingsPath)) {
50
+ try { settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8')); } catch { settings = {}; }
51
+ }
52
+ settings.statusLine = {
53
+ type: 'command',
54
+ command: `node "${scriptPath}"`,
55
+ };
56
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n', 'utf8');
57
+ return { scriptPath, settingsPath };
58
+ }
59
+
60
+ module.exports = { installStatusline };
package/src/ui.js CHANGED
@@ -3,7 +3,7 @@
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
5
  const readline = require('readline');
6
- const { spawnSync } = require('child_process');
6
+ const { spawn, spawnSync } = require('child_process');
7
7
 
8
8
  const USE_COLOR = Boolean(process.stdout.isTTY && !process.env.NO_COLOR);
9
9
  const ansi = (code, s) => (USE_COLOR ? `\x1b[${code}m${s}\x1b[0m` : String(s));
@@ -267,16 +267,41 @@ async function withSpinner(label, fn) {
267
267
  }
268
268
  }
269
269
 
270
+ function visibleWidth(str) {
271
+ const clean = String(str).replace(/\x1b\[[0-9;]*m/g, '');
272
+ let width = 0;
273
+ for (const ch of clean) {
274
+ const cp = ch.codePointAt(0);
275
+ // Wide emojis & CJK symbols occupy 2 terminal columns
276
+ if (cp >= 0x1F300 || (cp >= 0x2600 && cp <= 0x27BF)) width += 2;
277
+ else if (cp === 0xFE0F || cp === 0x200D) width += 0;
278
+ else width += 1;
279
+ }
280
+ return width;
281
+ }
282
+
283
+ function sparkline(values) {
284
+ const ticks = ['▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'];
285
+ const nums = (values || []).map(v => Math.max(0, Number(v) || 0));
286
+ if (!nums.length) return c.dim('▁▁▁▁▁▁▁');
287
+ const max = Math.max(1, ...nums);
288
+ return nums.map(v => {
289
+ const idx = v === 0 ? 0 : Math.min(ticks.length - 1, Math.max(1, Math.round((v / max) * (ticks.length - 1))));
290
+ return idx >= 5 ? c.mint(ticks[idx]) : idx >= 2 ? c.cyan(ticks[idx]) : c.dim(ticks[idx]);
291
+ }).join('');
292
+ }
293
+
270
294
  function printCard(title, rows) {
271
- const strip = s => String(s).replace(/\x1b\[[0-9;]*m/g, '');
272
- const width = Math.max(46, strip(title).length + 4, ...rows.map(r => strip(r).length + 4));
273
- const top = ` ${c.violet('╭─')} ${c.bold(c.white(title))} ${c.violet('─'.repeat(Math.max(1, width - strip(title).length - 3)) + '╮')}`;
274
- const bot = ` ${c.violet('╰' + '─'.repeat(width + 1) + '╯')}`;
295
+ const titleW = visibleWidth(title);
296
+ const width = Math.max(52, titleW + 6, ...rows.map(r => visibleWidth(r) + 4));
297
+ const topDash = Math.max(1, width - titleW - 3);
298
+ const top = ` ${c.violet('╭─')} ${c.bold(c.white(title))} ${c.violet('─'.repeat(topDash) + '╮')}`;
299
+ const bot = ` ${c.violet('╰' + '─'.repeat(width) + '╯')}`;
275
300
  console.log('');
276
301
  console.log(top);
277
302
  for (const row of rows) {
278
- const pad = Math.max(0, width - strip(row).length - 1);
279
- console.log(` ${c.violet('│')} ${row}${' '.repeat(pad)}${c.violet('│')}`);
303
+ const pad = Math.max(0, width - visibleWidth(row) - 2);
304
+ console.log(` ${c.violet('│')} ${row}${' '.repeat(pad)} ${c.violet('│')}`);
280
305
  }
281
306
  console.log(bot);
282
307
  console.log('');
@@ -292,7 +317,25 @@ function isNewerVersion(latest, current) {
292
317
  return false;
293
318
  }
294
319
 
295
- // Non-blocking 24h cached npm version check so friends always know when a newer labs-claude is out.
320
+ // Non-blocking auto-updater: checks npm in the background and silently installs newer versions
321
+ // in a detached process (once per version) so the next `labs` window is automatically up to date.
322
+ function spawnBackgroundUpdate(latest, cacheFile, cached) {
323
+ if (process.env.LABS_NO_AUTO_UPDATE === '1') return;
324
+ if (cached && cached.autoUpdatedTo === latest) return;
325
+ try {
326
+ fs.mkdirSync(path.dirname(cacheFile), { recursive: true });
327
+ fs.writeFileSync(cacheFile, JSON.stringify({ ...cached, latest, checkedAt: Date.now(), autoUpdatedTo: latest }));
328
+ const cmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
329
+ const child = spawn(cmd, ['install', '-g', `labs-claude@${latest}`, '--prefer-online', '--no-audit', '--no-fund'], {
330
+ stdio: 'ignore',
331
+ detached: true,
332
+ shell: process.platform === 'win32',
333
+ windowsHide: true,
334
+ });
335
+ child.unref();
336
+ } catch { /* silent fallback to manual labs update */ }
337
+ }
338
+
296
339
  function checkUpdateNotice(currentVersion, labsDir) {
297
340
  const cacheFile = path.join(labsDir, 'update-check.json');
298
341
  let cached = null;
@@ -301,17 +344,26 @@ function checkUpdateNotice(currentVersion, labsDir) {
301
344
  } catch { /* ignore corrupt cache */ }
302
345
 
303
346
  if (cached && cached.latest && isNewerVersion(cached.latest, currentVersion)) {
304
- console.log(` ${c.amber('⬆')} ${c.bold('Update available:')} ${c.dim(currentVersion)} → ${c.mint(cached.latest)} ${c.dim('Run:')} ${c.cyan('labs update')}`);
347
+ if (cached.autoUpdatedTo !== cached.latest) {
348
+ spawnBackgroundUpdate(cached.latest, cacheFile, cached);
349
+ console.log(` ${c.mint('⬆')} ${c.dim(`auto-updating labs`)} ${c.dim(currentVersion)} → ${c.cyan(cached.latest)} ${c.dim('in background (ready next window) ✨')}`);
350
+ } else {
351
+ console.log(` ${c.amber('⬆')} ${c.bold('update available:')} ${c.dim(currentVersion)} → ${c.mint(cached.latest)} ${c.dim('run:')} ${c.cyan('labs update')}`);
352
+ }
305
353
  }
306
354
 
307
- const stale = !cached || (Date.now() - (cached.checkedAt || 0)) > 6 * 3600e3;
355
+ const stale = !cached || (Date.now() - (cached.checkedAt || 0)) > 2 * 3600e3;
308
356
  if (stale && typeof fetch === 'function') {
309
357
  fetch('https://registry.npmjs.org/labs-claude/latest', { signal: AbortSignal.timeout(2500) })
310
358
  .then(r => (r.ok ? r.json() : null))
311
359
  .then(data => {
312
360
  if (!data?.version) return;
313
361
  fs.mkdirSync(labsDir, { recursive: true });
314
- fs.writeFileSync(cacheFile, JSON.stringify({ latest: data.version, checkedAt: Date.now() }));
362
+ const next = { ...(cached || {}), latest: data.version, checkedAt: Date.now() };
363
+ fs.writeFileSync(cacheFile, JSON.stringify(next));
364
+ if (isNewerVersion(data.version, currentVersion)) {
365
+ spawnBackgroundUpdate(data.version, cacheFile, next);
366
+ }
315
367
  })
316
368
  .catch(() => {});
317
369
  }
@@ -335,4 +387,4 @@ function runSelfUpdate(currentVersion) {
335
387
  console.log(`\n ${c.mint('✔')} Updated to latest! Close and reopen any open labs terminals.\n`);
336
388
  }
337
389
 
338
- module.exports = { c, gradient, CHILL_QUIPS, randomQuip, playMascotIntro, askMasked, withSpinner, printCard, isNewerVersion, checkUpdateNotice, runSelfUpdate };
390
+ module.exports = { c, gradient, visibleWidth, sparkline, CHILL_QUIPS, randomQuip, playMascotIntro, askMasked, withSpinner, printCard, isNewerVersion, checkUpdateNotice, runSelfUpdate };
package/src/web-mcp.js CHANGED
@@ -73,7 +73,18 @@ function pageText(htmlText) {
73
73
  return { title, text };
74
74
  }
75
75
 
76
- function createWeb({ fetchImpl = fetch, timeoutMs = 20000, braveKey = process.env.LABS_BRAVE_KEYS || process.env.LABS_BRAVE_KEY || '' } = {}) {
76
+ function storedBraveKey() {
77
+ try {
78
+ const fs = require('fs');
79
+ const path = require('path');
80
+ const os = require('os');
81
+ const cfgPath = path.join(os.homedir(), '.labs', 'config.json');
82
+ if (fs.existsSync(cfgPath)) return JSON.parse(fs.readFileSync(cfgPath, 'utf8')).braveKey || '';
83
+ } catch { /* ignore */ }
84
+ return '';
85
+ }
86
+
87
+ function createWeb({ fetchImpl = fetch, timeoutMs = 20000, braveKey = process.env.LABS_BRAVE_KEYS || process.env.LABS_BRAVE_KEY || storedBraveKey() } = {}) {
77
88
  const braveKeys = String(braveKey).split(',').map(s => s.trim()).filter(Boolean);
78
89
  let braveIdx = 0;
79
90
  const get = async (url, init = {}) => {