Documentation
¶
Overview ¶
Package approval holds the types shared by the tool-approval wrapper and the tools that know which of their calls need a human decision.
The package deliberately has no dependency on the tools package so that both built-in tools (including tools/custom) and front-ends can use it.
Index ¶
Constants ¶
const ( ModeOff = "off" // never ask ModeDangerous = "dangerous" // ask only for calls a tool flags as mutating (default) ModeAll = "all" // ask before every tool call )
Approval modes, configured with settings.approval.mode.
const ( AllowOnce = "允许本次" AllowSession = "本会话允许" Deny = "拒绝" )
Answers a front-end offers for an approval request.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Classifier ¶
Classifier is implemented by tools that can tell whether a specific call is dangerous. The bool result is true when the call mutates state, runs code or otherwise deserves confirmation.
type Policy ¶
type Policy struct {
Mode string
Allow map[string]bool // tools that never need approval
Always map[string]bool // tools that always need approval
}
Policy is the resolved approval configuration.
func (Policy) ModeOrDefault ¶
ModeOrDefault returns the configured mode, defaulting to ModeDangerous so a tool that can run commands or write files asks before doing so.
func (Policy) NeedsApproval ¶
func (p Policy) NeedsApproval(name, arguments string, classifier Classifier) (Request, bool)
NeedsApproval decides whether a call must be confirmed and builds the request shown to the user.