Skip to content
reaatech

@reaatech/agent-mesh

npm v1.0.0

A Zod-schema and TypeScript type package that defines the core domain entities, request/response shapes, and environment configuration for the agent-mesh multi-agent orchestrator ecosystem. It exports 15+ validated schemas and types (e.g., `IncomingRequestSchema`, `ContextPacketSchema`, `CircuitBreakerStateSchema`) along with shared constants, with `zod` as its only runtime dependency.

@reaatech/agent-mesh

npm version License: MIT CI

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

Core domain types, Zod validation schemas, environment configuration, and shared constants for the agent-mesh multi-agent orchestrator. This package is the single source of truth for all protocol shapes used throughout the @reaatech/agent-mesh-* ecosystem.

Installation

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

Feature Overview

  • 15+ exported types and Zod schemas — every domain entity has a matching runtime validation schema
  • Environment configuration — Zod-validated env object with 30+ configurable variables, fail-fast on missing required vars
  • Shared constants — service metadata, TTLs, size limits, rate-limit headers, SSRF protection patterns, and Pub/Sub collection names
  • Zero runtime dependencies beyond zod — lightweight and tree-shakeable
  • Dual ESM/CJS output — works with import and require

Quick Start

typescript
import {
  IncomingRequestSchema,
  type IncomingRequest,
  AgentResponseSchema,
  type AgentResponse,
} from "@reaatech/agent-mesh";
 
// Validate an incoming request at the boundary
const raw = JSON.parse(req.body);
const parsed = IncomingRequestSchema.parse(raw);
 
// Validate an agent's response before returning to the user
const agentResponse = AgentResponseSchema.parse({
  content: "I've reset your password. Check your email.",
  workflow_complete: true,
});

Exports

Request / Response Types

ExportDescription
IncomingRequestSchema / IncomingRequestValidated HTTP request body for /v1/request
EmployeeProfileSchema / EmployeeProfileResolved user identity from profile systems
AgentResponseSchema / AgentResponseValidated agent response with content, workflow_complete, and workflow_state

Classifier Types

ExportDescription
ClassifierOutputSchema / ClassifierOutputStructured Gemini classifier output: agent_id, confidence, ambiguous, detected_language, intent_summary, entities

Agent Configuration

ExportDescription
AgentConfigSchema / AgentConfigYAML agent registration schema: agent_id, display_name, description, endpoint, confidence_threshold, examples, etc.

Routing Types

ExportDescription
ContextPacketSchema / ContextPacketFull context bundle passed to agents: session_id, request_id, employee_id, raw_input, intent_summary, entities, turn_history, workflow_state
ConfidenceDecisionSchema / ConfidenceDecisionRouting decision: action (route/clarify/fallback), agent_id, confidence, reason, clarification_question

Session Types

ExportDescription
SessionRecordSchema / SessionRecordFirestore session document: session_id, user_id, status, active_agent, turn_history, workflow_state, ttl
TurnEntrySchema / TurnEntrySingle conversation turn: role, content, timestamp, intent_summary
SessionStatusUnion type: active, completed, abandoned, error

Circuit Breaker Types

ExportDescription
CircuitBreakerStateSchema / CircuitBreakerStatePer-agent state: agent_id, state (CLOSED/OPEN/HALF_OPEN), failure_count, success_count, backoff_multiplier
CircuitStateUnion type: CLOSED, OPEN, HALF_OPEN

Health Check Types

ExportDescription
HealthStatusSchema / HealthStatusHealth check response: status, version, uptime_ms, checks map

Configuration

ExportDescription
envZod-validated environment object with 30+ typed config variables
EnvTypeScript type inferred from the environment schema

Constants

ExportDescription
SERVICE_NAME / SERVICE_VERSIONService metadata
MAX_YAML_FILE_SIZE / MAX_REQUEST_BODY_SIZESize guards
CACHE_TTLTTL constants for API key, Slack profile, and clarification caches
RATE_LIMIT_HEADERSStandard rate-limit response header names
PRIVATE_IP_RANGESRegex patterns blocking localhost and private IPs (SSRF protection)
SUPPORTED_LANGUAGES / DEFAULT_LANGUAGE58 ISO 639-1 language codes for i18n
PUBSUB_TOPICS / FIRESTORE_COLLECTIONSGCP resource naming constants
MCPMCP protocol version and method names
CONFIDENCE / SESSIONThreshold boundaries and session defaults

Usage Pattern

Every schema export has a matching type export. Use the schema for runtime validation and the type for compile-time checking:

typescript
import { IncomingRequestSchema, type IncomingRequest } from "@reaatech/agent-mesh";
 
function handleRequest(raw: unknown): IncomingRequest {
  return IncomingRequestSchema.parse(raw);
}

License

MIT