dsh-swarm
A native swarm plugin for DeepSeek Harness (DSH): run multiple subagents on one task, collaborating through a shared, ordered message board with @mention wake-up.
This is a DSH plugin (a Host bundle plus a Web UI panel), not a prompt-only skill. The four swarm tools are registered with ctx.tools.register. Tested on DSH 0.2.2-rc.5 with zero runtime npm dependencies.
| Board | Members | Graph |
|---|---|---|
![]() |
![]() |
![]() |
Features
| Piece | Capability |
|---|---|
Host tools (swarm / post_message / read_board / swarm_wait) |
Registered on Cordis tools; full lifecycle from roster to wake-up |
| Persistence (append-only JSONL board + atomic roster) | node:fs only; survives disable/enable and process restarts |
@name wake-up through the subagent tree |
Delivers posts via ctx.subagents.sendMessage, skipping quoted/code blocks |
swarm_wait park/wake without polling |
Event-driven wait on new board posts or abort/timeout |
Forked session inheritance (inheritedFrom) |
Copies parent board history up to the fork cut with preserved seqs |
Web panel (Board / Members / Graph) in shell.overlay |
Collapsible lower-right overlay with deterministic seat-grid graph |
HTTP routes (snapshot / stream / tree) |
Live SSE push with polling fallback, plus raw tree diagnostics |
How it works
The session's agent is the coordinator. It splits work, assigns it by naming a member, and judges what comes back. Workers start from a clean context, so a brief must state what each owns, what it must not touch, and what to report.
swarm { action: "title" | "status" | "add" | "kill", name, brief, role, wake_mode, model, provider }
post_message { text: "@parser take the lexer tests", kind, request_id }
read_board { since, limit }
swarm_wait { since, timeout_ms }
A post is immutable and gets a per-swarm seq. A member wakes only for a post naming it (@name) or using @all; a member with wake_mode: "anything" wakes for every post. Delivery goes through ctx.subagents.sendMessage, so a running member sees it at its next step, an idle member starts a turn, and a stopped member resumes.
Brief on add
swarm add takes a brief. Naming a member does not start it, so a roster row alone leaves a worker that exists but has been told nothing; the brief is posted as @<name> <brief> in the same call, so the worker's first waking message already carries its task. The result's briefPost reports delivery honestly — a worker whose subagent is not running yet still gets the brief on the board, and undelivered says no live session received it.
A role's reasoning guidance is appended to the brief automatically: worker gets second- and third-order impact tracing, verifier gets falsification, and coordinator gets first-principles root-cause work. Pass your own instruction if you want something else — the guidance is a default, not an override.
Member state
swarm status reports each member as exactly one of:
| state | meaning | what the coordinator does |
|---|---|---|
waiting |
parked on the board, free | hand it work by name |
working |
inside a turn | it sees posts when it finishes; do not wait on a reply |
stopped |
no subagent running under that name | a post naming it revives it |
killed |
stopped and marked dead; no longer wakes | add a fresh member |
Only waiting is free capacity. If every member is waiting or stopped and the job is unfinished, nobody is coming — the swarm is waiting on you.
Live panel
The panel subscribes to /plugins/dsh-swarm/stream (SSE): one frame on connect, one per new post, and a keep-alive comment. If the stream is unavailable, fails, or goes silent for 45 s, the panel falls back to polling /plugins/dsh-swarm/snapshot, so it degrades instead of going blank. The footer says live, polling, or retrying.
/plugins/dsh-swarm/tree is the diagnostic counterpart, unused by the panel: it returns the live subagent tree as JSON (available, count, and descendant rows), separating "no swarm / no subagent service" from "no children spawned yet".
Repository layout
dsh-swarm/
├── index.js # Host entry: tools, SWARM_POLICY + HTTP routes
├── client.js # Browser panel (module-loader factory)
├── src/
│ ├── store.js # JSONL board + atomic roster + O_EXCL lock
│ ├── runtime.js # post/wake/wait/fork-inheritance logic
│ ├── mentions.js # @mention parsing and wake rules
│ ├── types.js # JSDoc type definitions
│ └── tools/index.js # the four tool definitions & JSON schemas
├── test/
│ └── smoke.mjs # 166 assertions: store, mentions, runtime, guidance, panel selection
├── locale/{en,zh}.json # display metadata
├── docs/DETAIL.{,zh.}md # localized plugin detail pages
├── skill/SKILL.md # coordinator playbook (usable as a DSH skill)
├── cordis.patch.yml # bundle patch
├── icon.svg # plugin icon
└── LICENSE # MIT
Install in DeepSeek Harness
Requirements: DeepSeek Harness (0.2.2-rc.5 or compatible) and Node.js >= 20.
Install directly in DSH Plugins > Add plugin with the Git spec:
git+https://github.com/V-dev-388/dsh-swarm.git
Or subscribe in Plugins > Discover (when Custom Plugin Indexes is enabled) using the format-1 index URL:
https://raw.githubusercontent.com/V-dev-388/dsh-swarm/main/market.json
Or clone this repository and install it into your DSH profile by directory link:
git clone https://github.com/V-dev-388/dsh-swarm.git
# In DSH plugin_manager:
plugin_manager install_bundle target=/path/to/dsh-swarm
Enable it with plugin_manager set_bundle. A new top-level Session sees the four tools; the panel appears in the lower-right of the Web GUI after a page refresh. Optionally load skill/SKILL.md as a skill for the coordinator playbook.
Reloading after edits: A Host change (
index.js/src/) requires disabling and re-enabling the bundle to load a fresh module generation; a Client change (client.js) only requires a page refresh.
Testing
Zero npm dependencies are needed — run the Node smoke suite with:
npm test
# or directly:
node test/smoke.mjs
test/smoke.mjs runs 166 assertions covering @mention parsing/inert regions, wake rules, JSONL persistence + O_EXCL locking, lazy session binding, brief delivery, member state transitions, kill interrupt reporting, and panel swarm selection.
Design constraints worth knowing
A bundle installed by directory link is loaded from its own path, and the hosting profile cannot resolve zod, @deepseek-ai/dsh-tools, or @deepseek-ai/dsh-storage-domain from disk — they ship inside the app archive. Consequence:
- No
storageDomain. The store usesnode:fsonly: an append-only JSONL board per swarm plus a roster document written through temp-file-and-rename. - No
defineTool. Tools are plainToolDefinitionobjects with standard JSON Schema and arenderfunction; argument checks run inexecute. - No Typert
@Remote. The panel reads plain HTTP routes (/plugins/dsh-swarm/snapshot,/stream,/tree) registered onctx.webServer. - No
Configexport. The loader requires a schemastery schema instance; defaults live inindex.js.
Limits
- No channels, no narrator agent, no model hot-switching.
- Separate storage: Boards live in
~/.dsh/storages/dsh-swarm/(relocatable viaDSH_HOME), not in the Session log, so they survive restarts but are not part of Session export/replay. killbehavior: Callsctx.subagents.interruptand markskilled: truein the roster, reportinginterrupt(sent,no-session,failed, orunavailable). Because DSH interrupts one turn and keeps subagent creation descendants independent, a member's own spawned children can remain alive.- Durability:
seqcomes from a persisted high-water counter (fsync+ atomic rename) committed before appending the board line under a cross-processO_EXCLlock. A crash between writes leaves a harmless gap rather than a reusedseq. - Lazy binding:
swarm addwrites a roster row;post_messagereconciles missing session IDs againstctx.subagents.listDescendants(onlycontinuablechildren bind) and reports unreachable targets inundelivered.



还没有评论,来写第一条。