返回目录
模型与 MCP 插件

dsh-autorestart

Eason-22/dsh-autorestart

DSH plugin: restarts without interrupting your work — it waits until every conversation is idle, then comes back and picks up where it left off.

Stars
2
Forks
1
Issues
6
更新
9 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:Eason-22/dsh-autorestart

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-autorestart

Restart DeepSeek Harness without losing the work that is currently running.

npm version license dsh-plugin language

Chinese version: README.zh.md

Current version: 0.9.7

What it does

Three small things, all around restarting.

1. The restart is queued. An agent asks for a restart; the plugin does not cut off the conversations that are still running. It waits until every one of them is idle, restarts the host, and picks the interrupted work back up — the sessions resume and a goal is re-armed. When several conversations ask at once the requests are merged into one restart, and every requester is woken afterwards. A goal-carrying session cannot block the restart forever: its goal is disarmed before the restart (the running round still finishes) and re-armed after it.

2. It backs up before each restart. The configuration and the local link: plugin directories are saved under ~/.dsh/storages/dsh-autorestart/backups/. At most maxBackups copies are kept (default 2, range 2–10); old and incomplete ones are pruned. A snapshot that cannot be removed (for example because a file inside it is locked) is reported in backupHygiene.error rather than silently kept, so the count can briefly exceed the limit.

3. It clears the login cookies. Every launch leaves a dsh-auth-* entry behind; they pile up until the request header overflows (~16 KB), the server answers 431, and the client can only say Web authentication failed. The plugin clears those stale credentials before each restart and records the outcome in last-cookie-clear.json.

There is also a countdown shutdown: a moon button at the bottom of the sidebar waits for every conversation to finish, counts down on screen, and powers the machine off.

What it does not do

  • It does not watch the host and does not decide whether a restart came back.
  • It does not restore anything on its own. The backup is never applied automatically; it is there for you to inspect or roll back by hand. The one exception is the start-at-login supervisor, if you installed it: that separate process rolls the last snapshot back when the host refuses to start.
  • There is nothing left to run by hand. If the host will not start, use its own crash dialog or reinstall the plugin.

Tools for the agent

Tool What it does
continuum_restart Queue a graceful restart (waits for every conversation to be idle)
continuum_status Phase, generation, queued requests, which sessions are blocking
continuum_cancel_restart Withdraw a queued request (scope: "mine" or "all")
continuum_park_goal Disarm a goal so a queued restart can proceed
continuum_recover_now Retry post-restart recovery immediately
continuum_handoff Hand an over-limit session off to a fresh one
continuum_supervisor Inspect or install the self-starting supervisor

Configuration

The settings page writes these; the defaults are the ones in the code.

