labs-claude 0.12.4 → 0.12.6
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 +15 -3
- package/package.json +1 -1
- package/src/dash.js +18 -6
- package/src/gateway-client.js +4 -2
- package/src/modpack.js +1 -0
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');
|
|
@@ -94,21 +94,33 @@ async function openChat(config) {
|
|
|
94
94
|
spawn(opener[0], opener[1], { stdio: 'ignore', detached: true }).unref();
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
function resetTerminalModes() {
|
|
98
|
+
if (process.stdout.isTTY) {
|
|
99
|
+
// Disable SGR/normal mouse tracking & focus reporting so Windows Terminal never spews [555;46;1M after an abrupt exit.
|
|
100
|
+
process.stdout.write('\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l\x1b[?1004l\x1b[?25h');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
97
104
|
function launchClaude(claudeArgs, env, onExit = code => process.exit(code ?? 0)) {
|
|
105
|
+
const finish = code => {
|
|
106
|
+
resetTerminalModes();
|
|
107
|
+
onExit(code);
|
|
108
|
+
};
|
|
98
109
|
// The native installer ships claude.exe; an npm-installed Claude Code on Windows is a .cmd shim that needs a shell.
|
|
99
110
|
const command = process.platform === 'win32' ? 'claude.exe' : 'claude';
|
|
100
111
|
const child = spawn(command, claudeArgs, { stdio: 'inherit', env });
|
|
101
112
|
const handle = { child, kill: () => handle.child.kill() };
|
|
102
113
|
child.on('error', error => {
|
|
103
114
|
if (error.code !== 'ENOENT' || process.platform !== 'win32') {
|
|
115
|
+
resetTerminalModes();
|
|
104
116
|
console.error(`❌ Could not start Claude Code: ${error.message}`);
|
|
105
117
|
process.exit(1);
|
|
106
118
|
}
|
|
107
119
|
const quoted = claudeArgs.map(arg => `"${arg.replace(/"/g, '\\"')}"`).join(' ');
|
|
108
120
|
handle.child = spawn(`claude ${quoted}`, { stdio: 'inherit', env, shell: true });
|
|
109
|
-
handle.child.on('exit', code =>
|
|
121
|
+
handle.child.on('exit', code => finish(code));
|
|
110
122
|
});
|
|
111
|
-
child.on('exit', code =>
|
|
123
|
+
child.on('exit', code => finish(code));
|
|
112
124
|
return handle;
|
|
113
125
|
}
|
|
114
126
|
|
package/package.json
CHANGED
package/src/dash.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Clean, calm, horizontally centered, zero mental load.
|
|
3
3
|
// Press Enter to code, [s] for settings (effort, theme, chrome, brave, statusline, key), [u] update, [a] admin (owner only).
|
|
4
4
|
const axios = require('axios');
|
|
5
|
+
const https = require('https');
|
|
5
6
|
const fs = require('fs');
|
|
6
7
|
const os = require('os');
|
|
7
8
|
const path = require('path');
|
|
@@ -39,13 +40,24 @@ function hasStatusline() {
|
|
|
39
40
|
} catch { return false; }
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
const DASH_HTTPS_AGENT = new https.Agent({ keepAlive: true, maxSockets: 2, family: 4 });
|
|
44
|
+
|
|
45
|
+
async function fetchMe(url, key, retries = 3) {
|
|
46
|
+
for (let i = 0; i < retries; i += 1) {
|
|
47
|
+
try {
|
|
48
|
+
const { data } = await axios.get(`${url}/v1/me`, {
|
|
49
|
+
headers: { 'x-api-key': key },
|
|
50
|
+
timeout: 6000,
|
|
51
|
+
httpsAgent: DASH_HTTPS_AGENT,
|
|
52
|
+
});
|
|
53
|
+
return data;
|
|
54
|
+
} catch (err) {
|
|
55
|
+
const status = err?.response?.status;
|
|
56
|
+
if (status && status < 500) return null;
|
|
57
|
+
if (i < retries - 1) await new Promise(r => setTimeout(r, 400 * (i + 1)));
|
|
58
|
+
}
|
|
48
59
|
}
|
|
60
|
+
return null;
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
function centerLine(text, cols) {
|
package/src/gateway-client.js
CHANGED
|
@@ -250,8 +250,9 @@ async function prepareGatewayLaunch(config, args, picked) {
|
|
|
250
250
|
...process.env,
|
|
251
251
|
ANTHROPIC_BASE_URL: url,
|
|
252
252
|
ANTHROPIC_AUTH_TOKEN: config.gatewayKey,
|
|
253
|
-
//
|
|
254
|
-
ANTHROPIC_MODEL
|
|
253
|
+
// Use ANTHROPIC_DEFAULT_MODEL + --settings (NOT ANTHROPIC_MODEL!) so /model can swap live mid-session
|
|
254
|
+
// between qwen-normal and qwen-uncensored without ANTHROPIC_MODEL locking it back.
|
|
255
|
+
ANTHROPIC_DEFAULT_MODEL: picked.id,
|
|
255
256
|
ANTHROPIC_DEFAULT_OPUS_MODEL: picked.id,
|
|
256
257
|
ANTHROPIC_DEFAULT_SONNET_MODEL: picked.id,
|
|
257
258
|
ANTHROPIC_DEFAULT_HAIKU_MODEL: picked.id,
|
|
@@ -264,6 +265,7 @@ async function prepareGatewayLaunch(config, args, picked) {
|
|
|
264
265
|
CLAUDE_CODE_MAX_OUTPUT_TOKENS: '262144'
|
|
265
266
|
};
|
|
266
267
|
delete env.ANTHROPIC_API_KEY;
|
|
268
|
+
delete env.ANTHROPIC_MODEL;
|
|
267
269
|
delete env.ANTHROPIC_CUSTOM_HEADERS;
|
|
268
270
|
delete env.ANTHROPIC_CUSTOM_MODEL_OPTION;
|
|
269
271
|
delete env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME;
|
package/src/modpack.js
CHANGED
|
@@ -137,6 +137,7 @@ const BRAIN_KERNEL = `<!-- LABS-BRAIN-START -->
|
|
|
137
137
|
- Read only the exact files/lines needed; make the smallest viable diff.
|
|
138
138
|
- Never claim done without running the real test/check and seeing exit code 0.
|
|
139
139
|
- Never delete failing assertions or silence errors with empty catch blocks.
|
|
140
|
+
- Never run blanket \`Stop-Process -Name node\` / \`taskkill /IM node.exe\` / \`pkill node\` (kills host \`labs\` CLI); kill only the specific target PID.
|
|
140
141
|
<!-- LABS-BRAIN-END -->`;
|
|
141
142
|
|
|
142
143
|
function installAutoVerifyHook() {
|