cua

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 46 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

cua-driver, the program computer use drives the desktop through: where it is, whether it keeps the contract icebath needs, what readies it once it installs and the sessions of it a backend holds

Index

Constants

View Source
const InstallHint = "cua-driver is not installed. Install it in /programs."

Guidance for a missing driver

Variables

This section is empty.

Functions

func Supported

func Supported() bool

Platforms the driver runs on

func Unknown

func Unknown(cfg *config.Config) error

Why the profile's computer_use.backend names no provider there is, nil for the built-in one

Types

type Action

type Action struct {
	OK         bool
	Action     string
	Message    string
	Meta       map[string]any
	Verified   *bool
	Effect     *string
	Escalation map[string]any
	Path       *string
	Degraded   *bool
	Delivery   *string
	Code       *string
}

What an action came to: whether the driver took it, and its verdict of what happened

type Autostart

type Autostart struct {
	// What it is and its name, as a person reads them
	Kind, Name string
	// File of a unit or entry, empty for the logon task
	Path string
	// A systemd user unit, stopped and disabled before its file goes
	Systemd bool
}

One way the driver starts on its own that outlives icebath: a systemd user unit, an XDG autostart entry, or the Windows logon task

func Autostarts

func Autostarts(folders []string) []Autostart

Every way the driver starts on its own whose program lies in one of the folders, such as those of icebath's package manager: the units and entries of the user's config folder, and the Windows logon task

func (Autostart) Remove

func (a Autostart) Remove(ctx context.Context) error

Stops and removes the way the driver starts on its own: a systemd user unit is stopped and disabled, its file removed and systemd told; an entry's file is removed; the logon task is deleted, with an administrator's approval when Windows asks for one

type Backend

type Backend struct {
	Mode string
	// contains filtered or unexported fields
}

A session of the driver one icebath session drives the desktop through, sticking to the window its last capture or focus picked

func (*Backend) App

func (b *Backend) App() string

App input goes to, empty before a capture or focus picked one

func (*Backend) Capture

func (b *Backend) Capture(ctx context.Context, mode, app string, pid, window *int) (*Capture, error)

Captures the front window, the app's, or an exact window, in som, ax or vision mode, making it the target of input

func (*Backend) Click

func (b *Backend) Click(ctx context.Context, c Click) *Action

Click or double click by element index or by point, with the button checked against the driver's choices

func (*Backend) Drag

func (b *Backend) Drag(ctx context.Context, d Drag) *Action

Drag between two elements or two points

func (*Backend) FocusApp

func (b *Backend) FocusApp(ctx context.Context, app string, raise bool) (*Action, error)

Makes the app's window the target, raising it only through the separately approved bring_to_front

func (*Backend) Key

func (b *Backend) Key(ctx context.Context, keys string, d Delivery) *Action

Presses a key, or a combination through hotkey

func (*Backend) ListApps

func (b *Backend) ListApps(ctx context.Context) ([]any, error)

Running apps: the structured list, the shapes older drivers reply in, those of the windows, then the text listing

func (*Backend) ListWindows

func (b *Backend) ListWindows(ctx context.Context) ([]map[string]any, error)

Windows on screen, front first, fetched through the CLI when MCP gives none

func (*Backend) Scroll

func (b *Backend) Scroll(ctx context.Context, s Scroll) *Action

Scroll by wheel ticks, one to fifty, at an element or a point when the driver takes points

func (*Backend) SetValue

func (b *Backend) SetValue(ctx context.Context, value string, element *int) *Action

Sets the value of an element, a popup's option included

func (*Backend) Start

func (b *Backend) Start(ctx context.Context) error

Checks the contract, starts the private daemon and the session, then declares the run's label and applies the profile's settings

func (*Backend) Stop

func (b *Backend) Stop() error

Ends the driver session, then closes it and stops the private daemon even when a step fails

func (*Backend) Target

func (b *Backend) Target() (pid, window *int)

Exact window input goes to, nil before one was picked

func (*Backend) Type

func (b *Backend) Type(ctx context.Context, text string, d Delivery) *Action

Types the text into the target window

func (*Backend) Wait

func (b *Backend) Wait(ctx context.Context, seconds float64) *Action

