dsh-prime-agent: A Persistent TypeScript REPL Plugin for DeepSeek Harness

Preface

In DSH’s plugin model, normal sessions typically continue to use the official one-shot semantics: one tool call handles one task, and it is not easy to preserve top-level variables, functions, and objects across multiple calls. dsh-prime-agent provides another entry point for sessions with the Prime preset selected: there is only one model-visible tool, repl, with the sole parameter { code }, which executes a persistent TypeScript REPL cell. Ordinary variables, functions, and objects declared in a previous cell can be used directly in the next cell; DSH’s other tools do not enter the model schema but are instead preloaded into the cell as tools, agents, and jobs bindings.

This plugin is maintained by yoke233. GitHub: https://github.com/yoke233/dsh-prime-agent. Directory page: https://www.skillhub.cn/plugins/yoke233/dsh-prime-agent.

What This Is

dsh-prime-agent is an RLM-first control plane for DeepSeek Harness. It targets DSH’s plugin and session model, providing a persistent TypeScript REPL tool for sessions with the Prime preset selected.

The core changes are:

  • The model-visible tool is consolidated to repl.
  • The sole parameter of repl is { code }.
  • Each call executes a persistent TypeScript REPL cell.
  • Ordinary variables, functions, and objects declared in a previous cell can be used directly in the next cell.
  • DSH’s other tools do not enter the model schema but are preloaded into the cell as tools, agents, and jobs bindings.
  • Non-Prime sessions continue to use the official one-shot semantics.
  • The official code-runtime row is kept as-is, with a new dsh-prime-agent/runtime host row added.

Core Capabilities

Persistent TypeScript REPL Cell

In Prime preset sessions, the model only needs to call one tool:

repl({ code: `...` })

Each call executes a persistent TypeScript REPL cell. Ordinary variables, functions, and objects declared in the previous cell remain available in the next cell.

Other DSH Tools Preloaded into Cell

No other DSH tools directly enter the model schema. The plugin preloads relevant capabilities into the cell as tools, agents, and jobs bindings.

Verified capabilities include:

  • agents.*: spawn, fork, list, send, interrupt.
  • jobs.*: list, output, kill.
  • A DSH Host MCP client explicitly installed by the profile will register its server tools into the unified catalog, and the repl unit automatically receives the corresponding tools.* bindings.

Directly calling other tools is rejected by the guard. These capabilities should appear as preloaded bindings within the cell.

Local Composition Capabilities

The plugin registers a local composition capability:

tools.apply_patch({ patch })

It handles related multi-hunk, multi-file changes.

Official Persistent Terminal

The Prime preset mounts DSH’s official persistent Terminal:

  • POSIX uses Bash.
  • Windows uses PowerShell.

Tool Result Presentation

Tool results are configured with a 12KB best-effort spill threshold. The model sees the notebook text without a typed shell.

A successful non-undefined completion is automatically kept in a generation-local single slot and is accessible via $_.

Persistent Task Files

Persistent task files are used to hold:

  • Large inputs.
  • Important results.
  • Checkpoints across restarts.

The Realm is live-only: abort, timeout, and OOM will hard-kill the Worker and lose the namespace. State that needs to survive restarts must be explicitly written to persistent task files by the program.

refine

refine is used for stable routing and behavioral experience, with:

  • Evidence-based reasoning.
  • Optimistic concurrency.
  • Transactional history.
  • Safe rollback.

Multi-TUI Process Sharing

Multiple TUI processes can share Prime persistent state and run different Sessions simultaneously.

The live Realm of the same Session can only be held by one process at a time. After the owner exits, another process takes over with an empty namespace.

Installation and Enablement

The plugin runs with the current dsh process permissions. Review the source code and license before installation. The verified materials do not specify the exact license type; the files list in package.json includes LICENSE.

Web Profile Installation

First handle dependencies and checks, then add the plugin:

npm install
npm run check:all
dsh plugin --profile web add ./dsh-prime-agent https://github.com/yoke233/dsh-tool-monitor/archive/9b6aac3701560309ac4e3befcf646a1eca920e77.tar.gz

