Все плагины

dsh-autorestart

dsh-autorestart · Версия 1.0.1 · Обновлён 29 нояб. 2026 г.

Плагин ставит запросы на перезапуск DSH в очередь, пока все сеансы не освободятся. Затем он перезапускает DSH, восстанавливает сеансы и заново привязывает цели. Одновременные запросы сводятся к одному перезапуску, после которого инициаторы возобновляют работу по очереди.

  • проверка каждой версии
  • Сессии и сообщения
  • MIT
  • Загрузок: 0

Описание

Ниже — оригинальный текст автора.

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: 1.0.1

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.

4. It stops asking you questions once you have gone. While that countdown shutdown is armed, the tools that ask you to decide something are held back: the model is told you are away, that the question belongs in the reply body, and that it should carry on with what you already approved. Turn the switch off and nothing is held back. Only the ask-type tools are affected — writing files, running commands and delegating work pass untouched — and it adds nothing permanent to a conversation: the only text is the one line a blocked question gets back.

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

ToolWhat it does
continuum_restartQueue a graceful restart (waits for every conversation to be idle)
continuum_statusPhase, generation, queued requests, which sessions are blocking
continuum_cancel_restartWithdraw a queued request (scope: "mine" or "all")
continuum_park_goalDisarm a goal so a queued restart can proceed
continuum_recover_nowRetry post-restart recovery immediately
continuum_handoffHand an over-limit session off to a fresh one
continuum_supervisorInspect or install the self-starting supervisor

Configuration

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

KeyDefaultMeaning
restartModeappapp = 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
settleMs2000How long the host must stay quiet before the restart may start
restartGraceMs0Extra 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
queuedGraceMs60000How 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
marketProbeTimeoutMs800Upper bound of one market probe in milliseconds (a caller can shorten it, never extend it past 800)
marketProbeIntervalMs1500How often the market is asked while a restart is waiting (milliseconds)
marketInstallCooldownMs15000How long the restart still waits after the market reported that it finished, to bridge the gap between two operations of its queue (milliseconds)
pluginFilesWatchtrueAlso 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
pluginFilesStableMs15000How 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
pluginFilesMaxBlockMs300000The 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)
forceRestartWhenBusyfalseInterrupt a running conversation instead of waiting. The default never interrupts a session. An interruption is a real cut, not a hand-off: the conversations it cuts are recorded as interrupted (continuum_status reports them), but only the session that ASKED for the restart is resumed — the others wait for you to say a word
deferPollMs3000Poll interval while waiting for the conversations to go idle
relaunchDelaySeconds2How long the detached helper waits before it kills the app
restartWindowbackgroundHow 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
maxCompareFiles20000How many files one configuration comparison may look at before it gives up. It is a dropdown inside the backup group, below the copy limit, offering 10000 / 20000 / 30000 / 50000; above the ceiling the comparison is skipped to save time and the backup still runs
backupOnRestarttrueTake 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
backupIncludePluginstrueThe 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)
maxBackups2How 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
restartCommandTimeoutMs30000How long the restart command may run before the plugin stops waiting for it
showSleepButtontrueShow the countdown-shutdown button
gateOnSleeptrueWhile the countdown shutdown is armed, hold back the tools that ask the user a question. On by default; turn it off and no guard is registered at all
sleepCountdownSeconds10Countdown 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
resumeOnBoottrueResume interrupted sessions after a restart
recoveryDelayMs6000Wait before the first resume attempt
maxResumeAttempts2Resume attempts per session, counted across boots
maxSessions4How 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
autoReloadPagetrueReload the web page after a restart
blockManualRestarttrueRefuse an agent that tries to kill or relaunch DSH by hand, and point it at continuum_restart instead
healthPath/__dsh_autorestart/healthHealth check route: the boot id, the pid, the phase and the self-check flags
enabledtrueTurns the whole plugin off
watchEnabledtrueThe 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
watchDelayMs8000How long the watch waits after boot before it reads
deferSoftMs, deferHardMs, deferPolicy300000 / 900000 / autoDeprecated — 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.

