Skip to content

dsh-sandbox-permissions-not-strictly-wider-justification-empty-fix

Verified

dsh-sandbox-permissions-not-strictly-wider-justification-empty-fix · v1.0.9 · MIT

修复 sandbox_permissions 和 justification 字段在 pwsh/bash/fs/dsh-sandbox 中的 no-op 升级报错。当会话已是 danger-full-access 模式时,模型携带空 justification 或重申同一模式被拒的问题。

Install

dsh plugin add dsh-sandbox-permissions-not-strictly-wider-justification-empty-fix

Confirm the layer applied with dsh --profile default --dump-config — see the install guide.

Source

Published to npm without a public repository. Inspect the package contents before installing.

Creators

Readme

dsh-sandbox-permissions-not-strictly-wider-justification-empty-fix

English | 中文

一个 DSH 插件,修复 sandbox_permissions 和 justification 字段在 pwsh、bash、fs(write/edit)、dsh-sandbox 四个工具中的两个相关 bug。

Bug 描述

当会话已经是 danger-full-access 模式时,可能触发两个错误:

  1. 空 justification:模型发送 justification: ""(空字符串),触发 validateEscalationArgs 抛出 invalid justification: expected a non-empty sentence
  2. no-op 升级:模型发送 sandbox_permissions: "danger-full-access"(与当前模式相同),触发 approveEscalation 抛出 sandbox escalation to "X" is not strictly wider

这是第 4 次独立报告(GitHub #3519 → #4359 → #4383 → #4412),影响所有使用非默认模型的会话。

修复方案

两层防御:

  1. Schema 描述:更新为明确说明 same-mode retry 是 no-op,减少模型发送空字段的倾向
  2. 运行时归一化:在每个工具的 execute/resolvePolicy 入口添加归一化逻辑,当请求的模式不比当前模式更宽时清除升级参数

工作原理

  • 安装(dsh plugin add):插件安装到 profile 目录,Cordis 注入动态插件行
  • 首次加载:index.js 的 apply() 函数运行 patch.js apply,备份原始文件并应用所有修改。此过程在首次加载时自动完成
  • 自动修复:每次客户端启动/重启时,插件检查 patch 是否仍然有效。如果 patch 丢失(如桌面端更新后),自动重新应用
  • 多目标:插件检测 DSH_HOME 和桌面端安装目录。如果硬链接已断开(如桌面端更新后),同时修改两端
  • 卸载(dsh plugin remove):preuninstall 脚本运行 patch.js restore,从备份恢复所有原始文件

安装

dsh plugin --profile web add dsh-sandbox-permissions-not-strictly-wider-justification-empty-fix@latest

卸载

步骤 1:从备份恢复原始文件:

cd $env:DSH_HOME\profiles\web\node_modules\dsh-sandbox-permissions-not-strictly-wider-justification-empty-fix
node scripts/patch.js restore

此命令使用存储在 $env:DSH_HOME\backups\dsh-sandbox-permissions-not-strictly-wider-justification-empty-fix\ 中的备份,将四个工具文件(dsh-sandbox、dsh-tool-pwsh、dsh-tool-bash、dsh-tool-fs)恢复到原始状态。

步骤 2:移除插件:

dsh plugin --profile web remove dsh-sandbox-permissions-not-strictly-wider-justification-empty-fix

备份机制说明:插件首次应用 patch 时,会将原始文件复制到 DSH_HOME\backups\dsh-sandbox-permissions-not-strictly-wider-justification-empty-fix\(插件目录之外)。即使插件被移除,备份仍然保留,因此随时可以恢复。

修改文件清单

文件 修改内容
dsh-sandbox/lib/index.js approveEscalation:throw → return effectiveMode
dsh-tool-pwsh/lib/index.js import +WIDER_MODES、execute 归一化、schema 描述
dsh-tool-bash/lib/index.js import +WIDER_MODES、execute 归一化、schema 描述
dsh-tool-fs/lib/index.js import +WIDER_MODES、resolvePolicy 归一化、schema 描述

兼容性

  • 兼容最新 dsh-std 插件元协定
  • 不与其他插件冲突(仅修改工具实现文件)
  • 桌面端和 WebUI 均支持(修改 DSH_HOME,与桌面端硬链接)

许可证

MIT