Skip to main content

@svatah/yam-adapter-playwright

Default web adapter: AgentSurface on Playwright

Exports

ExportKindSignature
ariaSnapshotTextfunctionexport async function ariaSnapshotText(frame: Frame): Promise<string>The public ariaSnapshot() text for the frame.
BrowserNametypealiasexport type BrowserName = "chromium" | "firefox" | "webkit";
callToolfunctionexport async function callTool(Call a declared tool.
CheckContextinterfaceexport interface CheckContext
chooseMechanismfunctionexport async function chooseMechanism(Resolve YAM_PW_SNAPSHOT into a mechanism, probing the frame for auto.
coordsOffunctionexport function coordsOf(candidate: Candidate): { x: number; y: number }"x,y" from a coords candidate.
createPlaywrightSurfacefunctionexport function createPlaywrightSurface(Build a surface from a project config (LLD §2.4).
DeclaredToolinterfaceexport interface DeclaredToolOne tool a page declares.
declaredToolsfunctionexport async function declaredTools(frame: Frame): Promise<DeclaredTool[]>Every tool the page currently declares, in declaration order.
declaresToolfunctionexport async function declaresTool(frame: Frame, name: string): Promise<boolean>Whether the page declares a tool by this name, right now.
DEFAULT_MAX_NODESvariableDEFAULT_MAX_NODES = 2000Default cap on nodes; a larger page is truncated in document order.
describeElementfunctionexport function describeElement(
evaluatePredicatefunctionexport async function evaluatePredicate(
lengthBucketfunctiondeclare function lengthBucket(value: string | undefined): string;Names collapse to a length bucket: 0, 1-8, 9-32, 33+ (LLD §6.2).
literalValuefunctionexport function literalValue(ref: ValueRef): string
locatorForfunctionexport function locatorFor(Build the locator a candidate names, or null when the candidate is one the
OBSERVED_ATTRIBUTEvariableOBSERVED_ATTRIBUTE = "data-yam-observed"The in-page observer (Draft 2.23, REQ-REC-13): what a person does in the
OBSERVER_BINDINGvariableOBSERVER_BINDING = "__yamObserved"
OBSERVER_SCRIPTvariableOBSERVER_SCRIPT = (() =>`
parseAiSnapshotfunctionexport function parseAiSnapshot(text: string): SnapshotNode[]
PICKED_ATTRIBUTEvariablePICKED_ATTRIBUTE = "data-yam-picked"The attribute the picker stamps on the clicked element.
PICKER_SCRIPTvariablePICKER_SCRIPT = (id) =>`The in-page picker: highlight what the pointer is over, resolve on click.
PLAYWRIGHT_ADAPTER_NAMEvariablePLAYWRIGHT_ADAPTER_NAME = "playwright"The name this adapter is selected by in yam.config.yaml (LLD §2.4).
PLAYWRIGHT_CAPABILITIESvariablePLAYWRIGHT_CAPABILITIES: Capabilities The capability descriptor for this adapter (LLD §2.4).
PlaywrightAdapterOptionsinterfaceexport interface PlaywrightAdapterOptionsEverything the adapter needs that is not in SessionInit.
playwrightMechanismAvailablefunctionexport async function playwrightMechanismAvailable(frame: Frame): Promise<boolean>Whether the Playwright mechanism answers on this frame.
PlaywrightSurfaceclassexport class PlaywrightSurface implements AgentSurface
RawDescriptioninterfaceexport interface RawDescriptionThe shape describeElement returns. Mirrors ElementDescription minus ref.
RawNodeinterfaceexport interface RawNodeThe shape walkDocument returns for one node. Mirrors SnapshotNode.
RefSpaceclassexport class RefSpaceEverything snapshot, locate, describe and act need in order to turn a
registerPlaywrightAdapterfunctionexport function registerPlaywrightAdapter(): voidRegister the adapter. Idempotent, because the registry refuses a silent
REGISTRYvariableREGISTRY = "__yamRefs__"The in-page array walkDocument fills; see page-script.ts.
renderForHashfunctiondeclare function renderForHash(nodes: readonly SnapshotNode[]): string;The canonical rendering the hash is taken over: one line per node, indented by
ScriptedActioninterfaceexport interface ScriptedActionOne action a scripted person performs (YAM_OBSERVE, the test affordance).
SnapshotMechanismtypealiasexport type SnapshotMechanism = "playwright" | "own";
SnapshotOptionsinterfaceexport interface SnapshotOptions
structuralHashfunctiondeclare function structuralHash(nodes: readonly SnapshotNode[]): string;sha256 of renderForHash, hex encoded.
takeSnapshotfunctionexport async function takeSnapshot(Take a snapshot through the session's mechanism (LLD §2.2).
ToolCallinterfaceexport interface ToolCall
translatefunctionexport function translate(error: unknown): unknownPlaywright's errors carry their cause in the message. Mapping them onto the
walkDocumentfunctionexport function walkDocument(options: