wire

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wire is the protocol between the host and the on-device agents.

One TCP connection carries everything in both directions. Each message is a single line of JSON. A message may carry binary data (a screenshot): it then has a "bin" field with the byte count, and that many raw bytes follow the newline.

The host sends requests: {"id":7,"op":"tap","x":100,"y":200} The agent answers each: {"id":7,"ok":true,...} or {"id":7,"ok":false,"error":"..."} The agent also pushes events without being asked (no "id"):

{"ev":"changed","seq":41}   the UI changed (an accessibility event arrived)
{"ev":"settled","seq":41}   no change for the quiet window since seq 41

The host never polls: it waits on these events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentError

type AgentError struct {
	Op  string
	Msg string
}

AgentError is an error the agent reported for a request.

func (*AgentError) Error

func (e *AgentError) Error() string

type Conn

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

Conn is a connection to one agent.

func Dial

func Dial(addr string, timeout time.Duration) (*Conn, error)

Dial connects to an agent at addr, retrying until timeout while it starts up.

func (*Conn) Call

func (c *Conn) Call(op string, params map[string]any, timeout time.Duration) (*Msg, error)

Call sends a request and waits for its answer. params is merged into the request.

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Done

func (c *Conn) Done() <-chan struct{}

Done is closed when the connection drops.

func (*Conn) Err

func (c *Conn) Err() error

Err is why the connection dropped.

func (*Conn) Hello

func (c *Conn) Hello() *Msg

Hello is the agent's greeting.

func (*Conn) HelloVersion

func (c *Conn) HelloVersion() string

HelloVersion is the agent build version from its greeting.

func (*Conn) Seq

func (c *Conn) Seq() int64

Seq is the sequence number of the latest UI change the agent reported.

func (*Conn) SettledSeq

func (c *Conn) SettledSeq() int64

SettledSeq is the change sequence number the latest "settled" event covered.

func (*Conn) Subscribe

func (c *Conn) Subscribe() chan *Msg

Subscribe returns a channel of pushed events. Call Unsubscribe when done.

func (*Conn) Unsubscribe

func (c *Conn) Unsubscribe(ch chan *Msg)

type Msg

type Msg struct {
	ID    int64           `json:"id,omitempty"`
	OK    bool            `json:"ok,omitempty"`
	Error string          `json:"error,omitempty"`
	Ev    string          `json:"ev,omitempty"`
	Seq   int64           `json:"seq,omitempty"`
	Bin   int             `json:"bin,omitempty"`
	Raw   json.RawMessage `json:"-"`
	Data  []byte          `json:"-"`
}

Msg is a decoded message. Raw keeps the full JSON so callers can decode op-specific fields.

func (*Msg) Decode

func (m *Msg) Decode(v any) error

Decode unmarshals the full message into v.

Jump to

Keyboard shortcuts

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