dsh-session-purge: Permanently delete sessions in sidebar archives

Introduction

DeepSeek Harness (DSH) only provides archive and unarchive operations for sessions by default. Session logs are append-only, the persistence layer does not expose a delete API, and the workspace registry merely removes the registration entry — the session directory and projection cache on disk often remain. To truly remove a record from the “already-processed session pile,” the built-in capabilities alone are not enough.

There is another npm package with the same name in the community, dsh-session-purge. Its README explains that archived sessions are not visible in the sidebar, so the menu is unreachable; you have to unarchive before deleting. This plugin, maintained by wwwyxsuper (GitHub: wwwyxsuper/dsh-session-purge, categorized under admin-security), takes the opposite approach: it only offers “Delete permanently” in the ⋯ menu of “Archived” sessions in the sidebar, targeting exactly the list of records you actually want to clean up.

What Is This

In one sentence: a DSH plugin that permanently deletes sessions from the archived-session ⋯ menu in the sidebar (log directory, projection cache, workspace registry; two-step confirmation; five safety gates).

The current package version is 0.2.0, MIT license; marked as compatible with DSH 0.2.0-rc.2, supporting web / desktop profiles.

Core Features

Two Host-Side Agent Tools

Tool Purpose
session_purge_list Read-only listing of all sessions on disk: title, size, last modified time, and archived / live-agent / current-session flags, to confirm the target before deletion
session_purge_delete Deletes a specified session; requires confirm: true, optionally allow_unarchived, allow_live, prune_registry

Client UI (since v0.2.0)

Adds a Delete permanently row to the ⋯ menu of session rows in the sidebar (pure incremental mounting, replaceRisk: none), positioned below “Unarchive” with a divider. Shown only for archived (ARCHIVED) sessions; whether a session is archived is determined by the host via GET /api/dsh-session-purge/state — the client does not guess snapshot structure.

Earlier versions had a hover button at the end of the row (sidebar.workspaces.session.row.action), which was removed because it looked cluttered; the menu entry is now the only entry point.

Deletion is irreversible, so the UI uses a two-click process: the first click changes the label to “Confirm delete?”, the second actually executes it; window.confirm is not used (it may be disabled in the Electron renderer).

What a Single Deletion Cleans Up

The same flow handles three locations:

  1. <DSH_HOME>/sessions/<workspace>/<session id>/ — the session log directory
  2. <DSH_HOME>/storages/session_projcache/sessions/<session id>.json — the projection cache (title, etc.)
  3. <DSH_HOME>/storages/workspace.json — the id in the workspace registry (first backed up as .bak-<stamp>, then atomically replaced)

An audit line is also written to <DSH_HOME>/session-purge.log.

The attachment directory $DSH_HOME/attachments/v1 is content-addressed and may be shared across sessions, so it is intentionally not deleted.

Five Safety Gates

# Gate
1 The UI entry appears only for archived sessions; on the tool side, deleting an unarchived session is rejected unless allow_unarchived: true is set
2 Refuses to delete the currently active conversation session (self-destruction)
3 Refuses to delete sessions that still have a live agent (otherwise it would be written back to disk)
4 After deletion, re-checks whether the files have been “resurrected” (resurrected), and gives an explicit warning
5 Two-step confirmation in the UI; the HTTP delete route requires a per-boot token injected into the page

HTTP Routes for Use by This Plugin’s Client Only

Method Path Meaning
GET /api/dsh-session-purge/state Returns { ok, archived: [sessionId…] }
POST /api/dsh-session-purge/delete Body { sessionId, confirm: true }

Both require the request header x-dsh-session-purge (the static token ui also works). Custom headers trigger a CORS preflight request; the routes do not approve preflight, so cross-origin pages cannot call them; the routes are mounted on DSH’s local loopback web service and do not open extra ports.

Installation and Activation

The plugin is installed into the profile as a file: dependency (copied, not symlinked). After modifying the source code, you must re-copy and restart DSH; the client half does not support hot reload.

The installation/update example in the docs (Windows PowerShell):

$src = '<this repo>'
$dst = "$env:USERPROFILE\.dsh\profiles\<profile>\node_modules\dsh-session-purge"
robocopy $src $dst /MIR /XD node_modules
# then restart DSH

Replace <this repo> with your local clone or extracted plugin directory, and <profile> with your profile name; restart DSH when done.

Uninstallation: remove dsh-session-purge from the profile’s package.json dependencies and dsh.profile.bundles, delete node_modules\dsh-session-purge, and restart DSH; the menu entry disappears, everything else stays the same.

Typical Usage

Sidebar (archived sessions)

  1. Open the archived-session list in the sidebar, click ⋯ on the target session.
  2. Choose “Delete permanently”, then click “Confirm delete?” once more to complete the deletion.

Agent tools

  1. Call session_purge_list to verify the session id, archived and live status.
  2. Call session_purge_delete for the confirmed target with confirm: true; only add allow_unarchived, allow_live, or prune_registry when explicitly needed.

Suitable Scenarios and Caveats

  • Suitable for: DSH users who need to perform irreversible cleanup directly from the “Archived” list while also wanting the Agent to be able to delete by id.
  • Permissions: the plugin reads and writes $DSH_HOME with the current DSH process’s permissions; review the GitHub source code and the MIT license yourself before installing.
  • Irrecoverable: deleted sessions cannot be recovered from the plugin side; the registry file has a .bak-<stamp> backup, but the session directory and projection cache are gone after deletion, so proceed carefully.
  • Ecosystem: the DSH community plugin directory is displayed on independent sites such as SkillHub; it has no official affiliation with DeepSeek / Hithink RoyalFlush; installation follows the README — do not mix expectations with the same-named package on npm maintained by someone else (the sidebar visibility policy differs).

Conclusion

dsh-session-purge fills the gap beyond DSH’s archiving feature — “permanently deleting a session in place from the archived sidebar” — and adds confirmation and multiple gates on both the tool and UI sides. Directory page: https://www.skillhub.cn/plugins/wwwyxsuper/dsh-session-purge; source code and documentation: https://github.com/wwwyxsuper/dsh-session-purge.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye