UNPKG

@openfloor/protocol

Version:

Open Floor Protocol implementation for JavaScript/TypeScript - enables interoperable multi-agent conversations

108 lines 3.24 kB
/** * @fileoverview JSON Schema validation for Open Floor Protocol * Provides validation against the official Open Floor schemas * @author Open Voice Interoperability Initiative * @version 0.0.1 * @license Apache-2.0 */ import { ValidationResult } from './types'; /** * Validates a dialog event object against the Dialog Event schema * @param data - Dialog event data to validate * @returns Validation result * * @example * ```typescript * const dialogEvent = { * id: 'de:123', * speakerUri: 'tag:example.com,2025:user1', * span: { startTime: '2025-01-01T00:00:00Z' }, * features: { * text: { * mimeType: 'text/plain', * tokens: [{ value: 'Hello' }] * } * } * }; * * const result = validateDialogEvent(dialogEvent); * console.log(result.valid); // true or false * ``` */ export declare function validateDialogEvent(data: unknown): ValidationResult; /** * Validates an assistant manifest object against the Assistant Manifest schema * @param data - Manifest data to validate * @returns Validation result * * @example * ```typescript * const manifest = { * identification: { * speakerUri: 'tag:example.com,2025:bot1', * serviceUrl: 'https://example.com/bot', * organization: 'Example Corp', * conversationalName: 'Bot', * synopsis: 'A helpful assistant' * }, * capabilities: [] * }; * * const result = validateManifest(manifest); * console.log(result.valid); // true or false * ``` */ export declare function validateManifest(data: unknown): ValidationResult; /** * Validates a conversation envelope object against the Conversation Envelope schema * @param data - Envelope data to validate * @returns Validation result * * @example * ```typescript * const envelope = { * openFloor: { * schema: { version: '1.0.0' }, * conversation: { id: 'conv:123' }, * sender: { speakerUri: 'tag:example.com,2025:agent1' }, * events: [] * } * }; * * const result = validateEnvelope(envelope); * console.log(result.valid); // true or false * ``` */ export declare function validateEnvelope(data: unknown): ValidationResult; /** * Enhanced validator that uses external AJV library if available * Falls back to simple validator if AJV is not available */ export declare class EnhancedValidator { private static _ajv; private static _initialized; /** * Initialize the validator (attempts to load AJV) */ private static _initialize; /** * Validate data against schema using AJV if available, otherwise simple validator * @param data - Data to validate * @param schema - JSON schema * @returns Validation result */ static validate(data: unknown, schema: Record<string, any>): ValidationResult; } /** * Validates dialog event using enhanced validator */ export declare function validateDialogEventEnhanced(data: unknown): ValidationResult; /** * Validates manifest using enhanced validator */ export declare function validateManifestEnhanced(data: unknown): ValidationResult; /** * Validates envelope using enhanced validator */ export declare function validateEnvelopeEnhanced(data: unknown): ValidationResult; //# sourceMappingURL=validation.d.ts.map