AI Tools Integration
External modules can provide AI tools for the Architect Agent.
Define AI Tools
Location: lib/server/ai/ai-tools.ts
Export getAiTools(userId) and return ToolDefinition[].
import { TaskRepository } from '$lib/repositories/external_modules/MoLOS-Tasks/task-repository';
import type { ToolDefinition } from '$lib/models/external_modules/MoLOS-Tasks';
import { db } from '$lib/server/db';
export function getAiTools(userId: string): ToolDefinition[] {
const repo = new TaskRepository(db as any);
return [
{
name: 'get_tasks',
description: 'Retrieve tasks for the current user.',
parameters: {
type: 'object',
properties: { limit: { type: 'number', default: 10 } }
},
execute: async (params) => repo.getByUserId(userId, params.limit)
}
];
}
How MoLOS Loads Tools
- Tools are discovered from
lib/server/ai/ai-tools.tsin external modules. - Tool names are automatically prefixed with
<ModuleId>_.
Key Rules
- Naming: Use
snake_casefor tool names (e.g.,create_task). - Descriptions: Keep them short and unambiguous.
- User Isolation: Always scope calls to
userId. - Safety: Return enough data for the agent to explain outcomes.