mcp-ai-agent-guidelines
Version:
A comprehensive Model Context Protocol server providing advanced tools, resources, and prompts for implementing AI agent best practices
106 lines • 3.66 kB
TypeScript
/**
* AgentOrchestrator - Manages agent handoffs and workflow execution
*
* @module agents/orchestrator
*/
import type { HandoffRequest, HandoffResult } from "./types.js";
/**
* Definition of a workflow containing sequential agent steps.
*/
export interface Workflow {
/** Unique name identifier for the workflow */
name: string;
/** Human-readable description of the workflow's purpose */
description: string;
/** Ordered sequence of agent steps to execute */
steps: WorkflowStep[];
}
/**
* A single step in a workflow execution.
*/
export interface WorkflowStep {
/** Name of the agent to execute for this step */
agent: string;
/** Optional mapping to extract data from previous outputs */
inputMapping?: Record<string, string>;
}
/**
* Result of executing a complete workflow.
*/
export interface WorkflowResult {
/** Whether the workflow completed successfully */
success: boolean;
/** Outputs from each step, keyed by agent name */
outputs: Record<string, unknown>;
/** Total time in milliseconds to execute the workflow */
executionTime: number;
/** Detailed results for each step */
steps: StepResult[];
/** Error message if the workflow failed */
error?: string;
}
/**
* Result of executing a single step in a workflow.
*/
export interface StepResult {
/** Name of the agent that executed this step */
agent: string;
/** Whether the step completed successfully */
success: boolean;
/** Output from the agent */
output?: unknown;
/** Time in milliseconds to execute this step */
executionTime: number;
/** Error message if the step failed */
error?: string;
}
/**
* Orchestrator for managing agent handoffs and multi-step workflows.
* Coordinates execution between agents and manages data flow.
*/
export declare class AgentOrchestrator {
private toolExecutor;
/**
* Sets the tool executor function for invoking MCP tools.
*
* @param executor - Function that executes an MCP tool by name with arguments
*/
setToolExecutor(executor: (toolName: string, args: unknown) => Promise<unknown>): void;
/**
* Executes a handoff to a target agent.
*
* @param request - The handoff request containing target agent and context
* @returns Result of the handoff including success status and output
*/
executeHandoff(request: HandoffRequest): Promise<HandoffResult>;
/**
* Executes a multi-step workflow with sequential agent handoffs.
*
* @param workflow - The workflow definition containing steps
* @param input - Initial input data for the first step
* @returns Result of the workflow execution including all step outputs
*/
executeWorkflow(workflow: Workflow, input: unknown): Promise<WorkflowResult>;
/**
* Maps input values from previous outputs based on mapping configuration.
*
* @param outputs - Record of previous outputs from workflow steps
* @param mapping - Mapping configuration with keys to path expressions
* @returns Mapped input object
*/
private mapInput;
/**
* Retrieves a value from a nested object using a dot-notation path.
*
* @param obj - The object to traverse
* @param path - Dot-separated path to the value (e.g., "user.name")
* @returns The value at the path, or undefined if not found
*/
private getValueByPath;
}
/**
* Singleton instance of the AgentOrchestrator.
* Use this export for global agent orchestration.
*/
export declare const agentOrchestrator: AgentOrchestrator;
//# sourceMappingURL=orchestrator.d.ts.map