Tools & Capabilities

deepseek-harness-sdk-rs

loner1024/deepseek-harness-sdk-rs · ★ 1

loner1024

Rust SDK for driving DeepSeek Harness. The SDK spawns the harness runtime as a subprocess and speaks the line-delimited JSON-RPC 2.0 protocol over its stdio. The runtime is the…

License
MIT
Added
2026-08-23
Maintenance
active
Install kind
github

No manifest check is available; listing does not imply compatibility or security review.

安装

dsh plugin --profile web add github:loner1024/deepseek-harness-sdk-rs

GitHub 源码安装:首次需按提示配置 allowBuilds 构建授权后重试

For install and environment setup, plus plugin development tutorials, see DSH community docs ↗

README

Source README · body: en · Read Chinese README

Table of contents
  1. Installation
  2. Quick start
  3. Packages
  4. Behavior
  5. Examples
  6. Relationship to DeepSeek Harness
  7. Contributor workflow

English | 中文

Tests crates.io docs.rs

Rust SDK for driving DeepSeek Harness. The SDK spawns the packaged dsh CLI (--profile sdk) as a subprocess and speaks the line-delimited JSON-RPC 2.0 protocol over its stdio. The CLI and its sidecars are distributed in the deepseek-harness-runtime-bin wheel also used by the Python SDK; the Rust client is a clean-room reimplementation of the protocol, mirroring the Python SDK's layering.

Installation

cargo add deepseek-harness-sdk-rs@0.2.1-rc.2

The default runtime-download feature fetches the platform dsh runtime wheel from PyPI on first use and caches it; no system Node.js is required. The repository pins Rust 1.97.1.

Quick start

[dependencies]
deepseek-harness-sdk-rs = "0.2.1-rc.2"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Set the provider key and an isolated Harness home:

export DEEPSEEK_API_KEY=sk-your-key-here
export DSH_HOME=/absolute/path/to/isolated-dsh-home
use deepseek_harness_sdk_rs::{DeepSeekHarness, DeepSeekHarnessConfig, RunOptions};

#[tokio::main]
async fn main() -> Result<(), deepseek_harness_sdk_rs::SdkError> {
    let harness = DeepSeekHarness::new(DeepSeekHarnessConfig::default());
    let result = harness.run("Say hi.", &RunOptions::default()).await?;
    println!("{}", result.final_response);
    harness.close().await;
    Ok(())
}

Every managed launch requires DSH_HOME or dsh_home; the SDK never discovers ~/.dsh. Reuse the same home and session id to continue a conversation. See the SDK reference for sessions, notifications, subagents, and custom profiles.

Packages

Directory Crate Responsibility
sdk deepseek-harness-sdk-rs High-level turn API, low-level JSON-RPC client, and the runtime downloader

Behavior

The SDK launches the runtime lazily and owns it across run() calls. Managed launches require an explicit Harness home (dsh_home or a non-empty DSH_HOME); the SDK never discovers ~/.dsh implicitly. Explicit launch_args_override callers own their argv and environment. The sdk profile and optional ordered patches are passed as --profile/--patch arguments. With no explicit launch channel, the runtime-download feature (default) fetches the platform runtime wheel from a PyPI-style index, verifies its digest, and caches the dsh executable, its ripgrep sidecar, and the platform resources; explicit runtime_bin or command/args callers can disable the feature.

Low-level parity with the Python SDK includes per-call request timeout overrides, timeout diagnostics from the runtime's stderr tail, symlink-resolved cwd/runtime_cwd handling, notification-filter failure containment, native user questions with cancellation, opt-in approval requests, persisted session resume, session working-directory reads and changes, and session/wait. Initialization carries reasoningEffort, maxTokens, and the question/approval opt-ins. SDK reference covers lifecycle, results, notifications, runtime selection, configuration, and errors.

Examples

Example What it shows
simple One-task run through the downloader; uses $DSH_HOME or a temporary home.
resolve Resolve the platform runtime through the downloader and print its path.
deep_research Deep research: web_search/web_fetch plus the subagent tool in the default sdk profile, with subagent reports rendered from the notification stream.
export DEEPSEEK_API_KEY=sk-your-key-here
export DSH_HOME=/absolute/path/to/isolated-dsh-home
cargo run --example deep_research -- "self-hosted vector databases"

Relationship to DeepSeek Harness

This repository is the standalone home of the Rust SDK. The runtime it drives is the dsh CLI published as deepseek-harness-runtime-bin by the DeepSeek Harness project; the SDK speaks that runtime's documented stdio JSON-RPC protocol and pins its own version of the runtime wheel for testing. The crate version tracks the targeted wheel release and is spelled PEP 440 for PyPI (0.2.1-rc.2 → 0.2.1rc2). Contributions land as pull requests to this repository, which also owns crates.io publication of deepseek-harness-sdk-rs through Trusted Publishing.

Contributor workflow

Build and test with cargo fmt --all, cargo clippy --all-targets --features test-support -- -D warnings, and cargo test --features test-support; the test-support feature builds the dsh-fake-runtime binary the mechanism-tier tests drive. Formatting settings live in rustfmt.toml; Clippy enables its pedantic group, with narrow documented allows for internal panic invariants and doc-section boilerplate. CI runs the keyless smoke tier against the real runtime executable downloaded from PyPI; locally it self-skips without DSH_TEST_RUNTIME_EXE.