import type { AgentConfig, FlowAgentConfig, FlowConfig, LLMAgentConfig, TriageAgentConfig } from '@ariaflowagents/core'; export type PermissionValue = 'allow' | 'deny' | 'ask'; export interface PermissionConfig { skill?: PermissionValue | Record; } export interface RuntimeConfigInput { defaultAgent?: string; defaultModel?: string; maxTurns?: number; maxSteps?: number; maxHandoffs?: number; contextMaxTokens?: number; contextMaxMessages?: number; contextStrategy?: 'sliding-window' | 'prune' | 'summarize'; summarizeAfterTurns?: number; alwaysRouteThroughTriage?: boolean; triageAgent?: string; callback?: { url: string; method?: 'POST' | 'PUT'; headers?: Record; allowList?: string[]; denyList?: string[]; includeFullText?: boolean; }; } export interface TemplateRefInput { template: string; customize?: { personality?: string; goal?: string; guardrails?: string; tone?: string; tools?: string; errorHandling?: string; characterNormalization?: string; voiceRules?: string; glossary?: string; systemReminder?: string; }; addSections?: Array<{ type: string; content: string; priority?: number; }>; glossary?: Array<{ name: string; description: string; synonyms?: string[]; category?: string; }>; voiceRules?: { useSpellTags?: boolean; useBreakTags?: boolean; useSpeedTags?: boolean; useEmotionTags?: boolean; useLaughterTags?: boolean; customPronunciations?: Record; formatDates?: 'MM/DD/YYYY' | 'DD/MM/YYYY' | 'YYYY-MM-DD' | 'speakable'; formatTimes?: '12h' | '24h'; urlFormat?: 'dot' | 'spell'; numberFormat?: 'words' | 'digits' | 'mixed'; verbalizeCurrency?: boolean; verbalizeSymbols?: boolean; }; injectTodayDate?: boolean; } export interface TemplateInlineInput { id: string; name: string; description?: string; sections: Array<{ type: string; content: string; priority?: number; }>; requiredSections?: string[]; } export type PromptRef = string | { file: string; } | TemplateRefInput | TemplateInlineInput; export interface BaseAgentInput { name?: string; description?: string; model?: string; prompt?: PromptRef; systemPrompt?: string; tools?: string[] | Record; maxTurns?: number; maxSteps?: number; autoRetrieve?: AutoRetrieveInput; } export interface LLMAgentInput extends BaseAgentInput { type?: 'llm'; } export interface FlowAgentInput extends BaseAgentInput { type: 'flow'; flowRef?: string; flow?: FlowFileInput; initialNode?: string; mode?: 'strict' | 'hybrid'; detourRules?: { allow?: string[]; deny?: string[]; emergency?: string[]; emergencyMessage?: string; emergencyHandoffAgent?: string; allowShortAffirmations?: boolean; allowDateTime?: boolean; }; } export interface TriageRouteInput { agentId: string; description: string; match?: string | { anyOf?: string[]; allOf?: string[]; regex?: string; }; } export interface TriageAgentInput extends BaseAgentInput { type: 'triage'; routes: TriageRouteInput[]; defaultAgent?: string; triageMode?: 'llm' | 'structured'; } export type AgentInput = LLMAgentInput | FlowAgentInput | TriageAgentInput; export interface ToolConfigInput { type: 'builtin' | 'module' | 'skill-loader' | 'cag' | 'cag-answer' | 'http'; entry?: string; paths?: string[]; inputSchema?: Record; outputSchema?: Record; timeoutMs?: number; description?: string; metadata?: Record; pack?: string; retrieverModel?: string; generatorModel?: string; prompt?: string; topK?: number; includeSources?: boolean; includeReasons?: boolean; candidateMaxChars?: number; method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; url?: string; pathParams?: Array<{ name: string; type: string; description: string; required?: boolean; }>; queryParams?: Array<{ name: string; type: string; description: string; required?: boolean; }>; headers?: Record; bodyParams?: Array<{ name: string; type: string; description: string; required?: boolean; }>; auth?: { type: 'bearer' | 'basic' | 'custom'; token?: string; username?: string; password?: string; headers?: Record; }; } export interface AutoRetrieveInput { tool: string; topK?: number; hint?: string; label?: string; message?: string; } export interface KnowledgePackInput { source: string; name?: string; description?: string; chunk?: { maxChars?: number; overlapChars?: number; }; } export interface KnowledgeConfigInput { packs?: Record; } export interface AriaflowConfig { $schema?: string; extends?: string[] | string; runtime?: RuntimeConfigInput; models?: Record; permissions?: PermissionConfig; agents?: Record; flows?: Record; tools?: Record; knowledge?: KnowledgeConfigInput; callback?: { url: string; method?: 'POST' | 'PUT'; headers?: Record; allowList?: string[]; denyList?: string[]; includeFullText?: boolean; }; } export type FlowNodeInput = FlowConfig['nodes'][number] & { nodeType?: 'start' | 'agent' | 'end' | 'global'; addGlobalPrompt?: boolean; }; export type FlowTransitionInput = NonNullable[number] & { contract?: { label?: string; conditionText?: string; toolOnly?: boolean; requiresUserTurn?: boolean; }; }; export interface FlowFileInput { id?: string; entry?: string; initialNode?: string; nodes: FlowNodeInput[]; transitions?: FlowTransitionInput[]; defaultRolePrompt?: string; contextStrategy?: FlowConfig['contextStrategy']; summaryPrompt?: FlowConfig['summaryPrompt']; summaryMaxTokens?: FlowConfig['summaryMaxTokens']; summaryTimeoutMs?: number; maxSteps?: FlowConfig['maxSteps']; } export interface LoadedRuntimeConfig { defaultAgentId: string; defaultModel?: unknown; maxTurns?: number; maxSteps?: number; maxHandoffs?: number; alwaysRouteThroughTriage?: boolean; triageAgentId?: string; callback?: { url: string; method?: 'POST' | 'PUT'; headers?: Record; allowList?: string[]; denyList?: string[]; includeFullText?: boolean; }; } export interface LoadedConfig { runtime: LoadedRuntimeConfig; agents: Array; flows: Record; tools: Record; sources: { configFiles: string[]; agentFiles: string[]; flowFiles: string[]; toolFiles: string[]; skillFiles: string[]; }; } export interface LoadOptions { cwd?: string; configPath?: string; configContent?: string; modelRegistry?: Record; defaultModel?: unknown; builtinTools?: Record; logger?: (level: 'debug' | 'warn' | 'error', message: string, meta?: Record) => void; silent?: boolean; } export interface SkillDefinition { name: string; description: string; license?: string; metadata?: Record; content: string; path: string; } export interface FlowMeta { id: string; initialNode?: string; path: string; } export type WarningType = 'invalid_frontmatter' | 'invalid_flow' | 'missing_prompt' | 'missing_template' | 'name_mismatch' | 'missing_ref' | 'invalid_tool_entry' | 'duplicate_agent' | 'duplicate_flow' | 'unresolved_flow_ref' | 'tool_not_found'; export interface ConfigWarning { type: WarningType; file: string; message: string; severity: 'warn' | 'error'; } export interface LoadSummary { agents: number; flows: number; tools: number; skills: number; layers: string[]; durationMs: number; warningCount: number; errorCount: number; } export interface LoadResult { config: LoadedConfig; summary: LoadSummary; warnings: ConfigWarning[]; }