Drifter-yh/dsh-tool-policy ↗★ 3

@drifter-yh/dsh-tool-policy

Allow, ask, or deny DeepSeek Harness tool calls before execution 适合需要对敏感工具(如bash命令)进行安全拦截与授权的用户。

Package
@drifter-yh/dsh-tool-policy
Compatibility
Unverified
Harness peer range
>=0.1.0-rc.5 <0.2.0
Cordis peer range
>=4.0.1 <5
Version
0.2.1
License
MIT
Last updated
Sep 20, 2026

Install

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

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:

  • 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.

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.