DeepSHPlugins
dsh-api 專案預覽
GITHUB / COMMUNITY PROJECT

dsh-api

生態與開發JavaScriptMIT

把 dsh 內部能力(語言、工作區登錄檔、agent-status 與 approval 事件)以 HTTP 路由的形式暴露在 dsh 已監聽的本地迴環 socket 上,字首 /dsh-api,並透過 /dsh-api/events 提供 SSE 事件推送。

2 Starslilming123 更新時間 2026-08-19
訪問 GitHub 倉庫
dsh-api 專案預覽

專案介紹

中文

把 dsh 內部能力(語言、工作區登錄檔、agent-status 與 approval 事件)以 HTTP 路由的形式暴露在 dsh 已監聽的本地迴環 socket 上,字首 /dsh-api,並透過 /dsh-api/events 提供 SSE 事件推送。

English

Exposes dsh's internal capabilities (language, workspace registry, agent-status and approval events) over HTTP under /dsh-api on the local loopback socket dsh already listens on, with SSE fan-out at /dsh-api/events.

專案資訊與收錄訊號

快照 2026-09-11
作者 / 組織
lilming123
倉庫
lilming123/dsh-api
GitHub Stars
2
Forks
0
開發語言
JavaScript
許可證
MIT
最近推送
2026-08-19
Manifest
資料中檢測到宣告

公開倉庫不自動等於可商用;許可證與當前相容性以原專案文件為準。Manifest 和資料評分不構成安裝安全認證。

資料評分

57/ 100
維護活躍
85
文件與實用資訊
85
生態關注度
14
安裝便捷訊號
100
專案宣告訊號
100

近 23 天仍在更新;README 含完整安裝與使用說明;關注度尚低(2)。

評分來自已有資料快照的五維模型,僅作瀏覽參考,不是實際使用評測或安全檢測結論。

安裝與使用

所有專案資料與許可均以對應 GitHub 倉庫為準。

dsh plugin --profile web add github:lilming123/dsh-api

複製命令不會自動執行。請先閱讀倉庫文件,確認環境要求與許可證。

專案截圖

倉庫 README

GitHub 原文

已儲存的倉庫文件快照;文件抓取時間未記錄,可能與上方目錄介紹處於不同版本。安裝前請核對當前倉庫說明。

儲存庫檔案保留原文,指令與授權文字不作自動改寫。

dsh-api — HTTP control-plane plugin for DeepSeek Harness

ci license: MIT

dsh-api is a first-party plugin for [DeepSeek Harness (dsh)][dsh] that exposes dsh's own internal capabilities on the loopback HTTP socket dsh is already listening on. Any process on the same machine — a desktop wrapper, a browser extension, a CLI, an editor integration — can drive dsh through one uniform entry point, instead of reaching into its in-process services directly.

  • Route prefix (default): /dsh-api
  • Binds only where dsh already binds (127.0.0.1)
  • Zero runtime dependencies beyond Node itself

[dsh]: https://www.npmjs.com/package/@deepseek-ai/dsh

Install

# From GitHub (any dsh profile):
dsh plugin --profile web add github:lilming123/dsh-api

# From npm (once published):
dsh plugin --profile web add dsh-api

dsh plugin is a thin pnpm wrapper. Both forms drop the package into $DSH_HOME/profiles/<profile>/node_modules/ and register dsh-api in the profile's bundle list — the next dsh web picks it up automatically, no --patch flag needed.

The desktop app [dsh-desktop][dsh-desktop] detects an already-installed dsh-api and skips its bundled fallback; you only need to install this plugin manually if you drive dsh directly.

[dsh-desktop]: https://github.com/lilming123/dsh-desktop

Endpoints

Two layers, mounted under the same /dsh-api prefix:

1. Native (always available once the plugin is loaded)

MethodPathPurpose
GET/dsh-api/healthLiveness + basic identity (dsh port, cwd, companion?)
GET/dsh-api/languageRead locale.preference
POST/dsh-api/languageWrite locale.preference (`{ "language": "zh"\"en" }`)
GET/dsh-api/workspace/listList every workspace known to workspaceRegistry
GET/dsh-api/workspace/currentCurrent cwd + companion snapshot (if registered)
POST/dsh-api/workspace/create{ path, title? } — register a new workspace entry
GET/dsh-api/eventsServer-Sent Events stream (see below)

2. Companion-bridged (needs a registered companion process)

A "companion" is any local process that writes $DSH_HOME/dsh-api-companion.json with { port, token, pid, ... } and serves the /companion/* protocol. These routes are 503 when no companion is registered; the native routes above keep working regardless.

MethodPathPurpose
GET/dsh-api/companion/stateCompanion state snapshot
POST/dsh-api/workspace/openSwitch dsh cwd (restarts dsh under the companion)
POST/dsh-api/input/paste{ text } — inject text into the dsh UI
POST/dsh-api/window/showFocus the host window
POST/dsh-api/window/reloadReload the host window
POST/dsh-api/app/quitQuit the host app

/dsh-api/events (Server-Sent Events)

Long-lived HTTP GET producing named SSE frames:

event: ready
data: {"timestamp":1730000000000}

event: agent-idle
data: {"sessionId":"…","title":"…","previousStatus":"running","timestamp":…}

event: approval-needed
data: {"sessionId":"…","kind":"…","summary":"…","timestamp":…}

event: heartbeat
data: {"timestamp":…}
  • agent-idle fires when any agent/status event transitions running → idle.
  • approval-needed is a read-only bypass of dsh's approval/request

waterfall — the plugin observes the request, broadcasts a summary, and passes control back to the real answerer chain unchanged.

  • heartbeat is emitted every 25 seconds so proxies don't idle-kill the

connection.

  • On dsh shutdown, subscribers receive a server-stopping event before the

socket closes.

Security

  • dsh binds 127.0.0.1 only; this plugin reuses that socket.
  • Mutating requests validate Origin: no Origin header (CLI) and

loopback origins are allowed; anything else is 403.

  • Companion-bridged routes forward the discovery-file token in

x-dsh-api-companion-token; the companion is expected to reject mismatches.

Configuration

The plugin exposes two knobs, both settable in the loader entry's config: { ... }:

KeyDefaultPurpose
basePath/dsh-apiHTTP route prefix
companionFile$DSH_HOME/dsh-api-companion.jsonCompanion discovery file to read on demand

Example ($DSH_HOME/profiles/web/cordis.patch.yml):

- id: dsh-api
  config:
    basePath: /control

Development

dsh-api is a plain-ESM plugin — no build step. Clone the repo, drop the file into a dsh profile, and start dsh with --patch:

git clone https://github.com/lilming123/dsh-api.git
cd dsh-api

# One-time: expose to a profile as a live-edit checkout
mkdir -p "$DSH_HOME/profiles/web/dsh-api-dev"
ln -sf "$PWD/index.mjs" "$DSH_HOME/profiles/web/dsh-api-dev/index.mjs"
cat > /tmp/dsh-api-dev.patch.yml <<'YML'
- insert:
    - id: dsh-api-dev
      name: ./dsh-api-dev/index.mjs
YML

dsh web --patch /tmp/dsh-api-dev.patch.yml --port 3181

# In another shell:
curl http://127.0.0.1:3181/dsh-api/health
curl -N http://127.0.0.1:3181/dsh-api/events

More runnable snippets live under examples/: curl.sh walks every endpoint, and events.mjs is a dependency-free Node SSE subscriber.

Troubleshooting

/dsh-api/* returns 404. The plugin isn't loaded. Check that ~/.dsh/profiles/web/package.json lists dsh-api under dsh.profile.bundles, and that ~/.dsh/profiles/web/node_modules/dsh-api exists. Re-run dsh plugin --profile web add dsh-api if either is missing.

/dsh-api/workspace/create returns 503. workspaceRegistry isn't in the current dsh context — either your dsh predates the service or a profile patch has stripped it. Upgrade dsh (npm i -g @deepseek-ai/dsh) and try again.

**/dsh-api/*/companion routes return 503.** No companion is registered. This is expected when you run dsh directly rather than through a wrapper like [dsh-desktop][dsh-desktop]; the native routes (/health, /language, /workspace/*, /events`) work regardless.

SSE stream disconnects every ~60 seconds. A reverse proxy is idle-killing the stream despite our 25-second heartbeat frames. Bump its idle timeout, or drop the proxy — dsh-api binds to 127.0.0.1 and doesn't need one.

[dsh-desktop]: https://github.com/lilming123/dsh-desktop

License

MIT © 2026 lilming123

使用前核對

安裝步驟、相容版本與授權範圍以原專案當前文件為準。Stars 和評分是快照中的導航訊號。

安裝與排錯 · 專案問題反饋

同類專案