|
1 | | -# openfloor-js |
| 1 | +<img src="https://github.com/open-voice-interoperability/artwork/blob/main/horizontal/color/Interoperability_Logo_color.png" width="300" alt="Open Floor Protocol Logo"> |
| 2 | + |
| 3 | +# Open Floor Protocol (OFP) — TypeScript Implementation |
| 4 | + |
| 5 | +[](https://www.npmjs.com/package/@openfloor/protocol) |
| 6 | +[](https://www.typescriptlang.org/) |
| 7 | +[](LICENSE) |
| 8 | +[](https://open-voice-interoperability.github.io/openfloor-js/) |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +> **A strict, standards-compliant TypeScript library for the [Open Floor Protocol (OFP)](https://github.com/open-voice-interoperability/docs), enabling interoperable, multi-agent conversational AI.** |
| 13 | +
|
| 14 | +--- |
| 15 | + |
| 16 | +## Table of Contents |
| 17 | +- [Overview](#overview) |
| 18 | +- [Installation](#installation) |
| 19 | +- [Usage](#usage) |
| 20 | +- [Protocol Overview](#protocol-overview) |
| 21 | +- [API Reference](#api-reference) |
| 22 | +- [Testing & Development](#testing--development) |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## Overview |
| 27 | + |
| 28 | +The Open Floor Protocol (OFP) is an open standard for multi-agent, multi-party conversational AI interoperability. This library provides a complete, rigorously tested TypeScript implementation of the OFP specifications, including: |
| 29 | +- **Conversation Envelope** (message container) |
| 30 | +- **Dialog Event** (utterances, context, etc.) |
| 31 | +- **Assistant Manifest** (agent capabilities/identity) |
| 32 | +- **Agent behaviors** (bot, floor manager, convener) |
| 33 | + |
| 34 | +**Goals:** |
| 35 | +- 100% schema compliance (see `/schemas`) |
| 36 | +- Robust automated testing (see `/tests`) |
| 37 | +- Developer-friendly, modern TypeScript API |
| 38 | +- Interoperability with all OFP-compliant agents |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +## Installation |
| 43 | + |
| 44 | +```sh |
| 45 | +npm install @openfloor/protocol |
| 46 | +``` |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## Usage |
| 51 | + |
| 52 | +### Create a Text Utterance Event |
| 53 | +```typescript |
| 54 | +import { createTextUtterance } from '@openfloor/protocol'; |
| 55 | + |
| 56 | +const utterance = createTextUtterance({ |
| 57 | + speakerUri: 'tag:example.com,2025:user1', |
| 58 | + text: 'Hello world', |
| 59 | + to: { speakerUri: 'tag:example.com,2025:bot1' } |
| 60 | +}); |
| 61 | +``` |
| 62 | + |
| 63 | +### Create a Basic Agent Manifest |
| 64 | +```typescript |
| 65 | +import { createBasicManifest } from '@openfloor/protocol'; |
| 66 | + |
| 67 | +const manifest = createBasicManifest({ |
| 68 | + speakerUri: 'tag:example.com,2025:bot1', |
| 69 | + serviceUrl: 'https://example.com/bot', |
| 70 | + name: 'Assistant', |
| 71 | + organization: 'Example Corp', |
| 72 | + description: 'A helpful assistant', |
| 73 | + capabilities: ['chat', 'help'] |
| 74 | +}); |
| 75 | +``` |
| 76 | + |
| 77 | +### Create a Conversation Envelope |
| 78 | +```typescript |
| 79 | +import { createSimpleEnvelope } from '@openfloor/protocol'; |
| 80 | + |
| 81 | +const envelope = createSimpleEnvelope({ |
| 82 | + conversationId: 'conv:123', |
| 83 | + senderUri: 'tag:example.com,2025:bot1', |
| 84 | + events: [utterance] |
| 85 | +}); |
| 86 | +``` |
| 87 | + |
| 88 | +### Validate and Parse a Payload |
| 89 | +```typescript |
| 90 | +import { validateAndParsePayload } from '@openfloor/protocol'; |
| 91 | + |
| 92 | +const jsonString = JSON.stringify({ openFloor: envelope }); |
| 93 | +const result = validateAndParsePayload(jsonString); |
| 94 | +if (result.valid) { |
| 95 | + console.log('Payload is valid:', result.payload); |
| 96 | +} else { |
| 97 | + console.error('Validation errors:', result.errors); |
| 98 | +} |
| 99 | +``` |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## Protocol Overview |
| 104 | + |
| 105 | +- **OFP** enables seamless, cross-platform communication between human users and autonomous agents. |
| 106 | +- **Conversation Envelope:** Universal JSON structure for agent-to-agent and agent-to-user messages. |
| 107 | +- **Dialog Event:** Standardized structure for utterances, context, and features. |
| 108 | +- **Assistant Manifest:** Machine-readable agent identity and capabilities. |
| 109 | + |
| 110 | +**Specifications:** |
| 111 | +- [Open Floor Inter-Agent Message Specification 1.0.0](https://github.com/open-voice-interoperability/docs/blob/main/specifications/ConversationEnvelope/1.0.0/InteroperableConvEnvSpec.md) |
| 112 | +- [Dialog Event Object Specification 1.0.2](https://github.com/open-voice-interoperability/docs/blob/main/specifications/DialogEvents/1.0.2/InteropDialogEventSpecs.md) |
| 113 | +- [Assistant Manifest Specification 1.0.0](https://github.com/open-voice-interoperability/docs/blob/main/specifications/AssistantManifest/1.0.0/AssistantManifestSpec.md) |
| 114 | + |
| 115 | +**Schemas:** |
| 116 | +- [Envelope Schema](./schemas/conversation-envelope/1.0.0/conversation-envelope-schema.json) |
| 117 | +- [Dialog Event Schema](./schemas/dialog-event/1.0.2/dialog-event-schema.json) |
| 118 | +- [Assistant Manifest Schema](./schemas/assistant-manifest/1.0.0/assistant-manifest-schema.json) |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +## API Reference |
| 123 | + |
| 124 | +- **[TypeDoc Documentation](https://open-voice-interoperability.github.io/openfloor-js/)** |
| 125 | +- All main classes, types, and utilities are exported from the package root. |
| 126 | +- See `/src/index.ts` for full API surface. |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## Testing & Development |
| 131 | + |
| 132 | +- **Run tests:** |
| 133 | + ```sh |
| 134 | + npm test |
| 135 | + ``` |
| 136 | +- **Build:** |
| 137 | + ```sh |
| 138 | + npm run build |
| 139 | + ``` |
| 140 | +- **Generate docs:** |
| 141 | + ```sh |
| 142 | + npm run docs |
| 143 | + ``` |
| 144 | + |
| 145 | + |
0 commit comments