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
- Variables
- func InstallCommand() string
- func Installable() bool
- func Manager() string
- func Missing() []string
- func Note(running bool, display, holder string) string
- func ProfileDir(cfg *config.Config) string
- func Shared() []string
- func Socket(cfg *config.Config) string
- func StateDir(cfg *config.Config) string
- func Supported() bool
- type Desktop
- func (d *Desktop) Admit(cfg *config.Config) (int64, error)
- func (d *Desktop) Claim(cfg *config.Config) error
- func (d *Desktop) Command(ctx context.Context, cfg *config.Config, argv []string, vars map[string]string, ...) ([]string, map[string]string, error)
- func (d *Desktop) Delete(profile string) error
- func (d *Desktop) DisplayCommand(env terminal.Environment, vars map[string]string, argv []string, what string) ([]string, map[string]string, error)
- func (d *Desktop) Env(ctx context.Context, cfg *config.Config, base map[string]string) map[string]string
- func (d *Desktop) Epoch(cfg *config.Config) int64
- func (d *Desktop) Executable(cfg *config.Config) string
- func (d *Desktop) Hint(ctx context.Context, cfg *config.Config) string
- func (d *Desktop) HumanHolds(cfg *config.Config) bool
- func (d *Desktop) InSandbox(cfg *config.Config) bool
- func (d *Desktop) Install(ctx context.Context, cfg *config.Config, claimed bool, ...) (Installed, error)
- func (d *Desktop) Lease(cfg *config.Config) Lease
- func (d *Desktop) Listen(cfg *config.Config, hear func(cfg *config.Config, event Event)) func()
- func (d *Desktop) Place(ctx context.Context, cfg *config.Config) (string, error)
- func (d *Desktop) Published(ctx context.Context, cfg *config.Config) (map[string]string, error)
- func (d *Desktop) Ready(ctx context.Context, cfg *config.Config)
- func (d *Desktop) Register(registrant Registrant)
- func (d *Desktop) Release(cfg *config.Config, h Handback) (Lease, error)
- func (d *Desktop) Resolve(cfg *config.Config) Placement
- func (d *Desktop) Running(ctx context.Context, cfg *config.Config) (bool, error)
- func (d *Desktop) SandboxChromium(env terminal.Environment) (string, error)
- func (d *Desktop) SandboxProfile(env terminal.Environment) (string, error)
- func (d *Desktop) SeedSandboxProfile(env terminal.Environment, dir string) error
- func (d *Desktop) Start(ctx context.Context, cfg *config.Config, wait time.Duration) (Status, error)
- func (d *Desktop) Status(ctx context.Context, cfg *config.Config) (Status, error)
- func (d *Desktop) Stop(ctx context.Context, cfg *config.Config, still func() bool) (bool, error)
- func (d *Desktop) StopIfIdle(ctx context.Context, cfg *config.Config) (bool, error)
- func (d *Desktop) SwitchImage(ctx context.Context, cfg *config.Config, approve bool) (string, error)
- func (d *Desktop) Take(cfg *config.Config, viewer, reason string) (Lease, error)
- func (d *Desktop) Thumbnail(ctx context.Context, cfg *config.Config, width, height, quality int) ([]byte, error)
- func (d *Desktop) Touch(cfg *config.Config)
- func (d *Desktop) Use(profile string) error
- func (d *Desktop) User(env terminal.Environment) (string, error)
- type Event
- type Handback
- type HumanHasControl
- type InstallBusy
- type Installed
- type Lease
- type Memory
- type Placement
- type Profiles
- type Registrant
- type Registry
- type Status
Constants ¶
const ( Runtime = "status" Leased = "lease" )
Kinds of change
const ( ThumbWidth = 960 ThumbHeight = 600 ThumbQuality = 72 )
Box a picture of the screen fits in, and its JPEG quality
const ( Agent = "agent" Human = "human" )
Who drives the screen
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
const Cancelled = -1
Exit code of an install the user gave no sudo password for
const (
DefaultWait = 15 * time.Second
)
How long a start waits for the launcher to publish, on this machine and in a sandbox
const DesktopUser = "pn"
Account the desktop and browser run as inside a sandbox image that has it
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
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 ¶
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
var Required = []string{"Xvnc", "xfwm4", "xfce4-panel", "xfdesktop", "xfsettingsd", "dbus-run-session", "xauth", "xdpyinfo", "setxkbmap", "xprop"}
Programs a screen on this machine needs
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 Note ¶
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 ¶
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
Types ¶
type Desktop ¶
type Desktop struct {
Registry
// contains filtered or unexported fields
}
The screens of every profile
func (*Desktop) Admit ¶
Epoch an agent action is admitted under, HumanHasControl while a person holds the screen
func (*Desktop) Claim ¶
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 ¶
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 ¶
Epoch the lease is at now, which an admitted action compares to its own once it ran
func (*Desktop) Executable ¶
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 ¶
Line of the runtime environment block for the profile's running screen, empty while none runs
func (*Desktop) HumanHolds ¶
Whether a person holds the profile's screen
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 ¶
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) Place ¶
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 ¶
Variables the screen published once its bus was up, none while it is down
func (*Desktop) Ready ¶
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 ¶
Hands the screen back to the agent unless the lease moved since the epoch judged, or another viewer holds it
func (*Desktop) Resolve ¶
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) 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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Notes that the screen was just used, which keeps it from the idle stop, and watches it from now
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 ¶
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 ¶
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
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
type Registrant ¶
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) 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
Source Files
¶
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 |