Key Default Meaning
restartMode app app = ask the desktop client to relaunch itself; command = run your own restart command
restartCommand '' The command used when restartMode is command; supports the {pid}, {ppid} and {app} placeholders
settleMs 2000 How long the host must stay quiet before the restart may start
restartGraceMs 0 Extra wait after the last conversation went idle, before the host is really restarted — a dropdown: 0 / 5 / 10 / 20 / 30 / 60 seconds. 0 = no extra wait
queuedGraceMs 60000 How long a queued inbox message may sit before it stops blocking the restart. A running conversation always blocks
marketStatusUrl '' Where the plugin market reports whether it is installing something. Empty = the status route of this host (/dsh-market/status). Read only — the probe never writes anything
marketProbeTimeoutMs 800 Upper bound of one market probe in milliseconds (a caller can shorten it, never extend it past 800)
marketProbeIntervalMs 1500 How often the market is asked while a restart is waiting (milliseconds)
marketInstallCooldownMs 15000 How long the restart still waits after the market reported that it finished, to bridge the gap between two operations of its queue (milliseconds)
pluginFilesWatch true Also wait while the profile's plugin files are being changed — package.json, pnpm-lock.yaml, node_modules and node_modules-link. This covers the installs that never go through the market: a manual pnpm add, or the host's own plugin manager
pluginFilesStableMs 15000 How long the plugin files must stay unchanged before the change counts as finished (milliseconds) — a dropdown in the settings page: 5 / 10 / 15 / 30 / 60 seconds. A false positive clears itself after this window
pluginFilesMaxBlockMs 300000 The longest a single file-change episode may hold a restart, so a stuck installation cannot pin the host shut (milliseconds) — a dropdown in the settings page: 5 / 10 / 30 / 60 minutes (the shortest wait is 5 minutes)
forceRestartWhenBusy false Interrupt a running conversation instead of waiting. The default never interrupts a session
deferPollMs 3000 Poll interval while waiting for the conversations to go idle
relaunchDelaySeconds 2 How long the detached helper waits before it kills the app
restartWindow background How the restart command script is started: background = no window at all, and it never takes the focus (the default since this version); foreground = the visible console window. An existing profile that already says foreground keeps it — only a missing or unreadable value falls back to background
backupOnRestart true Take a copy before every restart. It compares first, so a copy is only written when something changed. Two copies are kept by default and the oldest is deleted when there are more. With the switch off nothing is compared and no copy is taken
backupIncludePlugins true The copy holds plugins too, in three kinds: the plugins you wrote yourself and online plugins you downloaded and then changed on this machine (localised ones) are copied with their files, so a rollback restores them exactly; the rest of the online third-party plugins, installed as they came, only get their name and version recorded — their authors keep them up to date, so if something breaks, install them once more (~117 MB here, ~3 s with the files)
maxBackups 2 How many copies to keep (2–10). Its dropdown is a row of its own under Back up before a restart — no longer inside the Backup info fold. Past that number the oldest copy is deleted; shrinking asks first how many copies will go
restartCommandTimeoutMs 30000 How long the restart command may run before the plugin stops waiting for it
showSleepButton true Show the countdown-shutdown button
sleepCountdownSeconds 10 Countdown length before powering off — a dropdown: 0 / 10 / 20 / 30 / 60 seconds. 10 is only the default for an instance that never set it: a profile that already stores 20 (or 30, or 60) keeps that value — nothing is migrated or overwritten
sleepCommand '' Override the power-off command
resumeOnBoot true Resume interrupted sessions after a restart
recoveryDelayMs 6000 Wait before the first resume attempt
maxResumeAttempts 2 Resume attempts per session, counted across boots
maxSessions 4 How many sessions are resumed per boot
continuationText '' Override the continuation prompt text
stateFile '' Path of the checkpoint file. Empty = <DSH_HOME>/storages/dsh-autorestart/state.json
autoReloadPage true Reload the web page after a restart
blockManualRestart true Refuse an agent that tries to kill or relaunch DSH by hand, and point it at continuum_restart instead
healthPath /__dsh_autorestart/health Health check route: the boot id, the pid, the phase and the self-check flags
enabled true Turns the whole plugin off
watchEnabled true The plugin watch: after the host settles, compare what the loaded plugins provide with the previous reading and report what is no longer there. A report, not an automatic repair
watchDelayMs 8000 How long the watch waits after boot before it reads
deferSoftMs, deferHardMs, deferPolicy 300000 / 900000 / auto Deprecated — read but completely ignored. A pending restart has no deadline

Four of the keys above — restartWindow, pluginFilesWatch, pluginFilesStableMs and pluginFilesMaxBlockMs — have a control in the settings page, in the More settings block. The four market* keys are configuration keys without a settings-page control; the More settings subsection below says which is which.

The settings page

Every section is one row per thing: the title is on the left, the control is on the right, and the explanation is folded behind Show details (查看说明) so the page stays readable. A row that is switched off in its own title is a sliding switch, not a checkbox. The control column is wide enough (260 px, dropdowns at least 200 px) that a long choice such as Background (no window at all, and it never takes the focus; the default) is shown in full instead of being squeezed.

A row that only means something while the row above it is on is drawn as that row's subordinate: indented under it, behind a faint vertical line, and greyed out (its control cannot be used) when the parent is off.

Section What is in it
Restart settings The wait before the restart, Back up before a restart with two subordinate rows — Include the installed plugins in the backup and Copies kept — and the Backup info fold (read-only)
Shutdown settings The countdown of the graceful shutdown
More settings A block of its own, closed by default: how the restart command script runs, and the plugin-folder watchdog
Start at login How "start at login" works on this machine, with copyable commands. The plugin never changes your system configuration for you. Not shown on the desktop client — it relaunches itself, so there is nothing to install
Something is wrong The diagnostics and a Report a problem button that copies them and opens a pre-filled GitHub issue. The diagnostics carry no access token and no secrets

