@mrweicodes/dsh-permgate 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/client.js +26 -0
  2. package/index.js +14 -4
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -839,6 +839,19 @@ window.__ModuleLoader__.load({
839
839
  'quick.cordis_inspect_list': '检视能力清单',
840
840
  'quick.cordis_inspect_query': '执行只读检视',
841
841
  'quick.cordis_inspect_self': '检视本会话插件',
842
+ 'quick.perm_status': '查看权限状态',
843
+ 'quick.perm_set_category': '改分类默认动作',
844
+ 'quick.perm_set_fallback': '改兜底策略',
845
+ 'quick.perm_set_editor_kernel': '改编辑器内核判别',
846
+ 'quick.perm_add_exception': '添加例外',
847
+ 'quick.perm_remove_exception': '删除例外',
848
+ 'quick.perm_set_quick': '改快捷工具默认',
849
+ 'quick.perm_add_rule': '添加自定义规则',
850
+ 'quick.perm_remove_rule': '删除自定义规则',
851
+ 'quick.perm_reload': '重载配置',
852
+ 'quick.cordis_run': '运行动态插件',
853
+ 'quick.cordis_stop': '停用动态插件',
854
+ 'quick.cordis_undefine': '移除动态插件',
842
855
  'panel.excExpand': '展开',
843
856
  'panel.excCollapse': '折叠',
844
857
  'panel.excListLink': '例外列表',
@@ -1001,6 +1014,19 @@ window.__ModuleLoader__.load({
1001
1014
  'quick.cordis_inspect_list': 'list inspect capabilities',
1002
1015
  'quick.cordis_inspect_query': 'run a read-only inspect query',
1003
1016
  'quick.cordis_inspect_self': 'inspect session plugins',
1017
+ 'quick.perm_status': 'view permission status',
1018
+ 'quick.perm_set_category': 'set a category default',
1019
+ 'quick.perm_set_fallback': 'set the fallback policy',
1020
+ 'quick.perm_set_editor_kernel': 'set editor-kernel detection',
1021
+ 'quick.perm_add_exception': 'add an exception',
1022
+ 'quick.perm_remove_exception': 'remove an exception',
1023
+ 'quick.perm_set_quick': 'set a quick-tool default',
1024
+ 'quick.perm_add_rule': 'add a custom rule',
1025
+ 'quick.perm_remove_rule': 'remove a custom rule',
1026
+ 'quick.perm_reload': 'reload config',
1027
+ 'quick.cordis_run': 'run a dynamic plugin',
1028
+ 'quick.cordis_stop': 'stop a dynamic plugin',
1029
+ 'quick.cordis_undefine': 'remove a dynamic plugin',
1004
1030
  'panel.excExpand': 'Expand',
1005
1031
  'panel.excCollapse': 'Collapse',
1006
1032
  'panel.excListLink': 'Exception list',
package/index.js CHANGED
@@ -16,7 +16,10 @@ const ALL_MODES = ['ask', 'allow', 'deny', 'inherit']
16
16
  const MAX_DECISIONS = 30
17
17
  // 快捷工具预设:无文件/命令语义、只能按工具名设默认动作的清单(设置页据此展示,新配置按 QUICK_DEFAULTS 落默认)
18
18
  // 低风险观测/会话类工具默认放行,避免每次都弹窗;
19
- // cordis_run(宿主进程内执行代码)、cordis_stop/undefine(管理动态插件)与 mcp__*(外装 MCP)不在此列,走兜底策略(默认询问)
19
+ // 其余工具默认询问(ask):mcp__*(外装 MCP)、改权限配置的 perm_*(只读的 perm_status 除外)、
20
+ // 以及管理动态插件的 cordis_run/stop/undefine —— perm_* 曾经被 decide 无条件放行,等于
21
+ // 「AI 可自我提权、且全程无弹窗」;纳入本清单后统一按 ask 裁决,只有用户在设置页显式改成 allow
22
+ // 才会静默放行(预设默认优先于兜底策略,改兜底也不会漏)。
20
23
  const QUICK_DEFAULTS = {
21
24
  web_search: 'ask', skill: 'allow', grep: 'allow', glob: 'allow', web_fetch: 'ask',
22
25
  ask_user_question: 'allow', todo_write: 'allow', list_agents: 'allow',
@@ -25,6 +28,12 @@ const QUICK_DEFAULTS = {
25
28
  send_message: 'allow', interrupt_agent: 'allow',
26
29
  present: 'allow', exit_plan_mode: 'allow',
27
30
  cordis_define: 'allow', cordis_inspect_list: 'allow', cordis_inspect_query: 'allow', cordis_inspect_self: 'allow',
31
+ // 改权限配置 = 元操作,一律先问;只有 perm_status 是只读查询,默认放行(想看随时能看)
32
+ perm_status: 'allow', perm_set_category: 'ask', perm_set_fallback: 'ask', perm_set_editor_kernel: 'ask',
33
+ perm_add_exception: 'ask', perm_remove_exception: 'ask', perm_set_quick: 'ask',
34
+ perm_add_rule: 'ask', perm_remove_rule: 'ask', perm_reload: 'ask',
35
+ // cordis_run 在宿主进程里执行代码、stop/undefine 管理(可移除)动态插件 —— 同属元操作,一律先问
36
+ cordis_run: 'ask', cordis_stop: 'ask', cordis_undefine: 'ask',
28
37
  }
29
38
  // 单一来源:预设清单由 QUICK_DEFAULTS 的键派生(顺序即键的插入顺序),
30
39
  // 避免「清单」与「默认值」两份定义在新增工具时漂移(设置页展示与 locked 迁移共用这一份)
@@ -2127,9 +2136,10 @@ export default {
2127
2136
  if (d && d.ruleId) return ' (exception ' + d.ruleId + ')'
2128
2137
  return ''
2129
2138
  }
2130
- if (typeof name === 'string' && name.indexOf('perm_') === 0) {
2131
- return { action: 'allow', reason: bi('permgate 自身管理工具,始终放行', 'permgate management tool, always allowed'), cat: null, value: null, kind: null }
2132
- }
2139
+ // 注意:perm_* 曾在此被无条件放行,等于给 AI 留了一条「自我提权且无弹窗」的后门
2140
+ // (perm_set_category / perm_set_fallback / perm_add_exception 改动即生效)。
2141
+ // 现在不再特判,统一走下面的正常判定链(自定义规则 → 分类 → 快捷工具 → 兜底),
2142
+ // 其默认动作由 QUICK_DEFAULTS 钉成 ask;设置面板走 /permgate/* HTTP 路由、不经这里,不受影响。
2133
2143
  if (sessionPresetName(exec) !== 'custom-review') {
2134
2144
  return { action: 'allow', reason: bi('会话未选择「自定义审查」,由 DSH 权限预设处理', 'Session has not selected "Custom Review"; handled by DSH permission presets'), cat: null, value: null, kind: null }
2135
2145
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mrweicodes/dsh-permgate",
3
3
  "description": "Permission gateway for DSH (DeepSeek Harness): reviews tool calls per category (directory/command/read/image/edit/undo/subagent/doom loop) with global/project config, exceptions, quick-tool defaults, custom rules, a fallback policy for unmatched calls, bilingual approval modal and sandbox-upgrade flow. Config persisted at $DSH_HOME/dsh-permgate/config.json.",
4
- "version": "1.5.0",
4
+ "version": "1.5.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/MrWeiCodes/dsh-permgate.git"