UNPKG

@toolprint/hypertool-mcp

Version:

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

242 lines • 7.62 kB
/** * Zod schemas for persona configuration validation * * This module provides comprehensive validation schemas for persona YAML configurations * using Zod. It includes validation for structure, format requirements, and business rules. * * @fileoverview Persona YAML configuration validation schemas */ import { z } from "zod"; /** * Schema for persona name validation * * Names must be hyphen-delimited lowercase following the pattern: * - Start with a lowercase letter (a-z) * - Contain only lowercase letters, numbers, and hyphens * - End with a lowercase letter or number * - No consecutive hyphens allowed */ export declare const PersonaNameSchema: z.ZodEffects<z.ZodString, string, string>; /** * Schema for tool ID validation * * Tool IDs must follow the namespacedName format with MCP server prefix. * Supports compound tool names with multiple segments separated by dots. * Examples: "git.status", "docker.compose.up", "testing.unit.run", "linear.create-issue" */ export declare const ToolIdSchema: z.ZodString; /** * Schema for persona toolset configuration * * Validates individual toolset within a persona configuration */ export declare const PersonaToolsetSchema: z.ZodObject<{ name: z.ZodEffects<z.ZodString, string, string>; toolIds: z.ZodArray<z.ZodString, "many">; }, "strip", z.ZodTypeAny, { name: string; toolIds: string[]; }, { name: string; toolIds: string[]; }>; /** * Schema for persona metadata * * Optional metadata fields for persona information */ export declare const PersonaMetadataSchema: z.ZodObject<{ author: z.ZodOptional<z.ZodString>; tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; created: z.ZodOptional<z.ZodString>; lastModified: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { author?: string | undefined; tags?: string[] | undefined; created?: string | undefined; lastModified?: string | undefined; }, { author?: string | undefined; tags?: string[] | undefined; created?: string | undefined; lastModified?: string | undefined; }>; /** * Main persona configuration schema * * Validates the complete structure of a persona.yaml/yml file */ export declare const PersonaConfigSchema: z.ZodEffects<z.ZodObject<{ name: z.ZodEffects<z.ZodString, string, string>; description: z.ZodString; toolsets: z.ZodOptional<z.ZodArray<z.ZodObject<{ name: z.ZodEffects<z.ZodString, string, string>; toolIds: z.ZodArray<z.ZodString, "many">; }, "strip", z.ZodTypeAny, { name: string; toolIds: string[]; }, { name: string; toolIds: string[]; }>, "many">>; defaultToolset: z.ZodOptional<z.ZodString>; version: z.ZodOptional<z.ZodString>; metadata: z.ZodOptional<z.ZodObject<{ author: z.ZodOptional<z.ZodString>; tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; created: z.ZodOptional<z.ZodString>; lastModified: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { author?: string | undefined; tags?: string[] | undefined; created?: string | undefined; lastModified?: string | undefined; }, { author?: string | undefined; tags?: string[] | undefined; created?: string | undefined; lastModified?: string | undefined; }>>; }, "strict", z.ZodTypeAny, { name: string; description: string; version?: string | undefined; toolsets?: { name: string; toolIds: string[]; }[] | undefined; metadata?: { author?: string | undefined; tags?: string[] | undefined; created?: string | undefined; lastModified?: string | undefined; } | undefined; defaultToolset?: string | undefined; }, { name: string; description: string; version?: string | undefined; toolsets?: { name: string; toolIds: string[]; }[] | undefined; metadata?: { author?: string | undefined; tags?: string[] | undefined; created?: string | undefined; lastModified?: string | undefined; } | undefined; defaultToolset?: string | undefined; }>, { name: string; description: string; version?: string | undefined; toolsets?: { name: string; toolIds: string[]; }[] | undefined; metadata?: { author?: string | undefined; tags?: string[] | undefined; created?: string | undefined; lastModified?: string | undefined; } | undefined; defaultToolset?: string | undefined; }, { name: string; description: string; version?: string | undefined; toolsets?: { name: string; toolIds: string[]; }[] | undefined; metadata?: { author?: string | undefined; tags?: string[] | undefined; created?: string | undefined; lastModified?: string | undefined; } | undefined; defaultToolset?: string | undefined; }>; /** * Type inference for PersonaConfig */ export type PersonaConfigData = z.infer<typeof PersonaConfigSchema>; /** * Type inference for PersonaToolset */ export type PersonaToolsetData = z.infer<typeof PersonaToolsetSchema>; /** * Type inference for PersonaMetadata */ export type PersonaMetadataData = z.infer<typeof PersonaMetadataSchema>; /** * Validation result with enhanced error information */ export interface SchemaValidationResult { /** Whether validation passed */ success: boolean; /** Parsed and validated data if successful */ data?: PersonaConfigData; /** Validation errors with field paths */ errors: SchemaValidationError[]; /** Validation warnings */ warnings: SchemaValidationError[]; } /** * Enhanced validation error with field path information */ export interface SchemaValidationError { /** Field path where the error occurred */ path: string; /** Error message */ message: string; /** Error code from Zod */ code: string; /** Expected value or type */ expected?: string; /** Received value */ received?: any; /** Suggested fix */ suggestion?: string; } /** * Validate persona configuration against schema * * @param data - Raw persona configuration data to validate * @returns Detailed validation result with errors and suggestions */ export declare function validatePersonaConfig(data: unknown): SchemaValidationResult; /** * Validate just the toolset array * * @param toolsets - Array of toolset configurations to validate * @returns Validation result for toolsets */ export declare function validatePersonaToolsets(toolsets: unknown): SchemaValidationResult; /** * Create a validation error summary for display * * @param errors - Array of validation errors * @returns Formatted error summary string */ export declare function createValidationErrorSummary(errors: SchemaValidationError[]): string; /** * Supported persona configuration file names */ export declare const SUPPORTED_PERSONA_FILES: readonly ["persona.yaml", "persona.yml"]; /** * Check if a filename is a supported persona configuration file * * @param filename - Name of the file to check * @returns True if the file is a supported persona configuration file */ export declare function isSupportedPersonaFile(filename: string): boolean; /** * Extract persona name from a file path * * @param filePath - Path to the persona configuration file * @returns Extracted persona name from the parent directory */ export declare function extractPersonaNameFromPath(filePath: string): string; //# sourceMappingURL=schemas.d.ts.map