Waits the seconds asked, nought to thirty

type Capture

type Capture struct {
	Mode   string
	Width  int
	Height int
	// Base64 screenshot and its type, empty when there is none
	Image string
	Mime  string
	// Bytes of the screenshot
	Bytes    int
	Elements []Element
	App      string
	Title    string
	Note     string
	// Cap of the accessibility walk, zero for none
	AXMax int
}

A screenshot, the element map, or both, as the mode asked

type Checked

type Checked struct {
	Name, Status, Message, Hint string
}

One check of a health report as the doctor reads it: its name, pass, fail or skip, what it found and what to do

func Checks

func Checks(report map[string]any) ([]Checked, string)

The checks of a health report in its order, and its verdict: ok, degraded or failed

type Click

type Click struct {
	Element, X, Y *int
	Button        string
	Count         int
	Modifiers     []string
	Delivery
}

type Contract

type Contract struct {
	Ready   bool
	Binary  string
	Version string
	Reason  string
}

Whether the driver keeps the contract, and why not

type Delivery

type Delivery struct {
	Mode  string
	Front bool
}

How input is delivered: in the background, or with the window fronted, the persistent bring_to_front first when asked

type Drag

type Drag struct {
	From, To     *int
	FromXY, ToXY *[2]int
	Button       string
	Modifiers    []string
	Delivery
}

type Driver

type Driver struct {

	// Each profile's own screen, which the driver acts on while it runs, from inside the terminal backend's sandbox when it lives there
	Desktop *botdesktop.Desktop
	// contains filtered or unexported fields
}

The driver of this machine, as each profile picks it: the managed driver is one per machine, and a profile may name its own program

func New

func New(host *terminal.Terminal, pm *packages.Packages, desktop *botdesktop.Desktop) *Driver

The driver, which the package manager readies with Settle each time a person installs it

func (*Driver) Backend

func (d *Driver) Backend(cfg *config.Config, mode string) (*Backend, error)

Backend in the permission mode, with a daemon of its own outside the standard one

func (*Driver) Command

func (d *Driver) Command(cfg *config.Config, given string) (string, error)

Binary of the profile's driver: the program given or the profile's override, found on the search path of the driver's environment when it is a bare name, else the managed one; empty when there is none, never installing

func (*Driver) Contract

func (d *Driver) Contract(ctx context.Context, cfg *config.Config, binary string) (Contract, error)

Contract of the binary, the selected one when empty, kept thirty seconds while the binary stays the same file

func (*Driver) Display

func (d *Driver) Display(cfg *config.Config) string

Display a driver started now acts on, which a kept backend must still match

func (*Driver) Doctor

func (d *Driver) Doctor(ctx context.Context, cfg *config.Config, say Say, out io.Writer, include, skip []string, asJSON bool) (int, error)

`computer-use doctor`: the driver's health report, or one composed from probes, with the checks icebath adds; 0 when ok, 1 when degraded or failed, 2 when the driver is missing or can't be asked

func (*Driver) Env

func (d *Driver) Env(cfg *config.Config) map[string]string

Variables of the driver's children: this machine's child environment for the profile with the display of its Bot Desktop while it runs, the driver's telemetry off unless the profile allows it, no update check of its own, and Wayland directly when asked for on a Wayland session

func (*Driver) GrantCommand

func (d *Driver) GrantCommand(ctx context.Context, cfg *config.Config, say Say, out, errOut io.Writer) (int, error)

`computer-use permissions grant`: asks macOS for the grants, the dialog attributed to the driver, what the driver prints written to out and errOut as it is

func (*Driver) Health

func (d *Driver) Health(ctx context.Context, cfg *config.Config, include, skip []string) (map[string]any, map[string]any, error)

The driver's health report, or one composed from probes where the driver denies its own, with the checks icebath adds, and what the program says of itself beside it: an *Unhealthy when computer use names no driver icebath has, the driver is missing, can't be started or gives no report

func (*Driver) Installed

func (d *Driver) Installed(cfg *config.Config) (bool, error)

Whether a driver is there to run for the profile, its override or the managed one

func (*Driver) Linux

