usavv1547-cyber/dsh-plugin-workspace-image0

dsh-plugin-workspace-image

DSH web plugin: serve workspace image files over a constrained /dsh-image route so agents can embed images inline in conversation.

包名
dsh-plugin-workspace-image
版本
0.1.1
最近更新
2026年8月18日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:usavv1547-cyber/dsh-plugin-workspace-image

3) 配置插件(见下),然后重启 dsh web


> 本地开发时可用 `dsh plugin --profile web add file:/本地路径/dsh-plugin-workspace-image` 代替第 1 步。

### 配置(~/.dsh/profiles/web/cordis.patch.yml)

在 `cordis.patch.yml` 里追加:

```yaml
- insert:
    - id: workspace-image
      name: 'dsh-plugin-workspace-image'
      config:
        # alias -> 允许对外提供图片的绝对目录
        roots:
          sixsigma: /Users/guoguo/6sigma
        # 默认 false:.svg 不开放(可携带脚本,XSS 面);确需时改为 true
        allowSvg: false

不配置 roots 时,插件会自动回退到 harness 已注册的全部 workspace (按 workspace id 作为 alias),方便直接用现有工作区。

使用

配置了 alias sixsigma 指向 /Users/guoguo/6sigma 后:

消息内容效果
![](https://raw.githubusercontent.com/usavv1547-cyber/dsh-plugin-workspace-image/d2f83fbb6507bd2f92ebf71b93f710d5689136a2/dsh-image/sixsigma/fig.png)内嵌显示 /Users/guoguo/6sigma/fig.png
![](https://raw.githubusercontent.com/usavv1547-cyber/dsh-plugin-workspace-image/d2f83fbb6507bd2f92ebf71b93f710d5689136a2/dsh-image/sixsigma/reports/chart.webp)内嵌显示子目录图片

给 agent 的提示词可以加一句:"要内嵌展示图片时,用相对链接 /dsh-image//,如 ![](https://raw.githubusercontent.com/usavv1547-cyber/dsh-plugin-workspace-image/d2f83fbb6507bd2f92ebf71b93f710d5689136a2/dsh-image/sixsigma/fig.png)。"

安全设计(纵深防御)

  1. 只允许 GET / HEAD,其余方法返回 405;
  2. 逐段校验:每个路径段先 URL 解码,段不得为空、不得为 . / ..、 不得在解码后包含 /\、NUL(%2e%2e..%2f 等编码穿越均被拒);
  3. 词法包含检查resolve + normalize 后必须仍在 root 之下,否则 403;
  4. 真实路径检查realpath() 解析符号链接后再次校验必须仍在 root 之下, 防止 root 内的符号链接逃逸到任意文件(403);
  5. 扩展名白名单:仅常见栅格图格式(png/jpg/jpeg/webp/gif/avif/bmp/ico); SVG 默认 415(可选 allowSvg 打开);Content-Type 一律由白名单推导;
  6. 服务器进程外无任何暴露(路由挂在现有 dsh web 进程上)。

测试

cd dsh-plugin-workspace-image
npm install
node --test          # 15 项:正常读取 / HEAD / 405 / 各类穿越 / 符号链接逃逸 / MIME / SVG / 404 / 插件接线

与官方路线的关系

DSH 消息协议已为"助手输出图片"预留了 ImageBlockpackages/llm 中类型注释:valid in user or assistant content … assistant-side rendering is forward compatibility)。本插件是让这一能力当下可用的轻量落地; 官方后续若实现完整的 assistant 附件通道,本插件可作为过渡方案。 功能请求已提交:https://github.com/deepseek-ai/deepseek-harness/discussions/2995

License

MIT

配置(~/.dsh/profiles/web/cordis.patch.yml)

cordis.patch.yml 里追加:

- insert:
    - id: workspace-image
      name: 'dsh-plugin-workspace-image'
      config:
        # alias -> 允许对外提供图片的绝对目录
        roots:
          sixsigma: /Users/guoguo/6sigma
        # 默认 false:.svg 不开放(可携带脚本,XSS 面);确需时改为 true
        allowSvg: false

不配置 roots 时,插件会自动回退到 harness 已注册的全部 workspace (按 workspace id 作为 alias),方便直接用现有工作区。

使用

配置了 alias sixsigma 指向 /Users/guoguo/6sigma 后:

消息内容效果
![](https://raw.githubusercontent.com/usavv1547-cyber/dsh-plugin-workspace-image/d2f83fbb6507bd2f92ebf71b93f710d5689136a2/dsh-image/sixsigma/fig.png)内嵌显示 /Users/guoguo/6sigma/fig.png
![](https://raw.githubusercontent.com/usavv1547-cyber/dsh-plugin-workspace-image/d2f83fbb6507bd2f92ebf71b93f710d5689136a2/dsh-image/sixsigma/reports/chart.webp)内嵌显示子目录图片

给 agent 的提示词可以加一句:"要内嵌展示图片时,用相对链接 /dsh-image//,如 ![](https://raw.githubusercontent.com/usavv1547-cyber/dsh-plugin-workspace-image/d2f83fbb6507bd2f92ebf71b93f710d5689136a2/dsh-image/sixsigma/fig.png)。"