blastproof 0.34.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  - **Your tests live in your repository.** Plain-English YAML, reviewed in pull requests like code. No selectors to maintain: the agent reads the page the way a screen reader does.
26
26
  - **It runs where your code runs.** On your machine or in your CI. No account, no subscription, no dashboard to sign in to. The only thing that leaves your network is the model call, to the provider you choose — or none, with a local model through Ollama. MIT licensed.
27
- - **It costs cents, and you can cap it.** This repository's own 10-test suite takes about 110 model calls and 240k tokens per run on `claude-haiku-4.5`: about **$0.35 a run**, or 3–4 cents a test, at list prices. With `--impacted`, a pull request runs only the tests its diff can affect. A [budget](./docs/configuration.md#budget--bounding-what-a-run-spends) caps calls, tokens and time, and `--dry-run` costs nothing.
27
+ - **It costs cents, and you can cap it.** This repository's own 10-test suite takes about 110 model calls and 240k tokens per run on `claude-haiku-4.5`: about **$0.35 a run**, or 3–4 cents a test, at list prices. With [`replay`](./docs/configuration.md#replay--repeating-what-passed-last-time) on, a step that passed is repeated from what it did, and each run after the first takes less than half: 49 calls and 93k tokens on the same suite. With `--impacted`, a pull request runs only the tests its diff can affect. A [budget](./docs/configuration.md#budget--bounding-what-a-run-spends) caps calls, tokens and time, and `--dry-run` costs nothing.
28
28
  - **How often it is wrong is measured, not promised.** On this repository's benchmark, a seeded bug that should fail a test and a correct app that should pass it, both reference models got every verdict right in the latest measurement: 0 wrong in 89 runs on `claude-haiku-4.5` and 0 in 90 on `gpt-6-luna`. The demo app flatters, and the [method and its limits](./docs/reliability.md) are public.
29
29
 
30
30
  **It fits best** when you cannot send your application to a hosted service, when you want tests as code rather than in someone else's UI, or when you already have an LLM key. **It does not fit yet** if your markup is not accessible, if your key journeys need drag and drop, file upload or several tabs, or if you are on Windows, which is untested. [Does this fit your application?](./docs/writing-tests.md#does-this-fit-your-application) has the details.
@@ -88,7 +88,7 @@ Exit codes: **0** pass, **1** the gate failed or the run stopped, **2** usage or
88
88
 
89
89
  - [Writing tests](./docs/writing-tests.md) — the rules that decide whether a suite works, and whether your app fits
90
90
  - [Running, selecting and gating](./docs/running.md) — commands, `--impacted`, the score, and the free deterministic half
91
- - [Configuration](./docs/configuration.md) — providers, models, budgets, browser, concurrency
91
+ - [Configuration](./docs/configuration.md) — providers, models, budgets, browser, concurrency, replay
92
92
  - [Testing behind a login](./docs/auth.md) · [Running in CI](./docs/ci.md) — the GitHub Action is on the [Marketplace](https://github.com/marketplace/actions/blastproof-e2e-ai-testing)
93
93
  - [Trust boundaries](./docs/trust-boundaries.md) — what the agent may reach, and how secrets stay out of prompts
94
94
  - [How often a verdict is wrong](./docs/reliability.md) — the benchmark, and how to reproduce it
@@ -137,6 +137,9 @@ async function performAction(page, action, ctx) {
137
137
  }
138
138
  }
