UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

377 lines (376 loc) 16.4 kB
/** * workflow/config.ts * Configuration schemas, validation, and defaults * * Uses Zod for runtime validation and type safety */ import { z } from "zod"; import { AIProviderName } from "../constants/enums.js"; import type { JsonValue, ConditioningConfig, ExecutionConfig, JudgeConfig, WorkflowModelConfig, ModelGroup, WorkflowConfig, WorkflowValidation } from "../types/index.js"; export declare const MIN_SCORE = 0; export declare const MAX_SCORE = 100; export declare const MAX_REASONING_LENGTH = 200; export declare const PLACEHOLDER_PROVIDER = "none"; export declare const PLACEHOLDER_MODEL = "none"; export declare const WORKFLOW_CREATION_DATE = "2025-11-29T00:00:00.000Z"; /** * Model configuration schema */ export declare const ModelConfigSchema: z.ZodObject<{ provider: z.ZodType<AIProviderName, unknown, z.core.$ZodTypeInternals<AIProviderName, unknown>>; model: z.ZodString; weight: z.ZodOptional<z.ZodNumber>; temperature: z.ZodOptional<z.ZodNumber>; maxTokens: z.ZodOptional<z.ZodNumber>; systemPrompt: z.ZodOptional<z.ZodString>; timeout: z.ZodOptional<z.ZodNumber>; topP: z.ZodOptional<z.ZodNumber>; topK: z.ZodOptional<z.ZodNumber>; presencePenalty: z.ZodOptional<z.ZodNumber>; frequencyPenalty: z.ZodOptional<z.ZodNumber>; label: z.ZodOptional<z.ZodString>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; }, z.core.$strip>; /** * Judge configuration schema * NOTE: Testing phase enforces 0-100 score scale */ export declare const JudgeConfigSchema: z.ZodObject<{ provider: z.ZodType<AIProviderName, unknown, z.core.$ZodTypeInternals<AIProviderName, unknown>>; model: z.ZodString; criteria: z.ZodArray<z.ZodString>; outputFormat: z.ZodEnum<{ scores: "scores"; ranking: "ranking"; best: "best"; detailed: "detailed"; }>; customPrompt: z.ZodOptional<z.ZodString>; systemPrompt: z.ZodOptional<z.ZodString>; temperature: z.ZodOptional<z.ZodNumber>; maxTokens: z.ZodOptional<z.ZodNumber>; timeout: z.ZodOptional<z.ZodNumber>; blindEvaluation: z.ZodOptional<z.ZodBoolean>; includeReasoning: z.ZodBoolean; scoreScale: z.ZodObject<{ min: z.ZodLiteral<0>; max: z.ZodLiteral<100>; }, z.core.$strip>; label: z.ZodOptional<z.ZodString>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; }, z.core.$strip>; /** * Conditioning configuration schema */ export declare const ConditioningConfigSchema: z.ZodObject<{ useConfidence: z.ZodBoolean; confidenceThresholds: z.ZodOptional<z.ZodObject<{ high: z.ZodNumber; medium: z.ZodNumber; low: z.ZodNumber; }, z.core.$strip>>; toneAdjustment: z.ZodOptional<z.ZodEnum<{ neutral: "neutral"; soften: "soften"; strengthen: "strengthen"; }>>; includeMetadata: z.ZodOptional<z.ZodBoolean>; metadataFields: z.ZodOptional<z.ZodArray<z.ZodString>>; addConfidenceStatement: z.ZodOptional<z.ZodBoolean>; addModelAttribution: z.ZodOptional<z.ZodBoolean>; addExecutionTime: z.ZodOptional<z.ZodBoolean>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; }, z.core.$strip>; /** * Model group schema for layer-based execution */ export declare const ModelGroupSchema: z.ZodObject<{ id: z.ZodString; name: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; models: z.ZodArray<z.ZodObject<{ provider: z.ZodType<AIProviderName, unknown, z.core.$ZodTypeInternals<AIProviderName, unknown>>; model: z.ZodString; weight: z.ZodOptional<z.ZodNumber>; temperature: z.ZodOptional<z.ZodNumber>; maxTokens: z.ZodOptional<z.ZodNumber>; systemPrompt: z.ZodOptional<z.ZodString>; timeout: z.ZodOptional<z.ZodNumber>; topP: z.ZodOptional<z.ZodNumber>; topK: z.ZodOptional<z.ZodNumber>; presencePenalty: z.ZodOptional<z.ZodNumber>; frequencyPenalty: z.ZodOptional<z.ZodNumber>; label: z.ZodOptional<z.ZodString>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; }, z.core.$strip>>; executionStrategy: z.ZodEnum<{ parallel: "parallel"; sequential: "sequential"; }>; continueOnFailure: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; minSuccessful: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; parallelism: z.ZodOptional<z.ZodNumber>; timeout: z.ZodOptional<z.ZodNumber>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; }, z.core.$strip>; /** * Execution configuration schema */ export declare const ExecutionConfigSchema: z.ZodObject<{ timeout: z.ZodOptional<z.ZodNumber>; modelTimeout: z.ZodOptional<z.ZodNumber>; judgeTimeout: z.ZodOptional<z.ZodNumber>; retries: z.ZodOptional<z.ZodNumber>; retryDelay: z.ZodOptional<z.ZodNumber>; retryableErrors: z.ZodOptional<z.ZodArray<z.ZodString>>; parallelism: z.ZodOptional<z.ZodNumber>; earlyTermination: z.ZodOptional<z.ZodBoolean>; minResponses: z.ZodOptional<z.ZodNumber>; maxCost: z.ZodOptional<z.ZodNumber>; costThreshold: z.ZodOptional<z.ZodNumber>; enableMetrics: z.ZodOptional<z.ZodBoolean>; enableTracing: z.ZodOptional<z.ZodBoolean>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; }, z.core.$strip>; export declare const WorkflowConfigSchema: z.ZodObject<{ id: z.ZodString; name: z.ZodString; description: z.ZodOptional<z.ZodString>; version: z.ZodOptional<z.ZodString>; type: z.ZodEnum<{ custom: "custom"; chain: "chain"; adaptive: "adaptive"; ensemble: "ensemble"; }>; models: z.ZodArray<z.ZodObject<{ provider: z.ZodType<AIProviderName, unknown, z.core.$ZodTypeInternals<AIProviderName, unknown>>; model: z.ZodString; weight: z.ZodOptional<z.ZodNumber>; temperature: z.ZodOptional<z.ZodNumber>; maxTokens: z.ZodOptional<z.ZodNumber>; systemPrompt: z.ZodOptional<z.ZodString>; timeout: z.ZodOptional<z.ZodNumber>; topP: z.ZodOptional<z.ZodNumber>; topK: z.ZodOptional<z.ZodNumber>; presencePenalty: z.ZodOptional<z.ZodNumber>; frequencyPenalty: z.ZodOptional<z.ZodNumber>; label: z.ZodOptional<z.ZodString>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; }, z.core.$strip>>; modelGroups: z.ZodOptional<z.ZodArray<z.ZodObject<{ id: z.ZodString; name: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; models: z.ZodArray<z.ZodObject<{ provider: z.ZodType<AIProviderName, unknown, z.core.$ZodTypeInternals<AIProviderName, unknown>>; model: z.ZodString; weight: z.ZodOptional<z.ZodNumber>; temperature: z.ZodOptional<z.ZodNumber>; maxTokens: z.ZodOptional<z.ZodNumber>; systemPrompt: z.ZodOptional<z.ZodString>; timeout: z.ZodOptional<z.ZodNumber>; topP: z.ZodOptional<z.ZodNumber>; topK: z.ZodOptional<z.ZodNumber>; presencePenalty: z.ZodOptional<z.ZodNumber>; frequencyPenalty: z.ZodOptional<z.ZodNumber>; label: z.ZodOptional<z.ZodString>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; }, z.core.$strip>>; executionStrategy: z.ZodEnum<{ parallel: "parallel"; sequential: "sequential"; }>; continueOnFailure: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; minSuccessful: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; parallelism: z.ZodOptional<z.ZodNumber>; timeout: z.ZodOptional<z.ZodNumber>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; }, z.core.$strip>>>; defaultSystemPrompt: z.ZodOptional<z.ZodString>; defaultJudgePrompt: z.ZodOptional<z.ZodString>; judge: z.ZodOptional<z.ZodObject<{ provider: z.ZodType<AIProviderName, unknown, z.core.$ZodTypeInternals<AIProviderName, unknown>>; model: z.ZodString; criteria: z.ZodArray<z.ZodString>; outputFormat: z.ZodEnum<{ scores: "scores"; ranking: "ranking"; best: "best"; detailed: "detailed"; }>; customPrompt: z.ZodOptional<z.ZodString>; systemPrompt: z.ZodOptional<z.ZodString>; temperature: z.ZodOptional<z.ZodNumber>; maxTokens: z.ZodOptional<z.ZodNumber>; timeout: z.ZodOptional<z.ZodNumber>; blindEvaluation: z.ZodOptional<z.ZodBoolean>; includeReasoning: z.ZodBoolean; scoreScale: z.ZodObject<{ min: z.ZodLiteral<0>; max: z.ZodLiteral<100>; }, z.core.$strip>; label: z.ZodOptional<z.ZodString>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; }, z.core.$strip>>; judges: z.ZodOptional<z.ZodArray<z.ZodObject<{ provider: z.ZodType<AIProviderName, unknown, z.core.$ZodTypeInternals<AIProviderName, unknown>>; model: z.ZodString; criteria: z.ZodArray<z.ZodString>; outputFormat: z.ZodEnum<{ scores: "scores"; ranking: "ranking"; best: "best"; detailed: "detailed"; }>; customPrompt: z.ZodOptional<z.ZodString>; systemPrompt: z.ZodOptional<z.ZodString>; temperature: z.ZodOptional<z.ZodNumber>; maxTokens: z.ZodOptional<z.ZodNumber>; timeout: z.ZodOptional<z.ZodNumber>; blindEvaluation: z.ZodOptional<z.ZodBoolean>; includeReasoning: z.ZodBoolean; scoreScale: z.ZodObject<{ min: z.ZodLiteral<0>; max: z.ZodLiteral<100>; }, z.core.$strip>; label: z.ZodOptional<z.ZodString>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; }, z.core.$strip>>>; conditioning: z.ZodOptional<z.ZodObject<{ useConfidence: z.ZodBoolean; confidenceThresholds: z.ZodOptional<z.ZodObject<{ high: z.ZodNumber; medium: z.ZodNumber; low: z.ZodNumber; }, z.core.$strip>>; toneAdjustment: z.ZodOptional<z.ZodEnum<{ neutral: "neutral"; soften: "soften"; strengthen: "strengthen"; }>>; includeMetadata: z.ZodOptional<z.ZodBoolean>; metadataFields: z.ZodOptional<z.ZodArray<z.ZodString>>; addConfidenceStatement: z.ZodOptional<z.ZodBoolean>; addModelAttribution: z.ZodOptional<z.ZodBoolean>; addExecutionTime: z.ZodOptional<z.ZodBoolean>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; }, z.core.$strip>>; execution: z.ZodOptional<z.ZodObject<{ timeout: z.ZodOptional<z.ZodNumber>; modelTimeout: z.ZodOptional<z.ZodNumber>; judgeTimeout: z.ZodOptional<z.ZodNumber>; retries: z.ZodOptional<z.ZodNumber>; retryDelay: z.ZodOptional<z.ZodNumber>; retryableErrors: z.ZodOptional<z.ZodArray<z.ZodString>>; parallelism: z.ZodOptional<z.ZodNumber>; earlyTermination: z.ZodOptional<z.ZodBoolean>; minResponses: z.ZodOptional<z.ZodNumber>; maxCost: z.ZodOptional<z.ZodNumber>; costThreshold: z.ZodOptional<z.ZodNumber>; enableMetrics: z.ZodOptional<z.ZodBoolean>; enableTracing: z.ZodOptional<z.ZodBoolean>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; }, z.core.$strip>>; tags: z.ZodOptional<z.ZodArray<z.ZodString>>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>; createdAt: z.ZodOptional<z.ZodString>; updatedAt: z.ZodOptional<z.ZodString>; }, z.core.$strip>; /** * Default conditioning configuration * NOTE: Testing phase - stub only, no actual conditioning applied */ export declare const DEFAULT_CONDITIONING_CONFIG: ConditioningConfig; /** * Default execution configuration */ export declare const DEFAULT_EXECUTION_CONFIG: ExecutionConfig; /** * Default score scale (0-100 for testing phase) */ export declare const DEFAULT_SCORE_SCALE: { readonly min: 0; readonly max: 100; }; /** * Check if workflow uses layer-based execution (modelGroups) * @param config - Workflow configuration * @returns True if modelGroups is defined and has groups */ export declare function usesModelGroups(config: WorkflowConfig): boolean; /** * Get all models from workflow (either from flat array or groups) * @param config - Workflow configuration * @returns Array of all model configs */ export declare function getAllModels(config: WorkflowConfig): WorkflowModelConfig[]; /** * Get model groups (converts flat models to single group if needed) * @param config - Workflow configuration * @returns Array of model groups */ export declare function getModelGroups(config: WorkflowConfig): ModelGroup[]; /** * Default judge configuration values */ export declare const DEFAULT_JUDGE_CONFIG: { temperature: number; outputFormat: "detailed"; blindEvaluation: boolean; includeReasoning: boolean; scoreScale: { readonly min: 0; readonly max: 100; }; }; /** * Merge configuration with defaults * @param config - Workflow configuration to merge * @returns Complete workflow configuration with defaults applied */ export declare function mergeWithDefaults(config: WorkflowConfig): WorkflowConfig; /** * Validate workflow configuration * @param config - Partial workflow configuration to validate * @returns Validation result with parsed data or error details */ export declare function validateWorkflowConfig(config: Partial<WorkflowConfig>): WorkflowValidation<WorkflowConfig>; /** * Create workflow configuration from partial * @param partial - Partial configuration with required fields (id, name, type, models) * @returns Complete workflow configuration with defaults applied */ export declare function createWorkflowConfig(partial: Partial<WorkflowConfig> & Pick<WorkflowConfig, "id" | "name" | "type" | "models">): WorkflowConfig; /** * Validate model configuration * @param config - Partial model configuration to validate * @returns Validation result with parsed data or error details */ export declare function validateModelConfig(config: Partial<WorkflowModelConfig>): WorkflowValidation<WorkflowModelConfig>; /** * Validate judge configuration * @param config - Partial judge configuration to validate * @returns Validation result with parsed data or error details */ export declare function validateJudgeConfig(config: Partial<JudgeConfig>): WorkflowValidation<JudgeConfig>; /** * Check if workflow has judge configuration * @param config - Workflow configuration to check * @returns True if workflow has at least one judge configured */ export declare function hasJudge(config: WorkflowConfig): boolean; /** * Get all judges from workflow configuration * @param config - Workflow configuration * @returns Array of all judge configurations (empty if none) */ export declare function getAllJudges(config: WorkflowConfig): JudgeConfig[]; /** * Calculate estimated workflow cost (placeholder) * TODO: Implement actual provider-specific pricing * @param config - Workflow configuration * @param estimatedTokens - Estimated number of tokens for the request * @returns Estimated cost in USD */ export declare function estimateWorkflowCost(config: WorkflowConfig, estimatedTokens: number): number;