mc-lhz/dsh-add-headers-to-completions

为dsh的ChatCompletions请求添加headers,可用于接入OpenCode的免费v4-flash、hy3等模型。

Project Overview项目介绍

This is a native plugin built exclusively for DeepSeek Harness that injects custom HTTP headers into LLM API requests. It supports adding headers at three levels: global, per provider, and per model, and uses a soft replacement design that lets its custom settings coexist with the official Models page without overwriting existing functionality. To install, you first need to clone or download the repository to your local machine, then run the install script with Node.js, which requires version 20 or newer. Before installing, you must have already launched DSH web once to generate the required directory structure.

After installing the plugin, you need to apply two required patches to the DeepSeek Harness source code. The first patch adds the plugin's settings namespace to the allowlist so it is visible in the UI, and the second patch enables overriding the default User-Agent header. You do not need to edit the source code manually; you can just copy the provided prompts and paste them into your AI coding assistant to apply the changes automatically. This plugin is ideal for DSH users who need to access custom LLM providers or route requests through proxies that require specific headers.

This plugin supports both UI-based configuration and direct YAML editing for advanced users, and includes a one-click uninstall script to remove the plugin easily. There are a few limitations to note: model-level header injection only works on the fetch layer and does not sync to provider channels, and only User-Agent can be overridden from the default attribution headers. If you upgrade DeepSeek Harness, the patches will be overwritten, so you will need to re-apply them after upgrading to keep the plugin working. If you inject special headers like content-length or host, you are responsible for ensuring their semantic correctness.

这是一个专为 DeepSeek Harness 开发的原生插件,核心功能是向大模型 API 请求注入自定义 HTTP 请求头,例如 User-Agent、x-company 等自定义头,支持全局、按提供商、按模型三个层级的注入规则。插件采用软替换设计,新增的设置区块可以和官方模型设置页面共存,不会影响原有功能使用。安装要求 Node.js 版本不低于 20,且目标机器已成功启动过一次 DSH web 端生成对应目录。

用户安装后需要对 DSH 源码打两个必需补丁,一个是开放插件设置命名空间可见性,另一个放开 User-Agent 自定义覆盖,补丁可以直接让 AI 编码助手完成修改,无需手动操作。配置完成后,设置界面会新增「请求头」区块,支持三层可视化编辑,配置变更会自动同步到对应的 API 通道,改动实时生效。适合需要自定义请求头接入特殊模型或代理服务的 DSH 用户使用。

插件支持 YAML 直写配置,适配高级用户需求,卸载也提供了一键脚本,操作便捷。当前存在一些限制:按模型层级的注入仅在 fetch 层生效,不参与通道同步;除 User-Agent 外,其他 attribution 保留头仍不可覆盖;注入特殊头需要用户自行保证语义正确。升级 DSH 后需要重新打补丁,用户需要注意这一点。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 2 warnings2 项注意
  • No license declared - all rights reserved by default; ask the author before commercial use or redistribution未声明开源许可证 —— 默认「保留所有权利」,商用或再分发前先问作者
  • Only 3 stars - very few users, little community feedback星标只有 3,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add github:mc-lhz/dsh-add-headers-to-completions

把 mc-lhz/dsh-add-headers-to-completions 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-llm-headers

给 DeepSeek Harness 的模型请求注入自定义 HTTP 请求头的 bundle 插件(软替换:独立设置区块,与官方 Models 页共存)。

它能做什么

  • 向大模型请求注入自定义 HTTP 请求头,如 User-Agent、x-company、x-model-trace 等
  • 支持全局、按 provider、按模型注入

安装

前置:Node ≥ 20(install.mjs 无需 pnpm;dsh plugin 方式需要 pnpm)。目标机的 %DSH_HOME%\profiles\web 需已存在(先成功启动过一次 dsh web)。

1.克隆仓库/下载ZIP包

git clone https://github.com/mc-lhz/dsh-add-headers-to-completions.git
cd dsh-add-headers-to-completions

2.安装

node ./install.mjs

3.重启 dsh web(浏览器硬刷新 Ctrl+F5 加载新客户端)

dsh web

若 dsh 命令未全局安装,用你平时的启动方式(如 harness 源码目录下的 node --import tsx/esm apps/cli/src/bin.ts --profile web)。

