Asaiuta/dsh-custom-header ↗★ 0
dsh-custom-header
Outbound LLM request header modification for DeepSeek Harness (DSH): client-identity header presets (Codex / Claude Code / opencode), per-request dynamic headers, X-Stainless fingerprint stripping, URL rewriting and Anthropic body patching at the fetch transport layer.
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Asaiuta/dsh-custom-header说明文档
阅读完整 README ↗dsh-custom-header
DeepSeek Harness(DSH)出站 LLM 请求头修改插件。
工作在 fetch 传输层——比 LLM SDK 低一层——对出站 provider 请求的 HTTP 头做修改:
- 注入客户端身份头(
User-Agent、Originator、X-Claude-Code-Session-Id、x-opencode-*等),预设头集仿照真实 Codex / Claude Code / opencode 客户端 - 剥离 SDK 运行时指纹头(
X-Stainless-*) - 重写请求 URL(路径匹配 +
appendQuery) - 补丁 Anthropic Messages 请求体(identity / billing system 块 +
metadata.user_id)
所有修改受显式主机白名单(autoHosts)约束——白名单外的请求一律不碰;
默认 auto profile 且白名单为空时,所有请求原样放行。
仅用于你有权管理的服务器或已授权环境。Cloudflare 的 TLS/Bot 边缘拦截 需要不同的 API 入口、管理员白名单或本地正向代理(见下文故障排查)。
工作机制
DSH 没有按请求注入头的钩子,因此所有修改都落在 fetch 传输层,共用
一条共享中间件管道(Symbol.for("dsh-custom-header.fetch.pipeline.v1")):
| 机制 | 中间件 | 安全门 |
|---|---|---|
| 头注入 | header-inject(priority 7) | auto 需 host 匹配;固定 profile 始终注入 |
| 指纹头剥离 | header-strip(priority 6) | 仅 autoHosts 主机 |
| Anthropic body 补丁 | body-patch(priority 8) | 仅 Anthropic Messages 路径 |
| URL 重写 | url-rewrite(priority 5) | 仅 autoHosts 主机 |
| 会话 id 隔离 | 按 GenerateOptions.sessionId 隔离(AsyncLocalStorage 传递到 fetch 层,见 session-context.ts) | — |
| 403 诊断 | llm/stream 瀑布观察器(终态 403) | — |
安全默认:profile: "auto" 且 autoHosts 为空 → 什么都不做。
预设(profiles)
每个固定预设是一整套完整的客户端身份头:
| Profile | 发送的头 |
|---|---|