labs-claude 0.12.1 → 0.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "labs-claude",
3
- "version": "0.12.1",
3
+ "version": "0.12.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"
@@ -2,6 +2,7 @@
2
2
  // Box models skip the local ElevenLabs proxy: Claude Code talks to the gateway directly with the user's labs key.
3
3
  const axios = require('axios');
4
4
  const crypto = require('crypto');
5
+ const https = require('https');
5
6
  const fs = require('fs');
6
7
  const path = require('path');
7
8
  const { execFileSync, spawn } = require('child_process');
@@ -19,6 +20,7 @@ const GATEWAY_MODELS = {
19
20
  };
20
21
  const DEFAULT_GATEWAY_URL = 'https://labs.instant.uz';
21
22
  const ADMIN_TOKEN_FILE = path.join(LABS_DIR, 'gateway-admin');
23
+ const BOX_SETTINGS_FILE = path.join(LABS_DIR, 'box-settings.json');
22
24
  // Same capability list the box's own claude-local uses, so /effort, xhigh, max, and thinking work on Qwen4.
23
25
  const CAPS = 'effort,xhigh_effort,max_effort,thinking,interleaved_thinking';
24
26
 
@@ -45,9 +47,26 @@ function storedConfig() {
45
47
  return fs.existsSync(CONFIG_PATH) ? JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf8')) : {};
46
48
  }
47
49
 