harness 补丁(必需,本地改动,升级 harness 后需重打)

为什么必需:补丁1(设置命名空间可见):设置命名空间默认对插件不可见;补丁2:user-agent 是 harness attribution 的保留名(适配器会过滤部署 UA 再补 deepseek-harness/...)。这两个行为必须改源码。 不用手动改——复制下面两段提示词,分别粘贴给DeepSeek Harness或其他 AI 编码助手,它会在你的 harness 源码目录完成修改;提示词已带幂等与校验。 目标目录:harness 源码根目录(packages/... 所在层)。

【dsh-llm-headers 补丁 1/2 · 设置命名空间白名单】
目标文件:harness 源码根目录/packages/host/apiproxy/src/api-proxy.ts

请在该文件中做一处小修改(只改这一处,不得改动文件其它任何内容):
把:
  const WEB_SETTINGS_NAMESPACES = [
    'agent-loop', 'shell', 'locale', 'permission', 'ui-conversation', 'ui-theme', 'web-search-deepseek',
  ] as const
替换为:
  const WEB_SETTINGS_NAMESPACES = [
    'agent-loop', 'shell', 'locale', 'permission', 'ui-conversation', 'ui-theme', 'web-search-deepseek',
    // dsh-llm-headers: user-installed plugin's own settings section (soft
    // replacement, coexists with the official Models page). The namespace is
    // registered by the plugin; this allowlist is the exposure gate for the
    // settings configuration clients.
    'dsh-llm-headers',
  ] as const

规则:若文件里已存在行 'dsh-llm-headers',(含注释)则说明已打过,直接报告“已打过,跳过”并结束;
替换前先确认锚文本完全匹配(含缩进);完成后显示被替换位置的上下文供核对。
背景:缺它时,插件设置的 dsh-llm-headers 命名空间对设置页/GUI 不可见(回答 settings-not-exposed)。
【dsh-llm-headers 补丁 2/2 · 放开 user-agent 覆盖】
目标文件:harness 源码根目录/packages/llm/llm-pi-ai/src/adapter.ts

请把 requestHeaders 函数整体替换(函数签名保持不变):
原函数:
  function requestHeaders(headers: Readonly<Record<string, string>> | undefined): Record<string, string> {
    const deployment = headers ?? {}
    const attribution = attributionHeaders()
    const reserved = new Set(Object.keys(attribution).map(name => name.toLowerCase()))
    const kept = Object.fromEntries(
      Object.entries(deployment).filter(([name]) => !reserved.has(name.toLowerCase())),
    )
    return { ...kept, ...attribution }
  }
替换为:
  function requestHeaders(headers: Readonly<Record<string, string>> | undefined): Record<string, string> {
    const deployment = headers ?? {}
    const attribution = attributionHeaders()
    const reserved = new Set(Object.keys(attribution).map(name => name.toLowerCase()))
    // 本地增强(dsh-llm-headers):部署显式配置的 user-agent 允许胜出 ——
    // 这是本 build 唯一允许部署覆盖的 attribution 名;其余保留名仍以
    // Harness attribution 为准(过滤部署同名头、attribution 最后合并)。
    const deploymentHasUserAgent = Object.keys(deployment).some(name => name.toLowerCase() === 'user-agent')
    const kept = Object.fromEntries(
      Object.entries(deployment).filter(([name]) => {
        const lower = name.toLowerCase()
        return !reserved.has(lower) || lower === 'user-agent'
      }),
    )
    const keptAttribution = Object.fromEntries(
      Object.entries(attribution).filter(([name]) => {
        const lower = name.toLowerCase()
        return lower !== 'user-agent' || !deploymentHasUserAgent
      }),
    )
    return { ...kept, ...keptAttribution }
  }

规则:若文件里已存在注释行“本地增强(dsh-llm-headers)”则说明已打过,直接报告“已打过,跳过”并结束;
替换前先确认原函数文本完全匹配;完成后显示新函数头几行供核对。
背景:缺它时,部署在 llm-pi-ai.providers.*.headers 里配置的 User-Agent 会被过滤,
请求最终带上 deepseek-harness/<版本> 的 UA;打过之后显式配置的 UA 才能胜出。

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-whale-background 下一个 Next dsh-ops-console →