Ye-Yu-Mo / dsh-llm-proxy

목록에 있음

DeepSeek Harness (dsh) 全局 HTTP 代理插件:undici setGlobalDispatcher + EnvHttpProxyAgent,配置化、热切换、可观测

main모델 소스 보기

설치

npx -y @deepseek-ai/dsh plugin --profile web add github:Ye-Yu-Mo/dsh-llm-proxy

이 설치 명령은 GitHub 저장소 주소에서 생성된 확인되지 않은 시작점입니다.

README

유지 관리자가 작성한 문서 스냅샷입니다.

GitHub에서 보기 ↗
커밋 2679d6c동기화 2026. 8. 17.

dsh-llm-proxy

DeepSeek Harness (dsh) 的全局 HTTP 代理插件:用 undici setGlobalDispatcher + EnvHttpProxyAgent 接管 dsh 所有 LLM 请求的代理路由。配置化、热切换、可观测。

License Node dsh


为什么需要它

dsh(DeepSeek Harness)用 node 内置 fetch(undici)发 LLM 请求,而 undici 默认不读 http_proxy/https_proxy 环境变量。如果你的 LLM 端点(如 llm-proxy 网关)必须走代理才能访问,dsh 会直连超时。

本插件在 dsh 进程内用 setGlobalDispatcher(new EnvHttpProxyAgent(...)) 全局接管 fetch 的代理路由:

  • ✅ 让 dsh 所有 LLM 请求走你配置的代理
  • 热切换:设置变更即时生效,无需重启
  • 可逆:插件停止/禁用时恢复基线 dispatcher,不留进程级残留
  • 可观测/api/llm-proxy/status 查看当前生效模式,/api/llm-proxy/test 测试任意代理连通性

安装

本插件是 bundle 包(dsh.bundle.patch 清单):dsh plugin add 会把它装进 profile 依赖并自动加入 dsh.profile.bundles,下次启动自动激活,无需手动加 patch 行

# 一键安装(发布到 npm 后可直接用包名)
dsh plugin --profile web add dsh-llm-proxy
# 或直接从 GitHub 安装
dsh plugin --profile web add github:Ye-Yu-Mo/dsh-llm-proxy

开发调试(本地 link):

git clone https://github.com/Ye-Yu-Mo/dsh-llm-proxy
dsh plugin --profile web add link:$(pwd)/dsh-llm-proxy

安装后重启 dsh web 使 bundle 补丁生效;~/.dsh/dsh.log 出现 [llm-proxy] 日志(未启用时为「恢复基线」一行)即装载成功。

配置

通过 dsh 设置页的「LLM 代理」项,或直接编辑 ~/.dsh/settings.yaml

llm-proxy:
  enabled: true
  url: http://127.0.0.1:7891        # 你的 HTTP(S) 代理地址
  noProxy:
    - localhost
    - 127.0.0.1
    - ::1
字段类型默认说明
enabledbooleanfalse是否启用代理接管
urlstring''HTTP(S) 代理地址,如 http://127.0.0.1:7891
noProxystring[]['localhost','127.0.0.1','::1']不走代理的地址

⚠️ dsh 设置页只暴露白名单内的配置命名空间。若设置页显示「表单不可用」,需把 llm-proxy 加入 dsh-host-apiproxyWEB_SETTINGS_NAMESPACES(当前为 dsh 已知限制,见下)。

HTTP API

插件注册两个宿主路由(loopback-only,防 LAN 探测):

GET /api/llm-proxy/status

当前生效模式:

{
  "effective": { "mode": "setting", "url": "http://127.0.0.1:7891" },
  "env": { "httpProxy": "http://127.0.0.1:7891", "httpsProxy": "http://127.0.0.1:7891" }
}

mode 取值:

  • setting:走设置的 url
  • env:读环境变量代理(HTTP(S)_PROXY
  • direct:直连(无代理)

POST /api/llm-proxy/test

测试任意代理到目标端点的连通性:

// 请求
{ "url": "http://127.0.0.1:7891", "probeUrl": "https://llm-proxy.ftai.chat/v1/models", "timeoutMs": 8000 }
// 响应
{ "ok": true, "latencyMs": 246, "status": 200 }

开发

pnpm install
pnpm test        # 单元测试(logic/http-utils)
node scripts/... # 见 scripts/

目录结构:

lib/
  index.js       # 宿主核心:settings + dispatcher 接管 + HTTP 路由
  logic.js       # 纯函数配置判定(可单测)
  http-utils.js  # loopback 校验 / JSON 读写
  client.js      # 设置面板「LLM 代理」页
test/            # 单元测试

已知限制

dsh 设置页的配置命名空间白名单(dsh-host-apiproxyWEB_SETTINGS_NAMESPACES)是硬编码的,第三方插件无法自注册暴露。目前需要手动把 llm-proxy 加入白名单才能让设置页表单可用(dsh 官方已将"插件自注册"列为延后工作)。

已在上游提交讨论:Third-party plugins cannot expose settings namespaces to the web settings page(Ideas 分类)。

License

MIT

프로젝트 파일 및 신호

표시된 항목은 디렉터리 스냅샷에서 감지된 공개 저장소 신호입니다.

테스트감지됨

저장소 정보

언어
JavaScript
라이선스
MIT
마지막 업데이트
2026. 8. 17. AM 6:52

신중하게 설치하기

소스 코드, 권한, 수명 주기 스크립트, 의존성 및 네트워크 접근을 검토하고 신뢰하지 않는 플러그인은 격리 환경에서 테스트하세요.