treg
superdesigndev
OpenRouter for agent tools. Join community here: https://discord.gg/6mQYYfFMAn
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:juntaoqian/dsh-vars
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
DeepSeek Harness(DSH)变量插件:新建带类型和初始值的变量,通过本机 HTTP GET / POST 读写,并支持 WebSocket 变化订阅、可选 Bearer token、本机 IP/端口展示。
string / number / boolean / jsonGET /set 查询参数,或 POST /variables/<name> JSON bodyGET /all(等价于 GET /variables)ws://127.0.0.1:<DSH_PORT>/dsh-vars/api/events/health、/info 除外)~/.dsh/plugins/dsh-vars/variables.json(0600、原子写入)仓库:https://github.com/juntaoqian/dsh-vars
安装 DSH 插件:https://github.com/juntaoqian/dsh-vars,进目录执行 `node scripts/install.mjs --profile desktop`,然后完全退出并重开 DeepSeek Harness,确认「设置 → 变量」出现,并告诉我怎么用 curl 修改变量。
git clone https://github.com/juntaoqian/dsh-vars.git
cd dsh-vars
node scripts/install.mjs --profile desktop
# 完全退出并重新打开 DeepSeek Harness
验证安装:
$env:ELECTRON_RUN_AS_NODE = '1'
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\DeepSeek Harness.exe" scripts/validate-profile.mjs --profile desktop
安装/更新后需要重启 DSH(host 侧代码在进程启动时加载)。
打开 设置 → 变量:
DSH 端口见设置页顶部或 DSH 窗口地址;下文用 http://127.0.0.1:<DSH_PORT>,前缀 /dsh-vars/api。
响应统一为:
{ "ok": true, "value": ... }
{ "ok": false, "error": { "code": "...", "message": "..." } }
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /dsh-vars/api/health |
健康检查(公开) |
| GET | /dsh-vars/api/info |
本机端口、地址、tokenRequired(公开) |
| GET | /dsh-vars/api/variables |
列出全部变量 |
| GET | /dsh-vars/api/all |
获取当前所有变量(与 /variables 相同) |
| POST | /dsh-vars/api/variables |
新建 { name, type, initialValue? } |
| GET | /dsh-vars/api/variables/<name> |
读取单个变量 |
| POST / PUT | /dsh-vars/api/variables/<name> |
修改值 { value } |
| DELETE | /dsh-vars/api/variables/<name> |
删除变量 |
| GET | /dsh-vars/api/set?name=<name>&value=<value> |
用 GET 修改值 |
| POST | /dsh-vars/api/set |
用 POST 修改值 { name, value } |
$base = 'http://127.0.0.1:<DSH_PORT>/dsh-vars/api'
# 新建
Invoke-RestMethod "$base/variables" -Method Post -ContentType 'application/json' `
-Body (@{ name='demo'; type='number'; initialValue=1 } | ConvertTo-Json)
# 获取全部变量
Invoke-RestMethod "$base/all"
# GET 修改
Invoke-RestMethod "$base/set?name=demo&value=42"
# POST 修改
Invoke-RestMethod "$base/variables/demo" -Method Post -ContentType 'application/json' `
-Body (@{ value=7 } | ConvertTo-Json)
# 读取 / 删除
Invoke-RestMethod "$base/variables/demo"
Invoke-RestMethod "$base/variables/demo" -Method Delete
浏览器直接访问也可以(GET 改值):
http://127.0.0.1:<DSH_PORT>/dsh-vars/api/set?name=demo&value=42
三选一启用(读取优先级从上到下):
token;DSH_VARS_TOKEN(在启动 DSH 前设置);~/.dsh/plugins/dsh-vars/config.json:{ "token": "your-token" }
启用后:
Authorization: Bearer <token>;?token=<token>;/health、/info 始终公开,便于脚本发现端口与是否需要 token;localStorage),之后页面的 HTTP 与 WebSocket 都会自动带上。$base = 'http://127.0.0.1:<DSH_PORT>/dsh-vars/api'
$headers = @{ Authorization = 'Bearer your-token' }
Invoke-RestMethod "$base/all" -Headers $headers
Invoke-RestMethod "$base/set?name=demo&value=42" -Headers $headers
const ws = new WebSocket('ws://127.0.0.1:<DSH_PORT>/dsh-vars/api/events')
ws.onmessage = (event) => {
const message = JSON.parse(event.data)
// { type: 'ready', count, tokenRequired }
// { type: 'change', event: { type: 'created'|'updated'|'deleted', name }, at }
console.log(message)
}
启用 token 时:ws://127.0.0.1:<DSH_PORT>/dsh-vars/api/events?token=<token>。
/dsh-vars/api/events(DSH registerUpgrade 注册,仅本机)upgrade-required| 类型 | 默认值 | 接受的值 | 非法 |
|---|---|---|---|
string |
"" |
字符串(≤64 KiB) | 400 invalid-value |
number |
0 |
有限数字 / 数字字符串 | 400 invalid-value |
boolean |
false |
true / false(或字符串 "true"/"false") |
400 invalid-value |
json |
null |
任意 JSON 值或合法 JSON 文本(≤64 KiB) | 400 invalid-value |
变量名:字母或下划线开头,可含字母、数字、_ . -,≤64;重名 409 conflict;不存在 404 not-found;上限 200 个。
~/.dsh/plugins/dsh-vars/variables.json,权限 0600,临时文件 + rename 原子写;variables.json.corrupt-<时间> 并以空表启动;127.0.0.1 / ::1);node scripts/install.mjs --profile desktop --uninstall
Remove-Item "$env:USERPROFILE\.dsh\plugins\dsh-vars" -Recurse -Force # 可选:删数据
node --test
22 个测试覆盖:存储(类型校验、持久化、损坏恢复、并发串行化、订阅事件)、HTTP API(CRUD、GET/POST 修改、/all、/info、Bearer token、错误码)、WebSocket 握手与变化推送、client bundle 注册、host 挂载。
lib/
store.js 类型化变量存储 + 订阅
api.js HTTP 路由、Bearer token、/info
ws.js WebSocket 升级、变化推送
index.js DSH host 挂载(HTTP + upgrade)
client.js 设置页(对齐布局、本机地址、token、实时刷新)
test/
scripts/
MIT
| 项 | 值 |
|---|---|
| 版本 | 0.2.0 |
| 测试 | .github/workflows/ci.yml(push / PR) |
| CI | node --test(22 例) |
| 问题反馈 | https://github.com/juntaoqian/dsh-vars/issues |
| 源码 | https://github.com/juntaoqian/dsh-vars |
| 许可证 | MIT |
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: http-api。