core

package
v0.700.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package core provides the platform-independent building blocks of the Pando Desktop Controller: a normalized accessibility-tree element model, a selector DSL, snapshot/ref bookkeeping, action resolution and rendering for LLM consumption. No package in this directory performs any OS call; platform backends live under internal/uiauto/platform.

Index

Constants

View Source
const (
	CombinatorDescendant = " "
	CombinatorChild      = ">"
)

Combinator values describe the relationship between a step and the one before it in a Selector chain.

Variables

This section is empty.

Functions

func NewElementID

func NewElementID(n int) string

NewElementID returns the traversal-order element id for index n (1-based), e.g. NewElementID(1) == "e1".

func ParseElementRef

func ParseElementRef(ref string) (snapshotID string, elemID string, err error)

ParseElementRef splits a qualified ElementRef into its snapshot id and element id components. It returns an INVALID_ARGS DesktopError if ref is not well formed.

func RenderElements

func RenderElements(elements []*Element, opts RenderOptions) string

RenderElements renders a flat list of elements (e.g. a desktop_find result), one line per element, honouring MaxNodes/IncludeBounds and IncludeInvisible from opts. MaxDepth is not applicable to a flat list and is ignored.

func RenderTree

func RenderTree(snap *Snapshot, opts RenderOptions) string

RenderTree renders snap as a compact, indented, agent-facing tree starting from a synthetic header line describing the window/app, then one line per element in the form:

@<snapshotID>:<elemID> role "name" value="..." [flags...]

Semantically empty container nodes (no name/value/description/actions) are collapsed: they are not printed, but their children are still rendered at the collapsed node's depth.

Types

type Action

type Action struct {
	Kind ActionKind
	// Text carries the payload for ActionSetValue/ActionType.
	Text string
	// Amount carries the scroll delta for ActionScroll (positive/negative,
	// backend-defined units).
	Amount int
	// Key carries the key or chord identifier for ActionPress (e.g.
	// "Enter", "Ctrl+A").
	Key string
}

Action is a single request to perform ActionKind Kind against an Element, carrying whatever payload that kind needs.

type ActionKind

type ActionKind string

ActionKind enumerates the semantic actions that can be performed on an Element, either natively (through the accessibility backend) or, as a fallback, physically (through synthetic mouse/keyboard input).

const (
	ActionInvoke   ActionKind = "invoke"
	ActionFocus    ActionKind = "focus"
	ActionSetValue ActionKind = "setvalue"
	ActionToggle   ActionKind = "toggle"
	ActionSelect   ActionKind = "select"
	ActionExpand   ActionKind = "expand"
	ActionCollapse ActionKind = "collapse"
	ActionScroll   ActionKind = "scroll"
	ActionPress    ActionKind = "press"
	ActionType     ActionKind = "type"
)

type ActionResolver

type ActionResolver struct {
	Backend       Backend
	Physical      PhysicalInput
	AllowPhysical bool
}

ActionResolver implements the native-first, physical-fallback policy: it always tries the accessibility Backend first, and only falls back to PhysicalInput when the backend fails or does not support the action, and AllowPhysical is true.

func NewActionResolver

func NewActionResolver(backend Backend, physical PhysicalInput, allowPhysical bool) *ActionResolver

NewActionResolver builds an ActionResolver.

func (*ActionResolver) Click

func (r *ActionResolver) Click(ctx context.Context, el *Element) (*ActionResult, error)

Click performs a click: native Invoke first, physical click at Bounds.Center() as fallback.

func (*ActionResolver) Focus

func (r *ActionResolver) Focus(ctx context.Context, el *Element) (*ActionResult, error)

Focus focuses el: native Focus first, physical click as fallback.

func (*ActionResolver) Press

func (r *ActionResolver) Press(ctx context.Context, el *Element, key string) (*ActionResult, error)

Press sends a key/chord: native Press first, physical PressKey as fallback. When el is non-nil, the backend/physical input is asked to target it; a nil el means "send globally" (physical only).

