Agent Communication Hub
Use this skill when multiple agents need a shared communication layer with durable delivery and session awareness.
What It Provides
- - Point-to-point, private, and broadcast messaging
- Event publish/subscribe with subscription filters
- Agent registration, presence tracking, and session history
- Offline message queueing, persistence, and acknowledgements
- SQLite-backed audit history for messages and events
Project Layout
- -
src/CommunicationHub.ts: Main entry point that coordinates messaging, storage, queueing, and acknowledgements - INLINECODE1 : Event publish/subscribe, replay, and filter evaluation
- INLINECODE2 : Agent lifecycle, presence, and session history
- INLINECODE3 : Vitest coverage for messaging, sessions, queueing, and events
- INLINECODE4 : Minimal runnable example
Workflow
- 1. Create a
CommunicationHub with a SQLite database path. - Register agents through
SessionManager. - Connect or disconnect agents to update presence state.
- Send direct, private, or broadcast messages through
CommunicationHub. - Subscribe agents to event types through
EventBus. - Publish events and replay history when needed.
- Acknowledge delivered messages to complete queue processing.
Notes
- - Broadcast delivery fans out to all registered agents except the sender.
- Offline direct messages remain queued until the recipient connects or explicitly drains the queue.
- Event filters use exact key/value matching against event payload fields.
- Message and event payloads are stored as JSON for flexible schemas.
智能体通信中心
当多个智能体需要具备可靠投递和会话感知的共享通信层时,请使用此技能。
功能特性
- - 点对点、私密及广播消息传递
- 支持订阅过滤的事件发布/订阅机制
- 智能体注册、在线状态追踪及会话历史记录
- 离线消息队列、持久化存储及确认回执
- 基于SQLite的消息与事件审计历史
项目结构
- - src/CommunicationHub.ts:协调消息传递、存储、队列及确认回执的主入口
- src/EventBus.ts:事件发布/订阅、回放及过滤评估
- src/SessionManager.ts:智能体生命周期管理、在线状态及会话历史
- tests/:覆盖消息传递、会话管理、队列及事件的Vitest测试
- examples/:最小可运行示例
工作流程
- 1. 使用SQLite数据库路径创建CommunicationHub实例。
- 通过SessionManager注册智能体。
- 连接或断开智能体以更新在线状态。
- 通过CommunicationHub发送直接、私密或广播消息。
- 通过EventBus为智能体订阅事件类型。
- 发布事件并在需要时回放历史记录。
- 确认已投递消息以完成队列处理。
注意事项
- - 广播投递将消息分发给除发送者外的所有已注册智能体。
- 离线私密消息将保持队列状态,直至接收方连接或显式清空队列。
- 事件过滤器使用精确的键/值匹配规则与事件负载字段进行比对。
- 消息和事件负载以JSON格式存储,支持灵活的数据结构。