agentleFS
GiggleLiuGiggleLiu/cryochamber/.claude/skills/chat-bridge/SKILL.md

chat-bridge

Skill34 starsChanged 7 months agoMITView on GitHub

Use when the user wants to bridge a cryochamber to a chat platform — Zulip or Feishu (Lark) — so the chamber agent can be driven from chat and reply into it. One unified backbone with per-platform adapters: trigger models (mention-gated vs pull-all), credentials, services, and end-to-end validation.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ask the user one question at a time.

    line 36
  2. Very specific:

    If unsure, recommend Zulip + mention-gated — quietest, matches group-chat etiquette (one consolidated reply per batch, never reply unless …

    line 64
  3. Very specific:

    Reply round-trip: wait for the agent session (cryo.log), then confirm the reply appears in the same topic/thread.

    line 153

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Chat Bridge (Zulip / Feishu — unified)

Bridge a cryochamber to a chat platform so the chamber agent can be remote-controlled from chat and post replies back. One backbone handles both platforms with the same abstraction: scripts/chat-bridge (CLI) + chat_bridge/ package (backbone.py + zulip.py + lark.py).

How it works (the file contract)

chat platform  ⇄  bridge (backbone + channel adapter)  ⇄  chamber mailbox
   (bot API)       fetch_new / send                        messages/inbox  → wake agent
                                                           messages/outbox ← agent replies
  • A new inbox file wakes the agent (cryochamber watch_dirs).
  • The agent replies with cryo-agent send, which writes to messages/outbox/.
  • The bridge posts outbox messages back to chat (same thread/topic), then archives.
  • The bridge never talks to the agent and the agent never talks to chat — the mailbox is the entire interface. Swapping the agent is a one-line change in cryo.toml.

The Channel protocol is the same abstraction for both platforms: profile(), fetch_new(cursor), send(target, content), upload(), download(). All policy — trigger gate, quiet mode, anti-echo, dedupe, reply routing, whitelist, stats, systemd services — lives in backbone.py and is platform-identical.

Step 0 — Decide platform, transport, and trigger model

Ask the user one question at a time. Start with the platform:

  • Zulip uses the REST API (transport = events realtime queue, or poll). Trigger models:
    • Mention-gated (default, recommended for shared/busy streams): only messages directed at the bot reach the agent — @**bot** mentions or trigger words (flash, ...). (Zulip has no message-level reply ids; reply-to-bot follow-ups are a Lark-only trigger, see below.) Everything else stays out of the chamber inbox. Recent same-thread chatter is buffered as reference context and included only when a directed message arrives, so unrelated topics/chats never leak into the prompt.
    • Pull-all (require_mention = false): every message in the stream wakes the agent. Simple; fine for low-traffic channels.
    • Direct messages (--dm): every one-to-one DM wakes the agent without a mention. The bridge processes one DM at a time so replies cannot cross sender boundaries. Group DMs are ignored.
    • DM dropbox (--dm --auto-reply TEXT): downloads attachments under messages/dropbox/<sender>/, sends the configured acknowledgement, and does not wake the agent. Failed acknowledgements are persisted and retried. Acknowledgements are at-least-once because Zulip has no idempotent send API, so a bridge crash immediately after sending can produce a duplicate. Use --auto-reply-no-files TEXT to redirect text-only messages.
  • Feishu / Lark — lark-cli event stream (WebSocket long connection, no ports opened). require_mention gates both p2p and group @bot messages; mention detection is content-based (lark events carry no mentions array). Lark messages carry reply ids, so with reply_in_thread a reply to one of the bot's own messages also counts as directed and is answered in-thread.

If unsure, recommend Zulip + mention-gated — quietest, matches group-chat etiquette (one consolidated reply per batch, never reply unless directed, and never echo the @mention in replies — the chamber's plan.md/AGENTS.md should state this rule).

Prerequisites

  1. cryo installed and a chamber exists (cryo init or the make-plan skill).
  2. Credentials:
    • Zulip: a zuliprc file; the bot must be subscribed to the stream.
    • Lark: install the tested CLI with npx @larksuite/cli@1.0.53 install, then complete lark-cli config init and lark-cli auth login --recommend; app scopes im:message.p2p_msg:readonly (+ send) and im.message.receive_v1 event subscription enabled.
  3. The agent command (pi, opencode, ...) on PATH with credentials.

Setup

cd <chamber>
# Zulip
chat-bridge init --platform zulip --stream "STREAM" --topic T \
    --config path/to/zuliprc [--history] [--trigger flash] [--allow-sender id...]
# Zulip DM channel
chat-bridge init --platform zulip --dm --name questions \
    --config path/to/zuliprc
# Zulip attachment dropbox
chat-bridge init --platform zulip --dm --name submissions \
    --auto-reply "Submission received." \
    --auto-reply-no-files "Please attach your submission file."
# Lark
chat-bridge init --platform lark --chat-id oc_xxx [--chat-type p2p|group]
# multi-channel: repeat init with --name <other>
chat-bridge run            # installs the systemd user service (or --no-service)

For a Zulip stream channel, --topic T provides the default route for proactive chamber messages. Without it, reactive replies still go to the triggering message's topic, while proactive messages with no safe route are quarantined under messages/outbox/failed/. A Zulip --dm channel routes replies to the triggering sender. Lark can likewise resolve a reactive chat from the triggering message when --chat-id is omitted. init validates credentials before replacing .cryo/zuliprc (0600), adds runtime credentials/state to the chamber's .gitignore, resolves the channel, and anchors the cursor at the newest message. Zulip's --history option imports the past instead; Lark's event stream does not offer history import. With no Lark --chat-type, the bridge defaults to p2p. Per-chamber config: bridge.toml. State: chat-bridge.json; logs: chat-bridge.log in the chamber. Multiple configured channels are serialized: the bridge does not pull another route until the chamber's reply to the active route has been posted.

Common flags in bridge.toml:

KeyDefaultMeaning
poll_interval15seconds between sync cycles
require_mentiontrueonly directed messages wake the agent
trigger_words["flash", "flash-bot"]trigger words (start + punctuation)
allowed_senders[]whitelist of platform ids; empty = anyone
reply_in_threadtruetreat replies to the bot's messages as directed and answer in-thread (message-level replies are Lark-only; Zulip routes by topic)
transportautoshared by all channels; zulip: auto/poll/events (other values behave as poll); lark always uses its event stream

Per-channel keys under [[bridge.channels]]:

KeyDefaultMeaning
dmfalseZulip only: watch one-to-one direct messages instead of a stream
auto_replyunsetDM dropbox acknowledgement; stores attachments without waking the agent
auto_reply_no_filesunsetDM dropbox reply for messages without attachments

Step 3 — Survive reboots and logout

sudo loginctl enable-linger <user>        # critical on headless hosts
systemctl --user list-units "com.cryo.*" --no-legend
# expect com.cryo.daemon.* and com.cryo.chat-bridge.* running

Without linger the user systemd manager (and every bridge service) shuts down when the last SSH session closes — the chamber silently stops reacting.

Step 4 — End-to-end validation

  1. Init sanity: chat-bridge init logs the bot identity and anchor cursor.
  2. Quiet test: post a non-mention message; confirm chat-bridge pull logs buffered as context and the inbox stays empty.
  3. Trigger test: post @**bot** status from a real user account, not the bot — anti-echo skips the bot's own messages.
  4. Reply round-trip: wait for the agent session (cryo.log), then confirm the reply appears in the same topic/thread.
  5. Idle persistence: close all SSH sessions, wait ~1 min, reconnect, confirm both services still active.

Troubleshooting

SymptomLikely causeFix
init fails resolving streamBot not subscribed to the streamAdd the bot in Zulip stream settings
Mention posted but nothing happensDifferent stream, or posted as the botCheck the actual stream name; test from a real user
HTTP 400 on /register narrowNumeric stream id in the events-queue narrow/register wants [["stream", "NAME"]] (name, not id); /messages wants dict narrows
Events long-poll never returnsServer ignores timeout paramClient bounds the poll (10 s) and recycles the queue — by design
Services die when no SSH sessionloginctl linger disabledsudo loginctl enable-linger <user>
Agent wakes for every messagerequire_mention = false on a busy streamSet require_mention = true
Proactive outbox file is quarantinedNo active reply and no configured topic/chatConfigure --topic or --chat-id; stale DM routes are never reused

Common Mistakes

MistakeFix
Leaving .cryo/zuliprc world-readable or in gitchmod 600, .gitignore covers .cryo/
Testing the mention path as the botAnti-echo hides it — always test from a real user
Skipping loginctl enable-linger on a serverServices die on logout; chamber goes silent
Forgetting bot subscription before initInit fails or misses messages
Running chat-bridge run on macOSService installation is systemd-only; use run --no-service under your own supervisor

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.