Drifter-yh/dsh-tool-policy1

dsh-tool-policy

声明式工具调用策略插件:为 DSH 提供默认拒绝、询问或允许的工具调用安全策略,支持基于工具名和参数的规则过滤。

AI 分析

核心用途是保障 DSH 运行环境的安全。适合担心 AI 执行高危操作(如 bash 执行 rm -rf)的用户,通过配置规则实现工具调用的安全拦截。

套件
dsh-tool-policy
版本
0.1.0
授權
MIT
最近更新
2026年8月13日

安裝

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Drifter-yh/dsh-tool-policy

Configuration

defaultDecision: deny # deny (default), ask, or allow
rules:
  # First matching rule wins.
  - tool: 'bash'
    decision: deny
    reason: 'Destructive shell commands are disabled.'
    argument:
      path: /command
      contains: 'rm -rf'

  - tool: 'record.update'
    decision: deny
    reason: 'System records are immutable.'
    argument:
      path: /scope
      equals: system

  - tool: 'safe_*'
    decision: allow

  - tool: '*'
    decision: ask
    reason: 'Unlisted tools require approval.'

tool is an anchored name pattern with one wildcard, *. Other regular-expression metacharacters are treated literally. argument.path is an RFC 6901 JSON Pointer into parsed tool arguments. A condition uses exactly one of equals (JSON scalar equality) or contains (non-empty substring on a string). Rule order is explicit and deterministic.

Decision semantics:

  • deny returns a normal Harness tool error before the body runs;
  • ask returns { kind: 'ask' } and lets ctx.approval decide; without an approval channel Harness fails closed;
  • allow calls next() and therefore does not override a prior or later policy listener;
  • defaultDecision applies only when no rule matches.

Reasons never interpolate the call arguments. This avoids copying secrets or large payloads into model-visible approval feedback.