UNPKG

mcp-subagents

Version:

Multi-Agent AI Orchestration via Model Context Protocol - Access specialized CLI AI agents (Aider, Qwen, Gemini, Goose, etc.) with intelligent fallback and configuration

183 lines 8.19 kB
import { z } from 'zod'; // Agent names export const AgentName = z.enum(['qwen', 'gemini', 'aider', 'goose', 'codex', 'opencode', 'claude']); // Authentication status export const AuthStatus = z.enum(['ready', 'needs_login', 'needs_api_key', 'needs_setup']); // Input methods export const InputMethod = z.enum(['flag', 'stdin', 'positional', 'subcommand']); // Task configuration export const TaskConfig = z.object({ model: z.string().optional(), files: z.array(z.string()).optional(), timeout: z.number().int().positive().default(300000), retries: z.number().int().min(0).max(5).default(1), sandbox: z.boolean().optional(), workingDirectory: z.string().optional(), allowFallback: z.boolean().default(true), fallbackAgents: z.array(AgentName).optional(), env: z.record(z.string()).optional().describe('Additional environment variables to pass to the agent'), flags: z.array(z.string()).optional().describe('Additional command-line flags to pass to the agent (e.g., ["--yes-always", "--model", "gpt-4o"])'), context: z.object({ stdin: z.string().optional(), environment: z.record(z.string()).optional() }).optional(), smartSummary: z.boolean().optional().describe('Automatically add summary request to complex tasks') }).strict(); // Agent detection result export const AgentDetectionResult = z.object({ name: AgentName, available: z.boolean(), version: z.string().optional(), authStatus: AuthStatus, authInstructions: z.string(), inputMethod: InputMethod, autoAcceptFlag: z.string().optional(), modelFlag: z.string().optional(), requiresSubcommand: z.string().optional() }).strict(); // Execution attempt export const ExecutionAttempt = z.object({ agent: AgentName, status: z.enum(['success', 'failed', 'busy', 'unavailable']), error: z.string().optional(), startTime: z.number().optional(), endTime: z.number().optional() }); // Run agent response export const RunAgentResponse = z.object({ success: z.boolean(), taskId: z.string(), agent: AgentName, executedBy: AgentName.optional(), fallbackUsed: z.boolean(), attempts: z.array(ExecutionAttempt), output: z.array(z.string()).optional() }); // Agent status export const AgentStatus = z.object({ name: AgentName, available: z.boolean(), status: z.enum(['ready', 'busy', 'needs_auth', 'not_installed']), version: z.string().optional(), currentTasks: z.number(), maxConcurrent: z.number(), authInstructions: z.string().optional() }); // List agents response export const ListAgentsResponse = z.object({ agents: z.array(AgentStatus) }); // Task status export const TaskStatus = z.object({ taskId: z.string(), status: z.enum(['queued', 'running', 'completed', 'failed', 'cancelled']), agent: AgentName, startTime: z.number().optional(), endTime: z.number().optional(), duration: z.number().optional(), output: z.array(z.string()), error: z.string().optional(), progress: z.number().min(0).max(100).optional() }); // Streaming task status for real-time output export const StreamingTaskStatus = z.object({ taskId: z.string(), status: z.enum(['queued', 'running', 'completed', 'failed', 'cancelled']), agent: AgentName, startTime: z.number().optional(), endTime: z.number().optional(), duration: z.number().optional(), lines: z.array(z.object({ lineNumber: z.number(), content: z.string(), timestamp: z.number().optional() })), totalLines: z.number(), hasMore: z.boolean(), lastSeenLine: z.number(), newLinesCount: z.number(), error: z.string().optional(), progress: z.number().min(0).max(100).optional() }); // Get task status request export const GetTaskStatusRequest = z.object({ taskId: z.string(), outputOptions: z.object({ // Pagination options offset: z.number().int().min(0).optional().describe('Starting line number (0-based)'), limit: z.number().int().min(1).optional().describe('Maximum number of lines to return'), fromEnd: z.boolean().optional().describe('If true, offset from the end of output instead of beginning'), maxChars: z.number().int().min(100).optional().describe('Maximum total characters to return'), // Search options search: z.string().optional().describe('Regex pattern to search for in output'), context: z.number().int().min(0).max(10).optional().describe('Number of lines before/after each match to include'), outputMode: z.enum(['content', 'matches_only', 'count']).optional().describe('How to return search results: content (full lines), matches_only (just matching portions), count (just numbers)'), ignoreCase: z.boolean().optional().describe('Case insensitive search'), matchNumbers: z.boolean().optional().describe('Include line numbers in search results'), // Streaming options streaming: z.object({ lastSeenLine: z.number().int().min(-1).optional().describe('Last line number client has seen (-1 for none)'), waitForNew: z.boolean().optional().describe('Wait up to maxWaitTime for new output'), maxWaitTime: z.number().int().min(100).max(30000).optional().describe('Max time to wait for new output in ms (default: 5000)'), includeLineNumbers: z.boolean().optional().describe('Include line numbers with each line') }).optional().describe('Options for incremental/streaming output') }).optional().describe('Control how much output to retrieve and search within it') }); // Workflow types export const WorkflowTask = z.object({ id: z.string().describe('Unique identifier for this task'), agent: AgentName, task: z.string().min(1).describe('Task description (supports {{dependency.output}} templates)'), dependsOn: z.string().optional().describe('ID of task this depends on'), condition: z.enum(['success', 'completed', 'always']).optional().describe('When to execute this task'), config: z.any().optional().describe('Task configuration') }); export const RunAgentSequenceRequest = z.object({ tasks: z.array(WorkflowTask).min(1).describe('Array of tasks to execute in sequence'), continueOnFailure: z.boolean().optional().describe('Continue workflow even if a task fails'), templateData: z.record(z.any()).optional().describe('Additional template variables') }); export const WorkflowResult = z.object({ success: z.boolean(), workflowId: z.string(), completedTasks: z.number(), totalTasks: z.number(), tasks: z.array(z.object({ id: z.string(), agent: AgentName, taskId: z.string().optional(), status: z.enum(['pending', 'running', 'completed', 'failed', 'skipped']), startTime: z.number().optional(), endTime: z.number().optional(), error: z.string().optional() })), output: z.array(z.string()).describe('Combined output from all tasks (last 10 lines)') }); // Parallel execution types export const ParallelTask = z.object({ agent: AgentName, task: z.string().min(1).describe('Task description'), config: z.any().optional().describe('Task configuration') }); export const RunAgentsParallelRequest = z.object({ tasks: z.record(z.string(), ParallelTask).describe('Named tasks to execute in parallel'), timeout: z.number().min(1000).max(600000).optional().describe('Timeout in milliseconds for all tasks'), failFast: z.boolean().optional().describe('Stop all tasks if any fails') }); export const ParallelResult = z.object({ success: z.boolean(), parallelId: z.string(), completedTasks: z.number(), totalTasks: z.number(), duration: z.number().optional(), tasks: z.record(z.string(), z.object({ agent: AgentName, taskId: z.string().optional(), status: z.enum(['running', 'completed', 'failed', 'cancelled']), startTime: z.number().optional(), endTime: z.number().optional(), error: z.string().optional() })), output: z.array(z.string()).describe('Combined output from all tasks') }); //# sourceMappingURL=index.js.map