Skip to content
reaatechREAATECH

@reaatech/agent-handoff-validation

npm v0.1.0

Validates Agent Handoff Protocol payloads and agent compatibility using a `HandoffValidator` class or standalone manual functions. It optionally integrates with Zod for schema enforcement, falling back to manual validation if Zod is not installed.

@reaatech/agent-handoff-validation

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

Payload validation and agent compatibility checking for the Agent Handoff Protocol. Works with or without Zod — lazily loads Zod schemas if available, falls back to manual validation otherwise.

Installation

terminal
npm install @reaatech/agent-handoff-validation
# or
pnpm add @reaatech/agent-handoff-validation

With Zod (optional, for stricter validation):

terminal
npm install @reaatech/agent-handoff-validation zod

Feature Overview

  • Schema validation — validates HandoffPayload structure against the protocol shape
  • Agent compatibility — checks language support, capacity, availability, and history size
  • Zod support (optional) — complete Zod schemas for HandoffPayload and AgentCapabilities; lazily loaded
  • Manual fallback — identical validation without Zod — no peer dependency required
  • Rejection classification — categorizes failures into 6 typed reasons: capability_mismatch, overloaded, invalid_payload, timeout, unavailable, unknown

Quick Start

typescript
import { HandoffValidator } from '@reaatech/agent-handoff-validation';
 
const validator = new HandoffValidator();
 
const result = await validator.validatePayload(payload, agentCapabilities);
 
if (!result.isValid) {
  console.error('Validation errors:', result.errors);
}

Exports

HandoffValidator

typescript
new HandoffValidator()
MethodDescription
validatePayload(payload, agent)Full validation: schema structure + compatibility checks

Returns { isValid: boolean; errors: string[] }. Validates: payload schema (zod or manual), language compatibility, agent capacity, availability status, and conversation history size.

Manual Validation (no Zod required)

ExportDescription
validatePayloadManual(payload, agent?)Schema-only validation of HandoffPayload structure
validateAgentCapabilitiesManual(capabilities)Validate an AgentCapabilities object standalone
validateCompatibilityManual(payload, agent)Compatibility checks: language, load, availability

Rejection Classification

ExportDescription
classifyRejectionReason(message, statusCode?)Map HTTP responses and error messages to a RejectionReason
RejectionReasonType: capability_mismatch' | 'overloaded' | 'invalid_payload' | 'timeout' | 'unavailable' | 'unknown

Zod Integration (optional)

ExportDescription
createZodValidator()Returns a validator function using Zod schemas (requires zod installed)

The Zod schemas are lazily loaded: HandoffValidator tries import('zod') on construction. If Zod is available, validation uses the full schema with detailed error messages. If not, it falls back to manual validation — identical API, identical behavior.

License

MIT