Back up before a restart compares first, so it says what actually happens: your DSH settings and the plugins covered by the two rows below it are compared; only when something changed is a new copy written, and when nothing changed the most recent copy is reused. Two copies are kept by default and the oldest is deleted when there are more — that number is changed under Copies kept, the third row of this group. With the switch off nothing is compared and no copy is taken. A copy is never restored by itself: to roll back, press the button in Backup info.

Include the installed plugins in the backup splits the plugins into three kinds:

  • the plugins you wrote yourself, and the online plugins you downloaded and then changed on this machine (localised ones) — their files are copied, so a rollback restores them exactly as they were;
  • the rest of the online third-party plugins, installed as they came — only their names and versions are recorded and no files are copied; their authors keep them up to date, so if something breaks, install them once more.

That split is not a figure of speech: lib/backup.js really does treat a hand-written link, a localised localized and the remaining thirdParty separately, and the localised ones are copied with their files.

Backup info is the fold that shows what has been backed up: how many copies there are and what they take on disk, when a copy is taken, the list with a button that rolls back to that one copy, and the path with a copy button. Since this version it holds read-only content only — the Copies kept dropdown moved out of it and became the third subordinate row of Back up before a restart, where the number is actually set. It is closed by default — except on a boot the system had to restore, where it opens itself and says so on its title, because an intervention is the one thing that must not be hidden.

The last restart row is gone from the page: which launcher really ran (wscript, the PowerShell fallback, the foreground window) is still reported by the host — it is in the status payload and in the diagnostics — it simply does not take up room on the settings page any more.

More settings (「更多设置」)

A block of its own, after Shutdown settings and before Something is wrong, closed by default — until you click the title you only see the title.

Row (as it reads on the page) Key Control
How the restart command script runs restartWindow Dropdown: Foreground (a window appears briefly) / Background (no window at all, and it never takes the focus; the default)
Do not restart or shut down while plugins are installing pluginFilesWatch Sliding switch
How many seconds without a file change mean the plugin is installed pluginFilesStableMs Dropdown: 5 / 10 / 15 / 30 / 60 seconds
How long to wait at most for the plugin install pluginFilesMaxBlockMs Dropdown: 5 / 10 / 30 / 60 minutes

The last two are subordinate to the switch above them: they are drawn indented under it, and they are greyed out (their dropdown cannot be used) while that switch is off. Their own sentence says so as well — "When the switch above is off, these two do nothing."

A value that is not one of the offered choices is not rewritten: it shows up in the dropdown as Current value, so an existing profile keeps working and nothing changes until you pick a choice.

Background is the default since this version. The restart command script used to run in the foreground, in a console window that stayed visible for the length of the grace delay. An existing profile that already says foreground keeps the foreground — the default only fills in a missing or unreadable value. Nothing else about the restart changed: the wait, the idle gate, the kill of the whole process tree, the cookie clear and the relaunch happen in the same order. If this machine does not allow such little scripts to run, a hidden PowerShell runs the same command instead and the reason is written into the restart report.

The four market probe keys — marketStatusUrl, marketProbeTimeoutMs, marketProbeIntervalMs and marketInstallCooldownMs — have no control in the settings page. They are configuration keys: set them in the profile row or through the configuration API. The defaults in the table above are the ones the probe actually uses.

What the restart waits for

A restart is queued, not cut through. The gate waits for the work that is still going on — and the graceful shutdown (the moon button) waits for the same three things plus one more, because a shutdown cuts an installation in half even more surely than a restart does.

