@innerlife/channel-engine-adapter
v0.0.3
Published
ChannelEngine adapter for an inbox+runner brain (Innerlife Agent): inbox.push + debounce + per-agent serial run → outbound.
Readme
@innerlife/channel-engine-adapter
Implements ChannelEngine for an inbox + runner brain (Innerlife Agent).
Bridges @innerlife/channel's host to the brain: inbound → inbox.push →
per-agent serial runner.run → outbound. Zero dependency on @innerlife/agent
— it talks to a minimal structural BrainAgent / BrainRunner, so any matching
brain works and the app supplies the concrete instances.
Behaviour (see DESIGN.md §7)
- Identity —
resolveAgent(address, msg) → { agent, source }decides who. - Merge — push straight into the brain's inbox (
mergeKey = chat:<source>); the inbox merges bursts natively. A smalldebounceMscollects the first burst. - Concurrency — serial per agent instance (runner.run isn't reentrant),
concurrent across agents, bounded by a global semaphore (
concurrency, default 8). - Media —
mediaToText(ref)downgrades attachments to text (inbox text is a string). - Proactive —
engine.notify({ agent, source, text })(path B).
Reply routing assumes one agent per conversation source (the recommended model). A shared agent serving many sources cannot route replies precisely until the brain surfaces the processed source.
Usage
import { createInnerlifeEngine } from "@innerlife/channel-engine-adapter";
import { ChannelHost } from "@innerlife/channel";
import { weixin } from "@innerlife/channel-weixin";
const engine = createInnerlifeEngine({
runner, // your Innerlife Runner
resolveAgent: async (addr) => ({ agent: await pool.get(addr.peerId), source: addr.peerId }),
// mediaToText, resolveAddress, concurrency, debounceMs ... optional
});
const host = new ChannelHost({ channels: [weixin()], engine });
await host.start();