DeepSeek Harness Plugin: dsh-thread-tools

Introduction

The DeepSeek Harness (DSH) runtime does not have built-in session management capabilities. In multi-threaded and multi-agent collaboration scenarios, developers must manually maintain thread state and interactions. Existing approaches either implement a custom thread scheduling logic at the business layer or borrow the thread collaboration tools from the Codex desktop app. The latter, while mature, requires an additional adapter layer for DSH integration. The dsh-thread-tools plugin ports the Codex desktop thread collaboration toolkit 1:1 to DSH. Each DSH session maps to one thread, and a unified API handles thread creation, reading, waiting, messaging, archiving, and deletion.

Plugin Overview

dsh-thread-tools is a workflow-type plugin maintained by Heroicus. It does not depend on external account systems or network services, and relies solely on DSH’s internal APIs (sessionController.prompt, sessionController.wait, sessionQuery.readSurface, etc.) to perform thread management. It is well-suited for agent development and workflow orchestration scenarios that require direct multi-session management within DSH.

Core Features

The plugin provides 10 tools with identical names and parameters to their Codex desktop counterparts, maintaining consistent API semantics:

  • list_threads: List threads. Supports two modes:
  • mode: recent: Returns a list of pinned threads sorted by recency
  • mode: history: Returns a page of threads, supporting cursor and limit pagination parameters
  • list_archived_threads: Lists a page of archived threads, also with pagination support
  • read_thread: Reads the turn summary of a thread. Supported parameters:
  • turnLimit: Limits the number of turns returned
  • includeOutputs: Whether to include output content
  • maxOutputCharsPerItem: Maximum characters per output item
  • cursor: For pagination
  • wait_threads: Waits for multiple threads to complete or require input. Waits for up to 8 threads; returns as soon as any one completes or needs input. Supports a timeoutMs parameter with a maximum of 120000 ms; setting it to 0 means an immediate snapshot (no waiting)
  • send_message_to_thread: Sends a message to a specified thread. The message is wrapped in a <codex_delegation><source_thread_id>…</source_thread_id><input>…</input></codex_delegation> envelope
  • create_thread: Creates a new thread. Optionally includes an initial prompt, dispatched asynchronously
  • fork_thread: Duplicates a thread (including history) into a new independent thread
  • set_thread_title: Renames a thread
  • set_thread_archived: Archives or unarchives a thread. Archived threads reject incoming messages
  • delete_thread: Permanently deletes a thread and its persisted logs

The hostId and source parameters are signature-compatibility parameters; in the current installation context, there is only one host.

Implementation Details

  • Messaging goes through the same path as the host’s human client via sessionController.prompt. Cold sessions are automatically restored, busy sessions are queued, and log and title semantics match those of manual user input
  • wait_threads uses sessionController.wait and continues waiting in the case where a message is still being enqueued but the session has already gone idle, preventing premature responses
  • read_thread uses sessionQuery.readSurface to fold the event stream, filtering out <system-reminder> and time-injection blocks, retaining only user prompts and model replies
  • Read-only operations do not call sessionController.state(), avoiding accidental waking of cold sessions
  • Archive/pin state is stored in $DSH_PROFILE_DIR/session-bus/state.json (atomic writes)
  • DSH does not expose a public “remove loaded session” API. delete_thread first cancels any running turn, then deletes the on-disk logs; in-memory copies will disappear on the next restart. The return value includes clearedFromMemory: false to indicate this

Installation & Activation

Local directory installation:

  1. Clone or extract this repository to a local directory
  2. Open the “Plugins” menu in DSH
  3. Select “Add Plugin” and point to the local directory
  4. Or use plugin_manager’s install_bundle in a session, pointing to this directory

The plugin has no dependencies and no build step. index.js is the entire implementation.

Typical Usage

Create a thread and send the initial prompt:

// Create a thread
const thread = await create_thread({
  prompt: "Help me analyze the code changes from the past week"
});

// Wait for the thread to complete
await wait_threads({
  threadIds: [thread.id],
  timeoutMs: 60000
});

// Read the thread summary
const summary = await read_thread({
  threadId: thread.id,
  turnLimit: 10
});

Send a message across threads:

await send_message_to_thread({
  threadId: "target-thread-id",
  input: "Please continue the derivation based on the previous turn's conclusion"
});

Archive and delete:

await set_thread_archived({
  threadId: "thread-id",
  archived: true
});

await delete_thread({
  threadId: "thread-id"
});

Use Cases & Caveats

  • Ideal for developers and workflow orchestration scenarios that require direct multi-session and multi-agent collaboration within DSH
  • The plugin runs with the current DSH process permissions. Review the source code and license before installing
  • Compared to the Codex desktop, it lacks tools that depend on account systems or host networking (e.g., handoff_thread, share_thread, list_projects, get_usage_limits), and does not provide state setters like set_thread_pinned or set_thread_read_state (the DSH sidebar does not consume these states)

Conclusion

dsh-thread-tools provides DSH with a thread collaboration toolkit aligned with the Codex desktop, implementing thread creation, reading, waiting, messaging, archiving, and deletion through a unified interface. If you are doing multi-agent development or workflow orchestration in DSH, this plugin can reduce the boilerplate code for manual session management while improving the reliability and consistency of interactions.

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

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

Xiaoye