@dexwox-labs/a2a-core
Version:
Core types, validation and telemetry for Google's Agent-to-Agent (A2A) protocol - shared foundation for client and server implementations
124 lines • 7.52 kB
JavaScript
"use strict";
/**
* @module Core
* @description Core types, utilities, and validation for the A2A protocol
*
* This package provides the foundational types and utilities for working with the
* Agent-to-Agent (A2A) protocol. It includes JSON-RPC implementations, protocol-specific
* types, validation utilities, and error handling.
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Trace = exports.TraceClass = exports.TaskFailedError = exports.TaskCanceledError = exports.TaskAlreadyCompletedError = exports.TaskNotFoundError = exports.InvalidTaskStateError = exports.ERROR_CODES = exports.A2AError = exports.schemas = exports.formatValidationError = exports.isPushNotificationConfig = exports.isAgentCard = exports.isTask = exports.isMessage = exports.validateDiscoverResponse = exports.validateDiscoverRequest = exports.validatePushNotificationConfig = exports.validateAgentCard = exports.validateTask = exports.validateMessage = exports.createValidator = exports.validateWithSchema = exports.z = void 0;
/**
* JSON-RPC types for request/response handling
*/
__exportStar(require("./types/jsonrpc"), exports);
/**
* Core A2A protocol types and interfaces
*/
__exportStar(require("./types/a2a-protocol"), exports);
/**
* Re-export Zod for schema validation
* @remarks Exported explicitly to avoid conflicts
*/
var zod_1 = require("zod");
Object.defineProperty(exports, "z", { enumerable: true, get: function () { return zod_1.z; } });
/**
* Schema validation utilities
*/
var schema_utils_1 = require("./validation/schema-utils");
Object.defineProperty(exports, "validateWithSchema", { enumerable: true, get: function () { return schema_utils_1.validateWithSchema; } });
Object.defineProperty(exports, "createValidator", { enumerable: true, get: function () { return schema_utils_1.createValidator; } });
/**
* Validators and type guards for A2A protocol objects
*
* These functions validate that objects conform to the A2A protocol specifications
* and provide type guards for TypeScript type narrowing.
*/
var validators_1 = require("./validation/validators");
/** Validates a message object against the protocol schema */
Object.defineProperty(exports, "validateMessage", { enumerable: true, get: function () { return validators_1.validateMessage; } });
/** Validates a task object against the protocol schema */
Object.defineProperty(exports, "validateTask", { enumerable: true, get: function () { return validators_1.validateTask; } });
/** Validates an agent card object against the protocol schema */
Object.defineProperty(exports, "validateAgentCard", { enumerable: true, get: function () { return validators_1.validateAgentCard; } });
/** Validates a push notification config against the protocol schema */
Object.defineProperty(exports, "validatePushNotificationConfig", { enumerable: true, get: function () { return validators_1.validatePushNotificationConfig; } });
/** Validates a discover request against the protocol schema */
Object.defineProperty(exports, "validateDiscoverRequest", { enumerable: true, get: function () { return validators_1.validateDiscoverRequest; } });
/** Validates a discover response against the protocol schema */
Object.defineProperty(exports, "validateDiscoverResponse", { enumerable: true, get: function () { return validators_1.validateDiscoverResponse; } });
/** Type guard for Message objects */
Object.defineProperty(exports, "isMessage", { enumerable: true, get: function () { return validators_1.isMessage; } });
/** Type guard for Task objects */
Object.defineProperty(exports, "isTask", { enumerable: true, get: function () { return validators_1.isTask; } });
/** Type guard for AgentCard objects */
Object.defineProperty(exports, "isAgentCard", { enumerable: true, get: function () { return validators_1.isAgentCard; } });
/** Type guard for PushNotificationConfig objects */
Object.defineProperty(exports, "isPushNotificationConfig", { enumerable: true, get: function () { return validators_1.isPushNotificationConfig; } });
/** Formats validation errors into human-readable messages */
Object.defineProperty(exports, "formatValidationError", { enumerable: true, get: function () { return validators_1.formatValidationError; } });
/** Raw Zod schemas for all protocol objects */
Object.defineProperty(exports, "schemas", { enumerable: true, get: function () { return validators_1.schemas; } });
/**
* Type conversion utilities
*/
__exportStar(require("./conversion/type-converters"), exports);
/**
* Message handling utilities
*/
__exportStar(require("./utils/message"), exports);
/**
* Task management utilities
*/
__exportStar(require("./utils/task"), exports);
/**
* Artifact handling utilities
*/
__exportStar(require("./utils/artifact"), exports);
/**
* Error classes and error handling
*
* These error classes provide standardized error handling across the A2A SDK.
*/
var errors_1 = require("./errors");
/** Base error class for all A2A errors */
Object.defineProperty(exports, "A2AError", { enumerable: true, get: function () { return errors_1.A2AError; } });
/** Standard error codes used throughout the A2A protocol */
Object.defineProperty(exports, "ERROR_CODES", { enumerable: true, get: function () { return errors_1.ERROR_CODES; } });
/** Error thrown when attempting to transition a task to an invalid state */
Object.defineProperty(exports, "InvalidTaskStateError", { enumerable: true, get: function () { return errors_1.InvalidTaskStateError; } });
/** Error thrown when a task cannot be found */
Object.defineProperty(exports, "TaskNotFoundError", { enumerable: true, get: function () { return errors_1.TaskNotFoundError; } });
/** Error thrown when attempting to modify a completed task */
Object.defineProperty(exports, "TaskAlreadyCompletedError", { enumerable: true, get: function () { return errors_1.TaskAlreadyCompletedError; } });
/** Error thrown when a task has been canceled */
Object.defineProperty(exports, "TaskCanceledError", { enumerable: true, get: function () { return errors_1.TaskCanceledError; } });
/** Error thrown when a task has failed */
Object.defineProperty(exports, "TaskFailedError", { enumerable: true, get: function () { return errors_1.TaskFailedError; } });
/**
* Telemetry and tracing decorators
*
* These decorators provide instrumentation for classes and methods to enable
* monitoring, debugging, and performance analysis.
*/
var telemetry_1 = require("./decorators/telemetry");
/** Class decorator for adding telemetry to all methods */
Object.defineProperty(exports, "TraceClass", { enumerable: true, get: function () { return telemetry_1.TraceClass; } });
/** Method decorator for adding telemetry to specific methods */
Object.defineProperty(exports, "Trace", { enumerable: true, get: function () { return telemetry_1.Trace; } });
//# sourceMappingURL=index.js.map