Policy Presets

Complete API reference for all 8 policy presets in governance-sdk.

8 built-in presets that cover 90% of governance needs. Each returns a PolicyRule you pass to createGovernance.

ts

blockTools

ts

Block specific tools by name. Any action targeting a listed tool returns a block outcome. The most common policy preset.

ts

allowOnlyTools

ts

Allowlist mode. Only the listed tools are permitted — every other tool is blocked. Inverse of blockTools.

ts

requireApproval

ts

Human-in-the-loop gate. Takes an array of PolicyAction objects. Instead of blocking, returns a "requires_approval" outcome so your application can prompt a human reviewer before proceeding. Priority 80.

ts

tokenBudget

ts

Enforce a per-session token budget. Once the cumulative token count exceeds the limit, subsequent actions are blocked.

ts

rateLimit

ts

Declarative threshold check. The SDK compares a caller-supplied action count against the configured maximum. It does not track counts itself.

ts

Warning: This is a declarative check, not server-side rate limiting. For production use, pair it with Upstash or Redis to track actual counts.

requireLevel

ts

Require agents to meet a minimum governance score level (L0–L4) before acting. Agents below the threshold are blocked.

ts

requireSequence

ts

Enforce tool prerequisites. The target tool is blocked until all prerequisite tools have been called in the current session. Useful for CI/CD-style pipelines.

ts

timeWindow

ts

Restrict actions to specific time windows. Actions outside the window are blocked.

ts

Composing Presets

Presets return standard PolicyRule objects. Pass multiple to createGovernance and they evaluate in priority order.

ts

Note: Rules are evaluated in priority order. Use composePolicies from governance-sdk/policy-compose for cross-team merging with conflict resolution.