Introduction¶
When DSH runs long tasks, the process can get killed, crash, or the system can go to sleep on its own, leaving the task stuck halfway. Existing approaches either require you to manually type a “continue” prompt or simply lose all progress. The dsh-anti-interrupt plugin uses automatic resume and system settings intervention to pick up interrupted turns, and on Windows it disables the screen saver and sleep so tasks don’t stop mid-flight.
What It Does¶
Resuming Interrupted Turns¶
After DSH starts, the plugin scans for open turns at 6, 20, 45, 90, and 180 seconds. When it finds one, it restores the session using the same method as the frontend, then wakes it up to continue running. The resume message appears in the conversation as [Nightwatch Resume], including the interrupted turn number, the last tool call, the goal, and the next step. The source tag is zero-one-continuity.
Disabling Things That Interrupt You (Windows)¶
The Nightwatch button in the input toolbar contains two toggles. Enabling Anti-Screen-Saver turns off the screen saver and sets both display-off and sleep timeouts to “Never”—separately for AC power and battery. Disabling it restores the original values.
What this controls is the Windows built-in screen saver. Screen savers, lock-screen overlays, or break reminders implemented by other software are out of scope—those need to be disabled within their respective applications.
Both toggles are off by default.
Installation & Enablement¶
Search for dsh-anti-interrupt in the plugin marketplace and restart DSH after installing. Or:
dsh plugin add dsh-anti-interrupt
Manual: add "dsh-anti-interrupt": "^1.0.0" to the dependencies in ~/.dsh/profiles/<profile>/package.json, add "dsh-anti-interrupt" to dsh.profile.bundles, run the package manager install in the profile directory, then restart.
After installation, nightwatch action=status will report the version, and a Nightwatch button will appear in the input toolbar.
Core Features¶
Automatic Resume¶
Automatic resume uses only engine APIs and is platform-agnostic. The wake-up call uses agent.followup(), not agent.inject(). The contract of inject is that it does not wake the driver—the message stays in the inbox until the next user interaction pulls it out. Using the wrong one here means the resume never fires.
Session restoration goes through sessionController.resolveAgent(), the same path the frontend uses to open a session, so presets and tool sets are fully restored. There’s also an underlying agents.resume() that can bring a session back up, but the resulting agent lacks pwsh, read, and edit—the session exists, but no work can be done.
Interrupt detection has two paths, both verified with actual kills: the session tail didn’t close properly (native-turn-end), and the plugin’s own checkpoint is still open (own-checkpoint-open).
Anti-Screen-Saver¶
Action: disable screen saver
What changes: Registry HKCU\Control Panel\Desktop → ScreenSaveActive, along with ScreenSaveTimeOut and SCRNSAVE.EXE
How it restores: original values are saved before enabling; clicking “Off” writes them back
This Registry set is the complete set of Windows system screen saver controls. So this only affects the system screen saver: screen savers or lock screens implemented by third-party software (media players, security software, desktop customization, focus tools) are not in this Registry and are not affected by it.
Anti-Sleep¶
Action: disable display-off and sleep
What changes: uses powercfg to set VIDEOIDLE (display off) and STANDBYIDLE (sleep) on the current power scheme—separately for AC and battery
How it restores: a baseline is recorded the first time it’s enabled (power-original.json); clicking “Off” restores that set of values
Notes:
- No network access, no telemetry.
- Does not modify startup entries, does not kill processes.
- Does not create any scheduled tasks by default. Only when you click Install under Boot Guard is a single dsh-anti-interrupt-guard task created; clicking Uninstall removes it.
- Does not require administrator privileges.
- Only affects the current power scheme; switching schemes requires re-applying.
- It’s a one-shot action. After applying, if other software changes the power plan, it won’t automatically revert.
- The baseline is recorded only once; clicking “Off” restores the values from that first recording, not the most recent state.
All data lives under <DSH_HOME or ~/.dsh>/nightwatch/: toggle states, power baseline, checkpoints, and continuity/nightwatch.log. Checkpoints contain only the turn number, last tool call, goal, and next step—no conversation content.
Anti-Restart (Boot Guard)¶
Automatic resume only kicks in after DSH has restarted. To get DSH back on its own, something external needs to be watching—the plugin includes a built-in Boot Guard, but it only installs when you explicitly opt in.
What it installs: a Windows Scheduled Task named dsh-anti-interrupt-guard, running every minute; it launches DSH if it’s not running. Scripts, task definition, and logs all live under ~/.dsh/nightwatch/boot-guard/.
How to install: Input toolbar → Nightwatch → Boot Guard (Anti-Kill) → Install; or nightwatch action=guard guardAction=install.
How to uninstall: Uninstall from the same menu, or nightwatch action=guard guardAction=uninstall. Both the task and the directory are removed.
The toggle controls it. When the Anti-Restart toggle above is turned off, the task still fires on schedule but exits immediately at the gate—no check, no launch, no log entry. So if you want to shut down DSH normally, turn off the toggle first, then close the app, and it won’t come back on its own. The tradeoff is that crashes also won’t auto-resume at that point.
You can still use it without the guard: if the engine is restarted by a supervisor, or if you manually reopen DSH, turns will auto-resume—the window just won’t pop back up on its own.
The task uses XML registration and explicitly disables “Don’t start on battery power.” The default value of schtasks /SC MINUTE causes laptops on battery to never run this task, yet the UI still shows Ready with the next-run time advancing normally—we’ve actually hit this in practice; the task never executed once after registration.
Compatibility¶
Automatic resume uses only engine APIs and is platform-agnostic. The screen saver and power sections are Windows-specific; on other systems the corresponding interfaces return unsupported and that row is hidden in the UI.
Tested versions: 0.2.1-rc.5, 0.2.2-rc.1. After a major engine upgrade, it’s recommended to run nightwatch action=status first. If an API is missing, the related feature is disabled and logged clearly—DSH will still start.
Usage¶
| Action | Purpose |
|---|---|
nightwatch action=status |
Version, platform, toggles, watchdog install status, screen saver script, task status |
nightwatch action=toggle enabled=true\|false |
Enable/disable Nightwatch |
nightwatch action=checkpoint goal=… nextAction=… |
Write a checkpoint; will be included in the resume message |
nightwatch action=continuity |
Read back the current session’s checkpoint |
nightwatch action=check |
Dry-run the watchdog self-check |
nightwatch action=guard guardAction=status\|install\|uninstall |
Boot Guard: check status / install task / clean uninstall |
UI: Nightwatch button in the input toolbar.
HTTP: GET|POST /api/nightwatch/guard, POST {"screenAction":"status|disable|restore"}.
Uninstallation¶
Remove from dsh.profile.bundles and dependencies, then restart DSH. To clean up completely, also delete the data directory.
Before uninstalling, click Anti-Screen-Saver to turn it off first—otherwise the screen saver and sleep settings will remain disabled.
Use Cases & Notes¶
Suitable for scenarios requiring long-running DSH tasks where the process may be killed, crash, or the system may enter sleep. The plugin runs with the current DSH process privileges. Review the source code and license before installing.
Summary¶
dsh-anti-interrupt solves the problem of DSH long tasks being interrupted through automatic resume and system settings intervention. It picks up interrupted turns, disables screen saver and sleep on Windows, and provides an optional Boot Guard so DSH can come back on its own after being killed. Data is stored in the nightwatch directory. No network access, no telemetry, and no scheduled tasks are created (unless you manually install the Boot Guard).
Directory: https://www.skillhub.cn/plugins/ingk888766-cloud/dsh-anti-interrupt
GitHub: https://github.com/ingk888766-cloud/dsh-anti-interrupt