Mappedinfo/dsh-cron-scheduler0

@mappedinfo/dsh-cron-scheduler

DSH 定时任务插件:规则存为 Cron 表达式,由系统 cron(用户 crontab)在进程外执行 headless 任务,Web 端负责规则管理、部署与结果归类。

包名
@mappedinfo/dsh-cron-scheduler
版本
0.1.0
许可证
MIT
最近更新
2026年8月18日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Mappedinfo/dsh-cron-scheduler

安装(一条命令,零配置)

方式 A:npm 发布版(发布后)

dsh plugin --profile web add @mappedinfo/dsh-cron-scheduler

方式 B:Git 仓库直装(无需发布)

dsh plugin --profile web add github:Mappedinfo/dsh-cron-scheduler

方式 C:本地源码 + 一键脚本

git clone https://github.com/Mappedinfo/dsh-cron-scheduler.git
cd dsh-cron-scheduler && ./scripts/install.sh        # 构建 + 安装 + 提示,默认 web profile

装完重启 DSH Web 并硬刷新浏览器即可,无需任何手工配置:设置 → 定时任务 出现管理页,侧边栏工作区树自动出现每次运行的会话。

dsh plugin add 会自动把插件的 bundle 层(cordis.patch.yml)和客户端模块(dsh.clientlib/client.js)注册进 profile,这是 DSH 的官方插件安装通道。

使用

  • 设置 → 定时任务:新建(名称 / Cron 表达式或预设 / 任务说明 / 工作区 / 权限)、编辑、暂停/恢复、立即运行、删除;下方为运行历史(排队中/运行中/成功/失败/跳过 + 结果会话)。
  • 对话里:告诉 agent「每天 9 点运行 」,agent 会用 automation_create 创建(同样支持 automation_list / automation_runs / automation_update / automation_run_now / automation_delete)。

Cron 语法

5 字段:分 时 日 月 周。支持:

  • * 任意;a-b 范围;*/na-b/n 步长;a,b,c 列表
  • 月份/星期名称:JAN-DECMON-SUN(不区分大小写;星期 0/7 = 周日)
  • 快捷:@reboot@daily@hourly@weekly@monthly@yearly

示例:0 9 * * 1-5(工作日 9:00)、*/15 * * * *(每 15 分钟)、0 9 1 * *(每月 1 日 9:00)。

时区以系统时区解释(cron 行为);不支持秒级精度。

配置(一般不需要动)

配置默认说明
profileheadlesswrapper 使用的 headless profile 名
pollSeconds10会话监听器轮询间隔
historyLimit100每规则保留的运行记录数
dshCommand自动解析显式覆盖 wrapper 用的 dsh 命令(极少需要)

dsh 命令自动解析(零配置)

wrapper 在 cron 环境下执行、PATH 极简,所以插件在生成 wrapper 时会在 dsh web 进程内按链自动解析 dsh:

  1. config.dshCommand(显式覆盖)
  2. $DSH_BIN 环境变量
  3. command -v dsh(PATH 全局安装)
  4. 从当前进程推导 + 自动生成 shim:读取 process.argv[1]lib/bin.js 或 dev 模式的 src/bin.ts),在 ~/.dsh/cron-scheduler/bin/dsh 生成 exec "$@" shim——覆盖 pnpm dsh web、源码 checkout、npm 全局安装等常见方式
  5. 兜底 dsh + 设置页告警

设置页顶部会显示解析到的命令与来源(config / DSH_BIN / PATH / 自动 shim / 兜底)。@reboot 任务在下次登录时执行。

dsh 命令自动解析(零配置)

wrapper 在 cron 环境下执行、PATH 极简,所以插件在生成 wrapper 时会在 dsh web 进程内按链自动解析 dsh:

  1. config.dshCommand(显式覆盖)
  2. $DSH_BIN 环境变量
  3. command -v dsh(PATH 全局安装)
  4. 从当前进程推导 + 自动生成 shim:读取 process.argv[1]lib/bin.js 或 dev 模式的 src/bin.ts),在 ~/.dsh/cron-scheduler/bin/dsh 生成 exec "$@" shim——覆盖 pnpm dsh web、源码 checkout、npm 全局安装等常见方式
  5. 兜底 dsh + 设置页告警

设置页顶部会显示解析到的命令与来源(config / DSH_BIN / PATH / 自动 shim / 兜底)。@reboot 任务在下次登录时执行。