jinsiyu/dsh-webproxy-router-plugin ↗★ 0
dsh-webproxy-router-plugin
Proxy Router: route listed hostnames through an HTTP/SOCKS proxy for ctx.web fetches (host plugin) + settings card (client bundle)
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:jinsiyu/dsh-webproxy-router-plugin说明文档
阅读完整 README ↗Proxy Router — 静态插件(官方 npm 包形态)
将 ctx.web 抓取请求按 hostname 规则路由到 HTTP/SOCKS 代理的静态插件:host 插件 + dsh.client 声明的 client bundle(设置卡片),经 profile 组合加载,参数经官方 settings 服务持久化。
包结构
dsh-webproxy-router-plugin/
package.json main lib/index.js;types lib/types/index.d.ts;
exports: {".", "./client", "./package.json"};dsh.bundle + dsh.client {platform: web}
src/index.ts 插件源码(TS):name / inject / apply
src/env.d.ts 裸环境类型声明(tsc 用)
lib/index.js 构建产物(host 插件入口;git 忽略,由 build.mjs 生成)
lib/types/index.d.ts 构建产物(声明文件,官方布局;git 忽略)
lib/client.js 手写 client bundle(官方格式 window.__ModuleLoader__.load),设置卡片;git 保留
build.mjs 构建脚本(两遍 tsc:lib/index.js + lib/types/index.d.ts)
tsconfig.json 类型检查配置
.gitignore 忽略 node_modules / 构建产物 / *.tgz / 缓存
node_modules/ 开发期依赖(npm install;运行期依赖由 profile 安装 tarball 时物化)
*.tgz pnpm pack 产出的分发包(dsh-webproxy-router-plugin-0.1.0.tgz)
服务与扩展点
| 能力 | 机制 |
|---|---|
| 请求路由 | ctx.web.registerFetchProvider({id:'proxy-router'}):命中规则的 hostname 走代理,其余直连 |
| 请求引擎 | node-fetch + https-proxy-agent(http/https 代理)/ socks-proxy-agent(socks);CONNECT 隧道、TLS、chunked、重定向跟随由库处理;200KB 截断 + 超时由宿主封装 |
| 管理工具 | ctx.tools.register:proxy_manage(set_proxy / clear_proxy / add / remove / list / test) |
| 配置持久化 | ctx.settings.register('proxy-router', z.object({proxy, rules}));变更经 scope.update 写入 settings 文档;scope.watch 同步外部修改 |
| 设置卡片 | client bundle 在 settings.plugin.item(设置→插件→插件配置)注册折叠卡片(id proxy-router,order 30);数据通道走官方 ctx.webServer JSON API(GET/POST /proxy-router/config、POST /proxy-router/test)——当前 DSH 版本的配置客户端边界(dsh-host-apiproxy 的 WEB_SETTINGS_NAMESPACES 白名单,注释声明插件自行暴露配置为延后工作)不暴露第三方命名空间,settingsScope/describe 对 proxy-router 返回 unavailable,故卡片不依赖它;表单按官方模式构建:GET 响应附带序列化 schema → 官方 rehydrateSchema 还原活校验器、setPath/deletePath 编辑草稿、validateDraft 校验(与宿主同一份 schema),控件用官方 primitives Input/Button,写入由宿主权威校验;卡片外壳复刻内置 PluginCard 外观(内嵌发行包 CSS 类 YyYd_a_* / At1oFq_* 排版,展开箭头用官方 IconChevronDownOutline14) |