It waits for How it is decided What you see
Every conversation to be idle The plugin asks the host which sessions are still running. A queued (unclaimed) inbox message blocks for at most queuedGraceMs; a running conversation always blocks The restart stays queued; continuum_status names the sessions that block it
The plugin market to be done A read-only GET of the market's status route (/dsh-market/status): busy or active means "installing". An answer that cannot be read — a timeout, a 404, a non-2xx answer, a body that is not an object — means "nothing is being installed", and the restart goes on exactly as it did before this feature existed The restart capsule shows a pill ("waiting for the plugin market to finish installing"); the sidebar dot's tooltip says the same thing
The plugin files to settle The profile's package.json, pnpm-lock.yaml, node_modules and node_modules-link are fingerprinted; while the fingerprint keeps moving, the restart waits. This catches the installs that never go through the market: a manual pnpm add, or the host's own plugin manager The restart capsule shows a pill ("waiting for a plugin install to finish")
A goal that is still going (the shutdown only) A goal counts as running while it is still armed, has not reached a terminal phase (paused / blocked / complete / completed / done) and still has rounds left. A paused goal, a disarmed goal and a finished goal never hold the machine The shutdown is held and names the goal that is still working

Both of the installation waits have an upper bound, so a broken signal cannot hold the host for ever:

  • The market: an "installing" answer is remembered for at most marketInstallCooldownMs (15 s by default), and only while the market cannot be reached at all. Past that window the market counts as idle.
  • The plugin files: one episode of file changes holds a restart for at most pluginFilesMaxBlockMs (5 minutes by default), and it only counts as "changing" while the last change is younger than pluginFilesStableMs (15 s by default).

Both probes are read-only: one GET, no body, no retry, nothing is written.

Where it writes

Path What
~/.dsh/storages/dsh-autorestart/state.json Boot generation, phase, per-session restart state
~/.dsh/storages/dsh-autorestart/backups/<stamp>/ config/ + node_modules-link/ of one snapshot
~/.dsh/storages/dsh-autorestart/last-cookie-clear.json How many credentials the last clear removed
~/.dsh/storages/dsh-autorestart/access.json The loopback port and token the plugin listens on

About that backup

It holds the configuration files (package.json, cordis.patch.yml, pnpm-lock.yaml) and the plugins that are copied with their files — the ones you wrote yourself and the online ones you changed on this machine. The online third-party plugins installed as they came are not in it: the manifest only records their name and version, and they can be reinstalled from package.json + pnpm-lock.yaml. So it is good for "what did this look like before" and "put this one plugin version back", not a one-click reinstall.

How big is a backup, and where does the size come from?

Almost all of it is the plugins that are copied with their files. The online third-party plugins only contribute a name and a version to the manifest, so they cost nothing on disk.

Measured on this machine (2026-11-11, desktop client; read from the manifest and the disk):

Backup Size Files links localized thirdParty
2026-11-11T06-36-48-336Z 132.1 MB 820 7 0 145 (name + version only)
2026-11-11T04-13-04-262Z 129.2 MB 820 7 0 145 (name + version only)

linkBytes is 138,395,369 — essentially every byte of the copy. The two backups have the same structure; only the byte count moved.

Where those 138 MB sit — the seven copied plugins:

Plugin Size
dsh-codekg 118.7 MB
dsh-goal-guard 6.1 MB
dsh-autorestart 5.1 MB
dsh-secret-vault 1.2 MB
dsh-github-guard 0.4 MB
dsh-security-scan 0.3 MB
dsh-web-fetch-fallback 0.1 MB

dsh-codekg alone is about 86% of the whole backup, and almost all of that is its own data/ directory (114.0 MB): snapshots/ 99.6 MB (108 files, mostly the run-*.json baselines the tool writes), graphs/ 11.4 MB, runs/ 2.9 MB. That is run data the tool produced, and it grows and shrinks with use and with the tool's own retention.

So the size of a backup floats — that is normal. It does not mean the backup went wrong, and it does not mean a plugin was left out: the size follows the plugins' own working data. The things to look at are the file count and the plugin list, not the byte total.

