import { IEmbedder } from "../../embeddings/dist/index.js"; import { IGraphStore, IKnowledgeStore } from "../../store/dist/index.js"; import { Client } from "@modelcontextprotocol/sdk/client/index.js"; //#region packages/aikit-client/src/types.d.ts /** * IAikitClient — Unified data access interface for AI Kit consumers. * * Implemented by: * - DirectAikitClient (in-process, used by TUI) * - McpAikitClient (over MCP transport, used by Dashboard) */ interface AikitStatus { totalRecords: number; totalFiles: number; lastIndexedAt: string | null; onboarded: boolean; } interface AikitSearchResult { sourcePath: string; contentType: string; score: number; content: string; headingPath?: string; startLine?: number; endLine?: number; } interface AikitKnowledgeEntry { path: string; title: string; category: string; tags: string[]; content: string; } interface AikitGraphData { nodes: Array<{ id: string; name: string; type: string; sourcePath?: string; }>; edges: Array<{ fromId: string; toId: string; type: string; }>; } interface IAikitClient { /** Get AI Kit status. */ getStatus(): Promise; /** Search AI Kit. */ search(query: string, options?: { limit?: number; mode?: 'hybrid' | 'semantic' | 'keyword'; }): Promise; /** List curated knowledge entries. */ listKnowledge(): Promise; /** Read a specific curated entry. */ readKnowledge(path: string): Promise; /** Get knowledge graph data. */ getGraph(query?: string): Promise; /** Get file tree of indexed sources. */ getFileTree(): Promise; } //#endregion //#region packages/aikit-client/src/direct-client.d.ts interface CuratedEntry { path: string; title: string; category: string; tags: string[]; content: string; } interface DirectClientDeps { store: IKnowledgeStore; embedder: IEmbedder; graphStore?: IGraphStore; /** Function to list curated entries */ listCurated?: () => Promise; /** Function to read a single curated entry */ readCurated?: (path: string) => Promise; } declare class DirectAikitClient implements IAikitClient { private readonly deps; constructor(deps: DirectClientDeps); getStatus(): Promise; search(query: string, options?: { limit?: number; mode?: 'hybrid' | 'semantic' | 'keyword'; }): Promise; listKnowledge(): Promise; readKnowledge(path: string): Promise; getGraph(query?: string): Promise; getFileTree(): Promise; private getEdgesForNodes; } //#endregion //#region packages/aikit-client/src/mcp-client.d.ts declare class McpAikitClient implements IAikitClient { private readonly client; constructor(client: Client); getStatus(): Promise; search(query: string, options?: { limit?: number; mode?: 'hybrid' | 'semantic' | 'keyword'; }): Promise; listKnowledge(): Promise; readKnowledge(path: string): Promise; getGraph(query?: string): Promise; getFileTree(): Promise; } //#endregion //#region packages/aikit-client/src/parsers.d.ts /** * Content parsers for MCP tool responses. * Used by McpAikitClient to parse structuredContent from tool calls. */ interface ParsedContent { text: string; structured?: T; } /** * Extract text content from an MCP tool result. */ declare function extractText(result: { content?: unknown; } | null | undefined): string; /** * Extract structured content from an MCP tool result. */ declare function extractStructured(result: { structuredContent?: unknown; } | null | undefined): T | undefined; /** * Parse a tool result, returning both text and structured content. */ declare function parseToolResult(result: { content?: unknown; structuredContent?: unknown; } | null | undefined): ParsedContent; /** * Try to parse JSON from a text tool result. * Returns undefined if parsing fails. */ declare function tryParseJson(text: string): T | undefined; //#endregion export { type AikitGraphData, type AikitKnowledgeEntry, type AikitSearchResult, type AikitStatus, DirectAikitClient, type DirectClientDeps, type IAikitClient, McpAikitClient, type ParsedContent, extractStructured, extractText, parseToolResult, tryParseJson };