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 使用官方 AppBridgePostMessageTransport 处理 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,可配置 commandargscwdenvforwardWorkspace 等本地 Server 参数。

对于 transport: streamable-http,它不会接收 Workspace metadata,接受 url 和可选 headers,而不是 commandargscwdenv

启动 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
  • 开发环境要求 packageManagerpnpm@11.7.0node 版本为 ^22.19.0 || >=24.0.0
  • 发布需要 NPM_TOKEN,并且该 token 需要有 @creative-dswork scope 权限

链接

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

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

Xiaoye