perception library

Module B — server-side perception. One barrel export covering the VM connection, the inspector client, the scene model, stable-id generation, and the geometry/painted/hittable resolver.

Classes

AndroidNativeReader
Android native surfaces: the window manager says whose window has focus, and uiautomator dump reads it.
BusyResult
The app's VM stopped answering while the gate polled and had not recovered by the ceiling.
CoordinateResolver
Resolves nodes to live geometry. Lazy — re-queries every call.
CreationLocation
GeometryExpr
InspectorClient
Parses inspector trees into typed SceneNodes, reaching the app through FlutterRuntime only — no direct RPC calls.
NativeReader
Reads whatever native UI covers the app.
NativeSceneReader
Reads native surface content via glint-iossim ax-snapshot. Returns a parsed scene when the Simulator exposes an AX tree (needs macOS a11y permission), else a sentinel scene flagging an unreadable native surface.
NativeSurface
A native surface read as data: its kind, its question, the choices it offers, and the other text on it.
NeverReadyResult
NotFoundResult
OcrNativeReader
Reads a native surface over the app from a screenshot with text recognition, each line becoming a node at its place; for devices whose accessibility tree glint cannot reach.
ReadinessGate
§7.2 readiness primitive. Polls fresh scenes until glintId both exists in the tree AND passes a hit test at its centre, or the ceiling is reached.
ReadinessResult
Closed set of outcomes the gate can return.
ReadyResult
ResolvedCoord
One node's live geometry. Global coords in logical pixels. painted and hittable are independent (see §3, §9).
RunnerNativeReader
iOS native UI read through glint's XCUITest runner: system alerts, and surfaces the app presents in-process (photo picker, edit menu) that leave the Flutter lifecycle resumed.
Scene
One inspector group + its SceneNode tree. Dispose releases the VM-side id table.
SceneNode
One node in the perception tree, parsed from inspector DiagnosticsNode JSON.
SceneReader
Reads the inspector tree, assigns stable ids, returns a Scene the caller disposes when done.
SettledAnimating
Frames never went quiet but the readable content stopped changing.
SettledButLoading
SettleDetector
§8.4 settle detection. Polls the scheduler phase; once quietFramesNeeded quiet polls land it checks for loading affordances (a spinner is "frame- stable" while loading) and keeps waiting up to the ceiling if any remain. A screen that never goes quiet (shimmer, Lottie, marquee) is settled once two tree reads stabilityGapMs apart carry the same content signature.
SettledOk
SettleResult
SettleTimedOut
StableIdGenerator
Assigns symbolic glintIds — see §9 of source-of-truth for the algorithm. Same widget at the same source location + tree path → same id every read.
VmClient
VM-service connection scoped to the first Flutter isolate.

Enums

InspectorGroup
Inspector group identity used by InspectorClient.
SurfaceKind
What kind of native surface covers the app.

Extensions

ModalGeometry on CoordinateResolver
An eval can come back as prose (Instance of…, a Sentinel, an error text) instead of the JSON blob; surface that as a typed failure, never a crash. Dart prints unlaid-out geometry as NaN, which is not JSON: it becomes null so callers can name the condition. Measuring the modal on top of the app: what back needs to close a sheet or dialog.
SurfaceReplyLine on NativeSurface?
A reply summary with the surface's line on its own row, or unchanged when there is none.

Constants

kLoadingAffordanceLabels → const Set<String>
Widget labels that mean "still loading" while they are in the tree. RefreshIndicator is deliberately absent: it wraps a list permanently, only RefreshProgressIndicator is mounted while a refresh is running.
kPageScaffolds → const Set<String>
The widgets a screen is built on: Material's Scaffold and Cupertino's page and tab scaffolds.
kShallowProbeMaxDepth → const int
Max summary-tree depth at which a node is "shallow enough" for an accurate outer ModalRoute name. Deeper nodes are usually inside a GoRouter ShellRoute inner navigator or an off-screen PageView page.
pickerConfirmLabels → const Set<String>
Labels of the button that commits a multi-select pick.

Functions