This completes dependency installation, runs check:all, and adds the local dsh-prime-agent along with the specified dsh-tool-monitor archive to the web profile.

TUI Profile Installation

For TUI scenarios, first run npm pack, then pass the generated $primePackage to dsh plugin --profile tui add:

npm pack
dsh plugin --profile tui add $primePackage https://github.com/yoke233/dsh-tool-monitor/archive/9b6aac3701560309ac4e3befcf646a1eca920e77.tar.gz

After installation, verify the combined result with a configuration dump:

dsh --profile tui --dump-config

Confirm the combined result includes:

  • agent-presets
  • prime-code-runtime
  • monitor-jobs
  • tool-monitor
  • The official tool-subagent-report
  • tui

Then run:

dsh --profile tui

Headless Operation

The current DSH headless bundle does not mount agent presets. Therefore, headless scenarios require installing the prime-headless-shim from the repository and enabling the Prime preset in the headless profile.

The extended commands in the verified materials are incomplete, so we do not expand the full installation steps here. For headless operation, use an isolated DSH_HOME to avoid affecting daily profiles.

Typical Usage

The following example shows two repl calls in the same session. The first cell creates lookup and review, and the second cell reuses them.

repl({ code: `
const lookup = new Map(records.map(item => [item.id, item]))
const review = async (id) => tools.review_item({ item: lookup.get(id) })
lookup.size
` })

The next call continues to reuse the same persistent cell state:

repl({ code: `await review('a') // Map and function are still alive` })

When using repl, note:

  • Tool arguments use TypeScript object literals.
  • The complete cell is parsed before execution.
  • A syntax failure will not execute any code or tool calls within it.
  • After a syntax failure, correct it and retry.
  • Do not blindly JSON.parse the return values of tools.* again.

State and Lifecycle

State Layer Purpose Retention Boundary
Realm live namespace Ordinary top-level variables, functions, objects, Maps, and indices Retained between cells within the same Worker; lost after a hard kill
Latest completion The latest non-undefined cell result, accessed via $_ Replaced by the next non-undefined completion; lost after a hard kill or generation change
Persistent task files Large inputs, important results, and checkpoints across restarts Backed by the filesystem and recoverable after process restarts
refine Stable routing and behavioral experience Evidence-based, optimistic concurrency, transactional history, and safe rollback

Operational Boundaries and Notes

  • Prime preset sessions have only one model-visible tool: repl.
  • Non-Prime sessions continue to use the official one-shot semantics.
  • Routing relies on a trusted exec.agent.id. The plugin resolves a stable opaque Realm id from the shared realm-identity store and passes it to the host-side ctx.primeRealmRuntime.run(...).
  • It fails explicitly when a trusted execution context is missing or the Realm id cannot be resolved—never degrades silently.
  • Direct calls to other tools are rejected by the guard.
  • Prime preset does not mount DSH Plan Mode.
  • Compaction retains DSH’s default policy.
  • The host runtime monitors the immediate parent process that started it. When the Windows parent shell is force-killed, or the macOS/POSIX child process is re-parented, the plugin releases the entire Cordis tree, the Realm Worker, and the Realm leases held by that process, then exits.
  • It targets the foreground dsh lifecycle and does not support intentionally detaching the host from its parent process to run as a daemon.
  • The verified materials do not provide star counts or category fields; the specific license type is insufficiently documented, with only the confirmation that the files list in package.json includes LICENSE.

Conclusion

The value of dsh-prime-agent lies in consolidating DeepSeek Harness’s session tool calls into a persistent TypeScript REPL cell: the model writes continuous programs through the single repl tool, reuses top-level state, calls the preloaded tools, agents, and jobs, and writes anything that needs to survive restarts into persistent task files.

Directory page: https://www.skillhub.cn/plugins/yoke233/dsh-prime-agent

GitHub: https://github.com/yoke233/dsh-prime-agent

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

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

Xiaoye