SectionWhat is in it
Restart settingsThe 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 settingsThe countdown of the graceful shutdown, and the row under it: hold the questions while I am away
More settingsA block of its own, closed by default: how the restart command script runs, and the plugin-folder watchdog
Something is wrongThe 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)KeyControl
How the restart command script runsrestartWindowDropdown: 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 installingpluginFilesWatchSliding switch
How many seconds without a file change mean the plugin is installedpluginFilesStableMsDropdown: 5 / 10 / 15 / 30 / 60 seconds
How long to wait at most for the plugin installpluginFilesMaxBlockMsDropdown: 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 forHow it is decidedWhat you see
Every conversation to be idleThe plugin asks the host which sessions are still running. A queued (unclaimed) inbox message blocks for at most queuedGraceMs; a running conversation always blocksThe restart stays queued; continuum_status names the sessions that block it
The plugin market to be doneA 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 existedThe 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 settleThe 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 managerThe 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 machineThe 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

PathWhat
~/.dsh/storages/dsh-autorestart/state.jsonBoot 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.jsonHow many credentials the last clear removed
~/.dsh/storages/dsh-autorestart/access.jsonThe loopback port and token the plugin listens on
~/.dsh/storages/dsh-autorestart/last-sleep.jsonWhen and why the last shutdown intent was cleared (at / reason / armedAt / countdownSeconds)

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):

BackupSizeFileslinkslocalizedthirdParty
2026-11-11T06-36-48-336Z132.1 MB82070145 (name + version only)
2026-11-11T04-13-04-262Z129.2 MB82070145 (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:

PluginSize
dsh-codekg118.7 MB
dsh-goal-guard6.1 MB
dsh-autorestart5.1 MB
dsh-secret-vault1.2 MB
dsh-github-guard0.4 MB
dsh-security-scan0.3 MB
dsh-web-fetch-fallback0.1 MB

The copy carries SOURCE only (0.9.14). What a backup is for is putting back a plugin whose source was edited into a broken state — that is the only damage it has to undo. A dependency tree comes back with pnpm install, a plugin's own data/ is rebuilt the next time it runs, and .git comes back from the remote, so none of them belongs in every pre-restart copy.

Left outWhyMeasured here
node_modulesreinstallable from package.json / pnpm-lock.yaml585.6 MB / 35,406 files (dsh-agent-teams)
data/the plugin writes it at runtime and rebuilds it615.8 MB / 11,666 files (dsh-codekg graphs)
.gitrebuildable (clone/fetch)56.8 MB / 2,955 files (12 plugins)
.tmp* work directoriesscratch space by construction7.3 MB / 358 files

Measured on this machine (0.9.14): one full copy went from 1,151 MB to 58 MB. The price is stated so it is a choice rather than a surprise: restoring a linked plugin needs one pnpm install before it runs again, and a plugin that keeps state in data/ starts that state from empty. The plugin's own code, its manifest and the profile configuration come back complete either way.

The comparison that decides "did anything change?" uses the same list. The two used to disagree — "nothing changed" was decided on a smaller tree than the one the copy then walked — which is how a restart could skip the copy and then still pay for it on the next one.

The manifest records what was skipped (skipped: [{ plugin, name, files, bytes }]), so every exclusion is visible rather than implied.

Platforms

PlatformStatus
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 WindowsNot verified
WSL without systemd, native LinuxNot 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:

sole plugin install dsh-autorestart

From source:

git clone https://github.com/Eason-22/dsh-autorestart.git
cd dsh-autorestart
sole 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 sole plugin CLI:

sole 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 1250 test cases pass (1250 passed, 0 failed, 0 skipped) — measured on 2026-11-18 with the bundled Node: tests 1250 / pass 1250 / fail 0, exit code 0.

License

MIT

История версий

  • 1.0.129 нояб. 2026 г. · 2.0 MB