- Home
- Plugin
- Strumenti e capacità
- dsh-team-janitor
dsh-team-janitor
xian-yu-zhao/dsh-team-janitor
Closes subagents whose work is done — stops their running work, archives the session, and releases the activation slot — with a tree overview that marks closed members and a command that restores them.
Installazione
dsh plugin --profile web add github:xian-yu-zhao/dsh-team-janitorREADME
dsh-team-janitor
Team collaboration QoL for DeepSeek Harness (DSH): the agent can decide to close subagents whose work is done — single close, idle sweep, compact team overview, and restore — with a red cleared marker in the Web UI.
中文定位:让智能体自己决策清理用完的子代理——单关、空闲清扫、团队总览与恢复,网页端同步显示红色「已清除」标记。
⭐ Star 一下,让我假装自己是个有影响力的开源作者。 — 一个 star 就是作者今天的好心情,右上角点一下只需两秒。
Why
Subagent trees grow cluttered: finished children stay in list_agents forever and their sessions pile up in the workspace sidebar. A subagent that finishes normally settles by itself and frees its activation slot (maxActiveSubagents) — no plugin is needed for capacity. What DSH lacks is a model-facing way to close a member for good: archive it, see it as closed, and reopen it if needed. This plugin fills that gap — model-side archiving, sidebar hygiene, a visible closed status, and reversible restore.
中文说明: 子代理树会越堆越乱:完成的孩子永远留在 list_agents,会话也堆在侧栏。正常完成的子代理会自动结算并释放槽位,无需插件;DSH 缺的是模型侧主动关闭成员的能力——归档、看到 closed 状态、需要时再唤醒。本插件补的就是这一块。
Install
npm is a first-class install path — the package is published at npmjs.com/package/dsh-team-janitor:
# Recommended: install the bundle into the current DSH profile
plugin_manager install_bundle dsh-team-janitor
# Or fetch it with the npm CLI first, then load the same bundle
npm install dsh-team-janitor
Or clone/download this repository and in DSH: Plugins → Add plugin, selecting the folder.
| Source | target value | Notes |
|---|---|---|
| npm | dsh-team-janitor | Published on npm; npm install fetches the same bundle |
| DSH plugin manager | dsh-team-janitor | Recommended: loads the bundle into the current profile |
| GitHub / local folder | clone or download this repo | Plugins → Add plugin → select the folder |
中文说明: npm 正式支持:plugin_manager install_bundle dsh-team-janitor(或先 npm install dsh-team-janitor 再装载同一 bundle);也可克隆/下载本仓库后在 DSH 的 Plugins → Add plugin 里选择文件夹。
Requirements
- The
subagentsandtoolsservices — present in any preset with subagent delegation (e.g. Web/Desktop defaults). Activation also checksrootOf,listDescendants, andresolveName; without them the plugin stays idle and logs one warning. workspaceRegistryis optional: the plugin still loads, butteam_close/team_sweep/team_restorereturn an explicitworkspaceRegistry service is unavailableerror and no session is touched.agents(forparked/settledand settlement verdicts) andsystemPrompt(for the hygiene nudge) are read with guards — missing them degrades those features, it does not disable the plugin.- One Host-side ESM module (
lib/index.js) + one small browser module (client.js); zero dependencies. - Targets DSH 44.7.0 (built-in
@deepseek-ai/dsh-subagent0.2.2-rc.5). Noengines.dshis declared on purpose: DSH compares that field against its package version (0.2.2-rc.5in this build), not the44.7.0product number, so declaring>=44.7.0would make profiles refuse to load the plugin.
Advantages
| Advantage | What it buys you |
|---|---|
| Model-facing tools(模型工具) | Four purpose-built tools — team_overview, team_close, team_sweep, team_restore — that the agent calls itself. Cleanup happens inside the conversation; no clicking around the UI. |
| Reversible archiving(可逆归档) | Closing only archives a session; nothing is deleted. team_restore reopens it anytime, and prompt makes it a restore-and-continue in one call. |
| Status overview(状态总览) | team_overview reports closed / running / parked / settled per member, so both the model and the user see who is still resident and who already released a slot. |
| Zero intrusion(零侵入) | Purely additive: no @deepseek-ai imports, no host-log edits, no agent/pre-step gate, no core patch. Uninstalling leaves sessions and the profile as they were. |
| Subtree restricted(子树限定) | Every tool acts only on the caller's own descendants. Siblings, ancestors, unrelated trees, and the tree root can never be touched — no cross-team accidents. |
| Last words(收尾发言) | Each member's closing remarks are cached from subagent/end and shown in the roster, so "is this one actually done?" is answered from evidence, not from a guess. |
| Cleared marker(已清除标记) | The Web subagent menu shows a red 已清除 / Cleared roster, scoped to the current conversation and driven by the live archive stream. |
中文说明: 优势集中在模型自主调用、只归档不删除、四态总览、零侵入与子树限定;缓存的收尾发言帮助判断「这个真的做完了吗」,网页端红色标记按对话独立。
Tools
All tools act only on the caller's own subtree (the root or any subagent can use them on their descendants):
| Tool | Effect |
|---|---|
team_overview | Compact roster: closed / running / parked / settled per member (parked = registered idle, slot may be held; settled = disposed, slot released), each member's closing words (from the subagent/end cache; lastWords:false suppresses them for large trees), and a closable list limited to the caller's own descendants (parked first, then settled) |
team_close | Close specific descendants (names from team_overview/list_agents, or session ids): requests a stop of their running work, archives their sessions so they leave the workspace sidebar, then polls settlement once for the whole batch and reports per target settled (slot released) or still resident |
team_sweep | Batch-close idle descendants; preview defaults to true (list only), preview: false executes, includeRunning: true also closes running agents; per-failure rows come back in failuresDetail and settlement is reported as settled / resident / unobserved counts |
team_restore | Unarchive closed members so they are visible and continuable again; optional prompt delivers a message right after restoring (restore-and-continue — a cold target resumes and occupies a slot) |
Outcomes are enumerated (closed, already-closed, duplicate, unknown, refused, cancelled, failed; restore: restored, not-closed, …), so the model can branch on them instead of parsing prose.
A short team-janitor:hygiene system-prompt context nudges the agent toward closing finished subagents whenever the tools are visible; it is assembled from the tools that are actually visible and stays under 260 characters.
中文说明: 四个工具只作用于调用者自己的子树。关闭 = 停止运行 + 会话归档(从侧栏消失);team_sweep 默认只预览;team_restore 带 prompt 可一步恢复并续跑。
Web UI: cleared marker
The plugin also ships a small browser half (client.js). In the session header's subagent catalog (the menu behind the descendant count), a red 已清除 / Cleared section lists whose sessions were cleared, below the tree. Data comes from the Host-authoritative Workspace follow stream (ctx.workspaces.list), so marks appear and disappear with real archive/unarchive events — team_close, team_sweep, and a manual GUI unarchive all reflect instantly.
Coverage follows what the tree has loaded: it matches the archived set against the same subagentCatalog projections the lineage renderer reads, so expanding a branch brings its levels into the roster. If the workspace state service is unavailable, the marker stays silent instead of guessing.
The roster is per conversation: it walks only the current session's own subtree (its catalog, then each loaded child catalog), so cleared members from other conversations never leak into this menu.
中文说明: 网页端子代理菜单底部有红色「已清除 / Cleared」名单,数据来自宿主 Workspace 归档流,随真实归档/取消归档即时变化;名单按对话独立,只遍历当前会话自己的子树。
Key semantics: closing
workspaceRegistry.archiveSession(childId, { stopActivity: true })writes a durable archive;- the session's own running turn is cancelled (like the user's stop button) and running descendants are cancelled with parent cause;
- the archived session leaves the workspace sidebar;
team_restore(or unarchiving in the GUI) brings it back; - later model steps are blocked by DSH's built-in gates: since DSH 44.7.0 the session controller rejects steps for agents whose own session is archived, and the subagent runtime's archive admission also checks managed ancestors — the plugin adds no gate of its own;
- capacity: a subagent that finishes normally settles by itself and frees its activation slot — no plugin needed. Archiving changes activity and visibility, not settlement guarantees: an idle member whose inbox still holds parked input may stay resident and keep its slot after archiving (DSH exposes no public dispose or inbox-clear API);
- settlement confirmation:
team_closepolls the agents registry once per call for up to ~2s after archiving the whole batch (200ms steps, honoring cancellation) and reports per targetsettled, slot releasedwhen the member leaves the registry,still resident — slot may be retained (parked inbox input)on timeout, orsettlement not observed (call cancelled)when the call was aborted.team_sweepreports the same assettled/resident/unobservedcounts; team_restoremakes a member resident again and occupies a capacity slot; with the optionalpromptthe message is accepted right after unarchiving (restore-and-continue — a cold target resumes), without it no turn starts. Non-continuable members (one-shot children) refuse apromptup front.
Closing never deletes history; archived sessions stay recoverable. Closing frees neither the child's name nor its list_agents row (catalog entries are permanent); whether the activation slot frees depends on the manager's settlement (point 5).
Note on scope: the archive set (archivedSessionIds) is profile-global. team_overview therefore answers "is this session archived in this profile", not "in this conversation" — a GUI unarchive, or another conversation's team_restore, clears closed everywhere in the Host view. The per-conversation scoping applies to the Web marker (see below).
中文说明: 唤醒拦截由 DSH 内置闸门完成(44.7.0 起覆盖「自身已归档」与「祖先已归档」),插件不自建闸门。正常完成自动释放槽位;若空闲成员的 inbox 里还停放着输入,归档后槽位可能仍被占用。team_overview 用 parked(仍驻留可能占槽)/ settled(已结算已释放)区分空闲成员,team_close 归档后短轮询、如实回报。关闭不删历史、不释放名字。详见 docs/DETAIL.md。
Boundaries & limitations
| Concern | What DSH already does | Our boundary |
|---|---|---|
| Slot release on normal finish | Automatic settlement | Not needed — no plugin involvement |
| Wake-up gate for archived sessions | Built-in since 44.7.0 (self + managed ancestors) | Adds no gate of its own |
| Archive / restore | workspaceRegistry API | Model-facing tools over that API |
| Sidebar hygiene | — | Closing archives the session so it leaves the sidebar |
| Cross-team safety | — | Every tool is restricted to the caller's own subtree |
list_agentsreads parent-owned catalogs whose membership entries are permanent: closed members may still appear there asinactive. Useteam_overviewfor the closed marker.- Closing does not free the child's name; names stay reserved among the creator's children (Harness rule).
- Archiving does not force-free capacity: a member idle with parked input in its inbox may stay resident (slot still occupied) after
team_close/team_sweep. - Requires a host composition with
subagents+tools(withrootOf/listDescendants/resolveName);workspaceRegistryis optional — without it the close/sweep/restore tools fail loudly with an explicit error and touch nothing. - The Web marker only covers catalog levels that are loaded, and only renders in root-conversation catalogs.
Testing
The repo ships a zero-dependency test suite; no DSH installation is needed:
npm run check # node --check on both halves
npm test # 104 assertions against a fake Cordis context
npm run verify # both
test/smoke.mjs drives the Host half with fake subagents / agents / workspaceRegistry / tools / systemPrompt services and asserts the contract: which tools register, roster statuses, closable scope (no siblings, never the caller), settlement verdicts (settled / still resident / cancelled), dedupe, refusal paths, restore-and-continue, and packaging invariants (no @deepseek-ai imports, bundle + web manifest, shipped file list). CI runs it on Node 20 and 22.
⭐ 觉得好用就 Star 一下,让我假装自己是个有影响力的开源作者。
Changelog
Full history: CHANGELOG.md.
- 1.1.5 — Correctness pass with a real test suite. Fixed:
team_sweepcould close the caller itself (the subtree walk included the owner);team_overviewoffered uncloseable siblings asclosable;team_restoreaccepted a self-restore and aprompton non-continuable children; cancellation was reported as a settlement verdict; an unmatched name was blamed on the subtree. Token efficiency: one settlement poll budget per call instead of one per target, trimmed tool descriptions,lastWords:false, 100-char closing words, no duplicated roster lines, hygiene context under 260 chars built from the visible tools. Also: bounded last-words cache (invalidated on restore), enumeratedoutcomevalues, structuredsettled,test/smoke.mjs(104 checks) + GitHub Actions CI. Noengines.dshon purpose (DSH compares it against0.2.2-rc.5, not44.7.0). Tool names and required parameters unchanged. - 1.1.4 —
team_overviewdistinguishesparked(registered idle, slot may be held) fromsettled(disposed, slot released) and ordersclosable nowaccordingly;team_closepolls ~2s after archiving and reports the observed settlement;team_sweepreturns per-failure rows infailuresDetail;team_restoreaccepts an optionalpromptfor restore-and-continue. New browser half: a red 已清除 / Cleared roster in the subagent catalog menu footer, driven by the live Workspace archive stream. Tool names and required parameters unchanged. - 1.1.3 — Target DSH 44.7.0 (
@deepseek-ai/dsh-subagent0.2.2-rc.5): dropped the plugin's ownagent/pre-steparchive gate (built-in gates now cover self-archived sessions and managed ancestors); reworded tool descriptions so closing no longer promises a freed capacity slot. Tool names, parameters, and output shapes unchanged. - 1.1.2 — First clean npm release: strips the UTF-8 BOM that made strict JSON parsing reject 1.1.0/1.1.1 (both deprecated).
- 1.1.0 — Initial release:
team_overview/team_close/team_sweep/team_restore.
中文说明: 1.1.5 修掉了几个真 bug——team_sweep 一度可能把调用者自己关掉(子树判定把 owner 算进去了)、closable 会混入不可关的旁支、team_restore 允许恢复自己、给一次性子代理带 prompt;被取消的调用不再谎报「仍驻留」。同时把结算确认改成整批一次轮询(关 12 个不再等于 12×2 秒)、工具描述与花名册瘦身(lastWords:false、收尾发言截断 100 字、去重复行),并新增零依赖自检 104 项 + GitHub Actions CI。故意不声明 engines.dsh:DSH 拿它跟包版本(0.2.2-rc.5)比较,不是 44.7.0 产品号,声明了会让 profile 直接拒绝加载。