@svatah/yam-bindings
Bindings store, context hash, resolver, synthesis, fingerprint, relocalization
- Source:
packages/bindings· README:packages/bindings/README.md - Install:
npm install @svatah/yam-bindings - Version 0.1.0 · Apache-2.0
Exports
| Export | Kind | Signature | |
|---|---|---|---|
assertElementId | function | export function assertElementId(id: string): void | Throw unless id is well formed, naming what is wrong. |
attrSimilarity | function | export function attrSimilarity(a: Record<string, string>, b: Record<string, string>): number | Jaccard over key=value pairs. |
BindingIndexEntry | interface | export interface BindingIndexEntry | The dictionary's view of the store: every element id with the phrases its file |
BindingsStore | class | export class BindingsStore | The store, held in memory and written back as files. |
boxProximity | function | export function boxProximity( | How near two boxes are, in both position and size. |
CandidateAttempt | interface | export interface CandidateAttempt | What one candidate did when it was tried. |
candidatesFor | function | export function candidatesFor( | The ranked candidates for one element, before uniqueness filtering. |
contextHash | function | export function contextHash( | The context hash for an element, or for the page when no element is named. |
contextPattern | function | export function contextPattern(url: string, options: ContextPatternOptions = {}): string | The URL or window pattern an entry is stored against (REQ-REC-6). |
ContextPatternOptions | interface | export interface ContextPatternOptions | Options for contextPattern (config.bindings, LLD §3.5). |
contextRoot | function | export function contextRoot( | The node a context is scoped to: the nearest landmark ancestor of ref, |
decide | function | export function decide( | Decide from a ranking, applying the threshold and the margin. |
DEFAULT_CANDIDATE_TIMEOUT_MS | variable | DEFAULT_CANDIDATE_TIMEOUT_MS = 2000 | Default per-candidate timeout; Config.run.candidateTimeoutMs. |
DEFAULT_MARGIN | variable | DEFAULT_MARGIN = 0.1 | heal.margin — the best must beat the runner-up by this much. |
DEFAULT_MAX_CANDIDATES | variable | DEFAULT_MAX_CANDIDATES = 300 | How many elements are described and scored before giving up. |
DEFAULT_THRESHOLD | variable | DEFAULT_THRESHOLD = 0.72 | heal.relocalizeThreshold — below this, nothing is proposed. |
Dictionary | class | export class Dictionary | |
elementIdFromPhrase | function | export function elementIdFromPhrase(phrase: string): string | The element id a target phrase normalises to (docs/flow-language.md §4): drop a |
EntrySelector | interface | export interface EntrySelector | How an entry is selected for a context (LLD §6.3). |
fingerprint | function | export async function fingerprint( | The fingerprint of a live element. |
fingerprintOf | function | export function fingerprintOf( | The structural fingerprint of one element (REQ-REC-4, LLD §3.3). |
idToSegments | function | export function idToSegments(id: string): string[] | Path segments for an id, relative to the bindings directory; the last is the file. |
isElementId | function | export function isElementId(id: string): boolean | Whether a string is a well-formed element id. |
LANDMARK_ROLES | variable | LANDMARK_ROLES = [ | The roles that scope a context, in the order LLD §6.2 tries them: a landmark, |
LocatorError | class | export class LocatorError extends LocateError | |
LocatorErrorDetail | interface | export interface LocatorErrorDetail | |
looksGenerated | function | export function looksGenerated(value: string): boolean | Whether a value looks machine-generated and so is not worth binding to. |
Lookup | interface | export interface Lookup | |
Match | interface | export interface Match | |
neighbourSimilarity | function | export function neighbourSimilarity( | Neighbour text, before and after weighted equally. |
pathToId | function | export function pathToId(relativePath: string): string | The id a path under the bindings directory belongs to. |
patternMatches | function | export function patternMatches( | Whether a stored pattern applies to a URL. |
rank | function | export function rank( | Rank a set of already-described elements against a fingerprint. |
readBindingIndex | function | export function readBindingIndex(dir: string): BindingIndexEntry[] | Read a bindings directory as ids and phrases. |
relocalize | function | export async function relocalize( | Find the element a fingerprint describes, on the page as it is now. |
RelocalizeOptions | interface | export interface RelocalizeOptions | |
RelocalizeResult | typealias | export type RelocalizeResult | |
Resolution | interface | export interface Resolution | |
resolve | function | export async function resolve( | Resolve one element id against a live surface. |
ResolveOptions | interface | export interface ResolveOptions | |
rolePathSimilarity | function | export function rolePathSimilarity(a: readonly string[], b: readonly string[]): number | How alike two ancestries are: the longest common suffix, over the roles |
Score | interface | export interface Score | |
scoreAgainst | function | export function scoreAgainst( | Score one live element against a recorded fingerprint (LLD §6.4). |
siteToolCandidatesFor | function | export function siteToolCandidatesFor(phrase: string, elementId?: string): string[] | The tool names a target might be, best first. |
siteToolOf | function | export function siteToolOf(phrase: string): string | undefined | The site tool a target phrase names, if it names one. |
subtree | function | export function subtree(snapshot: Snapshot, root: SnapshotNode): SnapshotNode[] | The subtree under a node, in document order, with depths made relative to it. |
synthesise | function | export async function synthesise( | The ranked, verified candidate bundle for one element (REQ-REC-3). |
synthesiseBundle | function | export async function synthesiseBundle( | Candidates and fingerprint in one pass, which is what the recorder wants. |
synthesiseSiteTool | function | export async function synthesiseSiteTool( | The webmcp candidate for a target, when the page declares the tool. |
SynthesisOptions | interface | export interface SynthesisOptions | |
textSimilarity | function | export function textSimilarity(a: string, b: string): number | Dice similarity over word tokens, with an exact-match shortcut. |
tryResolve | function | export async function tryResolve( | Try to resolve, and report rather than throw. |
WEIGHTS | variable | WEIGHTS | The weights of LLD §6.4. They sum to 1. |