Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoApprove ¶
AutoApprove returns whether a tool at the given risk level should auto-execute.
func Register ¶ added in v0.9.0
Register publishes a risk level for tool at runtime. Used by mcpfed to classify federated MCP tools after their annotations are read at startup. A second Register call for the same tool overrides the previous level — the most recent assertion wins.
Invalid levels (outside [Low, Critical]) are rejected. AutoApprove is `toolRisk <= threshold`, so a stored Level(-1) would silently auto-approve at any non-negative threshold and bypass the confirm gate — exactly the property the registry exists to defend. The reject-vs-clamp choice matches Classify's fail-safe: an unregistered tool falls through to High, the safe default, rather than to whatever a typo'd caller passed.
func Unregister ¶ added in v0.9.0
func Unregister(tool string)
Unregister removes a runtime entry. Falls through to the static toolLevels map and ultimately the High default. Used in tests to keep the runtime overlay clean between cases.
func WantsDiff ¶ added in v0.13.0
WantsDiff reports whether tools at the given level should have a unified-diff preview attached to their confirmation request. Today only Medium qualifies: High/Critical already require explicit approval and the operator usually wants to read the params box, not scroll a diff. Medium is the tier where the previous prompt asked "approve this write?" with no insight into what would change — the diff plugs that gap.
Types ¶
type Level ¶
type Level int
func Classify ¶
Classify returns the risk level for a given tool name. The runtime overlay is consulted first; otherwise the static toolLevels map; otherwise High (the safe default — an unknown capability is gated behind a confirmation rather than silently auto-approved).
func ClassifyExplicit ¶
ClassifyExplicit returns the registered risk level and true if the tool has an explicit classification (either from the runtime overlay or the static map), or (High, false) if the tool fell through to the safe default. Used by the agent-package coverage test to detect drift between the tool catalogue and this registry.