UNPKG

@agentdesk/workflows-mcp

Version:

MCP workflow orchestration tool with presets for thinking, coding and more

142 lines (141 loc) 5.62 kB
import { z } from "zod"; /** * Represents a parameter for a tool * * @interface ParameterConfig */ export interface ParameterConfig { /** Type of the parameter */ type: "string" | "number" | "boolean" | "array" | "object" | "enum"; /** Description of what the parameter does */ description?: string; /** Whether the parameter is required */ required?: boolean; /** Default value for the parameter */ default?: any; /** Possible values for enum type parameters */ enum?: (string | number)[]; /** For array types, defines the type of items in the array */ items?: ParameterConfig; /** For object types, defines the properties of the object */ properties?: Record<string, ParameterConfig>; } /** * Represents a tool that can be used in a prompt * * @interface ToolConfig */ export interface ToolConfig { /** Name of the tool */ name: string; /** Description of what the tool does */ description?: string; /** Parameters that the tool accepts */ parameters?: Record<string, ParameterConfig>; } /** * Configuration for a specific prompt * * @interface PromptConfig */ export interface PromptConfig { /** If provided, completely replaces the default prompt */ prompt?: string; /** Additional context to append to the prompt (either default or custom) */ context?: string; /** Available tools for this prompt */ tools?: ToolConfig[]; /** Whether tools should be executed sequentially or situationally */ toolMode?: "sequential" | "situational"; /** Description for the tool (used as second parameter in server.tool) */ description?: string; /** Whether this tool is disabled */ disabled?: boolean; /** Optional name override for the registered tool (default is the config key) */ name?: string; /** Parameters that the tool accepts */ parameters?: Record<string, ParameterConfig>; } /** * Main configuration interface for all developer tools * All tool configurations are dynamically loaded from YAML files in the presets directory * * @interface DevToolsConfig */ export interface DevToolsConfig { /** * Dynamic mapping of tool names to their configurations * Tool names are determined by the keys in the YAML preset files */ [key: string]: PromptConfig | undefined; } /** * Merges two config objects, with the second one having precedence * * @param {DevToolsConfig} target - The target config to merge into * @param {DevToolsConfig} source - The source config to merge from (has precedence over target) * @returns {DevToolsConfig} The merged configuration object */ export declare function mergeConfigs(target: DevToolsConfig, source: DevToolsConfig): DevToolsConfig; /** * Lists all available preset names by scanning the presets directory * * @returns {string[]} Array of available preset names (without file extensions) */ export declare function listAvailablePresets(): string[]; /** * Loads configuration from preset names * * @param {string[]} presets - Array of preset names to load * @returns {DevToolsConfig} The merged preset configuration */ export declare function loadPresetConfigs(presets: string[]): DevToolsConfig; /** * Loads configuration from all YAML files in the specified directory * or returns default config if directory not found or empty * * @param {string} [directoryPath] - Path to the directory containing configuration YAML files * @returns {Promise<DevToolsConfig>} Promise resolving to the loaded and merged configuration */ export declare function loadConfig(directoryPath?: string): Promise<DevToolsConfig>; /** * Synchronous version of loadConfig for easier testing * * @param {string} [directoryPath] - Path to the directory containing configuration YAML files * @returns {DevToolsConfig} The loaded and merged configuration */ export declare function loadConfigSync(directoryPath?: string): DevToolsConfig; /** * Validates the configuration of a specific tool * Note: This function validates the tool definition itself, not the runtime parameters * (which are validated by the schema validation mechanism) * * @param {DevToolsConfig} config - The complete tool configuration * @param {string} toolName - The name of the tool to validate * @returns {string|null} Error message if invalid, null if valid */ export declare function validateToolConfig(config: DevToolsConfig, toolName: string): string | null; /** * Converts parameter configuration to JSON Schema format * @param {Record<string, ParameterConfig>} parameters - Parameter configurations * @returns {object} JSON Schema object */ export declare function convertParametersToJsonSchema(parameters: Record<string, ParameterConfig>): any; /** * Converts a single parameter configuration to JSON Schema * @param {ParameterConfig} param - Parameter configuration * @returns {object} JSON Schema for the parameter */ export declare function convertParameterToJsonSchema(param: ParameterConfig): any; /** * Converts parameter configuration to Zod schema * @param {Record<string, ParameterConfig>} parameters - Parameter configurations * @returns {object} Zod schema object for use with MCP SDK */ export declare function convertParametersToZodSchema(parameters: Record<string, ParameterConfig>): Record<string, z.ZodTypeAny>; /** * Converts a single parameter configuration to a Zod schema * @param {ParameterConfig} param - Parameter configuration * @returns {z.ZodTypeAny} Zod schema for the parameter */ export declare function convertParameterToZodSchema(param: ParameterConfig): z.ZodTypeAny;