New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

dsh-api-gateway

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dsh-api-gateway

DSH 业务系统 HTTP API 网关:随 DSH 启动常驻,默认关闭,可通过侧边栏图标或设置页手动启用,为业务系统提供任务提交、会话、用户、工作区、记忆等 HTTP API。

latest
Source
npmnpm
Version
23.0.3
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

dsh-api-gateway

DSH 业务系统 HTTP API 网关:一个随 DSH 启动常驻的正式 Bundle 插件,为外部业务系统提供 HTTP API,让业务系统可以直接向 DSH 提交任务、查询会话、管理用户与工作区、读写记忆。业务端点默认关闭,由管理员通过控制端点手动启用,兼顾安全与可用性。

  • 类型:DSH 正式插件(Cordis Bundle),随 DSH 启动自动加载
  • 语言:Node.js ESM(Host)+ 浏览器模块(Client)
  • 许可:MIT
  • 仓库:https://github.com/zuoxiang20/dsh-api-gateway
  • npm:https://www.npmjs.com/package/dsh-api-gateway

📖 完整接口文档见 docs/api.md(含请求/响应示例、curl 对接示例);npm 包内已随包附带 docs/api.md,安装后可本地查阅。

功能

  • 控制端点 /api/dsh/_gw/* 始终在线:查询状态、启停业务端点、修改 admin token
  • 业务端点 /api/dsh/* 默认关闭,启用后提供任务提交、会话查询、用户/工作区管理、记忆读写
  • 多用户 / 多工作区隔离:每 (用户 × 工作区) 一个持久 Agent 会话,互不干扰
  • 鉴权:控制端点用 admin token,业务端点用用户 apiKey(x-api-key 或 Authorization: Bearer)
  • 持久化:状态保存在 $DSH_HOME/.dsh-api/(users.json / workspaces.json / gateway-config.json)
  • Client UI:左下角图标 + 设置页,可查看状态、开关服务、配置 token

安装

要求:已安装 DSH(桌面版默认 profile 为 web),DSH 桌面版或 CLI 均可。

从 npm 安装(推荐)

dsh plugin --profile web add dsh-api-gateway

指定版本:

dsh plugin --profile web add dsh-api-gateway@23.0.1

从 GitHub 安装

dsh plugin --profile web add github:zuoxiang20/dsh-api-gateway
# 或
dsh plugin --profile web add git+https://github.com/zuoxiang20/dsh-api-gateway.git

安装成功后重启 DSH 生效(Bundle 在启动时加载),插件会自动进入 profile 的 dsh.profile.bundles。

使用

  • 重启 DSH 后,点击左下角图标或进入设置页
  • 点击「启用」开启业务端点
  • 首次使用的默认 admin token 为 dsh-admin-2024,建议立即在设置页修改

接口列表

完整接口文档(含请求/响应示例、鉴权说明、curl 对接示例):👉 docs/api.md

端点速览:

方法路径鉴权说明
GET/api/dsh/_gw/status无查询状态
POST/api/dsh/_gw/toggleadmin启用/停用业务端点
POST/api/dsh/_gw/setTokenadmin修改 admin token
POST/api/dsh/usersadmin创建用户(返回 apiKey)
POST/api/dsh/workspacesadmin创建工作区
POST/api/dsh/taskuser提交任务
GET/api/dsh/task/:iduser查询任务结果
GET/DELETE/api/dsh/memory?workspace=<id>user读写记忆

卸载

dsh plugin --profile web remove dsh-api-gateway

开发

目录结构

.
├── package.json        # 包元数据 + dsh.bundle + dsh.client 声明
├── host.js             # Host 端:控制端点 + 业务逻辑(Node ESM)
├── client.js           # Client 端:图标 + 设置页(__ModuleLoader__.load)
├── cordis.patch.yml    # Bundle 自插入:- insert: [{id, name}]
└── docs/api.md         # 完整接口文档

本地开发(直接引用源码目录,改代码后需重装同步)

# 把 <插件源码目录> 换成你本地的插件目录绝对路径
dsh plugin --profile web add "file:<插件源码目录>"
# 改完源码后,重装以同步快照
dsh plugin --profile web remove dsh-api-gateway
dsh plugin --profile web add "file:<插件源码目录>"

说明:file: 依赖是快照拷贝,改源码后必须 remove + add 重新同步,否则运行的还是旧版;每次操作后重启 DSH 生效。

发布流程

# 1. 改代码
# 2. 升版本并发布 npm
npm version patch
npm publish --registry https://registry.npmjs.org
# 3. 推送 GitHub
git add .
git commit -m "describe change"
git push

License

MIT

Keywords

dsh

FAQs

Package last updated on 24 Aug 2026

Related posts