AgentSkillsCN

comm-bridge

C4通信桥——ALL外部通信的中央网关(Telegram、Lark等)。在通过“通过……回复”路径回复用户、向外部渠道发送主动消息、为Memory Sync获取对话历史,或在同步后创建检查点时使用此功能。传入的消息由各渠道机器人排队,并通过PM2调度守护进程传递给Claude。会话启动钩子会自动提供对话上下文,并可在未总结的对话超过预设阈值时触发Memory Sync。

SKILL.md
--- frontmatter
name: comm-bridge
description: >-
  C4 communication bridge — central gateway for ALL external communication (Telegram, Lark, etc.).
  Use when replying to users via the "reply via" path, sending proactive messages to external channels,
  fetching conversation history for Memory Sync, or creating checkpoints after sync.
  Incoming messages are queued by channel bots and delivered to Claude via a PM2 dispatcher daemon.
  Session-start hooks automatically provide conversation context and can trigger Memory Sync when unsummarized conversations exceed the configured threshold.

Communication Bridge (C4)

Central message hub - ALL communication with Claude goes through C4.

Architecture

code
Web Console ──┐
Telegram    ───┼──► C4 Bridge ◄──► Claude
Lark        ───┘

Components

ScriptPurposeReference
c4-receive.jsExternal → Claude (queue incoming messages)c4-receive
c4-send.jsClaude → External (route outgoing messages)c4-send
c4-control.jsSystem control plane (heartbeat, maintenance)c4-control
c4-dispatcher.jsPM2 daemon: polls pending queue, delivers to tmux
c4-session-init.jsHook (session start): context + Memory Sync triggerhooks
c4-fetch.jsFetch conversations by id rangec4-fetch
c4-checkpoint.jsCreate/query checkpoints (sync boundaries)c4-checkpoint

Database

SQLite at ~/zylos/comm-bridge/c4.db:

  • conversations: All messages (in/out) with priority, status, retry tracking
  • checkpoints: Recovery points with conversation id ranges
  • control_queue: System control messages (heartbeat, maintenance) with priority, ack deadlines, and status lifecycle

Health & Status

The activity monitor writes ~/zylos/activity-monitor/claude-status.json which includes a health field:

ValueMeaning
okSystem healthy, messages accepted normally
recoveringLiveness check failed, automatic recovery in progress
downMax recovery attempts exhausted, manual intervention required

Fail-open semantics: If the status file is missing or malformed, health is assumed ok — intake is never blocked by a read failure.

When health is not ok, c4-receive.js rejects incoming messages and records the channel/endpoint in ~/zylos/activity-monitor/pending-channels.jsonl. Once health returns to ok, the activity monitor sends recovery notifications to all pending channels.

Service Management

bash
pm2 status c4-dispatcher
pm2 logs c4-dispatcher
pm2 restart c4-dispatcher