UNPKG

mcp-think-tank

Version:

Structured thinking and knowledge management tool for Model Context Protocol

119 lines 3.49 kB
import { LRUCache } from 'lru-cache'; /** * ToolManager tracks and limits tool calls across agents */ export declare class ToolManager { private globalCount; private perAgentCount; private callCache; get contentCache(): LRUCache<string, any>; private _contentCache; private allowedTools; constructor(); /** * Set the whitelist of allowed tools * @param tools Array of tool names that are allowed */ setAllowedTools(tools: string[]): void; /** * Call a tool with tracking and limits * @param agentId ID of the agent making the call * @param toolName Name of the tool to call * @param params Parameters for the tool * @returns Result from the tool * @throws ToolLimitError if call limit is exceeded * @throws ToolNotPermittedError if tool is not in the whitelist */ callTool(agentId: string, toolName: string, params: any): Promise<any>; /** * Execute the actual tool call - this is a placeholder that will be implemented * by adapters for each specific tool */ private executeToolCall; /** * Log a tool call */ private logToolCall; /** * Get a summarized version of params for logging */ private getParamsSummary; /** * Get the current call counts */ getStats(): { global: number; perAgent: Map<string, number>; }; /** * Get statistics about the content cache */ getContentCacheStats(): { enabled: boolean; size: number; maxSize: number; ttl: number; }; /** * Check if content is in the cache * @param key Cache key to check * @returns Whether the key exists in the cache */ hasContentCacheItem(key: string): boolean; /** * Get content from the cache * @param key Cache key to retrieve * @returns The cached content or undefined if not found */ getContentCacheItem(key: string): any; /** * Set content in the cache * @param key Cache key * @param value Value to cache * @returns The cache instance */ setContentCacheItem(key: string, value: any): LRUCache<string, any>; /** * Reset all counters */ reset(): void; /** * Generate a SHA-1 hash of content * @param content The content to hash * @returns The SHA-1 hash as a hex string */ private generateContentHash; /** * Read a file with caching based on content hash * @param filePath Path to the file to read * @param options Options for fs.readFile * @returns The file contents */ readFileWithCache(filePath: string, options?: any): Promise<string | Buffer>; /** * Fetch URL content with caching based on content hash * @param url The URL to fetch * @returns The URL content */ fetchUrlWithCache(url: string): Promise<string>; /** * Helper method to fetch URL content * @param url The URL to fetch * @returns Promise resolving to the URL content */ private fetchUrl; } /** * Error thrown when tool call limit is exceeded */ export declare class ToolLimitError extends Error { constructor(message: string); } /** * Error thrown when a tool is not in the allowed list */ export declare class ToolNotPermittedError extends Error { constructor(message: string); } export declare const toolManager: ToolManager; //# sourceMappingURL=ToolManager.d.ts.map