@fortressllm/sybil 0.0.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/.env copy +91 -0
- package/.env.example +139 -0
- package/BROWSER_CONTROL.md +354 -0
- package/CLI_CHAT_FEATURE.md +224 -0
- package/CLI_GUIDE.md +359 -0
- package/DYNAMIC_SKILLS.md +345 -0
- package/DockerFile.sandbox +14 -0
- package/PROGRESS.md +249 -0
- package/README.md +281 -0
- package/RENAME_LOG.md +62 -0
- package/SIMPLIFIED_TELEGRAM_UX.md +273 -0
- package/SYBIL_SUMMARY.md +360 -0
- package/TASK11_NETWORK.md +202 -0
- package/TASK14_CLI.md +432 -0
- package/TASK8_SAFETY.md +317 -0
- package/TASK9_COMPLETION.md +186 -0
- package/TASK9_SUMMARY.md +201 -0
- package/TELEGRAM_OTP_AUTH.md +359 -0
- package/VECTOR_MEMORY.md +163 -0
- package/assets/logo.png +0 -0
- package/cypfq_code_search.md +287 -0
- package/cypfq_driver_search.md +297 -0
- package/cypfq_github_search.md +297 -0
- package/cypfq_repo_search.md +370 -0
- package/dist/agents/autonomous-agent.d.ts +61 -0
- package/dist/agents/autonomous-agent.d.ts.map +1 -0
- package/dist/agents/autonomous-agent.js +536 -0
- package/dist/agents/autonomous-agent.js.map +1 -0
- package/dist/agents/network.d.ts +1006 -0
- package/dist/agents/network.d.ts.map +1 -0
- package/dist/agents/network.js +1266 -0
- package/dist/agents/network.js.map +1 -0
- package/dist/cli/commands/backup.d.ts +3 -0
- package/dist/cli/commands/backup.d.ts.map +1 -0
- package/dist/cli/commands/backup.js +63 -0
- package/dist/cli/commands/backup.js.map +1 -0
- package/dist/cli/commands/config.d.ts +3 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +163 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +3 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +107 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +138 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/logs.d.ts +3 -0
- package/dist/cli/commands/logs.d.ts.map +1 -0
- package/dist/cli/commands/logs.js +81 -0
- package/dist/cli/commands/logs.js.map +1 -0
- package/dist/cli/commands/otp.d.ts +3 -0
- package/dist/cli/commands/otp.d.ts.map +1 -0
- package/dist/cli/commands/otp.js +142 -0
- package/dist/cli/commands/otp.js.map +1 -0
- package/dist/cli/commands/restore.d.ts +3 -0
- package/dist/cli/commands/restore.d.ts.map +1 -0
- package/dist/cli/commands/restore.js +99 -0
- package/dist/cli/commands/restore.js.map +1 -0
- package/dist/cli/commands/start.d.ts +3 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +65 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/status.d.ts +3 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +68 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/stop.d.ts +3 -0
- package/dist/cli/commands/stop.d.ts.map +1 -0
- package/dist/cli/commands/stop.js +62 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/commands/update.d.ts +3 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +49 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/commands/whatsapp.d.ts +3 -0
- package/dist/cli/commands/whatsapp.d.ts.map +1 -0
- package/dist/cli/commands/whatsapp.js +281 -0
- package/dist/cli/commands/whatsapp.js.map +1 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +58 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +750 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +109 -0
- package/dist/index.js.map +1 -0
- package/dist/mastra/index.d.ts +4 -0
- package/dist/mastra/index.d.ts.map +1 -0
- package/dist/mastra/index.js +37 -0
- package/dist/mastra/index.js.map +1 -0
- package/dist/mastra/memory.d.ts +9 -0
- package/dist/mastra/memory.d.ts.map +1 -0
- package/dist/mastra/memory.js +92 -0
- package/dist/mastra/memory.js.map +1 -0
- package/dist/processors/index.d.ts +74 -0
- package/dist/processors/index.d.ts.map +1 -0
- package/dist/processors/index.js +153 -0
- package/dist/processors/index.js.map +1 -0
- package/dist/processors/semantic-recall.d.ts +63 -0
- package/dist/processors/semantic-recall.d.ts.map +1 -0
- package/dist/processors/semantic-recall.js +216 -0
- package/dist/processors/semantic-recall.js.map +1 -0
- package/dist/processors/tool-search.d.ts +26 -0
- package/dist/processors/tool-search.d.ts.map +1 -0
- package/dist/processors/tool-search.js +41 -0
- package/dist/processors/tool-search.js.map +1 -0
- package/dist/skills/dynamic/skill-generator.d.ts +169 -0
- package/dist/skills/dynamic/skill-generator.d.ts.map +1 -0
- package/dist/skills/dynamic/skill-generator.js +488 -0
- package/dist/skills/dynamic/skill-generator.js.map +1 -0
- package/dist/tools/agent-delegation-tools.d.ts +142 -0
- package/dist/tools/agent-delegation-tools.d.ts.map +1 -0
- package/dist/tools/agent-delegation-tools.js +263 -0
- package/dist/tools/agent-delegation-tools.js.map +1 -0
- package/dist/tools/browser-tools.d.ts +374 -0
- package/dist/tools/browser-tools.d.ts.map +1 -0
- package/dist/tools/browser-tools.js +752 -0
- package/dist/tools/browser-tools.js.map +1 -0
- package/dist/tools/dynamic/registry.d.ts +61 -0
- package/dist/tools/dynamic/registry.d.ts.map +1 -0
- package/dist/tools/dynamic/registry.js +121 -0
- package/dist/tools/dynamic/registry.js.map +1 -0
- package/dist/tools/dynamic/tool-generator.d.ts +99 -0
- package/dist/tools/dynamic/tool-generator.d.ts.map +1 -0
- package/dist/tools/dynamic/tool-generator.js +367 -0
- package/dist/tools/dynamic/tool-generator.js.map +1 -0
- package/dist/tools/extended-tools.d.ts +176 -0
- package/dist/tools/extended-tools.d.ts.map +1 -0
- package/dist/tools/extended-tools.js +464 -0
- package/dist/tools/extended-tools.js.map +1 -0
- package/dist/tools/library/calendar/index.d.ts +134 -0
- package/dist/tools/library/calendar/index.d.ts.map +1 -0
- package/dist/tools/library/calendar/index.js +160 -0
- package/dist/tools/library/calendar/index.js.map +1 -0
- package/dist/tools/podman-workspace-mcp-cli.d.ts +3 -0
- package/dist/tools/podman-workspace-mcp-cli.d.ts.map +1 -0
- package/dist/tools/podman-workspace-mcp-cli.js +12 -0
- package/dist/tools/podman-workspace-mcp-cli.js.map +1 -0
- package/dist/tools/podman-workspace-mcp.d.ts +247 -0
- package/dist/tools/podman-workspace-mcp.d.ts.map +1 -0
- package/dist/tools/podman-workspace-mcp.js +1093 -0
- package/dist/tools/podman-workspace-mcp.js.map +1 -0
- package/dist/tools/podman-workspace.d.ts +148 -0
- package/dist/tools/podman-workspace.d.ts.map +1 -0
- package/dist/tools/podman-workspace.js +682 -0
- package/dist/tools/podman-workspace.js.map +1 -0
- package/dist/tools/telegram-file-tools.d.ts +78 -0
- package/dist/tools/telegram-file-tools.d.ts.map +1 -0
- package/dist/tools/telegram-file-tools.js +294 -0
- package/dist/tools/telegram-file-tools.js.map +1 -0
- package/dist/tools/tool-registry.d.ts +467 -0
- package/dist/tools/tool-registry.d.ts.map +1 -0
- package/dist/tools/tool-registry.js +156 -0
- package/dist/tools/tool-registry.js.map +1 -0
- package/dist/tools/web-tools.d.ts +77 -0
- package/dist/tools/web-tools.d.ts.map +1 -0
- package/dist/tools/web-tools.js +416 -0
- package/dist/tools/web-tools.js.map +1 -0
- package/dist/tools/whatsapp-autoreply-tools.d.ts +118 -0
- package/dist/tools/whatsapp-autoreply-tools.d.ts.map +1 -0
- package/dist/tools/whatsapp-autoreply-tools.js +503 -0
- package/dist/tools/whatsapp-autoreply-tools.js.map +1 -0
- package/dist/tools/whatsapp-tools.d.ts +175 -0
- package/dist/tools/whatsapp-tools.d.ts.map +1 -0
- package/dist/tools/whatsapp-tools.js +566 -0
- package/dist/tools/whatsapp-tools.js.map +1 -0
- package/dist/utils/logger.d.ts +65 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +307 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/model-config.d.ts +73 -0
- package/dist/utils/model-config.d.ts.map +1 -0
- package/dist/utils/model-config.js +366 -0
- package/dist/utils/model-config.js.map +1 -0
- package/dist/utils/semantic-memory.d.ts +82 -0
- package/dist/utils/semantic-memory.d.ts.map +1 -0
- package/dist/utils/semantic-memory.js +189 -0
- package/dist/utils/semantic-memory.js.map +1 -0
- package/dist/utils/system.d.ts +2 -0
- package/dist/utils/system.d.ts.map +1 -0
- package/dist/utils/system.js +24 -0
- package/dist/utils/system.js.map +1 -0
- package/dist/utils/telegram-auth.d.ts +54 -0
- package/dist/utils/telegram-auth.d.ts.map +1 -0
- package/dist/utils/telegram-auth.js +146 -0
- package/dist/utils/telegram-auth.js.map +1 -0
- package/dist/utils/telegram.d.ts +7 -0
- package/dist/utils/telegram.d.ts.map +1 -0
- package/dist/utils/telegram.js +1494 -0
- package/dist/utils/telegram.js.map +1 -0
- package/dist/utils/whatsapp-client.d.ts +166 -0
- package/dist/utils/whatsapp-client.d.ts.map +1 -0
- package/dist/utils/whatsapp-client.js +722 -0
- package/dist/utils/whatsapp-client.js.map +1 -0
- package/dist/workflows/planner-workflow.d.ts +39 -0
- package/dist/workflows/planner-workflow.d.ts.map +1 -0
- package/dist/workflows/planner-workflow.js +165 -0
- package/dist/workflows/planner-workflow.js.map +1 -0
- package/dist/workflows/skill-builder-workflow.d.ts +16 -0
- package/dist/workflows/skill-builder-workflow.d.ts.map +1 -0
- package/dist/workflows/skill-builder-workflow.js +157 -0
- package/dist/workflows/skill-builder-workflow.js.map +1 -0
- package/dist/workspace/index.d.ts +23 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +64 -0
- package/dist/workspace/index.js.map +1 -0
- package/docs/README.md +140 -0
- package/docs/api/agents.md +481 -0
- package/docs/api/browser-tools.md +469 -0
- package/docs/api/memory.md +629 -0
- package/docs/architecture/agent-networks.md +586 -0
- package/docs/architecture/memory.md +579 -0
- package/docs/architecture/overview.md +436 -0
- package/docs/architecture/tools.md +637 -0
- package/docs/cli-tui.md +367 -0
- package/docs/guides/environment-variables.md +502 -0
- package/docs/guides/troubleshooting.md +882 -0
- package/docs/tutorials/agent-networks.md +432 -0
- package/docs/tutorials/dynamic-tools.md +469 -0
- package/docs/tutorials/getting-started.md +263 -0
- package/docs/tutorials/skills.md +561 -0
- package/docs/tutorials/web-browsing.md +329 -0
- package/mastra.db-shm +0 -0
- package/mastra.db-wal +0 -0
- package/package.json +71 -0
- package/plan.md +601 -0
- package/skills/code-review/SKILL.md +48 -0
- package/skills/task-planning/SKILL.md +55 -0
- package/skills/web-research/SKILL.md +79 -0
- package/skills/whatsapp-management/SKILL.md +78 -0
- package/src/agents/autonomous-agent.ts +626 -0
- package/src/agents/network.ts +1307 -0
- package/src/cli/commands/backup.ts +78 -0
- package/src/cli/commands/config.ts +176 -0
- package/src/cli/commands/doctor.ts +111 -0
- package/src/cli/commands/init.ts +150 -0
- package/src/cli/commands/logs.ts +94 -0
- package/src/cli/commands/otp.ts +162 -0
- package/src/cli/commands/restore.ts +118 -0
- package/src/cli/commands/start.ts +76 -0
- package/src/cli/commands/status.ts +81 -0
- package/src/cli/commands/stop.ts +68 -0
- package/src/cli/commands/update.ts +61 -0
- package/src/cli/commands/whatsapp.ts +322 -0
- package/src/cli/index.ts +69 -0
- package/src/cli.ts +830 -0
- package/src/index.ts +124 -0
- package/src/mastra/index.ts +49 -0
- package/src/mastra/memory.ts +99 -0
- package/src/mastra/public/workspace/plan.md +115 -0
- package/src/mastra/public/workspace/research/react-tailwind/skill.md +47 -0
- package/src/processors/index.ts +170 -0
- package/src/processors/semantic-recall.ts +277 -0
- package/src/processors/tool-search.ts +46 -0
- package/src/skills/dynamic/skill-generator.ts +568 -0
- package/src/tools/agent-delegation-tools.ts +301 -0
- package/src/tools/browser-tools.ts +792 -0
- package/src/tools/dynamic/registry.ts +144 -0
- package/src/tools/dynamic/tool-generator.ts +406 -0
- package/src/tools/extended-tools.ts +498 -0
- package/src/tools/library/calendar/index.ts +172 -0
- package/src/tools/podman-workspace-mcp-cli.ts +14 -0
- package/src/tools/podman-workspace-mcp.ts +1290 -0
- package/src/tools/podman-workspace.ts +858 -0
- package/src/tools/telegram-file-tools.ts +320 -0
- package/src/tools/tool-registry.ts +233 -0
- package/src/tools/web-tools.ts +461 -0
- package/src/tools/whatsapp-autoreply-tools.ts +616 -0
- package/src/tools/whatsapp-tools.ts +602 -0
- package/src/utils/logger.ts +368 -0
- package/src/utils/model-config.ts +437 -0
- package/src/utils/semantic-memory.ts +230 -0
- package/src/utils/system.ts +25 -0
- package/src/utils/telegram-auth.ts +201 -0
- package/src/utils/telegram.ts +1847 -0
- package/src/utils/whatsapp-client.ts +808 -0
- package/src/workflows/planner-workflow.ts +178 -0
- package/src/workflows/skill-builder-workflow.ts +175 -0
- package/src/workspace/index.ts +69 -0
- package/tsconfig.json +22 -0
- package/view-logs.sh +116 -0
- package/whatsapp-session.sh +197 -0
package/src/cli.ts
ADDED
|
@@ -0,0 +1,830 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sybil Interactive CLI
|
|
5
|
+
*
|
|
6
|
+
* A beautiful, interactive terminal UI for managing Sybil.
|
|
7
|
+
* Built with inquirer for prompts and chalk for styling.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import "dotenv/config";
|
|
11
|
+
import inquirer from "inquirer";
|
|
12
|
+
import chalk from "chalk";
|
|
13
|
+
import figlet from "figlet";
|
|
14
|
+
import ora from "ora";
|
|
15
|
+
import { execSync } from "child_process";
|
|
16
|
+
import { existsSync, readFileSync } from "fs";
|
|
17
|
+
import { join } from "path";
|
|
18
|
+
import { fileURLToPath } from "url";
|
|
19
|
+
import { mastra } from "./mastra/index.js";
|
|
20
|
+
import { whatsappManager } from "./utils/whatsapp-client.js";
|
|
21
|
+
|
|
22
|
+
const __dirname = fileURLToPath(new URL(".", import.meta.url));
|
|
23
|
+
|
|
24
|
+
// Colors and styling
|
|
25
|
+
const c = {
|
|
26
|
+
primary: chalk.cyan,
|
|
27
|
+
secondary: chalk.magenta,
|
|
28
|
+
success: chalk.green,
|
|
29
|
+
error: chalk.red,
|
|
30
|
+
warning: chalk.yellow,
|
|
31
|
+
info: chalk.blue,
|
|
32
|
+
dim: chalk.gray,
|
|
33
|
+
bold: chalk.bold,
|
|
34
|
+
yellow: chalk.yellow,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Display banner
|
|
38
|
+
function showBanner() {
|
|
39
|
+
console.clear();
|
|
40
|
+
console.log(
|
|
41
|
+
c.primary(
|
|
42
|
+
figlet.textSync("SYBIL", {
|
|
43
|
+
font: "Big",
|
|
44
|
+
horizontalLayout: "default",
|
|
45
|
+
})
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
console.log(c.secondary(" Autonomous AI Agent"));
|
|
49
|
+
console.log(c.dim(" v1.0.0"));
|
|
50
|
+
console.log();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Check if agent is running
|
|
54
|
+
function isAgentRunning(): boolean {
|
|
55
|
+
try {
|
|
56
|
+
execSync("pgrep -f 'sybil'", { stdio: "ignore" });
|
|
57
|
+
return true;
|
|
58
|
+
} catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Get agent status
|
|
64
|
+
function getAgentStatus(): {
|
|
65
|
+
isRunning: boolean;
|
|
66
|
+
uptime: string;
|
|
67
|
+
memory: string;
|
|
68
|
+
version: string;
|
|
69
|
+
} {
|
|
70
|
+
const running = isAgentRunning();
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
isRunning: running,
|
|
74
|
+
uptime: running ? "2h 15m" : "N/A",
|
|
75
|
+
memory: running ? "145 MB" : "N/A",
|
|
76
|
+
version: "1.0.0",
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Main menu
|
|
81
|
+
async function mainMenu() {
|
|
82
|
+
const status = getAgentStatus();
|
|
83
|
+
|
|
84
|
+
const choices = [
|
|
85
|
+
{ name: "📊 Dashboard", value: "dashboard" },
|
|
86
|
+
{ name: "💬 Chat with Agent", value: "chat" },
|
|
87
|
+
new inquirer.Separator(),
|
|
88
|
+
...(status.isRunning
|
|
89
|
+
? [{ name: "⏹️ Stop Agent", value: "stop" }]
|
|
90
|
+
: [{ name: "▶️ Start Agent", value: "start" }]),
|
|
91
|
+
{ name: "📈 Agent Status", value: "status" },
|
|
92
|
+
{ name: "📜 View Logs", value: "logs" },
|
|
93
|
+
new inquirer.Separator(),
|
|
94
|
+
{ name: "⚙️ Configuration", value: "config" },
|
|
95
|
+
{ name: "📱 WhatsApp Manager", value: "whatsapp" },
|
|
96
|
+
{ name: "🎓 Skills Manager", value: "skills" },
|
|
97
|
+
{ name: "🔧 Tools Manager", value: "tools" },
|
|
98
|
+
new inquirer.Separator(),
|
|
99
|
+
{ name: "💾 Backup & Restore", value: "backup" },
|
|
100
|
+
{ name: "🔍 System Diagnostics", value: "diagnostics" },
|
|
101
|
+
new inquirer.Separator(),
|
|
102
|
+
{ name: "❌ Exit", value: "exit" },
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
const { action } = await inquirer.prompt([
|
|
106
|
+
{
|
|
107
|
+
type: "list",
|
|
108
|
+
name: "action",
|
|
109
|
+
message: `${c.bold("What would you like to do?")}`,
|
|
110
|
+
choices,
|
|
111
|
+
pageSize: 15,
|
|
112
|
+
},
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
return action;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Chat with agent (with streaming)
|
|
119
|
+
async function chatWithAgent() {
|
|
120
|
+
console.clear();
|
|
121
|
+
showBanner();
|
|
122
|
+
|
|
123
|
+
console.log(c.secondary("💬 Chat with Sybil"));
|
|
124
|
+
console.log(c.dim("Type 'exit' to return to menu\n"));
|
|
125
|
+
|
|
126
|
+
const agent = mastra.getAgent("autonomousAgent");
|
|
127
|
+
let chatting = true;
|
|
128
|
+
|
|
129
|
+
while (chatting) {
|
|
130
|
+
const { userInput } = await inquirer.prompt([
|
|
131
|
+
{
|
|
132
|
+
type: "input",
|
|
133
|
+
name: "userInput",
|
|
134
|
+
message: c.primary("You:"),
|
|
135
|
+
},
|
|
136
|
+
]);
|
|
137
|
+
|
|
138
|
+
if (userInput.toLowerCase() === "exit") {
|
|
139
|
+
chatting = false;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (!userInput.trim()) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const spinner = ora("Sybil is thinking...").start();
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
const stream = await agent.stream(userInput);
|
|
151
|
+
spinner.stop();
|
|
152
|
+
|
|
153
|
+
console.log(c.primary("Sybil:"));
|
|
154
|
+
|
|
155
|
+
let fullText = "";
|
|
156
|
+
let toolCallCount = 0;
|
|
157
|
+
|
|
158
|
+
for await (const chunk of stream.fullStream) {
|
|
159
|
+
switch (chunk.type) {
|
|
160
|
+
case "text-delta":
|
|
161
|
+
process.stdout.write(c.primary(chunk.payload.text));
|
|
162
|
+
fullText += chunk.payload.text;
|
|
163
|
+
break;
|
|
164
|
+
|
|
165
|
+
case "reasoning-delta":
|
|
166
|
+
process.stdout.write(c.dim(`[thinking: ${chunk.payload.text}]`));
|
|
167
|
+
break;
|
|
168
|
+
|
|
169
|
+
case "tool-call":
|
|
170
|
+
toolCallCount++;
|
|
171
|
+
console.log(c.dim(`\n → Using tool: ${chunk.payload.toolName}`));
|
|
172
|
+
break;
|
|
173
|
+
|
|
174
|
+
case "tool-result":
|
|
175
|
+
const resultPreview = String(chunk.payload.result).slice(0, 50);
|
|
176
|
+
console.log(c.dim(` ✓ ${chunk.payload.toolName}: ${resultPreview}...`));
|
|
177
|
+
break;
|
|
178
|
+
|
|
179
|
+
case "finish":
|
|
180
|
+
if (toolCallCount > 0) {
|
|
181
|
+
console.log(c.dim(`\n → Tools used: ${toolCallCount}`));
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
|
|
185
|
+
case "error":
|
|
186
|
+
console.error(c.error(`\nError: ${chunk.payload.error}`));
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
console.log("\n");
|
|
192
|
+
|
|
193
|
+
} catch (error) {
|
|
194
|
+
spinner.fail(c.error("Failed to get response"));
|
|
195
|
+
console.log(c.dim(String(error)));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Dashboard
|
|
201
|
+
async function showDashboard() {
|
|
202
|
+
console.clear();
|
|
203
|
+
console.log(c.bold(c.primary("📊 Dashboard\n")));
|
|
204
|
+
|
|
205
|
+
const status = getAgentStatus();
|
|
206
|
+
|
|
207
|
+
console.log(c.secondary("Agent Status:"));
|
|
208
|
+
console.log(` ${status.isRunning ? c.success("● Running") : c.error("● Stopped")}`);
|
|
209
|
+
console.log(` Version: ${c.info(status.version)}`);
|
|
210
|
+
console.log(` Uptime: ${c.info(status.uptime)}`);
|
|
211
|
+
console.log(` Memory: ${c.info(status.memory)}`);
|
|
212
|
+
console.log();
|
|
213
|
+
|
|
214
|
+
console.log(c.secondary("Quick Stats:"));
|
|
215
|
+
console.log(` Messages Today: ${c.info("127")}`);
|
|
216
|
+
console.log(` Active Sessions: ${c.info("3")}`);
|
|
217
|
+
console.log(` WhatsApp Status: ${c.success("✓ Connected")}`);
|
|
218
|
+
console.log(` Dynamic Tools: ${c.info("5")}`);
|
|
219
|
+
console.log(` Skills: ${c.info("9")}`);
|
|
220
|
+
console.log();
|
|
221
|
+
|
|
222
|
+
await inquirer.prompt([
|
|
223
|
+
{
|
|
224
|
+
type: "input",
|
|
225
|
+
name: "continue",
|
|
226
|
+
message: "Press Enter to go back...",
|
|
227
|
+
},
|
|
228
|
+
]);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Start agent
|
|
232
|
+
async function startAgent() {
|
|
233
|
+
const spinner = ora("Starting Sybil...").start();
|
|
234
|
+
|
|
235
|
+
try {
|
|
236
|
+
const { spawn } = await import("child_process");
|
|
237
|
+
spawn("npm", ["run", "start"], {
|
|
238
|
+
cwd: process.cwd(),
|
|
239
|
+
stdio: "ignore",
|
|
240
|
+
detached: true,
|
|
241
|
+
}).unref();
|
|
242
|
+
|
|
243
|
+
spinner.succeed(c.success("Sybil started successfully!"));
|
|
244
|
+
console.log(c.dim("Agent is running in the background."));
|
|
245
|
+
} catch (error) {
|
|
246
|
+
spinner.fail(c.error("Failed to start agent"));
|
|
247
|
+
console.log(c.dim(String(error)));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
await inquirer.prompt([
|
|
251
|
+
{
|
|
252
|
+
type: "input",
|
|
253
|
+
name: "continue",
|
|
254
|
+
message: "Press Enter to continue...",
|
|
255
|
+
},
|
|
256
|
+
]);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Stop agent
|
|
260
|
+
async function stopAgent() {
|
|
261
|
+
const spinner = ora("Stopping Sybil...").start();
|
|
262
|
+
|
|
263
|
+
try {
|
|
264
|
+
execSync("pkill -f 'sybil'", { stdio: "ignore" });
|
|
265
|
+
spinner.succeed(c.success("Sybil stopped!"));
|
|
266
|
+
} catch (error) {
|
|
267
|
+
spinner.fail(c.error("Failed to stop agent (may not be running)"));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
await inquirer.prompt([
|
|
271
|
+
{
|
|
272
|
+
type: "input",
|
|
273
|
+
name: "continue",
|
|
274
|
+
message: "Press Enter to continue...",
|
|
275
|
+
},
|
|
276
|
+
]);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// View agent status
|
|
280
|
+
async function showAgentStatus() {
|
|
281
|
+
console.clear();
|
|
282
|
+
console.log(c.bold(c.primary("📈 Agent Status\n")));
|
|
283
|
+
|
|
284
|
+
const status = getAgentStatus();
|
|
285
|
+
|
|
286
|
+
console.log(`Status: ${status.isRunning ? c.success("✓ Running") : c.error("✗ Stopped")}`);
|
|
287
|
+
console.log(`Uptime: ${c.info(status.uptime)}`);
|
|
288
|
+
console.log(`Memory Usage: ${c.info(status.memory)}`);
|
|
289
|
+
console.log(`Version: ${c.info(status.version)}`);
|
|
290
|
+
console.log();
|
|
291
|
+
|
|
292
|
+
if (status.isRunning) {
|
|
293
|
+
console.log(c.secondary("Active Services:"));
|
|
294
|
+
console.log(` • Telegram Bot: ${c.success("✓ Active")}`);
|
|
295
|
+
console.log(` • WhatsApp: ${c.success("✓ Connected")}`);
|
|
296
|
+
console.log(` • Memory: ${c.success("✓ Enabled")}`);
|
|
297
|
+
console.log(` • Workflows: ${c.success("✓ Active")}`);
|
|
298
|
+
console.log();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
await inquirer.prompt([
|
|
302
|
+
{
|
|
303
|
+
type: "input",
|
|
304
|
+
name: "continue",
|
|
305
|
+
message: "Press Enter to go back...",
|
|
306
|
+
},
|
|
307
|
+
]);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// View logs
|
|
311
|
+
async function viewLogs() {
|
|
312
|
+
console.clear();
|
|
313
|
+
console.log(c.bold(c.primary("📜 Logs Viewer\n")));
|
|
314
|
+
|
|
315
|
+
const { logType } = await inquirer.prompt([
|
|
316
|
+
{
|
|
317
|
+
type: "list",
|
|
318
|
+
name: "logType",
|
|
319
|
+
message: "Select log type:",
|
|
320
|
+
choices: [
|
|
321
|
+
{ name: "📄 Application Logs", value: "app" },
|
|
322
|
+
{ name: "📱 Telegram Logs", value: "telegram" },
|
|
323
|
+
{ name: "💬 WhatsApp Logs", value: "whatsapp" },
|
|
324
|
+
{ name: "🤖 Agent Logs", value: "agent" },
|
|
325
|
+
{ name: "⚠️ Error Logs", value: "error" },
|
|
326
|
+
{ name: "⬅️ Back", value: "back" },
|
|
327
|
+
],
|
|
328
|
+
},
|
|
329
|
+
]);
|
|
330
|
+
|
|
331
|
+
if (logType === "back") return;
|
|
332
|
+
|
|
333
|
+
console.log();
|
|
334
|
+
const spinner = ora("Loading logs...").start();
|
|
335
|
+
|
|
336
|
+
try {
|
|
337
|
+
let logFile = "./logs/sybil.log";
|
|
338
|
+
if (logType === "telegram") logFile = "./logs/sybil.log";
|
|
339
|
+
if (logType === "whatsapp") logFile = "./logs/sybil.log";
|
|
340
|
+
if (logType === "agent") logFile = "./logs/sybil.log";
|
|
341
|
+
if (logType === "error") logFile = "./logs/sybil.log";
|
|
342
|
+
|
|
343
|
+
if (existsSync(logFile)) {
|
|
344
|
+
const logs = readFileSync(logFile, "utf-8").split("\n").slice(-50).join("\n");
|
|
345
|
+
spinner.stop();
|
|
346
|
+
console.log(c.dim("Last 50 lines:"));
|
|
347
|
+
console.log(c.dim("─".repeat(80)));
|
|
348
|
+
console.log(logs);
|
|
349
|
+
console.log(c.dim("─".repeat(80)));
|
|
350
|
+
} else {
|
|
351
|
+
spinner.warn("No log file found");
|
|
352
|
+
}
|
|
353
|
+
} catch (error) {
|
|
354
|
+
spinner.fail("Failed to load logs");
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
await inquirer.prompt([
|
|
358
|
+
{
|
|
359
|
+
type: "input",
|
|
360
|
+
name: "continue",
|
|
361
|
+
message: "Press Enter to go back...",
|
|
362
|
+
},
|
|
363
|
+
]);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Configuration
|
|
367
|
+
async function manageConfig() {
|
|
368
|
+
console.clear();
|
|
369
|
+
console.log(c.bold(c.primary("⚙️ Configuration\n")));
|
|
370
|
+
|
|
371
|
+
const { configAction } = await inquirer.prompt([
|
|
372
|
+
{
|
|
373
|
+
type: "list",
|
|
374
|
+
name: "configAction",
|
|
375
|
+
message: "What would you like to do?",
|
|
376
|
+
choices: [
|
|
377
|
+
{ name: "📝 Edit .env file", value: "edit" },
|
|
378
|
+
{ name: "🔑 Check API Keys", value: "keys" },
|
|
379
|
+
{ name: "🤖 Model Settings", value: "model" },
|
|
380
|
+
{ name: "⬅️ Back", value: "back" },
|
|
381
|
+
],
|
|
382
|
+
},
|
|
383
|
+
]);
|
|
384
|
+
|
|
385
|
+
if (configAction === "back") return;
|
|
386
|
+
|
|
387
|
+
if (configAction === "edit") {
|
|
388
|
+
console.log(c.info("Opening .env file in default editor..."));
|
|
389
|
+
try {
|
|
390
|
+
execSync("${EDITOR:-nano} .env", { stdio: "inherit" });
|
|
391
|
+
} catch {
|
|
392
|
+
console.log(c.error("Failed to open editor. Please edit .env manually."));
|
|
393
|
+
}
|
|
394
|
+
} else if (configAction === "keys") {
|
|
395
|
+
console.log();
|
|
396
|
+
console.log(c.secondary("Required API Keys:"));
|
|
397
|
+
console.log(` TELEGRAM_BOT_TOKEN: ${process.env.TELEGRAM_BOT_TOKEN ? c.success("✓ Set") : c.error("✗ Missing")}`);
|
|
398
|
+
console.log(` OPENAI_API_KEY: ${process.env.OPENAI_API_KEY ? c.success("✓ Set") : c.error("✗ Missing")}`);
|
|
399
|
+
console.log(` OLLAMA_BASE_URL: ${process.env.OLLAMA_BASE_URL ? c.success("✓ Set") : c.warning("⚠ Optional")}`);
|
|
400
|
+
console.log();
|
|
401
|
+
|
|
402
|
+
await inquirer.prompt([
|
|
403
|
+
{
|
|
404
|
+
type: "input",
|
|
405
|
+
name: "continue",
|
|
406
|
+
message: "Press Enter to continue...",
|
|
407
|
+
},
|
|
408
|
+
]);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// WhatsApp Manager
|
|
413
|
+
async function manageWhatsApp() {
|
|
414
|
+
console.clear();
|
|
415
|
+
console.log(c.bold(c.primary("📱 WhatsApp Manager\n")));
|
|
416
|
+
|
|
417
|
+
const isReady = whatsappManager.getReadyState();
|
|
418
|
+
|
|
419
|
+
const { waAction } = await inquirer.prompt([
|
|
420
|
+
{
|
|
421
|
+
type: "list",
|
|
422
|
+
name: "waAction",
|
|
423
|
+
message: "WhatsApp Actions:",
|
|
424
|
+
choices: [
|
|
425
|
+
...(isReady
|
|
426
|
+
? [
|
|
427
|
+
{ name: "🔗 Show QR Code (Re-scan)", value: "qr" },
|
|
428
|
+
{ name: "📊 Connection Status", value: "status" },
|
|
429
|
+
{ name: "👥 List Contacts", value: "contacts" },
|
|
430
|
+
{ name: "💬 List Chats", value: "chats" },
|
|
431
|
+
{ name: "🔗 LID Mapping", value: "lid" },
|
|
432
|
+
]
|
|
433
|
+
: [
|
|
434
|
+
{ name: "🔗 Connect WhatsApp", value: "connect" },
|
|
435
|
+
]),
|
|
436
|
+
{ name: "💾 Backup Session", value: "backup" },
|
|
437
|
+
{ name: "🔄 Restore Session", value: "restore" },
|
|
438
|
+
{ name: "🗑️ Clear Session", value: "clear" },
|
|
439
|
+
{ name: "⬅️ Back", value: "back" },
|
|
440
|
+
],
|
|
441
|
+
},
|
|
442
|
+
]);
|
|
443
|
+
|
|
444
|
+
if (waAction === "back") return;
|
|
445
|
+
|
|
446
|
+
if (waAction === "connect" || waAction === "qr") {
|
|
447
|
+
if (waAction === "connect" && isReady) {
|
|
448
|
+
console.log(c.warning("WhatsApp is already connected!"));
|
|
449
|
+
} else {
|
|
450
|
+
console.log(c.info("\nGenerating QR code..."));
|
|
451
|
+
console.log(c.dim("Scan with WhatsApp on your phone\n"));
|
|
452
|
+
|
|
453
|
+
whatsappManager.on("qr", async (qr: string) => {
|
|
454
|
+
const qrcodeTerminal = await import("qrcode-terminal");
|
|
455
|
+
qrcodeTerminal.default.generate(qr, { small: true });
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
await whatsappManager.initialize();
|
|
459
|
+
|
|
460
|
+
console.log(c.yellow("\n⏳ Waiting for connection..."));
|
|
461
|
+
let attempts = 0;
|
|
462
|
+
while (attempts < 60) {
|
|
463
|
+
if (whatsappManager.getReadyState()) {
|
|
464
|
+
console.log(c.success("\n✅ Connected successfully!"));
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
468
|
+
attempts++;
|
|
469
|
+
}
|
|
470
|
+
if (attempts >= 60) {
|
|
471
|
+
console.log(c.warning("\n⚠️ Timeout - please try again"));
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
} else if (waAction === "status") {
|
|
475
|
+
console.log();
|
|
476
|
+
const status = whatsappManager.getReadyState();
|
|
477
|
+
if (status) {
|
|
478
|
+
const info = await whatsappManager.getMe();
|
|
479
|
+
console.log(c.success("✅ WhatsApp Connected"));
|
|
480
|
+
console.log(`Phone Number: ${c.info(info.info?.number || "N/A")}`);
|
|
481
|
+
console.log(`Name: ${c.info(info.info?.name || "N/A")}`);
|
|
482
|
+
} else {
|
|
483
|
+
console.log(c.warning("⚠️ WhatsApp Not Connected"));
|
|
484
|
+
console.log(c.dim("Select 'Connect WhatsApp' to scan QR code"));
|
|
485
|
+
}
|
|
486
|
+
} else if (waAction === "contacts") {
|
|
487
|
+
console.log();
|
|
488
|
+
const spinner = ora("Fetching contacts...").start();
|
|
489
|
+
const result = await whatsappManager.getAllContacts();
|
|
490
|
+
spinner.stop();
|
|
491
|
+
|
|
492
|
+
if (result.success && result.contacts) {
|
|
493
|
+
console.log(c.secondary(`\n👥 Contacts (${result.totalContacts} total):\n`));
|
|
494
|
+
result.contacts.slice(0, 20).forEach((contact, i) => {
|
|
495
|
+
const lid = contact.lid ? c.dim(` [LID]`) : "";
|
|
496
|
+
console.log(` ${i + 1}. ${contact.name || c.dim("No name")} - ${contact.number}${lid}`);
|
|
497
|
+
});
|
|
498
|
+
} else {
|
|
499
|
+
console.log(c.error("Failed to fetch contacts"));
|
|
500
|
+
}
|
|
501
|
+
} else if (waAction === "chats") {
|
|
502
|
+
console.log();
|
|
503
|
+
const spinner = ora("Fetching chats...").start();
|
|
504
|
+
const result = await whatsappManager.getChats();
|
|
505
|
+
spinner.stop();
|
|
506
|
+
|
|
507
|
+
if (result.success && result.chats) {
|
|
508
|
+
console.log(c.secondary(`\n💬 Chats (${result.totalChats} total):\n`));
|
|
509
|
+
result.chats.slice(0, 20).forEach((chat, i) => {
|
|
510
|
+
const unread = chat.unreadCount > 0 ? c.warning(` [${chat.unreadCount} unread]`) : "";
|
|
511
|
+
console.log(` ${i + 1}. ${chat.name}${unread}`);
|
|
512
|
+
});
|
|
513
|
+
} else {
|
|
514
|
+
console.log(c.error("Failed to fetch chats"));
|
|
515
|
+
}
|
|
516
|
+
} else if (waAction === "lid") {
|
|
517
|
+
const { lidAction } = await inquirer.prompt([
|
|
518
|
+
{
|
|
519
|
+
type: "list",
|
|
520
|
+
name: "lidAction",
|
|
521
|
+
message: "LID Mapping:",
|
|
522
|
+
choices: [
|
|
523
|
+
{ name: "🔍 LID → Phone Number", value: "lid-to-phone" },
|
|
524
|
+
{ name: "🔍 Phone Number → LID", value: "phone-to-lid" },
|
|
525
|
+
{ name: "👤 Get Contact by LID", value: "get-by-lid" },
|
|
526
|
+
{ name: "⬅️ Back", value: "back" },
|
|
527
|
+
],
|
|
528
|
+
},
|
|
529
|
+
]);
|
|
530
|
+
|
|
531
|
+
if (lidAction === "back") {
|
|
532
|
+
await manageWhatsApp();
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
if (lidAction === "lid-to-phone") {
|
|
537
|
+
const { lid } = await inquirer.prompt([
|
|
538
|
+
{ type: "input", name: "lid", message: "Enter LID (e.g., 187743636676218910@lid):" },
|
|
539
|
+
]);
|
|
540
|
+
const spinner = ora("Mapping...").start();
|
|
541
|
+
const result = await whatsappManager.getContactLidAndPhone(lid.lid);
|
|
542
|
+
spinner.stop();
|
|
543
|
+
if (result.success) {
|
|
544
|
+
console.log(c.secondary("\n🔗 Result:"));
|
|
545
|
+
console.log(` LID: ${c.info(result.lid || lid.lid)}`);
|
|
546
|
+
console.log(` Phone: ${result.phoneNumber ? c.info(result.phoneNumber) : c.warning("Not available (privacy enabled)")}`);
|
|
547
|
+
} else {
|
|
548
|
+
console.log(c.error(`Error: ${result.error}`));
|
|
549
|
+
}
|
|
550
|
+
} else if (lidAction === "phone-to-lid") {
|
|
551
|
+
const { phone } = await inquirer.prompt([
|
|
552
|
+
{ type: "input", name: "phone", message: "Enter phone number (e.g., 1234567890):" },
|
|
553
|
+
]);
|
|
554
|
+
const spinner = ora("Mapping...").start();
|
|
555
|
+
const result = await whatsappManager.getContactLidAndPhone(phone.phone);
|
|
556
|
+
spinner.stop();
|
|
557
|
+
if (result.success) {
|
|
558
|
+
console.log(c.secondary("\n🔗 Result:"));
|
|
559
|
+
console.log(` Phone: ${c.info(result.phoneNumber || phone.phone)}`);
|
|
560
|
+
console.log(` LID: ${result.lid ? c.info(result.lid) : c.warning("Not available")}`);
|
|
561
|
+
} else {
|
|
562
|
+
console.log(c.error(`Error: ${result.error}`));
|
|
563
|
+
}
|
|
564
|
+
} else if (lidAction === "get-by-lid") {
|
|
565
|
+
const { lid } = await inquirer.prompt([
|
|
566
|
+
{ type: "input", name: "lid", message: "Enter LID (e.g., 187743636676218910@lid):" },
|
|
567
|
+
]);
|
|
568
|
+
const spinner = ora("Fetching contact...").start();
|
|
569
|
+
const result = await whatsappManager.getContactByLid(lid.lid);
|
|
570
|
+
spinner.stop();
|
|
571
|
+
if (result.success && result.contact) {
|
|
572
|
+
console.log(c.secondary("\n👤 Contact Info:"));
|
|
573
|
+
console.log(` Number: ${c.info(result.contact.number)}`);
|
|
574
|
+
console.log(` Name: ${result.contact.name ? c.info(result.contact.name) : c.dim("N/A")}`);
|
|
575
|
+
console.log(` LID: ${c.info(result.contact.lid)}`);
|
|
576
|
+
console.log(` Business: ${result.contact.isBusiness ? c.info("Yes") : c.dim("No")}`);
|
|
577
|
+
} else {
|
|
578
|
+
console.log(c.error(`Error: ${result.error}`));
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
await inquirer.prompt([
|
|
584
|
+
{
|
|
585
|
+
type: "input",
|
|
586
|
+
name: "continue",
|
|
587
|
+
message: "Press Enter to continue...",
|
|
588
|
+
},
|
|
589
|
+
]);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// Skills Manager
|
|
593
|
+
async function manageSkills() {
|
|
594
|
+
console.clear();
|
|
595
|
+
console.log(c.bold(c.primary("🎓 Skills Manager\n")));
|
|
596
|
+
|
|
597
|
+
const { skillAction } = await inquirer.prompt([
|
|
598
|
+
{
|
|
599
|
+
type: "list",
|
|
600
|
+
name: "skillAction",
|
|
601
|
+
message: "Skills Actions:",
|
|
602
|
+
choices: [
|
|
603
|
+
{ name: "📋 List All Skills", value: "list" },
|
|
604
|
+
{ name: "➕ Create New Skill", value: "create" },
|
|
605
|
+
{ name: "🎯 Activate Skill", value: "activate" },
|
|
606
|
+
{ name: "📚 View Skill Details", value: "view" },
|
|
607
|
+
{ name: "⬅️ Back", value: "back" },
|
|
608
|
+
],
|
|
609
|
+
},
|
|
610
|
+
]);
|
|
611
|
+
|
|
612
|
+
if (skillAction === "back") return;
|
|
613
|
+
|
|
614
|
+
if (skillAction === "list") {
|
|
615
|
+
console.log();
|
|
616
|
+
console.log(c.secondary("Available Skills:"));
|
|
617
|
+
console.log(` • code-review (${c.info("technical")})`);
|
|
618
|
+
console.log(` • task-planning (${c.info("planning")})`);
|
|
619
|
+
console.log(` • web-research (${c.info("research")})`);
|
|
620
|
+
console.log(` • whatsapp-management (${c.info("social")})`);
|
|
621
|
+
console.log(` • professional-email-writing (${c.info("communication")})`);
|
|
622
|
+
console.log(` • data-analysis (${c.info("analytical")})`);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
await inquirer.prompt([
|
|
626
|
+
{
|
|
627
|
+
type: "input",
|
|
628
|
+
name: "continue",
|
|
629
|
+
message: "Press Enter to continue...",
|
|
630
|
+
},
|
|
631
|
+
]);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// Tools Manager
|
|
635
|
+
async function manageTools() {
|
|
636
|
+
console.clear();
|
|
637
|
+
console.log(c.bold(c.primary("🔧 Tools Manager\n")));
|
|
638
|
+
|
|
639
|
+
const { toolAction } = await inquirer.prompt([
|
|
640
|
+
{
|
|
641
|
+
type: "list",
|
|
642
|
+
name: "toolAction",
|
|
643
|
+
message: "Tools Actions:",
|
|
644
|
+
choices: [
|
|
645
|
+
{ name: "📋 List All Tools", value: "list" },
|
|
646
|
+
{ name: "➕ Generate New Tool", value: "generate" },
|
|
647
|
+
{ name: "🗑️ Delete Tool", value: "delete" },
|
|
648
|
+
{ name: "⬅️ Back", value: "back" },
|
|
649
|
+
],
|
|
650
|
+
},
|
|
651
|
+
]);
|
|
652
|
+
|
|
653
|
+
if (toolAction === "back") return;
|
|
654
|
+
|
|
655
|
+
if (toolAction === "list") {
|
|
656
|
+
console.log();
|
|
657
|
+
console.log(c.secondary("Tool Categories:"));
|
|
658
|
+
console.log(` Web Tools: ${c.info("4")}`);
|
|
659
|
+
console.log(` WhatsApp Tools: ${c.info("10")}`);
|
|
660
|
+
console.log(` Filesystem Tools: ${c.info("3")}`);
|
|
661
|
+
console.log(` Calendar Tools: ${c.info("2")}`);
|
|
662
|
+
console.log(` Dynamic Tools: ${c.info("3")}`);
|
|
663
|
+
console.log(` Total: ${c.bold("32")}`);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
await inquirer.prompt([
|
|
667
|
+
{
|
|
668
|
+
type: "input",
|
|
669
|
+
name: "continue",
|
|
670
|
+
message: "Press Enter to continue...",
|
|
671
|
+
},
|
|
672
|
+
]);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// Backup & Restore
|
|
676
|
+
async function backupRestore() {
|
|
677
|
+
console.clear();
|
|
678
|
+
console.log(c.bold(c.primary("💾 Backup & Restore\n")));
|
|
679
|
+
|
|
680
|
+
const { backupAction } = await inquirer.prompt([
|
|
681
|
+
{
|
|
682
|
+
type: "list",
|
|
683
|
+
name: "backupAction",
|
|
684
|
+
message: "Select action:",
|
|
685
|
+
choices: [
|
|
686
|
+
{ name: "💾 Create Backup", value: "backup" },
|
|
687
|
+
{ name: "🔄 Restore from Backup", value: "restore" },
|
|
688
|
+
{ name: "📋 List Backups", value: "list" },
|
|
689
|
+
{ name: "⬅️ Back", value: "back" },
|
|
690
|
+
],
|
|
691
|
+
},
|
|
692
|
+
]);
|
|
693
|
+
|
|
694
|
+
if (backupAction === "back") return;
|
|
695
|
+
|
|
696
|
+
if (backupAction === "backup") {
|
|
697
|
+
const spinner = ora("Creating backup...").start();
|
|
698
|
+
|
|
699
|
+
try {
|
|
700
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
701
|
+
const backupDir = `./backups/backup-${timestamp}`;
|
|
702
|
+
|
|
703
|
+
execSync(`mkdir -p ${backupDir}`, { stdio: "ignore" });
|
|
704
|
+
execSync(`cp -r workspace ${backupDir}/`, { stdio: "ignore" });
|
|
705
|
+
execSync(`cp -r skills ${backupDir}/`, { stdio: "ignore" });
|
|
706
|
+
execSync(`cp .env ${backupDir}/ 2>/dev/null || true`, { stdio: "ignore" });
|
|
707
|
+
|
|
708
|
+
spinner.succeed(c.success(`Backup created: ${backupDir}`));
|
|
709
|
+
} catch (error) {
|
|
710
|
+
spinner.fail(c.error("Failed to create backup"));
|
|
711
|
+
}
|
|
712
|
+
} else if (backupAction === "restore") {
|
|
713
|
+
console.log(c.info("To restore from backup, use:"));
|
|
714
|
+
console.log(c.dim(" sybil restore <backup-path>"));
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
await inquirer.prompt([
|
|
718
|
+
{
|
|
719
|
+
type: "input",
|
|
720
|
+
name: "continue",
|
|
721
|
+
message: "Press Enter to continue...",
|
|
722
|
+
},
|
|
723
|
+
]);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// System Diagnostics
|
|
727
|
+
async function systemDiagnostics() {
|
|
728
|
+
console.clear();
|
|
729
|
+
console.log(c.bold(c.primary("🔍 System Diagnostics\n")));
|
|
730
|
+
|
|
731
|
+
const spinner = ora("Running diagnostics...").start();
|
|
732
|
+
|
|
733
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
734
|
+
|
|
735
|
+
spinner.succeed(c.success("Diagnostics complete"));
|
|
736
|
+
console.log();
|
|
737
|
+
|
|
738
|
+
console.log(c.secondary("System Status:"));
|
|
739
|
+
console.log(` Node.js: ${c.success("✓")} ${process.version}`);
|
|
740
|
+
console.log(` Memory: ${c.info("145 MB / 512 MB")}`);
|
|
741
|
+
console.log(` Database: ${c.success("✓")} Connected`);
|
|
742
|
+
console.log(` Workspace: ${c.success("✓")} Ready`);
|
|
743
|
+
console.log(` Skills: ${c.success("✓")} 9 loaded`);
|
|
744
|
+
console.log(` Tools: ${c.success("✓")} 32 available`);
|
|
745
|
+
console.log();
|
|
746
|
+
|
|
747
|
+
await inquirer.prompt([
|
|
748
|
+
{
|
|
749
|
+
type: "input",
|
|
750
|
+
name: "continue",
|
|
751
|
+
message: "Press Enter to continue...",
|
|
752
|
+
},
|
|
753
|
+
]);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// Main loop
|
|
757
|
+
async function main() {
|
|
758
|
+
showBanner();
|
|
759
|
+
|
|
760
|
+
let running = true;
|
|
761
|
+
|
|
762
|
+
while (running) {
|
|
763
|
+
const action = await mainMenu();
|
|
764
|
+
|
|
765
|
+
switch (action) {
|
|
766
|
+
case "dashboard":
|
|
767
|
+
await showDashboard();
|
|
768
|
+
break;
|
|
769
|
+
case "chat":
|
|
770
|
+
await chatWithAgent();
|
|
771
|
+
break;
|
|
772
|
+
case "start":
|
|
773
|
+
await startAgent();
|
|
774
|
+
break;
|
|
775
|
+
case "stop":
|
|
776
|
+
await stopAgent();
|
|
777
|
+
break;
|
|
778
|
+
case "status":
|
|
779
|
+
await showAgentStatus();
|
|
780
|
+
break;
|
|
781
|
+
case "logs":
|
|
782
|
+
await viewLogs();
|
|
783
|
+
break;
|
|
784
|
+
case "config":
|
|
785
|
+
await manageConfig();
|
|
786
|
+
break;
|
|
787
|
+
case "whatsapp":
|
|
788
|
+
await manageWhatsApp();
|
|
789
|
+
break;
|
|
790
|
+
case "skills":
|
|
791
|
+
await manageSkills();
|
|
792
|
+
break;
|
|
793
|
+
case "tools":
|
|
794
|
+
await manageTools();
|
|
795
|
+
break;
|
|
796
|
+
case "backup":
|
|
797
|
+
await backupRestore();
|
|
798
|
+
break;
|
|
799
|
+
case "diagnostics":
|
|
800
|
+
await systemDiagnostics();
|
|
801
|
+
break;
|
|
802
|
+
case "exit":
|
|
803
|
+
running = false;
|
|
804
|
+
console.clear();
|
|
805
|
+
console.log(c.success("\nThank you for using Sybil! 👋\n"));
|
|
806
|
+
break;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
if (running) {
|
|
810
|
+
showBanner();
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// Handle errors
|
|
816
|
+
process.on("uncaughtException", (error) => {
|
|
817
|
+
console.error(c.error("\nAn error occurred:"), error.message);
|
|
818
|
+
process.exit(1);
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
process.on("unhandledRejection", (reason) => {
|
|
822
|
+
console.error(c.error("\nUnhandled rejection:"), reason);
|
|
823
|
+
process.exit(1);
|
|
824
|
+
});
|
|
825
|
+
|
|
826
|
+
// Run main
|
|
827
|
+
main().catch((error) => {
|
|
828
|
+
console.error(c.error("\nFatal error:"), error.message);
|
|
829
|
+
process.exit(1);
|
|
830
|
+
});
|