interaction

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package interaction defines a host-neutral port for soliciting input from a human user in the middle of an agent run.

The port deliberately does NOT depend on planexec (or any specific runtime). The planexec runtime reaches it only through an adapter in the Job host (planexec.Question -> interaction.Request), and a future agent tool can depend on the very same interface without importing planexec. Keeping this type set runtime-agnostic is what lets the interaction capability grow (instruction injection, approval gates, ...) without rippling planexec types across the codebase.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answer

type Answer struct {
	ID       string
	Choice   string   // ItemSelect
	Choices  []string // ItemMultiSelect
	FreeText string   // ItemFreeText
}

Answer is the user's reply for one Item, correlated by ID. Exactly the field matching the item's Type is populated.

type Interactor

type Interactor interface {
	Solicit(ctx context.Context, req Request) (Outcome, error)
}

Interactor is the host port used to solicit input from the user. The planexec OnQuestion callback adapts to this; a future agent tool depends on the same interface. Implementations persist whatever state is needed to resume and post the question to the user's surface (e.g. Slack).

type Item

type Item struct {
	// ID is unique within the Request; the host echoes it back in the
	// matching Answer so the caller can correlate.
	ID string
	// Text is the human-facing prompt for this item.
	Text string
	// Type selects the answer control. select / multi_select require
	// Options; free_text ignores them.
	Type ItemType
	// Options is the closed list of allowed answers for select /
	// multi_select. Ignored for free_text.
	Options []string
}

Item is one question within a Request.

type ItemType

type ItemType string

ItemType discriminates how the host should render the answer control. Closed-list types (select / multi_select) require non-empty Options; free_text ignores Options.

const (
	ItemSelect      ItemType = "select"
	ItemMultiSelect ItemType = "multi_select"
	ItemFreeText    ItemType = "free_text"
)

func (ItemType) IsValid

func (t ItemType) IsValid() bool

IsValid reports whether t is a recognised item type.

type Outcome

type Outcome struct {
	Paused  bool
	Answers []Answer
}

Outcome reports what happened to a Solicit call. For the pause/resume model used by Jobs, Paused is true and the caller must stop and return; resumption happens out-of-band (the user answers via Slack, which re-enters the run). Answers is reserved for a future synchronous path and is empty when Paused is true.

type Request

type Request struct {
	// Reason is the shared rationale ("why am I asking?") rendered once
	// above the items.
	Reason string
	// Items is the ordered list of questions (1..maxItems).
	Items []Item
}

Request is a host-neutral description of something the agent wants from the user mid-run. Today it carries a question (a set of items); it is shaped to grow by adding fields/Kind later without breaking callers.

func (*Request) Validate

func (r *Request) Validate() error

Validate enforces the Request invariants at the call site: item count bounds, unique non-empty IDs, valid types, and Options presence for the closed-list types.

Jump to

Keyboard shortcuts

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