48
- async function boxModels(url, key) {
49
- const { data } = await axios.get(`${url}/v1/models`, { headers: { 'x-api-key': key }, timeout: 8000 });
50
- return data.data || [];
50
+ const GATEWAY_HTTPS_AGENT = new https.Agent({ keepAlive: true, maxSockets: 4, family: 4 });
51
+
52
+ async function boxModels(url, key, retries = 3) {
53
+ let lastErr;
54
+ for (let i = 0; i < retries; i += 1) {
55
+ try {
56
+ const { data } = await axios.get(`${url}/v1/models`, {
57
+ headers: { 'x-api-key': key },
58
+ timeout: 6000,
59
+ httpsAgent: GATEWAY_HTTPS_AGENT,
60
+ });
61
+ return data.data || [];
62
+ } catch (err) {
63
+ lastErr = err;
64
+ const status = err?.response?.status;
65
+ if (status && status < 500) throw err;
66
+ if (i < retries - 1) await new Promise(r => setTimeout(r, 500 * (i + 1)));
67
+ }
68
+ }
69
+ throw lastErr;
51
70
  }
52
71
 
53
72
  // `labs key lk_...` takes the key from the command line: on Windows PowerShell a Ctrl+V into the hidden prompt can
@@ -199,32 +218,52 @@ async function prepareGatewayLaunch(config, args, picked) {
199
218
 
200
219
  const claudeArgs = args.filter((_, i) => i !== picked.index && (picked.inline || i !== picked.index + 1));
201
220
  if (!claudeArgs.some(a => a === '--effort' || a.startsWith('--effort='))) claudeArgs.push('--effort', config.defaultEffort || 'high');
202
- const ctxLabel = (model.max_model_len || 131072) >= 1000000 ? '1m context' : `${Math.round((model.max_model_len || 131072) / 1000)}k context`;
203
- const displayName = picked.id === 'qwen-uncensored' ? 'Qwen4-35B-A3B (uncensored)' : 'Qwen4-35B-A3B';
221
+ const ctxLabelFor = m => ((m?.max_model_len || 131072) >= 1000000 ? '1m context' : `${Math.round((m?.max_model_len || 131072) / 1000)}k context`);
222
+ const labelFor = id => (id === 'qwen-uncensored' ? 'Qwen4-35B-A3B (uncensored)' : id === 'qwen-normal' ? 'Qwen4-35B-A3B' : id);
223
+ const ctxLabel = ctxLabelFor(model);
224
+ const displayName = labelFor(picked.id);
225
+
226
+ // Replace Claude Code's built-in Opus/Fable/Sonnet/Haiku picker rows with our real live LABS models only.
227
+ const pickerOptions = models.map(m => ({
228
+ model: m.id,
229
+ label: labelFor(m.id),
230
+ description: `${ctxLabelFor(m)} · vision · web · 200-400 tok/s`,
231
+ }));
232
+ fs.mkdirSync(LABS_DIR, { recursive: true });
233
+ fs.writeFileSync(BOX_SETTINGS_FILE, JSON.stringify({
234
+ model: picked.id,
235
+ availableModels: models.map(m => m.id),
236
+ modelPicker: {
237
+ replaceBuiltInOptions: true,
238
+ options: pickerOptions,
239
+ },
240
+ }, null, 2) + '\n', 'utf8');
241
+ if (!claudeArgs.some(a => a === '--settings' || a.startsWith('--settings='))) {
242
+ claudeArgs.push('--settings', BOX_SETTINGS_FILE);
243
+ }
244
+
204
245
  const env = {
205
246
  ...process.env,
206
247
  ANTHROPIC_BASE_URL: url,
207
248
  ANTHROPIC_AUTH_TOKEN: config.gatewayKey,
208
- // v1 acceptance style: present recognized Claude ids so the /model picker is clean and there are no
209
- // unrecognized_model warnings. The real box model (qwen-normal / qwen-uncensored) rides in X-Labs-Model;
210
- // the gateway routes on that header and forwards the real id to the box, so side calls + subagents stay on Qwen4.
211
- ANTHROPIC_MODEL: 'claude-opus-4-6',
212
- ANTHROPIC_CUSTOM_MODEL_OPTION: 'claude-opus-4-6',
213
- ANTHROPIC_CUSTOM_MODEL_OPTION_NAME: displayName,
214
- ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION: `${displayName} · ${ctxLabel} · vision · web · 200-400 tok/s`,
215
- ANTHROPIC_DEFAULT_OPUS_MODEL: 'claude-opus-4-6',
216
- ANTHROPIC_DEFAULT_SONNET_MODEL: 'claude-sonnet-4-6',
217
- ANTHROPIC_DEFAULT_HAIKU_MODEL: 'claude-haiku-4-5',
249
+ // Real LABS model IDs everywhere so header, /model, subagents, and mid-session switches are 100% honest.
250
+ ANTHROPIC_MODEL: picked.id,
251
+ ANTHROPIC_DEFAULT_OPUS_MODEL: picked.id,
252
+ ANTHROPIC_DEFAULT_SONNET_MODEL: picked.id,
253
+ ANTHROPIC_DEFAULT_HAIKU_MODEL: picked.id,
218
254
  ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES: CAPS,
219
255
  ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES: CAPS,
220
256
  ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES: CAPS,
221
- ANTHROPIC_CUSTOM_HEADERS: `X-Labs-Model: ${picked.id}`,
222
- CLAUDE_CODE_SUBAGENT_MODEL: 'claude-opus-4-6',
257
+ CLAUDE_CODE_SUBAGENT_MODEL: picked.id,
223
258
  CLAUDE_CODE_MAX_CONTEXT_TOKENS: String(model.max_model_len || 131072),
224
259
  // Qwen4 is a 1M-context model; without this Claude Code caps output at 128k and errors on long replies.
225
260
  CLAUDE_CODE_MAX_OUTPUT_TOKENS: '262144'
226
261
  };
227
262
  delete env.ANTHROPIC_API_KEY;
263
+ delete env.ANTHROPIC_CUSTOM_HEADERS;
264
+ delete env.ANTHROPIC_CUSTOM_MODEL_OPTION;
265
+ delete env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME;
266
+ delete env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION;
228
267
  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))}`;
229
268
  // Qwen cannot use Claude Code's WebSearch (an Anthropic server tool); give it a search tool that runs here instead.
230
269
  if (!claudeArgs.some(a => a === '--strict-mcp-config')) claudeArgs.push(...require('./web-mcp').webMcpArgs());
@@ -256,4 +295,4 @@ function openConsole(config) {
256
295
  console.log(`🖥️ Opening the console at ${config.gatewayUrl || DEFAULT_GATEWAY_URL}/console, already logged in.`);
257
296
  }
258
297
 
259
- module.exports = { boxOnlyArgs, GATEWAY_MODELS, gatewayModelFrom, prepareGatewayLaunch, saveGatewayKey, makeAdminToken, openConsole, storedConfig };
298
+ module.exports = { boxOnlyArgs, BOX_SETTINGS_FILE, GATEWAY_MODELS, gatewayModelFrom, prepareGatewayLaunch, saveGatewayKey, makeAdminToken, openConsole, storedConfig };
package/src/modpack.js CHANGED
@@ -124,6 +124,11 @@ Bug: $ARGUMENTS
124
124
  2. Read \`~/.labs/learnings.md\` (create if missing).
125
125
  3. Add at most 2 short, concrete, verified rules (1 line each) that prevent a real failure we just observed.
126
126
  4. Prune any stale, vague, or redundant lines so \`learnings.md\` stays under 30 lines total (zero prompt bloat).
127
+ `,
128
+ 'models.md': `Show only the real LABS models available on this session (never list fake Anthropic models):
129
+ 1. Read \`~/.labs/box-settings.json\` if it exists and display the currently active model and every live LABS model listed under \`modelPicker.options\` (ID, label, description) in a clean compact list.
130
+ 2. Tell the user they can switch live inside chat with \`/model qwen-normal\` or \`/model qwen-uncensored\` (or open the cleaned \`/model\` picker), and adjust thinking depth with \`/effort low | high | xhigh | max\`.
131
+ 3. If the user passed a model name in \`$ARGUMENTS\`, tell them the exact \`/model <id>\` command to run right now.
127
132
  `,
128
133
  };
129
134