Auto-continue an interrupted dsh session after a web restart by injecting a "continue" follow-up; one-shot per process, no duplicate-injection loops.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:shengyvself/dsh-autoresume
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time. Only install sources you trust, and pin a commit (github:owner/repo#sha).
README
This plugin publishes its README in Chinese only.
web 进程重启后,若目标会话停在"被打断的中间态"(open turn / 无结果的 tool call / turn/end interrupted), 自动向该会话注入一条「继续」,让 agent 接着干活——无需人工干预。
特性
- 只服务一个配置的
targetSessionId,绝不扫描其他会话 - 通过
ctx.sessionPersistence.inspect()读取会话持久化事件流做状态判定 - 判定逻辑:
- interrupted(注入「继续」):turn/step 打开未闭合、存在无对应
tool/result的tool/call、最后一个turn/end原因为interrupted - completed(不动作):最后是
assistant/message,或turn/end为completed且其后无新用户消息 - settled(不动作):
cancelled/error等已闭合终态;以及闭合轮次后出现的手动用户消息
- interrupted(注入「继续」):turn/step 打开未闭合、存在无对应
- 注入方式:
ctx.agents.get(target)→agent.followup(userMessage)(消息source.kind=plugin, form=notice) - 进程级一次性:每个 web 进程只判定/注入一次;
bootGraceMs宽限窗口内有效(profile HMR 装卸插件不误触发) - 目标会话未就绪时按
pollIntervalMs重查
安装
# 1. 构建
npm run build
# 2. 注册到 web profile
dsh plugin --profile web add /path/to/dsh-autoresume
# 3. 配置目标会话(编辑 web profile 的 cordis.patch.yml)
- insert:
- id: dsh-autoresume
name: 'dsh-autoresume'
config:
targetSessionId: '<your-session-id>' # 必填
# 4. 验证注册
dsh --profile web --dump-config # 应出现 id: dsh-autoresume
# 5. 重启生效
sudo systemctl restart dsh-web
配置项
| 键 | 默认 | 说明 |
|---|---|---|
targetSessionId |
(必填) | 要自动续跑的目标会话 ID;未配置则插件不动作 |
bootGraceMs |
120000 |
web 进程启动后允许判定的宽限窗口(毫秒) |
initialDelayMs |
3000 |
首次检查延迟(等会话恢复) |
pollIntervalMs |
5000 |
会话未就绪时的重查间隔 |
promptText |
继续(自动) |
注入的续跑提示词 |
工作原理
web 重启 → 插件加载 → 宽限窗口内 inspect(目标会话)
├─ interrupted → agent.followup('继续(自动)') → 自动接续
├─ completed / settled → 不动作(避免重复注入)
└─ 会话未就绪 → 5s 后重查
架构
src/
├── service.js # 服务端:状态机判定 + 注入(构建到 lib/)
└── client.js # 客户端占位(构建到 lib/)
scripts/
├── build.mjs # 构建:src → lib
└── self-test.mjs # 状态机单测(9 用例)
开发
npm run build # src → lib
npm test # 状态机自测
故障排查
| 现象 | 原因 | 处理 |
|---|---|---|
| 插件不动作 | targetSessionId 未配置 |
检查 cordis.patch.yml 配置项 |
| 注入后 agent 不接续 | 会话处于 running 而非 idle |
插件只在 idle 时注入,等其空闲 |
| 重启后无「继续」 | 超过 bootGraceMs 窗口 |
增大窗口或确认在启动后 2 分钟内判定 |
| HMR 装卸后误触发 | —— | 已防:判定仅在新进程启动宽限内进行 |
卸载
dsh plugin --profile web remove dsh-autoresume
License
Apache-2.0
Links
More in this category
Q00/ouroboros#integrations/dsh-plugin★ 5530
Config-only bundle that mounts Ouroboros through the DSH MCP client, exposing 36 interview, Seed, execution, evaluation, and evolution workflow tools in DSH.
NanmiCoder/dsh-agent-teams★ 529
AgentTeams multi-agent teams.
EthanYoQ/AI-Novel-Writer#dsh-ai-novel-writer★ 385
Installs a dedicated AI novel-writing preset and workbench: revisioned local project assets, a compact side drawer, and native approval-gated single-file changes.
orziz/odai#odai-dsh-plugin★ 87
Profile-wide DSH governance and routing bundle with configurable compaction calls and scoped local semantic memory; compatible with DSH 0.1.0-rc.6 and 0.1.0-rc.7.
icetomoyo/dsh_workflow★ 80
UltraCode-style multi-agent orchestration: a generatable, savable, governable, observable, resumable workflow layer.
titanwings/dsh-automation★ 53
Scheduled coding runs in fresh agent sessions with auditable history.