Documentation
¶
Overview ¶
Package appstate builds live app snapshots for the computer-use server.
Code generated by textgen; DO NOT EDIT. Unicode data: textgen/LICENSE.unicode. Swift policy: textgen/NOTICE.swift.
Index ¶
- Variables
- func CheckScreenshotGeometry(ctx context.Context, window *axuiautomation.Element, ...) error
- func ListApps(ctx context.Context) ([]computeruse.AppInfo, error)
- func PresentationNodeTextBytes(n *appshotlex.NativeNode, limit int) (int, error)
- func ResolveApp(ctx context.Context, selector string) (computeruse.AppInfo, error)
- func ValidatePresentationNode(n *appshotlex.NativeNode, maxTextBytes int) 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 ContextCapture
- type ContextNode
- type ContextPresentation
- type ContextPresentationIndex
- type ContextPresentationRow
- type ContextPresentationText
- type ContextTitle
- type Snapshot
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCaptureResourceLimit = errors.New("screenshot resource limit")
ErrCaptureResourceLimit reports a screenshot exceeding capture resource limits.
var ErrCaptureUnstable = errors.New("window capture geometry did not stabilize")
ErrCaptureUnstable reports geometry that failed consecutive stabilization checks.
var ErrContextTargetChanged = errors.New("context target changed")
var ErrContextWindowNotFound = errors.New("context window not found")
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 PresentationNodeTextBytes ¶ added in v0.4.0
func PresentationNodeTextBytes(n *appshotlex.NativeNode, limit int) (int, error)
PresentationNodeTextBytes bounds retained lexical text without rendering.
Example ¶
size, err := PresentationNodeTextBytes(presentationFixture("row"), 100)
fmt.Println(size, err)
Output: 3 <nil>
func ResolveApp ¶
func ValidatePresentationNode ¶ added in v0.4.0
func ValidatePresentationNode(n *appshotlex.NativeNode, maxTextBytes int) error
ValidatePresentationNode bounds input before invoking the shared lexer. It validates copied state, not the authenticity of supplied Unicode facts.
Example ¶
fmt.Println(ValidatePresentationNode(presentationFixture("row"), 100))
Output: <nil>
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 ContextCapture ¶ added in v0.4.0
type ContextCapture struct {
Window computeruse.WindowInfo
// Title is capture-only optional title evidence; nil means it was not supplied.
Title *ContextTitle
Nodes []ContextNode
// Presentation is supplied only after native transformation and rendering.
Presentation *ContextPresentation
PNG []byte
Screenshot *computeruse.ScreenshotInfo
}
ContextCapture owns no accessibility handles or action-session authority.
func CaptureContextWindow ¶ added in v0.4.0
func CaptureContextWindow(ctx context.Context, info computeruse.AppInfo, windowID uint32, expected *axuiautomation.Element, maxNodes int, imageMode string) (ContextCapture, error)
CaptureContextWindow captures an exact retained window, or resolves a window once by ID (zero means focused). It never launches or activates an application. info is the caller-resolved application identity, not an authorization grant. expected remains owned by the caller. All internally obtained handles are released.
type ContextNode ¶ added in v0.4.0
type ContextNode struct {
computeruse.ElementNode
Subrole string
SecureValue bool
FloatValue bool
ValueType computeruse.ValueType
Focused bool
SelectedText string
WebFocus *ContextNode
WebDocument bool
RoleDescription string
RoleDescriptionPresent bool
URL string
Help string
Placeholder string
ValueDescription string
// contains filtered or unexported fields
}
ContextNode contains capture-local data and a secure-plaintext omission marker.
type ContextPresentation ¶ added in v0.4.0
type ContextPresentation struct {
Body, Focus []ContextPresentationRow
SelectedText ContextPresentationText
RawNodeCount, OmittedSecureValues int
}
ContextPresentation is the handle-free result of completed native rendering. Body and Focus are independent depth-first occurrence lists. Empty Body is valid after transformation of a nonempty raw capture.
func CopyContextPresentation ¶ added in v0.4.0
func CopyContextPresentation(ctx context.Context, p ContextPresentation, maxNodes, maxTextBytes int) (ContextPresentation, error)
CopyContextPresentation validates and copies a completed presentation before the caller closes its capture lease. Limits bound both forests cumulatively; callers must also charge acquisition and temporary work to their own ledger.
Example ¶
p, err := CopyContextPresentation(context.Background(), ContextPresentation{RawNodeCount: 1}, 10, 1024)
fmt.Println(p.RawNodeCount, len(p.Body), err)
Output: 1 0 <nil>
type ContextPresentationIndex ¶ added in v0.4.0
ContextPresentationIndex is copied provenance, not an action target.
type ContextPresentationRow ¶ added in v0.4.0
type ContextPresentationRow struct {
Node *appshotlex.NativeNode
Depth int
RawPosition, RenderElementID ContextPresentationIndex
DetailText ContextPresentationText
}
ContextPresentationRow is one occurrence in an admitted render forest. Depth belongs to that forest; RawPosition belongs to acquisition.
type ContextPresentationText ¶ added in v0.4.0
ContextPresentationText preserves absent and present-empty text.
type ContextTitle ¶ added in v0.4.0
ContextTitle preserves the distinction between absent and present-empty title metadata. Text is empty when Present is false.
Example ¶
absent := ContextTitle{}
empty := ContextTitle{Present: true}
fmt.Printf("absent: present=%t text=%q\n", absent.Present, absent.Text)
fmt.Printf("empty: present=%t text=%q\n", empty.Present, empty.Text)
Output: absent: present=false text="" empty: present=true text=""
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
Source Files
¶
- ax_bindings.go
- builder.go
- capture.go
- context.go
- context_date.go
- context_date_bindings.go
- context_hierarchy.go
- context_hierarchy_bindings.go
- context_identity.go
- context_optional_string.go
- context_placeholder.go
- context_presentation.go
- context_prune_state.go
- context_role_description.go
- context_scalar.go
- context_scalar_observation.go
- context_scalar_observation_bindings.go
- context_secure.go
- context_selection.go
- context_string.go
- context_title.go
- context_title_bindings.go
- context_unsigned.go
- context_unsigned_bindings.go
- context_url.go
- context_url_bindings.go
- context_value_type.go
- context_web.go
- doc.go
- native_acquire.go
- native_ax_bindings.go
- native_batch.go
- native_batch_acquire.go
- native_batch_decode.go
- native_batch_empty.go
- native_batch_funding.go
- native_batch_request.go
- native_children.go
- native_children_bindings.go
- native_context.go
- native_context_bindings.go
- native_flags.go
- native_initial_metadata.go
- native_lease.go
- native_lexical_state.go
- native_pipeline.go
- native_render.go
- native_stage0.go
- native_stage1.go
- native_stage2.go
- native_text.go
- native_text_prepare.go
- native_text_tables.go
- native_url.go
- selection_reader.go
- visible_text.go