UNPKG

@toolprint/hypertool-mcp

Version:

HyperTool MCP proxy server for routing requests between clients and multiple underlying MCP servers

114 lines • 4.08 kB
/** * YAML parser implementation for persona configuration files * * This module provides comprehensive YAML parsing functionality for persona.yaml/yml files * with robust error handling, line number preservation, and schema validation integration. * * @fileoverview Persona YAML parsing with comprehensive error handling */ import { type PersonaConfigData } from "./schemas.js"; import { type PersonaConfig, type ValidationResult, type PersonaValidationErrorInfo } from "./types.js"; /** * Result of YAML parsing operation */ export interface ParseResult<T = PersonaConfig> { /** Whether parsing was successful */ success: boolean; /** Parsed and validated data if successful */ data?: T; /** Parsing or validation errors */ errors: PersonaValidationErrorInfo[]; /** Parsing or validation warnings */ warnings: PersonaValidationErrorInfo[]; /** Raw YAML parsing errors with line numbers (if any) */ yamlErrors?: YAMLError[]; } /** * YAML parsing error with line number information */ export interface YAMLError { /** Error message from YAML parser */ message: string; /** Line number where error occurred */ line?: number; /** Column number where error occurred */ column?: number; /** Error name/type from YAML parser */ name?: string; /** Original error for debugging */ originalError: Error; } /** * Options for YAML parsing */ export interface ParseOptions { /** Whether to perform schema validation after parsing */ validateSchema?: boolean; /** Whether to include warnings in the result */ includeWarnings?: boolean; /** Custom validation beyond schema (business rules, etc.) */ customValidation?: (data: PersonaConfigData) => ValidationResult; } /** * Parse persona YAML content from string * * @param content - YAML content as string * @param filename - Optional filename for error reporting * @param options - Parse options * @returns Parse result with data, errors, and warnings */ export declare function parsePersonaYAML(content: string, filename?: string, options?: ParseOptions): ParseResult<PersonaConfig>; /** * Parse persona YAML file from file system * * @param filePath - Path to the YAML file * @param options - Parse options * @returns Parse result with data, errors, and warnings */ export declare function parsePersonaYAMLFile(filePath: string, options?: ParseOptions): Promise<ParseResult<PersonaConfig>>; /** * Check if a file is a persona configuration file * * @param filePath - Path to check * @returns True if the file appears to be a persona config */ export declare function isPersonaConfigFile(filePath: string): boolean; /** * Get supported persona file extensions * * @returns Array of supported file extensions */ export declare function getSupportedPersonaFiles(): readonly string[]; /** * Create a validation result from parsing errors * * @param parseResult - Parse result to convert * @returns ValidationResult compatible with existing patterns */ export declare function parseResultToValidationResult(parseResult: ParseResult): ValidationResult; /** * Parse multiple persona YAML files concurrently * * @param filePaths - Array of file paths to parse * @param options - Parse options * @returns Map of file paths to parse results */ export declare function parseMultiplePersonaFiles(filePaths: string[], options?: ParseOptions): Promise<Map<string, ParseResult<PersonaConfig>>>; /** * Validate raw YAML content without full parsing * * Quick validation to check if content is valid YAML syntax * without performing schema validation or data processing. * * @param content - YAML content to validate * @returns True if YAML syntax is valid */ export declare function isValidYAMLSyntax(content: string): boolean; /** * Extract persona name from parsed YAML content * * @param content - YAML content * @returns Persona name if found, undefined otherwise */ export declare function extractPersonaNameFromYAML(content: string): string | undefined; //# sourceMappingURL=parser.d.ts.map