UNPKG

@dexwox-labs/a2a-server

Version:

TypeScript server implementation for Google's Agent-to-Agent (A2A) protocol - includes Express/WebSocket handlers, request validation and queue management

69 lines 2.13 kB
"use strict"; /** * @module QueueManager * @description Interface and types for managing event queues in the A2A protocol * * This module provides interfaces and types for managing the lifecycle of event * queues in the A2A protocol server. It defines the QueueManager interface and * related types for queue statistics and errors. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.NoQueueError = exports.QueueExistsError = void 0; const a2a_core_1 = require("@dexwox-labs/a2a-core"); /** * Error thrown when attempting to add a queue that already exists * * This error is thrown when trying to add a new queue for a task that * already has a queue registered with the queue manager. * * @example * ```typescript * try { * await queueManager.add('task-123', new EventQueue()); * } catch (error) { * if (error instanceof QueueExistsError) { * console.error('Cannot add queue:', error.message); * } * } * ``` */ class QueueExistsError extends a2a_core_1.A2AError { /** * Creates a new QueueExistsError * * @param taskId - ID of the task that already has a queue */ constructor(taskId) { super(`Queue already exists for task ${taskId}`, a2a_core_1.ERROR_CODES.QUEUE_EXISTS); } } exports.QueueExistsError = QueueExistsError; /** * Error thrown when attempting to access a queue that doesn't exist * * This error is thrown when trying to access or tap into a queue for a task * that doesn't have a queue registered with the queue manager. * * @example * ```typescript * try { * await queueManager.tap('task-123'); * } catch (error) { * if (error instanceof NoQueueError) { * console.error('Cannot tap queue:', error.message); * } * } * ``` */ class NoQueueError extends a2a_core_1.A2AError { /** * Creates a new NoQueueError * * @param taskId - ID of the task that doesn't have a queue */ constructor(taskId) { super(`No queue exists for task ${taskId}`, a2a_core_1.ERROR_CODES.NO_QUEUE); } } exports.NoQueueError = NoQueueError; //# sourceMappingURL=queue-manager.js.map