botdesktop

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 43 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

The Bot Desktop: each profile's own headless screen, a TigerVNC and Xfce desktop on this machine or inside the terminal backend's sandbox, that computer use and the browser drive and that a person can take over, the agent's actions refused until they hand it back

Index

Constants

View Source
const (
	Runtime = "status"
	Leased  = "lease"
)

Kinds of change

View Source
const (
	ThumbWidth   = 960
	ThumbHeight  = 600
	ThumbQuality = 72
)

Box a picture of the screen fits in, and its JPEG quality

View Source
const (
	Agent = "agent"
	Human = "human"
)

Who drives the screen

View Source
const (
	// On the machine icebath runs on
	Gateway = "gateway"
	// Inside the sandbox of the terminal backend
	Terminal = "terminal"
	// Nowhere: the backend's sandbox can't host it and the screen may not leave it
	Refused = "refused"
)

Where a screen runs

View Source
const Cancelled = -1

Exit code of an install the user gave no sudo password for

View Source
const (
	DefaultWait = 15 * time.Second
)

How long a start waits for the launcher to publish, on this machine and in a sandbox

View Source
const DesktopUser = "pn"

Account the desktop and browser run as inside a sandbox image that has it

View Source
const LauncherLog = "launcher.log"

Name of the file in the folder of the screen state that the launcher of the desktop writes its output to

View Source
const NoSudo = -2

Exit code of an install on a host without root or sudo, the command to run as root said through the lines

Variables

View Source
var Packages = map[string][]string{
	"apt": {"tigervnc-standalone-server", "xfce4-panel", "xfwm4", "xfdesktop4", "xfce4-settings", "xfce4-terminal", "dbus-x11", "x11-xserver-utils",
		"x11-utils", "x11-xkb-utils", "xauth", "fonts-dejavu-core"},
	"dnf": {"tigervnc-x11-server", "xfce4-panel", "xfwm4", "xfdesktop", "xfce4-settings", "xfce4-terminal", "dbus-daemon", "xsetroot", "xset",
		"xdpyinfo", "xprop", "xorg-x11-xauth", "setxkbmap", "dejavu-sans-fonts"},
	"pacman": {"tigervnc", "xfce4-panel", "xfwm4", "xfdesktop", "xfce4-settings", "xfce4-terminal", "dbus", "xorg-xsetroot", "xorg-xset",
		"xorg-xdpyinfo", "xorg-xprop", "xorg-xauth", "xorg-setxkbmap", "ttf-dejavu"},
}

Packages each package manager installs a screen from

View Source
var Required = []string{"Xvnc", "xfwm4", "xfce4-panel", "xfdesktop", "xfsettingsd", "dbus-run-session", "xauth", "xdpyinfo", "setxkbmap", "xprop"}

Programs a screen on this machine needs

View Source
var SharedArgs = []string{"--test-type", "--ozone-platform=x11", "--start-maximized", fmt.Sprintf("--disk-cache-size=%d", diskCache)}

Flags the agent's launch on the screen and the dock icon share: on the screen's X display even under a Wayland session, maximized

Functions

func InstallCommand

func InstallCommand() string

Install command as a person types it here, sudo first unless root; empty without a package manager

func Installable

func Installable() bool

Whether the install could succeed here: a package manager, and root or sudo

func Manager

func Manager() string

Package manager of the machine, apt, dnf or pacman, empty for none

func Missing

func Missing() []string

Programs of a screen missing from PATH

func Note

func Note(running bool, display, holder string) string

One line telling the agent of its screen: running on a display with who holds it, or no longer running; empty for a running screen whose display or holder is not known

func ProfileDir

func ProfileDir(cfg *config.Config) string

Profile folder the screen's browser keeps: browser.user_data_dir, else the screen's own

func Shared

func Shared() []string

Files the screens keep outside the folders of the profiles, which every icebath of the computer shares: the lock taken while a display is picked

func Socket

func Socket(cfg *config.Config) string

Socket of this machine a viewer reaches the screen through, empty while it is down or in a sandbox

func StateDir