This version copies everything, file by file. There is no exclusion by directory or by plugin — which is why the running data of the backed-up plugins is in there too (dsh-codekg's data/, 114 MB measured, of which snapshots/ is 99.6 MB). That is deliberate, not an oversight: some people really do need their data backed up as well — moving to another machine, keeping a record, looking at it after an incident. If it is ever offered, it should be a setting the user picks — deciding for themselves what gets copied — rather than a decision made for everybody. This version does not do that.

Platforms

Platform Status
Windows desktop client (restartMode: app) Verified on the real machine
Hosted dsh web on WSL with systemd (restartMode: command) Verified on a real instance
Hosted dsh web on Windows Not verified
WSL without systemd, native Linux Not verified

macOS, a remote SSH session without a graphical session and containers are out of scope — not tested, and not supported. The per-capability matrix is in docs/platform-matrix.md.

The floating overlay in hosted dsh web — read this before expecting it

The restart / sleep / plugin-failure surfaces are drawn in the client slot shell.overlay — "a frame-wide floating layer, above every column and outside their scroll containers". Both facts below were checked against the shipped packages and a live client, not assumed:

  • The slot is declared by the shared workspace UI package (dsh-client-ui-workspace/lib/types/client/contract/slots.d.ts), which is what the hosted web UI mounts — so the slot itself is not desktop-only.
  • On the desktop client all three of our entries are registered and active: true: autorestart-plugin-failure (order 9), autorestart-restart-overlay (order 55), autorestart-sleep-overlay (order 60). Verified through the live client Slot inspection.

On hosted web the restart has fewer phases, and one of them does not exist at all. Measured on a real instance (0.9.5, restartMode: command), sampling /health?state=1 every 300 ms across a full restart — 121 frames:

waiting      17 frames (~4 s)
DOWN         1 frame          old process gone
restarting    1 frame
DOWN         4 frames         process swap
back          1 frame
DOWN         3 frames

There is no snapshotting frame. On the desktop the backup happens in the old process before it quits, and that is what the overlay reports. Hosted web does it the other way round: the old process only goes waiting → restarting, and the backup is written by the new process at boot, surfaced as firstInstallBackup. So the "backing up, plugins included" sentence has no phase to attach to on the web — it is not hidden, it does not happen there.

The backup itself is still real and still includes plugins on web — verified on the same run:

manifest.json  stamp: 2026-11-09T09-41-41-335Z  atLocal: 2026-11-09T17:41:41+08:00
               includePlugins: true   profileDir: /home/fg/.dsh/profiles/web

Treat the restart overlay as a desktop-client feature and do not plan around seeing it in a browser. This is a property of "the page is not the host", not a defect fixable from the plugin side. The restart stays fully visible in the HTTP surface on both platforms — GET /__dsh_autorestart/health?state=1 reports the live restartPhase and the finished firstInstallBackup — so a scripted check observes what a browser tab cannot.

Install

From npm:

dsh plugin install dsh-autorestart

From source:

git clone https://github.com/Eason-22/dsh-autorestart.git
cd dsh-autorestart
dsh plugin --profile desktop add /absolute/path/to/dsh-autorestart

Inside DSH the equivalent is the plugin_manager tool:

plugin_manager install_bundle  target = <absolute path to the package>

The plugin needs no configuration to work: the defaults queue restarts, take a snapshot before each one, and clear the stale cookies.

Uninstall

Remove the dsh-autorestart row from your profile's bundle list — in the Plugin Manager of the UI, or with the dsh plugin CLI:

dsh plugin remove dsh-autorestart

The snapshots under ~/.dsh/storages/dsh-autorestart/backups/ are yours; they are not deleted for you.

Tests

The plugin ships its own test suite in plugins/dsh-autorestart/test/. There is no node on PATH in the desktop environment, so the repository ships a script that runs the suite with the bundled Node:

pwsh -NoProfile -File plugins/dsh-autorestart/scripts/run-tests.ps1

On Windows PowerShell the same thing is:

powershell -NoProfile -ExecutionPolicy Bypass -File plugins/dsh-autorestart/scripts/run-tests.ps1

Do not hand a directory to node --test. Node 24 and newer treat the positional arguments of --test as glob patterns, so node --test plugins/dsh-autorestart/test fails with MODULE_NOT_FOUND. The script passes the glob plugins/dsh-autorestart/test/*.test.mjs instead.

All 1191 test cases pass (1191 passed, 0 failed, 0 skipped) — measured on 2026-11-11 with the bundled Node: tests 1191 / pass 1191 / fail 0, exit code 0.

License

MIT

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度中

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。