feat(daemon): wire tool registry and executor into agent
This commit is contained in:
+14
-2
@@ -6,6 +6,7 @@ import { NativeAgent } from '../backends/index.js';
|
|||||||
import { createTelegramBot } from '../frontends/telegram/index.js';
|
import { createTelegramBot } from '../frontends/telegram/index.js';
|
||||||
import { SessionStore, SessionManager } from '../session/index.js';
|
import { SessionStore, SessionManager } from '../session/index.js';
|
||||||
import { HookEngine } from '../hooks/index.js';
|
import { HookEngine } from '../hooks/index.js';
|
||||||
|
import { ToolRegistry, ToolExecutor, allBuiltinTools } from '../tools/index.js';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import { homedir } from 'os';
|
import { homedir } from 'os';
|
||||||
import { mkdirSync, readFileSync, existsSync } from 'fs';
|
import { mkdirSync, readFileSync, existsSync } from 'fs';
|
||||||
@@ -19,6 +20,8 @@ export interface DaemonContext {
|
|||||||
sessionManager: SessionManager;
|
sessionManager: SessionManager;
|
||||||
hookEngine: HookEngine;
|
hookEngine: HookEngine;
|
||||||
modelRouter: ModelRouter;
|
modelRouter: ModelRouter;
|
||||||
|
toolRegistry: ToolRegistry;
|
||||||
|
toolExecutor: ToolExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSystemPrompt(): string {
|
function loadSystemPrompt(): string {
|
||||||
@@ -120,6 +123,13 @@ export async function startDaemon(config: Config): Promise<DaemonContext> {
|
|||||||
// Initialize hook engine
|
// Initialize hook engine
|
||||||
const hookEngine = new HookEngine(config.hooks);
|
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
|
// Initialize model router
|
||||||
const modelRouter = createModelRouter(config);
|
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 telegramUserId = String(config.telegram.allowed_chat_ids[0]);
|
||||||
const session = sessionManager.getSession('telegram', telegramUserId);
|
const session = sessionManager.getSession('telegram', telegramUserId);
|
||||||
|
|
||||||
// Initialize native agent with session
|
// Initialize native agent with session and tools
|
||||||
const agent = new NativeAgent({
|
const agent = new NativeAgent({
|
||||||
modelClient: modelRouter,
|
modelClient: modelRouter,
|
||||||
systemPrompt: loadSystemPrompt(),
|
systemPrompt: loadSystemPrompt(),
|
||||||
session,
|
session,
|
||||||
|
toolRegistry,
|
||||||
|
toolExecutor,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initialize Telegram bot with hook engine
|
// Initialize Telegram bot with hook engine
|
||||||
@@ -169,7 +181,7 @@ export async function startDaemon(config: Config): Promise<DaemonContext> {
|
|||||||
|
|
||||||
console.log('Flynn daemon started');
|
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';
|
export { Lifecycle } from './lifecycle.js';
|
||||||
|
|||||||
Reference in New Issue
Block a user