appBusyCause(Object e) → RuntimeUnresponsiveError?
The VM timeout behind e when the VM did not answer in time (busy or blocked), else null.
classifySurface(Scene scene, {String? owner}) → NativeSurface
Classifies scene (a native reader's snapshot) with its foreign owner window, when the platform names one.
didYouMean(List<String> suggestions) → String?
"did you mean" nextStep line, or null when there is nothing to suggest.
findNativeSurface(Map<String, Object?> reply, {bool wholeApp = false, String? appId}) → ({String name, List<Map<String, Object?>> roots})?
What covers the app in a runner /tree reply: a system alert, else the window's top-level view holding the UIKit-only elements (Flutter's own sit in another, or are hidden by a full-screen modal); null when only Flutter and the keyboard are on screen. With wholeApp (device mode, no Flutter) it is the app's alert or sheet, else the whole app, named from appId.
idForLabel(SceneNode root, String wanted) → String?
The glintId to use when wanted is visible text rather than an id: the nearest tappable ancestor of the matching text, else the text itself; pages under the active one are skipped.
labelHint(SceneNode root, String wanted) → String?
nextStep naming the id behind a label the agent passed as a glintId, or null.
nativeElements(List<Map<String, Object?>> roots, {({double h, double w})? screen, int max = 40, double scale = 1}) → List<NativeNode>
The labelled or tappable elements under roots whose center is on screen (points), at most max, with frames in points times scale.
nativeScene(Iterable<NativeNode> nodes, double dpr) → Scene
The labelled or tappable nodes as a flat native scene in logical points.
otherDeviceServers(String serial, String adbPath, {Future<ProcessResult> run(String, List<String>) = boundedRun}) → Future<List<String>>
Automation servers other tools left running on the device (app_process mains such as mobile-mcp's DeviceServer or scrcpy); they hold the accessibility and screen-capture connections glint needs.
parseDeviceServers(String ps) → List<String>
Main classes of app_process servers in a ps -o ARGS listing.
parseFocusedComponent(String dumpsys) → String?
The package/activity in mCurrentFocus=Window{… u0 package/activity}, or null.
sceneFromServerWindows(Map<String, Object?> reply, double dpr) → Scene
Flat scene of the focused window in the server's windows reply (the top application window when none has focus).
sceneFromUiDump(String xml, double dpr) → Scene
Flat scene of the labelled or tappable nodes in a uiautomator dump, framed in logical points.
screenOf(Map<String, Object?> reply) → ({double h, double w})?
The app's frame size in a runner /tree reply, which is the screen in logical points.
scrollableAround(FlutterRuntime runtime, Scene scene, SceneNode node, {required bool horizontal}) → Future<AxisScrollable?>
The nearest scrollable around node that scrolls along the horizontal or vertical axis, skipping nearer ones on the other axis; null when there is none or the eval fails.
suggestIds(Iterable<String> candidates, String wanted, {int max = 3}) → List<String>
Closest glintIds to a stale or mistyped one, so a failed lookup names the likely replacement instead of sending the agent back to a full re-read. Same base name (before #hash) wins, then small edit distance, then prefix.
tapTargetFor(Iterable<SceneNode> roots, SceneNode node) → String?
The id a tap on node should use: its nearest tappable ancestor-or-self, else its own id.

Typedefs

AxisScrollable = ({bool paged, ({double h, double w, double x, double y}) rect})
The scrollable that moves content along one axis: its global rect and whether it paged (PageView, TabBarView).
NativeNode = ({bool clickable, String cls, String label, int x1, int x2, int y1, int y2})
One node a native reader found: class, label, whether it is tappable, and its bounds in pixels.
RecognisedLine = ({double h, String text, double w, double x, double y})
One line of recognised text with its box in screenshot pixels.
SurfaceChoice = ({String id, String text, double x, double y})
One tappable choice on a native surface, at its center in logical points.

Exceptions / Errors

AppNotResumedError
A frame-bound read refused because the app is not resumed, e.g. a system prompt covers it.
GeometryResolveError
InspectorReadError
StaleInspectorIdError
The inspector id of the target is no longer known to the app, so a fresh read can find it again.