Attaches a wake rule to any session: the host polls whether its latest turn ended cleanly (LLM error, max-tokens truncation, unclosed turn, prolonged silence) and genuinely wakes it through sessionController.prompt, with a Beijing-time window, an idle-delay gate and three guards (cooldown, hourly/daily quota, no-progress circuit breaker). Includes five agent tools and a settings page. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.
Install
# from npm (prebuilt)
dsh plugin --profile web add dsh-auto-wake
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:lzlrt/dsh-auto-wake
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 — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
This plugin publishes its README in Chinese only.
给任意会话(包括你自己)挂一条唤醒规则:宿主定期检查它「最新一轮是不是结束得不像结束」,
命中条件就通过 sessionController.prompt() 真正把它叫醒,让它接着干。
为什么需要
DSH 自带的 dsh-schedule 只能给自己定时提醒,不能跨会话、不能按条件、没有熔断。
而会话「结束得不像结束」是常态:error、max-tokens、或者跑到一半静默了。
本插件补的就是这一块。
五个工具
| 工具 | 作用 |
|---|---|
autowake_create |
建规则:目标会话 + 触发条件 + 唤醒文本 + 额度 |
autowake_list |
列出当前规则 |
autowake_update |
改已有规则(只传要改的字段;熔断后传 resume: true 可恢复) |
autowake_delete |
删规则 |
autowake_run |
立即检查一轮(dryRun 只判定不投递,排障用) |
触发条件
trigger |
含义 |
|---|---|
unfinished(默认) |
最新一轮以 error / max-tokens 结束,或有未闭合的 turn |
keyword |
该会话最近文本含 keywords 之一 |
always |
只要不忙就唤醒(慎用,靠额度兜住) |
aborted(用户主动取消)和interrupted不算未完成 —— 你打断它,它就不该自己爬起来。
护栏
- 冷却:同一规则两次唤醒至少间隔
cooldown_seconds(默认 30s) - 额度:
max_per_hour(默认 6)/max_per_day(默认 30),滚动窗口 - 熔断:连续
max_stalls(默认 3)次唤醒后目标会话没有产生新事件 → 停止唤醒 熔断只在真正出现新事件时复位;唤醒成功本身不解熔断(否则空转会话会被永远唤醒)
两个时间控制(最常用)
1. 北京时间段
{ "windowStart": "09:00", "windowEnd": "22:00" }
只在北京时间(UTC+8,固定偏移,不含夏令时)的这个区间内科唤醒。
windowEnd 早于 windowStart 表示跨天:"22:00"–"06:00" 就是夜里那段。
- 段外连检查都不做 —— 下次检查直接睡到段开始那一刻,不空转读日志
- 段内/段外的判定在规则卡片上直接显示(绿色「在段内」/ 黄色「窗外,不唤醒」)
- 不填就是全天可用
⚠️ 时区用固定
+480分钟换算,不读容器的 TZ —— 容器里 TZ 通常是 UTC, 用new Date().getHours()会把 09:00 变成 17:00。
2. 静置多久后唤醒
{ "minIdleSeconds": 1800 }
目标会话最后一条动静距今超过 30 分钟才唤醒。这比「每 N 分钟轮询一次」 更贴近人想要的意思:它按会话真实的空闲时长算,不会被轮询间隔带偏 (设 30 分钟不会变成 31 或 29)。不填或 0 = 不限制。
两个可以叠用:09:00–22:00 且 静置 ≥ 30 分钟 才唤醒。
设置页(Web UI)
装好并重启后,设置 → 会话自动唤醒 会出现一个独立页面:
- 规则列表:每条规则显示状态(运行中 / 已熔断)、目标会话、唤醒文本、触发条件、
本小时与今日额度用量、失败次数、连续无进展计数、上次检查 / 上次唤醒 / 下次检查时间,
以及最近一次判定结果(
fired:error、skipped:hour_quota、tripped:no_progress_x3等)。 - 新建规则:从下拉里挑会话(自动列出全部会话与标题,已归档的会话不列出,也可手动填
session-…id), 选触发条件、填唤醒文本、设间隔与护栏。关键词模式下填逗号/空格分隔的词表。 - 试跑:只判定不投递,告诉你「现在会不会唤醒、为什么」。
- 立即唤醒:真发一次,会弹确认 —— 对方会话会立刻开始干活,代价不可逆。
- 删除:删除后不再唤醒该会话。
页面每 15 秒自动刷新一次(额度与冷却状态是随宿主 tick 变的)。
实现要点
设置页走 /dsh-auto-wake/* 这组 REST 端点,和四个模型工具共用同一套业务函数
(validateCreateArgs / normalizeRule / handleRule / ruleView),
所以「网页上点按钮」和「模型调工具」的判定结论必然一致,不会出现两套阈值。
| 端点 | 方法 | 作用 |
|---|---|---|
/dsh-auto-wake/list |
GET | 规则列表 + 额度/冷却/熔断状态 |
/dsh-auto-wake/sessions |
GET | 可选的会话清单(带标题) |
/dsh-auto-wake/create |
POST | 新建规则(参数与 autowake_create 一致) |
/dsh-auto-wake/delete |
POST | 删除规则 |
/dsh-auto-wake/run |
POST | 立即跑一轮,dryRun: true 只判定 |
编辑已有规则
设置页每条规则卡片上都有「编辑」按钮,点开表单会回填当前值,改完点「保存修改」。
也可以在工具层直接改,只传要动的字段:
{ "id": "aw-xxxx", "everySeconds": 120, "windowEnd": "23:00" }
编辑语义(这几条都是刻意的):
- 只改你传的字段,没传的原样保留;运行时状态(额度余额、熔断计数、关键词游标、进度游标)一律不动
sessionId可以换目标会话;换了会重新校验会话是否存在trigger从keyword切走时,关键词会清空 —— 免得以后切回来时旧词意外复活- 传
windowStart: ""/windowEnd: ""取消时段限制(不传 = 保持原样) - 规则被熔断或暂停后,卡片上出现「恢复运行」按钮(等价于
resume: true)—— 这是解熔断的唯一入口,比先删再建强 - 改了间隔会立刻按新间隔收紧下次检查,不用等旧节拍走完
配合 dsh-cross-session 使用
两个插件可以共存于同一个会话,因为它们都通过宿主的 sessionController.prompt() 投递。
能力边界(说清楚才不会被误解):
- 本插件负责定时/按条件唤醒指定会话
dsh-cross-session为会话提供跨会话发送/回复能力- 被本插件唤醒的会话,若它所在 preset 加载了
dsh-cross-session,就可以主动调用session_send去唤醒或通知其他会话
这是该会话自己的行为,不是本插件的自动联动 —— 本插件不做任何转发,唤醒正文里 也不带任何来源会话信息。所以:
- ❌ 不能指望「被唤醒的会话处理完回给 auto-wake」——它不是会话,收不到回信
- ❌ 不能指望「唤醒后自动通知别的会话」——那需要在
wakeText里明确要求它这么做 - ✅ 可以这样写唤醒文本:「查完把结果用 session_send 告诉 cs_xxxxxxxxxx」
⚠️ 组合使用时注意额度:本插件自带限流(冷却、小时/天额度、熔断), 但
session_send没有任何限流 —— 每一次发送都是真实prompt()、真实消耗。 两个会话互相发送时会形成不经过本插件配额的环,只能靠唤醒文本里写明「不要回信」来规避。
安装
从 npm 装:
dsh plugin --profile web add dsh-auto-wake
或者本地目录装:
dsh plugin --profile web add /path/to/dsh-auto-wake
装完重启 web 进程,然后在「设置 → 会话自动唤醒」里管理规则。
状态文件:~/.dsh/auto-wake/state.json(原子写,重启自动恢复)
版本记录
本轮开发经过 4 轮团队审阅,共修 3 个 blocker + 5 个 high。这些不是风格问题,都是会让插件"看起来在工作其实没有"的真缺陷:
| 轮次 | 问题 | 现象 |
|---|---|---|
| 审计 | sessionQuery.read() 不存在 |
冷读恒失败,规则 100% 不触发 |
| 审计 | 读 message.finish(字段不存在) |
error/max-tokens 判定恒 false |
| 审阅1 | no_reader 里清 stallCount |
第二个熔断复位点,导致永不熔断、空转到额度耗尽 |
| 审阅1 | 投递窗口内额度不落账 | 并发路径再穿护栏,同一会话 30s 内收两条 |
| 审阅1 | persist 失败仍回 ok | 模型以为建成,重启后规则消失 |
| 审阅2 | dryRun 被 in_flight 误挡 |
排障工具在故障时刻说谎 |
| 审阅2 | 熔断判定在投递前 | 用户设 N 实际只发 N-1 次,最后一次永不到来 |
已知限制
- 宿主必须运行才能唤醒;宿主下线期间的唤醒不补发
- 投递依赖
sessionController.prompt(),失败只 warn + 计数,不重试 - 冷会话唤醒会触发一次真实 resume,有成本;别对大量冷会话同时建规则
- 进程若在投递途中被杀,那次唤醒按「已消耗额度」计 —— 宁可少唤醒,不重复唤醒
cooldownSeconds下限 30 秒,everySeconds上限 86400 秒
Links
More in this category
loopx-project/loopx#dsh-loopx-plugin★ 6694
LoopX, a provider-neutral, local-first state kernel and control plane for long-horizon agents: keeps Goal, Todo, gate, evidence, quota, recovery, and handoff state above DeepSeek Harness, while the plugin bootstraps the CLI and skills, admits bounded same-session continuation, and adds a loopback GoalBar for the exact bound loop.
Q00/ouroboros#integrations/dsh-plugin★ 6373
Config-only bundle that mounts Ouroboros through the DSH MCP client, exposing 36 interview, Seed, execution, evaluation, and evolution workflow tools in DSH.
chuspeeism/dashi-taskboard#deepseek-harness★ 3495
Embeds the active installed Codex Taskboard runtime in the DeepSeek Harness sidebar, using its launcher runtime descriptor instead of a fixed port.
NanmiCoder/dsh-agent-teams★ 2978
AgentTeams multi-agent teams.
EthanYoQ/AI-Novel-Writer#dsh-ai-novel-writer★ 2670
Installs a dedicated AI novel-writing preset and workbench: revisioned local project assets, a compact side drawer, and native approval-gated single-file changes.
shanliuling/dsh-image-gen★ 1576
Native conversational image generation for DeepSeek Harness: ask the agent to create an image, and it handles generation and keeps the result directly in the conversation.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.