Documentation
¶
Overview ¶
Package appstate builds live app snapshots for the computer-use server.
Index ¶
- func CheckScreenshotGeometry(ctx context.Context, window *axuiautomation.Element, ...) error
- func ListApps(ctx context.Context) ([]computeruse.AppInfo, error)
- func ResolveApp(ctx context.Context, selector string) (computeruse.AppInfo, error)
- type Builder
- func (b *Builder) Build(ctx context.Context, selector, windowTitle string, ...) (*Snapshot, error)
- func (b *Builder) BuildWindow(ctx context.Context, pid int32, windowID uint32, ...) (*Snapshot, error)
- func (b *Builder) BuildWindowElement(ctx context.Context, pid int32, window *axuiautomation.Element, ...) (*Snapshot, error)
- type Snapshot
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 ResolveApp ¶
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 (s *Snapshot) App() *axuiautomation.Application
func (*Snapshot) Resolve ¶
func (s *Snapshot) Resolve(index int) (*axuiautomation.Element, computeruse.ElementNode, error)
func (*Snapshot) State ¶
func (s *Snapshot) State() computeruse.AppState