headless

package
v0.224.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(cfg *config.Config, opts Options, newServices func() Services) (err error)

Run executes one headless task. newServices builds the composition root; it is called only after the flags validate, so a bad --format or --mode never starts any service.

Types

type Interrupts added in v0.221.0

type Interrupts interface {
	Note(id, reason string)
	Forget(id string)
}

Interrupts is the registry a run's interrupts are noted under, so the worker answering a resume knows which broker each interrupt belongs to. A nil one belongs to an unattended run, where nothing answers the resume.

type Options

type Options struct {
	Model           string
	Task            string
	Files           []string
	NoSave          bool
	SessionID       string
	RequireApproval bool
	Heartbeat       bool
	Remote          bool
	ResultFile      string
	Format          string
	Mode            string
	Serve           bool
	KeepAlive       bool
}

Options carries the headless command's flag values.

type Panel added in v0.219.0

type Panel struct {
	// contains filtered or unexported fields
}

Panel answers the panel frames a session worker reads on stdin: listings, model and mode switches, direct tool requests and the conversation snapshot. Each reply is one JSON line on out, one Write per line.

func NewPanel added in v0.219.0

func NewPanel(deps PanelDeps, out io.Writer) *Panel

NewPanel builds the panel units, one per frame family, each holding only the dependencies it uses.

func (*Panel) Handle added in v0.219.0

func (p *Panel) Handle(line []byte) bool

Handle answers one stdin line and reports whether the panel consumed it. A run input's messages are recorded in the shell history but left for the turn loop, and an approval_response is consumed only when it answers a tool_request.

type PanelDeps added in v0.219.0

PanelDeps are the collaborators the panel units use, all from the worker's own container, so every answer is scoped to the worker's project dir.

type Publish added in v0.219.0

type Publish func(event agentdomain.ChatEvent) (agui.Published, bool)

Publish maps a chat event to the run state or activity its owner publishes for it. It reports false for an event it does not own.

type RunEncoder added in v0.219.0

type RunEncoder struct {
	// contains filtered or unexported fields
}

RunEncoder renders one agent run on the AG-UI protocol: it maps each ChatEvent to the AG-UI events of the run it writes, and an approval or a question suspends the run with the interrupt outcome and continues on the run the answer opens.

func NewRunEncoder added in v0.219.0

func NewRunEncoder(w io.Writer, deps RunEncoderDeps) *RunEncoder

NewRunEncoder builds the encoder for one run over w. History, when non-empty, is emitted as MESSAGES_SNAPSHOT right after RUN_STARTED, so the run continues an existing conversation. Approvals and questions broker IPC decisions for gated tool calls and questions (nil channels reject or dismiss immediately). Startup drains the boot progress the run opens with, and Interrupt notes the interrupts the run raises so resume entries find their broker.

func (*RunEncoder) Finish added in v0.219.0

func (r *RunEncoder) Finish() error

Finish writes the current run's one terminal event, RUN_FINISHED carrying the usage and the session extras or the failure the run ended with. It returns the run error for the caller's exit code and telemetry.

func (*RunEncoder) Handle added in v0.219.0

func (r *RunEncoder) Handle(event agentdomain.ChatEvent)

Handle renders one agent ChatEvent into the run's AG-UI stream.

func (*RunEncoder) Start added in v0.219.0

func (r *RunEncoder) Start(threadID, runID string)

Start frames the run: RUN_STARTED, the MESSAGES_SNAPSHOT of the restored history when the run continues an existing conversation, and the boot progress recorded before the run opened.

type RunEncoderDeps added in v0.221.0

type RunEncoderDeps struct {
	Model     string
	Repo      convdomain.ConversationRepository
	History   []convdomain.ConversationEntry
	Jobs      func() []scheddomain.TrackedJob
	Approvals <-chan ipc.ApprovalResponse
	Questions <-chan ipc.UserQuestionResponse
	Startup   *startupNotes
	Interrupt Interrupts
	Publish   []Publish
}

RunEncoderDeps are the collaborators of one run's encoder.

type Services added in v0.207.0

type Services interface {
	RouteBrowserRequests(request func(ctx context.Context, id string, frame json.RawMessage) (json.RawMessage, error))
	SetUINotifier(n agentdomain.UINotifier)
	Shutdown(ctx context.Context) error
	StartScreenshotServer(sessionID string) *computerinfra.ScreenshotServer
	GetGatewaySupervisor() *gateway.Supervisor
	GetAgentSupervisor() a2adomain.AgentSupervisor
	GetAgentService() agentdomain.AgentService
	GetMCPSupervisor() mcpdomain.Supervisor
	GetToolRegistry() *tools.Registry
	GetToolService() agentdomain.ToolService
	GetFileService() agentdomain.FileService
	GetImageService() agentdomain.ImageService
	GetModelService() convdomain.ModelService
	GetConversationRepository() convdomain.ConversationRepository
	GetMessageQueue() convdomain.MessageQueue
	GetSessionRollover() convdomain.SessionRollover
	GetStateStore() *statemanager.Store
	GetShortcutRegistry() *shortcuts.Registry
	GetBackgroundTaskRegistry() scheddomain.BackgroundTaskRegistry
	GetTelemetryRecorder() *telemetry.Recorder
	NewPanel(out io.Writer) *Panel
}

Services is the slice of the composition root a headless run uses. cmd/headless supplies the *container.ServiceContainer.

Jump to

Keyboard shortcuts

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