UNPKG

@mastra/core

Version:
109 lines (108 loc) 4.82 kB
require("./rolldown-runtime-uwYp4b74.cjs"); //#region src/a2a/types.ts /** Error code for JSON Parse Error (-32700). Invalid JSON was received by the server. */ const ErrorCodeParseError = -32700; /** Error code for Invalid Request (-32600). The JSON sent is not a valid Request object. */ const ErrorCodeInvalidRequest = -32600; /** Error code for Method Not Found (-32601). The method does not exist / is not available. */ const ErrorCodeMethodNotFound = -32601; /** Error code for Invalid Params (-32602). Invalid method parameter(s). */ const ErrorCodeInvalidParams = -32602; /** Error code for Internal Error (-32603). Internal JSON-RPC error. */ const ErrorCodeInternalError = -32603; /** Error code for Task Not Found (-32001). The specified task was not found. */ const ErrorCodeTaskNotFound = -32001; /** Error code for Task Not Cancelable (-32002). The specified task cannot be canceled. */ const ErrorCodeTaskNotCancelable = -32002; /** Error code for Push Notification Not Supported (-32003). Push Notifications are not supported for this operation or agent. */ const ErrorCodePushNotificationNotSupported = -32003; /** Error code for Unsupported Operation (-32004). The requested operation is not supported by the agent. */ const ErrorCodeUnsupportedOperation = -32004; /** Error code for Content Type Not Supported (-32005). The requested content type is not supported. */ const ErrorCodeContentTypeNotSupported = -32005; /** Error code for Invalid Agent Response (-32006). The agent returned an invalid response. */ const ErrorCodeInvalidAgentResponse = -32006; /** Error code for Extended Agent Card Not Configured (-32007). The agent has no extended card configured. */ const ErrorCodeExtendedAgentCardNotConfigured = -32007; /** Error code for Extension Support Required (-32008). The request requires extension support. */ const ErrorCodeExtensionSupportRequired = -32008; /** Error code for Version Not Supported (-32009). The requested protocol version is not supported. */ const ErrorCodeVersionNotSupported = -32009; //#endregion //#region src/a2a/error.ts /** * Custom error class for A2A server operations, incorporating JSON-RPC error codes. */ var MastraA2AError = class MastraA2AError extends Error { code; data; taskId; constructor(code, message, data, taskId) { super(message); this.name = "MastraA2AError"; this.code = code; this.data = data; this.taskId = taskId; } /** * Formats the error into a standard JSON-RPC error object structure. */ toJSONRPCError() { const errorObject = { code: this.code, message: this.message }; if (this.data !== void 0) errorObject.data = this.data; return errorObject; } static parseError(message, data) { return new MastraA2AError(ErrorCodeParseError, message, data); } static invalidRequest(message, data) { return new MastraA2AError(ErrorCodeInvalidRequest, message, data); } static methodNotFound(method) { return new MastraA2AError(ErrorCodeMethodNotFound, `Method not found: ${method}`); } static invalidParams(message, data) { return new MastraA2AError(ErrorCodeInvalidParams, message, data); } static internalError(message, data) { return new MastraA2AError(ErrorCodeInternalError, message, data); } static taskNotFound(taskId) { return new MastraA2AError(ErrorCodeTaskNotFound, `Task not found: ${taskId}`, void 0, taskId); } static taskNotCancelable(taskId) { return new MastraA2AError(ErrorCodeTaskNotCancelable, `Task not cancelable: ${taskId}`, void 0, taskId); } static pushNotificationNotSupported() { return new MastraA2AError(ErrorCodePushNotificationNotSupported, "Push Notification is not supported"); } static unsupportedOperation(operation) { return new MastraA2AError(ErrorCodeUnsupportedOperation, `Unsupported operation: ${operation}`); } static contentTypeNotSupported(contentType) { return new MastraA2AError(ErrorCodeContentTypeNotSupported, `Content type not supported: ${contentType}`, { contentType }); } static invalidAgentResponse(message, data) { return new MastraA2AError(ErrorCodeInvalidAgentResponse, message, data); } static extendedAgentCardNotConfigured() { return new MastraA2AError(ErrorCodeExtendedAgentCardNotConfigured, "Extended agent card is not configured"); } static extensionSupportRequired(extension) { return new MastraA2AError(ErrorCodeExtensionSupportRequired, extension ? `Extension support required: ${extension}` : "Extension support required", extension ? { extension } : void 0); } static versionNotSupported(version) { return new MastraA2AError(ErrorCodeVersionNotSupported, `Version not supported: ${version}`, { version }); } }; //#endregion Object.defineProperty(exports, "MastraA2AError", { enumerable: true, get: function() { return MastraA2AError; } }); //# sourceMappingURL=client-C9xbmacV.cjs.map