export interface KablewyConfig { apiUrl: string; orgId: string; userId: string; apiKey: string; apiKeyId?: string; apiKeyPrefix?: string; apiKeyExpiresAt?: string; docWorkerUrl?: string; docProcessorToken?: string; updateCheckLastAt?: string; concurrency: number; retryAttempts: number; retryDelay: number; parseMode: 'fast' | 'balanced' | 'premium' | 'auto'; interactive: boolean; theme: 'light' | 'dark' | 'auto'; mcpServers: Record; plugins: string[]; } export interface MCPServerConfig { command?: string; args?: string[]; env?: Record; cwd?: string; url?: string; httpUrl?: string; headers?: Record; timeout?: number; trust?: boolean; description?: string; includeTools?: string[]; excludeTools?: string[]; } export interface MCPTool { name: string; description: string; inputSchema: MCPToolSchema; server: string; } export interface MCPToolSchema { type: 'object'; properties: Record; required?: string[]; } export interface MCPToolProperty { type: 'string' | 'number' | 'boolean' | 'array' | 'object'; description?: string; enum?: string[]; items?: MCPToolProperty; properties?: Record; } export interface MCPMessage { role: 'user' | 'assistant' | 'system'; content: string; toolCalls?: MCPToolCall[]; toolResults?: MCPToolResult[]; } export interface MCPToolCall { id: string; name: string; arguments: Record; } export interface MCPToolResult { id: string; content: string; isError?: boolean; } export interface DocumentMetadata { id: string; title: string; description?: string; type: string; size: number; createdAt: string; updatedAt: string; tags: string[]; chunks: number; embeddings: boolean; } export interface SearchResult { id: string; title: string; content: string; score: number; metadata: DocumentMetadata; highlights: string[]; } export interface ChatSession { id: string; title: string; messages: MCPMessage[]; createdAt: string; updatedAt: string; context: string[]; } export interface UploadSession { id: string; files: UploadFile[]; status: 'pending' | 'uploading' | 'completed' | 'failed'; progress: number; createdAt: string; completedAt?: string; manifestPath?: string; stats?: UploadSessionStats; metadata?: Record; rateLimiter?: UploadRateLimiterState; } export interface UploadRateLimiterState { windowStart: number; requestsInWindow: number; bytesInWindow: number; advisoryConcurrency?: number; } export interface UploadSessionStats { total: number; completed: number; failed: number; skipped: number; bytesUploaded: number; } export interface UploadFile { path: string; name: string; size: number; type: string; status: 'pending' | 'uploading' | 'completed' | 'failed' | 'skipped'; error?: string; documentId?: string; attempts?: number; startedAt?: string; completedAt?: string; lastError?: UploadErrorInfo; } export interface UploadErrorInfo { category: UploadErrorCategory; message: string; code?: string | number; retryable: boolean; timestamp: string; details?: Record | string; } export type UploadErrorCategory = 'NETWORK' | 'AUTHENTICATION' | 'AUTHORIZATION' | 'VALIDATION' | 'SERVER' | 'CLIENT' | 'UNKNOWN'; export interface CommandContext { config: unknown; mcpClient: MCPClient; output: OutputHandler; input: InputHandler; telemetry?: { command?: string; }; } export interface OutputHandler { info(message: string): void; success(message: string): void; warning(message: string): void; error(message: string): void; table(data: unknown[]): void; progress(message: string): ProgressBar; spinner(message: string): Spinner; section(title: string): void; list(items: string[], options?: { bullet?: string; color?: string; }): void; json(obj: unknown): void; code(code: string, language?: string): void; banner(text: string): void; box(message: string, options?: BoxOptions): void; clear(): void; } export interface InputHandler { prompt(question: string, options?: PromptOptions): Promise; confirm(message: string, options?: ConfirmOptions): Promise; select(message: string, choices: string[], options?: SelectOptions): Promise; multiSelect(message: string, choices: string[], options?: MultiSelectOptions): Promise; } export interface MCPClient { connect(): Promise; disconnect(): Promise; listTools(): Promise; callTool(name: string, args: Record): Promise; sendMessage(message: MCPMessage): Promise; startChat(messages: MCPMessage[]): AsyncGenerator; } export interface Plugin { name: string; version: string; description: string; commands: Command[]; tools: MCPTool[]; init(context: CommandContext): Promise; destroy(): Promise; } export interface Command { name: string; description: string; options: CommandOption[]; action: (args: unknown, context: CommandContext) => Promise; } export interface CommandOption { flags: string; description: string; required?: boolean; default?: unknown; choices?: string[]; } export interface UploadOptions { parseMode?: 'fast' | 'balanced' | 'premium' | 'auto'; concurrency?: number; retryAttempts?: number; retryDelay?: number; public?: boolean; force?: boolean; recursive?: boolean; skipExisting?: boolean; include?: string; exclude?: string; json?: boolean; verbose?: boolean; sessionDir?: string; sessionId?: string; resumeFrom?: string; logFile?: string; /** commander negated option: `--no-session-store` sets this to false */ sessionStore?: boolean; maxRequestsPerMinute?: number; maxBytesPerMinute?: number; maxConcurrency?: number; useContainer?: boolean; docWorkerUrl?: string; docProcessorToken?: string; } export interface ChatOptions { session?: string; model?: string; temperature?: number; maxTokens?: number; json?: boolean; verbose?: boolean; ui?: boolean; toolsMode?: 'exact' | 'none'; } export interface ConfigOptions { key?: string; value?: string; reset?: boolean; json?: boolean; verbose?: boolean; } export interface StatusOptions { health?: boolean; tools?: boolean; json?: boolean; verbose?: boolean; } export interface InteractiveOptions { session?: string; welcome?: boolean; json?: boolean; verbose?: boolean; } export interface ToolsOptions { list?: boolean; call?: string; args?: string; json?: boolean; verbose?: boolean; } export interface PluginOptions { list?: boolean; install?: string; uninstall?: string; enable?: string; disable?: string; info?: string; commands?: boolean; tools?: boolean; force?: boolean; json?: boolean; verbose?: boolean; } export interface SkillOptions { json?: boolean; verbose?: boolean; name?: string; description?: string; allowedTools?: string; githubUrl?: string; githubBranch?: string; runtime?: string; entry?: string; args?: string; env?: string; version?: string; timeoutMs?: number; force?: boolean; } export interface SkillManifest { id: string; name: string; description: string; visibility?: 'org' | 'private' | 'custom'; latestVersion?: string | null; latestRuntime?: string | null; createdAt?: string; updatedAt?: string; } export interface SkillDetails { manifest: SkillManifest; body: string; } export interface SkillBundleIndex { latestVersion?: string; versions: Record; } export interface MCPToolResponse { success: boolean; data?: unknown; error?: string; metadata?: Record; } export interface SearchDocumentsResponse extends MCPToolResponse { data?: { results: SearchResult[]; total: number; query: string; }; } export interface UploadDocumentResponse extends MCPToolResponse { data?: { documentId: string; title: string; chunks: number; size: number; }; } export interface ListDocumentsResponse extends MCPToolResponse { data?: { documents: DocumentMetadata[]; total: number; }; } export interface CreateChatSessionResponse extends MCPToolResponse { data?: { sessionId: string; title: string; }; } export interface SendChatMessageResponse extends MCPToolResponse { data?: { messageId: string; content: string; toolCalls?: MCPToolCall[]; }; } export interface ProgressBar { update(progress: number): void; stop(): void; } export interface Spinner { start(): void; stop(): void; succeed(message?: string): void; fail(message?: string): void; update(text: string): void; } export interface PromptOptions { type?: 'input' | 'password' | 'number'; default?: string; validate?: (input: string) => boolean | string; filter?: (input: string) => string; } export interface ConfirmOptions { default?: boolean; } export interface SelectOptions { default?: string; pageSize?: number; } export interface MultiSelectOptions { default?: string[]; pageSize?: number; } export interface BoxOptions { title?: string; titleAlignment?: 'left' | 'center' | 'right'; padding?: number; margin?: number; borderStyle?: 'single' | 'double' | 'round' | 'bold' | 'singleDouble' | 'doubleSingle' | 'classic'; borderColor?: string; backgroundColor?: string; dimBorder?: boolean; float?: 'left' | 'center' | 'right'; }