139
139
  async function performResolvedAction(page, action, ctx) {
140
+ if (ctx.dialogs?.answering(action) !== void 0) {
141
+ return ctx.dialogs.perform(action, action.value === void 0 ? void 0 : resolve(action.value, ctx));
142
+ }
140
143
  switch (action.action) {
141
144
  case "navigate": {
142
145
  const value = resolve(requireValue(action), ctx);
@@ -480,6 +483,7 @@ function snapshotFields(snapshot) {
480
483
  }
481
484
 
482
485
  export {
486
+ ActionError,
483
487
  allowedOriginsFor,
484
488
  isOriginAllowed,
485
489
  describeBoundary,
@@ -495,4 +499,4 @@ export {
495
499
  FIELD_ROLES,
496
500
  snapshotFields
497
501
  };
498
- //# sourceMappingURL=chunk-7UQT6SVD.js.map
502
+ //# sourceMappingURL=chunk-VBWOSSGY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runner/actions.ts","../src/runner/snapshot.ts"],"sourcesContent":["import type { AgentAction, AgentTarget } from '../llm/schemas.js';\nimport type { DialogWatch } from './dialog.js';\nimport type { SnapshotElement } from './snapshot.js';\n\n/**\n * Narrow Playwright subset used by the runner. Real `Page`/`Locator` objects are\n * structurally compatible (cast once at the boundary) and tests use fakes.\n */\nexport interface LocatorLike {\n click(): Promise<void>;\n hover(): Promise<void>;\n fill(value: string): Promise<void>;\n press(key: string): Promise<void>;\n selectOption(option: { label: string }): Promise<unknown>;\n waitFor(options?: { state?: 'attached' | 'visible'; timeout?: number }): Promise<void>;\n count(): Promise<number>;\n}\n\nexport interface PageLike {\n goto(url: string, options?: { timeout?: number }): Promise<unknown>;\n /**\n * Only ever called with `aria-ref=<ref>` (design act-on-the-element-the-model-read,\n * D1): the element the snapshot line the model read was printed from, or\n * nothing. There is no search by role, name or text to widen.\n */\n locator(selector: string): LocatorLike;\n keyboard: { press(key: string): Promise<void> };\n screenshot(options: { path: string; fullPage?: boolean }): Promise<unknown>;\n url(): string;\n /**\n * Waits for the page to reach the given load state, bounded by `timeout`\n * (design D1/D2, trustworthy-verdicts). Signature matches Playwright's own\n * `page.waitForLoadState`, so a real `Page` satisfies this with no adapter.\n *\n * Required, not optional (design D2): `PageLike` is *implemented* by every\n * test double rather than passed as options, so an optional method here is\n * exactly the shape that let `timeoutMs` and `budget` go silently unset at\n * one call site while every other one set them — a no-op fake is at least\n * visible in that fake; an absent method is invisible everywhere. A page\n * double that cannot say when it settled cannot support a trustworthy\n * verdict.\n *\n * Rejects on timeout, exactly like Playwright — this primitive stays\n * honest about what happened. `executor.ts`'s settling helper is what\n * decides that exceeding the budget is normal and silent, not this method.\n */\n waitForLoadState(state: 'networkidle', options?: { timeout?: number }): Promise<void>;\n}\n\nexport class ActionError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ActionError';\n }\n}\n\nexport interface ActionContext {\n baseUrl: string;\n /**\n * The configured `browser.timeout_ms` (design D1: one knob, not two): bounds how\n * long resolution waits for each candidate element to become visible, and how\n * long `navigate` waits to load. Must be populated by the caller — a Playwright\n * locator's explicit per-call timeout always overrides `page.setDefaultTimeout()`,\n * so leaving this `undefined` silently reinstates a fixed two-second wait for\n * resolution (and thirty seconds for navigation) regardless of what\n * `browser.timeout_ms` says, which is exactly the defect this field once was.\n */\n resolveTimeoutMs?: number;\n /** Extra origins the agent may reach; `baseUrl`'s own is always allowed. */\n allowedOrigins?: string[];\n /** Resolves `{{env.*}}` in action payloads at the moment of acting (design D2). */\n resolveValue?: (value: string) => string;\n /**\n * The page's native dialogs (design answer-native-dialogs, D3): an action\n * whose ref names a control of the open dialog answers it, and never reaches\n * `aria-ref=`.\n */\n dialogs?: Pick<DialogWatch, 'answering' | 'perform'>;\n}\n\n/** The URL a fresh browser context shows before anything is loaded (design contained-navigation, D2). */\nconst BLANK_PAGE = 'about:blank';\n\n/**\n * The origins the agent may be on: the application's own, plus whatever the\n * configuration declares. One construction, used by both checks (design\n * contained-navigation, D3) — this defect existed because the rule lived at one\n * call site while claiming to cover everything, and two copies of it that can\n * drift apart would be a poor way to fix that.\n */\nexport function allowedOriginsFor(baseUrl: string, allowedOrigins: string[] | undefined): Set<string> {\n const allowed = new Set<string>([new URL(baseUrl).origin]);\n for (const origin of allowedOrigins ?? []) {\n allowed.add(new URL(origin).origin);\n }\n return allowed;\n}\n\n/**\n * Whether `url` is inside the boundary.\n *\n * `about:blank` is inside it: the browser's own empty page carries no content\n * and is what a fresh context shows before the first `goto`. Everything else is\n * compared by origin, and a URL with no comparable origin — `file:`, `data:` —\n * is **not** allowed. Treating \"no origin\" as \"fine\" would be the same\n * permissiveness that produced this defect (design D2).\n */\nexport function isOriginAllowed(url: string, allowed: ReadonlySet<string>): boolean {\n if (url === BLANK_PAGE) return true;\n let origin: string;\n try {\n origin = new URL(url).origin;\n } catch {\n return false;\n }\n if (origin === 'null') return false;\n return allowed.has(origin);\n}\n\n/** Describes the boundary the way both failure messages name it. */\nexport function describeBoundary(allowed: ReadonlySet<string>): string {\n return [...allowed].join(' or ');\n}\n\n/**\n * The one containment that does not depend on the model cooperating: an absolute\n * URL ignores the base entirely (`new URL('https://x/y', base)` is `https://x/y`),\n * so a page that can influence the agent could otherwise send it anywhere while it\n * holds a live session. Compared, not argued with (design D1).\n *\n * Refusing to make the request is strictly better than making it and objecting\n * afterwards, so this stays even though the executor now also checks where the\n * page ended up: the model is told its target is out of bounds and can choose\n * differently, rather than the step simply ending.\n */\nfunction assertAllowedOrigin(url: URL, ctx: ActionContext): void {\n const allowed = allowedOriginsFor(ctx.baseUrl, ctx.allowedOrigins);\n if (!isOriginAllowed(url.toString(), allowed)) {\n throw new ActionError(\n `Refusing to navigate outside the application: ${url.origin} is not ${describeBoundary(allowed)}. ` +\n 'Add it to allowed_origins in .blastproof/config.yaml if the app legitimately spans hosts.',\n );\n }\n}\n\nfunction describeTarget(target: AgentTarget): string {\n const parts: string[] = [];\n if (target.role) parts.push(`role=${target.role}`);\n if (target.name) parts.push(`name=\"${target.name}\"`);\n return parts.join(' ') || '(no target)';\n}\n\nfunction normaliseName(text: string | undefined): string {\n return (text ?? '').replace(/\\s+/g, ' ').trim().toLowerCase();\n}\n\n/** `f1e25`, however the model wrapped it: `[ref=f1e25]`, `ref=f1e25`. */\nfunction bareRef(ref: string): string {\n return ref.trim().replace(/^\\[/, '').replace(/^ref=/, '').replace(/\\]$/, '');\n}\n\nfunction describeElement(element: SnapshotElement): string {\n const name = element.name ?? element.text;\n return name === undefined ? element.role : `${element.role} \"${name}\"`;\n}\n\n/**\n * Binds an action's target to the element its ref names in the snapshot the\n * model was given (design act-on-the-element-the-model-read, D2/D5). The ref\n * alone decides the element; the role and name the model wrote are checked\n * against that element's line, so a ref copied from the neighbouring line is\n * refused instead of clicking the neighbour. The returned action carries the\n * snapshot's own role and name, which is what the record, the reports and the\n * commit-repeat identity read: the element acted on, never the model's words.\n *\n * Throws {@link ActionError}, one failed attempt, on a missing, unknown or\n * mismatched ref. An action with no target (navigate, a bare press) is\n * returned unchanged.\n */\nexport function bindTarget(action: AgentAction, refs: ReadonlyMap<string, SnapshotElement>): AgentAction {\n const target = action.target;\n // An empty target is no target: a press of the focused element sends one.\n if (!target || (!target.ref && !target.role && !target.name)) return { ...action, target: undefined };\n const fix = 'Use the [ref=…] on the line of the element you mean in the current snapshot.';\n if (!target.ref) {\n throw new ActionError(`refused: the target names no ref, so nothing was done. ${fix}`);\n }\n const ref = bareRef(target.ref);\n const element = refs.get(ref);\n if (!element) {\n throw new ActionError(`refused: no element in the current snapshot has ref \"${ref}\". ${fix}`);\n }\n const shown = element.name ?? element.text;\n const sameRole = normaliseName(target.role) === normaliseName(element.role);\n const sameName = normaliseName(target.name) === normaliseName(shown);\n if (!sameRole || !sameName) {\n const said = [target.role ?? '(no role)', target.name === undefined ? '' : `\"${target.name}\"`]\n .filter(Boolean)\n .join(' ');\n throw new ActionError(\n `refused: ref ${ref} is ${describeElement(element)}, not ${said}, so nothing was done. ${fix}`,\n );\n }\n return { ...action, target: { ref, role: element.role, name: shown } };\n}\n\n/**\n * Resolves the element a ref names (design act-on-the-element-the-model-read,\n * D1/D4), and nothing else: Playwright's `aria-ref` locator answers with the\n * element the snapshot line was printed from or with none. None means the page\n * changed since the snapshot (the element was replaced, or the page navigated,\n * which Playwright reports as an invalid frame), and fails at once instead of\n * waiting `browser.timeout_ms` for an element that cannot come back. A resolved\n * element is still waited on to be visible, bounded by `resolveTimeoutMs`.\n */\nexport async function resolveTarget(\n page: PageLike,\n target: AgentTarget,\n resolveTimeoutMs = 2_000,\n): Promise<LocatorLike> {\n if (!target.ref) throw new ActionError(`Element not found: ${describeTarget(target)} has no ref`);\n const ref = bareRef(target.ref);\n const locator = page.locator(`aria-ref=${ref}`);\n let count: number;\n try {\n count = await locator.count();\n } catch {\n count = 0;\n }\n if (count === 0) {\n throw new ActionError(\n `Element not found: ${describeTarget(target)} (ref ${ref}) is no longer on the page; it changed since the ` +\n 'snapshot. Choose the element again from the fresh snapshot.',\n );\n }\n try {\n await locator.waitFor({ state: 'visible', timeout: resolveTimeoutMs });\n } catch {\n throw new ActionError(\n `Element not found: ${describeTarget(target)} (ref ${ref}) is on the page but did not become visible ` +\n `within ${resolveTimeoutMs}ms.`,\n );\n }\n return locator;\n}\n\nfunction requireTarget(action: AgentAction): AgentTarget {\n if (!action.target?.ref) {\n throw new ActionError(`Action \"${action.action}\" requires a target (its ref in the snapshot)`);\n }\n return action.target;\n}\n\n/** Expands `{{env.*}}` only now, so the value was never in a prompt (design D2). */\nfunction resolve(value: string, ctx: ActionContext): string {\n return ctx.resolveValue ? ctx.resolveValue(value) : value;\n}\n\nfunction requireValue(action: AgentAction): string {\n if (action.value === undefined || action.value === '') {\n throw new ActionError(`Action \"${action.action}\" requires a value`);\n }\n return action.value;\n}\n\n/**\n * Playwright's own words for \"the target was fine and something else took the\n * click\", written into the call log of an action that then times out\n * (design name-what-blocks-the-click, D2).\n *\n * Quoted rather than re-derived: asking the page which element sits at the\n * target's coordinates costs a second round trip, at the moment an action has\n * just spent the whole browser timeout failing, to recompute what the error\n * already carries.\n *\n * Playwright renders the blocker as a whole element — `<div class=\"…\"></div>`\n * — so the capture takes the **opening** tag and the rest of the rendering is\n * skipped up to the phrase. Bounded to one line, because the call log holds a\n * second element a few lines above (`locator resolved to <button …>`, the\n * target itself) and a pattern allowed to cross newlines names that one\n * instead: the wrong element, and the one this message exists to exonerate.\n *\n * This pattern is the coupling this translation rests on. If Playwright ever\n * rewords the line, the translation stops firing and behaviour reverts to the\n * raw timeout — which is why `tests/actions.test.ts` pins a real call log\n * verbatim rather than a hand-written approximation.\n */\nconst INTERCEPTS_POINTER = /(<[^>\\n]{1,400}>)[^\\n]{0,400}?intercepts pointer events/;\n\n/** A framework's overlay class list is long, decorative, and about to be paid for by the token. */\nconst MAX_BLOCKER_LENGTH = 80;\n\nfunction truncateBlocker(tag: string): string {\n return tag.length <= MAX_BLOCKER_LENGTH ? tag : `${tag.slice(0, MAX_BLOCKER_LENGTH)}…>`;\n}\n\n/**\n * Translates an interception into an obstruction the model can act on, or\n * returns `undefined` for any other failure (design D1/D3).\n *\n * The message leads with the fact that inverts the model's default reading. A\n * bare `locator.click: Timeout 30000ms exceeded` says the target is the\n * problem, so a model given one does the only thing that message supports: it\n * re-resolves the same element under a different accessible name. That was\n * measured against a real application — three attempts, three names, all\n * resolving to the correct element, the whole retry budget spent while the\n * dialog on top of it was never touched. So the first thing this says is that\n * the target was found and is fine, and the last thing it says is that trying\n * another name cannot help.\n *\n * The captured tag is markup, and the model is forbidden from targeting by CSS\n * everywhere else. It is named here as *what took the click* and never as a\n * handle: the route to the overlay is the accessibility snapshot, where the\n * dialog and its close control appear as roles and names.\n */\nfunction obstructionFor(error: unknown, action: AgentAction): ActionError | undefined {\n const message = error instanceof Error ? error.message : String(error);\n const match = INTERCEPTS_POINTER.exec(message);\n if (!match) return undefined;\n const where = action.target ? ` on ${describeTarget(action.target)}` : '';\n return new ActionError(\n `blocked: the ${action.action}${where} was NOT performed. The target was found and is visible, ` +\n `enabled and stable — nothing about it is wrong. ${truncateBlocker(match[1]!)} is on top of it and ` +\n `received the pointer event instead. Something is covering the page: find it in the snapshot — a ` +\n `dialog, a cookie banner, an onboarding overlay — and dismiss it first, using its own close or ` +\n `accept control, or by pressing Escape with no target. Then act on this target again. Choosing a ` +\n `different name for the same target cannot help.`,\n );\n}\n\n/**\n * Performs one agent action on the page. `assert`/`done`/`fail` are control\n * actions handled by the executor and rejected here.\n * Returns a short human-readable result string fed back into the next prompt.\n *\n * The obstruction translation is guarded here, over the whole action path,\n * rather than at the five call sites that touch a locator (design D1).\n * `click`, `hover`, `fill`, `select` and a targeted `press` all wait for the\n * same actionability and can all be intercepted; wrapping each of them is five\n * places to forget the sixth, which is this codebase's named recurring defect\n * — a guarantee implemented at a call site instead of over its scope.\n */\nexport async function performAction(\n page: PageLike,\n action: AgentAction,\n ctx: ActionContext,\n): Promise<string> {\n try {\n return await performResolvedAction(page, action, ctx);\n } catch (error) {\n // Conditional on the error text, so anything that is not an interception\n // reaches the model byte-identical to before.\n throw obstructionFor(error, action) ?? error;\n }\n}\n\nasync function performResolvedAction(\n page: PageLike,\n action: AgentAction,\n ctx: ActionContext,\n): Promise<string> {\n if (ctx.dialogs?.answering(action) !== undefined) {\n return ctx.dialogs.perform(action, action.value === undefined ? undefined : resolve(action.value, ctx));\n }\n switch (action.action) {\n case 'navigate': {\n const value = resolve(requireValue(action), ctx);\n const url = new URL(value, ctx.baseUrl);\n assertAllowedOrigin(url, ctx);\n // Same knob as resolution (design D1): a slow app is waited for, not just\n // the elements on the page it eventually renders.\n await page.goto(url.toString(), { timeout: ctx.resolveTimeoutMs ?? 30_000 });\n // Where it landed, when that is not where it was asked to go (design\n // judge-sees-the-record, D1). The executor has both facts and used to\n // discard one, which left every later reader — the model, the step\n // record, the judge, and whoever reads the log afterwards — believing a\n // redirected navigation had arrived at the requested URL.\n const landed = page.url();\n return landed === url.toString()\n ? `ok: navigated to ${url.toString()}`\n : `ok: navigated to ${url.toString()}, which redirected to ${landed}`;\n }\n case 'click': {\n const target = requireTarget(action);\n const locator = await resolveTarget(page, target, ctx.resolveTimeoutMs);\n await locator.click();\n return `ok: clicked ${describeTarget(target)}`;\n }\n case 'hover': {\n // Not a commit (design hover-over-an-element, D2): it changes what the\n // page shows, never what the application holds.\n const target = requireTarget(action);\n const locator = await resolveTarget(page, target, ctx.resolveTimeoutMs);\n await locator.hover();\n return `ok: hovered ${describeTarget(target)}`;\n }\n case 'fill': {\n const target = requireTarget(action);\n const value = resolve(requireValue(action), ctx);\n const locator = await resolveTarget(page, target, ctx.resolveTimeoutMs);\n await locator.fill(value);\n return `ok: filled ${describeTarget(target)}`;\n }\n case 'press': {\n const key = action.value ? resolve(action.value, ctx) : 'Enter';\n if (action.target?.ref) {\n const locator = await resolveTarget(page, action.target, ctx.resolveTimeoutMs);\n await locator.press(key);\n return `ok: pressed ${key} on ${describeTarget(action.target)}`;\n }\n await page.keyboard.press(key);\n return `ok: pressed ${key}`;\n }\n case 'select': {\n const target = requireTarget(action);\n const value = resolve(requireValue(action), ctx);\n const locator = await resolveTarget(page, target, ctx.resolveTimeoutMs);\n await locator.selectOption({ label: value });\n return `ok: selected \"${value}\" in ${describeTarget(target)}`;\n }\n case 'assert':\n case 'done':\n case 'fail':\n throw new ActionError(`Action \"${action.action}\" is handled by the executor, not the page`);\n }\n}\n\n/** A value held in the page, as Playwright hands it back. */\ninterface ProbeHandle {\n evaluate<R>(fn: (value: never) => R): Promise<R>;\n dispose(): Promise<void>;\n}\n\n/** The Playwright calls the default-button lookup needs, beyond {@link PageLike}. */\ninterface FormProbePage {\n evaluateHandle(fn: () => unknown): Promise<ProbeHandle>;\n locator(selector: string): {\n count(): Promise<number>;\n elementHandle(options?: { timeout?: number }): Promise<ProbeHandle | null>;\n evaluate(\n fn: (element: DomControl, arg: { field: DomControl | null; enter: boolean }) => boolean,\n arg: { field: unknown; enter: boolean },\n options?: { timeout?: number },\n ): Promise<boolean>;\n evaluateHandle(fn: (element: DomControl) => unknown): Promise<ProbeHandle>;\n };\n}\n\n/** The DOM a control is read through in the page; this build has no DOM types. */\ninterface DomControl {\n tagName: string;\n type?: string;\n disabled?: boolean;\n form?: DomControl | null;\n getRootNode(): { querySelectorAll(selector: string): ArrayLike<DomControl> };\n addEventListener(type: string, listener: () => void, options: { capture: boolean; once: boolean }): void;\n}\n\n/** Enter submits a form; Space in a field types a space. */\nconst SUBMIT_KEYS: ReadonlySet<string> = new Set(['Enter', 'NumpadEnter']);\n/** The keys that activate a focused button. */\nconst ACTIVATING_KEYS: ReadonlySet<string> = new Set([...SUBMIT_KEYS, ' ', 'Space', 'Spacebar']);\n\n/** The button a press activates, and whether the press did. */\nexport interface SubmitControl {\n role: string;\n name: string;\n /**\n * Whether the button was clicked, or its form submitted, since the lookup:\n * asked after the press. Enter in a field whose own handler takes the key\n * (an autocomplete, a tag input) does neither, and must not be recorded as\n * the button's click. Asking also lets go of what the lookup held in the\n * page, so it is asked for a press that was not performed too.\n */\n activated(): Promise<boolean>;\n}\n\n/**\n * The button a press activates, as the snapshot shows it (design\n * refuse-the-same-submit-twice, D2): for Enter in a field, the default submit\n * button of the field's form; for Enter or Space with no target, also the\n * focused button itself. The field is the press's target, or the focused\n * element for a press with no target. `undefined` when the page names no such\n * button, when the snapshot does not show it, when the lookup takes longer than\n * `timeoutMs`, and on any failure: the press is then identified as before, and\n * this never fails a step.\n *\n * Implicit submission is a fact about the page that the accessibility snapshot\n * does not carry, since it has no form membership, so the browser is asked.\n * The rule is the one measured in Chromium: Enter in an `<input>` clicks the\n * first submit button its form owns, in tree order, an image button included,\n * and does nothing when that button is disabled. The button is found by asking\n * each `button` line's element, by its ref, whether it is that one. Matching it\n * by its text would be the search by name that\n * act-on-the-element-the-model-read removed.\n */\nexport async function submitControlOf(\n page: PageLike,\n action: AgentAction,\n refs: ReadonlyMap<string, SnapshotElement>,\n timeoutMs = 2_000,\n): Promise<SubmitControl | undefined> {\n if (action.action !== 'press') return undefined;\n // `||`, as `performAction` reads it: an empty key is Enter too.\n const key = action.value || 'Enter';\n const enter = SUBMIT_KEYS.has(key);\n // Space activates only a button that has the focus; on a named target the\n // record already knows whether it is a button.\n if (!enter && !(ACTIVATING_KEYS.has(key) && !action.target?.ref)) return undefined;\n if (action.target?.role !== undefined && action.target.role.trim().toLowerCase() === 'button') return undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const late = new Promise<undefined>((resolve) => {\n timer = setTimeout(() => resolve(undefined), timeoutMs);\n });\n try {\n return await Promise.race([findSubmitControl(page as unknown as FormProbePage, action, enter, refs, timeoutMs), late]);\n } catch {\n return undefined;\n } finally {\n clearTimeout(timer);\n }\n}\n\nasync function findSubmitControl(\n probe: FormProbePage,\n action: AgentAction,\n enter: boolean,\n refs: ReadonlyMap<string, SnapshotElement>,\n timeoutMs: number,\n): Promise<SubmitControl | undefined> {\n let field: ProbeHandle | null;\n if (action.target?.ref) {\n const locator = probe.locator(`aria-ref=${bareRef(action.target.ref)}`);\n if ((await locator.count()) === 0) return undefined;\n field = await locator.elementHandle({ timeout: timeoutMs });\n } else {\n field = await probe.evaluateHandle(\n () => (globalThis as unknown as { document: { activeElement: unknown } }).document.activeElement,\n );\n }\n try {\n for (const [ref, element] of refs) {\n if (element.role !== 'button') continue;\n const locator = probe.locator(`aria-ref=${ref}`);\n let clicks: ProbeHandle;\n try {\n if ((await locator.count()) === 0) continue;\n const isIt = await locator.evaluate(\n (button, arg) => {\n const candidate = arg.field;\n if (candidate === null) return false;\n // The focused element is this button: the key activates it.\n if (candidate === button) return true;\n // Enter in an input its form owns. A textarea takes Enter as a new line.\n if (!arg.enter || candidate.tagName !== 'INPUT' || !candidate.form) return false;\n if (['button', 'submit', 'reset', 'image', 'file', 'color', 'range', 'hidden'].includes(candidate.type ?? 'text')) {\n return false;\n }\n const form = candidate.form;\n const owned = Array.from(form.getRootNode().querySelectorAll('button, input'));\n const first = owned.find((control) => control.form === form && (control.type === 'submit' || control.type === 'image'));\n // A disabled default button means Enter submits nothing.\n return first === button && !first.disabled;\n },\n { field, enter },\n { timeout: timeoutMs },\n );\n if (!isIt) continue;\n clicks = await locator.evaluateHandle((button) => {\n // No named function in here: this body is sent to the page as text,\n // and a compiler's name helper would not exist there.\n const seen = { clicked: false };\n button.addEventListener('click', () => { seen.clicked = true; }, { capture: true, once: true });\n // A key handler that calls `requestSubmit()` itself clicks nothing\n // and submits all the same.\n button.form?.addEventListener('submit', () => { seen.clicked = true; }, { capture: true, once: true });\n return seen;\n });\n } catch {\n // Another frame's element, or one that went away: not this button.\n continue;\n }\n return {\n role: element.role,\n name: element.name ?? element.text ?? '',\n activated: async () => {\n try {\n return await clicks.evaluate((seen: { clicked: boolean }) => seen.clicked);\n } catch {\n // The page that held the answer is gone: the press navigated.\n return true;\n } finally {\n await clicks.dispose().catch(() => undefined);\n }\n },\n };\n }\n return undefined;\n } finally {\n await field?.dispose().catch(() => undefined);\n }\n}\n","import type { Page } from 'playwright';\nimport { isOriginAllowed } from './actions.js';\n\n/**\n * Which frames' content a snapshot may carry (design\n * show-frames-from-declared-origins, D1): the boundary navigation is compared\n * against, and who to tell when a frame was left out.\n */\nexport interface FrameBoundary {\n /** `base_url`'s origin plus `allowed_origins:`, as `allowedOriginsFor` builds it. */\n allowed: ReadonlySet<string>;\n /** Called with the origin of every frame whose content was not shown. */\n onHidden?: (origin: string) => void;\n}\n\nexport interface SnapshotOptions {\n /** Maximum number of snapshot lines sent to the LLM. Default 200. */\n maxLines?: number;\n /** Required: a snapshot without it would carry every frame's content. */\n frames: FrameBoundary;\n}\n\n/**\n * The URLs of the frame an `iframe` element shows, then of each frame containing\n * it, up to the page — but only when the element `contentRef` names is in that\n * same frame. `undefined` otherwise, or when either element cannot be found.\n */\nexport type FrameChainLookup = (frameRef: string, contentRef: string) => Promise<string[] | undefined>;\n\nconst IFRAME_WITH_CONTENT = /^(\\s*)- iframe\\b.*:$/;\n\n/** The origin a frame's content is judged by: its own URL's, or for `about:` its container's (design D2). */\nfunction contentUrl(chain: string[]): string | undefined {\n return chain.find((url) => !url.startsWith('about:'));\n}\n\n/** The origin of a web URL, or `undefined` for one that has none (`data:`, `file:`). */\nfunction webOrigin(url: string): string | undefined {\n try {\n const origin = new URL(url).origin;\n return origin === 'null' ? undefined : origin;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Replaces the content of every frame outside the boundary with one line saying\n * so (design show-frames-from-declared-origins, D1/D2). Its refs go with it, so\n * an action naming one is refused by `bindTarget` as a ref the snapshot does not\n * have. A frame inside a cut frame goes with its lines. A page with no frame\n * costs no lookup.\n */\nexport async function cutUndeclaredFrames(\n snapshot: string,\n lookup: FrameChainLookup,\n frames: FrameBoundary,\n): Promise<string> {\n if (!/- iframe\\b/.test(snapshot)) return snapshot;\n const lines = snapshot.split('\\n');\n const out: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!;\n out.push(line);\n const frame = IFRAME_WITH_CONTENT.exec(line);\n if (!frame) continue;\n const indent = frame[1]!.length;\n let end = i + 1;\n while (end < lines.length && indentOf(lines[end]!) > indent) end++;\n // Both refs are read from the lines' attribute groups, never from their\n // text: a frame controls the names in its own lines, and a heading named\n // \"[ref=e1]\" must not pass for the page's e1 (design D1).\n const frameRef = lineRef(line);\n const contentRef = lines.slice(i + 1, end).map(lineRef).find((r) => r !== undefined);\n const chain = frameRef === undefined || contentRef === undefined ? undefined : await lookup(frameRef, contentRef);\n const url = chain === undefined ? undefined : contentUrl(chain);\n if (url !== undefined && isOriginAllowed(url, frames.allowed)) continue;\n const origin = url === undefined ? undefined : webOrigin(url);\n const reason =\n url === undefined\n ? \"the frame's origin could not be read\"\n : origin === undefined\n ? `a ${url.split(':')[0]}: frame is never shown`\n : `${origin} is not in allowed_origins`;\n // Only an origin `allowed_origins:` can name gets a warning offering it.\n if (origin !== undefined) frames.onHidden?.(origin);\n out.push(`${' '.repeat(indent + 2)}- text: \"content not shown: ${reason}\"`);\n i = end - 1;\n }\n return out.join('\\n');\n}\n\n/**\n * The live lookup (design D1): the frame the `iframe` element shows, bound to\n * the frame its first content element is in. The `iframe` line's ref is written\n * by Playwright, not by the page; the content ref is tied to the document the\n * snapshot read, so a frame that navigated since does not resolve and is cut.\n */\nfunction frameChainOn(page: Page): FrameChainLookup {\n const handleOf = (ref: string) => page.locator(`aria-ref=${ref}`).elementHandle({ timeout: 1_000 });\n return async (frameRef, contentRef) => {\n const handles: { dispose(): Promise<void> }[] = [];\n try {\n const frameElement = await handleOf(frameRef);\n if (frameElement) handles.push(frameElement);\n const content = await handleOf(contentRef);\n if (content) handles.push(content);\n const shown = await frameElement?.contentFrame();\n const owner = await content?.ownerFrame();\n if (!shown || shown !== owner) return undefined;\n const chain: string[] = [];\n for (let f: typeof shown | null = shown; f; f = f.parentFrame()) chain.push(f.url());\n return chain;\n } catch {\n // Detached between the snapshot and the lookup: unknown, so not shown.\n return undefined;\n } finally {\n await Promise.all(handles.map((h) => h.dispose().catch(() => {})));\n }\n };\n}\n\nconst DEFAULT_MAX_LINES = 200;\n\nfunction indentOf(line: string): number {\n return line.length - line.trimStart().length;\n}\n\n// A line whose role is a dialog, YAML single-quoted or not.\nconst DIALOG_LINE = /^\\s*- '?(?:dialog|alertdialog)(?=[\\s:\"']|$)/;\nconst OMITTED_LINE = /^\\s*- \\.\\.\\. \\(\\d+ lines? omitted: max_snapshot_lines is (\\d+)\\)$/m;\n\n/**\n * The cap a snapshot was cut at, read from its markers, or `undefined` when\n * nothing was omitted (design keep-the-open-dialog-in-the-snapshot, D3). Read\n * from the text so a step's reason cannot disagree with what the model saw.\n */\nexport function snapshotCutAt(snapshot: string): number | undefined {\n const match = OMITTED_LINE.exec(snapshot);\n return match ? Number(match[1]) : undefined;\n}\n\n/**\n * Which lines of an over-cap snapshot to keep (design\n * keep-the-open-dialog-in-the-snapshot, D1). Frameworks render dialogs, menus\n * and palettes in a portal at the end of `<body>`, so a cut from the top\n * dropped first the element the last action opened (#162). The open dialogs\n * (the last one, on top, first) and the focused element are kept with their\n * subtree and the lines they sit under; the rest of the cap is filled from the\n * top, as before. Never more than `maxLines`.\n */\nfunction linesToKeep(lines: string[], maxLines: number): Set<number> {\n const keep = new Set<number>();\n const subtreeEnd = (i: number): number => {\n let j = i + 1;\n while (j < lines.length && indentOf(lines[j]!) > indentOf(lines[i]!)) j++;\n return j;\n };\n const ancestors = (i: number): number[] => {\n const found: number[] = [];\n let indent = indentOf(lines[i]!);\n for (let j = i - 1; j >= 0 && indent > 0; j--) {\n if (indentOf(lines[j]!) < indent) {\n found.unshift(j);\n indent = indentOf(lines[j]!);\n }\n }\n return found;\n };\n\n const dialogs = lines.flatMap((line, i) => (DIALOG_LINE.test(line) ? [i] : [])).reverse();\n const focused = lines.flatMap((line, i) => (line.includes('[active]') ? [i] : []));\n for (const anchor of [...dialogs.slice(0, 1), ...focused, ...dialogs.slice(1)]) {\n for (const line of ancestors(anchor)) if (keep.size < maxLines) keep.add(line);\n for (let line = anchor; line < subtreeEnd(anchor) && keep.size < maxLines; line++) keep.add(line);\n }\n for (let line = 0; line < lines.length && keep.size < maxLines; line++) keep.add(line);\n return keep;\n}\n\n/**\n * Trims an aria snapshot: drops empty containers (e.g. `- group:` with no children)\n * and caps the line count. Over the cap, each run of omitted lines is replaced in\n * place by a marker naming the setting that cut it (design\n * keep-the-open-dialog-in-the-snapshot, D2). Pure function, exported for tests.\n */\nexport function trimSnapshot(snapshotYaml: string, maxLines: number = DEFAULT_MAX_LINES): string {\n let lines = snapshotYaml.split('\\n').filter((line) => line.trim().length > 0);\n\n // Removing empty containers can empty their parents; iterate until stable (bounded).\n for (let pass = 0; pass < 5; pass++) {\n const kept: string[] = [];\n let removed = 0;\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!;\n const isContainer = line.trimEnd().endsWith(':');\n if (isContainer) {\n const next = lines[i + 1];\n const hasChildren = next !== undefined && indentOf(next) > indentOf(line);\n if (!hasChildren) {\n removed++;\n continue;\n }\n }\n kept.push(line);\n }\n lines = kept;\n if (removed === 0) break;\n }\n\n if (lines.length <= maxLines) return lines.join('\\n');\n\n const keep = linesToKeep(lines, maxLines);\n const out: string[] = [];\n let omitted = 0;\n for (let i = 0; i <= lines.length; i++) {\n if (i < lines.length && !keep.has(i)) {\n omitted++;\n continue;\n }\n if (omitted > 0) {\n const indent = ' '.repeat(indentOf(lines[i - omitted]!));\n out.push(`${indent}- ... (${omitted} ${omitted === 1 ? 'line' : 'lines'} omitted: max_snapshot_lines is ${maxLines})`);\n omitted = 0;\n }\n if (i < lines.length) out.push(lines[i]!);\n }\n return out.join('\\n');\n}\n\n/**\n * Captures the current page as a compact accessibility snapshot (design D1),\n * prefixed with the page URL so the model can reason about navigation.\n *\n * Always in AI mode (design act-on-the-element-the-model-read, D3): every\n * element carries the `[ref=…]` an action names it by, and a plain\n * `ariaSnapshot()` invalidates the refs of the last AI-mode one, measured. The\n * `[cursor=pointer]` marker it adds is dropped: it is about the mouse, not the\n * element, and it was most of the growth that was not a ref.\n */\nexport async function captureSnapshot(page: Page, options: SnapshotOptions): Promise<string> {\n const raw = await page.locator('body').ariaSnapshot({ mode: 'ai' });\n // Before the trim, so a hidden frame uses none of the line budget (design D1).\n const shown = await cutUndeclaredFrames(raw, frameChainOn(page), options.frames);\n return `url: ${page.url()}\\n${trimSnapshot(shown.replace(/ \\[cursor=pointer\\]/g, ''), options.maxLines)}`;\n}\n\nconst REF_MARKER = / \\[ref=[A-Za-z0-9_-]+\\]/g;\n\n/**\n * The snapshot as a reader that chooses no element sees it: the judge and the\n * planner (design act-on-the-element-the-model-read, D3). Refs are ids, not\n * page content, and the judge corpus's stored snapshots have none.\n */\nexport function withoutRefs(snapshot: string): string {\n return snapshot.replace(REF_MARKER, '');\n}\n\n/** What the snapshot line holding a ref shows about its element. */\nexport interface SnapshotElement {\n role: string;\n /** The accessible name, unquoted; absent when the line has none. */\n name?: string;\n /** Inline text after the colon (`- generic [ref=e4]: Promo code`), unquoted. */\n text?: string;\n}\n\n/** Undoes YAML double-quote escaping, the form a name containing `\"` is printed in. */\nfunction unquote(value: string): string {\n const trimmed = value.trim();\n if (trimmed.length >= 2 && trimmed.startsWith('\"') && trimmed.endsWith('\"')) {\n return trimmed.slice(1, -1).replace(/\\\\([\"\\\\])/g, '$1');\n }\n if (trimmed.length >= 2 && trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\")) {\n return trimmed.slice(1, -1).replace(/''/g, \"'\");\n }\n return trimmed;\n}\n\n// `- role \"name\" [attr] [ref=x] [attr]: inline text`, every part after the role optional.\nconst ELEMENT_LINE =\n /^\\s*- ([a-z][a-zA-Z]*)(?: (\"(?:[^\"\\\\]|\\\\.)*\"))?((?: \\[[^\\]]*\\])*)(?::(?: (.*))?)?$/;\n\n/** A snapshot line as an element: its role, quoted name, attribute group and text. */\nfunction parseElementLine(raw: string): RegExpExecArray | null {\n // YAML single-quotes a whole entry whose text holds `: `, as in\n // `- 'heading \"Notes on file: 1\" [level=2] [ref=e16]'`.\n const quoted = /^(\\s*- )'((?:[^']|'')*)'(:.*)?$/.exec(raw);\n const line = quoted ? `${quoted[1]}${quoted[2]!.replace(/''/g, \"'\")}${quoted[3] ?? ''}` : raw;\n return ELEMENT_LINE.exec(line);\n}\n\n/** The ref in a line's attribute group, never one its name or text spells out. */\nfunction lineRef(raw: string): string | undefined {\n const match = parseElementLine(raw);\n return match ? /\\[ref=([A-Za-z0-9_-]+)\\]/.exec(match[3] ?? '')?.[1] : undefined;\n}\n\n/**\n * Each ref in a snapshot, with the role and name its line shows (design\n * act-on-the-element-the-model-read, D2). Read from the snapshot text the model\n * was given, masked as it was, so what is checked and recorded is what the\n * model read and no secret enters the record.\n */\nexport function indexRefs(snapshot: string): Map<string, SnapshotElement> {\n const index = new Map<string, SnapshotElement>();\n for (const raw of snapshot.split('\\n')) {\n const match = parseElementLine(raw);\n if (!match) continue;\n const ref = /\\[ref=([A-Za-z0-9_-]+)\\]/.exec(match[3] ?? '')?.[1];\n if (!ref) continue;\n const element: SnapshotElement = { role: match[1]! };\n if (match[2] !== undefined) element.name = unquote(match[2]);\n if (match[4] !== undefined && match[4].trim() !== '') element.text = unquote(match[4]);\n index.set(ref, element);\n }\n return index;\n}\n\n/** The roles whose line holds a value someone typed or chose. */\nexport const FIELD_ROLES: ReadonlySet<string> = new Set(['textbox', 'searchbox', 'combobox', 'spinbutton']);\n\n/** A field line of a snapshot, and whether it shows a value. */\nexport interface SnapshotField {\n role: string;\n name: string;\n filled: boolean;\n}\n\n/**\n * The fields a snapshot shows, each with whether it holds a value (design\n * refuse-the-same-submit-twice, D3). A value is printed inline\n * (`- textbox \"Note\": Check the invoice`) or, when the field has a placeholder\n * too, as a `- text:` line under it. A `/placeholder` line is not a value.\n */\nexport function snapshotFields(snapshot: string): SnapshotField[] {\n const lines = snapshot.split('\\n');\n const indentOf = (line: string): number => line.length - line.trimStart().length;\n const fields: SnapshotField[] = [];\n for (let i = 0; i < lines.length; i++) {\n const match = parseElementLine(lines[i]!);\n if (!match || !FIELD_ROLES.has(match[1]!)) continue;\n let filled = match[4] !== undefined && match[4].trim() !== '';\n const indent = indentOf(lines[i]!);\n // Its own lines only: text deeper down belongs to a popup or an option.\n const childIndent = i + 1 < lines.length ? indentOf(lines[i + 1]!) : 0;\n for (let j = i + 1; !filled && j < lines.length && indentOf(lines[j]!) > indent; j++) {\n if (indentOf(lines[j]!) !== childIndent) continue;\n const child = parseElementLine(lines[j]!);\n filled = child?.[1] === 'text' && child[4] !== undefined && child[4].trim() !== '';\n }\n fields.push({ role: match[1]!, name: match[2] === undefined ? '' : unquote(match[2]), filled });\n }\n return fields;\n}\n"],"mappings":";;;AAiDO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AA2BA,IAAM,aAAa;AASZ,SAAS,kBAAkB,SAAiB,gBAAmD;AACpG,QAAM,UAAU,oBAAI,IAAY,CAAC,IAAI,IAAI,OAAO,EAAE,MAAM,CAAC;AACzD,aAAW,UAAU,kBAAkB,CAAC,GAAG;AACzC,YAAQ,IAAI,IAAI,IAAI,MAAM,EAAE,MAAM;AAAA,EACpC;AACA,SAAO;AACT;AAWO,SAAS,gBAAgB,KAAa,SAAuC;AAClF,MAAI,QAAQ,WAAY,QAAO;AAC/B,MAAI;AACJ,MAAI;AACF,aAAS,IAAI,IAAI,GAAG,EAAE;AAAA,EACxB,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,WAAW,OAAQ,QAAO;AAC9B,SAAO,QAAQ,IAAI,MAAM;AAC3B;AAGO,SAAS,iBAAiB,SAAsC;AACrE,SAAO,CAAC,GAAG,OAAO,EAAE,KAAK,MAAM;AACjC;AAaA,SAAS,oBAAoB,KAAU,KAA0B;AAC/D,QAAM,UAAU,kBAAkB,IAAI,SAAS,IAAI,cAAc;AACjE,MAAI,CAAC,gBAAgB,IAAI,SAAS,GAAG,OAAO,GAAG;AAC7C,UAAM,IAAI;AAAA,MACR,iDAAiD,IAAI,MAAM,WAAW,iBAAiB,OAAO,CAAC;AAAA,IAEjG;AAAA,EACF;AACF;AAEA,SAAS,eAAe,QAA6B;AACnD,QAAM,QAAkB,CAAC;AACzB,MAAI,OAAO,KAAM,OAAM,KAAK,QAAQ,OAAO,IAAI,EAAE;AACjD,MAAI,OAAO,KAAM,OAAM,KAAK,SAAS,OAAO,IAAI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