# peak-hours-stop **Repository Path**: alienity/peak-hours-stop ## Basic Information - **Project Name**: peak-hours-stop - **Description**: deepseek harness 插件,在峰值时刻把所有的任务都停掉,在非峰值的时候再恢复 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-08-19 - **Last Updated**: 2026-08-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # peak-hours-stop DSH(DeepSeek Harness)宿主级 Cordis 插件:在**北京时间高峰时段(09:00–12:00 和 14:00–18:00)冻结所有会话**,高峰结束后**自动恢复**继续处理。 冻结语义:高峰期间不产生任何模型调用、不执行任何工具,同时**所有待处理消息完整保留**(排队与 steering 消息留在 agent inbox,正在跑的轮次被中止但不丢队列),高峰结束积压工作按原顺序自动续跑。 零依赖、单文件、无需编译。时间判定显式按 UTC+8 换算,与宿主机器时区无关。 ## 工作原理 四个保障层,保证"无论如何都要停住,且消息不丢": | 层 | 拦截点 | 作用 | |---|---|---| | 1 | `agent/status` | 高峰期间任何 agent 翻转为 running 立即 `cancel(keepInbox)`——状态事件在 driver 认领消息**之前**同步触发,唤醒消息留在 inbox | | 2 | 精确边界定时器 | 09:00/14:00 整点冻结所有存活 agent(中止在飞轮次、保留队列);12:00/18:00 整点恢复积压工作 | | 3 | 5 秒轮询 | 兜底:休眠唤醒/边界竞态下反复冻结或恢复 | | 4 | `tools/pre-execute` | 高峰期间拒绝工具分发(纵深防御) | 恢复机制:对每个有积压工作的 idle agent 注入一条**空内容、插件来源**的唤醒消息(`steer`),`agent/pre-step` 监听器把该标记消息从批次中剥离(平台允许 enter 决策省略已认领消息),真实排队消息按顺序继续,唤醒轮次不消耗模型调用。 - 高峰窗口:`09:00 ≤ t < 12:00`、`14:00 ≤ t < 18:00`(北京时间,左闭右开)。 - 非高峰:全部放行,会话正常运行。 - 关键差异:**不是** `agent/pre-step` reject——reject 会消费已认领的消息(丢弃),冻结是在认领前中止并保留队列。 ## 安装方式(任选其一) ### 方式 A:npm 包安装(推荐给别人用) 仓库已按 npm 包结构组织(`package.json` + `exports` 指向 `peak-hours-stop.mjs`)。两种途径: **途径 A1:从 GitHub 直接安装(无需发布到 npm registry)** 在 DSH 的 profile 目录(如 `C:\Users\wx\.dsh\profiles\web`)执行: ```bash npm install /peak-hours-stop.git # 例如:npm install github:your-name/peak-hours-stop ``` **途径 A2:发布到 npm registry 后安装** ```bash npm publish # 使用者在 profile 目录: npm install peak-hours-stop ``` 然后在你 DSH profile 的 `cordis.patch.yml` 里加一行(**注意是包名,不是相对路径**): ```yaml - insert: - id: peak-hours-stop name: 'peak-hours-stop' ``` 重启 `dsh web` 即生效。 ### 方式 B:直接复制文件(最简单,零依赖) 把 `peak-hours-stop.mjs` 复制到你的 DSH profile 目录(如 `C:\Users\wx\.dsh\profiles\web\`),然后在 `cordis.patch.yml` 里加: ```yaml - insert: - id: peak-hours-stop name: './peak-hours-stop.mjs' ``` 重启 `dsh web` 即生效。 > 注意:方式 B 的挂载行是相对路径,插件文件必须放在 profile 目录里;方式 A 用包名,插件由 node_modules 解析,位置无关。 ## 自定义高峰时段 编辑 `peak-hours-stop.mjs` 顶部的 `PEAK` 数组(单位:当日分钟数): ```js const PEAK = [ [540, 720], // 09:00 - 12:00 [840, 1080], // 14:00 - 18:00 ] ``` 例:改成 8:30–11:30 和 13:00–17:00: ```js const PEAK = [ [510, 690], // 08:30 - 11:30 [780, 1020], // 13:00 - 17:00 ] ``` ## 验证是否生效 挂载后可通过运行中服务的插件清单接口确认: ``` POST http://127.0.0.1:3080/api/pluginInventory/list ``` 请求体:`{"type":"client-request","rpcId":"v","method":"pluginInventory/list","payload":{"args":{}}}` 响应中应出现 `"moduleName": "./peak-hours-stop.mjs"`(方式 B)或 `"moduleName": "peak-hours-stop"`(方式 A),且 `"fiberPhase": "active"`。 > 提示:运行中的进程会缓存已加载的模块。修改 `peak-hours-stop.mjs` 内容后,需要重启 `dsh web` 才会加载新版本。 ## 目录结构 ``` peak-hours-stop/ ├── peak-hours-stop.mjs # 插件本体(全部逻辑) ├── package.json # npm 包结构(方式 A 安装需要) ├── cordis.patch.yml # 挂载示例(方式 B) ├── README.md └── LICENSE ``` ## License MIT