feat(daemon): wire tool registry and executor into agent

This commit is contained in:
William Valentin
2026-02-05 17:49:32 -08:00
parent 4f87643341
commit b9601b50ab
+14 -2
View File
@@ -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<DaemonContext> {
// 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<DaemonContext> {
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<DaemonContext> {
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';