headless

package
v0.219.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 41 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 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
}

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 user_message is recorded in the shell history but left for the turn loop, and an approval_response is consumed only when it answers a tool_request.

func (*Panel) TakeSnapshotReply added in v0.219.0

func (p *Panel) TakeSnapshotReply() bool

TakeSnapshotReply reports and clears whether the panel just answered a new_session or resume_conversation frame with a MESSAGES_SNAPSHOT, so the run opening right after it need not repeat the same snapshot.

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.CustomEvent, bool)

Publish maps a chat event to the CUSTOM event 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.

func NewRunEncoder added in v0.219.0

func NewRunEncoder(w io.Writer, model string, repo convdomain.ConversationRepository, history []convdomain.ConversationEntry, jobs func() []scheddomain.TrackedJob, approvals <-chan ipc.ApprovalResponse, questions <-chan ipc.UserQuestionResponse, publish ...Publish) *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). publish renders the events the encoder does not map itself.

func (*RunEncoder) Finish added in v0.219.0

func (r *RunEncoder) Finish() error

Finish writes the run's one terminal event, RUN_FINISHED carrying the session totals 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, then a MESSAGES_SNAPSHOT of the restored history when the run continues an existing conversation.

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