func (*ActionResolver) Scroll

func (r *ActionResolver) Scroll(ctx context.Context, el *Element, amount int) (*ActionResult, error)

Scroll scrolls el (or the point at its bounds center): native Scroll first, physical scroll as fallback.

func (*ActionResolver) Type

func (r *ActionResolver) Type(ctx context.Context, el *Element, text string) (*ActionResult, error)

Type enters text: native SetValue, then native Type, then physical focus+TypeText as fallback.

type ActionResult

type ActionResult struct {
	// Method is "native" when the backend performed the action directly,
	// or "physical" when a synthetic-input fallback was used.
	Method string
	Action Action
	// Notes records anything worth surfacing to the caller/LLM, e.g. why a
	// fallback was taken.
	Notes []string
}

ActionResult reports how an action was ultimately carried out.

type AppInfo

type AppInfo struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	PID     int    `json:"pid"`
	Windows int    `json:"windows"`
}

AppInfo is a lightweight description of a running application, cheap enough to list without walking any accessibility tree.

type AttrPredicate

type AttrPredicate struct {
	Attr  string
	Op    string
	Value string
}

AttrPredicate is a single `[attr op "value"]` filter on a SelectorStep.

type Backend

type Backend interface {
	// Name returns the backend identifier, e.g. "atspi", "uia", "ax",
	// "cdp", "null".
	Name() string

	// Available reports the Capabilities this backend can offer in the
	// current session. It may perform cheap probing but must not block on
	// user interaction.
	Available(ctx context.Context) (Capabilities, error)

	// Apps lists running applications visible to this backend.
	Apps(ctx context.Context) ([]AppInfo, error)

	// Windows lists the top-level windows of appID, or of all apps when
	// appID is empty.
	Windows(ctx context.Context, appID string) ([]WindowInfo, error)

	// Find resolves a selector within scope, returning at most limit
	// matches (limit <= 0 means "backend default cap"). Implementations
	// should stop traversing as soon as they have enough matches.
	Find(ctx context.Context, scope Scope, sel *Selector, limit int) ([]*Element, error)

	// Children returns the direct children of el.
	Children(ctx context.Context, el *Element) ([]*Element, error)

	// Properties reads a set of extra properties for el. When props is
	// empty, the backend returns whatever extra properties it can cheaply
	// provide.
	Properties(ctx context.Context, el *Element, props []string) (map[string]any, error)

	// Perform executes action against el.
	Perform(ctx context.Context, el *Element, action Action) error

	// Close releases any resources (connections, handles) held by the
	// backend.
	Close() error
}

Backend is the platform-specific accessibility/automation driver. It must never be forced to build a whole accessibility tree: Find/Children let each platform optimize traversal (cached subtree fetch, batched attribute reads, incremental queries, ...).

type BackendFactory

type BackendFactory func() (Backend, error)

BackendFactory constructs a Backend instance.

type Bounds

type Bounds struct {
	X int `json:"x"`
	Y int `json:"y"`
	W int `json:"w"`
	H int `json:"h"`
}

Bounds is an axis-aligned rectangle in screen coordinates.

func (Bounds) Center

func (b Bounds) Center() (x, y int)

Center returns the midpoint of the bounds, suitable as a physical click target.

func (Bounds) Empty

func (b Bounds) Empty() bool

Empty reports whether the bounds carry no usable size (e.g. an element that was never laid out or that the backend could not measure).

type Capabilities

type Capabilities struct {
	Screenshot       bool `json:"screenshot"`
	Accessibility    bool `json:"accessibility"`
	UIInspection     bool `json:"uiInspection"`
	Mouse            bool `json:"mouse"`
	Keyboard         bool `json:"keyboard"`
	WindowManagement bool `json:"windowManagement"`
	UIActions        bool `json:"uiActions"`
	Events           bool `json:"events"`
}

