UNPKG

@openfloor/protocol

Version:

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

220 lines 9.17 kB
/** * @fileoverview Open Floor Protocol - Main entry point * Complete TypeScript implementation of the Open Floor Protocol specifications * @author Open Voice Interoperability Initiative * @version 0.0.1 * @license Apache-2.0 */ export type { SchemaOptions, IdentificationOptions, SupportedLayersOptions, CapabilityOptions, ManifestOptions, ConversantOptions, ConversationOptions, SenderOptions, ToOptions, BaseEventOptions, EnvelopeOptions, PayloadOptions, JsonSerializable, EventType, UtteranceEventOptions, ContextEventOptions, GetManifestsEventOptions, PublishManifestsEventOptions, RecommendScope, FloorReasonToken, AgentEventHandlers, ValidationResult } from './types'; export { parseIsoDuration, millisecondsToIsoDuration, generateUUID, resolveJsonPath, isValidUri, isValidUrl, isValidConfidence, isValidEncoding, deepClone, hasRequiredProperties, createValidationError } from './utils'; export { Span, Token, Feature, TextFeature, DialogEvent } from './dialog-event'; export type { DialogHistory } from './dialog-event'; export { Schema, Identification, SupportedLayers, Capability, Manifest, Conversant, Conversation, Sender, To, Event, Envelope, Payload } from './envelope'; export { UtteranceEvent, ContextEvent, InviteEvent, UninviteEvent, DeclineInviteEvent, ByeEvent, GetManifestsEvent, PublishManifestsEvent, RequestFloorEvent, GrantFloorEvent, RevokeFloorEvent, YieldFloorEvent, createEvent, isUtteranceEvent, isContextEvent, isInviteEvent, isUninviteEvent, isDeclineInviteEvent, isByeEvent, isGetManifestsEvent, isPublishManifestsEvent, isRequestFloorEvent, isGrantFloorEvent, isRevokeFloorEvent, isYieldFloorEvent } from './events'; export { OpenFloorAgent, BotAgent, FloorManager, ConvenerAgent } from './agents'; export { validateDialogEvent, validateManifest, validateEnvelope, validateDialogEventEnhanced, validateManifestEnhanced, validateEnvelopeEnhanced, EnhancedValidator } from './validation'; export declare const VERSION = "0.0.1"; /** * Library information */ export declare const OPEN_FLOOR_PROTOCOL: { readonly name: "@openfloor/protocol"; readonly version: "0.0.1"; readonly description: "Open Floor Protocol implementation for JavaScript/TypeScript"; readonly specifications: { readonly envelope: "1.0.0"; readonly dialogEvent: "1.0.2"; readonly manifest: "1.0.0"; }; readonly repository: "https://github.com/open-voice-interoperability/openfloor-js"; readonly documentation: "https://github.com/open-voice-interoperability/openfloor-js#readme"; }; /** * Convenience factory functions for common use cases */ /** * Creates a simple text utterance event * @param options - Utterance options * @returns UtteranceEvent instance * * @example * ```typescript * const utterance = createTextUtterance({ * speakerUri: 'tag:example.com,2025:user1', * text: 'Hello world', * to: { speakerUri: 'tag:example.com,2025:bot1' } * }); * ``` */ export declare function createTextUtterance(options: { speakerUri: string; text: string; to?: { speakerUri?: string; serviceUrl?: string; private?: boolean; }; confidence?: number; lang?: string; }): UtteranceEvent; /** * Creates a basic agent manifest * @param options - Manifest options * @returns Manifest instance * * @example * ```typescript * const manifest = createBasicManifest({ * speakerUri: 'tag:example.com,2025:bot1', * serviceUrl: 'https://example.com/bot', * name: 'Assistant', * organization: 'Example Corp', * description: 'A helpful assistant', * capabilities: ['chat', 'help'] * }); * ``` */ export declare function createBasicManifest(options: { speakerUri: string; serviceUrl: string; name: string; organization: string; description: string; capabilities?: string[]; department?: string; role?: string; }): Manifest; /** * Creates a simple conversation envelope * @param options - Envelope options * @returns Envelope instance * * @example * ```typescript * const envelope = createSimpleEnvelope({ * conversationId: 'conv:123', * senderUri: 'tag:example.com,2025:bot1', * events: [utteranceEvent] * }); * ``` */ export declare function createSimpleEnvelope(options: { conversationId?: string; senderUri: string; senderServiceUrl?: string; events?: Event[]; schemaVersion?: string; schemaUrl?: string; }): Envelope; /** * Creates a payload with openFloor wrapper * @param envelope - Envelope to wrap * @returns Payload instance * * @example * ```typescript * const payload = createPayload(envelope); * console.log(payload.toJSON()); // {"openFloor": {...}} * ``` */ export declare function createPayload(envelope: Envelope): Payload; /** * Parses an Open Floor payload from JSON string * @param jsonString - JSON string to parse * @returns Parsed Payload instance * @throws Error if JSON is invalid * * @example * ```typescript * const jsonString = '{"openFloor": {...}}'; * const payload = parsePayload(jsonString); * ``` */ export declare function parsePayload(jsonString: string): Payload; /** * Validates and parses an Open Floor payload * @param jsonString - JSON string to validate and parse * @returns Object containing validation result and parsed payload (if valid) * * @example * ```typescript * const result = validateAndParsePayload(jsonString); * if (result.valid) { * console.log('Payload is valid:', result.payload); * } else { * console.error('Validation errors:', result.errors); * } * ``` */ export declare function validateAndParsePayload(jsonString: string): { valid: boolean; errors: string[]; payload?: Payload; }; import { UtteranceEvent, ContextEvent, InviteEvent, UninviteEvent, DeclineInviteEvent, ByeEvent, GetManifestsEvent, PublishManifestsEvent, RequestFloorEvent, GrantFloorEvent, RevokeFloorEvent, YieldFloorEvent } from './events'; import { Span, Token, Feature, TextFeature, DialogEvent } from './dialog-event'; import { Schema, Identification, SupportedLayers, Capability, Manifest, Conversant, Conversation, Sender, To, Event, Envelope, Payload } from './envelope'; import { OpenFloorAgent, BotAgent, FloorManager, ConvenerAgent } from './agents'; import { validateDialogEvent, validateManifest, validateEnvelope } from './validation.js'; /** * Default export with all main classes for convenient importing */ declare const _default: { readonly Span: typeof Span; readonly Token: typeof Token; readonly Feature: typeof Feature; readonly TextFeature: typeof TextFeature; readonly DialogEvent: typeof DialogEvent; readonly Schema: typeof Schema; readonly Identification: typeof Identification; readonly SupportedLayers: typeof SupportedLayers; readonly Capability: typeof Capability; readonly Manifest: typeof Manifest; readonly Conversant: typeof Conversant; readonly Conversation: typeof Conversation; readonly Sender: typeof Sender; readonly To: typeof To; readonly Event: typeof Event; readonly Envelope: typeof Envelope; readonly Payload: typeof Payload; readonly UtteranceEvent: typeof UtteranceEvent; readonly ContextEvent: typeof ContextEvent; readonly InviteEvent: typeof InviteEvent; readonly UninviteEvent: typeof UninviteEvent; readonly DeclineInviteEvent: typeof DeclineInviteEvent; readonly ByeEvent: typeof ByeEvent; readonly GetManifestsEvent: typeof GetManifestsEvent; readonly PublishManifestsEvent: typeof PublishManifestsEvent; readonly RequestFloorEvent: typeof RequestFloorEvent; readonly GrantFloorEvent: typeof GrantFloorEvent; readonly RevokeFloorEvent: typeof RevokeFloorEvent; readonly YieldFloorEvent: typeof YieldFloorEvent; readonly OpenFloorAgent: typeof OpenFloorAgent; readonly BotAgent: typeof BotAgent; readonly FloorManager: typeof FloorManager; readonly ConvenerAgent: typeof ConvenerAgent; readonly createTextUtterance: typeof createTextUtterance; readonly createBasicManifest: typeof createBasicManifest; readonly createSimpleEnvelope: typeof createSimpleEnvelope; readonly createPayload: typeof createPayload; readonly parsePayload: typeof parsePayload; readonly validateAndParsePayload: typeof validateAndParsePayload; readonly validateDialogEvent: typeof validateDialogEvent; readonly validateManifest: typeof validateManifest; readonly validateEnvelope: typeof validateEnvelope; readonly VERSION: "0.0.1"; readonly OPEN_FLOOR_PROTOCOL: { readonly name: "@openfloor/protocol"; readonly version: "0.0.1"; readonly description: "Open Floor Protocol implementation for JavaScript/TypeScript"; readonly specifications: { readonly envelope: "1.0.0"; readonly dialogEvent: "1.0.2"; readonly manifest: "1.0.0"; }; readonly repository: "https://github.com/open-voice-interoperability/openfloor-js"; readonly documentation: "https://github.com/open-voice-interoperability/openfloor-js#readme"; }; }; export default _default; //# sourceMappingURL=index.d.ts.map