import { Type } from "typebox"; import { CacheManager } from "../shared/cache"; import { serializeResponseWithMeta, type SerializedToolResult } from "../shared/serialize"; export interface CacheAdminDeps { cacheManager: CacheManager; } export function createGetCacheInfoTool(deps: CacheAdminDeps) { return { name: "get_cache_info", label: "Get Cache Info", description: "Get cache statistics: entry count, size, memory usage.", promptSnippet: "Return rtfd cache statistics (entry count, size, memory)", parameters: Type.Object({}), async execute(_toolCallId?: string, _params?: Record): Promise { const stats = deps.cacheManager.getStats(); return serializeResponseWithMeta(stats); }, }; } export function createGetCacheEntriesTool(deps: CacheAdminDeps) { return { name: "get_cache_entries", label: "Get Cache Entries", description: "Get details for all cached entries: age, size, content preview.", promptSnippet: "List all rtfd cache entries with age, size, and content preview", parameters: Type.Object({}), async execute(_toolCallId?: string, _params?: Record): Promise { const entries = deps.cacheManager.getAllEntries(); const result = { total_entries: Object.keys(entries).length, entries, }; return serializeResponseWithMeta(result); }, }; }