labs-claude 0.1.7 ā 0.2.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/README.md +67 -5
- package/bin/labs.js +178 -114
- package/package.json +2 -1
- package/src/anthropic-protocol.js +100 -11
- package/src/autostart.js +43 -0
- package/src/bedrock.js +162 -0
- package/src/browser-setup.js +38 -0
- package/src/chat/index.html +534 -0
- package/src/chat-routes.js +149 -0
- package/src/config.js +11 -1
- package/src/elevenlabs-tools.js +37 -7
- package/src/launch-args.js +44 -35
- package/src/local-auth.js +33 -0
- package/src/proxy-manager.js +82 -45
- package/src/proxy.js +801 -585
- package/src/read-shunt.js +26 -0
- package/src/setup.js +51 -5
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Spotify's "Shunt" (2026-09): a whole-file Read of a big file goes to a cheap worker model, and the main model gets
|
|
2
|
+
// a digest with line ranges instead of every line. Reads with offset/limit are exact on purpose and pass untouched,
|
|
3
|
+
// so the main model can still fetch the precise lines it needs before an Edit.
|
|
4
|
+
function oversizedWholeFileReads(toolResults, priorContent, maxLines) {
|
|
5
|
+
if (!Array.isArray(priorContent)) return [];
|
|
6
|
+
const calls = new Map(priorContent.filter(block => block.type === 'tool_use').map(block => [block.id, block]));
|
|
7
|
+
return toolResults.flatMap(result => {
|
|
8
|
+
const call = calls.get(result.toolUseId);
|
|
9
|
+
if (!call || call.name !== 'Read' || result.isError) return [];
|
|
10
|
+
if (call.input?.offset !== undefined || call.input?.limit !== undefined) return [];
|
|
11
|
+
const lineCount = result.content.split('\n').length;
|
|
12
|
+
return lineCount > maxLines ? [{ result, filePath: call.input?.file_path || '(unknown file)', lineCount }] : [];
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const WORKER_PROMPT = 'You read files for a coding agent that will not see them. Given a file (with line numbers) and '
|
|
17
|
+
+ 'the agent\'s current task, write a digest: what the file is for; every function, class, section and export with '
|
|
18
|
+
+ 'its line range; important constants, config keys and identifiers; and, copied verbatim with line numbers, every '
|
|
19
|
+
+ 'part that matters for the task. Be factual and complete; never invent lines.';
|
|
20
|
+
|
|
21
|
+
function shuntNote(filePath, lineCount, model, digest) {
|
|
22
|
+
return `[labs: ${filePath} has ${lineCount} lines. To save context, ${model} read the whole file and wrote this `
|
|
23
|
+
+ 'digest. Read it again with offset and limit for the exact lines before you Edit.]\n\n' + digest;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = { oversizedWholeFileReads, shuntNote, WORKER_PROMPT };
|
package/src/setup.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const axios = require('axios');
|
|
2
2
|
const readline = require('readline');
|
|
3
3
|
const { execFileSync } = require('child_process');
|
|
4
|
-
const
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { API_BASE, CONFIG_PATH, LABS_DIR, loadConfig, saveConfig, saveLlmList } = require('./config');
|
|
6
|
+
const { saveBedrockKey } = require('./bedrock');
|
|
7
|
+
const { EXTENSION_URL, installBrowserServer } = require('./browser-setup');
|
|
5
8
|
|
|
6
9
|
const BRIDGE_AGENT_NAME = 'Labs Claude Code Bridge';
|
|
7
10
|
|
|
@@ -46,7 +49,7 @@ async function createBridgeAgent(headers) {
|
|
|
46
49
|
backup_llm_config: { preference: 'disabled' }
|
|
47
50
|
}
|
|
48
51
|
},
|
|
49
|
-
conversation: { text_only: true, max_duration_seconds: 7200, file_input: { enabled: true } }
|
|
52
|
+
conversation: { text_only: true, max_duration_seconds: 7200, max_duration_seconds_after_last_agent_message: 7200, file_input: { enabled: true } }
|
|
50
53
|
},
|
|
51
54
|
platform_settings: {
|
|
52
55
|
// Post-conversation analysis adds nothing for a coding bridge.
|
|
@@ -87,6 +90,10 @@ async function runSetup() {
|
|
|
87
90
|
} else {
|
|
88
91
|
console.log('š Paste your ElevenLabs API key (elevenlabs.io ā Developers ā API Keys; it needs ElevenAgents access).');
|
|
89
92
|
apiKey = await askHidden(' API key: ');
|
|
93
|
+
if (!apiKey) {
|
|
94
|
+
console.log('ā Nothing was pasted. Your terminal may block pasting into a hidden prompt. Run this instead:\n $env:ELEVENLABS_API_KEY = "sk_..."; labs setup');
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
90
97
|
}
|
|
91
98
|
const headers = { 'xi-api-key': apiKey };
|
|
92
99
|
|
|
@@ -94,7 +101,9 @@ async function runSetup() {
|
|
|
94
101
|
try {
|
|
95
102
|
llms = (await axios.get(`${API_BASE}/llm/list`, { headers })).data.llms;
|
|
96
103
|
} catch (error) {
|
|
97
|
-
|
|
104
|
+
const reason = error.response?.data?.detail?.message || error.response?.data?.detail?.status || error.message;
|
|
105
|
+
console.log(`ā ElevenLabs rejected the key (${error.response?.status || 'no response'}): ${reason}`);
|
|
106
|
+
console.log(` The key you gave is ${apiKey.length} characters long${apiKey.startsWith('sk_') ? '' : ' and does not start with sk_'}. Check it has ElevenAgents permission.`);
|
|
98
107
|
process.exit(1);
|
|
99
108
|
}
|
|
100
109
|
saveLlmList(llms);
|
|
@@ -115,7 +124,44 @@ async function runSetup() {
|
|
|
115
124
|
...(process.env.ELEVENLABS_API_KEY ? {} : { apiKey }),
|
|
116
125
|
bridgeAgent
|
|
117
126
|
});
|
|
118
|
-
console.log(`š¾ Saved ${CONFIG_PATH}\n
|
|
127
|
+
console.log(`š¾ Saved ${CONFIG_PATH}\n`);
|
|
128
|
+
await setupBrowser();
|
|
129
|
+
console.log('\nš Done. Run: labs (Astra)\n labs --model opus\n labs models (list all)');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function setupBrowser() {
|
|
133
|
+
const answer = await ask('š Let labs control your real Chrome (your logins and tabs)? [y/N] ');
|
|
134
|
+
if (!/^y/i.test(answer)) return console.log('āļø Skipped. Run "labs setup" again to add it later.');
|
|
135
|
+
console.log(`1. Install Microsoft's official Playwright Extension:\n ${EXTENSION_URL}`);
|
|
136
|
+
console.log('2. Click the extension icon and copy PLAYWRIGHT_MCP_EXTENSION_TOKEN (optional: without it Chrome asks "Allow?" each time).');
|
|
137
|
+
const token = (await askHidden('š Paste the token, or press Enter to skip: ')).replace(/^PLAYWRIGHT_MCP_EXTENSION_TOKEN=/, '');
|
|
138
|
+
try {
|
|
139
|
+
installBrowserServer(token);
|
|
140
|
+
console.log('ā
Browser tools added to Claude Code (labs-browser). Restart open labs windows to use them.');
|
|
141
|
+
} catch (error) {
|
|
142
|
+
console.log(`ā Could not add the browser tools: ${error.message}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function ask(question) {
|
|
147
|
+
return new Promise(resolve => {
|
|
148
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
149
|
+
rl.question(question, answer => {
|
|
150
|
+
rl.close();
|
|
151
|
+
resolve(answer.trim());
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// The key is typed hidden and goes straight to ~/.labs/bedrock-key (mode 600); it is never printed or logged.
|
|
157
|
+
async function setupBedrock() {
|
|
158
|
+
console.log('\nš§ Amazon Bedrock key for GLM 5.3 (labs --model glm)');
|
|
159
|
+
console.log(' Create one in the AWS console: Amazon Bedrock > API keys > Generate long-term API key.\n');
|
|
160
|
+
const key = await askHidden('Paste the Bedrock API key (hidden): ');
|
|
161
|
+
if (!key) return console.log('Nothing saved.');
|
|
162
|
+
if (!/^ABSK/.test(key)) console.log('ā ļø Bedrock API keys usually start with ABSK; saving it anyway.');
|
|
163
|
+
saveBedrockKey(LABS_DIR, key);
|
|
164
|
+
console.log(`ā
Saved to ${path.join(LABS_DIR, 'bedrock-key')}. Start with: labs --model glm`);
|
|
119
165
|
}
|
|
120
166
|
|
|
121
|
-
module.exports = { runSetup };
|
|
167
|
+
module.exports = { runSetup, setupBedrock };
|