npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yadsh/dsh-kv-persist

v0.2.7

Published

Persistent KV-cache/session-state manager for DeepSeek Harness (llama.cpp slot snapshots)

Downloads

1,135

Readme

@yadsh/dsh-kv-persist

dsh-kv-persist keeps local LLM sessions warm across session switches and restarts.

It maps DeepSeek Harness sessions to persistent inference-cache snapshots and restores them when a session becomes active again. The initial backend uses llama.cpp's slot save/restore API, allowing large agent contexts to resume without repeating a full prompt prefill.

KV state is treated strictly as an optimization: DSH's session log remains the source of truth, and any missing, stale, or incompatible cache automatically falls back to normal inference. The model never knows this plugin exists.

Features

  • Maps DSH sessions (sessionId + provider + model) to llama.cpp slot snapshots via GET /slots and POST /slots/{id}?action=save|restore|erase.
  • Lazy restore: nothing is loaded until the session's first managed request; resident sessions run with zero disk I/O and zero management calls.
  • Save-before-switch, idle checkpoints, and shutdown/flush checkpoints, with dirty generations and save coalescing instead of a naive boolean.
  • Runtime compatibility gate: snapshots restored only when the server instance, provider, model, and runtimeKey generation match; the rest are marked invalid and skipped, never deleted.
  • Cold fallback everywhere: persistence failures degrade to ordinary inference; optional strict mode is the only failure path.
  • Circuit breaker stops a broken backend from costing latency on every request.
  • Auxiliary requests (session titles, compaction) are coordinated so they never pollute or hijack a session's slot ownership.
  • Structured kv.* logging, in-memory metrics, status() and doctor() diagnostics on the service.

Requirements

  • DeepSeek Harness >= 0.1.5-rc.2 < 0.2.0
  • A llama.cpp llama-server started with --slots --slot-save-path <dir> and --parallel 1 for the single-slot mode (see the design doc §6). The server flag does not replace the plugin's local lease, which also serializes save, restore, erase, and terminal stream bookkeeping.
  • Node.js >= 22

Installation

Install the published npm package by name:

dsh plugin --profile <profile> add @yadsh/dsh-kv-persist

From sources, build the package and link the checkout:

pnpm nx run @yadsh/dsh-kv-persist:build
dsh plugin --profile <profile> add ./plugins/dsh-kv-persist

Configuration

Configure the plugin under the kv-persist key in the DSH profile. Only providers listed under providers are ever coordinated.

| Option | Type | Default | Description | | --- | --- | --- | --- | | enabled | boolean | true | Master switch; false passes everything through. | | backend.baseURL | string | http://127.0.0.1:8080 | llama-server management endpoint. | | backend.apiKey | string | "" | Bearer key for the management API; never logged. | | backend.requestTimeoutMs | number | 15000 | Bounded timeout per persistence call. | | providers | string[] | [] | Managed provider routes; empty = plugin inert. | | mode | "single-slot" | "single-slot" | v0.1 supports single-slot only. | | slotId | number | 0 | Physical slot used in single-slot mode. | | runtimeKey | string | "" | Runtime identity escape hatch; changing it hides old snapshots (they are kept, not deleted). | | checkpoint.onSwitch | boolean | true | Save a dirty slot before reassignment. | | checkpoint.onShutdown | boolean | true | Final checkpoint on plugin disposal. | | checkpoint.onSessionFlush | boolean | true | Checkpoint on the session flush event. | | checkpoint.idleMs | number | 30000 | Idle checkpoint delay; 0 disables. | | checkpoint.onTurnEnd | boolean | false | Checkpoint after every user turn. | | checkpoint.onStepEnd | boolean | false | Reserved for per-step checkpoints. | | restore.enabled | boolean | true | Restore compatible snapshots lazily. | | restore.verify | boolean | true | Reject restores reporting n_restored <= 0. | | failure.strict | boolean | false | Turn restore failures into request failures. | | failure.maxConsecutiveFailures | number | 3 | Failures before the circuit opens. | | failure.cooldownMs | number | 60000 | Circuit open duration. | | metadata.path | string | <DSH home>/cache/dsh-kv-persist | Manifest storage directory. DSH home is non-blank $DSH_HOME, otherwise ~/.dsh. | | logging.level | "debug" \| "info" \| "off" | "info" | Structured kv.* event verbosity. |

Full configuration rationale: design doc §35.

Compatibility

  • DeepSeek Harness >=0.1.5-rc.2 <0.2.0 (see compatibility.json)
  • Node.js >= 22
  • llama.cpp server with the slots management API enabled

Development

pnpm nx run @yadsh/dsh-kv-persist:lint
pnpm nx run @yadsh/dsh-kv-persist:typecheck
pnpm nx run @yadsh/dsh-kv-persist:test
pnpm nx run @yadsh/dsh-kv-persist:build
pnpm nx run @yadsh/dsh-kv-persist:verify

Optional end-to-end check against a live server (no GPU in CI):

DSH_KV_TEST_LLAMA_URL=http://127.0.0.1:8080 pnpm --filter @yadsh/dsh-kv-persist test:llama

See SPEC.md for the product contract and implementation status.

License

MIT