func StateDir(cfg *config.Config) string

Folder of the profile's screen state

func Supported

func Supported() bool

Whether screens run here: Linux only

Types

type Desktop

type Desktop struct {
	Registry
	// contains filtered or unexported fields
}

The screens of every profile

func New

func New(cfg *config.Config, host *terminal.Terminal, b *browser.Browser) *Desktop

func (*Desktop) Admit

func (d *Desktop) Admit(cfg *config.Config) (int64, error)

Epoch an agent action is admitted under, HumanHasControl while a person holds the screen

func (*Desktop) Claim

func (d *Desktop) Claim(cfg *config.Config) error

Takes the install slot of the profile, in this process and across processes, InstallBusy when another holds it

func (*Desktop) Command

func (d *Desktop) Command(ctx context.Context, cfg *config.Config, argv []string, vars map[string]string, what string, start bool) ([]string,
	map[string]string, error)

Command of this machine running argv as the desktop user on the profile's screen in the terminal backend's sandbox, with the variables over what the screen published, which names what it is for in a refusal, and the variables of this machine it runs with, those of the profile the sandbox's client reads: the screen brought up first when start says so. Nil without error for a screen on this machine, and when not starting it, for one that is not up

func (*Desktop) Delete

func (d *Desktop) Delete(profile string) error

Stops the deleted profile's screen and hands its lease back before its folder goes

func (*Desktop) DisplayCommand

func (d *Desktop) DisplayCommand(env terminal.Environment, vars map[string]string, argv []string, what string) ([]string, map[string]string, error)

Command of this machine running argv as the desktop user on the sandbox's screen with the variables, which name what it is for in a refusal, and the variables of this machine it runs with: those of the profile the sandbox's client reads

func (*Desktop) Env

func (d *Desktop) Env(ctx context.Context, cfg *config.Config, base map[string]string) map[string]string

Variables of base with the running screen's DISPLAY, XAUTHORITY and bus merged in and WAYLAND_DISPLAY dropped, so a program started with them opens on the screen; base unchanged while it is down. Base is the environment of the program for the profile, such as its ChildEnv

func (*Desktop) Epoch

func (d *Desktop) Epoch(cfg *config.Config) int64

Epoch the lease is at now, which an admitted action compares to its own once it ran

func (*Desktop) Executable

func (d *Desktop) Executable(cfg *config.Config) string

Chromium the screen runs: the pinned one, then the packaged one, then the system's, the last two swapped under the AppArmor user namespace rule when not root; empty when there is none

func (*Desktop) Hint

func (d *Desktop) Hint(ctx context.Context, cfg *config.Config) string

Line of the runtime environment block for the profile's running screen, empty while none runs

func (*Desktop) HumanHolds

func (d *Desktop) HumanHolds(cfg *config.Config) bool

Whether a person holds the profile's screen

func (*Desktop) InSandbox

func (d *Desktop) InSandbox(cfg *config.Config) bool

Whether the profile's screen lives in the terminal backend's sandbox

func (*Desktop) Install

func (d *Desktop) Install(ctx context.Context, cfg *config.Config, claimed bool, password func() (string, error),
	line func(string)) (Installed, error)

Installs the screen's packages with the distribution's package manager under the profile's slot, claimed here unless the caller did, asking for the sudo password when sudo needs one. Each line the package manager prints is handed to line as its progress, and the whole of it is kept in the profile's logs folder when the install fails

func (*Desktop) Lease

func (d *Desktop) Lease(cfg *config.Config) Lease

Lease of the profile, a person's hold that the launcher of its screen judged abandoned as it stopped the screen handed back first

func (*Desktop) Listen

func (d *Desktop) Listen(cfg *config.Config, hear func(cfg *config.Config, event Event)) func()

Hears every change of a watched screen until the returned stop is called

func (*Desktop) Place

func (d *Desktop) Place(ctx context.Context, cfg *config.Config) (string, error)

Where the browser or driver about to start runs, gateway or terminal, a sandbox screen that is down started first; an error saying why for a refused placement

func (*Desktop) Published

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