Capabilities describes what a Backend can actually do on the current platform/session. Callers must check these rather than branching on platform name, since e.g. Wayland sessions may lack input/screenshot capabilities even though the backend itself is available.

func (Capabilities) Missing

func (c Capabilities) Missing(required ...string) []string

Missing returns the subset of required capability names (case-insensitive field names such as "screenshot", "uiActions") that are not enabled on c. An unrecognized name is reported as missing too, so callers can catch typos.

func (Capabilities) String

func (c Capabilities) String() string

String renders the enabled capabilities as a comma-separated, alphabetically sorted list, e.g. "accessibility,keyboard,mouse".

type Condition

type Condition string

Condition is a wait predicate evaluated by WaitFor against the element(s) a Locator resolves to.

const (
	// ConditionExists waits until the locator resolves to at least one
	// element.
	ConditionExists Condition = "exists"
	// ConditionNotExists waits until the locator resolves to no element.
	ConditionNotExists Condition = "notexists"
	// ConditionVisible waits until the locator resolves to an element
	// with Visible == true.
	ConditionVisible Condition = "visible"
	// ConditionEnabled waits until the locator resolves to an element
	// with Enabled == true.
	ConditionEnabled Condition = "enabled"
	// ConditionFocused waits until the locator resolves to an element
	// with Focused == true.
	ConditionFocused Condition = "focused"
)

type DesktopError

type DesktopError struct {
	Code       ErrorCode
	Message    string
	Suggestion string
}

DesktopError is the structured error type returned by every uiauto operation that can fail in an LLM-actionable way.

func AsDesktopError

func AsDesktopError(err error) (*DesktopError, bool)

AsDesktopError unwraps err into a *DesktopError if it is (or wraps) one.

func NewActionFailedError

func NewActionFailedError(message string) *DesktopError

NewActionFailedError constructs an ACTION_FAILED DesktopError.

func NewAppNotFoundError

func NewAppNotFoundError(message string) *DesktopError

NewAppNotFoundError constructs an APP_NOT_FOUND DesktopError.

func NewElementNotFoundError

func NewElementNotFoundError(message string) *DesktopError

NewElementNotFoundError constructs an ELEMENT_NOT_FOUND DesktopError.

func NewInvalidArgsError

func NewInvalidArgsError(message string) *DesktopError

NewInvalidArgsError constructs an INVALID_ARGS DesktopError.

func NewPermDeniedError

func NewPermDeniedError(message string) *DesktopError

NewPermDeniedError constructs a PERM_DENIED DesktopError.

func NewPlatformNotSupportedError

func NewPlatformNotSupportedError(message string) *DesktopError

NewPlatformNotSupportedError constructs a PLATFORM_NOT_SUPPORTED DesktopError.

func NewPolicyDeniedError

func NewPolicyDeniedError(message string) *DesktopError

NewPolicyDeniedError constructs a POLICY_DENIED DesktopError.

func NewSnapshotNotFoundError

func NewSnapshotNotFoundError(message string) *DesktopError

NewSnapshotNotFoundError constructs a SNAPSHOT_NOT_FOUND DesktopError.

func NewStaleRefError

func NewStaleRefError(message string) *DesktopError

NewStaleRefError constructs a STALE_REF DesktopError.

func NewTimeoutError

func NewTimeoutError(message string) *DesktopError

NewTimeoutError constructs a TIMEOUT DesktopError.

func (*DesktopError) Error

func (e *DesktopError) Error() string

Error implements the error interface.

func (*DesktopError) Payload

func (e *DesktopError) Payload() map[string]any

Payload renders the DesktopError as the structured, LLM-facing response shape: {"ok":false,"error":{"code":...,"message":...,"suggestion":...}}.

type Element

