DSH Uni Editor:把現有 Editor 接入 DeepSeek Harness Agent Chat

前言

如果已有 Editor 希望進入 DeepSeek Harness Agent Chat,讓模型側能調用工具、用戶側能繼續操作界面,而不是每個 Editor 單獨維護一套接入方式,就需要一個統一 Editor runtime。

DSH Uni Editor 由 creativedswork 維護,MIT 許可。它用 MCP Apps 提供統一 Editor runtime,把現有 Editor 帶入 DeepSeek Harness Agent Chat。

這是什麼

DSH Uni Editor 是一個 Cordis 插件包。一個 npm 包提供三類內容:

  • Host plugin
  • Browser bundle
  • 用於激活兩者的 dsh.bundle patch

它的定位是統一 Editor runtime:All Editors, one DSH Editor. Unified Editor runtime for DeepSeek Harness, powered by MCP Apps.

Host 負責自己的 MCP 連接,通過 Harness 暴露模型可見工具,將 app-only 工具留在模型註冊表之外,並通過 different-origin Sandbox Proxy 提供 untrusted Views。這個方案不需要修改 agent loop,也不需要外部 MCP proxy。

核心功能

Editor 接入與工具邊界

DSH Uni Editor 支持以下 MCP 能力:

  • Targets MCP Apps specification 2026-01-26
  • Advertises text/html;profile=mcp-app
  • 支持 stdio 和 Streamable HTTP MCP transports
  • 應用 _meta.ui.visibility;未寫 visibility 時,默認表示 model and app

工具可見性被分成兩類:

  • model-visible tools:通過 Harness 暴露給模型
  • app-only tools:只供對應 View 使用,不進入模型可見工具註冊表

對於結果展示,它會爲模型保留可讀文本,同時把 structuredContent 和 result _meta 保留在 bounded UI-only presentation metadata 中。

Prompt 注入與 Workspace 元數據

DSH Uni Editor 只注入顯式 allowlisted MCP Prompts,並帶 source provenance,注入到 Harness system prompt 中。

prompts.autoInject 是一個顯式信任允許列表。不要從 untrusted Server 添加 prompt,因爲這些內容會獲得 system-prompt authority。

對於 trusted local stdio Server,如果配置 forwardWorkspace: true,DSH Uni Editor 會把 calling Agent 的 immutable workspace cwd 添加到 model-originated tools/call request metadata 中,位置爲:

ai.deepseek.dsh/workspace

這個 workspace 元數據不會被加入以下位置:

  • remote HTTP calls
  • app-originated calls
  • model-visible tool arguments
  • results

View 與交互

DSH Uni Editor 使用官方 AppBridge 和 PostMessageTransport 處理 View lifecycle,以及 app-originated tool/resource calls。

它提供以下交互能力:

  • 在 Header 中保留 Session-scoped Active App entry,並支持多個 MCP App instances
  • 打開 active App fullscreen 時,不重新創建 iframe 或 AppBridge,保留未保存的 View state
  • 通過 Locate in Chat 返回原始 tool message
  • 爲 Sandbox Views 中介 ui/download-file,支持單個 embedded JSON resource,上限 4 MiB
  • View 無法加載時,回退到普通 text tool result

安全邊界

DSH Uni Editor 的 View 運行在隔離環境中:

  • View 位於 double iframe 中
  • 使用 HTTP CSP 和 explicit sandbox attributes
  • 接受 bridge traffic 前,會驗證 postMessage source 和 origin
  • Host APIs reject cross-origin writes
  • Host APIs 對 body 和 metadata 設置有限邊界

Web profile 必須綁定到:

127.0.0.1

插件會拒絕更寬的綁定,因爲 Sandbox Proxy 目前只支持 loopback browsers。

安裝與啓用

下面介紹如何安裝並啓用 DSH Uni Editor。

安裝正式包

先把它安裝到 Web profile:

dsh plugin --profile web add @creative-dswork/dsh-uni-editor

安裝後,bundle 會隨之激活。接下來需要配置它的 mcp-apps 行,配置路徑是:

$DSH_HOME/profiles/web/cordis.patch.yml

關鍵配置項包括:

  • serverName:必須匹配 [A-Za-z0-9_-]{1,32},併成爲 public tool name 的一部分
  • transport:支持 stdio 和 Streamable HTTP
  • forwardWorkspace:默認關閉,只建議爲 trusted local stdio Server 開啓
  • prompts.autoInject:顯式信任允許列表,不要加入 untrusted Server 的 prompt

對於 stdio Server,可配置 command、args、cwd、env、forwardWorkspace 等本地 Server 參數。

對於 transport: streamable-http,它不會接收 Workspace metadata,接受 url 和可選 headers,而不是 command、args、cwd、env。

啓動 Harness

配置完成後,啓動 Harness:

dsh web

注意 Web profile 必須綁定到 127.0.0.1。

典型用法

本地 checkout 安裝

如果你在當前倉庫做本地開發,可以把本地 checkout 安裝到 profile:

dsh plugin --profile web add .

Standalone Counter Demo

倉庫提供了一個 Standalone Counter Demo。下面命令來自 README,用於從當前 checkout 運行 Demo:

pnpm install
pnpm run build
export DSH_HOME="$PWD/.tmp/demo-home"
pnpm dlx @deepseek-ai/dsh@0.1.0-rc.6 plugin --profile web add "$PWD"
pnpm dlx @deepseek-ai/dsh@0.1.0-rc.6 web --patch "$PWD/demo/cordis.patch.yml"

這個 Demo 展示的是 Editor 與 Agent Chat 的組合:模型可見工具觸發 View,app-only 工具只服務於該 View。

適用場景與注意

適合以下場景:

  • 已有 Editor 或 MCP App 希望接入 DeepSeek Harness Agent Chat
  • 需要區分 model-visible tools 和 app-only tools
  • 需要把 allowlisted MCP Prompts 注入 Harness system prompt
  • 需要 Sandbox Proxy、CSP、postMessage origin 校驗
  • 需要 Session Header、fullscreen View、Locate in Chat 等交互
  • 需要本地 stdio Server 或 Streamable HTTP MCP Server

使用前需要注意:

  • 插件以當前 dsh 進程權限運行,安裝前應檢查源碼和許可證
  • Web profile 必須綁定 127.0.0.1,更寬綁定會被拒絕
  • forwardWorkspace 默認關閉,只應開啓給 trusted local stdio Server
  • transport: streamable-http 不會接收 Workspace metadata
  • serverName 必須匹配 [A-Za-z0-9_-]{1,32}
  • prompts.autoInject 是顯式信任列表,不要加入 untrusted Server 的 prompt
  • Tool-list changes 會同步,但 automatic transport reconnection 尚未實現
  • Browser 每五秒刷新一次 catalog
  • 開發環境要求 packageManager 爲 pnpm@11.7.0,node 版本爲 ^22.19.0 || >=24.0.0
  • 發佈需要 NPM_TOKEN,並且該 token 需要有 @creative-dswork scope 權限

鏈接

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

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

小夜