Variables the screen published once its bus was up, none while it is down

func (*Desktop) Ready

func (d *Desktop) Ready(ctx context.Context, cfg *config.Config)

Brings the screen up ahead of a tool that drives it: one in the sandbox always, one on this machine when auto_start allows; a failure only logged, for the tool to report

func (*Desktop) Register

func (d *Desktop) Register(registrant Registrant)

Adds a registrant; a registry nested in the host reaches it through Host

func (*Desktop) Release

func (d *Desktop) Release(cfg *config.Config, h Handback) (Lease, error)

Hands the screen back to the agent unless the lease moved since the epoch judged, or another viewer holds it

func (*Desktop) Resolve

func (d *Desktop) Resolve(cfg *config.Config) Placement

Where the profile's screen runs, from its settings and the kind of its terminal backend alone, never starting a sandbox: on this machine for a local backend or when the settings say so, in the sandbox of a backend that can host it, else refused

func (*Desktop) Running

func (d *Desktop) Running(ctx context.Context, cfg *config.Config) (bool, error)

Whether the screen published a display

func (*Desktop) SandboxChromium

func (d *Desktop) SandboxChromium(env terminal.Environment) (string, error)

Playwright Chromium inside the sandbox, empty when its image has none

func (*Desktop) SandboxProfile

func (d *Desktop) SandboxProfile(env terminal.Environment) (string, error)

The one user data dir the agent's browser and the dock icon share inside the sandbox

func (*Desktop) SeedSandboxProfile

func (d *Desktop) SeedSandboxProfile(env terminal.Environment, dir string) error

Writes the quiet preferences into a browser profile inside the sandbox, as the desktop user

func (*Desktop) Start

func (d *Desktop) Start(ctx context.Context, cfg *config.Config, wait time.Duration) (Status, error)

Starts the profile's screen, one already up kept, waiting for the launcher to publish

func (*Desktop) Status

func (d *Desktop) Status(ctx context.Context, cfg *config.Config) (Status, error)

Status of the profile's screen, the sandbox's when it lives there. The launcher of a screen of this machine is looked at once, and what it published and its socket read by what that look found

func (*Desktop) Stop

func (d *Desktop) Stop(ctx context.Context, cfg *config.Config, still func() bool) (bool, error)

Stops the profile's screen, still saying first whether a stop waited on is still due; whether a launcher or a server left behind was signalled

func (*Desktop) StopIfIdle

func (d *Desktop) StopIfIdle(ctx context.Context, cfg *config.Config) (bool, error)

Stops the screen idle past its limit that no live hold of a person keeps, handing an abandoned hold back; whether it stopped

func (*Desktop) SwitchImage

func (d *Desktop) SwitchImage(ctx context.Context, cfg *config.Config, approve bool) (string, error)

Moves the profile's sandbox to the image with the desktop, or keeps the one it runs, answering the image now set

func (*Desktop) Take

func (d *Desktop) Take(cfg *config.Config, viewer, reason string) (Lease, error)

A person takes the screen under the viewer id of their client, last one in winning; a hold by the same viewer stays as it is

func (*Desktop) Thumbnail

func (d *Desktop) Thumbnail(ctx context.Context, cfg *config.Config, width, height, quality int) ([]byte, error)

JPEG of the running screen shrunk into the box, nil when no screen is up; it only reads, so neither the lease nor a person in control is disturbed

func (*Desktop) Touch

func (d *Desktop) Touch(cfg *config.Config)

Notes that the screen was just used, which keeps it from the idle stop, and watches it from now

func (*Desktop) Use

func (d *Desktop) Use(profile string) error

Watches from now the screen of the profile icebath uses, one that ever ran: its launcher leaves the idle stop to this process while it runs, and a person's hold the launcher judged abandoned as it stopped the screen with no icebath running is handed back

func (*Desktop) User

func (d *Desktop) User(env terminal.Environment) (string, error)

Desktop user of the sandbox, the account its browser and screen run as

type Event

type Event struct {
	// Running or stopped, or another holder of the lease
	Kind string
	// The screen as of the change
	Running bool
	Display string
	Lease   Lease
}

