interact

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package interact is the contract between the core and its frontends. A new frontend implements UI and needs no change in the core.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("interaction not supported by this frontend")

ErrUnsupported is returned by a headless UI that cannot ask questions.

Modes is in Shift+Tab and ACP order.

Functions

This section is empty.

Types

type Answers

type Answers struct {
	// Selected maps each answered question to the chosen labels, or to the
	// typed answer.
	Selected map[string][]string
	// Notes maps a question to text typed beside a choice.
	Notes     map[string]string
	Cancelled bool
}

type Approval

type Approval struct {
	// ToolID is empty when the request is not for a tool call, e.g. a hook
	// command.
	ToolID  string
	Tool    string
	Summary string
	Reason  string
	// Warning describes what a destructive command would do; frontends show
	// it prominently.
	Warning      string
	OutsideRoots bool
	// Confirm means no mode or stored approval can ever allow this call, so
	// it is asked every time.
	Confirm bool
	// Remember describes what AllowAlways allows from now on, e.g. "`go
	// test` commands in this project". Empty means only AllowOnce applies.
	Remember string
	// Edit means the call edits files, which accept-edits mode allows
	// without asking.
	Edit bool
}

type Choice

type Choice string
const (
	AllowOnce Choice = "allow_once"
	// AllowAlways also allows what Approval.Remember describes.
	AllowAlways Choice = "allow_always"
	Deny        Choice = "deny"
)

type Mode

type Mode string

Mode is how much the agent may do without asking.

const (
	ModeStrict      Mode = "strict"
	ModeBalanced    Mode = "balanced"
	ModeAcceptEdits Mode = "accept-edits"
	ModeTrust       Mode = "trust"
)

func ParseMode

func ParseMode(raw string) (Mode, error)

type Option

type Option struct {
	Label       string `json:"label"`
	Description string `json:"description"`
	Preview     string `json:"preview,omitempty"`
}

type Question

type Question struct {
	Question    string   `json:"question"`
	Header      string   `json:"header"`
	Options     []Option `json:"options"`
	MultiSelect bool     `json:"multiSelect,omitempty"`
	// Custom offers a free-text answer below the options; nil means true.
	Custom *bool `json:"custom,omitempty"`
}

func (Question) AllowsCustom

func (q Question) AllowsCustom() bool

type UI

type UI interface {
	// Approve is called for tool calls and hook commands the permission mode
	// does not allow on its own.
	Approve(ctx context.Context, req Approval) (Verdict, error)
	// Ask serves ask_user.
	Ask(ctx context.Context, qs []Question) (Answers, error)
}

type Verdict

type Verdict struct {
	Choice Choice
	// Feedback accompanies a denial: what the user wants done instead.
	Feedback string
}

Jump to

Keyboard shortcuts

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