/** * LangChain Integration for Matimo * * Converts Matimo tools to LangChain-compatible format. * Simple, lightweight, scales to 2000+ tools. * * NOTE: Requires @langchain/core as peer dependency. * Install with: npm install @langchain/core langchain * * Usage: * const matimo = await MatimoInstance.init('./tools'); * const langchainTools = await convertToolsToLangChain( * matimo.listTools(), * matimo, * { SLACK_BOT_TOKEN: process.env.SLACK_BOT_TOKEN } * ); */ import { z } from 'zod'; import type { ToolDefinition } from '../core/types.js'; import type { MatimoInstance } from '../matimo-instance.js'; export interface LangChainTool { name: string; description: string; schema: z.ZodSchema; invoke: (input: Record) => Promise; } /** * Convert Matimo tools to LangChain format * * @param tools - Matimo tools * @param matimo - MatimoInstance * @param secrets - Map of parameter names to secret values * @param secretParamNames - Explicitly declared secret parameters (optional) * @returns LangChain tools * * @example * ```ts * const tools = await convertToolsToLangChain( * matimo.listTools().filter(t => t.name.startsWith('slack')), * matimo, * { SLACK_BOT_TOKEN: process.env.SLACK_BOT_TOKEN } * ); * ``` */ export declare function convertToolsToLangChain(tools: ToolDefinition[], matimo: MatimoInstance, secrets?: Record, secretParamNames?: Set): Promise; export interface SkillContext { name: string; description: string; content: string; } /** * Return Level 1 metadata (name + description) for all available skills. * * Token-safe — only a few lines per skill. Include this in the system prompt * so the agent knows what skills exist and can request them by name, mirroring * what `matimo_list_skills` does in the tool-based flow. * * @example * ```ts * const meta = getSkillsMetadata(matimo); * // → [{ name: 'code-review', description: 'Code review checklist' }, ...] * ``` */ export declare function getSkillsMetadata(matimo: MatimoInstance): Array<{ name: string; description: string; }>; /** * Build a per-request system prompt snippet from semantically relevant skills. * * Uses TF-IDF semantic search (built-in, zero dependencies) to rank all skills * against the user's query and loads full content only for the top matches. * This preserves the progressive disclosure model without MCP: * * Level 1 at startup → Level 2 per-request (only relevant skills) * * @param matimo - Initialised MatimoInstance * @param query - The user's current message/query; drives semantic ranking * @param options.topK - Max skills to load (default 3); keeps token cost bounded * @param options.minScore - Minimum cosine similarity to include (default 0.3) * @param options.header - Custom header text (optional) * @returns Formatted string ready to inject as a context block, or empty string * when no skills score above `minScore`. * * @example * ```ts * // In your ReAct loop, per message: * const skillContext = await buildRelevantSkillPrompt(matimo, userMessage, { topK: 2 }); * const messages = [ * new SystemMessage(baseSystemPrompt), * ...(skillContext ? [new SystemMessage(skillContext)] : []), * new HumanMessage(userMessage), * ]; * ``` */ export declare function buildRelevantSkillPrompt(matimo: MatimoInstance, query: string, options?: { topK?: number; minScore?: number; header?: string; }): Promise; //# sourceMappingURL=langchain.d.ts.map