mcp-ai-agent-guidelines
Version:
A comprehensive Model Context Protocol server providing advanced tools, resources, and prompts for implementing AI agent best practices
71 lines • 2.56 kB
TypeScript
/**
* Tool Invoker - Core runtime for A2A tool orchestration
*
* Provides the execution layer for tool-to-tool invocations with:
* - Timeout enforcement
* - Recursion depth guards
* - Context propagation
* - Execution logging
* - Error handling and recovery
*/
import { type A2AContext } from "./a2a-context.js";
import type { ToolResult } from "./tool-registry.js";
/**
* Options for tool invocation
*/
export interface InvokeOptions {
/** Override timeout for this specific invocation */
timeoutMs?: number;
/** Skip execution if inputs match a recent invocation (deduplication) */
deduplicate?: boolean;
/** Custom error handler for this invocation */
onError?: (error: Error) => ToolResult | Promise<ToolResult>;
}
/**
* Invoke a tool with A2A context support
*
* This is the primary entry point for tool-to-tool invocations.
* It handles:
* - Context creation/propagation
* - Recursion depth checking
* - Timeout enforcement
* - Execution logging
* - Error handling
*
* @param toolName - Name of the tool to invoke
* @param args - Arguments to pass to the tool
* @param context - A2A context (optional for top-level, required for nested)
* @param options - Invocation options
* @returns Tool execution result
* @throws RecursionDepthError if maximum depth exceeded
* @throws ChainTimeoutError if chain timeout exceeded
* @throws ToolTimeoutError if tool timeout exceeded
* @throws ToolInvocationError if tool execution fails
*/
export declare function invokeTool(toolName: string, args: unknown, context?: A2AContext, options?: InvokeOptions): Promise<ToolResult>;
/**
* Batch invoke multiple tools in parallel
*
* @param invocations - Array of tool invocations
* @param context - Optional A2A context
* @returns Array of results (in same order as invocations)
*/
export declare function batchInvoke(invocations: Array<{
toolName: string;
args: unknown;
options?: InvokeOptions;
}>, context?: A2AContext): Promise<ToolResult[]>;
/**
* Invoke tools sequentially, passing output from one to the next
*
* @param chain - Array of tool invocations with optional transform functions
* @param context - Optional A2A context
* @param initialInput - Initial input for first tool
* @returns Final tool result
*/
export declare function invokeSequence(chain: Array<{
toolName: string;
transform?: (previousOutput: unknown) => unknown;
options?: InvokeOptions;
}>, context?: A2AContext, initialInput?: unknown): Promise<ToolResult>;
//# sourceMappingURL=tool-invoker.d.ts.map