dsh-fetch-header-rewrite —— 可配置的请求头改写插件(User-Agent 等) #3227
MwumLi
started this conversation in
Show Your Plugins!
Replies: 1 comment
|
不能单个控制? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
简介
dsh-fetch-header-rewrite是一个 dsh(DeepSeek Harness)的 cordis 插件:通过 patchglobalThis.fetch,改写 dsh 所有 provider 请求的 HTTP 请求头(如User-Agent、任意自定义头)。一份配置对全部 provider 路由生效,与具体适配器无关。为什么需要
this User-Agent is not allowed by configured policy,把 UA 改为opencode/0.2.1后返回 200。llm-pi-ai还会剥离 profile headers 中的user-agent)。相关讨论
本插件是上述 Bug 场景的临时 workaround:在官方 appIdentity 功能落地前,用它给网关配置允许的 User-Agent(或任意请求头)。若官方提供统一配置能力,届时按需移除本插件,改用官方方案即可。
特性
headers作用于所有请求;可选rules按序匹配、首个命中即停、命中规则与全局合并(同名规则胜出)match支持 URL 前缀,或/pattern/flags正则(对完整 URL 做test,如/^https://corp\.example/i)verbose日志自动脱敏authorization/cookie等凭据头@deepseek-ai/cordis)安装
在 profile 的
cordis.patch.yml挂载:配置示例
改所有请求的 User-Agent:
全局默认 + 按规则精确控制:
链接
node --test、file:挂载、verbose调试)已知局限
fetch发请求(当前 DeepSeek adapter 与 pi-ai 均是);未来若某 adapter 改用自定义 dispatcher 则不在覆盖范围All reactions