re-ITRT/dsh-keyring0

dsh-keyring

DeepSeek Harness 密钥保险库插件:密钥自动脱敏、自动收纳、密码本设置页、跨重启持久(官方 profile bundle)

包名
dsh-keyring
版本
0.1.0
许可证
MIT
最近更新
2026年8月22日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:re-ITRT/dsh-keyring

dsh-keyring

DeepSeek Harness(dsh)密钥保险库插件:密钥自动脱敏、自动收纳、密码本设置页、跨重启持久。 以官方 profile bundle(npm 包)形态安装,重启 dsh web 后自动加载,数据不丢。

功能

  1. 密钥自动脱敏(进模型上下文前)
    • 覆盖常见敏感项(规则参照 Hermes redact.py):
      • 厂商前缀 token:ghp_ / github_pat_ / gho_sk- / sk-ant-AIza(Google)、AKIA(AWS)、xox* / xapp-(Slack)、hf_glpat- 等 GitLab 全家桶、npm_pypi-、Stripe / Telegram / JWT / 私钥块等。
      • 赋值形态:KEY=value 环境变量、YAML/JSON 字段(password: …"apiKey":"…")、Authorization: / x-api-key: 请求头。
      • 其它:DB 连接串密码、URL 裸 token、E.164 手机号(手机号只脱敏、不收纳)。
    • 遮罩规则:短 token( 若从 git 安装,需要 prepare 脚本 + pnpm-workspace.yamlallowBuilds(见官方 publish.md)。

开发与验证

本插件在克隆的 deepseek-harness 仓库内作为 workspace 成员开发(复用仓库依赖), 以独立 DSH_HOME + 独立端口跑隔离测试环境,绝不触碰生产 ~/.dsh

# 构建 host + client
pnpm --filter dsh-keyring run build
# 或直接:
../../node_modules/.bin/tsc -p tsconfig.json
node scripts/build-client.mjs

# 一键验收(类型检查 + 37 项功能验证)
bash verify-all.sh

# 隔离环境安装(独立 DSH_HOME)
DSH_HOME=$PWD/test-home pnpm dsh plugin --profile web add ./plugin-dev/dsh-keyring

# 隔离环境启动
DSH_HOME=$PWD/test-home pnpm dsh --profile web --no-open --port 3091

结构

src/redact.ts    脱敏引擎(Hermes 规则移植 TS,输出命中列表 + 遮罩文本)
src/store.ts     KeyringStore 服务:全局凭据持久 + 会话内存
src/bridge.ts    脱敏桥:agent/pre-step + tools/post-execute + agent/disposed 清理
src/tools.ts     keyring_store/get/list/unset 模型工具
src/remote.ts    keyring Remote(host 侧,供设置页 CRUD)
src/config.ts    Schemastery 配置 schema
client/          浏览器半:设置页「密码本」UI(remote.ts 描述符 + index.tsx)
cordis.patch.yml bundle patch(id: keyring, name: dsh-keyring)
scripts/build-client.mjs  client bundle 构建(esbuild + __ModuleLoader__ 外壳)

参考