type Element struct {
	ID          ElementRef   `json:"id"`
	Role        Role         `json:"role"`
	Name        string       `json:"name,omitempty"`
	Value       string       `json:"value,omitempty"`
	Description string       `json:"description,omitempty"`
	Bounds      Bounds       `json:"bounds,omitempty"`
	Enabled     bool         `json:"enabled"`
	Visible     bool         `json:"visible"`
	Focused     bool         `json:"focused"`
	ParentID    ElementRef   `json:"parentId,omitempty"`
	ChildIDs    []ElementRef `json:"childIds,omitempty"`
	Actions     []ActionKind `json:"actions,omitempty"`

	// Backend is the name of the backend that produced this element
	// ("atspi", "uia", "ax", "cdp", "null").
	Backend string `json:"backend,omitempty"`
	// AppID identifies the owning application, backend-specific.
	AppID string `json:"appId,omitempty"`
	// WindowID identifies the owning window, backend-specific.
	WindowID string `json:"windowId,omitempty"`

	Native NativeData `json:"native,omitempty"`
}

Element is the normalized, platform-independent representation of a node in an accessibility tree.

func WaitFor

func WaitFor(ctx context.Context, b Backend, l *Locator, cond Condition, timeout, interval time.Duration) (*Element, error)

WaitFor polls the locator against b until cond is satisfied, timeout elapses or ctx is cancelled, checking every interval. It always performs at least one immediate check before waiting. On success it returns the matched element (nil for ConditionNotExists). On timeout it returns a TIMEOUT DesktopError; on context cancellation it returns ctx.Err().

type ElementRef

type ElementRef string

ElementRef is a qualified reference to an Element, always scoped to the snapshot that produced it, of the form "@<snapshotID>:<elemID>".

func FormatElementRef

func FormatElementRef(snapshotID, elemID string) ElementRef

FormatElementRef builds a qualified ElementRef from a snapshot id and an element id.

type ErrorCode

type ErrorCode string

ErrorCode enumerates the structured error codes surfaced to the LLM by the desktop tools. Every DesktopError carries exactly one of these.

const (
	// ErrPermDenied signals the OS or the assistive-technology stack
	// denied access (e.g. accessibility permission not granted).
	ErrPermDenied ErrorCode = "PERM_DENIED"
	// ErrElementNotFound signals a selector or ref did not resolve to any
	// element.
	ErrElementNotFound ErrorCode = "ELEMENT_NOT_FOUND"
	// ErrAppNotFound signals the requested application/process was not
	// found among the running apps.
	ErrAppNotFound ErrorCode = "APP_NOT_FOUND"
	// ErrStaleRef signals a qualified ElementRef's snapshot expired or was
	// evicted, or the element no longer exists within it.
	ErrStaleRef ErrorCode = "STALE_REF"
	// ErrSnapshotNotFound signals a snapshot id is unknown to the store.
	ErrSnapshotNotFound ErrorCode = "SNAPSHOT_NOT_FOUND"
	// ErrPolicyDenied signals the action was blocked by the allow/deny
	// application policy.
	ErrPolicyDenied ErrorCode = "POLICY_DENIED"
	// ErrActionFailed signals a backend action (native or physical) was
	// attempted and failed.
	ErrActionFailed ErrorCode = "ACTION_FAILED"
	// ErrPlatformNotSupported signals the current platform/backend cannot
	// perform the requested operation.
	ErrPlatformNotSupported ErrorCode = "PLATFORM_NOT_SUPPORTED"
	// ErrTimeout signals a wait/retry loop exceeded its deadline.
	ErrTimeout ErrorCode = "TIMEOUT"
	// ErrInvalidArgs signals malformed input, e.g. an unparsable selector
	// or ref.
	ErrInvalidArgs ErrorCode = "INVALID_ARGS"
)

type Locator

type Locator struct {
	Scope    Scope
	Selector *Selector
}

Locator is a lazy reference to an element: it captures a Scope and Selector and only resolves against a Backend when asked to, so callers can re-resolve immediately before acting instead of trusting a potentially stale snapshot.

func NewLocator

func NewLocator(scope Scope, sel *Selector) *Locator

NewLocator builds a Locator.

func (*Locator) Resolve

