Skip to content

waygraph / locate

Function: locate() ​

locate(page, library, options?): Promise<string | null>

Defined in: src/engine/locate.ts:28

"Where am I" - reverse-matches a live page against every NavBlock / PageBlock in library (all at once), returning the first in order whose own verify Traits all pass (its checkpoint), or null if none match. Deliberately Nav/Page hubs only: each has exactly one fixed checkpoint and a verify list whose whole job is already "confirm arrival here," so it's a reliable fingerprint - a regular defineBlock can branch to different Out tags depending on runtime evidence, so its verify alone doesn't identify a single state the way a hub's does.

The primitive waygraph auto's discovered graph is for - the graph says what pages exist and how to reach them; locate() is how an autonomous run figures out which one it's actually looking at right now, without a human telling it.

More than one NavBlock matching is a real possibility (two Checkpoints whose verify Traits are both satisfied by the same page) - locate() returns the first match rather than treating that as an error; resolving genuine ambiguity is a follow-up, not solved here.

Parameters ​

page ​

Page

library ​

readonly SomeBlock[]

options? ​

timeoutMs? ​

number

Returns ​

Promise<string | null>

Example ​

ts
const here = await locate(page, [NavLoginBlock, NavDashboardBlock]);

waygraph 0.18.3 (alpha) · Node 24+ · peer @playwright/test ^1.40.0 · syntax may change before 1.0: see what was removed