A change of a profile's screen

type Handback

type Handback struct {
	Viewer string
	Unless bool
	Epoch  *int64
}

How control is handed back: by the viewer that took it, none meaning anyone; not while a person holds it when unless says so; only while the lease is still at the epoch judged, when one is

type HumanHasControl

type HumanHasControl struct{ Message string }

Refusal of a screen action while a person holds the screen

func (*HumanHasControl) Error

func (e *HumanHasControl) Error() string

type InstallBusy

type InstallBusy struct{ Message string }

Refusal of an install while another holds the profile's slot

func (*InstallBusy) Error

func (e *InstallBusy) Error() string

type Installed

type Installed struct {
	Code   int
	Reason string
	Log    string
}

How an install ended: its exit code, and when it failed why in words and the file in the profile's logs folder that keeps all the package manager printed

type Lease

type Lease struct {
	Holder string `json:"holder"`
	// Capability of the person's client that took it, never shown
	Viewer string `json:"viewer_id,omitempty"`
	// Unix seconds of the last change of hands
	Since  float64 `json:"since"`
	Reason string  `json:"reason"`
	Epoch  int64   `json:"epoch"`
}

Who drives a profile's screen. Every change of hands moves the epoch on, so an action admitted before it can tell its result is void

func (Lease) Hash

func (l Lease) Hash() string

Short hash of the viewer that holds the screen, empty when no viewer does

type Memory

type Memory struct {
	Available, Limit int
}

Memory free for a start and the limit it counts against, in MiB, -1 when unknown

type Placement

type Placement struct {
	Where, Backend, Reason string
}

Where the profile's screen runs, the terminal backend it judged by, and the sentence a refusal says

type Profiles

type Profiles struct{ Desktop *Desktop }

The screens as profiles come and go: a profile's stopped and its lease handed back before it is deleted or its folder moves to a new name, and the screen of the profile icebath uses watched

func (Profiles) Delete

func (p Profiles) Delete(profile string) error

func (Profiles) Stop

func (p Profiles) Stop(profile string) error

func (Profiles) Use

func (p Profiles) Use(profile string) error

type Registrant

type Registrant interface {
	Changed(cfg *config.Config, event Event)
}

What a feature hears of a profile's screen: that it came up or went down, or changed hands, with its status as of then

type Registry

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

func (*Registry) Changed

func (r *Registry) Changed(cfg *config.Config, event Event)

func (*Registry) Host

func (r *Registry) Host() *Desktop

Host the registry is nested in

func (*Registry) Register

func (r *Registry) Register(registrant Registrant)

type Status

type Status struct {
	Profile   string
	Supported bool
	Installed bool
	Missing   []string
	Running   bool
	// Launcher process, zero for none
	PID      int
	Display  string
	Socket   string
	Geometry string
	// Command that installs what is missing
	Install string
	// Chromium the screen runs
	Browser string
	// Why it cannot start now
	Blocker string
	// Free memory and its limit in MB, -1 when unknown
	Available, Limit int
	// gateway, or terminal:<backend>
	Placement string
	// Title of the place of the agent's commands it runs in, for a screen in their sandbox
	Sandbox string
	// Image change of the sandbox it waits on, nil for none
	Switch *terminal.Switch
	Lease  Lease
}

What the profile's screen is: whether it can run and is installed, running and where, who holds it, and what keeps it from starting

Directories

Path Synopsis
Page of Desktop in the settings menu: the profile's own hidden desktop, its state as a sentence, the acts that apply to it now (start and stop, taking it over and handing it back, a screenshot, installing its programs and the image of its sandbox), and its options
Page of Desktop in the settings menu: the profile's own hidden desktop, its state as a sentence, the acts that apply to it now (start and stop, taking it over and handing it back, a screenshot, installing its programs and the image of its sandbox), and its options
Connect service of the agent desktop, through which the screen commands and the app reach the screens of the machine the server runs on
Connect service of the agent desktop, through which the screen commands and the app reach the screens of the machine the server runs on

Jump to

Keyboard shortcuts

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