rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:soffits/dsh-cron-jobs
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
Scheduled jobs for DeepSeek Harness (DSH): shell commands, agent prompts, or both.
DSH's built-in Schedule delivers a prompt to an agent session, so every tick starts a model turn. That is wasteful for jobs that are only a script, or for a check that usually finds nothing. This plugin runs jobs inside the DSH Host process, so they start and stop with DSH:
A job's result can be delivered: the woken agent's final answer, or a command's output and failures, is handed to another plugin that sends it on, such as a chat bot. This plugin knows no channel itself; any plugin that provides a small send method can be one (see Result delivery).
Jobs run on cron expressions, RFC 5545 RRULE schedules, or once at a given time, and they can also run on events instead of polling: any script, hook or CLI can emit one with dsh-cron-event <channel>, and the plugin can keep long-running watchers (a mailbox push stream, a notification feed) whose output lines are events (see Events). Jobs come from the plugin config, or an agent creates them from a conversation with the plugin's tools ("remind me here tomorrow at 9", "check this every Monday until January"). A Cron tasks page in the Web GUI shows every job and its recent runs, and lets you run a job now, pause it, or delete one an agent created.
Install it into the web profile from npm:
dsh plugin --profile web add @soffits/dsh-cron-jobs
Then restart dsh web (or enable it on the Plugins page). To work on it locally instead, clone the repository, install its dependencies, and install the directory as a bundle:
git clone https://github.com/soffits/dsh-cron-jobs.git
cd dsh-cron-jobs
npm install
Then ask the agent to install it, or call the plugin manager yourself:
plugin_manager install_bundle /absolute/path/to/dsh-cron-jobs
The bundle adds two rows: cron-jobs, the scheduler, and cron-jobs-tools, which gives every agent the tools described in Jobs created from a conversation. To give the tools to one agent preset only, disable the cron-jobs-tools row and mount @soffits/dsh-cron-jobs/tools in that preset instead.
Built and tested against DSH 0.2.2-rc.1 (engines.dsh is >=0.2.2-rc.1 <0.3.0-0). Commands run with bash -c, or sh -c when bash is missing, so the Host needs a POSIX shell. The plugin needs DSH's storage domain service (@deepseek-ai/dsh-storage-domain, part of every standard DSH composition) for run history and pause state.
Config jobs live in the config of the cron-jobs row. Add an override to your profile's cordis.patch.yml (or edit the row on the plugin's settings page). An override replaces the whole config, so list every job in it.
- id: cron-jobs
config:
# Optional: send every job's result here unless the job says otherwise.
deliver:
via: telegramTopics
to: notify
jobs:
# Plain job: runs the command, logs the result, nothing else.
- name: Nightly backup
cron: '30 2 * * *'
timeZone: Europe/Berlin
command: ./backup.sh >> backup.log 2>&1
cwd: /srv/backups
timeoutSeconds: 1800
# Gated job: wakes an agent only when the command prints something.
# Its agent's final answer goes to the row's deliver target.
- name: New issues
cron: '*/15 * * * *'
command: ./scripts/new-issues.sh
cwd: /home/me/project
agent:
prompt: Triage the new issues listed below and label them.
preset: standard
cwd: /home/me/project
# Optional: keep feeding one session for 6 hours instead of opening a new one each time.
reuseWithinHours: 6
# Optional: the model of the woken session.
model:
provider: deepseek
model: deepseek-chat
reasoningEffort: high
# Agent job: no command, the prompt goes out at every run.
- name: Weekly review
deliver: false # the answer stays in the session
rrule: |
DTSTART;TZID=Europe/Berlin:20260907T090000
RRULE:FREQ=WEEKLY;BYDAY=MO;UNTIL=20270101T000000Z
agent:
prompt: Review last week's notes and plan this week.
# Optional: post into this existing session instead of opening a new one.
sessionId: session-0123
| Field | Meaning |
|---|---|
name |
Job name, used in logs and session titles. Must be unique. |
cron |
Cron expression: 5 fields, or 6 with seconds first. Parsed by croner, which handles daylight-saving changes like Vixie cron: a fixed time skipped by a spring forward runs at the first valid time after the gap, a fixed time repeated by a fall back runs once, and patterns with several hours, minutes or seconds run on both repeated occurrences. Set exactly one of cron, rrule and at, or none when the job has on. |
on |
Event channel patterns that start a run, such as [mail.inbox, alerts.*]. See Events. |
coalesceSeconds |
How long this job's events gather before it runs once. 0 runs at once. The row's events.coalesceSeconds when unset. |
maxRunsPerHour |
Most event-started runs of this job in any hour. 0 means no cap. The row's events.maxRunsPerHour when unset. |
rrule |
RFC 5545 schedule: a DTSTART line and an RRULE line. The time zone comes from DTSTART (TZID=..., or Z for UTC). See Schedules. |
at |
Run once at this time: ISO 8601 with an offset, or a local date-time read in timeZone. |
timeZone |
IANA time zone for the cron expression or an at without offset. The Host's zone when empty. |
command |
Shell command line. Leave it out for an agent job. |
cwd |
Working directory of the command. The Host process directory when empty. |
timeoutSeconds |
Stop the command (and everything it started) after this long. Default 3600; 0 means no limit. |
enabled |
false keeps the job in the config without scheduling it. Default true. |
deliver |
Where the job's result is sent: { via: <service name>, to: <address> } (or { via: command, to: <command line> }, see The command channel), or false for nothing. Unset: the row's deliver, except for jobs with agent.sessionId, which send nothing. See Result delivery. |
agent.prompt |
With a command, makes the job a gated job; without one, an agent job. The prompt sent to the session. |
agent.sessionId |
Send the prompt into this existing session instead of opening a new one. Such a session is never auto-archived. |
agent.preset |
Agent preset of the new session. The Host default when empty. |
agent.cwd |
Working directory of the woken session; it joins the workspace registered at that path. When empty: the row's defaultAgentCwd, then the job's cwd, then the Host default. |
agent.autoArchive |
Archive the woken session once its turn ends (see below). The row's autoArchive when unset. |
agent.reuseWithinHours |
Send the prompt into the job's previous woken session when that session was opened less than this many hours ago (see below). 0 always opens a new session. The row's reuseWithinHours when unset. |
agent.model.provider, agent.model.model |
Model of the new session, with the same provider and model ids the model picker uses. Both must be set; otherwise the preset's or the Host's default model applies. |
agent.model.reasoningEffort |
Reasoning effort id for that model. The model's default when empty. |
Next to jobs, the row also takes:
| Field | Meaning |
|---|---|
defaultAgentCwd |
Working directory of woken sessions for jobs without agent.cwd. |
autoArchive |
Default for agent.autoArchive. Default true. |
reuseWithinHours |
Default for agent.reuseWithinHours. Default 0. |
deliver |
Default delivery target, { via, to }, for jobs that do not set deliver. Unset: results are not delivered. |
problems.channel |
Also emit every problem note as an event on this channel, so an agent job with on: [<channel>] can handle it. See Problem notes. |
problems.deliver |
Where problem notes are sent instead of the job's own target: { via, to }, or false for none once a job took the event. Unset: the job's target, as before. |
historyRecords |
Runs kept per job for the Cron tasks page. Default 50, at most 1000. |
endedRetentionHours |
Hours an ended job made with the tools stays listed before it is removed, with its run history. Default 24; 0 keeps ended jobs until they are deleted by hand; fractions work (0.5). See Schedules. |
runLog |
Optional JSON Lines file of run starts and ends, see below. |
watchers |
Long-running commands whose output lines are events: [{ id, channel, command, cwd, enabled }]. See Watchers. |
events.coalesceSeconds |
Events for one job that arrive within this many seconds of the first start one run. Default 30; a job's own coalesceSeconds replaces it. |
events.maxRunsPerHour |
Most event-started runs of one job in any hour; past that, events wait and run together. Default 6; 0 means no cap. A job's own maxRunsPerHour replaces it. |
skipped run-log line, with reason: session-working and the session when the turn is the cause), the way Kubernetes' concurrencyPolicy: Forbid and Temporal's Skip overlap policy drop a tick; the next tick covers it. Events do not get dropped: see below. Run now is a person's explicit ask and always starts.cron-jobs. Sending the result anywhere else is what Result delivery is for.runLog (next to jobs) to a file path to also keep that record as JSON Lines: one start line per run, one end line with status, outcome, exitCode, durationMs, the output tails and the delivery state, a delivery line when a result waits for its channel (waiting), is left for the next start (pending), or has been delivered or not (sent, silent, failed), a skipped line for a skipped tick, an overdue line (with dueAt and lateMs) when a tick did not start on time and the watchdog ran it late, and scheduler-start / scheduler-stop lines (with job: null) when the scheduler starts or stops, so a gap in the log can be told apart from a lost tick. Events add an event line per event (channel, source, the matched job ids, or duplicate), and watchers watcher-start, watcher-exit (exit code, run time, stderr tail), watcher-down and watcher-up lines. An event run's start line has trigger: event and the events' count and channels. A start with no end means DSH stopped during the run. A removed line (jobId, endedAt) marks an ended job taken away by endedRetentionHours. The file is only appended to; rotate it yourself if it grows.When agent.model is set, the model is checked with the Host's LLM service before the session is created, then selected on the new session the same way the model picker does. Unlike the picker, it does not become the Host's default model. A model the Host cannot route fails the wake (shown as "Could not wake the agent" with the reason in the run's output) instead of silently falling back to another model.
DSH's session search only finds sessions whose working directory is exactly the caller's. Woken sessions in a separate jobs directory are therefore invisible from your main workspace and the other way round. Pointing defaultAgentCwd (or agent.cwd) at the main workspace keeps them all searchable together, and auto-archive keeps the sidebar tidy.
With auto-archive on, the plugin waits until the woken session's agent is idle (its turn and anything queued behind it have finished, successfully or not), then archives the session with DSH's Workspace registry, the same service behind the sidebar's Archive action. An archived session leaves the sidebar's active list but stays in DSH: it can be opened, unarchived, and is still returned by DSH's session search tools, which filter only by working directory.
prompt_session, open_session) the same source kind user, so the plugin reads the caller behind it, source.principal: kinds dsh-session, cron-job and external are agents and never keep a session; the owner in the Web UI (no principal) and a channel's signed-in sender do. A session another agent only followed up is archived after the turn that follows up causes. Such a held session is never reused either.With reuseWithinHours above 0, a gated job sends its prompt into the session it opened earlier instead of opening a new one, as long as that session was first opened less than reuseWithinHours ago. The window counts from the first wake, not from the latest reuse, so a frequent job still starts a fresh session every reuseWithinHours. Delivery takes the same path as DSH's Schedule for an existing-session target: the session is resumed if needed and the prompt is queued as a new user turn. If the session is busy, the prompt waits for its next turn instead of a second session being opened.
Only sessions the plugin opened for that job are candidates. If the previous session no longer exists, cannot be resumed, is pinned or was taken over by a person, a new session is opened and the run notes why. DSH does not run model steps in an archived session, so with auto-archive on, an archived session is unarchived just before the prompt and archived again after its turn; with auto-archive off, an archived session is not reused. Runs that reused a session say so in the run history.
A job with a delivery target sends its result when a run is over:
[SILENT], sends nothing, so a check that found nothing stays quiet. The prompt tells the agent this in one line, so job prompts don't have to.⚠️ <job> failed (exit <code>) (or timed out after <n>s, ...) followed by the last 15 lines of stderr.⚠️ <job>: could not wake the agent: <reason>. A gate that decides not to wake sends nothing.MEDIA:<path> in the result are taken out of the text and sent as files. Relative paths are read from the job's directory (the session directory for agent answers), and ~ is the home directory.Where results go is decided per job: its own deliver (or false), otherwise nothing for jobs that post into an existing session (agent.sessionId, or the tools' this_session / sessionId), since the answer is already in that conversation, otherwise the row's deliver. A run stopped because DSH is shutting down delivers nothing.
Each run's delivery shows on the Cron tasks page and in the run log: not sent yet (waiting for the answer or for the channel), sent, nothing to send, or not sent with the reason. A delivery still waiting when DSH stops or the plugin reloads, whether for a turn that is still running or for a channel that is not there, is picked up and delivered after the next start.
Failure notes (a command or gate that failed, a wake or rerun that failed, a watcher that is down or works again) go to the same place as the job's results unless the row says otherwise. That is the right default when whoever reads results also fixes the jobs. When the results go to someone who should not get raw failures, such as a person reading an agent's reports, the row's problems setting sends them elsewhere:
- id: cron-jobs
config:
deliver: { via: telegramTopics, to: notify }
problems:
channel: cron.problem # hand each note to the jobs on this channel
deliver: false # and don't also send it to the job's target
jobs:
- name: Fix broken jobs
on: [cron.problem]
agent:
prompt: A scheduled job or watcher failed; the note is below. Find the cause and fix it. Tell the owner only what needs them.
channel: each note becomes an event with the note as its text and details as data: kind (command-failed, gate-failed, wake-failed, rerun-failed, watcher-down, watcher-up), job and jobId (or watcher and its channel), trigger, startedAt, error, exitCode, sessionId when known, and text. Events batch and are capped like any others. A run that this channel started never emits a note on it, so a failing handler can't feed itself.deliver: a target sends every note there instead (a log topic, an ops chat), with or without channel. false sends nothing, but only when a job listening on channel took the event; a note no job took (no channel, nobody listening, or the handler's own failure) still goes to the job's target, so a broken job never goes quiet.Ordinary results are not affected. Both are off by default.
A woken turn that a DSH restart cuts off before it finishes is run again once. A turn a person stopped, or one that failed, is not. Finding the cut turns is left to dsh-restart-resume (0.4.0 or later), which reads every cut turn from DSH's log after a restart and hands the ones a job started back to this plugin; without it, a cut-off run is recorded but not run again. The cut-off turn delivers nothing; when it is handed back, the plugin sends a short follow-up into the same session saying the earlier turn was cut off and asking the agent to finish the job without repeating what is done. The session already holds the job's prompt, command output and events, and whatever the cut-off turn did. The rerun's answer is delivered like any other.
The rerun is skipped, with the reason in the run history and a rerun-skipped run-log line, when the cut-off run started more than 2 hours ago, a later run of the job has woken the agent since, the job's next run is less than 15 minutes away, or the job is paused, disabled or deleted. A session the job opened for itself that a person has since taken over is left alone: the rerun fails with a note to the delivery target. A rerun that is cut off too is not run again. The run log marks the cut-off with a cut-off line, and the rerun's start line carries rerunOf.
Every prompt a job puts into a session has the source kind schedule, which the Web GUI shows as a scheduled run, and names the job as principal, the field DSH uses for the caller behind a user message:
{ kind: 'cron-job', channel: 'cron', id, name, trigger, events }
id is the job's id (its name for a config job), name its name, trigger what started the run (schedule, manual, event, or rerun), and events the channels of the events that started an event run. Scripts that read session logs can tell job prompts apart, and which job sent each, without parsing the text.
A delivery target is { via, to }: via names a DSH service, to is an address that service understands (a chat topic, a mailbox, a webhook name; it can be empty). When a result is ready, the plugin looks the service up by name with ctx.get(via) and calls:
await service.send({
to, // string: the target's address
text, // string: the message, may be empty when files are attached
files, // string[]: absolute file paths
from: {
job, // string: the job's name
jobId, // string: the job's id (its name for a config job)
sessionId, // string, agent and gated jobs only: the session that wrote the answer
},
})
The promise resolves when the message is sent and rejects with an Error when it is not. A rejected send is tried again twice (after 5 and 30 seconds). A service that is not running (for example while its plugin reloads or is stuck unloading) is not a failed try: the delivery waits for it, looking again every 10 seconds for up to an hour, and a restart in that time leaves it pending for the next start, which waits again. Set retryable: false on the error to stop the retries for a failure that will not go away, such as an unknown address. The return value is ignored. A send that still fails is recorded in the run's history and the run log; the job itself carries on.
To make a plugin a delivery channel, provide a service with that method:
export function apply(ctx) {
ctx.provide('myChannel', {
async send({ to, text, files, from }) {
// deliver it, or throw
},
})
}
and point a job at it with deliver: { via: myChannel, to: <address> }.
from.runId names the run the result belongs to (when the run history has one), the same for every retry and for a delivery resumed after a restart, so a channel can drop a result it already took.
One channel is built in: via: command runs to as a shell command and hands it the result, for a channel that is a CLI rather than a plugin (a notification router, a mailer, a script):
deliver:
via: command
to: my-notify --from-job
In the tools and in declared sets the same target is command:my-notify --from-job.
send gets: { to, text, files, from }.bash -c (or sh -c) in the directory the result came from: the woken session's for agent and gated jobs, the job's cwd for command jobs. DSH_CRON_JOB is the job's name, and DSH_SESSION_ID the session that wrote the answer (unset for command jobs), so a DSH tool the command calls credits that session.command is not looked up as a service, so a plugin providing a service of that name is never used for delivery.DTSTART line and one RRULE line, for example DTSTART;TZID=America/Toronto:20261109T100000 and RRULE:FREQ=DAILY;INTERVAL=3;UNTIL=20261215T150000Z (every three days at 10:00 Toronto time until mid-December). A TZID rule keeps local clock time across daylight-saving changes. RRULE:FREQ=DAILY;COUNT=1 runs once. A DTSTART in the past is fine; runs start with the first occurrence after the job is armed. Rules are evaluated by DSH's own bounded RRULE engine (@deepseek-ai/dsh-util-time, built on rrule), the same one the built-in Schedule uses, so a rule behaves the same in both, with the same limits (no SECONDLY, COUNT at most 1000, and so on).When an RRULE or one-time schedule has no more runs (or a once job has run), the job's state becomes ended. Config jobs stay listed until they are removed from the config. A job made with the tools is removed automatically endedRetentionHours (default 24) after it ended, together with its run history, the same as deleting it; set the option to 0 to keep ended jobs until you delete them. Only jobs in the ended state are removed: paused and active jobs stay, and so does a job whose last run is still going or still waiting to deliver its result. The time is checked once a minute, and again when the scheduler starts, so a job that expired while DSH was down goes right away. Jobs that ended under an older version, with no end time saved, start their retention when this version first sees them. Giving an ended job a new schedule brings it back. cron_job_list and cron_job_view show removesAt for an ended job, and each removal is logged at info level with the job's title and id. To keep a record of one-shot jobs after they are gone, set runLog: the file gets a removed line next to the job's start and end lines.
A job can run when something happens instead of checking on a timer. Give it on, a list of channel patterns, with or without a schedule:
- name: Mailbox
on: [mail.me]
command: ./mail-gate.sh
agent:
prompt: Handle the new mail.
Channels are dot-separated names of letters, digits, _, : and -, such as mail.me, ci.run.123 or dsh.started. In a pattern, * matches any characters, dots included, so alerts.* matches alerts.disk and alerts.komodo.down.
Emitting an event. The package installs a small CLI:
dsh-cron-event ci.run.123 --data '{"conclusion": "success"}'
gh run watch 123 --exit-status; dsh-cron-event ci.run.123 --data "{\"exit\": $?}"
echo '{"subject": "hi"}' | dsh-cron-event mail.me --data -
It writes one file into the plugin's inbox, $DSH_HOME/cron-jobs/events/ (mode 700), and waits up to ten seconds for DSH to take it, printing the ids of the jobs it matched. No port, token or network path into DSH is needed, and an event written while DSH is down waits there and is taken at the next start. --id <key> drops a second event with the same channel and key within an hour; --no-wait returns at once; --text sends plain text instead of JSON. Exit code 3 means DSH did not take it in time (it stays queued). The CLI is in the profile's node_modules/.bin; link it somewhere on PATH to call it by name.
What a run sees. Events for one job that arrive within its window, counted from the first one, are gathered, and the job runs once with all of them. The window is the job's own coalesceSeconds (set it to 900 for a mailbox that is fine to read every quarter of an hour, or 0 to run at once), or events.coalesceSeconds (30 s) for a job without one:
{"trigger": "event", "events": [{"channel", "at", "data" or "text", "key", "source"}], "dropped": 0}, and every command gets DSH_CRON_TRIGGER (schedule, manual or event) and DSH_CRON_JOB in its environment. A gate still decides whether to wake the agent.If the job is still working when its batch is ready (a run is going, or the agent it woke has not finished its turn), the events wait and the job runs once more as soon as it stops, with every event gathered meanwhile (Temporal's BufferOne). A gate runs then, not before, so a mailbox the first session already read does not wake a second one, and mail that arrived meanwhile is handled by one later session instead of two at once. A scheduled tick that finds the job working is skipped. At most events.maxRunsPerHour (6) event runs of one job start in any hour (a job's own maxRunsPerHour replaces that for it: a cheap command job that rebuilds a view on every change wants a higher number than an agent handler); past that, events wait and run together when the oldest of those runs is an hour old, so a stuck feed cannot start hundreds of runs. A paused, ended or disabled job ignores events. The run history and the Cron tasks page show event runs with their channels.
once (tools only) ends a job after its first run that was not started by hand. With on: [dsh.started] it waits for the next DSH start.
Built-in events. dsh.started is emitted once per DSH process, when the scheduler first starts (not on a plugin reload). A one-off "check DSH after the restart" job becomes on: [dsh.started], once: true, instead of a guessed time. dsh.turn.started and dsh.turn.ended are emitted when a turn starts or ends in any session (subagents and jobs' sessions included), with data.sessionId, and only while a job listens on them: a view of what is running follows the sessions instead of polling them. A job that opens sessions itself and listens to these events runs again for its own turns, so listen from a command job that opens none.
Delivery and safety. An inbox file is kept (as .processing) until every run it started has begun, so a restart in between reads it again. Events from watchers are not kept; each watcher catches up from its own cursor when it starts (below). A lost event is a bug in the source or its watcher to fix there; a timer added "just in case" would hide it and wake the job for nothing. Give a job a schedule only when the clock is part of the work (a daily rollover) or when its source cannot send events and has to be polled.
A watcher is a long-running command the plugin starts with the scheduler, restarts when it exits, and stops on unload. Each stdout line is an event on the watcher's channel:
id field, if any, is the dedupe key;{"wakeAgent": false} lines are ignored.A watcher that exits is restarted after 1 s, doubling up to 5 minutes, and back to 1 s once a run lasted a minute. If it has not managed to stay up for a minute in 15 minutes, one note goes to the row's deliver target (or as set by problems), and one more when it works again; exits, stderr tails and these notes are in the run log. The command runs with bash -c in its own process group, with DSH_CRON_WATCHER (its id), DSH_CRON_CHANNEL and DSH_CRON_STATE_DIR ($DSH_HOME/cron-jobs/watchers/<id>, a directory for its cursor) in its environment.
Watchers come from the row's watchers list, or from a conversation with the cron_job_watch tool (create, delete, list), which keeps them in DSH storage. A tool-made watcher can be once: it runs one time and removes itself when it exits, for a one-off wait that has to survive a DSH restart:
cron_job_watch create id=ci-123 channel=ci.123 once=true
command='gh run watch 123 --exit-status >/dev/null; echo "{\"exit\": $?}"'
cron_job_create title="Report CI 123" target=this_session on=["ci.123"] once=true prompt="CI run 123 finished; check it and tell me."
A good watcher keeps a cursor (a JMAP state string, an IMAP UIDNEXT, a feed's last message id) in DSH_CRON_STATE_DIR, prints one line at startup when something changed while it was down, and exits on any error or a connection that went silent, leaving the restart to the plugin. Some sources that fit:
eventSourceUrl with types=EmailDelivery and print a line per state push.onNewMail: echo new.curl -sN 'https://ntfy.sh/<topic>,<topic>/json?since=<last id>', printing the message events.The cron-jobs-tools row registers five tools. Their names start with cron_job by default; the row's prefix setting changes that (prefix: schedule gives schedule_create and so on, the names of DSH's built-in Schedule tools, for use in its place).
| Tool | What it does |
|---|---|
cron_job_create |
Create a job: a title, a prompt and/or a command, one of cron, rrule and at (with timeZone where needed) and/or on (event channels), where the prompt goes, and optionally once, coalesceSeconds (the event window), where the result is delivered and which model its sessions use. |
cron_job_edit |
update the given fields, pause, resume (continues from now), or delete a job by id. An empty cron, rrule or at removes the schedule of a job with on; an empty on removes its subscriptions. coalesceSeconds sets the event window; a negative number removes it, so the row's setting applies again. prompt_replace and command_replace change the text in place; see below. |
cron_job_list |
Every job, from the config and from tools, with its id, state, schedule, next run, target and last run. |
cron_job_view |
One job's full definition and its five latest runs. |
cron_job_watch |
create, delete or list watchers. |
A new job takes the calling session's working directory and agent preset, so a job created from a session in /home/me/project runs its command there and opens its sessions there. cwd sets another directory.
Where the prompt goes (target):
new (default): a new session for every run, with the row's auto-archive and session reuse settings, like a gated config job.new_once: one new session, opened by the first run; every later run posts into it.this_session: the session that created the job, for reminders and follow-ups to the conversation. sessionId names another existing session instead.deliver takes <service>:<address> (such as telegramTopics:notify) or none; the service must be running when the job is created. Left out, the job uses the row's default target, or delivers nothing when its prompt goes to an existing session. On cron_job_edit, an empty deliver goes back to the default.
prompt_replace and command_replace on cron_job_edit change a long prompt or command without resending it: a list of literal { "old": "...", "new": "...", "replace_all": false } replacements, applied in order, each to the result of the one before. Every old must match exactly once unless that item sets replace_all; otherwise the call fails naming the item (prompt_replace[1] (old "..."): no match or matches 3 times) and changes nothing. They cannot be combined with prompt or command.
model is an object, { "provider": "anthropic", "model": "claude-sonnet-4-5", "reasoningEffort": "high" }, with the same ids the model picker uses; provider and model are required together and reasoningEffort is optional. The sessions the job opens start on that model, like agent.model on a config job; left out, the preset's or host default applies. cron_job_edit with model sets it on an existing job, and an empty object ({}) clears it. cron_job_list and cron_job_view show the model when one is set. A job that posts into an existing session (this_session, sessionId) does not open a session, so its model has no effect.
The prompt arrives as a scheduled message from the user, with the job's title and id, so the agent can look the job up or delete it when it is done. A message for an existing session is queued behind a turn that is still running. It is delivered even if the session is pinned or a person is using it, since that is what the job was created for; an archived target session is unarchived first. Target sessions are never auto-archived.
Jobs created with the tools are kept in DSH storage (see below) and survive restarts. Each one remembers its next run, so a run missed while DSH was down happens once when it starts again (only once, however many were missed). If DSH stops in the middle of a run, that run happens again at startup. Jobs from the plugin config cannot be changed with the tools; cron_job_edit says so instead.
A delegated subagent can use the tools, but its own session cannot be a target, since it ends with its task.
Jobs made one by one from conversations are easy to start and hard to review as a whole. A declared set keeps a group of standing jobs in a file you own (a repository, a dotfiles folder, another tool's config) and applies the whole list at once, the way kubectl apply --prune does: keys that are new are created, jobs whose fields differ are changed, and members of the set that left the list are removed. Jobs made with the tools and members of other sets are never touched, so quick one-off reminders keep working next to it.
dsh-cron-apply --set home --file jobs.json --dry-run # what would change
dsh-cron-apply --set home --file jobs.json # apply it
The file is a JSON list of jobs (or { "jobs": [...] }); --file - reads stdin. Each job takes the fields of cron_job_create (title, prompt, command, cron + timeZone, rrule, at, on, once, coalesceSeconds, cwd, target as new or new_once, sessionId, deliver, model) plus:
key (required): the job's stable name in the set, such as nightly-backup. Renaming a key replaces the job.preset: agent preset of the sessions it opens (the tools take the caller's; here it is explicit).timeoutSeconds: the command's time limit.paused: true keeps it paused. A pause from the page or a tool lasts until the next apply.adopt: the id of an existing tool-made job to take over the first time, keeping its id, run history, next run and pause state. Use it to move existing jobs into a set without losing their history.deliver is <service>:<address>, none, or default (or left out) for the row's target; every service a set names must be running, or nothing is applied. Every entry is checked before anything changes, so a typo in one job leaves the whole set as it was.
Members are ordinary stored jobs: they catch up, keep history and show on the page and in cron_job_list, marked declared: <set>/<key>. The tools can still change them (a script that moves a job's time zone, a quick pause), and the next apply puts back whatever differs from the file; a --dry-run with no changes to the file shows such drift. The request travels through a file inbox under $DSH_HOME/cron-jobs/requests (no port or token). A request DSH does not take within --timeout (default 30 s) is withdrawn, and one older than ten minutes is refused, so an old list is never applied after a restart.
To stop keeping a set in a file, release it: dsh-cron-apply --set home --release (with --dry-run to list first). Every member becomes an ordinary stored job with the same id, run history, schedule and pause state, and no later apply sees it; nothing is deleted.
Exit codes: 0 done, 1 refused (nothing changed; the reason is on stderr), 2 bad arguments, 3 DSH did not answer in time.
The Web GUI gets a Cron tasks entry in the sidebar, laid out like DSH's own Automation tasks page:
⋯ menu starts one run immediately; it is refused while the job is already running, and it does not move the schedule. Delete in the same menu removes a job an agent created, with its run history. A job with a prompt has a footer link to its latest session.The page does not create or edit jobs: config jobs are edited in the config, the others through the tools.
All three are kept in DSH's storage domain service under the domain cron_jobs (with the default JSON backend, <DSH_HOME>/storages/cron_jobs.json), so they survive restarts. The jobs table holds run history and pause state, one record per job (config jobs by name, other jobs by id); the tasks table holds the jobs created with the tools. A stored job looks like this:
{
"id": "job-1a2b3c4d",
"title": "Check the parcel",
"prompt": "Has the parcel arrived? Tell me either way.",
"schedule": { "kind": "rrule", "rrule": "DTSTART;TZID=America/Toronto:20261109T100000\nRRULE:FREQ=DAILY;COUNT=1" },
"cwd": "/home/me",
"preset": "default",
"target": { "kind": "session", "sessionId": "session-0123" },
"deliver": { "via": "telegramTopics", "to": "notify" },
"model": { "provider": "anthropic", "model": "claude-sonnet-4-5" },
"status": "active",
"scheduledAt": "2026-11-09T15:00:00.000Z",
"createdAt": "2026-11-08T17:00:00.000Z",
"updatedAt": "2026-11-08T17:00:00.000Z",
"createdBy": "session-0123"
}
schedule is { "kind": "cron", "expression", "timeZone" }, { "kind": "rrule", "rrule" } or { "kind": "at", "at" } (a UTC instant); target is { "kind": "new" }, { "kind": "new_once", "sessionId"? } or { "kind": "session", "sessionId" }; status is active, paused or ended; command, timeoutSeconds, coalesceSeconds, model ({ "provider", "model", "reasoningEffort"? }) and deliver ({ "via", "to" } or false; the default when missing) are optional. scheduledAt is the next run.
For run history and pausing:
historyRecords runs of a job are kept, and each saved run keeps the last 1000 characters of stdout and of stderr. A run still marked running when DSH starts again is shown as interrupted.enabled: false in the config always wins: such a job is never scheduled, whatever its saved pause state, and pause and resume are unavailable for it. A pause saved earlier applies again once the job is enabled. Run now still works.If the storage domain cannot be opened, config jobs still run, the page says that history is kept in memory only, and jobs created with the tools are lost on restart.
The page calls the Host with POST requests to /api/dsh-cron-jobs/<endpoint> (list, runs, run, pause, delete), exact routes the plugin adds to DSH's shared /api channel. They are authenticated like the rest of the Web GUI, and DSH lets only the owner reach them, since Run now executes shell commands. The page's styles use only DSH theme tokens, and its layout and icons are copied from DSH's own pages (DSH is MIT-licensed), so it follows light and dark themes and the interface language (English and Chinese).
After the command finishes:
wakeAgent is exactly false, such as {"wakeAgent": false}, no agent is woken. This is the gate convention of Hermes Agent cron jobs, so existing gate scripts work unchanged. Any other value, a missing key, or a non-JSON last line wakes.<job name> · <YYYY-MM-DD HH:mm> in the job's time zone, and sent the prompt followed by the command's stdout in a labelled block. The message is marked as a scheduled message, so the Web GUI shows it like a scheduled run.A gate script that prints a summary when there is work, and nothing (or {"wakeAgent": false}) when there is not, is enough:
#!/usr/bin/env bash
count=$(gh issue list --label needs-triage --json number --jq length)
if [ "$count" -eq 0 ]; then
echo '{"wakeAgent": false}'
exit 0
fi
gh issue list --label needs-triage
Up to the last 64 KiB of stdout goes into the prompt; anything earlier is cut and the cut is noted.
npm install
npm test
npm run check
MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。