confirmation

package
v0.0.60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConfirmationDenied = errors.New("action requires confirmation")

ErrConfirmationDenied is returned when the user declines a confirmation prompt or when the client does not support elicitation and the fallback is "deny".

Functions

func CheckConfirmation

func CheckConfirmation(ctx context.Context, elicitor api.Elicitor, message, fallback string) error

CheckConfirmation prompts the user for confirmation via the elicitor. If the client does not support elicitation, the fallback determines behavior: "deny" returns ErrConfirmationDenied, "allow" returns nil (with a warning log).

func CheckKubeRules

func CheckKubeRules(ctx context.Context, provider api.ConfirmationRulesProvider, elicitor api.Elicitor,
	verb, kind, group, version, name, namespace string) error

CheckKubeRules finds matching kube-level rules, merges them, and elicits confirmation. Returns nil if no rules match or the user accepts.

func CheckToolRules

func CheckToolRules(ctx context.Context, provider api.ConfirmationRulesProvider, elicitor api.Elicitor,
	toolName string, destructiveHint *bool) error

CheckToolRules finds matching tool-level rules, merges them, and elicits confirmation. Returns nil if no rules match or the user accepts. Returns an error if the user declines or elicitation is not supported and the fallback is "deny".

func MatchKubeLevelRules

func MatchKubeLevelRules(rules []api.ConfirmationRule, verb, kind, group, version, name, namespace string) []api.ConfirmationRule

MatchKubeLevelRules returns all kube-level rules that match the given Kubernetes API request. A rule matches if all of its non-empty fields match the request:

  • verb: exact match (e.g. "get", "delete", "list")
  • kind: exact match on the resource kind
  • group: exact match on the API group
  • version: exact match on the API version
  • name: exact match on the resource name
  • namespace: exact match on the namespace

func MatchToolLevelRules

func MatchToolLevelRules(rules []api.ConfirmationRule, toolName string, destructiveHint *bool) []api.ConfirmationRule

MatchToolLevelRules returns all tool-level rules that match the given tool call. A rule matches if all of its non-empty fields match the call:

  • tool: exact match on tool name
  • destructive: matches when the tool's DestructiveHint equals the rule value

func MergeMatchedRules

func MergeMatchedRules(matched []api.ConfirmationRule, globalFallback string) (message string, effectiveFallback string)

MergeMatchedRules combines matched rules into a single message. If a single rule matched, its message is used directly. If multiple rules matched, messages are combined as a bulleted list. The global fallback is always used as the effective fallback.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL