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AA+B,CAAA,uBAAA,EAA0B,SAAS,CAAA,CAAE,CAAA;AAAA,EAChG;AAAA,EAEA,OAAO,wBAAwB,WAAA,EAAqC;AAClE,IAAA,OAAO,IAAI,eAAA,CAAe,gCAAA,EAAkC,CAAA,4BAAA,EAA+B,WAAW,CAAA,CAAA,EAAI;AAAA,MACxG;AAAA,KACD,CAAA;AAAA,EACH;AAAA,EAEA,OAAO,oBAAA,CAAqB,OAAA,EAAiB,IAAA,EAAgC;AAC3E,IAAA,OAAO,IAAI,eAAA,CAAe,6BAAA,EAA+B,OAAA,EAAS,IAAI,CAAA;AAAA,EACxE;AAAA,EAEA,OAAO,8BAAA,GAAiD;AACtD,IAAA,OAAO,IAAI,eAAA,CAAe,uCAAA,EAAyC,uCAAuC,CAAA;AAAA,EAC5G;AAAA,EAEA,OAAO,yBAAyB,SAAA,EAAoC;AAClE,IAAA,OAAO,IAAI,eAAA;AAAA,MACT,iCAAA;AAAA,MACA,SAAA,GAAY,CAAA,4BAAA,EAA+B,SAAS,CAAA,CAAA,GAAK,4BAAA;AAAA,MACzD,SAAA,GAAY,EAAE,SAAA,EAAU,GAAI;AAAA,KAC9B;AAAA,EACF;AAAA,EAEA,OAAO,oBAAoB,OAAA,EAAiC;AAC1D,IAAA,OAAO,IAAI,gBAAe,4BAAA,EAA8B,CAAA,uBAAA,EAA0B,OAAO,CAAA,CAAA,EAAI,EAAE,SAAS,CAAA;AAAA,EAC1G;AACF","file":"chunk-SKWYPONI.cjs","sourcesContent":["import type { AgentCard, JSONRPCMessage, Message, Task } from '@a2a-js/sdk';\nimport type { FullOutput, MastraModelOutput } from '../stream/base/output';\n\n/**\n * Represents a JSON-RPC error object.\n */\nexport interface JSONRPCError<Data = unknown | null, Code = number> {\n  /**\n   * A number indicating the error type that occurred.\n   */\n  code: Code;\n\n  /**\n   * A string providing a short description of the error.\n   */\n  message: string;\n\n  /**\n   * Optional additional data about the error.\n   * @default null\n   */\n  data?: Data;\n}\n\n/**\n * Represents a JSON-RPC response object.\n */\nexport interface JSONRPCResponse<R = unknown | null, E = unknown | null> extends JSONRPCMessage {\n  /**\n   * The result of the method invocation. Required on success.\n   * Should be null or omitted if an error occurred.\n   * @default null\n   */\n  result?: R;\n\n  /**\n   * An error object if an error occurred during the request. Required on failure.\n   * Should be null or omitted if the request was successful.\n   * @default null\n   */\n  error?: JSONRPCError<E> | null;\n}\n\nexport interface TaskContext {\n  /**\n   * The current state of the task when the handler is invoked or resumed.\n   * Note: This is a snapshot. For the absolute latest state during async operations,\n   * the handler might need to reload the task via the store.\n   */\n  task: Task;\n\n  /**\n   * The specific user message that triggered this handler invocation or resumption.\n   */\n  userMessage: Message;\n\n  /**\n   * Function to check if cancellation has been requested for this task.\n   * Handlers should ideally check this periodically during long-running operations.\n   * @returns {boolean} True if cancellation has been requested, false otherwise.\n   */\n  isCancelled(): boolean;\n\n  /**\n   * The message history associated with the task up to the point the handler is invoked.\n   * Optional, as history might not always be available or relevant.\n   */\n  history?: Message[];\n\n  // taskStore is removed as the server now handles loading/saving directly.\n  // If a handler specifically needs history, it would need to be passed differently\n  // or the handler pattern might need adjustment based on use case.\n\n  // Potential future additions:\n  // - logger instance\n  // - AbortSignal linked to cancellation\n}\n\n// === Error Types (Standard and A2A)\n\n/** Error code for JSON Parse Error (-32700). Invalid JSON was received by the server. */\nexport const ErrorCodeParseError = -32700;\nexport type ErrorCodeParseError = typeof ErrorCodeParseError;\n/** Error code for Invalid Request (-32600). The JSON sent is not a valid Request object. */\nexport const ErrorCodeInvalidRequest = -32600;\nexport type ErrorCodeInvalidRequest = typeof ErrorCodeInvalidRequest;\n/** Error code for Method Not Found (-32601). The method does not exist / is not available. */\nexport const ErrorCodeMethodNotFound = -32601;\nexport type ErrorCodeMethodNotFound = typeof ErrorCodeMethodNotFound;\n/** Error code for Invalid Params (-32602). Invalid method parameter(s). */\nexport const ErrorCodeInvalidParams = -32602;\nexport type ErrorCodeInvalidParams = typeof ErrorCodeInvalidParams;\n/** Error code for Internal Error (-32603). Internal JSON-RPC error. */\nexport const ErrorCodeInternalError = -32603;\nexport type ErrorCodeInternalError = typeof ErrorCodeInternalError;\n\n/** Error code for Task Not Found (-32001). The specified task was not found. */\nexport const ErrorCodeTaskNotFound = -32001;\nexport type ErrorCodeTaskNotFound = typeof ErrorCodeTaskNotFound;\n/** Error code for Task Not Cancelable (-32002). The specified task cannot be canceled. */\nexport const ErrorCodeTaskNotCancelable = -32002;\nexport type ErrorCodeTaskNotCancelable = typeof ErrorCodeTaskNotCancelable;\n/** Error code for Push Notification Not Supported (-32003). Push Notifications are not supported for this operation or agent. */\nexport const ErrorCodePushNotificationNotSupported = -32003;\nexport type ErrorCodePushNotificationNotSupported = typeof ErrorCodePushNotificationNotSupported;\n/** Error code for Unsupported Operation (-32004). The requested operation is not supported by the agent. */\nexport const ErrorCodeUnsupportedOperation = -32004;\nexport type ErrorCodeUnsupportedOperation = typeof ErrorCodeUnsupportedOperation;\n/** Error code for Content Type Not Supported (-32005). The requested content type is not supported. */\nexport const ErrorCodeContentTypeNotSupported = -32005;\nexport type ErrorCodeContentTypeNotSupported = typeof ErrorCodeContentTypeNotSupported;\n/** Error code for Invalid Agent Response (-32006). The agent returned an invalid response. */\nexport const ErrorCodeInvalidAgentResponse = -32006;\nexport type ErrorCodeInvalidAgentResponse = typeof ErrorCodeInvalidAgentResponse;\n/** Error code for Extended Agent Card Not Configured (-32007). The agent has no extended card configured. */\nexport const ErrorCodeExtendedAgentCardNotConfigured = -32007;\nexport type ErrorCodeExtendedAgentCardNotConfigured = typeof ErrorCodeExtendedAgentCardNotConfigured;\n/** Error code for Extension Support Required (-32008). The request requires extension support. */\nexport const ErrorCodeExtensionSupportRequired = -32008;\nexport type ErrorCodeExtensionSupportRequired = typeof ErrorCodeExtensionSupportRequired;\n/** Error code for Version Not Supported (-32009). The requested protocol version is not supported. */\nexport const ErrorCodeVersionNotSupported = -32009;\nexport type ErrorCodeVersionNotSupported = typeof ErrorCodeVersionNotSupported;\n\n/**\n * Union of all well-known A2A and standard JSON-RPC error codes defined in this schema.\n * Use this type for checking against specific error codes. A server might theoretically\n * use other codes within the valid JSON-RPC ranges.\n */\nexport type KnownErrorCode =\n  | typeof ErrorCodeParseError\n  | typeof ErrorCodeInvalidRequest\n  | typeof ErrorCodeMethodNotFound\n  | typeof ErrorCodeInvalidParams\n  | typeof ErrorCodeInternalError\n  | typeof ErrorCodeTaskNotFound\n  | typeof ErrorCodeTaskNotCancelable\n  | typeof ErrorCodePushNotificationNotSupported\n  | typeof ErrorCodeUnsupportedOperation\n  | typeof ErrorCodeContentTypeNotSupported\n  | typeof ErrorCodeInvalidAgentResponse\n  | typeof ErrorCodeExtendedAgentCardNotConfigured\n  | typeof ErrorCodeExtensionSupportRequired\n  | typeof ErrorCodeVersionNotSupported;\n\nexport type RequestCredentialsMode = 'omit' | 'same-origin' | 'include';\n\nexport interface A2AAgentCardVerificationContext {\n  cardUrl: string;\n  fetchedAt: Date;\n}\n\nexport interface A2AAgentVerificationOptions {\n  verify: (card: AgentCard, context: A2AAgentCardVerificationContext) => Promise<void> | void;\n}\n\nexport interface A2AAgentOptions {\n  url: string;\n  id?: string;\n  name?: string;\n  description?: string;\n  headers?: Record<string, string>;\n  retries?: number;\n  backoffMs?: number;\n  maxBackoffMs?: number;\n  credentials?: RequestCredentialsMode;\n  fetch?: typeof fetch;\n  abortSignal?: AbortSignal;\n  timeoutMs?: number;\n  verifyAgentCard?: A2AAgentVerificationOptions;\n}\n\nexport interface A2AAgentRunState {\n  runId: string;\n  contextId?: string;\n  taskId?: string;\n  executionUrl: string;\n  cardUrl: string;\n  streamingSupported: boolean;\n  waitingForInput: boolean;\n  lastTask?: Task;\n}\n\nexport interface A2AAgentResumePayload {\n  taskId?: string;\n  contextId?: string;\n  executionUrl: string;\n  cardUrl: string;\n  waitingForInput: boolean;\n  task?: Task;\n}\n\nexport type A2AAgentGenerateResult = FullOutput<undefined> & {\n  task?: Task;\n  message?: Message;\n  resumePayload?: A2AAgentResumePayload;\n  resumeSchema?: string;\n};\n\nexport type A2AAgentStreamResult = MastraModelOutput<undefined> & {\n  task: Promise<Task | undefined>;\n  suspendPayload: Promise<A2AAgentResumePayload | undefined>;\n  resumeSchema: Promise<string | undefined>;\n  getResult(): Promise<A2AAgentGenerateResult>;\n};\n","import {\n  ErrorCodeContentTypeNotSupported,\n  ErrorCodeExtendedAgentCardNotConfigured,\n  ErrorCodeParseError,\n  ErrorCodeExtensionSupportRequired,\n  ErrorCodeInvalidRequest,\n  ErrorCodeInvalidAgentResponse,\n  ErrorCodeMethodNotFound,\n  ErrorCodePushNotificationNotSupported,\n  ErrorCodeTaskNotCancelable,\n  ErrorCodeTaskNotFound,\n  ErrorCodeUnsupportedOperation,\n  ErrorCodeInvalidParams,\n  ErrorCodeInternalError,\n  ErrorCodeVersionNotSupported,\n} from './types';\nimport type { JSONRPCError, KnownErrorCode } from './types';\n\n/**\n * Custom error class for A2A server operations, incorporating JSON-RPC error codes.\n */\nexport class MastraA2AError extends Error {\n  public code: KnownErrorCode | number;\n  public data?: unknown;\n  public taskId?: string; // Optional task ID context\n\n  constructor(code: KnownErrorCode | number, message: string, data?: unknown, taskId?: string) {\n    super(message);\n    this.name = 'MastraA2AError';\n    this.code = code;\n    this.data = data;\n    this.taskId = taskId; // Store associated task ID if provided\n  }\n\n  /**\n   * Formats the error into a standard JSON-RPC error object structure.\n   */\n  toJSONRPCError(): JSONRPCError<unknown> {\n    const errorObject: JSONRPCError<unknown> = {\n      code: this.code,\n      message: this.message,\n    };\n    if (this.data !== undefined) {\n      errorObject.data = this.data;\n    }\n    return errorObject;\n  }\n\n  // Static factory methods for common errors\n\n  static parseError(message: string, data?: unknown): MastraA2AError {\n    return new MastraA2AError(ErrorCodeParseError, message, data);\n  }\n\n  static invalidRequest(message: string, data?: unknown): MastraA2AError {\n    return new MastraA2AError(ErrorCodeInvalidRequest, message, data);\n  }\n\n  static methodNotFound(method: string): MastraA2AError {\n    return new MastraA2AError(ErrorCodeMethodNotFound, `Method not found: ${method}`);\n  }\n\n  static invalidParams(message: string, data?: unknown): MastraA2AError {\n    return new MastraA2AError(ErrorCodeInvalidParams, message, data);\n  }\n\n  static internalError(message: string, data?: unknown): MastraA2AError {\n    return new MastraA2AError(ErrorCodeInternalError, message, data);\n  }\n\n  static taskNotFound(taskId: string): MastraA2AError {\n    return new MastraA2AError(ErrorCodeTaskNotFound, `Task not found: ${taskId}`, undefined, taskId);\n  }\n\n  static taskNotCancelable(taskId: string): MastraA2AError {\n    return new MastraA2AError(ErrorCodeTaskNotCancelable, `Task not cancelable: ${taskId}`, undefined, taskId);\n  }\n\n  static pushNotificationNotSupported(): MastraA2AError {\n    return new MastraA2AError(ErrorCodePushNotificationNotSupported, 'Push Notification is not supported');\n  }\n\n  static unsupportedOperation(operation: string): MastraA2AError {\n    return new MastraA2AError(ErrorCodeUnsupportedOperation, `Unsupported operation: ${operation}`);\n  }\n\n  static contentTypeNotSupported(contentType: string): MastraA2AError {\n    return new MastraA2AError(ErrorCodeContentTypeNotSupported, `Content type not supported: ${contentType}`, {\n      contentType,\n    });\n  }\n\n  static invalidAgentResponse(message: string, data?: unknown): MastraA2AError {\n    return new MastraA2AError(ErrorCodeInvalidAgentResponse, message, data);\n  }\n\n  static extendedAgentCardNotConfigured(): MastraA2AError {\n    return new MastraA2AError(ErrorCodeExtendedAgentCardNotConfigured, 'Extended agent card is not configured');\n  }\n\n  static extensionSupportRequired(extension?: string): MastraA2AError {\n    return new MastraA2AError(\n      ErrorCodeExtensionSupportRequired,\n      extension ? `Extension support required: ${extension}` : 'Extension support required',\n      extension ? { extension } : undefined,\n    );\n  }\n\n  static versionNotSupported(version: string): MastraA2AError {\n    return new MastraA2AError(ErrorCodeVersionNotSupported, `Version not supported: ${version}`, { version });\n  }\n}\n"]}