question

package
v0.2.2-alpha.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package question provides the back-channel between the AskUserQuestion tool (blocked agent goroutine) and the TUI (user interaction). The design mirrors internal/permission/broker.go exactly: one Broker per process, shared by all agents; the TUI registers an OnRequest callback at startup and calls Respond when the user has answered all questions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetOnRequest

func SetOnRequest(b Broker, fn OnRequest)

SetOnRequest is exported as a free function (not on the interface) so callers building a Broker from NewBroker can register a callback without reflection.

Types

type Annotation

type Annotation struct {
	Notes   string
	Preview string
}

Annotation carries extra metadata about the user's answer — the preview content they were shown, or free-text notes they added.

type Broker

type Broker interface {
	// Request blocks until the user responds or ctx is cancelled.
	// Returns an error response when ctx is cancelled.
	Request(ctx context.Context, req Request) (Response, error)

	// Respond delivers the user's answers to the blocked Request.
	// Idempotent per ID — a second call for the same ID is a no-op.
	Respond(id string, r Response) error
}

Broker is the back-channel between the AskUserQuestion tool and the TUI. A single Broker is shared by the root agent and all subagents.

func NewBroker

func NewBroker() Broker

NewBroker returns a Broker backed by an in-memory request map.

type OnRequest

type OnRequest func(req Request)

OnRequest is the callback the broker invokes when a new request is created. The TUI registers here to render the question overlay.

type Option

type Option struct {
	Label       string
	Description string
	Preview     string // optional; only meaningful for single-select questions
}

Option is one item the user can select.

type Question

type Question struct {
	Question    string
	Header      string // short chip label, max 12 chars
	MultiSelect bool
	Options     []Option
}

Question is one question in a Request.

type Request

type Request struct {
	ID        string
	AgentID   string
	Questions []Question
}

Request is what the TUI needs to render the question overlay. ID is empty on input; Broker.Request assigns one.

type Response

type Response struct {
	Answers     map[string]string
	Annotations map[string]Annotation
}

Response is the payload delivered back to the blocked tool goroutine once the user has finished answering.

Answers maps question text → answer string. For single-select questions the value is the chosen option's label. For multi-select questions the value is a comma-separated list of chosen labels. For "Other" free-text the value is whatever the user typed.

Annotations is keyed by question text. It is always non-nil but entries are only present when the user's selection had an associated preview or notes.

Jump to

Keyboard shortcuts

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