UNPKG

mcp-ai-agent-guidelines

Version:

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

149 lines 4.42 kB
/** * A2A-specific error types for tool orchestration * * Extends the base error system with specialized errors for: * - Tool invocation failures * - Recursion depth violations * - Timeout enforcement * - Orchestration workflow errors */ /** * Base error class for A2A operations with consistent structure */ class A2AOperationError extends Error { code; context; timestamp; constructor(message, code, context) { super(message); this.name = "A2AOperationError"; this.code = code; this.context = context; this.timestamp = new Date(); if (Error.captureStackTrace) { Error.captureStackTrace(this, A2AOperationError); } } } /** * Error thrown when a tool invocation fails */ export class ToolInvocationError extends A2AOperationError { toolName; constructor(toolName, message, context) { super(message, "TOOL_INVOCATION_ERROR", { ...context, toolName, }); this.name = "ToolInvocationError"; this.toolName = toolName; } } /** * Error thrown when recursion depth limit is exceeded */ export class RecursionDepthError extends A2AOperationError { currentDepth; maxDepth; constructor(currentDepth, maxDepth, context) { super(`Recursion depth limit exceeded: ${currentDepth} > ${maxDepth}`, "RECURSION_DEPTH_ERROR", { ...context, currentDepth, maxDepth, }); this.name = "RecursionDepthError"; this.currentDepth = currentDepth; this.maxDepth = maxDepth; } } /** * Error thrown when a tool execution times out */ export class ToolTimeoutError extends A2AOperationError { toolName; timeoutMs; constructor(toolName, timeoutMs, context) { super(`Tool '${toolName}' timed out after ${timeoutMs}ms`, "TOOL_TIMEOUT_ERROR", { ...context, toolName, timeoutMs, }); this.name = "ToolTimeoutError"; this.toolName = toolName; this.timeoutMs = timeoutMs; } } /** * Error thrown when the entire chain execution times out */ export class ChainTimeoutError extends A2AOperationError { chainTimeoutMs; toolsCompleted; constructor(chainTimeoutMs, toolsCompleted, context) { super(`Chain execution timed out after ${chainTimeoutMs}ms (${toolsCompleted} tools completed)`, "CHAIN_TIMEOUT_ERROR", { ...context, chainTimeoutMs, toolsCompleted, }); this.name = "ChainTimeoutError"; this.chainTimeoutMs = chainTimeoutMs; this.toolsCompleted = toolsCompleted; } } /** * Error thrown when a tool is not found in the registry */ export class ToolNotFoundError extends A2AOperationError { toolName; constructor(toolName, context) { super(`Tool '${toolName}' not found in registry`, "TOOL_NOT_FOUND_ERROR", { ...context, toolName, }); this.name = "ToolNotFoundError"; this.toolName = toolName; } } /** * Error thrown when a tool is not allowed to invoke another tool */ export class ToolInvocationNotAllowedError extends A2AOperationError { callerTool; targetTool; constructor(callerTool, targetTool, context) { super(`Tool '${callerTool}' is not allowed to invoke '${targetTool}'`, "TOOL_INVOCATION_NOT_ALLOWED_ERROR", { ...context, callerTool, targetTool, }); this.name = "ToolInvocationNotAllowedError"; this.callerTool = callerTool; this.targetTool = targetTool; } } /** * Error thrown when orchestration workflow execution fails */ export class OrchestrationError extends A2AOperationError { workflowName; constructor(message, context) { super(message, "ORCHESTRATION_ERROR", context); this.name = "OrchestrationError"; this.workflowName = context?.workflowName; } } /** * Error thrown when execution strategy is invalid or cannot be executed */ export class ExecutionStrategyError extends A2AOperationError { strategy; constructor(strategy, message, context) { super(message, "EXECUTION_STRATEGY_ERROR", { ...context, strategy, }); this.name = "ExecutionStrategyError"; this.strategy = strategy; } } //# sourceMappingURL=a2a-errors.js.map