1.开源仓库
https://github.com/deepseek-ai/deepseek-harness
如果github访问不稳定,也可以试试gitee, 以下是我fork的一份到gitee
https://gitee.com/SandwichBoy/deepseek-harness.git
2.初始化项目
$ node -v
v16.20.2
Administrator@USER-20230930SH MINGW64 /d/git/deepseek-harness (master)
$ pnpm install
ERROR: This version of pnpm requires at least Node.js v18.12
The current version of Node.js is v16.20.2
Visit https://r.pnpm.io/comp to see the list of past pnpm versions with respective Node.js version support.
可见要求Node.js v18.12 或以上版本
还好我这里有高低版本,切换一下版本, 再安装依赖
$ nvm list
20.11.1
* 16.20.2 (Currently using 64-bit executable)
$ nvm use 20.11.1
Now using node v20.11.1 (64-bit)
$ pnpm install
WARN Unsupported engine: wanted: {"node":"^22.19.0 || >=24.0.0"} (current: {"node":"v20.11.1","pnpm":"9.12.1"})
native/landlock-run/packages/linux-arm64 | WARN Unsupported platform: wanted: {"cpu":["arm64"],"os":["linux"],"libc":["any"]} (current: {"os":"win32","cpu":"x64","libc":"unknown"})
native/landlock-run/packages/linux-x64 | WARN Unsupported platform: wanted: {"cpu":["x64"],"os":["linux"],"libc":["any"]} (current: {"os":"win32","cpu":"x64","libc":"unknown"})
Scope: all 238 workspace projects
WARN There are cyclic workspace dependencies: D:\git\deepseek-harness\packages\api\gateway, D:\git\deepseek-harness\packages\client\connection, D:\git\deepseek-harness\packages\host\apiproxy, D:\git\deepseek-harness\packages\api\remotes; D:\git\deepseek-harness\packages\sandbox\sandbox-local, D:\git\deepseek-harness\packages\sandbox\sandbox-windows-acl; D:\git\deepseek-harness\packages\subagent\subagent-spawn-in-process, D:\git\deepseek-harness\packages\subagent\tool-subagent; D:\git\deepseek-harness\vendor\cordis, D:\git\deepseek-harness\vendor\include
╭───────────────────────────────────────────────────────────────────╮
│ │
│ Update available! 9.12.1 → 11.21.0. │
│ Changelog: https://github.com/pnpm/pnpm/releases/tag/v11.21.0 │
│ Run "pnpm add -g pnpm" to update. │
│ │
│ Follow @pnpmjs for updates: https://x.com/pnpmjs │
│ │
╰───────────────────────────────────────────────────────────────────╯
....
#依赖安装成功
$ pnpm run build
WARN Unsupported engine: wanted: {"node":"^22.19.0 || >=24.0.0"} (current: {"node":"v20.11.1","pnpm":"9.12.1"})
> @deepseek-ai/dsh-root@0.1.0-rc.5 build D:\git\deepseek-harness
> npm run build:lib && npm run build:web
> @deepseek-ai/dsh-root@0.1.0-rc.5 build:lib
> npm run build:lib:host && npm run build:lib:client
> @deepseek-ai/dsh-root@0.1.0-rc.5 build:lib:host
> tsc -b tsconfig.host.json && tsdown --env.DSH_BUILD_FACE host
file:///D:/git/deepseek-harness/node_modules/.pnpm/rolldown@1.1.1/node_modules/rolldown/dist/shared/rolldown-build-abS241_6.mjs:9
import { formatWithOptions, styleText } from "node:util";
^^^^^^^^^
SyntaxError: The requested module 'node:util' does not provide an export named 'styleText'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
Node.js v20.11.1
ELIFECYCLE Command failed with exit code 1.
依赖安装成功,但是build失败了
按建议继续升级 node, node":"^22.19.0 || >=24.0.0
$ nvm install 24.0.0
Downloading node.js version 24.0.0 (64-bit)...
Extracting node and npm...
Complete
npm v11.3.0 installed successfully.
Installation complete. If you want to use this version, type
nvm use 24.0.0
$ nvm use 24.0.0
Now using node v24.0.0 (64-bit)
重新执行以下就正常了
pnpm install
pnpm run build
$ pnpm dsh web
> @deepseek-ai/dsh-root@0.1.0-rc.5 dsh D:\git\deepseek-harness
> node --import tsx/esm apps/cli/src/bin.ts "web"
dsh web: http://127.0.0.1:3080
启动页面会要求你配置API Key

填入API Key就可以enjoy了,记得充值,没有免费token, 哈哈

3.原理结构
3.1.整体架构分层图

3.2.Harness 编排层详细结构

3.3.数据流图

3.4.核心模块交互序列图

3.5.模块依赖关系图

3.6.请求生命周期状态机

3.7.多层级时序图

3.8.部署架构图

3.9.Harness 内部数据总线

3.10.配置与插件体系

这里体现了一切皆可插件的思想
4.DeepSeek Harness 工具调用链路
4.1. 主流程图

4.2.消息结构变换序列图

4.3.多轮工具调用循环

4.4.并行工具调用

4.5.Harness 执行器内部逻辑

4.6.异常处理决策树

4.7.完整状态机

后期等我深度使用再来更新,谢谢。