/** * Core TypeScript type definitions for Obsidian MCP Bundle * Defines types for tool inputs, outputs, errors, and internal data structures */ import { z } from 'zod'; /** * Base tool input type - all tools receive parameters as an object */ export interface ToolInput { [key: string]: unknown; } /** * Successful tool output */ export interface ToolOutput { content: Array<{ type: 'text'; text: string; }>; isError?: false; } /** * Error response conforming to MCP error format */ export interface ErrorResponse { content: Array<{ type: 'text'; text: string; }>; isError: true; } /** * MCP error codes mapping */ export enum MCPErrorCode { InvalidParams = -32602, InternalError = -32603, ParseError = -32700, InvalidRequest = -32600, MethodNotFound = -32601, } /** * Custom error types for Obsidian operations */ export enum ObsidianErrorType { FILE_NOT_FOUND = 'FILE_NOT_FOUND', VAULT_NOT_FOUND = 'VAULT_NOT_FOUND', OBSIDIAN_NOT_RUNNING = 'OBSIDIAN_NOT_RUNNING', AMBIGUOUS_NAME = 'AMBIGUOUS_NAME', CLI_TIMEOUT = 'CLI_TIMEOUT', CLI_ERROR = 'CLI_ERROR', VALIDATION_ERROR = 'VALIDATION_ERROR', } /** * CLI execution result */ export interface CLIResult { stdout: string; stderr: string; exitCode: number; timedOut?: boolean; } /** * CLI command configuration */ export interface CLICommand { command: string; args: string[]; timeout?: number; cwd?: string; } /** * Vault configuration from environment */ export interface VaultConfig { vaultName: string; } /** * Note metadata */ export interface NoteMetadata { path: string; name: string; folder?: string; size?: number; created?: string; modified?: string; tags?: string[]; properties?: Record; } /** * Search result */ export interface SearchResult { file: string; matches?: Array<{ line: number; text: string; }>; } /** * Task item */ export interface TaskItem { id?: string; text: string; completed: boolean; line?: number; file?: string; } /** * Link reference */ export interface LinkReference { source: string; target: string; type: 'wikilink' | 'markdown' | 'embed'; } /** * Property definition */ export interface PropertyDefinition { key: string; value: unknown; type: 'text' | 'number' | 'boolean' | 'date' | 'list' | 'object'; } /** * Tool definition for MCP protocol */ export interface ToolDefinition { name: string; description: string; inputSchema: z.ZodObject; } /** * Logger interface */ export interface Logger { info(message: string, ...args: unknown[]): void; warn(message: string, ...args: unknown[]): void; error(message: string, ...args: unknown[]): void; debug(message: string, ...args: unknown[]): void; } /** * Timeout configuration */ export interface TimeoutConfig { default: number; perCommand: Record; }