UNPKG

nestjs-a2a

Version:

NestJS module for creating Google Agent to Agent Server

109 lines (108 loc) 4.5 kB
"use strict"; // === JSON-RPC Base Structures Object.defineProperty(exports, "__esModule", { value: true }); exports.TaskMethod = exports.ErrorCodeUnsupportedOperation = exports.ErrorCodePushNotificationNotSupported = exports.ErrorCodeTaskNotCancelable = exports.ErrorCodeTaskNotFound = exports.ErrorCodeInternalError = exports.ErrorCodeInvalidParams = exports.ErrorCodeMethodNotFound = exports.ErrorCodeInvalidRequest = exports.ErrorCodeParseError = exports.MessageRole = exports.PartType = exports.OutputMode = exports.InputMode = exports.TaskState = exports.JSONRPCResponse = exports.JSONRPCError = void 0; /** * Represents a JSON-RPC error object. */ class JSONRPCError { constructor(code, message, data) { this.code = code; this.message = message; this.data = data; } static of(code, message, data) { return new JSONRPCError(code, message, data); } } exports.JSONRPCError = JSONRPCError; /** * Represents a JSON-RPC response object. */ class JSONRPCResponse { constructor(result, error) { /** * Specifies the JSON-RPC version. Must be "2.0". * @default "2.0" * @const "2.0" */ this.jsonrpc = '2.0'; this.result = result; this.error = error; } static success(result) { return new JSONRPCResponse(result); } static error(error) { return new JSONRPCResponse(null, error); } } exports.JSONRPCResponse = JSONRPCResponse; // === Core A2A Data Structures /** * Represents the state of a task within the A2A protocol. * @description An enumeration. */ var TaskState; (function (TaskState) { TaskState["SUBMITTED"] = "submitted"; TaskState["WORKING"] = "working"; TaskState["INPUT_REQUIRED"] = "input-required"; TaskState["COMPLETED"] = "completed"; TaskState["CANCELED"] = "canceled"; TaskState["FAILED"] = "failed"; TaskState["UNKNOWN"] = "unknown"; })(TaskState || (exports.TaskState = TaskState = {})); var InputMode; (function (InputMode) { InputMode["TEXT"] = "text"; InputMode["FILE"] = "file"; InputMode["JSON"] = "json"; })(InputMode || (exports.InputMode = InputMode = {})); var OutputMode; (function (OutputMode) { OutputMode["TEXT"] = "text"; OutputMode["FILE"] = "file"; OutputMode["JSON"] = "json"; })(OutputMode || (exports.OutputMode = OutputMode = {})); var PartType; (function (PartType) { PartType["TEXT"] = "text"; PartType["FILE"] = "file"; PartType["DATA"] = "data"; })(PartType || (exports.PartType = PartType = {})); var MessageRole; (function (MessageRole) { MessageRole["USER"] = "user"; MessageRole["AGENT"] = "agent"; })(MessageRole || (exports.MessageRole = MessageRole = {})); // === Error Types (Standard and A2A) /** Error code for JSON Parse Error (-32700). Invalid JSON was received by the server. */ exports.ErrorCodeParseError = -32700; /** Error code for Invalid Request (-32600). The JSON sent is not a valid Request object. */ exports.ErrorCodeInvalidRequest = -32600; /** Error code for Method Not Found (-32601). The method does not exist / is not available. */ exports.ErrorCodeMethodNotFound = -32601; /** Error code for Invalid Params (-32602). Invalid method parameter(s). */ exports.ErrorCodeInvalidParams = -32602; /** Error code for Internal Error (-32603). Internal JSON-RPC error. */ exports.ErrorCodeInternalError = -32603; /** Error code for Task Not Found (-32001). The specified task was not found. */ exports.ErrorCodeTaskNotFound = -32001; /** Error code for Task Not Cancelable (-32002). The specified task cannot be canceled. */ exports.ErrorCodeTaskNotCancelable = -32002; /** Error code for Push Notification Not Supported (-32003). Push Notifications are not supported for this operation or agent. */ exports.ErrorCodePushNotificationNotSupported = -32003; /** Error code for Unsupported Operation (-32004). The requested operation is not supported by the agent. */ exports.ErrorCodeUnsupportedOperation = -32004; // === A2A Request Interfaces var TaskMethod; (function (TaskMethod) { TaskMethod["SEND"] = "tasks/send"; TaskMethod["GET"] = "tasks/get"; TaskMethod["CANCEL"] = "tasks/cancel"; TaskMethod["PUSH_NOTIFICATION"] = "tasks/pushNotification/set"; TaskMethod["GET_PUSH_NOTIFICATION"] = "tasks/pushNotification/get"; TaskMethod["RESUBSCRIBE"] = "tasks/resubscribe"; TaskMethod["SEND_SUBSCRIBE"] = "tasks/sendSubscribe"; })(TaskMethod || (exports.TaskMethod = TaskMethod = {}));