squidclaw 0.4.1 → 0.4.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/bin/squidclaw.js +0 -30
- package/lib/cli/setup.js +4 -48
- package/lib/engine.js +16 -17
- package/package.json +1 -1
package/bin/squidclaw.js
CHANGED
|
@@ -500,36 +500,6 @@ if (process.argv.length <= 2) {
|
|
|
500
500
|
process.exit(0);
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
-
program
|
|
504
|
-
.command('wake')
|
|
505
|
-
.description('🦑 Wake up an agent (first-time hatching conversation)')
|
|
506
|
-
.argument('[agentId]', 'Agent ID')
|
|
507
|
-
.action(async (agentId) => {
|
|
508
|
-
const { hatchTUI } = await import('../lib/cli/hatch-tui.js');
|
|
509
|
-
if (!agentId) {
|
|
510
|
-
const config = (await import('../lib/core/config.js')).loadConfig();
|
|
511
|
-
const home = (await import('../lib/core/config.js')).getHome();
|
|
512
|
-
const { readdirSync, readFileSync } = await import('fs');
|
|
513
|
-
const { join } = await import('path');
|
|
514
|
-
const agentsDir = join(home, 'agents');
|
|
515
|
-
try {
|
|
516
|
-
const dirs = readdirSync(agentsDir);
|
|
517
|
-
for (const d of dirs) {
|
|
518
|
-
try {
|
|
519
|
-
const m = JSON.parse(readFileSync(join(agentsDir, d, 'agent.json'), 'utf8'));
|
|
520
|
-
if (!m.hatched) { agentId = m.id; break; }
|
|
521
|
-
} catch {}
|
|
522
|
-
}
|
|
523
|
-
if (!agentId && dirs.length > 0) {
|
|
524
|
-
const m = JSON.parse(readFileSync(join(agentsDir, dirs[0], 'agent.json'), 'utf8'));
|
|
525
|
-
agentId = m.id;
|
|
526
|
-
}
|
|
527
|
-
} catch {}
|
|
528
|
-
}
|
|
529
|
-
if (!agentId) { console.log('No agents found. Run: squidclaw hatch'); return; }
|
|
530
|
-
await hatchTUI(agentId);
|
|
531
|
-
});
|
|
532
|
-
import { registerUninstallCommand } from '../lib/cli/uninstall-cmd.js';
|
|
533
503
|
program
|
|
534
504
|
.command('wake')
|
|
535
505
|
.description('🦑 Wake up an agent (first-time hatching conversation)')
|
package/lib/cli/setup.js
CHANGED
|
@@ -22,7 +22,7 @@ export async function setup() {
|
|
|
22
22
|
ensureHome();
|
|
23
23
|
|
|
24
24
|
// ═══ Step 1: AI Provider ═══
|
|
25
|
-
p.note('Step 1 of
|
|
25
|
+
p.note('Step 1 of 4: AI Brain', '🧠');
|
|
26
26
|
|
|
27
27
|
const provider = await p.select({
|
|
28
28
|
message: 'Choose your AI provider:',
|
|
@@ -104,7 +104,7 @@ export async function setup() {
|
|
|
104
104
|
config.ai.providers[provider].key = apiKey;
|
|
105
105
|
|
|
106
106
|
// ═══ Step 2: Agent ═══
|
|
107
|
-
p.note('Step 2 of
|
|
107
|
+
p.note('Step 2 of 4: Your Agent', '🤖');
|
|
108
108
|
|
|
109
109
|
const agentName = await p.text({
|
|
110
110
|
message: 'What should your agent be called?',
|
|
@@ -162,7 +162,7 @@ export async function setup() {
|
|
|
162
162
|
const manifest = { id: agentId, name: agentName, language, tone, model, status: 'active', createdAt: new Date().toISOString() };
|
|
163
163
|
|
|
164
164
|
// ═══ Step 3: WhatsApp ═══
|
|
165
|
-
p.note('Step 3 of
|
|
165
|
+
p.note('Step 3 of 4: WhatsApp', '📱');
|
|
166
166
|
|
|
167
167
|
const connectWA = await p.select({
|
|
168
168
|
message: 'Connect WhatsApp?',
|
|
@@ -195,7 +195,7 @@ export async function setup() {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
// ═══ Step 4: Telegram ═══
|
|
198
|
-
p.note('Step 4 of
|
|
198
|
+
p.note('Step 4 of 4: Telegram', '✈️');
|
|
199
199
|
|
|
200
200
|
const connectTG = await p.confirm({ message: 'Connect Telegram bot?', initialValue: false });
|
|
201
201
|
if (p.isCancel(connectTG)) return p.cancel('Setup cancelled');
|
|
@@ -214,51 +214,9 @@ export async function setup() {
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
// ═══ Step 5: Knowledge ═══
|
|
218
|
-
p.note('Step 5 of 5: Knowledge (optional)', '📚');
|
|
219
|
-
|
|
220
|
-
const addKnowledge = await p.confirm({
|
|
221
|
-
message: 'Upload docs now? (menu, FAQ, etc — you can add later too)',
|
|
222
|
-
initialValue: false,
|
|
223
|
-
});
|
|
224
|
-
if (p.isCancel(addKnowledge)) return p.cancel('Setup cancelled');
|
|
225
|
-
|
|
226
|
-
const knowledgeFiles = [];
|
|
227
|
-
if (addKnowledge) {
|
|
228
|
-
let addMore = true;
|
|
229
|
-
while (addMore) {
|
|
230
|
-
const ft = await p.select({
|
|
231
|
-
message: 'What to add?',
|
|
232
|
-
options: [
|
|
233
|
-
{ value: 'file', label: '📄 Local file (PDF, TXT, MD)' },
|
|
234
|
-
{ value: 'url', label: '🌐 Website URL' },
|
|
235
|
-
{ value: 'text', label: '✏️ Type it directly' },
|
|
236
|
-
],
|
|
237
|
-
});
|
|
238
|
-
if (p.isCancel(ft)) break;
|
|
239
|
-
|
|
240
|
-
if (ft === 'file') {
|
|
241
|
-
const fp = await p.text({ message: 'File path:', placeholder: '/path/to/menu.pdf', validate: (v) => !existsSync(v) ? 'File not found' : undefined });
|
|
242
|
-
if (!p.isCancel(fp)) knowledgeFiles.push({ type: 'file', path: fp });
|
|
243
|
-
} else if (ft === 'url') {
|
|
244
|
-
const url = await p.text({ message: 'URL:', placeholder: 'https://mysite.com/menu', validate: (v) => !v.startsWith('http') ? 'Enter a valid URL' : undefined });
|
|
245
|
-
if (!p.isCancel(url)) knowledgeFiles.push({ type: 'url', path: url });
|
|
246
|
-
} else {
|
|
247
|
-
const txt = await p.text({ message: 'Paste your text:', placeholder: 'Business hours: 9am-11pm...' });
|
|
248
|
-
if (!p.isCancel(txt)) knowledgeFiles.push({ type: 'text', content: txt });
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const more = await p.confirm({ message: 'Add more?', initialValue: false });
|
|
252
|
-
addMore = !p.isCancel(more) && more;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
217
|
// ═══ Save everything ═══
|
|
257
218
|
saveConfig(config);
|
|
258
219
|
writeFileSync(join(agentDir, 'agent.json'), JSON.stringify(manifest, null, 2));
|
|
259
|
-
if (knowledgeFiles.length > 0) {
|
|
260
|
-
writeFileSync(join(agentDir, 'knowledge', 'pending.json'), JSON.stringify(knowledgeFiles, null, 2));
|
|
261
|
-
}
|
|
262
220
|
|
|
263
221
|
// ═══ Summary ═══
|
|
264
222
|
const waStatus = connectWA === 'pair' ? 'Pairing code (on start)' : connectWA === 'qr' ? 'QR code (on start)' : 'skipped';
|
|
@@ -279,7 +237,6 @@ export async function setup() {
|
|
|
279
237
|
console.log(' ' + chalk.bold('Language:') + ' ' + (langText[language] || language));
|
|
280
238
|
console.log(' ' + chalk.bold('WhatsApp:') + ' ' + waStatus);
|
|
281
239
|
console.log(' ' + chalk.bold('Telegram:') + ' ' + tgStatus);
|
|
282
|
-
if (knowledgeFiles.length > 0) console.log(' ' + chalk.bold('Knowledge:') + ' ' + knowledgeFiles.length + ' items queued');
|
|
283
240
|
console.log('\n ────────────────────────────────────');
|
|
284
241
|
console.log('\n ' + chalk.bold('Now just run:\n'));
|
|
285
242
|
console.log(' ' + chalk.cyan('squidclaw start'));
|
|
@@ -294,7 +251,6 @@ export async function setup() {
|
|
|
294
251
|
console.log(' ' + chalk.cyan('squidclaw status') + ' — check what\'s running');
|
|
295
252
|
console.log(' ' + chalk.cyan('squidclaw tui') + ' — chat in terminal');
|
|
296
253
|
console.log(' ' + chalk.cyan('squidclaw agent chat ' + agentId) + ' — test your agent');
|
|
297
|
-
console.log(' ' + chalk.cyan('squidclaw knowledge upload') + ' — add documents');
|
|
298
254
|
console.log(' ' + chalk.cyan('squidclaw help') + ' — all commands');
|
|
299
255
|
console.log('\n ════════════════════════════════════\n');
|
|
300
256
|
|
package/lib/engine.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main entry point — starts all subsystems
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
import { ToolRouter } from "./tools/router.js";
|
|
6
|
-
import { TelegramManager } from "./channels/telegram/bot.js";
|
|
7
|
-
import { addToolSupport } from "./core/agent-tools-mixin.js";
|
|
4
|
+
// Knowledge, tools, telegram — loaded dynamically
|
|
8
5
|
|
|
9
6
|
import { loadConfig, getHome, ensureHome } from './core/config.js';
|
|
10
7
|
import { initLogger, logger } from './core/logger.js';
|
|
@@ -60,19 +57,21 @@ export class SquidclawEngine {
|
|
|
60
57
|
const agents = this.agentManager.getAll();
|
|
61
58
|
console.log(` 👥 Agents: ${agents.length} loaded`);
|
|
62
59
|
|
|
63
|
-
// 3b. Knowledge Base
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
60
|
+
// 3b. Knowledge Base + Tools (optional)
|
|
61
|
+
try {
|
|
62
|
+
const { KnowledgeBase } = await import("./memory/knowledge.js");
|
|
63
|
+
const { ToolRouter } = await import("./tools/router.js");
|
|
64
|
+
const { addToolSupport } = await import("./core/agent-tools-mixin.js");
|
|
65
|
+
this.knowledgeBase = new KnowledgeBase(this.storage, this.config);
|
|
66
|
+
this.toolRouter = new ToolRouter(this.config, this.knowledgeBase);
|
|
67
|
+
const toolList = ["web search", "page reader"];
|
|
68
|
+
if (this.config.tools?.google?.oauthToken) toolList.push("calendar", "email");
|
|
69
|
+
console.log(" 🔧 Tools: " + toolList.join(", "));
|
|
70
|
+
for (const agent of agents) {
|
|
71
|
+
addToolSupport(agent, this.toolRouter, this.knowledgeBase);
|
|
72
|
+
}
|
|
73
|
+
} catch (err) {
|
|
74
|
+
console.log(" 🔧 Tools: basic mode");
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
// 4. WhatsApp Manager
|