toolconfirm

package
v1.77.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package toolconfirm centralizes the tool-confirmation policy shared by docker-agent's own confirmation dialog and embedders that bring their own dialog framework (e.g. the Gordon assistant embedded in Docker Sandboxes): the decision set and its runtime resume semantics, the "always allow" permission-pattern construction, key bindings, and the user-facing strings.

Keeping this policy in one runtime-agnostic place matters most for BuildPermissionPattern: the pattern shown to the user ("always allow ls*") and the pattern granted to the runtime must come from the same code, in every UI that hosts a confirmation.

Index

Constants

View Source
const (
	Title    = "Tool Confirmation"
	Question = "Do you want to allow this tool call?"
)

User-facing strings of the confirmation prompt.

Variables

This section is empty.

Functions

func AlwaysAllowLabel

func AlwaysAllowLabel(pattern string) string

AlwaysAllowLabel is the descriptive label of the "always allow" option for a pattern from BuildPermissionPattern: the command pattern for shell ("always allow ls*"), the tool name otherwise.

func BuildPermissionPattern

func BuildPermissionPattern(toolCall tools.ToolCall) string

BuildPermissionPattern creates the permission pattern granted by the "always allow" decision. For shell commands it extracts the first word of the command and creates a pattern like "shell:cmd=ls*" matching all invocations of that command; for other tools it returns the tool name.

func OptionsHelp

func OptionsHelp(pattern string) []string

OptionsHelp returns the key/label pairs of the decision row, in display order, ready for a help-keys renderer (e.g. dialog.RenderHelpKeys).

Types

type Decision

type Decision int

Decision is the user's answer to a tool confirmation.

const (
	// Approve runs this one call.
	Approve Decision = iota
	// ApproveTool runs the call and always allows the tool, scoped by the
	// permission pattern from BuildPermissionPattern.
	ApproveTool
	// ApproveSession runs the call and approves all tools for the rest of
	// the session.
	ApproveSession
	// Reject rejects the call with an optional reason shown to the model.
	Reject
)

func (Decision) Resume

func (d Decision) Resume(pattern, reason string) runtime.ResumeRequest

Resume translates the decision into the runtime resume request. pattern is the permission pattern for ApproveTool (from BuildPermissionPattern); reason is the optional rejection reason for Reject. Each is ignored by the other decisions.

type KeyMap

type KeyMap struct {
	Yes      key.Binding
	No       key.Binding
	All      key.Binding
	ThisTool key.Binding
}

KeyMap defines the confirmation key bindings.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the standard confirmation key bindings.

type RejectionReason

type RejectionReason struct {
	ID    string // stable identifier
	Label string // short label shown to the user
	Value string // model-friendly sentence sent as the rejection reason
}

RejectionReason is one preset answer to "Why reject this tool call?".

func RejectionReasons

func RejectionReasons() []RejectionReason

RejectionReasons returns the preset rejection reasons, in display order.

Jump to

Keyboard shortcuts

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