Help us shape the future of Go! Take the 2026 Go Developer Survey

appstate

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package appstate builds live app snapshots for the computer-use server.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckScreenshotGeometry added in v0.3.0

func CheckScreenshotGeometry(ctx context.Context, window *axuiautomation.Element, info *computeruse.ScreenshotInfo) error

CheckScreenshotGeometry checks the exact window ID, unrounded logical frame, and active display topology recorded in info. It does not capture pixels, verify process birth, or make dispatch atomic. The caller retains window's lifetime and handles authorization and intervention. The context bounds AX messaging waits. Nil arguments or invalid metadata return an error.

Example
package main

import (
	"context"
	"fmt"
	"github.com/tmc/axmcp/internal/computeruse/appstate"
)

func main() {
	err := appstate.CheckScreenshotGeometry(context.Background(), nil, nil)
	fmt.Println(err)
}
Output:
screenshot window and metadata required

func ListApps

func ListApps(ctx context.Context) ([]computeruse.AppInfo, error)

func ResolveApp

func ResolveApp(ctx context.Context, selector string) (computeruse.AppInfo, error)

Types

type Builder

type Builder struct{}

func NewBuilder

func NewBuilder() *Builder

func (*Builder) Build

func (b *Builder) Build(ctx context.Context, selector, windowTitle string, instructions computeruse.InstructionProvider) (*Snapshot, error)

func (*Builder) BuildWindow added in v0.3.0

func (b *Builder) BuildWindow(ctx context.Context, pid int32, windowID uint32, instructions computeruse.InstructionProvider) (*Snapshot, error)

BuildWindow captures one running process's exact window. A zero windowID selects its focused window; a positive ID must match exactly. It never launches an app or falls back to another window. The caller owns the returned snapshot. Process-instance validation across capture is the action runner's responsibility.

Example
builder := NewBuilder()
_, err := builder.BuildWindow(context.Background(), 0, 0, nil)
fmt.Println(err)
Output:
pid must be positive

func (*Builder) BuildWindowElement added in v0.3.0

func (b *Builder) BuildWindowElement(ctx context.Context, pid int32, window *axuiautomation.Element, instructions computeruse.InstructionProvider) (*Snapshot, error)

BuildWindowElement captures the live window matching a retained accessibility element in the exact process's window list. It never falls back to a window title, numeric ID, or focused window. The caller retains ownership of window; the returned snapshot independently owns its enumerated handles. The caller holds window alive and validates the process instance across capture.

Example
builder := NewBuilder()
_, err := builder.BuildWindowElement(context.Background(), 1, nil, nil)
fmt.Println(err)
Output:
window is required

type Snapshot

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

func (*Snapshot) App

func (*Snapshot) Close

func (s *Snapshot) Close() error

func (*Snapshot) Resolve

func (*Snapshot) State

func (s *Snapshot) State() computeruse.AppState

Jump to

Keyboard shortcuts

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