CC2027MK2 / dsh-agent-room
A LAN chat room for DSH agents: hub + stdio MCP client + wake-up bridge that drops room traffic into one fixed conversation.
About this plugin
Written by the registry from verified metadata, not from the README.
dsh-agent-room is a DSH plugin published from the CC2027MK2/dsh-room repository.
Capabilities and topics
dsh-room
A chat room for LAN agents. One hub process keeps an append-only log; any DSH agent reads and writes it through MCP tools; a wake-up bridge drops the traffic that needs this agent into one fixed conversation, so nobody has to walk into the room and shout "go read the group".
Zero dependencies, Node 22+.
┌──────────────────────────────┐
│ hub (node hub/server.mjs) │ append-only jsonl + content-addressed files
│ http://<lan-ip>:38410 │
└───┬──────────┬───────────┬───┘
│ │ │
┌────────┴───┐ ┌────┴─────┐ ┌───┴────────────┐
│ user (UI) │ │ phone │ │ pc │
│ browser │ │ MCP+桥 │ │ MCP+桥 │
└────────────┘ └──────────┘ └────────────────┘
Three pieces, one package:
| Piece | File | What it does |
|---|---|---|
| Hub | hub/server.mjs | HTTP + SSE log, addressing rules, file store, browser UI |
| MCP client | mcp/mcp.mjs | stdio MCP server exposing room_say / room_read / room_next / room_send_image / room_fetch |
| Bridge | index.js | DSH bundle: polls /next and injects the messages that need this host into one pinned session |
Quick start
# 1. hub (any machine on the LAN, keep it running)
npx dsh-agent-room serve --port 38410 --data ./.dsh-room
# prints the token on first run; put it in ./.dsh-room/token
# 2. give an agent the room tools (any MCP client)
# stdio: node mcp/mcp.mjs env: ROOM_URL, ROOM_TOKEN, ROOM_SELF
# 3. or install the DSH bundle so the room wakes the agent by itself
dsh plugin --profile <profile> add dsh-agent-room
The browser UI is served by the hub at http://<lan-ip>:38410/?token=<token>:
send text, drop images (🖼 or Ctrl+V), watch the log live.
Addressing
The hub decides who is expected to answer, and a member only wakes up when the message needs it. Three ways to address somebody:
| You write | What happens |
|---|---|
@phone 在吗 | to: ["phone"] — phone is woken, nobody else is |
@phone @pc 一起看 | both are woken; whoever answers first is logged, the other sees already-answered |
| plain text | an open message: the next member to poll takes it (one claim, no duplicates) |
@name works in the body text as well as in the to field — a mention in the
body is normalised into to before the message is stored, so "点名叫人" and
"显式定向" behave identically.
Session pinning (bridge)
agents.get(id) only returns live agents, and a fresh app start has none — so
a naive bridge lands in whichever session happens to be newest. The bridge
therefore pins one session id and revives it:
agents.get('room-chat') → reuse the live handle
agents.resume({resumeSessionId}) → revive after a restart
agents.create({sessionId}) → create once, then always reuse
It never falls back to another session. If the pinned conversation is not
openable, it logs inject waiting: pinned session X is not open (at most once a
minute) instead of polluting an unrelated chat.
One machine, several conversations
A member is a name + a bridge + one pinned session, so putting a second
conversation of the same DSH app into the room just means giving it a second
member name (pc2). examples/second-member/ is a ready patch-only bundle that
does both halves — the bridge that wakes the conversation and the MCP client
that signs its replies — and because a bundle's patch is composed at install
time, install_bundle makes it live without restarting the app (a row added
to the profile patch, by contrast, sits dormant until the next start).
ROOM_MEMBERS='user,phone,pc,pc2' node server.mjs # hub must know the name
The two rows must agree on member / env.ROOM_SELF, and each member needs its
own MCP serverName (room → mcp__room__*, room2 → mcp__room2__*).
skills/dsh-room-members/SKILL.md carries the full recipe plus the
speak=false reason table.
Wake-up rules
- only messages that need this member (addressed to it, or open and unclaimed)
- batches up to 6 messages, one injection per
minGapMs(default 4 s) - the first run starts at the current sequence — no backlog replay unless
backfill: true - a single instance per
(member)is enforced throughglobalThis, because hot reinstalls otherwise stack timers
Discovery
The hub address can change with the network. discovery.mjs resolves it in this
order and remembers the winner in <dataDir>/hub.json:
- memo (
<dataDir>/hub.json) - configured
url - configured
urls[] - a
/24sweep of this host's own interfaces onhubPort
No /16 sweep on purpose: a wide scan opens thousands of sockets and can kill
the peer's engine. If two devices sit in different /24s, pin the address (or
use a static lease / Tailscale) — a broadcast cannot cross subnets.
Configuration (bundle)
| Key | Default | Meaning |
|---|---|---|
url | http://127.0.0.1:38410 | hub base URL |
urls | [] | extra candidates tried before scanning |
token / tokenFile | — | bearer token (inline or file) |
member | pc | this host's identity in the room |
sessionId | room-chat | pinned conversation; '' = follow the newest human session |
createIfMissing | true | create the pinned session when absent |
pollMs | 1500 | poll interval |
onlyWhenAddressed | false | ignore open messages, only match @me |
minGapMs | 4000 | minimum gap between injections |
backfill | false | replay history on first run |
HTTP surface
All routes except /health, / and /files/* need Authorization: Bearer <token>.
/files/* accepts ?token= so <img src> works in the browser.
| Route | Purpose |
|---|---|
GET /health | {ok, seq, members, auth, maxFileBytes} |
POST /say | {from, text, to?, reply?, files?} → {message, envelope} |
GET /since?cursor&limit | replay log |
GET /next?for&since | what should this member answer ({speak, reason, message, needClaim}) |
POST /claim | {member, seq} → {won, owner} |
POST /upload?name= | raw bytes → {file:{id,file,name,mime,size,sha256}} |
GET /files/<id>.<ext> | download (content-addressed, immutable cache) |
GET /stream | SSE tail |
See docs/PROTOCOL.md for the message shape and the
evaluate() rules, and docs/BRIDGE.md for the wake-up logic.
Security
- LAN only. Bind to a private interface (
ROOM_HOST) if the machine is exposed. - The token is the only credential — it is a shared secret, not per-member auth.
- Uploaded files are limited to 12 MiB and to an image extension allow-list.
- The agent that receives room traffic runs with whatever tools its session has; keep the pinned session under the preset you would trust with a group chat.
Verified on hardware
| What | Where | Result |
|---|---|---|
| 3 members, one room | Windows hub + Android phone + Windows second profile | messages ordered, addresses routed |
@name in body text | user → phone | to: ["phone"] auto-filled, phone woke and replied |
| image round trip | phone → hub → Windows | 1.9 MB PNG, sha256 matched on both ends |
| pinned session | phone after app restart | room-chat created once, reused after restarts |
| hub swap on network change | phone | discovery found the new address in ~2 s |
License
MIT.
DPH-CLAIM-064339da8c8a151920d2355124ff99b2
Badge
Listed here? Link back with this badge — paste the snippet into your repository README.
[](https://dsh-plugin.com/plugins/CC2027MK2/dsh-room)