Adapter SDK
Overview
Introduction to @oro.ad/bridge-adapter-sdk — high-level orchestration for building platform adapters.
Adapter SDK
@oro.ad/bridge-adapter-sdk is the high-level orchestration package for building platform adapters. It re-exports everything from @oro.ad/bridge-sdk and adds:
- Runtime — factory that wires all components and manages lifecycle
- PlatformAdapter — interface your platform implements
- Formatter — transforms semantic blocks to platform-native markup
- Orchestrators — bidirectional event routing (bridge ↔ platform)
- Store — SQLite persistence for session mappings and message dedup
- TurnStreamer — incremental text streaming with throttled edits
Installation
npm install @oro.ad/bridge-adapter-sdk
You do not need to install
@oro.ad/bridge-sdk separately — it's re-exported from the adapter SDK.Architecture
┌─────────────────────────────────────────────────────┐
│ Your Adapter Code │
│ ┌──────────────────┐ ┌────────────────────────┐ │
│ │ PlatformAdapter │ │ Formatter │ │
│ │ (your impl) │ │ (your impl) │ │
│ └────────┬──────────┘ └───────────┬────────────┘ │
├───────────┼──────────────────────────┼───────────────┤
│ │ Adapter SDK Runtime │ │
│ ┌────────┴──────────────────────────┴────────────┐ │
│ │ Reconciler │ Replayer │ B2P │ P2B │ Streamer │ │
│ └────────────────────────┬───────────────────────┘ │
│ │ │
│ ┌────────────────────────┴───────────────────────┐ │
│ │ BridgeApi (REST) │ BridgeClient (WebSocket) │ │
│ └────────────────────────────────────────────────┘ │
├──────────────────────────────────────────────────────┤
│ ORO Claude Bridge │
└──────────────────────────────────────────────────────┘
What you implement
To build an adapter, you provide two things:
- PlatformAdapter — container lifecycle, message posting, attachment handling
- Formatter — rendering semantic blocks into your platform's message format
Everything else — bridge connectivity, session reconciliation, message replay, deduplication, streaming management — is handled by the SDK.
Minimal Example
import { createAdapterRuntime } from '@oro.ad/bridge-adapter-sdk'
import { MyPlatformAdapter } from './platform'
import { MyFormatter } from './formatter'
const runtime = createAdapterRuntime({
bridge: { url: 'http://localhost:3000' },
platform: new MyPlatformAdapter({ token: process.env.BOT_TOKEN }),
formatter: new MyFormatter(),
dataDir: './data',
skipReplay: false,
})
process.on('SIGINT', () => runtime.stop())
await runtime.start()