import { routeUserInput } from "../services/router.js"; const intelligentRouterToolDefinition = { name: "intelligent_router", description: "Natural language interface to the knowledge base. Ask questions, teach knowledge, or manage documents. LLM automatically understands intent and routes to the right operation (search, curate, add, or list).", inputSchema: { type: "object", properties: { input: { type: "string", description: "Your natural language question, statement, or command about the knowledge base.", }, }, required: ["input"], additionalProperties: false, }, }; export const routerTools = [intelligentRouterToolDefinition]; export async function handleRouterTool(name, args, config) { if (name === "intelligent_router") { try { if (!args.input || typeof args.input !== "string") { return { content: [ { type: "text", text: "Error: 'input' field is required and must be a string", }, ], isError: true, }; } const result = await routeUserInput(args.input, config); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (err) { return { content: [ { type: "text", text: `Router error: ${err.message}`, }, ], isError: true, }; } } return null; }