Drifter-yh/dsh-tool-policy ↗★ 3
@drifter-yh/dsh-tool-policy
在执行前允许、询问或拒绝智能体工具调用。 适合需要对敏感工具(如bash命令)进行安全拦截与授权的用户。
安裝
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Drifter-yh/dsh-tool-policy說明文件
閱讀完整 README ↗Configuration
defaultDecision: deny # deny (default), ask, or allow
trace: false # emit an argument-free decision trace through the Cordis logger
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:
denyreturns a normal Harness tool error before the body runs;askreturns{ kind: 'ask' }and letsctx.approvaldecide; without an approval channel Harness fails closed;allowcallsnext()and therefore does not override a prior or later policy listener;defaultDecisionapplies only when no rule matches.
Reasons never interpolate the call arguments. This avoids copying secrets or large payloads into model-visible approval feedback.
Policy decision trace
Set trace: true when operators need to understand why this plugin produced a decision:
trace: true
rules:
- tool: 'read_*'
decision: allow
- tool: 'bash'
decision: ask
reason: 'Shell execution requires approval.'
The plugin writes an info record through the Cordis logger with the tool name, this plugin's decision, the one-based matched rule number (or null when defaultDecision was used), and the configured reason for ask or deny. It never includes parsed tool arguments. Tracing is disabled by default, is best-effort, and does not replace Harness session audit events; a later policy listener or monotonic tool guard may still change whether an allowed call executes.