LavaUI docs GitHub

struct AgentHost

Swift

struct AgentHost

Callbacks the host app provides so the server stays UI-framework-agnostic.

Sources/LavaUI/AgentServer.swift:64

Constructors

init(framebufferSize: @escaping () -> (w: Float, h: Float), settle: @escaping () -> Void, layoutTreeJSON: @escaping (_ maxDepth: Int) -> String, hitLabel: @escaping (_ x: Float, _ y: Float) -> String?, resolveFrame: @escaping (_ sid: String?, _ label: String?, _ id: UInt64?, _ query: String?) -> (label: String, sid: String, x: Float, y: Float, w: Float, h: Float)?, find: @escaping (_ query: String, _ limit: Int) -> [[String : Any]], injectMove: @escaping (_ x: Float, _ y: Float) -> Void, injectClick: @escaping (_ x: Float, _ y: Float, _ button: Int32, _ mods: Int32) -> Void, injectPointerButton: @escaping (_ x: Float, _ y: Float, _ button: Int32, _ pressed: Bool) -> Void, injectScroll: @escaping (_ dx: Float, _ dy: Float) -> Void, injectKey: @escaping (_ key: Int32, _ action: Int32, _ mods: Int32) -> Void, injectText: @escaping (_ text: String) -> Void, screenshotBase64: @escaping (_ x: Int32, _ y: Int32, _ w: Int32, _ h: Int32, _ maxSide: Int32) -> (b64: String, w: Int32, h: Int32)?)

Creates a host from one closure per agent capability.

Sources/LavaUI/AgentServer.swift:100

Properties

var find: (_ query: String, _ limit: Int) -> [[String : Any]]

Up to limit nodes whose label, sid or text matches query, as JSON objects (the agent's find).

Sources/LavaUI/AgentServer.swift:78

var framebufferSize: () -> (w: Float, h: Float)

The window's framebuffer size in pixels.

Sources/LavaUI/AgentServer.swift:66

var hitLabel: (_ x: Float, _ y: Float) -> String?

The label of the topmost node at a window point, or nil over nothing (the agent's hit_test).

Sources/LavaUI/AgentServer.swift:72

var injectClick: (_ x: Float, _ y: Float, _ button: Int32, _ mods: Int32) -> Void

mods is KeyMods, so a script can Ctrl+click or Shift+click.

Sources/LavaUI/AgentServer.swift:82

var injectKey: (_ key: Int32, _ action: Int32, _ mods: Int32) -> Void

Delivers a synthetic key event: a GLFW key code, action and KeyMods bits.

Sources/LavaUI/AgentServer.swift:90

var injectMove: (_ x: Float, _ y: Float) -> Void

Delivers a synthetic pointer move to the window.

Sources/LavaUI/AgentServer.swift:80

var injectPointerButton: (_ x: Float, _ y: Float, _ button: Int32, _ pressed: Bool) -> Void

Delivers a synthetic press (pressed == true) or release of button at a point.

Sources/LavaUI/AgentServer.swift:84

var injectScroll: (_ dx: Float, _ dy: Float) -> Void

Delivers a synthetic wheel scroll, in notches.

Sources/LavaUI/AgentServer.swift:88

var injectText: (_ text: String) -> Void

Delivers typed text, as if entered on the keyboard.

Sources/LavaUI/AgentServer.swift:92

var layoutTreeJSON: (_ maxDepth: Int) -> String

The layout tree as JSON, at most maxDepth levels deep (the agent's layout_tree).

Sources/LavaUI/AgentServer.swift:70

var resolveFrame: (_ sid: String?, _ label: String?, _ id: UInt64?, _ query: String?) -> (label: String, sid: String, x: Float, y: Float, w: Float, h: Float)?

Resolve a frame by sid/agentId, label, process id, or first find hit.

Sources/LavaUI/AgentServer.swift:74

var screenshotBase64: (_ x: Int32, _ y: Int32, _ w: Int32, _ h: Int32, _ maxSide: Int32) -> (b64: String, w: Int32, h: Int32)?

Capture pixels only (caller settles when needed). Returns base64 PNG plus encoded size (after optional downsample).

Sources/LavaUI/AgentServer.swift:95

var settle: () -> Void

Force layout+present; should also drain any injected input first.

Sources/LavaUI/AgentServer.swift:68