diff --git a/src/daemon/index.ts b/src/daemon/index.ts index ca25deb..6056c13 100644 --- a/src/daemon/index.ts +++ b/src/daemon/index.ts @@ -6,6 +6,7 @@ import { NativeAgent } from '../backends/index.js'; import { createTelegramBot } from '../frontends/telegram/index.js'; import { SessionStore, SessionManager } from '../session/index.js'; import { HookEngine } from '../hooks/index.js'; +import { ToolRegistry, ToolExecutor, allBuiltinTools } from '../tools/index.js'; import { resolve } from 'path'; import { homedir } from 'os'; import { mkdirSync, readFileSync, existsSync } from 'fs'; @@ -19,6 +20,8 @@ export interface DaemonContext { sessionManager: SessionManager; hookEngine: HookEngine; modelRouter: ModelRouter; + toolRegistry: ToolRegistry; + toolExecutor: ToolExecutor; } function loadSystemPrompt(): string { @@ -120,6 +123,13 @@ export async function startDaemon(config: Config): Promise { // Initialize hook engine const hookEngine = new HookEngine(config.hooks); + // Initialize tool registry and executor + const toolRegistry = new ToolRegistry(); + for (const tool of allBuiltinTools) { + toolRegistry.register(tool); + } + const toolExecutor = new ToolExecutor(toolRegistry, hookEngine); + // Initialize model router const modelRouter = createModelRouter(config); @@ -127,11 +137,13 @@ export async function startDaemon(config: Config): Promise { const telegramUserId = String(config.telegram.allowed_chat_ids[0]); const session = sessionManager.getSession('telegram', telegramUserId); - // Initialize native agent with session + // Initialize native agent with session and tools const agent = new NativeAgent({ modelClient: modelRouter, systemPrompt: loadSystemPrompt(), session, + toolRegistry, + toolExecutor, }); // Initialize Telegram bot with hook engine @@ -169,7 +181,7 @@ export async function startDaemon(config: Config): Promise { console.log('Flynn daemon started'); - return { config, lifecycle, bot, agent, sessionStore, sessionManager, hookEngine, modelRouter }; + return { config, lifecycle, bot, agent, sessionStore, sessionManager, hookEngine, modelRouter, toolRegistry, toolExecutor }; } export { Lifecycle } from './lifecycle.js';