Durable background task templates for DSH: define a task as one to ten ordered steps, then run it by hand or from a native Schedule entry. Steps are executed by the calling agent in its own authorized context - there is no resident worker. Each execution becomes its own TaskRun with a frozen template snapshot, persisted per-step status and progress, a heartbeat and execution token, a failure record naming the failing step, and a queryable run history. Failed, interrupted and blocked runs are recovered by creating a new run that carries completed steps over and resumes at the first unfinished one; a step that may have produced side effects needs explicit confirmation before retry, and records that cannot be proven finished are never replayed automatically. Records live in a StorageDomain rather than memory, so they survive restart; a duplicated schedule delivery cannot start a second execution, and overlapping runs are bounded per task and per Session. Verified on DSH 0.2.2-rc.3 (desktop) with Node 22+; scheduling uses the host native Schedule and is unavailable when that service is not mounted, while manual runs keep working. Tasks are private to the Session that created them; the board UI is meant for a single local user and does not claim multi-user isolation, because the host does not authenticate plugin HTTP routes. Registers 14 task_* tools and reuses the host schedule, agent and tool permissions instead of replacing them. 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-background-task-engine
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:yzzshanyin-rgb/dsh-background-task-engine
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
English | 中文
Durable background task engine for DeepSeek Harness (DSH): reusable task templates, ordered linear steps, one persisted run ledger, progress and history queries, explicit failure/interruption recovery, and optional linkage to native DSH Schedule.
It does not reimplement a scheduler, an agent loop, a job registry or a storage
backend — it composes the Host's own ctx.schedule, ctx.storageDomain and
ctx.tools.
- Install
- Tools
- Execution protocol
- Data model
- Configuration
- Errors
- Security
- Upgrade
- Troubleshooting
- Development
Install
Supported range
| Item | Declared | Verified |
|---|---|---|
| DSH | engines.dsh: >=0.2.2-rc.3 |
0.2.2-rc.3 only (desktop) |
| Node | engines.node: >=22 |
24.13.0 |
| Storage | ctx.storageDomain must be mounted |
stock base bundle, storage-domain backend: json |
| Schedule | optional; manual runs work without it | same version |
| Platform | desktop app (the board uses the host ctx.webServer) |
macOS |
Newer hosts are untested: the plugin only uses public APIs, but untested versions are not
covered by the promise. After a host upgrade, run task_engine_status and follow the
re-verification steps in docs/TEST-REPORT.md.
# from npm (current: 1.2.3)
dsh plugin --profile <name> add dsh-background-task-engine
# or from a local checkout
dsh plugin --profile <name> add /absolute/path/to/dsh-background-task-engine
When installing from a directory path, run npm install in that directory first:
the plugin imports @deepseek-ai/schemastery, and a missing node_modules makes
the loader fail with ERR_MODULE_NOT_FOUND. The registry spec carries its own
dependencies and needs no checkout.
Then restart the app. Confirm in Plugins that the row
background-task-engine is enabled; the row shows this bundle's title,
description and icon.
The bundle patch is intentionally empty apart from the plugin row, so installing it does not change any other setting:
- insert:
- id: background-task-engine
name: 'dsh-background-task-engine'
config: { ... }
Tools
Twelve model-facing tools, all returning
{ success: true, ... } or { success: false, error: { code, message, retryable, relatedRunId? } }.
| Tool | Purpose | Key arguments |
|---|---|---|
task_create |
Create a template (1–10 steps) | title, description?, steps[], copyFromTaskId? |
task_list |
List this Session's templates | status?, query?, limit?, cursor? |
task_get |
Read one template + recent runs | taskId, includeRuns? |
task_update |
Edit title/description/steps/status | taskId, expectedRevision, changes |
task_archive |
Soft-archive; history preserved | taskId, expectedRevision |
task_schedule |
Manage the native schedule link | taskId, action, timing?, scheduleRule? |
task_run |
Start a manual run now | taskId, manualRunId?, defer? |
task_run_begin |
Claim a run (task or queued run or delivery payload) | taskId?, runId?, triggerPayload?, scheduleId?, occurrenceKey?, idempotencyKey? |
task_step_report |
Report a step | runId, stepId, action, summary?, error? |
task_run_finish |
Submit the run result | runId, status, summary?, error? |
task_run_history |
Page run history | taskId, status?, limit?, cursor? |
task_resume |
Recover a failed/interrupted/blocked run | runId, confirmation? |
task_schedule actions: create, update, pause, resume, delete,
run_now, status. Timing input accepts at, every, rrule, cron,
daily, weekly; daily/weekly are translated to an equivalent RRULE so
the plugin depends on fewer host shapes. The plugin stores only scheduleId
plus a small reference — never a copy of cron state.
Execution protocol
A run is executed by the calling Agent in its own authorized context. There
is no worker process, and a followup receipt is never treated as completion.
task_runortask_run_begin→runId+ snapshot + step list.- For each step in
order:task_step_report(action:"started"). task_step_report(action:"completed" | "failed" | "skipped")with a real summary.completedrequires the step'scompletionCriteriato be met.- Missing input, a pending approval, or an unmet external condition →
task_run_finish(status:"blocked", summary:"…")naming what is awaited. - All required steps completed →
task_run_finish(status:"succeeded"). - A failure →
task_step_report(action:"failed", error:{…})thentask_run_finish(status:"failed").
Progress is always floor(completed required steps / required steps × 100) and is
recomputed from persisted step rows — never from caller claims.
Scheduled runs
A task_schedule create stores a prompt carrying task_id_json on the host
schedule. When a delivery arrives:
task_run_begin({ triggerPayload: "<the delivered message>" })
The tool extracts task_id_json, schedule_id_json and occurrence_at, then
uses schedule:<scheduleId>:<occurrence> as the idempotency key. A duplicated
delivery returns the existing run with deduplicated: true instead of starting a
second execution. Delivery proves the message was enqueued — not that the run
finished.
Data model
StorageDomain unit dsh_background_task_engine, schema version 1
(the underscore form is required: the host's unit-name rule is
/^[a-z][a-z0-9_]*$/).
| Table | Key | Contents |
|---|---|---|
tasks |
taskId |
template, status, revision, owner Session, steps, schedule reference |
task_runs |
runId |
status, trigger, snapshot, progress, times, summary/error, resumesRunId |
task_run_steps |
runId/stepId |
per-run step status, attempt, times, summary/error |
meta |
global |
schemaVersion, applied-migration ledger, recovery/prune timestamps |
Status machines:
Task active → paused → active active/paused → archived (final)
TaskRun queued → running → succeeded | failed | blocked | interrupted
queued → skipped
blocked → failed | interrupted (never back to running)
failed, succeeded, interrupted and skipped are terminal. Recovery always
creates a new run with resumesRunId; completed steps are carried over, the
run continues at the first unfinished step, and a run whose failed step may have
had side effects requires an explicit confirmation.
Retention: terminal runs older than historyRetentionDays (default 90) are
pruned with their step rows at startup. Active runs, templates and audit events
are never pruned.
Configuration
All eight numbers are edited from the card at Settings → Plugins → dsh-background-task-engine;
saving applies immediately, with no restart. The same keys can be written to the profile's
cordis.patch.yml — both paths edit one configuration.
Exported as Config (Schemastery) and validated again at load; out-of-range
values fail the load rather than being clamped.
Why a save takes effect immediately: every field is declared volatile, so the host hands the plugin a reference it updates in place and the plugin reads through it on each use. Volatile is also what makes the card exist at all —
dsh-settingsonly serves namespaces that carry at least one volatile field, so an all-ordinary schema never gets a form on the Plugins page.
| Key | Default | Range | Meaning |
|---|---|---|---|
maxTasksPerOwner |
100 | 1–1000 | unarchived templates per Session |
maxStepsPerTask |
10 | 1–10 | steps per template (V1.0 is linear) |
maxActiveRunsPerOwner |
3 | 1–20 | concurrent queued/running runs per Session |
maxParallelRunsPerTask |
1 | 1 | parallel runs of one task (fixed in V1.0) |
defaultTimeoutMinutes |
60 | 1–1440 | timeout used for identification only |
staleRunAfterMinutes |
30 | 1–1440 | age at which a startup scan marks a run interrupted |
historyRetentionDays |
90 | 1–3650 | terminal run retention |
maxSummaryChars |
2000 | 100–10000 | summary truncation bound |
Errors
| Code | Meaning | Retryable |
|---|---|---|
TASK_NOT_FOUND |
task missing, or not owned by this Session | no |
TASK_ALREADY_RUNNING |
the task already has an active run | after it ends |
TASK_REVISION_CONFLICT |
expectedRevision is stale |
re-read, then retry |
TASK_INVALID_STEPS |
bad step definition / count | fix arguments |
TASK_RUN_NOT_FOUND |
run missing or not owned by this Session | no |
TASK_RUN_ALREADY_FINISHED |
run is terminal | start a new run |
TASK_STEP_ORDER_INVALID |
out-of-order, unknown, or duplicate step report | fix order |
TASK_PERMISSION_DENIED |
archived/paused task, or missing resume confirmation | no |
TASK_SCHEDULE_UNAVAILABLE |
Schedule not mounted | after the host provides it |
TASK_SCHEDULE_FAILED |
host schedule operation failed | inspect host state |
TASK_STORAGE_ERROR |
StorageDomain missing, failed, or incompatible | after the host is fixed |
TASK_RUN_INTERRUPTED |
execution lost, marked interrupted | task_resume |
TASK_MAX_CONCURRENCY |
per-Session active-run cap reached | after a run ends |
TASK_INVALID_ARGUMENTS |
argument failed validation | fix arguments |
TASK_INTERNAL_ERROR |
unexpected runtime failure | no |
The first 13 are the PRD's stable codes; the last two are additive so an unexpected failure is never reported as a misleading PRD code.
Security
- Session isolation. Every tool entry point resolves the caller Session from
exec.agent.session.idand compares it with the record owner. A record owned by another Session is reported asTASK_NOT_FOUND, so the error cannot be used to probe other Sessions' data. - No privilege escalation. The engine never adds shell, file, browser or network capability. Every action runs through the Agent's already-authorized tools and existing approval flow.
- Templates are data. Step
instructiontext is user content with no elevated authority; a template cannot change system prompts, permissions or tool access. External text is rendered as untrusted single-line text. - No leakage. Error messages are sanitised: stack frames dropped, absolute
paths replaced with
<path>, credential-looking assignments redacted. - No code injection. Task arguments cannot carry JavaScript, dynamic imports or scripts; there is no evaluator anywhere in the plugin.
- Scheduling is bound to the creating Session, so a scheduled run executes in the Session that owns the task.
Deployment model and known boundary
This plugin is designed for a single local user. The board reads tasks through local
HTTP routes on the host ctx.webServer, and the host does not authenticate those static
routes per request (its authentication layer covers only the RPC gateway). Therefore:
- The routes are reachable from this machine only:
ctx.webServerrefuses to bind a wildcard address and accepts one concrete local interface. - The Session id is a data selector, not a verified identity. The board passes the Session of the page it runs in and the server filters by it; the server neither has nor proves that the caller is that Session — any local process can build the same request.
- So do not deploy this plugin as a shared multi-user instance or expose it publicly. In such
a deployment the board routes provide no access isolation; isolation is enforced at the tool
layer only (
task_*resolve the Session fromexec.agent.session.id, which cannot be forged). - The hint at the bottom of the board panel and
deploymentModel/sessionVerified: falsein/statusare this boundary declaring itself — not a security problem that has been solved.
If a future host supplies a trustworthy peer identity for static routes, the board should derive the Session from it instead of trusting a query parameter.
Cleanup behaviour
Cleanup is a batched prune performed at plugin startup (200 runs per batch, terminal runs
older than historyRetentionDays and their step rows). It is not a resident timer and not a
periodic background job: the host offers no side-effect-free background scheduling primitive and
the plugin does not build a resident worker. A long-lived process therefore keeps expired records
until its next start.
Upgrade
- Bump the bundle; the plugin row keeps its config.
- On next start the engine opens the domain, compares the stored
meta.schemaVersion, and runs any pending migration once each, recording a marker only after the migration succeeds. - A stored version higher than the plugin supports is refused with
TASK_STORAGE_ERROR— downgrading is not silently allowed.
the 1.0 baseline shipped an empty migration set; the runner and ledger exist so a future shape change is a data edit plus one entry.
Back up
~/.dsh/storages/dsh_background_task_engine.json(or the same file under your profile's storage root) before upgrading. schema v2 data cannot be handed to 1.1.x: the old code declares unit version 1 and refuses a v2 file withversion-mismatchat startup. To roll back, restore the backup — do not hand-edit the version number.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Every tool returns TASK_STORAGE_ERROR mentioning ctx.storageDomain |
the Host has no StorageDomain mounted | enable storage + storage-json + storage-domain in the profile |
invalid unit name '…' |
a domain/table name with a hyphen | the unit must match /^[a-z][a-z0-9_]*$/ (this plugin uses dsh_background_task_engine) |
TASK_SCHEDULE_UNAVAILABLE |
ctx.schedule is not mounted |
scheduling is optional; manual runs still work |
| Row did not activate: cannot get property "…" without inject | a plugin read an optional service as a property | resolve optional services via ctx.get |
TASK_REVISION_CONFLICT |
two edits raced | task_get, then retry with the current revision |
A run is interrupted after a restart |
the Host stopped mid-run; nothing is auto-restarted | task_resume with a confirmation if a step may have had side effects |
| Install rejected: dsh.bundle.patch must be a file path | flat manifest form | use "dsh": { "bundle": { "patch": "./cordis.patch.yml" } } |
Development
npm install
npm run build # tsc -> dist/
npm run typecheck
npm test # 81 tests
Layout:
src/
index.ts plugin entry: name / inject / Config / apply
host.ts structural host contract (no host package imports)
config.ts Schemastery Config + resolveConfig
errors.ts stable codes, payloads, message sanitisation
domain/records.ts zod record schemas
domain/state.ts TaskRun/StepRun state machines, progress, ordering
storage/spec.ts domain declaration, migrations, integrity check
storage/repository.ts the only reader/writer of domain tables
services/ audit, task, run, schedule adapter, engine
tools/ 12 tool definitions + shared plumbing
prompt/guidance.ts execution protocol and delivery parsing
tests/ domain, storage, rendering, integration (+ fakes)
docs/ API compatibility audit, test report, detail page
Verification records: docs/API-COMPATIBILITY-AUDIT.md (host capability audit,
including the real-stack runs) and docs/TEST-REPORT.md (all 81 assertions).
License
MIT — see LICENSE.
Links
More in this category
Tencent/WeKnora#dsh-weknora★ 38385
Four read-only tools over a WeKnora knowledge base: list knowledge bases, hybrid passage search, reassemble one document's chunks in order, and WeKnora's own cited RAG or ReAct-agent answer with a resumable session id.
DayuanJiang/next-ai-draw-io#dsh-plugin★ 37218
Draws draw.io diagrams in DeepSeek Harness through the next-ai-drawio MCP server: the link in the reply opens a live preview in the right sidebar, you can edit the diagram by hand, and each AI change is a version you can restore. Node.js 18+; npx downloads the MCP server on first use.
yikart/AiToEarn#dsh-plugin-aitoearn★ 28812
Generate copy, images and short videos, and publish with one click to Douyin, Kuaishou, Xiaohongshu, WeChat Official, Bilibili, Facebook, TikTok and more, covering the full content lifecycle from creation to publishing and monetization.
superdesigndev/treg★ 9804
Tool catalog for agents: search ~2,600 external endpoints (SEO and SERP, backlinks, social, people and company enrichment, ad libraries, scraping) by the task you want done, read each one's parameters and per-call price, then call it with the credential injected server-side. Ships the skill plus an MCP row that stays disabled until TREG_TOKEN is set.
T-Auto/dsh-ops★ 6039
Provides bash, PowerShell 7, and high-performance Rust tools for DSH on Windows to reduce token usage.
Hithink-Tech-Org/Financial-API#hithink-finance★ 4659
Query Hithink Finance data in DeepSeek Harness, view charts in chat, and save refreshable dashboards.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.