func (l *Locator) Resolve(ctx context.Context, b Backend) (*Element, error)

Resolve resolves the locator against b, returning the single best match. It returns an ELEMENT_NOT_FOUND DesktopError when nothing matches.

func (*Locator) ResolveAll

func (l *Locator) ResolveAll(ctx context.Context, b Backend) ([]*Element, error)

ResolveAll resolves the locator against b, returning up to limit matches (limit <= 0 means "no explicit cap", left to the backend's default).

type NativeData

type NativeData struct {
	// Platform identifies the backend that produced this data, e.g.
	// "atspi", "uia", "ax", "cdp".
	Platform string `json:"platform,omitempty"`
	// Role is the raw, un-normalized platform role (e.g. AT-SPI "push button").
	Role string `json:"role,omitempty"`
	// SubRole is a platform-specific refinement (e.g. macOS AXSubrole).
	SubRole string `json:"subRole,omitempty"`
	// Data carries any additional backend-specific attributes.
	Data map[string]any `json:"data,omitempty"`
}

NativeData is the per-backend escape hatch: it preserves the raw platform role/subrole and any extra attributes a normalized Element cannot express.

type NullBackend

type NullBackend struct{}

NullBackend is a Backend implementation used when no platform backend is available (unsupported OS, missing permissions, etc). Every operation fails with PLATFORM_NOT_SUPPORTED except Available, which reports an all-false Capabilities so callers can degrade gracefully instead of crashing.

func NewNullBackend

func NewNullBackend() *NullBackend

NewNullBackend constructs a NullBackend.

func (*NullBackend) Apps

func (n *NullBackend) Apps(ctx context.Context) ([]AppInfo, error)

Apps implements Backend.

func (*NullBackend) Available

func (n *NullBackend) Available(ctx context.Context) (Capabilities, error)

Available implements Backend.

func (*NullBackend) Children

func (n *NullBackend) Children(ctx context.Context, el *Element) ([]*Element, error)

Children implements Backend.

func (*NullBackend) Close

func (n *NullBackend) Close() error

Close implements Backend.

func (*NullBackend) Find

func (n *NullBackend) Find(ctx context.Context, scope Scope, sel *Selector, limit int) ([]*Element, error)

Find implements Backend.

func (*NullBackend) Name

func (n *NullBackend) Name() string

Name implements Backend.

func (*NullBackend) Perform

func (n *NullBackend) Perform(ctx context.Context, el *Element, action Action) error

Perform implements Backend.

func (*NullBackend) Properties

func (n *NullBackend) Properties(ctx context.Context, el *Element, props []string) (map[string]any, error)

Properties implements Backend.

func (*NullBackend) Windows

func (n *NullBackend) Windows(ctx context.Context, appID string) ([]WindowInfo, error)

Windows implements Backend.

type PhysicalInput

type PhysicalInput interface {
	Click(x, y int) error
	MoveMouse(x, y int) error
	TypeText(s string) error
	PressKey(key string) error
	Scroll(x, y, amount int) error
}

PhysicalInput is the minimal synthetic-input surface an ActionResolver falls back to when a backend cannot perform an action natively. It is implemented by the internal/uiauto/input package in later phases; core only depends on this interface.

type Registry

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

Registry maps backend names to constructors, so callers can resolve "auto" (platform default) or a specific backend name without importing every platform package.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty backend Registry.

func (*Registry) Names

func (r *Registry) Names() []string

Names returns the registered backend names, sorted.

func (*Registry) Register

func (r *Registry) Register(name string, factory BackendFactory)

Register adds or replaces the factory for the given backend name.

func (*Registry) Resolve

func (r *Registry) Resolve(name string) (Backend, error)

Resolve constructs the backend registered under name. name == "auto" (or "") tries the configured auto-order, then any remaining registered backends, returning the first one that constructs successfully. Resolve never itself returns NullBackend; callers should fall back to it explicitly when no backend is available.

func (*Registry) SetAutoOrder

func (r *Registry) SetAutoOrder(names ...string)

SetAutoOrder sets the preference order used when resolving "auto".

type RenderOptions

type RenderOptions struct {
	// MaxNodes caps how many element lines are emitted; 0 means unbounded.
	MaxNodes int
	// MaxDepth caps how many levels below the root are descended; 0 means
	// unbounded.
	MaxDepth int
	// IncludeBounds appends bounds="x,y,w,h" to each line.
	IncludeBounds bool
	// IncludeInvisible includes elements with Visible == false. When
	// false (the default), invisible subtrees are skipped entirely.
	IncludeInvisible bool
}

RenderOptions controls the agent-facing compact renderer.

type Role

type Role string

Role is the normalized, platform-independent semantic role of an accessibility element.

const (
	RoleApplication Role = "application"
	RoleWindow      Role = "window"
	RoleDialog      Role = "dialog"
	RoleButton      Role = "button"
	RoleCheckbox    Role = "checkbox"
	RoleRadio       Role = "radio"
	RoleTextField   Role = "textfield"
	RoleTextArea    Role = "textarea"
	RoleComboBox    Role = "combobox"
	RoleList        Role = "list"
	RoleListItem    Role = "listitem"
	RoleMenu        Role = "menu"
	RoleMenuItem    Role = "menuitem"
	RoleMenuBar     Role = "menubar"
	RoleTab         Role = "tab"
	RoleTabList     Role = "tablist"
	RoleTree        Role = "tree"
	RoleTreeItem    Role = "treeitem"
	RoleTable       Role = "table"
	RoleRow         Role = "row"
	RoleCell        Role = "cell"
	RoleLink        Role = "link"
	RoleImage       Role = "image"
	RoleHeading     Role = "heading"
	RoleLabel       Role = "label"
	RoleText        Role = "text"
	RoleGroup       Role = "group"
	RoleToolbar     Role = "toolbar"
	RoleScrollbar   Role = "scrollbar"
	RoleSlider      Role = "slider"
	RoleProgressBar Role = "progressbar"
	RoleStatusBar   Role = "statusbar"
	RolePanel       Role = "panel"
	RoleSeparator   Role = "separator"
	RoleUnknown     Role = "unknown"
)

Canonical role vocabulary. Backends map their platform-specific roles onto this set via NormalizeRole.

func NormalizeRole

func NormalizeRole(platform, raw string) Role

NormalizeRole maps a raw, platform-specific role string to the canonical Role vocabulary. platform selects the per-backend table ("atspi", "uia", "ax", "cdp"); any other value, or a raw string not present in the table, falls back to lowercasing raw and matching it directly against the canonical vocabulary, and finally to RoleUnknown.

func (Role) Matches

func (r Role) Matches(selectorRole string) bool

Matches reports whether the receiver role matches the given selector role token, case-insensitively and allowing a small set of common aliases (e.g. "textbox" -> textfield, "edit" -> textfield). A selectorRole of "*" always matches.

type Scope

type Scope struct {
	AppID    string
	WindowID string
	// Root, when set, restricts the search to the subtree rooted at this
	// element instead of the whole app/window.
	Root *Element
	// Depth caps how many levels below Root/window the backend should
	// descend. Zero means "backend default".
	Depth int
}

Scope restricts a Find/traversal operation to a subtree, so a backend never has to walk more of the tree than the caller asked for.

type Selector

type Selector struct {
	Steps []SelectorStep
}

Selector is a parsed chain of SelectorStep, e.g. `app[name="Chrome"] window[name="Settings"] > button[name="New Tab"]`.

func ParseSelector

func ParseSelector(s string) (*Selector, error)

ParseSelector parses a selector string. It returns an INVALID_ARGS DesktopError on malformed input.

func (*Selector) String

func (s *Selector) String() string

String renders the Selector back to its canonical selector syntax.

type SelectorStep

type SelectorStep struct {
	// Combinator is the relationship to the previous step: "" for the
	// first step in the chain, CombinatorDescendant or CombinatorChild
	// otherwise.
	Combinator string
	// Role is the raw role token as written in the selector ("" or "*"
	// both mean "any role").
	Role    string
	Attrs   []AttrPredicate
	Pseudos []string
	// Nth is the 1-indexed sibling position filter, or 0 when unset. It
	// requires sibling context that Element alone does not carry, so
	// MatchesElement does not apply it; callers that walk a tree with
	// sibling information are expected to apply it themselves.
	Nth int
}

SelectorStep is one element of a Selector chain: an optional role token, zero or more attribute predicates, zero or more pseudo-class filters and an optional 1-indexed `nth` position filter.

func (SelectorStep) MatchesElement

func (step SelectorStep) MatchesElement(el *Element) bool

MatchesElement reports whether el satisfies this step's role, attribute and pseudo-class predicates. The Nth predicate, if set, is not evaluated here since it requires sibling context; see SelectorStep.Nth.

func (SelectorStep) String

func (step SelectorStep) String() string

String renders the step back to selector syntax (without its leading combinator, which Selector.String prints between steps).

type Snapshot

type Snapshot struct {
	ID        string
	CreatedAt time.Time
	Backend   string
	AppID     string
	WindowID  string
	Root      *Element
	// Elements indexes every element in the snapshot by its bare element
	// id (e.g. "e17", without the "@<snapshotID>:" prefix).
	Elements map[string]*Element
	// Origin is the selector (if any) that produced this snapshot, kept so
	// the snapshot can be re-resolved after it goes stale.
	Origin *Selector
	// NativeHandles lets a backend stash opaque per-element native
	// handles (e.g. a COM pointer or a D-Bus object path) keyed by bare
	// element id, without leaking backend types into core.
	NativeHandles map[string]any
}

Snapshot is a captured, immutable view of an accessibility (sub)tree at a point in time. Every Element it contains is addressable through a qualified ElementRef scoped to this snapshot's ID.

type SnapshotStore

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

SnapshotStore is a goroutine-safe, TTL-based, size-bounded (LRU) store of Snapshots, and the single place that resolves qualified ElementRefs.

func NewSnapshotStore

func NewSnapshotStore(ttl time.Duration, max int) *SnapshotStore

NewSnapshotStore creates a SnapshotStore. ttl <= 0 disables expiry; max <= 0 disables the LRU cap.

func (*SnapshotStore) Get

func (s *SnapshotStore) Get(id string) (*Snapshot, error)

Get retrieves a snapshot by id, returning SNAPSHOT_NOT_FOUND or STALE_REF as appropriate.

func (*SnapshotStore) Len

func (s *SnapshotStore) Len() int

Len returns the current number of stored snapshots (test/introspection helper).

func (*SnapshotStore) Prune

func (s *SnapshotStore) Prune()

Prune removes expired entries and, if over capacity, evicts the least recently accessed entries down to max.

func (*SnapshotStore) Put

func (s *SnapshotStore) Put(snap *Snapshot) *Snapshot

Put stores snap, assigning it a fresh ID if it does not already have one, and evicts expired/excess entries.

func (*SnapshotStore) Resolve

func (s *SnapshotStore) Resolve(ref ElementRef) (*Snapshot, *Element, error)

Resolve looks up the element addressed by a qualified ElementRef, returning the owning snapshot and the element. Errors: INVALID_ARGS for a malformed ref, SNAPSHOT_NOT_FOUND / STALE_REF for the snapshot lookup, ELEMENT_NOT_FOUND when the snapshot no longer contains that element id.

type WindowInfo

type WindowInfo struct {
	ID      string `json:"id"`
	AppID   string `json:"appId"`
	Title   string `json:"title"`
	Bounds  Bounds `json:"bounds"`
	Focused bool   `json:"focused"`
}

WindowInfo is a lightweight description of a top-level window.

Jump to

Keyboard shortcuts

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