UNPKG

mcp-ai-agent-guidelines

Version:

A comprehensive Model Context Protocol server providing advanced tools, resources, and prompts for implementing AI agent best practices

92 lines 2.81 kB
/** * Execution Controller - Orchestration strategies for A2A tool chaining * * Provides declarative execution patterns: * - Sequential execution (one after another) * - Parallel execution (concurrent with Promise.all) * - Parallel with join (merge results) * - Conditional branching * - Retry with exponential backoff */ import type { A2AContext } from "./a2a-context.js"; import { type InvokeOptions } from "./tool-invoker.js"; import type { ToolResult } from "./tool-registry.js"; /** * Execution strategy types */ export type ExecutionStrategy = "sequential" | "parallel" | "parallel-with-join" | "conditional" | "retry-with-backoff"; /** * Error handling mode */ export type ErrorHandling = "abort" | "skip" | "fallback"; /** * Step in an execution plan */ export interface ExecutionStep { /** Step identifier */ id: string; /** Tool to invoke */ toolName: string; /** Arguments for the tool */ args: unknown; /** Dependencies on other steps (by ID) */ dependencies?: string[]; /** Optional transform function for previous step output */ transform?: (previousOutput: unknown) => unknown; /** Invocation options */ options?: InvokeOptions; /** Condition for conditional execution */ condition?: (sharedState: Map<string, unknown>) => boolean; } /** * Execution plan configuration */ export interface ExecutionPlan { /** Execution strategy */ strategy: ExecutionStrategy; /** Steps to execute */ steps: ExecutionStep[]; /** Error handling mode */ onError: ErrorHandling; /** Fallback tool if onError is 'fallback' */ fallbackTool?: string; /** Fallback args */ fallbackArgs?: unknown; /** Retry configuration for retry-with-backoff strategy */ retryConfig?: { maxRetries: number; initialDelayMs: number; maxDelayMs: number; backoffMultiplier: number; }; } /** * Result of executing a chain */ export interface ChainResult { /** Whether the entire chain succeeded */ success: boolean; /** Results from each step (keyed by step ID) */ stepResults: Map<string, ToolResult>; /** Final output (from last successful step) */ finalOutput?: unknown; /** Error if chain failed */ error?: string; /** Execution summary */ summary: { totalSteps: number; successfulSteps: number; failedSteps: number; skippedSteps: number; totalDurationMs: number; }; } /** * Execute a chain of tools according to the execution plan * * @param plan - Execution plan * @param context - A2A context * @returns Chain execution result */ export declare function executeChain(plan: ExecutionPlan, context: A2AContext): Promise<ChainResult>; //# sourceMappingURL=execution-controller.d.ts.map