func (d *Driver) Linux(cfg *config.Config) bool

Whether the driver acts on Linux: on this machine, or always inside the terminal backend's sandbox

func (*Driver) Override

func (d *Driver) Override(cfg *config.Config) string

Program the profile names in place of the managed driver, empty for none

func (*Driver) PermissionsCommand

func (d *Driver) PermissionsCommand(ctx context.Context, cfg *config.Config, say Say, out io.Writer, asJSON bool) (int, error)

`computer-use permissions status`: the grants of the provider as JSON written to out, or said as a checklist

func (*Driver) Sandboxed

func (d *Driver) Sandboxed(ctx context.Context, cfg *config.Config) ([]string, map[string]string, error)

Command of this machine that runs the driver's MCP server on the profile's screen inside the terminal backend's sandbox, the screen started first, and the variables of this machine it runs with, those of the profile the sandbox's client reads; nil for a screen on this machine

func (*Driver) Settle

func (d *Driver) Settle(ctx context.Context, cfg *config.Config, binary string, r packages.Reporter) error

Readies the driver a person installed for this computer: it must keep the contract icebath needs, then gets what its platform needs, the logon task on Windows and the signed app registered with Launch Services on macOS; a failure says what is left to do

func (*Driver) Shown

func (d *Driver) Shown(cfg *config.Config, binary string) string

Binary of the driver as a person is told it: the profile's override as the settings write it when they name a variable in it and the binary is the one it names, so nothing told shows the variable's value; the binary itself else

func (*Driver) Status

func (d *Driver) Status(ctx context.Context, cfg *config.Config, given string) (*Status, error)

Readiness of the profile's provider: for the driver its version, its doctor's probes, and on macOS its privacy grants

func (*Driver) StatusCommand

func (d *Driver) StatusCommand(ctx context.Context, cfg *config.Config, say Say) (int, error)

`computer-use status`: the driver selected, where it came from, its contract, and on Linux the serve daemons that are not listening

type Element

type Element struct {
	Index    int
	Role     string
	Label    string
	Bounds   [4]int
	App      string
	PID      int
	WindowID int
	// Capability the driver minted for the element in this snapshot, empty when it mints none
	Token string
}

One interactable element of a capture, its bounds x, y, width and height in the screen's own pixels

type Printer

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

Where readying the driver tells the person what it does: notes and warnings, as lines of the install in their tones

func (Printer) Info

func (p Printer) Info(text string)

func (Printer) Warning

func (p Printer) Warning(text string)

type Probe

type Probe struct {
	Label   string `json:"label"`
	Status  string `json:"status"`
	Message string `json:"message"`
}

One probe of the driver's own doctor

type Say

type Say func(text string, tone Tone)

Where a command says what it found, line by line in the tone of each, the indent of a line kept before its mark

type Scroll

type Scroll struct {
	Direction     string
	Amount        int
	Element, X, Y *int
	Modifiers     []string
	Delivery
}

type Status

type Status struct {
	Platform                  string  `json:"platform"`
	PlatformSupported         bool    `json:"platform_supported"`
	Installed                 bool    `json:"installed"`
	Version                   *string `json:"version"`
	Ready                     *bool   `json:"ready"`
	CanGrant                  bool    `json:"can_grant"`
	Checks                    []Probe `json:"checks"`
	Source                    any     `json:"source"`
	Error                     *string `json:"error"`
	Accessibility             *bool   `json:"accessibility"`
	ScreenRecording           *bool   `json:"screen_recording"`
	ScreenRecordingCapturable *bool   `json:"screen_recording_capturable"`
}

How ready computer use is on this machine, as the permissions command and the status show it

type Tone

type Tone int

How a line of what a command says reads

const (
	Plain Tone = iota
	// The heading of a part, such as the verdict of a health report
	Step
	Good
	Warn
	Bad
	// Said by the way, such as a hint or where a program is
	Dim
)

type Unhealthy

type Unhealthy struct {
	Text string
	Fix  []string
}

Why the driver gives no health report, as a person reads it: what is wrong, then what to do

func (*Unhealthy) Error

func (e *Unhealthy) Error() string

Jump to

Keyboard shortcuts

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